akhauriyash/Code-Regression huggingface dataset:
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*///

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}


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 sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}

int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);

int n=RD(),d=RD(),x=2*d+1;
int ans=ceil(n*1.0/x);
cout<<ans<<"\n";

 }


Measured memory_bytes: 256
import sys
from collections import Counter

n, *a = map(int, sys.stdin.read().split())

def main():
    res = 0
    for v, c in Counter(a).items():
        if c < v:
            res += c
        elif c > v:
            res += c - v
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 18728
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    const char Wh = '.';
    const char Bl = '#';
    const char Sp = ' ';

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var h = int.Parse(spl[0]);
        var w = int.Parse(spl[1]);

        var aa = new char[h][];
        for(int i =0; i<h; i++) {
            var s = input.ReadLine();
            aa[i] = s.ToCharArray();
        }

        for(int i=0; i<h; i++) {
            var all = true;
            for(int j=0; j<w; j++) {
                if(aa[i][j] == Bl) {
                    all = false;
                    break;
                }
            }
            if (all) {
                for (int j = 0; j < w; j++) {
                    aa[i][j] = Sp;
                }
            }
        }

        for (int j = 0; j < w; j++) {
            var all = true;
            for (int i = 0; i < h; i++) {
                if (aa[i][j] == Bl) {
                    all = false;
                    break;
                }
            }
            if (all) {
                for (int i = 0; i < h; i++) {
                    aa[i][j] = Sp;
                }
            }
        }

        var sb = new StringBuilder();
        for (int i = 0; i < h; i++) {
            bool exist = false;
            for (int j = 0; j < w; j++) {
                if(aa[i][j] != Sp) {
                    sb.Append(aa[i][j]);
                    exist = true;
                }
            }
            if (exist) sb.AppendLine();
        }

        return sb;
    }
}


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

int main() {



	/*int n,m,d;
	cin >> n >> m >> d;

	for(int i=0; i<n; i++){
			string masu;
			cin >> masu;
		}
		*/
	for (int i=0; i<5; i++){
		int joi=0;
		int ioi=0;
		string s;
		cin >> s;

		for (int j=0; j<s.size(); j++){
			if(s[j] == 'J' && s[j+1] == 'O' && s[j+2] == 'I'){
				joi++;
			}
			if(s[j] == 'I' && s[j+1] == 'O' && s[j+2] == 'I'){
				ioi++;
			}
		}
		cout << joi << endl;
		cout << ioi << endl;
	}
	return 0;
}



Measured memory_bytes: 3024
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True
    #次見る頂点を格納するキュー
    queue=deque([s])
    visited_num=1

    #問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex=queue.popleft()
        #インデックスがない場合は
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



#n=int(input())
a=list(map(int,input().split()))
for i,v in enumerate(a):
    if v==0:
        print(i+1)
        exit()

Measured memory_bytes: 27128
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let mut vec: Vec<Vec<i32>> = Vec::new();

    for i in 0..3 {
        let mut each_vec: Vec<i32> =
            (0..3).map(|_| read()).collect();
        vec.push(each_vec);
    }

    let num11 = vec[0][0];
    let num12 = vec[0][1];
    let num13 = vec[0][2];
    let num21 = vec[1][0];
    let num22 = vec[1][1];
    let num23 = vec[1][2];
    let num31 = vec[2][0];
    let num32 = vec[2][1];
    let num33 = vec[2][2];

    let mut isOk: bool = false;

    for a1 in 0..num11+1 {
        let b1 = num11 - a1;
        let b2 = num12 - a1;
        let b3 = num13 - a1;
        let a2 = num21 - b1;
        let a3 = num31 - b1;

        let a1b1 = a1+b1;
        let a1b2 = a1+b2;
        let a1b3 = a1+b3;
        let a2b1 = a2+b1;
        let a2b2 = a2+b2;
        let a2b3 = a2+b3;
        let a3b1 = a3+b1;
        let a3b2 = a3+b2;
        let a3b3 = a3+b3;

        if a1b1 == num11 &&
            a1b2 == num12 &&
            a1b3 == num13 &&
            a2b1 == num21 &&
            a2b2 == num22 &&
            a2b3 == num23 &&
            a3b1 == num31 &&
            a3b2 == num32 &&
            a3b3 == num33 {
            isOk = true;
            break;
        }
    }

    println!("{}", if isOk {"Yes"} else {"No"});
}

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

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

