akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <fstream>

using namespace std;
#define intMax 2147483647
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repp(i, a, b) for (int i = a; i >= b; i--)
#define be(a) (a.begin(), a.end())
#define rbe(p) (p.rbegin(), p.rend())
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a;
    cin >> a;
    string s;
    cin >> s;
    int counter = 0;
    rep(i,0,a-2){
        if ( s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' ){
            counter++;
        }
    }
    cout << counter;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

// ここまで

fn dijkstra(src: usize, g: &Vec<Vec<(usize, u32)>>) -> Vec<u64> {
    let inf: u64 = 10000000000000000;
    let mut dp = vec![inf; g.len()];
    dp[src] = 0;
    let mut h = std::collections::BinaryHeap::<(i64, usize)>::new();
    h.push((0, src));
    while let Some((d, v)) = h.pop() {
        let d = (-d) as u64;
        if d > dp[v] {
            continue;
        }
        for &(u, t) in &g[v] {
            let c = d + t as u64;
            if c < dp[u] {
                dp[u] = c;
                h.push((-(c as i64), u));
            }
        }
    }
    dp
}

use std::io::BufWriter;
use std::io::Write;

fn run() {
    input! {
        n: usize,
        m: usize,
        s: usize1,
        t: usize1,
        e: [(usize1, usize1, u32, u32); m],
    }
    let mut g = vec![vec![]; n];
    let mut h = vec![vec![]; n];
    for (u, v, a, b) in e {
        g[u].push((v, a));
        g[v].push((u, a));
        h[u].push((v, b));
        h[v].push((u, b));
    }
    let x = dijkstra(s, &g);
    let y = dijkstra(t, &h);
    let mut prev = 0;
    let mut ans = vec![0; n];
    for ((x, y), dp) in x.iter().zip(y.iter()).zip(ans.iter_mut()).rev() {
        let z = 1000000000000000 - (*x + *y);
        prev = std::cmp::max(prev, z);
        *dp = prev;
    }
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    for ans in ans {
        writeln!(out, "{}", ans).unwrap();
    }
}

fn main() {
    run();
}


Measured memory_bytes: 36596
package main

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