Measured memory_bytes: 4352
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto H = RD;
	auto A = RD;

	writeln((H+A-1) / A);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    #define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
    #define ll long long
    #define int long long 
    #define ull unsigned long long 
    #define ld long double
    #define sb __builtin_popcount
    #define vi vector<int>
    #define vc vector<char>
    #define ii pair<int, int>
    #define pq priority_queue<ii, vector<ii>, greater<ii>>
    #define vii vector<ii>
    #define sz(a) int((a).size())
    #define f(a, b) for (int i = a; i < b; i++)
    #define fr(a, b) for (int i = a - 1; i >= b; i--)
    #define tr(x, m) for (auto x : m)
    #define in(a, b) (b.find(a) != string::npos)
    #define minin(a) *min_element(all(a))
    #define maxin(a) *max_element(all(a))
    #define X first
    #define Y second
    #define fill(a, x) memset(a, x, sizeof(a))
    #define pb push_back
    #define pf push_front
    #define mp make_pair
    #define all(v) v.begin(), v.end()
    #define rall(v) reverse(v.begin(), v.end())
    #define unq(v) v.erase(unique(all(v)), v.end())
    #define el "\n"
    #define mx3(a, b, c) max(max(a, b), c)
    #define mn3(a, b, c) min(min(a, b), c)
    #define S(v) accumulate(all(v), (ll)0)
    #define SP(n) cout.precision(n)
    const ld PI = atan(1.0) * 4.0;
    const ll MOD = 1e9 + 7;
    const ll INF = 1e18;
    const ld EPS = 0.0000001;
    const ll MD = 998244353;


        int32_t main() {
            fio;
             int a,b,c,d,e,f;
             cin>>a>>b>>c>>d;
             while(a>0 && c>0){
                 e=c-b;
                 f=a-d;
                 c=e;
                 a=f;
               if(e<=0){
                   cout<<"Yes"<<el;
                   break;
               }
               else if(f<=0){
                   cout<<"No"<<el;
                   break;
               }
             }
           
            return 0;
        }


Measured memory_bytes: 3644
N=int(input())
A=list(map(int, input().split()))
flag=True
cnt=0
while flag:
    flag=False
    j=0
    for i in range(N-1, j, -1):
        if A[i-1]>A[i]:
            A[i-1],A[i]=A[i],A[i-1]
            flag=True
            cnt+=1
    j+=1
print(*A)
print(cnt)


Measured memory_bytes: 5608
#!/usr/bin/env php
<?php
const YES = "YES";
const NO = "NO";

const UP = 'U';
const DOWN = 'D';
const LEFT = 'L';
const RIGHT = 'R';

const REVERSE = [
    UP => DOWN,
    DOWN => UP,
    LEFT => RIGHT,
    RIGHT => LEFT,
];

function genInputs() {
    while(($input = rtrim(fgets(STDIN))) !== false) {
        foreach (explode(' ', $input) as $v) {
            yield $v;
        }
    }
}
function getNext($gen) {
    $value = $gen->current();
    $gen->next();
    return $value;
}
$gen = genInputs();

$H = (int)getNext($gen);
$W = (int)getNext($gen);
$N = (int)getNext($gen);
$s_r = (int)getNext($gen);
$s_c = (int)getNext($gen);
$S = (string)getNext($gen);
$T = (string)getNext($gen);

$calc_need = function($now) use($H, $W, $s_r, $s_c) {
    $need = 0;
    if ($now == UP) {
        $need = $s_r;
    } elseif ($now == DOWN) {
        $need = $H - $s_r + 1;
    } elseif ($now == LEFT) {
        $need = $s_c;
    } else {
        $need = $W - $s_c + 1;
    }
    return $need;
};