var INF = math.MaxInt32
var INF64 = math.MaxInt64

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func readLineFloats(bf *bufio.Reader) []float64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []float64{}
	for _, field := range fields {
		num, _ := strconv.ParseFloat(field, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineStrs(bf *bufio.Reader) []string {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	return strings.Split(line, " ")
}

func dfs(v int, indegrees []int, dists []int, edges map[int][]int, visits []bool) {
	visits[v] = true
	for _, nv := range edges[v] {
		dists[nv] = max(dists[nv], dists[v]+1)
		indegrees[nv]--
		if indegrees[nv] == 0 {
			dfs(nv, indegrees, dists, edges, visits)
		}
	}
}

func main() {
	bf := bufio.NewReader(os.Stdin)
	nm := readLineNums(bf)
	N, M := nm[0], nm[1]
	indegrees := make([]int, N+1) // 每个节点的入度
	dists := make([]int, N+1) // 开始节点(虚拟节点)到每个节点距离
	edges := make(map[int][]int)
	visits := make([]bool, N+1) // BUG: visit是必须记录的, 防止节点被重复遍历
	for i:=0; i<M; i++ {
		ft := readLineNums(bf)
		if _, ok := edges[ft[0]]; !ok {
			edges[ft[0]] = make([]int, 0)
		}
		edges[ft[0]] = append(edges[ft[0]], ft[1])
		indegrees[ft[1]]++
	}

	for i:=1; i<=N; i++ {
		if indegrees[i] == 0 && !visits[i] {
			dfs(i, indegrees, dists, edges, visits)
		}
	}

	ans := 0
	for i:=1; i<=N; i++ {
		ans = max(ans, dists[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 63104
a, b, c = map(int, input().split())
max_abc = max(a, b, c)
ma = (max_abc - a) / 2
mb = (max_abc - b) / 2
mc = (max_abc - c) / 2
if (ma+mb+mc)%2 == 0:
    print(int(ma+mb+mc))
elif (ma+mb+mc) == max_abc:
    print(max_abc)
else:
    total = int(ma) + int(mb) + int(mc) + ((ma-int(ma))*4) + ((mb-int(mb))*4) + ((mc-int(mc))*4)
    print(int(total))

Measured memory_bytes: 3064
N, = map(int, input().split())
R = [0] * (N**2+1)
V = [0] * (N**2+1)
X = list(map(int, input().split()))
for ai in range(N**2):
    i, j = divmod(ai, N)
    R[ai+1] = min([i, N-i-1, j, N-j-1])

r = 0
for a in X:
    r += R[a]
    V[a] = 1
    stack=[a]
    while stack:
        v = stack.pop()
        if v>N:
            if not(R[v]>=R[v-N] or ((1-V[v]) and R[v]+1 >= R[v-N])):
                R[v-N] -= 1
                stack.append(v-N)
        if v<N**2+1-N:
            if not(R[v]>=R[v+N] or ((1-V[v]) and R[v]+1 >= R[v+N])):
                R[v+N] -= 1
                stack.append(v+N)
        if v%N:
            if not(R[v]>=R[v+1] or ((1-V[v]) and R[v]+1 >= R[v+1])):
                R[v+1] -= 1
                stack.append(v+1)
        if v%N!=1:
            if not(R[v]>=R[v-1] or ((1-V[v]) and R[v]+1 >= R[v-1])):
                R[v-1] -= 1
                stack.append(v-1)
print(r)


Measured memory_bytes: 158600
N = int(input())
A = list(map(int, input().split()))
from collections import Counter
MOD = 10**9+7
def is_ok(n, a_list):
    if N%2==0:
        # even
        c = Counter(a_list)
        for a in a_list:
            if a%2==0:
                return False
            elif c[a] != 2:
                return False
    else:
        # odd
        c = Counter(a_list)
        for a in a_list:
            if a%2==1:
                return False
            elif a == 0:
                if c[a]!=1:
                    return False
            elif c[a] != 2:
                return False
    
    return True


if (is_ok(N, A)):
    print((2**(N//2))%MOD if N%2==0 else (2**((N-1)//2))%MOD)
else:
    print(0)

Measured memory_bytes: 14692
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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


int main()
{
	double d, px, py, vx, vy;
	while (cin >> d, d > 1e-9)
	{
		cin >> px >> py >> vx >> vy;
		double p = hypot(px, py), v = hypot(vx, vy);
		double cs = (px*vx + py*vy)/p/v;
		if (abs(abs(cs) - 1) > 1e-9)
			d = 0;

		double res;
		if (cs < 0)
			res = p;
		else
			res = (1 - p) + 1;

		if (res < d - 1e-5)
			printf("%.9f\n", res);
		else
			puts("impossible");
	}
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val s = readLine()!!
    val dp = Array(s.length+1) {Array(13) {0L} }
    val mod = 1000000007L
    dp[0][0] = 1L
    for (i in 0 until s.length) {
        for (j in 0 until 13) {
            if (s[i] == '?') {
                for(k in 0..9) {
                    dp[i+1][(j*10 + k) % 13] += dp[i][j]%mod
                }
            } else {
                dp[i+1][(j*10 + (s[i] - '0')) % 13] += dp[i][j]%mod
            }
        }
    }
    println(dp[s.length][5]%mod)
}

Measured memory_bytes: 148192
#include<iostream>
using namespace std;
int a[3],size;
void to(int c)
{
	int i=0;
	while(c>0){
		a[i++]=c%10;c/=10;
	}
	size=i-1;
	int j=size;
	i=0;
	while(j>=0){
		if(a[size]<a[i++]){
			a[size]++;
			return ;
		}
		j--;
	}
}
int main(void)
{
	int N;
	cin >> N;
	to(N);
	int j=size;
	
	while(j>=0){
		cout << a[size];
		j--;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>

int main() {
    std::string s;

    std::cin >> s;

    char now_color = s[0];
    int ans = 0;
    for (int i = 1; i < s.length(); i++) {
        if (now_color != s[i]) {
            now_color = s[i];
            ans++;
        }
    }

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

Measured memory_bytes: 512
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
kouho=[]
for i in range(x):
	kouho.append(p[i])
for i in range(y):
	kouho.append(q[i])
kouho.sort()
j=0
for i in range(len(kouho)):
	if kouho[i]<r[j]:
		kouho[i]=r[j]
		j+=1
		if j==c:
			break
print(sum(kouho))

Measured memory_bytes: 23328
import math
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

def order(l):
    ans=0
    a=list(range(N))
    for i in range(N):
        ans+= a[l[i]-1]*math.factorial(N-1-i)
        for j in range(l[i],N):
            a[j]-=1
    return ans
p=order(P)
q=order(Q)
print(abs(p-q))

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

#define ll long long

const int mxN = 1e5;
ll N, h[mxN], dp[mxN];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for(int i = 0; i < N; ++i)
		cin >> h[i];
	for(int i = 1; i < N; ++i){
		dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
		if(i>=2)
			dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[N-1] << '\n';
	return 0;
}



Measured memory_bytes: 5152
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC opatimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int main() {
//    freopen("in.txt","r", stdin);
//    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long x;
    cin >> x;
    long long ans = 0;
    if (x % 2 == 0) {
        while (x > 0) {
            ans += x / 5 / 2;
            x /= 5;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        while(!isPrime(x))x++;
        System.out.println(x);
    }
    static boolean isPrime(int x) {
        if(x <= 1) return false;
        for(int i = 2; i * i <= x; i++) {
            if(x % i == 0) return false;
        }
        return true;
    }
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  int a ,b;
  cin >> a>> b;
  cout << (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0 ? "Possible" : "Impossible") << LF;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
 
typedef long long ll;
 
 
int main(){
	unsigned long long  n;
	cin >> n;
	unsigned long long res = 0;
	n-=1;
	
	res = (n*(n+1))/2;
	
	
	cout << res <<endl;
	
	
	return 0;
}



Measured memory_bytes: 256
import numpy as np
A,B=np.array(list(map(int, input().split())))
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    
C=np.array(prime_factorize(gcd(A,B)))
print(len(np.unique(C))+1)

Measured memory_bytes: 21272
//https://atcoder.jp/contests/abc155/tasks/abc155_b

#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <algorithm>

using namespace std;

int main ()
{

    int N;
    bool permission;
    cin >> N;

    vector <int> arrayNum(N);

    for (int i = 0; i < N; ++i)
    {
        cin >> arrayNum.at(i);
    }

    for (int i = 0; i < N; ++i)
    {
        if (arrayNum.at(i) % 2 == 0)
        {
            if (arrayNum.at(i) % 3 == 0 || arrayNum.at(i) % 5 == 0)
            {
                permission = true;
            } else
            {
                permission = false;
                break;
            }
        }
    }

    if (permission)
    {
        cout << "APPROVED" << endl;
    } else
    {
        cout << "DENIED" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll r, D, x;
    cin >> r >> D >> x;
    rep(i,10) {
        x = r * x - D;
        cout << x << endl;
    }
}

Measured memory_bytes: 764
#include<stdio.h>
int main(){
    char strt[100];
    char *ptime=strt;
    int i=0;
    int j=0;
    int flag=0;
    int ttl=0;
    int a[3] = {0};
    int tmp=0;
    char strflag[4][10] = {0};
    fgets(strt, sizeof(strt), stdin);
     
    //数字をすべてchar型で読み込みstrflagに一文字ずつ格納していっている。
    while(*ptime){
        //改行文字削除して文字列の最後にNULLを入れる
        if(*ptime=='\n'){
            *ptime='\0';
        }else if(*ptime==' '){  //ひとまとまりの数字を読み込むとflagをインクリメントすることで、flagと数字のまとまりを対応させる
            flag++;
            i=0;
            ptime++;
        }else{
            strflag[flag][i]=*ptime;
            i++;
            ptime++;
        }
    }
     
    /*
    if(atoi(&strflag[0]) > atoi(&strflag[1]) ) printf("a > b\n");
    else if(atoi(&strflag[0])< atoi(&strflag[1]) ) printf("a < b\n");
    else printf("a == b\n");
    */
    
    /*
    if( atoi(&strflag[0]) < atoi(&strflag[1]) && atoi(&strflag[1]) < atoi(&strflag[2]) ){
       printf("Yes\n");
       exit(0);
    }
    printf("No\n");
    */
    
    for(i=0; i<3; ++i) a[i] =atoi(&strflag[i]);
    
    for (i=0; i<3; ++i) {
       for (j=i+1; j<3; ++j) {
          if (a[i] > a[j]) {
             tmp = a[i];
             a[i] = a[j];
             a[j] = tmp;
          }
       }
    }
    
    for (i=0; i<2; i++) printf("%d ",a[i]);
    printf("%d\n",a[2]);
    
    
    /*
    for (i=0; i<3; i++){
       ttl+=atoi(&strflag[i]);
    }
    printf("TTL:%d\n",ttl);
    */
    
    
}


Measured memory_bytes: 2140
#include <iostream>


int main()
{
    int n,v;
    long total=0;
    int max=-1000001;
    int min=1000001;
    std::cin >> n;
    for(int a=0;a<n;a++){
        std::cin >> v;
        total=total+v;
        if(v>max)max=v;
        if(v<min)min=v;
    }
    std::cout << min << " " << max << " " << total << std::endl;

    return 0;
}

Measured memory_bytes: 3100
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

toSet = map head . group . sort 
lunion xs [] = xs
lunion [] ys = ys
lunion xa@(x:xs) ya@(y:ys)
  | x<y = x : lunion xs ya
  | x>y = y : lunion xa ys
  | otherwise = x : lunion xs ys

lsearch t [] = False
lsearch t (x:xs)
  | t==x = True
  | t<x = False
  | otherwise = lsearch t xs

main = do
    n <- getInt
    when (n/=0) $ do
        m <- getInt
        rel <- map (apply2 (,)) <$> replicateM m getInts
        let friends = toSet $ [y | (x, y) <- rel, x==1] ++ [x | (x, y) <- rel, y==1]
        let frifriends = toSet $ [y | (x, y) <- rel, y/=1, lsearch x friends] ++ [x | (x, y) <- rel, x/=1, lsearch y friends]
        print $ length $ lunion friends frifriends
        main

Measured memory_bytes: 11288
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

constexpr ll mod = 1e9 + 7;
ll fact[2000010], facti[2000010];
ll pow(ll n, ll e) {
	ll v = 1;
	while (e) {
		if (e & 1)
			v = (v * n) % mod;
		n = (n * n) % mod;
		e /= 2;
	}
	return v;
}
ll comb(ll n, ll r) {
	return (fact[n] * facti[n - r] % mod) * facti[r] % mod;
}
ll f(ll r, ll c) {
	ll s = 0;
	for (int i = 0; i <= r; i++)
		s += comb(i + c, c);
	for (int i = 0; i <= c; i++)
		s += comb(i + r, r);
	return (s - 1 + mod) % mod;
}

int c1, c2, r1, r2;
int main() {
	scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
	fact[0] = 1;
	for (int i = 1; i <= 2000000; i++)
		fact[i] = fact[i - 1] * i % mod;
	facti[2000000] = pow(fact[2000000], mod - 2);
	for (int i = 2000000; 1 <= i; i--)
		facti[i - 1] = facti[i] * i % mod;
	printf("%lld\n", ((f(r2,c2) - f(r2,c1-1) - f(r1-1, c2) + f(r1-1, c1-1)) % mod + mod) % mod);
}

Measured memory_bytes: 31488
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

using namespace std;


int main() {
	
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
		cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string s;
	int a=0,b=0;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='Z'){
			b=i;
			break;
		}
	}
	cout << b-a+1 << endl;
}

Measured memory_bytes: 832
#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 pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

int main() {
    int n,d;
    cin >> n >> d;
    int cnt = d+1;
    int ans=0;
    bool flag = true;
    while (flag){
      cnt += d;
      if (cnt >= n) flag = false;
      ans ++;
      cnt += d+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
h,w,k=map(int,input().split())
c=[list(input()) for _ in range(h)]
ans=0
for i in range(2**h):
    for j in range(2**w):
        black=0
        for m in range(h):
            for n in range(w):
                if (i>>m)&1==0 and (j>>n)&1==0 and c[m][n]=='#':
                    black+=1
        if black==k:
            ans+=1
print(ans)

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

int main(){
  ll n,k;
  std::cin >> k>>n;
  std::vector<ll> a(n);

  rep(i,n)std::cin >> a[i];
  sort(a.begin(),a.end());

  int maxd=0;
  ll ans=0;
  rep(i,n-1){
    int temp=a[i+1]-a[i];
    ans+=temp;
    maxd=max(maxd,temp);
  }
  int temp=k-a[n-1]+a[0];
  ans+=temp;
  maxd=max(maxd,temp);

  std::cout << ans-maxd << '\n';



  return 0;
}


Measured memory_bytes: 1792
import sys
import copy
from collections import deque
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x, n = na()
p = na()

res = 0
for i in range(102):
    if abs(i-x)<abs(res-x):
        if not i in p:
            res = i


print(res)

Measured memory_bytes: 68228
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

MOD = 1000000007

def smax(a,b):
    if a>b:
        return a
    else:
        return b

def smin(a,b):
    if a<b:
        return a
    else:
        return b

def gcd(a,b):
    a,b = smax(a,b),smin(a,b)
    while a%b!=0:
        a,b = b,a%b
    return b

from collections import defaultdict

def main():
    K = int(readline())
    dd = defaultdict(int)

    for i in range(1,K+1):
        for j in range(1,K+1):
            dd[gcd(i,j)]+=1

    ans = 0
    for key in dd:
        for k in range(1,K+1):
            ans += dd[key]*gcd(key,k)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 68760
n = int(input())
a = list(map(int, input().split()))

ans = 0
i = 0

while i < n:
    if i == n - 1:
        ans += 1
        break

    # 増加
    plus = 0
    while i + plus + 1 < n:
        if a[i + plus] <= a[i + plus + 1]:
            plus += 1
        else:
            break

    # 減少
    minus = 0
    while i + minus+1 < n:
        if a[i + minus] >= a[i + minus+1]:
            minus += 1
        else:
            break

    ans += 1
    if plus >= minus:
        i += plus + 1
    else:
        i += minus + 1


print(ans)


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
string s;
void solve(){
	cin >> n >> s;
	
	i64 ans = 0;
	int b[26] = {0};
	for(int i = 0; i < n; i++){
		i64 cnt = 1;
		for(int j = 0; j < 26; j++){
			if(s[i]-'a' == j) continue;
			else cnt *= b[j]+1;
			cnt %= INF;
		}
		ans += cnt;
		ans %= INF;
		b[s[i]-'a']++;
		//cout << ans << endl;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ar[n],i,j;
     for(i=0;i<n;i++)
        cin>>ar[i];
    for(i=0;i<n;i++)
    {
        for(j=0;j<n-1;j++)
        {
            if(ar[j]>ar[j+1])
            swap(ar[j],ar[j+1]);
        }
    }
    float di,d;
    di=ar[0];
    for(i=1;i<n;i++)
     {

         d=di+ar[i];
         di=d/2;

     }
     cout<<di<<endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool prime[1000000];
void sieve() {
    fill_n(prime, 1000000, true);
    for (int i=2; i<=1000; ++i) {
        if (prime[i]) {
            for (int j=i*i; j<1000000; j+=i) {
                prime[j] = false;
            }
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    sieve();

    int memo[1000000];
    for (int i=1; i<1000000; ++i) {
        memo[i] = memo[i-1]; 
        if (prime[i]) {
            memo[i] ++; 
        }
    }

    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i=2; i<=n; ++i) {
            if (prime[i]) {
                cnt ++;
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,total=0,cnt=0;
    cin>>n>>m;
    int a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        total+=a[i];
    }
    //double k=4*m;
    //double b= (total/k);
    double b=ceil(total/(4.0*m));
    for(int i=0; i<n; i++)
    {
        if(a[i]>=b)
        {
            cnt++;
        }

    }

    if(cnt>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;
 
typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no { cout << -1; return; }

void solve() {
    int n; cin >> n;
    cout << n * (n + 1) / 2 - ((n / 3) * (n / 3 + 1) / 2) * 3
    - ((n / 5) * (n / 5 + 1) / 2) * 5 + ((n / 15) * (n / 15 + 1) / 2) * 15;
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3636
<?php
$arr = explode(' ', trim(fgets(STDIN)));

$n = $arr[0];
$k = $arr[1];

$a_arr = array();
for ($i=0; $i < $k; $i++) { 
    $d = trim(fgets(STDIN));
    $a_arr = array_merge($a_arr,explode(' ', trim(fgets(STDIN))));
}
$a_arr = array_unique($a_arr);

$a_ct = count($a_arr);

echo $n - $a_ct;
return;

?>


Measured memory_bytes: 17584
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int get()
{
	int h,m;
	scanf("%d %d",&h,&m);
	return h*60+m;
}
int main()
{
	int s=get(),t=get();
	int k;
	scanf("%d",&k);
	printf("%d\n",t-s-k);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	ll n; cin >> n;
	ll ans = 1e18;

	for(ll i = 1; i*i <= n; i++){
		if(n%i == 0){
			ans = min(ans, i+n/i-2);
		}
	}

	cout << ans << '\n';
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  for (int i = 1; i <= 9; i++) {
    if (N % i == 0 && N / i <= 9) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 888
import sys
while True:
    (H, W) = [int(i) for i in sys.stdin.readline().split()]
    if H == W == 0:
        break
    print("#" * W)
    print(("#" + "." * (W - 2) + "#" + "\n") * (H - 2), end="")
    print("#" * W + "\n")

Measured memory_bytes: 6796
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int H[N];
  for(int i=0;i<N;i++){
    cin >> H[i];
  }

  sort(H,H+N,greater<int>());

  long long int times = 0;
  for(int i=0;i<N;i++){
    if(i<K) H[i] = 0;
    times += H[i];
  }

  cout << times << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
 
int main(void){
    int a,b,c;
    int i,count;
    count = 0;
    while(scanf("%d%d%d",&a,&b,&c)==3){
        //if(!x&&!y) return 0;
    for(i=a;i<=b;i++){
        if(c%i == 0) count++;
    }
    printf("%d\n",count);
    return 0;
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;

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

int main(){
    int N;
    cin >> N;
    vector<int> ss(N, 0);
    vector<int> fs(N, 0);
    vector<int> cs(N, 0);
    rep(i, N - 1){
        cin >> cs[i] >> ss[i] >> fs[i];
    }

    rep(i, N){
        int ans = 0;
        for(int j = i; j < N - 1; j++){
            int tmp = (ans + fs[j] - 1) / fs[j];
            ans = max(tmp * fs[j], ss[j]);//出発時間をセット
            ans += cs[j];//次の駅までの所用時間をたす
        }
        cout << ans << endl;
    }

    return 0;
}


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

#include <atcoder/all>

using namespace std;
using namespace atcoder;

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

constexpr int INF = TEN(9);

int op(int x, int y) { return max(x, y); }

int e() { return 0; }

const int MX = 300010;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;

    segtree<int, op, e> seg(MX);
    int ans = 0;

    rep(i, N) {
        int x;
        cin >> x;
        int l = max(0, x - K);
        int r = min(MX, x + K + 1);
        int g = seg.prod(l, r);
        int d = g + 1;
        seg.set(x, d);
        chmax(ans, d);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8472
N = int(input())
A = list(map(int, input().split()))
A.sort()
import itertools
a = [len(list(l)) % 2 for k, l in itertools.groupby(A)]
ans = len(a)
if len([x for x in a if x == 0]) % 2 == 1:
    ans -= 1
print(ans)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
   int main(){
     cout<<fixed<<setprecision(6);
     
     double r;
     cin>>r;

     double PI =acos(-1);
     double area = r*r*PI;
     double cir =(r+r)*PI;
     cout<<area<<" "<<cir<<endl;


    return 0;
}


Measured memory_bytes: 3288
import collections

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

gokei = 0
counter = collections.Counter(A)
for i in counter.values():
    gokei += i * (i - 1) // 2

ans = [0]*(N+1)
for i in range(N):
    z = A[i]
    d = counter[z]
    if ans[z] == 0:
        e = gokei - (d * (d - 1) // 2 - (d-1) * (d - 2) // 2)
        ans.append(e)
        print(e)
    else:
        print(ans[z])

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

int main(int argc, char *argv[]){
  long long N,A;
  cin>>N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin>>A;
    vec[i]=A;
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<N; ){
    for(int j=1; j<N; j++){
      vec[j]=vec[j]%vec[0];
      if(vec[j]==0){
	vec.erase(vec.begin()+j);
	if(vec.size()==1) break;
	N--;
	j--;
	i--;
      }
    }
    if(vec.size()==1) break;
      sort(vec.begin(),vec.end());
    }
  
  
  cout<<vec[0]<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int n;
cin>>n;
int a=0;
string s;
while(n>0){
	n=n-1;
	s+=char('a'+n%26);
	
	n=n/26;
}
int i=s.length()-1;
string s1="";
while(i>=0){
	s1+=s[i];
	i--;
	
}
cout<<s1<<endl;
  
 
}

Measured memory_bytes: 3612
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
s = RS()

cw = 0
lw = []
for i in range(n):
    if s[i]=='W':
        cw += 1
        lw.append(cw)
    else:
        lw.append(cw)
# print(lw)

sr = list(reversed(s))
# print(sr)
ce = 0
le = []
for i in range(n):
    if sr[i]=='E':
        ce += 1
        le.append(ce)
    else:
        le.append(ce)
le = list(reversed(le))
# print(le)

ls = []
for i in range(n):
    k = lw[i] + le[i] - 1
    ls.append(k)
# print(ls)

ans = min(ls)
print(ans)

Measured memory_bytes: 162296
from collections import Counter
from functools import lru_cache


@lru_cache(maxsize=None)
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


@lru_cache(maxsize=None)
def lcm(a, b):
    """
    aとbの最小公倍数を計算する
    """
    from math import gcd

    return a * b // gcd(a, b)


N = int(input())
A = tuple(map(int, input().split(' ')))

counter = Counter()
for a in A:
    for d in get_dividers(a):
        counter[d] += 1

ans = 1
candidates = []
for key, value in counter.items():
    if value == N:
        ans = lcm(ans, key)
    elif value == N - 1:
        candidates.append(key)

if candidates:
    ans = max([lcm(ans, c) for c in candidates])

print(ans)


Measured memory_bytes: 89272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const double pi=acos(-1);
const int maxn=2e5+5;
double a[10],b[10];
double qjl(int x,int y)
{
    return sqrt((a[x]-a[y])*(a[x]-a[y])+(b[x]-b[y])*(b[x]-b[y]));
}
int main()
{
    int n;
    sint(n);
    for(int i=0; i<n; i++)
        scanf("%lf %lf",&a[i],&b[i]);
    int s=2;
    for(int i=1; i<=n-2; i++)
        s*=i;
    double sum=0;
    for(int i=0; i<n-1; i++)
        for(int j=i+1; j<n; j++)
            sum+=qjl(i,j);
    printf("%f",2*sum/n);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    string s,t,u;
    cin >> s >> t >> u;
    cout << s[0] << t[1] << u[2] << 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() {
  int N, X, T;
  cin >> N >> X >> T;
  int ans = (((N - 1) / X) + 1) * T;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    let s = buf.trim();
    if &s[(s.len()-1)..s.len()] == "s" {
        println!("{}es", s);
    }else{
        println!("{}s", s);
    }
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <sstream>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int M;
std::vector<P> results;

int main(){
    while(std::cin >> M, M != 0){
        results.clear();

        REP(i, M){
            int id;
            std::cin >> id;

            scanf("%*c");

            int pins[30], length = 0;
            {
                std::string s;
                std::getline(std::cin, s);
            
                std::stringstream ss(s);
                while(std::getline(ss, s, ' ')){
                    pins[length] = std::stoi(s);
                    length += 1;
                }
            }

            int points = 0;
            {
                int frame = 0, index = 0;
                while(frame < 10){
                    if(frame == 9){
                        if(index+3 == length){
                            points += pins[index] + pins[index+1] + pins[index+2];
                        }else{
                            points += pins[index] + pins[index+1];
                        }
                    }else{
                        if(pins[index] == 10){
                            points += 10;
                            if(index+2 < length){points += pins[index+1] + pins[index+2]; index += 1;}
                            else if(index+1 < length){points += pins[index+1]; index += 1;}
                        }else if(index+1 < length && pins[index] + pins[index+1] == 10){
                            points += 10;
                            if(index+2 < length){points += pins[index+2]; index += 2;}
                        }else{
                            points += pins[index] + pins[index+1];
                            index += 2;
                        }
                    }

                    frame += 1;
                }
            }

            results.push_back(mp(points, id));
        }

        std::sort(results.begin(), results.end(),
                  [](const P& lhs, const P& rhs){if(lhs.first != rhs.first){return lhs.first > rhs.first;} return lhs.second < rhs.second;});


        REP(i, M){
            printf("%d %d\n", results[i].second, results[i].first);
        }
    }
}

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

int main(){
    int a,b;
    string s;

    cin>>a>>b>>s;

    if(s[a] == '-'){
        for(int i=0; i < a; i++){
            if(s[i] == '-'){
                cout<<"No\n";
                return 0;
            }
        }

        for(int i = a+1; i < a+b+1;i++){
            if(s[i] == '-'){
                cout<<"No\n";
                return 0;
            }
        }
        cout<<"Yes\n";
    }

    else cout<<"No\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int n;
	cin >> n;
	int mn = 1e9+7;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(x < mn)
			ans++, mn = x;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
import sys
x,y=map(int,input().split())
if x==1:
    if 2*x==y or 4*x==y:
        print('Yes')
        sys.exit()
for i in range(x+1):
  if 2*x>y:
    break
  if 2*i+4*(x-i)==y:
    print('Yes')
    sys.exit()
 
print('No')

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

#define SQ(a) ((a) * (a))

int main(void)
{
	int n; 								/* üèûÌÂ */
	int vertical, horizontal, height;	/* Éc, ¡, ·³ */
	int radius;							/* üèûÌ¼a */
	int i;								/* [vpÏ */
	
	while (1){
		
		scanf("%d %d %d", &vertical, &horizontal, &height);
		
		if (vertical == 0 && horizontal == 0 && height == 0){
			break;
		}
		
		scanf("%d", &n);
		
		radius = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d", &radius);
			
			if (sqrt(SQ((float)horizontal)+SQ((float)height)) < 2 * (float) radius ){ 
				printf("OK\n");
			}
			else {
				printf("NA\n");
			}
		}
		
	}
	
	return (0);
}

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

int main(){
  string s;
  cin>>s;
  int i = 0;
  while(1){
    if(s[i]=='A')break;
    i++;
  }

  int j = i;
  int ans;
  while(1){
    if(s.size()<j)break;
    if(s[j]=='Z')ans=j;
    j++;
  }
  ans++;
  cout<<ans-i<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){

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

  int inspect = d*2+1;
  int answer;
  if (n%inspect == 0) {
    answer = n/inspect;
  } else {
    answer = n/inspect+1;
  }

  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
print = sys.stdout.write

class Node:
    __slots__ = ["data", "left", "right"]
    def __init__(self, data):
        self.data = data
        self.left = None
        self.right = None

class BinarySearchTree:
    __slots__ = ["root"]
    def __init__(self):
        self.root = None
    
    def insert(self, data):
        parent = self.root
        if parent is None:
            self.root = Node(data)
            return
        while parent:
            parent_old = parent
            parent = parent.left if data < parent.data else parent.right
        if data < parent_old.data:
            parent_old.left = Node(data)
        else:
            parent_old.right = Node(data)
        
    def find(self, data):
        parent = self.root
        if parent is None:
            print("no\n")
            return
        while parent:
            if parent.data == data:
                print("yes\n")
                return
            parent = parent.left if data < parent.data else parent.right
        print("no\n")
        return


def print_preorder(node):
    print(" {}".format(node.data))
    if node.left:
        print_preorder(node.left)
    if node.right:
        print_preorder(node.right)

def print_inorder(node):
    if node.left:
        print_inorder(node.left)
    print(" {}".format(node.data))
    if node.right:
        print_inorder(node.right)

if __name__ == "__main__":
    n = int(input())
    binary_search_tree = BinarySearchTree()
    for _ in range(n):
        operation, *num = input().split()
        if operation[0] == "i":
            binary_search_tree.insert(int(num[0]))
        elif operation[0] == "f":
            binary_search_tree.find(int(num[0]))
        elif binary_search_tree.root is not None:
            print_inorder(binary_search_tree.root)
            print("\n")
            print_preorder(binary_search_tree.root)
            print("\n")


Measured memory_bytes: 44152
#include <bits/stdc++.h>
#define P pair<int, int>

using namespace std;
const int INF=1e5;

int main(){
  long long n, a[100009];
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  long long delta=0, cnt=1;
  for(int i=1;i<n;i++){
    if(delta*(a[i]-a[i-1])<0){
      delta=0;
      cnt++;
    }
    else if(a[i]-a[i-1]!=0){
      delta=a[i]-a[i-1];
    }
  }
  cout << cnt << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=998244353;

const int MAX_N=303030;
ll inv[MAX_N+1], fact[MAX_N+1], ifact[MAX_N+1];

ll C(int n, int k){
  if(n<k) return 0;
  return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
}

void prepare(){
  inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1LL;
  for(int i=2;i<=MAX_N;i++){
    inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    fact[i]=fact[i-1]*i%MOD;
    ifact[i]=ifact[i-1]*inv[i]%MOD;
  }
}

int N;
ll A,B,K;

int main(){
  prepare();
  cin>>N>>A>>B>>K;
  ll ans=0;
  for(ll a=0;a<=N&&a*A<=K;a++){
    if((K-A*a)%B!=0) continue;
    ll b=(K-A*a)/B;
    ans+=(C(N,a)*C(N,b))%MOD;
    ans%=MOD;
    if(ans<0) ans+=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7296