$is_end_game = function($s_now, $s_vec, $t_vec) use($calc_need) {
    $off = $s_vec[$s_now];
    $on = $t_vec[REVERSE[$s_now]];
    if ($off <= $on) {
        return false;
    }
    $need = $calc_need($s_now);
    if (($off - $on) >= $need) {
        return true;
    }
    return false;
};

$check_usable_vec = function($t_now, $s_vec, &$t_vec) use($calc_need) {
    $off = $t_vec[$t_now];
    $on = $s_vec[REVERSE[$t_now]];
    $need = $calc_need($t_now);
    if (($off - $on) >= $need) {
        $t_vec[$t_now]--;
    }
};

$s_vec = $t_vec = [
    UP => 0,
    DOWN => 0,
    LEFT => 0,
    RIGHT => 0,
];
for ($i = 0; $i < $N; $i++) {
    $s_now = $S[$i];
    $s_vec[$s_now]++;
    //print_r([$i, $s_now, $s_vec, $t_vec]);
    if ($is_end_game($s_now, $s_vec, $t_vec)) {
        echo NO.PHP_EOL;
        exit;
    }
    $t_now = $T[$i];
    $t_vec[$t_now]++;
    $check_usable_vec($t_now, $s_vec, $t_vec);
}
echo YES.PHP_EOL;
exit;


Measured memory_bytes: 4728
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


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


n, k = inpl()
H = inpl()

if k >= n: k = n - 1
H = [H[0]] + H
dp = [INF] * (n + 1)
dp[0] = 0

for i in range(1, n + 1):
    for j in range(1, k + 1):
        if i - j < 0: break
        dp[i] = min(dp[i], abs(H[i] - H[i - j]) + dp[i - j])
    # print(dp)

print(dp[n])


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

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

    char table[52];
    char c='A';
    for(int i=0;i<26;i++)
    {
        table[i]=c;
        c++;
    }
    c='A';
    for(int i=26;i<52;i++)
    {
        table[i]=c;
        c++;
    }

    rep(i,s.size())
    {
        s[i] = table[s[i] - 'A'+n];
    }
    cout << s;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[105],i,n,x=0,y=0,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	sort(a,a+n);
	for(i=n-1;i>=0;i=i-2)
	x=x+a[i];
	for(i=n-2;i>=0;i=i-2)
	y=y+a[i];
	k=x-y;
	printf("%d",k);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
        cin>>a[i];
	int dp[n]={0};
	dp[n-2]=abs(a[n-1]-a[n-2]);
    for(int i=n-3;i>=0;i--)
    {
        dp[i]=min( abs(a[i]-a[i+1])+dp[i+1], abs(a[i]-a[i+2])+dp[i+2]);
    }
    cout<<dp[0];
    return 0;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
 
using namespace __gnu_pbds;
using namespace std;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;
 
      a=a*a%mod;
      b/=2;
 
      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
 
 
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    // ifstream fin(".in");
    // ofstream fout(".in");
int a,b,k;
cin>>k>>a>>b;
fore(i,a,b)if(i%k==0){cout<<"OK";
return 0;}
 
cout<<"NG";
 
 
 
    return 0;
  }

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ss(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl

using ll = long long;

using namespace std;

const int N = 100111;

int n;
ll m[N];

int main() {
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf ("%lld", m + i);
	ll l, r;
	l = r = 2;
	
	for (int i = n; 1 <= i; --i) {
		ll a = ((l - 1) / m[i]) * m[i] + m[i];
		ll b = (r / m[i]) * m[i];
		
		if (a > b) 
			return printf ("-1\n"), 0;
			
		l = a;
		r = b + m[i] - 1;
	}
	
	printf ("%lld %lld\n", l, r);
	return 0;
}


Measured memory_bytes: 4516
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
//typedef complex<double>P;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS*(abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a - 1) / (2 * b + 1) + 1 << endl;
}

Measured memory_bytes: 256
from sys import stdin
import itertools
import numpy as np

def main():
    N = int(stdin.readline().rstrip())
    L = [int(x) for x in stdin.readline().rstrip().split()]
    C = list(itertools.combinations(L, 2))
    for i in range(len(C)):
        C[i] = np.prod(np.array(C[i]))
    C = sum(C)
    print(C)
    
main()

Measured memory_bytes: 12492
s = input()
t = input()
s = list(s)
t = list(t)
s.sort()
t.sort(reverse=True)

for i in range(min(len(s), len(t))):
    if s[i] < t[i]:
        print("Yes")
        exit()
    elif s[i] > t[i]:
        print("No")
        exit()

if len(s) < len(t):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
S = list(str(input()))
l = []
ls = len(S)
B,W = 0,0
for i in range(ls):
  if S[i] == "B":
    B += 1
    if W != 0:
      l.append('W')
      W = 0
  else:
    W += 1
    if B != 0:
      l.append('B')
      B = 0
  if i == ls-1:
    if S[i] == "B":
      l.append("B")
    elif S[i] == "W":
      l.append("W")
ls = len(l)

print(ls-1)

Measured memory_bytes: 4652
<?php
fscanf(STDIN, "%d", $n);
$ds = explode(' ', trim(fgets(STDIN)));
$x = $n;

$sum = '';
for ($i = 0; $i < $n; $i++) {
  $iii = $i + 1;
  $x--;
  for ($ii = 0; $ii < $x; $ii++) {
    $sum += $ds[$i] * $ds[$iii];
    $iii++;
  }
}

echo $sum;


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

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

 
 
using namespace __gnu_pbds;
using namespace std;
 const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 
int multiply(int a, int b, int in_mod){return (a*b)%in_mod;} 
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}



void solve()
{
    int x;
    cin>>x;
    for(int a=-1e3;a<=1e3;a++)
    {
        for(int b=-1e3;b<=1e3;b++)
        {
            if(a*a*a*a*a -b*b*b*b*b==x)
            {
                cout<<a<<" "<<b<<endl;
                return ;
            }
        }
    }
    assert(false);
}

 
 
signed main()
 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
            freopen ("INPUT.txt" , "r" , stdin);
            freopen ("OUTPUT.txt" , "w" , stdout);
        }
    #endif
    auto clk=clock(); 
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        solve();
        // cout<<endl;
 
    }
 
    // -------------------------------------Code ends here------------------------------------------------------------------
 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


Measured memory_bytes: 3804
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  long long N;
  long long res = 0;
  rd(N);
  if(N%2){
    wt_L(0);
    wt_L('\n');
    return 0;
  }
  N /= 2;
  while(N){
    res += (N /= 5);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// {
//   ll N, res = 0;
//   rd(N);
//   if(N%2) wt(0), return 0;
//   N /= 2;
//   while(N) res += (N /= 5);
//   wt(res);
// }


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 120000;

vector<int> eds[MAXN];
vector<int> reds[MAXN];

int n, m;

int was[MAXN];
vector<int> vv;

void dfs1(int v) {
	was[v] = 1;
	for (int u: eds[v]) {
		if (!was[u])
			dfs1(u);
	}
	vv.push_back(v);
}

int go[MAXN];
int dp[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> m;
	for (int i = 0; i < n - 1 + m; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		eds[a].push_back(b);
		reds[b].push_back(a);
	}
	for (int i = 0; i < n; ++i)
		if (!was[i])
			dfs1(i);
	reverse(ALL(vv));
	for (int i: vv) {
		int k = -1;
		for (int j: reds[i]) {
			if (dp[j] + 1 > dp[i])
				dp[i] = dp[j] + 1, k = j;
		}
		go[i] = k;
	}
	for (int i = 0; i < n; ++i)
		cout << go[i] + 1 << "\n";
	return 0;
}




Measured memory_bytes: 15996
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    vector<string> a(3);
    int i, j;
    FOR0(j, 3) cin>>a[j];
    int ans = 0;
    FOR0(i, n)
    {
        set<char> t;
        t.clear();
        FOR0(j, 3)
        {
            t.insert(a[j][i]);
        }
        if(t.size()==2) ans += 1;
        else if(t.size()==3) ans += 2;
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

const int MAX_N = 300000;
int n;
unsigned long long a[MAX_N];
const long long mod = 1000000007;

void solve()
{
    unsigned long long ans = 0;
    for (int i = 0; i < 60; i++)
    {
        unsigned long long bit = 1ULL << i;
        int oc = 0,
            zc = 0;
        for (int j = 0; j < n; j++)
        {
            if (a[j] % 2 == 0)
            {
                zc++;
            }
            else
            {
                oc++;
            }
            a[j] /= 2;
        }
        unsigned long long add = (bit % mod);
        add *= oc;
        add %= mod;
        add *= zc;
        add %= mod;
        ans = (ans + add) % mod;
    }
    cout << ans << endl;
}

int main()
{
    cin >> n;

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

    solve();
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
    int x,a,b;
    int p,n;
    cin>>x>>a>>b;
    p=abs(x-a);
    n=abs(x-b);
    if(p>n){
        cout<<"B";    }
if(n>p){
    cout<<"A";
}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
INF = float("inf")
# 解説参照

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(reverse=True)  # 使用可能は数字は大きい順にソートしておく
    cost = [-1, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    # dp[i]:= マッチi本で作れる最大桁数
    dp = [-1] * (n + 1)
    dp[0] = 0
    for i in range(1, n + 1):
        for aj in a:
            if i - cost[aj] < 0:
                continue
            dp[i] = max(dp[i], dp[i - cost[aj]] + 1)
    digits = dp[n]
    ans = ""
    rest = n
    # 上から貪欲
    while digits:
        for aj in a:
            if rest - cost[aj] < 0:
                continue
            if dp[rest - cost[aj]] == digits - 1:
                ans += str(aj)
                rest -= cost[aj]
                digits -= 1
                break
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
/*string s;
string t;

cin>>s;
cin>>t;
int contador=0;
for(int i=0;i<3;i++)
{
	if(s[i]==t[i])
	{
		contador=contador+1;
	}
	
	
}
cout<<contador;*/
string s;
cin>>s;
sort(s.begin(),s.end());

if((s[0]==s[1])&&(s[2]==s[3])&&(s[0]!=s[3]))
{
	cout<<"Yes"<<endl;
	
}
else
{
	cout<<"No"<<endl;
}


return 0;


}

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

using namespace std;

int main() {
    int n, k;
    vector<int> d;
    vector<vector<int>> a;
    cin >> n >> k;
    vector<int> ans(n, 0);
    for (int i = 0; i < k; i++) {
        int td;
        // vector<int> ta;
        cin >> td;
        // d.push_back(td);
        for (int j = 0; j < td; j++) {
            int tta;
            cin >> tta;
            // ta.push_back(tta);
            ans[tta - 1] = 1;
        }
        // a.push_back(ta);
    }
    int n_count = count(ans.begin(), ans.end(), 0);
    cout << n_count << endl;
    return 0;
}


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

int main() {
  long long h,n;cin>>h>>n;
  vector<int>vec(n);long long sum=0;
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    sum+=vec.at(i);
  }
  if(h>sum)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B;
    cin >> A >> B;
    if((A*B)%2!=0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,a[3],k;
    cin>>a[0]>>a[1]>>a[2]>>k;
    sort(a,a+3);
    while(k--)
    {
        a[2]+=a[2];
    }
    ll sum=a[0]+a[1]+a[2];
     cout<<sum<<'\n';

   return 0;
}





Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   string s;
   cin >> s;
   bool a=false, b=false, c=false;
   for(int i = 0; i < s.size(); i++){
      if(s[i] == 'a'){a = true;}
      if(s[i] == 'b'){b = true;}
      if(s[i] == 'c'){c = true;}
   }
   if(a && b && c){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
   }

   return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)

max = 0
result = 'Yes'
n.times do |i|
  if max - 1 > h[i]
    result = 'No'
    break
  end
  max = h[i] if max < h[i]
end

puts(result)

Measured memory_bytes: 9604
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        int i = 0;
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        char a = n.charAt(0);
        char b = n.charAt(1);
        char c = n.charAt(2);
        char d = n.charAt(3);
        if (a == '+') {
            i++;
        }else{
            i--;
        }
        if (b == '+') {
            i++;
        }else{
            i--;
        }
        if (c == '+') {
            i++;
        }else{
            i--;
        }
        if (d == '+') {
            i++;
        }else{
            i--;
        }
        System.out.println(i);
    }
}

Measured memory_bytes: 21844
import math
li = input().split()
A = int(li[0])
B = int(li[1])
C = int(li[2])
D = int(li[3])

times_1 = math.ceil(C / B)
times_2 = math.ceil(A / D)

if times_1 <= times_2:
    print('Yes')
elif times_1 > times_2:
    print('No')


Measured memory_bytes: 9180
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    a = LI()
    b = LI()
    fm = {}
    def f(ai,bi,pt,sa,sb,t):
        if pt > 2:
            return 0
        key = (ai,bi,pt,sa,sb,t)
        if key in fm:
            return fm[key]
        r = f(ai,bi,pt+1,0,0,not t) + sa - sb
        tr = 0
        if t:
            if ai < n:
                if a[ai] < 0:
                    tr = f(ai+1,bi,0,sa,0,not t)
                else:
                    tr = f(ai+1,bi,0,sa+a[ai],sb,not t)
                if r < tr:
                    r = tr
        else:
            if bi < m:
                if b[bi] < 0:
                    tr = f(ai,bi+1,0,0,sb,not t)
                else:
                    tr = f(ai,bi+1,0,sa,sb+b[bi],not t)
                if r > tr:
                    r = tr
        fm[key] = r
        return r

    r = f(0,0,0,0,0,True)
    return r


print(main())



Measured memory_bytes: 51168
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String S=sc.nextLine();
    String str1="ABC";
    String str2="ARC";
    if(S.equals(str1)){
      System.out.println("ARC");
    }else if(S.equals(str2)){
      System.out.println("ABC");
    }
  }
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	ll i;
	for(i = 1; i <= 1e9; i++){
		if(i * i > n) break;
	}
	cout << (i - 1) * (i - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

if a == 0:
    if b == 100:
        print(b + 1)
    else:
        print(b)

else:
    cand = 100 **a

    if cand*b == 100**2:
        print(cand * b + 100)
    
    elif cand*b == 100**3:
        print(cand * b + 10000)
        
    else:
        print(cand * b)

Measured memory_bytes: 38384
S = input()
if len(S) == 26:
    done = set()
    for i, s in enumerate(S[::-1]):
        s = ord(s)
        if done:
            if max(done) < s:
                done.add(s)
                if i == 25:
                    print(-1)
            elif i != 25:
                l = 30
                for d in done:
                    if l > abs(d - s) and s < d:
                        x = d
                        l = d - s
                print(S[: -(i + 1)] + chr(x))
                break
            else:
                print(chr(ord(S[0]) + 1))
        else:
            done.add(s)
else:
    for i in range(ord("a"), ord("z") + 1):
        if not (chr(i) in S):
            print(S + chr(i))
            break

Measured memory_bytes: 9128
def main():
    n = iread()
    print(n ** 2)

def iread():
    return int(input())


def sread():
    return input()


def aread(t="int"):
    if t == "int":
        ret = [int(i) for i in input().split()]
    elif t == "str":
        ret = list(input().split())
    return ret


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


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set
ll D;
ll c[26];
ll s[365][26];
void input(){
    cin >> D;
    for(int i=0;i<26;i++) cin >> c[i];
    for(int i=0;i<D;i++) for(int j=0;j<26;j++) cin >> s[i][j];
}
constexpr ll INF=1e18;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    input();
    vector<int> last(26,0);
    vector<int> ret;
    rep(i,D){
        ll plus=-INF;
        int ans=0;
        rep(j,26){
            //open j contest
            ll ret=s[i][j];
            rep(k,26){
                if(j!=k) ret-=c[k]*(i+1-last[k]);
            }
            if(ret>plus){
                plus=ret;
                ans=j;
            }
        }
        last[ans]=i+1;
        ret.pb(ans+1);
    }
    for(int u:ret) cout << u << endl;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007 
#define pb push_back
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int w=1;
	// cin>>w;
	while(w--){
		ll n;
		cin>>n;
		vector<ll>v1(n),v2(n);
		F(i,0,n){
			cin>>v1[i];
		}
		F(i,0,n){
			cin>>v2[i];
		}
		vi v;
		for(int i=0,j=n-1;i<n;i++,j--){
			if(v1[i]==v2[j]){v.pb(j);}
		}
		int x=0;
		for(auto i:v){
			swap(v2[i],v2[x]);
			x++;
		}
		v.clear();
		for(int i=0,j=n-1;i<n;i++,j--){
			if(v1[i]==v2[j]){v.pb(j);}
		}
		x=n-1;
		for(auto i:v){
			swap(v2[i],v2[x]);
			x--;
		}
		for(int i=0,j=n-1;i<n;i++,j--){
			if(v1[i]==v2[j]){cout<<"No";return 0;}
		}
		cout<<"Yes\n";
		for(int j=n-1;j>=0;j--){
			cout<<v2[j]<<" ";
		}

	}
	return 0;
}

Measured memory_bytes: 7276
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k,count=0;
    cin >> n >> k;
    int h[n];
    
    for(int i=0;i<n;i++){
        cin >> h[i];
        if(h[i]>=k) count++;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

ll N;
ll res=0;
ll A[20];
ll x[20][20];
ll y[20][20];

void calc(vector<ll> v){
  ll count=0;
  rep(i,N){
    //正直者を探す
    if(v[i]==1){
      count++;
      //正直な証言を確かめる
      rep(j,A[i]){
        if(y[i][j]!=v[x[i][j]]){
          //cout<<"人"<<i<<"は不親切だ。なぜなら人"<<x[i][j]<<"について嘘を言っているからだ。"
          //  <<endl;
         // cout<<" ";
         // rep(k,N) cout<<v[k]<<" ";
         // cout<<endl;
          return;
        }
      }
    }
  }
  
  chmax(res,count);
  
 // rep(i,N)
 //   cout<<v[i]<<" ";
 // cout<<endl;
}

void dfs(vector<ll> v,ll depth){
  if(depth==N){
    calc(v);
    return;
  }
  for(int i=0;i<2;i++){
    v[depth]=i;
    dfs(v,depth+1);
  }
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  cin>>N;
  rep(i,N){
    cin>>A[i];
    rep(j,A[i]){
      cin>>x[i][j]>>y[i][j];
      x[i][j]--;
    }
  }
  
  vector<ll>v(N);
  
  dfs(v,0);
  
  cout<<res;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, Y = list(map(int, input().split()))

find = False
for z in range(N+1):
    for y in range(N-z+1):
        x = N - y - z
        if x * 1000 + y * 5000 + z * 10000 == Y :
            print(str(z) + " " + str(y) + " " + str(x))
            find = True
            break
        if find == True:
            break
    if find == True:
        break

if find == False:
    print(str(-1) + " " + str(-1) + " " + str(-1))


Measured memory_bytes: 3060
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)

int main(void) {
	int n;
	cin >> n;

	vector<int> monsters;

	FOR(i, 0, n) {
		int hp;
		cin >> hp;
		monsters.push_back(hp);
	}
	
	//cout << "monsters:" << endl;
	//FOR(i, 0, n) cout << monsters[i] << endl;

	while (monsters.size() > 1) {
		//小さい順にソート
		sort(monsters.begin(), monsters.end());

		//最小HPで残りのHP割る
		FOR(i, 1, monsters.size()) monsters[i] %= monsters[0];
		
		//HP0は削除
		auto it_remove = remove(monsters.begin(), monsters.end(), 0);
		monsters.erase(it_remove, monsters.end());

		//cout << "monsters:" << endl;
		//for(int m: monsters) cout << m << endl;
	}

	cout << monsters[0];

}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n, k, ma=-1999999999, tmp;
	vector<int> v, g;

	cin>> n >> k;
	v.resize(n);
	for(int i=0;i<n;i++) cin>> v[i];

	for(int i=0;i<=min(k, n);i++){
		for(int j=0;i+j<=min(k, n);j++){
			for(int l=0;l<i;l++) g.emplace_back(v[l]);
			for(int l=0;l<j;l++) g.emplace_back(v[n-l-1]);
			/*for(int l=0;l<g.size();l++) cout<< g[l] << " ";
			cout<< "  " << i+j << endl;*/

			sort(g.begin(), g.end());
			tmp=0;
			for(int l=0;l<k-i-j;l++){
				if(g.size()<=l) break;
				if(g[l]<0) g[l]=0;
			}
			for(int l=0;l<g.size();l++) tmp+=g[l];
			ma=max(ma, tmp);

			g.erase(g.begin(), g.end());
		}
	}

	cout<< ma << endl;

}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int k, n;
int ci[15], cf[15];
int x[15], y[15], p[15], d[15];
bool used[15]={0};
ll mini;

void tan(int d, int s){
	if(d==k){
		//count
		ll sm=0;
		rep(i, n) if(!used[i]){
			int mn=min(abs(x[i]), abs(y[i]));
			rep(j, k){
				if(cf[j]) mn=min(mn, abs(x[i]-x[ci[j]]));
				else mn=min(mn, abs(y[i]-y[ci[j]]));
			}
			sm+=(ll)p[i]*mn;
		}
		mini=min(mini, sm);
		return ;
	}
	for(int i=s; i<n-(k-1-d); i++){
		ci[d]=i;
		used[i]=true;
		rep(j, 2){
			cf[d]=j;
			tan(d+1, i+1);
		}
		used[i]=false;
	}
}

int main(){
	cin>>n;
	rep(i, n) cin>>x[i]>>y[i]>>p[i];

	for(k=0; k<n+1; k++){
		mini=LLONG_MAX;
		tan(0, 0);
		cout<<mini<<endl;
	}

	return 0;
}


Measured memory_bytes: 3584
x = input() #sys.stdin.readlineは最後が改行
n = len(x)

tama = 0
cnt = 0
for i in range(n):
    if x[i] =='S':
        tama+=1
    elif x[i] =='T' and tama>0:
        cnt += 2
        tama-=1
print(n-cnt)

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


using namespace std;
int v[1000010][3];

int dp[1000010][3];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }

    for (int i = 0; i < 3; ++i) {
        dp[0][i] = v[0][i];
    }
    for (int j = 1; j < n; ++j) {
        for (int i = 0; i < 3; ++i) {
            dp[j][i] = 0;
            for (int k = 0; k < 3; ++k) {
                if(i == k) {
                    continue;
                }else {
                    dp[j][i] = max(dp[j][i],dp[j-1][k] + v[j][i]);
                }

            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
}

Measured memory_bytes: 5504
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

N = int(input())
num_list = [[i+1 for i in range(N)],[i+1 for i in range(N)],[i+1 for i in range(N)]]
sum = 0
for a in num_list[0]:
    for b in num_list[1]:
        for c in num_list[2]:
            sum = sum + gcd(a,b,c)

print(sum)

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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;

  ll c=v-w;
  ll d=abs(b-a);

  if(c<=0){
     cout<<"NO";
  }
  else if(d<=(c*t)){
     cout<<"YES";
  }
  else{
     cout<<"NO";
  }
   return 0;
}



Measured memory_bytes: 3636