akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	n := scanInt()
	len := n / 2
	e := make([]int, len)
	ec := make(map[int]int, len)
	o := make([]int, len)
	oc := make(map[int]int, len)

	for i := 0; i < n; i++ {
		j := i / 2
		if i%2 == 0 {
			e[j] = scanInt()
			ec[e[j]]++
		} else {
			o[j] = scanInt()
			oc[o[j]]++
		}
	}

	mn := func(m map[int]int) (int, int, int) {
		r1, r2 := 0, 0
		maxnum := 0
		for k, v := range m {
			if v > r1 {
				r1, r2 = v, r1
				maxnum = k
			} else if v > r2 {
				r2 = v
			}
		}
		return r1, r2, maxnum
	}

	e1, e2, em := mn(ec)
	o1, o2, om := mn(oc)

	if em != om {
		fmt.Println((len - e1) + (len - o1))
		return
	}

	t1 := (len - e1) + (len - o2)
	t2 := (len - e2) + (len - o1)

	if t1 < t2 {
		fmt.Println(t1)
	} else {
		fmt.Println(t2)
	}
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

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

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {

	if a < b {
		a, b = b, a
	}

	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}


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

int main() { /* ここに書く */

  long K,N,A,B,Ans;
  
  cin >> K >> N;
  
  vector<long>H(N);
  
  for(int i = 0; i<N ; i++){
    cin >> H.at(i);
  }
  A = K - H.at(N-1) + H.at(0);
  
  for(int i = 1; i<N ; i++){
    B = H.at(i) - H.at(i-1);
    if( B > A ){
      A = B;}
  }
  
  Ans = K - A;
  
  cout << Ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int dp[111][11111];
signed main(){
    int n,w;cin>>n>>w;
    rep(i,0,n+1)rep(j,0,w+1){
        dp[i][j]=-mod;
    }
    dp[0][0]=0;
    rep(i,1,n+1){
        int a,b;cin>>a>>b;
        for(int j=w;j>=0;j--){
            if(j>=a)dp[i][j]=max(dp[i-1][j],dp[i-1][j-a]+b);
            else dp[i][j]=dp[i-1][j];
            //cout<<dp[i][j]<<" ";
        }//cout<<endl;
    }
    int ans=-1;
    rep(i,0,w+1){
        ans=max(ans,dp[n][i]);
    }cout<<ans<<endl;return 0;
}

Measured memory_bytes: 9728
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

using Weight=int;
using DArray=vector<Weight>;
using DMatrix=vector<DArray>;

static const Weight INF=1<<29;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

size_t get_root(const Graph &g) {
    // stores the node type
    size_t V=g.size();
    vector<Weight> indeg(V);
    for (size_t i=0; i<V; ++i)
        for (const Edge &e: g[i])
            indeg[e.dst] += e.weight;

    for (size_t i=0; i<V; ++i)
        if (!indeg[i])
            return i;

    return 0;
}

template <class Functor>
void walk_postorder(const Graph &g, size_t root, Functor F) {
    if (root >= g.size()-1) return;

    for (const Edge &e: g[root])
        walk_postorder(g, e.dst, F);

    F(root);
}

void reconstruct_tree(
    vector<size_t>::iterator first1, vector<size_t>::iterator last1,
    vector<size_t>::iterator first2, vector<size_t>::iterator last2,
    Graph &g
) {
    vector<size_t>::iterator root=find(first2, last2, *first1);
    if (first1+1 > first1+(root-first2)) {
        connect(g, *root, g.size()-1);
    } else {
        connect(g, *root, first1[1]);
        reconstruct_tree(first1+1, first1+(root-first2)+1, first2, root, g);
    }

    if (first1+(root-first2)+1 > last1-1) {
        connect(g, *root, g.size()-1);
    } else {
        connect(g, *root, first1[(root-first2)+1]);
        reconstruct_tree(first1+(root-first2)+1, last1, root+1, last2, g);
    }
}

int main() {
    size_t n;
    scanf("%zu", &n);

    vector<size_t> preorder(n);
    for (size_t i=0; i<n; ++i) {
        scanf("%zu", &preorder[i]);
        --preorder[i];
    }

    vector<size_t> inorder(n);
    for (size_t i=0; i<n; ++i){
        scanf("%zu", &inorder[i]);
        --inorder[i];
    }

    Graph g(n+1);
    reconstruct_tree(
        preorder.begin(), preorder.end(), inorder.begin(), inorder.end(), g
    );

    size_t r=get_root(g);

    vector<size_t> postorder;
    auto postpush=[=, &postorder](size_t v)->void {
        if (v < n)
            postorder.push_back(v+1);
    };

    walk_postorder(g, r, postpush);
    for (size_t i=0; i<n; ++i)
        printf("%zu%c", postorder[i], i<n-1? ' ':'\n');

    return 0;
}

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

int main()
{
    int n, k; cin >> n >> k;
    ll q = n / k;
    ll ans = q * q * q;
    if (k % 2 == 0) {
        ll q2 = (n + k / 2) / k;
        ans += q2 * q2 * q2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
h,w = gets.chomp.split.map(&:to_i)
s = []
h.times do
    s << gets.chomp.split("")
end

for i in 0..(h-1)
    for j in 0..(w-1)
        c = 0
        next if s[i][j] == '.'
        c += 1 if i > 0 && s[i-1][j] == "#"
        c += 1 if j > 0 && s[i][j-1] == "#"
        c += 1 if i != h-1 && s[i+1][j] == "#"
        c += 1 if j != w-1 && s[i][j+1] == "#"
        if c == 0
            puts "No"
            exit
        end
    end
end

puts "Yes"

Measured memory_bytes: 2172
use std::cmp::min;
use proconio::input;
use std::ops::Mul;
use num_traits::One;
const MAX:usize = 210000;
fn main() {
    input!{
        n:usize,
        k:usize,
        a:[usize;n]
    }
    let a1 :Vec<usize> = a.iter().map(|x| x-1).collect::<Vec<_>>();
//    println!("{:?}",a1);
    let ans = pow(&Perm{p:a1},k).p;
    print!("{}",ans[0]+1);
}
struct Perm{
    p:Vec<usize>
}

impl Mul for Perm {
    type Output = Self;
    fn mul(self,other:Self) -> Self
    {
        let n = min(self.p.len(),other.p.len());
        let mut ret:Vec<usize> = vec![0;n];
        for i in 0..n {
            ret[i]=self.p[other.p[i]];
        }
        Self{p:ret}
    }
}
impl One for Perm {
    fn one() -> Self {
        Self{p:(0..MAX).collect::<Vec<usize>>()}
    }
}

impl Clone for Perm {
    fn clone(&self) -> Self {
        Self{p:self.p.clone()}
    }
}

fn pow<M: std::ops::Mul + num_traits::One + Clone>(x: &M, n: usize) -> M {
    let mut p = n;
    let mut cur = x.clone();
    let mut ret = M::one();
    while p > 0 {
        if (p & 1) == 1 {
            ret = ret.clone() * cur.clone();
        }
        cur = cur.clone() * cur.clone();
        p >>= 1;
    }
    ret
}

Measured memory_bytes: 15740
# 【考察】
# 0-indexedで考える。Aは降順ソートして考える。
# まず、初期状態でTop Pに含まれる問題はすべて出題されうる。
# なので初期でTop q (q > P)の問題が出題されるか否かを考えていく。
# 最終的にTop Pに入れるか否かが問題なので、Top 1 ~ P-1の問題は無視。
# Top qの問題に毎回投票しつつ、Top P ~ q-1の問題になるべく投票しないようにしたい。
# そこで数列 A[P], A[P+1], ..., A[q-1] を考える。
# この中から最大でN-V個の数字を選んで1減らすことをM回繰り返し、
# すべてA[q]以下にすることができればTop qの問題は出題されうる。
# 当然A[P]-A[q] > Mだったら無理（出題されない）。
# 以後A[P]-A[q] <= Mとする。
# この時、(A[P]-A[q]) + (A[P+1]-A[q]) + ... + (A[q-1]-A[q]) <= M * (N-V) であればTop qのは出題可能。
# 整理すると A[P] + A[P+1] + ... + A[q-1] <= M * (N-V) + A[q] * (q-P) となるので、
# Aの累積和のデータを保持しておけば各qにおいてO(1)で出題可否が判定可能。


def main():
    N, M, V, P = list(map(int, input().split()))
    A = list(map(int, input().split()))
    P -= 1  # to 0-indexed
    A.sort(reverse=True)  # 降順ソート
    cumsum = [0] * N
    cumsum[0] = A[0]
    for i in range(1, N):
        cumsum[i] = cumsum[i - 1] + A[i]
    q = P + 1
    while q < N:
        left = cumsum[q - 1]
        if P > 0:
            left -= cumsum[P - 1]
        right = M * (N - V) + A[q] * (q - P)
        if A[P] - A[q] > M or left > right:
            print(q)
            return
        q += 1
    print(q)


if __name__ == '__main__':
    main()

Measured memory_bytes: 20524
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        boolean exist = false;
        for (int i = 0; i <= n/4; i++) {
            for (int j = 0; j <= n/7; j++) {
                if (n == (i*4) + (j*7)) {
                    exist = true;
                    break;
                }
            }
        }

        if (exist) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <queue>
#define sl "\n"
#define ll long long
using namespace std ;
const int N = 2e5+5 ;
ll n,a[N];
ll r,s,q;
int main()
{
  cin >> n ;
  r = s = 0 ; q = 1000ll ;
  for (int  i = 0 ; i < n ; i++ ) 
    cin >> a[i] ;
  for (int i = 0 ; i < n -1 ; i++ ) {
    if (a[i] < a[i+1]) {
      q += r * s ;
      s = q / a[i] ;
      r = q % a[i] ;
      q = s * a[i+1] ;
      q += r ;
      r = s = 0 ;
    } else {
      q += r * s ;
      r =s = 0 ;
      s = a[i+1] ;
      r = q / s ;
      q = q % a[i+1] ;
    }
  }
  q += r*s ;
  cout << q ;
  return  0 ;
}


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

int main(int argc, char const *argv[]) {
  string S;
  cin >> S;

  bool easy = true;
  int N = S.size();
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      if (S[i] == 'L') {
        easy = false;
        break;
      }
    } else {
      if (S[i] == 'R') {
        easy = false;
        break;
      }
    }
  }
  if (easy) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main(){
	double N;
	cin >> N;
	vector<double> A(N);
	for(double i=0; i<N; i++){
		cin >> A.at(i);
	}

	long long ans=0;
	for(double i=1; i<N; i++){
		double dlt = A.at(i) - A.at(i-1);
		if(dlt<0){
			ans -= dlt;
			A.at(i) = A.at(i-1);
		}
	}
	cout << ans << endl;
}


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

int main(void){

    int N,M,X,A,l=0,r=0;
    cin >> N >> M >> X;
    int data[N+1];
    for(int i=0;i<N+1;i++) data[i] = 0;
    
    for(int i=0;i<M;i++){
        cin >> A;
        data[A] = 1;
    }
    
    for(int i=X;i<N+1;i++){
        if(data[i] == 1) l++;
    }
    
    for(int i=X;i>=0;i--){
        if(data[i] == 1) r++;
    }
    cout << min(l,r) << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define vec vector <int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define all(x) x.bg,x.en
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cout<<#x<<" "<<x<<endl;
#define dbga(arr,n) cout<<#arr<<": "; rp(tt,0,n) cout<<tt<<" "<<arr[tt].ff<<" "<<arr[tt].ss<<endl; cout<<endl;
#define mapi map<int,int>
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
const int mod=1e9+7,mex=1e12,md=998244353;
signed main()
{
	fast
	int n;
	cin>>n;
	int x=n/500;
	n=n%500;
	int y=n/5;
	int ans=1000*x + y*5;
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int r,d,x;cin>>r>>d>>x;
    for(int i = 0; i < 10 ; i++){
        x = r*x-d;
        cout << x << endl;
    
    }
    return 0;
    
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var S, w string
	fmt.Scan(&S)
	for _, v := range S {
		switch v {
		case '0':
			w += "0"
		case '1':
			w += "1"
		case 'B':
			if len(w) > 0 {
				w = w[:len(w)-1]
			}
		}
	}
	fmt.Println(w)
}

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


int main()
{
	int count[26] = { 0 };
	char ch;
	while (cin >> ch){
		if ('a' <= ch && ch <= 'z'){
			count[ch - 'a']++;
		}
		else if ('A' <= ch && ch <= 'Z'){
			count[ch - 'A']++;
		}
	}
	for (int i = 0; i < 26; i++){
		cout << char('a' + i) << " : " << count[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std; 
string a; 
int n;
int main(){
   cin >> a;
    for(int i = 0;i < 4;i++)
	{
        if(a[i] == '+')
            n++;
        else
            n--;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long inf = numeric_limits<long long>::max();
int main()
{
  int n;
  cin >> n;
  for(int i = 111; i <= 999; i += 111) {
    if (i >= n) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	string s;
	vector<char>t1;
	vector<char>t2;
	cin>>n>>s;
	if(n%2!=0) cout<<"No";
	else
	{
		for(long long i=0;i<n/2;i++)
		t1.push_back(s[i]);
		for(ll i=n/2;i<n;i++)
		t2.push_back(s[i]);
		if(t1==t2) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    s = input()
    words = ["dream", "dreamer", "erase", "eraser"]
    while len(s) > 0:
        if s[-5:] in ["dream", "erase"]:
            s = s[:-5]
        elif s[-7:] == "dreamer":
            s = s[:-7]
        elif s[-6:] == "eraser":
            s = s[:-6]
        else:
            print("NO")
            break
    if not len(s):
        print("YES")

Measured memory_bytes: 3188
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#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 FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vll a(n);
    vll f(n);
    ll s = 0;
    REP(i,n) {
        cin >> a[i];
        s+=a[i];
    }
    REP(i,n) cin >> f[i];
    sort(ALL(f));
    sort(ALL(a));
    ll ans = a[n-1]*f[n-1];
   
    if(s<=k){
        cout << 0 << endl;
        return 0;
    }
    s-=k;
    //cout << s << endl;
    ll ok = ans;
    ll ng = -1;
    while(abs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        bool flg=true;
        ll cnt = 0;
        REP(i,n){
            ll t = mid/f[i];
            if(t>a[n-1-i]){
                cnt+=a[n-1-i];
            }else{
                cnt += t;
            }
        }
        //cout << mid << ":" << cnt << endl;
        if(cnt<s){
            flg=false;
        }
        if(flg){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    ans = ok;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
n, m = map(int, input().split())
rank = list(map(int, input().split()))
rank.sort(reverse=True)
cnt = 0

for r in rank:
  if r >= (sum(rank)/(4*m)):
    cnt += 1
    if cnt >= m:
      break

if cnt >= m :
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
using G = vector<vector<bool>>;
const long long INF = 1LL << 60;


ll h ,w;

int main() {
  
  cin >> h >> w;
  ll ans = 0;
  if(h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  ans = ((h*w)+1LL) / 2LL;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define INF 1000000000
#define INFLL 1000000000000000010ll
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))
#define mid(x,y) (((x)+(y))>>1)
int n,c,k;
int t[100005];
int main() {
	scanf("%d%d%d",&n,&c,&k);
	for (int i=0;i<n;i++) {
		scanf("%d",&t[i]);
	}
	sort(t,t+n);
	int cur=-1,ans=0,cnt=0;
	for (int i=0;i<n;i++) {
		if (t[i]<=cur && cnt<c) {
			cnt++;
		} else {
			ans++;
			cnt=1;
			cur=t[i]+k;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
int main(){
    ll n,ans=0;
    string s;
    cin>>n;
    cin>>s;
    rep(i,0,1000){
        int cnt=0;
        int as=i;
        int w1=i/100,w2=(i/10)%10,w3=i%10;
        rep(j,0,n){
            int g=s[j]-'0';
            if(cnt==0&&w1==g)cnt++;
            else if(cnt==1&&w2==g)cnt++;
            else if(cnt==2&&w3==g){ans++;break;}
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
vector<int> O[10];
char fi[1005][1005];
P sg[10];
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int n,k;

int kuso(int a,int b){
    if(b>a)swap(a,b);
    while(a%b!=0){
        a=a%b;
        swap(a,b);
    }
    return b;
}
signed main(){
    int n;cin>>n;
    int count=1;
    rep(i,n){
        int a;cin>>a;
        if(count<a)swap(a,count);
        count=a*(count/kuso(count,a));
    }
    cout<<count<<endl;
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int N;
int A[1000][1000];
int idx[1000];
int cnt[1000][1000];

int main() {
  cin >> N;
  rep(i, N) rep(j, N - 1) {
    cin >> A[i][j];
    A[i][j]--;
  }
  int ans = 0;
  queue<pii> q;
  rep(i, N) q.push(mp(i, A[i][0]));

  while (true) {
    ans++;
    queue<pii> tmp;
    bool flg = false;

    while (!q.empty()) {
      pii p = q.front();
      q.pop();
      int a = min(p.F, p.S);
      int b = max(p.F, p.S);
      cnt[a][b]++;
      if (cnt[a][b] == 2) {
        idx[a]++;
        idx[b]++;
        if (idx[a] < N - 1) {
          tmp.push(mp(a, A[a][idx[a]]));
        }
        if (idx[b] < N - 1) {
          tmp.push(mp(b, A[b][idx[b]]));
        }
        flg = true;
      }
    }

    if (flg && tmp.empty()) {
      cout << ans << endl;
      return 0;
    }

    if (!flg) {
      cout << "-1" << endl;
      return 0;
    }

    q = tmp;
  }
}


Measured memory_bytes: 8064
#include<stdio.h>

int Partition(int [],int,int);
void Quicksort(int [],int,int);

int main(){
  int n,i,endnumber;
  int A[100001];
  
  scanf("%d", &n);
  for( i = 1; i <= n; i++ ){
    scanf("%d", &A[i]);
  }
 
  endnumber=Partition(A, 1, n);
 
  for(i=1;i< n;i++){
    if(i==endnumber){
      printf("[%d] ",A[i]);
    }
    else
      printf("%d ",A[i]);
  } 
  printf("%d\n",A[i]);

  return 0;
}

int Partition(int A[],int p,int r){
  int x,i,j,exchange;
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      exchange=A[j];
      A[j]=A[i];
      A[i]=exchange;
    }
  }
  exchange=A[i+1];
  A[i+1]=A[r];
  A[r]=exchange;

  return i+1;
}

Measured memory_bytes: 988
N=int(input())
dp=[[0]*3 for i in range(N+1)]
for i in range(N):
  a,b,c=map(int,input().split())
  dp[i+1][0]=max(dp[i][1],dp[i][2])+a
  dp[i+1][1]=max(dp[i][0],dp[i][2])+b
  dp[i+1][2]=max(dp[i][0],dp[i][1])+c
print(max(dp[N]))
  

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

int tax8(int x){
  double res = x*0.08;
  return floor(res);
}

int tax10(int x){
  double res = x*0.1;
  return floor(res);
}

int tax(int A, int B){
  for(int i=10; i<=1250; i++){
    if(tax8(i)==A && tax10(i)==B){
      return i;
    }
  }
  return -1;
}

int main(){
  int A, B;
  cin >> A >> B;
  cout << tax(A,B) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t;
  cin>>n>>t;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  vector<int> s(n,0);
  int al=a.at(0);
  int sm=0;
  for(int i=1;i<n;i++){
    s.at(i)=a.at(i)-al;
    sm=max(sm,s.at(i));
    al=min(al,a.at(i));
  }
  int cs=0;
  for(int i=0;i<n;i++)
    if(s.at(i)==sm)
      cs++;
  vector<int> b(n,0);
  int ag=a.at(n-1);
  int bm=0;
  for(int i=n-2;i>=0;i--){
    b.at(i)=ag-a.at(i);
    bm=max(bm,b.at(i));
    ag=max(ag,a.at(i));
  }
  int cb=0;
  for(int i=0;i<n;i++)
    if(b.at(i)==bm)
      cb++;
  cout<<min(cs,cb)<<endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>

typedef long long i64;

i64 mem[20];

i64 dfs(int l, int r, i64 d) {
  if (l >= r) return d ? 0 : (l == r ? 10 : 1);
  int t = (10 - d % 10) % 10;
  i64 v = d - t * mem[r - l] + t;
  return ((l ? 10 : 9) - t) * dfs(l + 1, r - 1, llabs(v) / 10);
}

int main() {
  mem[0] = 1;
  for (int i = 1; i <= 18; ++i) mem[i] = 10 * mem[i - 1];
  int d;
  scanf("%d", &d);
  i64 ans = 0;
  for (int i = 0; i <= 18; ++i) ans += dfs(0, i, d);
  printf("%lld\n", ans);
  return 0;
}


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

int main(void) {
    int n, m;
    cin >> n >> m;
    map<int, bool> mp;
    int fk;
    cin >> fk;
    for (int i = 0; i < fk; i++) {
        int fa;
        cin >> fa;
        mp[fa] = true;
    }
    for (int i = 1; i < n; i++) {
        int k;
        cin >> k;
        map<int, bool> kmp;
        for (int ki = 0; ki < k; ki++) {
            int a;
            cin >> a;
            if (mp.count(a) > 0) {
                kmp[a] = true;
            }
        }
        mp = kmp;
    }
    cout << mp.size() << endl;
    return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

struct edge { int to, cost; };
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;


struct UnionFind {
  vector<int> par,ranc;
  
  UnionFind(int N) : par(N),ranc(N) { REP(i,N) par[i]=i,ranc[i]=0; }
  
  int root(int s) {
    if (par[s]==s) return s;
    else return root(par[s]);
  }
  
  bool same(int x, int y) { return root(x)==root(y); }
  
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x==y) return;
    if (ranc[x]>ranc[y]) {
      par[y] = x;
    } else {
      par[x] = y;
      if (ranc[x]==ranc[y]) ranc[y]++;
    }
  }
};

int main() {
  int N,M;cin>>N>>M;
  VECINT PS(N);
  REP(i,N) {
    cin>>PS[i];
    PS[i]--;
  }

  // 同じUniteツリーの中に属していれば、OK
  UnionFind uf(N);
  REP(i,M) {
    int x,y;cin>>x>>y;
    x--;y--;
    uf.unite(x,y);
  }

  int ans = 0;
  REP(i,N) {
    if (uf.same(uf.root(i),uf.root(PS[i]))) ans++;
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    bool odd_flag;int counter=0;
    while(1){
        odd_flag=false;
        for(int i=0;i<n;i++)
        {
            if(a[i]%2==1)
            odd_flag=true;
        }
        if(odd_flag)
        break;
        for(int i=0;i<n;i++)
        a[i]/=2;
        counter++;
    }
    cout<<counter<<endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        a: [u64; n],
    }

    let mut r = 1000u64;
    for i in 0..n - 1{
        if a[i] < a[i + 1] {
            let s = r / a[i];
            r += s * (a[i + 1] - a[i]);
        }
    }
    println!("{}", r);
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int was[110];

signed main(){
   IOS;
   int x,n; cin >> x >> n;
   for(int i = 0; i < n; i++) {
      int it; cin >> it;
      was[it] = 1;
   }
   vector<pair<int,int> > ans;
   for(int i = 0; i < 10000; i++) {
      if(i < 110) {
         if(!was[i]) ans.push_back({abs(i-x), i});
      }
      else ans.push_back({abs(i-x), i});
   }  
   sort(ans.begin(), ans.end());
   cout << ans[0].second << "\n";
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a[9];
  int N;
  cin >> a[0] >> a[1] >> a[2];
  cin >> a[3] >> a[4] >> a[5];
  cin >> a[6] >> a[7] >> a[8];
  cin >> N;
  int *b = new int[N];
  
  for(int i=0; i<N; i++){
	cin >> b[i];
	for(int j=0; j<9; j++){
	  if(a[j] == b[i]) a[j] = 0;
	}
  }
  /*
  for(int i=0; i<9; i+=3){
	cout << a[i] << " " << a[i+1] << " " << a[i+2] << endl;
  }
  */
  // yoko bingo check
  if(a[0] == a[1] && a[1] == a[2] && a[0] == 0){
	cout << "Yes" << endl;
  }
  else if(a[3] == a[4] && a[4] == a[5] && a[3] == 0){
	cout << "Yes" << endl;
  }
  else if(a[6] == a[7] && a[7] == a[8] && a[6] == 0){
	cout << "Yes" << endl;
  }
  // tate bingo check
  else if(a[0] == a[3] && a[3] == a[6] && a[0] == 0){
	cout << "Yes" << endl;
  }
  else if(a[1] == a[4] && a[4] == a[7] && a[1] == 0){
	cout << "Yes" << endl;
  }
  else if(a[2] == a[5] && a[5] == a[8] && a[2] == 0){
	cout << "Yes" << endl;
  }
  // naname bingo check
  else if(a[0] == a[4] && a[4] == a[8] && a[0] == 0){
	cout << "Yes" << endl;
  }
  else if(a[2] == a[4] && a[4] == a[6] && a[2] == 0){
	cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
  
  delete[] b;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

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

int main(void){
   long long Q,H,S,D;
   cin>>Q>>H>>S>>D;
   long long N;
   cin>>N;
   long long temp1=min(min(Q*4,H*2),S);
   long long temp2=min(min(min(8*Q,4*H),2*S),D);
   cout<<(N/2)*temp2+(N%2)*temp1<<endl;
   return 0;
}


Measured memory_bytes: 256
n = int(input())
tbl = [[False for i in range(13)] for j in range(4)]
for i in range(n):
    mark,num = input().split()
    number = int(num)
    if mark == 'S':
      tbl[0][number-1] = True
    elif mark == 'H':
      tbl[1][number-1] = True
    elif mark == 'C':
      tbl[2][number-1] = True
    else:
      tbl[3][number-1] = True
      
for j in range(4):
  for i in range(13):
    if tbl[j][i] == False:
      if j == 0:
        print(f'S {i+1}')
      if j == 1:
        print(f'H {i+1}')
      if j == 2:
        print(f'C {i+1}')
      if j == 3:
        print(f'D {i+1}')


Measured memory_bytes: 5620
A,B,H,M=map(int,input().split())

import math
hkaku=0
mkaku=0

hkaku=(H%12)*30+M/2
mkaku=M*6
kaku=abs(hkaku-mkaku)
#print(hkaku,mkaku)
#print(kaku)
if kaku > 180:
    kaku=360-kaku
C=A**2+B**2-2*A*B*math.cos(math.radians(kaku))
C=C**(1/2)
print(C)

Measured memory_bytes: 9568
N,x = map(int,raw_input().split())
a = map(int,raw_input().split())

a.sort()

score = 0
count = N
for i in range(N):
    score+=a[i]
    if score > x:
        count = i
        break

if count==N and score<x:
    count-=1

print count

Measured memory_bytes: 2568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.System.in;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int N = Integer.parseInt(reader.readLine());
        int[] table = new int[N];
        for (int i = 0; i < N; i++) {
            table[i] = Integer.parseInt(reader.readLine());
        }

        Arrays.sort(table);

        int[] b = new int[N];
        int currentIndex = 0;
        int currentNum = 0;
        for (int i = 0; i < N; i++) {
            if (currentNum == table[i]) {
                b[currentIndex] += 1;
            } else {
                currentNum = table[i];
                currentIndex += 1;
                b[currentIndex] += 1;
            }
        }


        int counter = 0;
        for (int i = 1; i < N; i++) {
            if(b[i] % 2 ==1) {
                counter +=1;
            }
        }

        System.out.println(counter);
    }
}

Measured memory_bytes: 33096
module Main where

import Control.Applicative
import Numeric
import Data.List

main :: IO ()
main = do
  { [n] <- getInts
  ; cards <- loop n
  ; putCards (allcards \\ cards)
  }

putCards :: [(Suit, Int)] -> IO()
putCards = putStr . unlines . map showCard

loop :: Int -> IO [(Suit, Int)]
loop 0 = return []
loop n = do
  { c <- getCard
  ; cs <- loop (n-1)
  ; return (c:cs)
  }

showCard :: (Suit, Int) -> String
showCard (s, n) = show s ++ " " ++ show n

--

data Suit = S | H | C | D deriving (Eq, Ord, Show, Read)

allcards :: [(Suit, Int)]
allcards = [(s, r) | s <- [S, H, C, D], r <- [1 .. 13]]

getCard :: IO(Suit, Int)
getCard = do
  {[s, r] <- words <$> getLine
  ; return (read s, read r)
  }

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""

done :: IO()
done = return ()



Measured memory_bytes: 4228
#include <stdio.h>

int main(void){

  int a,b,c,d,e,k;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  scanf("%d", &k);

  if (e-a > k) {
    printf(":(\n");
  } else {
    printf("Yay!\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
struct Number
{
    int n;
    int diff;
};
bool cmp(Number n1, Number n2)
{
    return n1.diff < n2.diff;
}
int main()
{
    int n = 5;
    Number arr[n];
    int max1 = 0,in = 0;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i].n;
        if(arr[i].n%10 == 0)
        {
            arr[i].diff = 0;
            continue;
        }
        int ps = ((arr[i].n)/10)*10 + 10;
        arr[i].diff = ps - arr[i].n;
        if(arr[i].diff > max1)
            max1 = arr[i].diff, in = i;
    }
    
    // cout<<max1<<" "<<in<<" ";
    // sort(arr, arr+n, cmp);
    // for(int i=0; i<n; i++)
        // cout<<arr[i].n<<" "<<arr[i].diff<<"\n";
    int ans = 0;
    for(int i=0; i<n; i++)
    {
        ans += arr[i].n;
        if(i != in)
            ans += arr[i].diff;
        // cout<<ans<<" ";
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
#define ll long long

int M,N;
vector<int> A;
int sum;
int debug=0;

int main(){
    cin >> N >> M;
    sum=0;
    for(int i=0;i<N;++i){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
        sum+=tmp;
    }

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

    if(debug){
        for(int i=0;i<N;++i){
            cout << A[i] << " ";
        }
        cout << endl;
    }


    // sum = number of votes
    // 
    int line = sum / (4 * M);
    // round up
    int r = sum % (4*M);
    if (r != 0 ) line++;

    if(debug){
        cout <<"line=" << line << endl;
    }

    for(int i=0;i<M;++i){
        if(A[i] < line){
            cout << "No" << endl;
            return 0;
        }
    }

    // Yes
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll r, d, x0;
    cin >> r >> d >> x0;
    ll res = x0;
    REP(i, 10){
        res = r * res - d;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		int ans = n*a;
		
		if (ans>b) {
			ans=b;
		}
		
		System.out.println(ans);
		
		scanner.close();
	}

}


Measured memory_bytes: 21972
s=list(input())
a=len(s)
cnt=0
if a%2==0:
  for i  in range(a//2):
    if s[i]!=s[a-1-i]:
      cnt+=1
elif a%2!=0:
  for i in range(a//2):
    if s[i]!=s[a-1-i]:
      cnt+=1
print(cnt)      

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

int main(){
  char x;
  cin >> x;
  
  if( x=='A' || x=='B' || x=='C' || x=='D' || x=='E' || x=='F' ||
     x=='G' || x=='H' || x=='I' || x=='J' || x=='K' || x=='L' ||
     x=='M' || x=='N' || x=='O' || x=='P' || x=='Q' || x=='R' ||
     x=='S' || x=='T' || x=='U' || x=='V' || x=='W' || x=='X' ||
     x=='Y' || x=='Z' ){
    cout << 'A' << endl;
  }
  else{
    cout << 'a' << endl;
  }
}

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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int x; cin >> x;

    int money=100;
    int year=0;
    while(true){
        year++;
        money+=money*0.01;
        if(money>=x) {
            cout << year<<endl;
            break;
        }
    }
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_165_We_Love_Golf
    {
        // https://atcoder.jp/contests/abc165/tasks/abc165_a
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long k = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var Array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int a = Array[0];
            int b = Array[1];

            for (int i = a; i < b + 1; i++)
            {
                if (i % k == 0)
                {
                    Console.WriteLine("OK");
                    break;
                }
                else if (i == b)
                {
                    Console.WriteLine("NG");
                }
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28296
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a;
    string s;
    
    cin >> a;
    cin >> s;
    
    if (a >= 3200) {
        cout << s << endl;
    }else {
        cout << "red" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 888
#pragma region Imports
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#pragma endregion
#pragma region Macros
#pragma GCC optimize (2)
#define uns unsigned
#define out cout
#define in cin
#define au auto
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define elif else if
#define sz(x) x.size()
#define fl(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define fli(i, a, b, c) for(int (i)=a;(i)<(b);(i)+=(c))
#define fr(i, x) for(int (i)=(x)-1;(i)>=0;(i)--)
#define fb(i, x) for(int (i)=0;(i)<(x);(i)++)
#define fa(i, x) for(auto& (i):(x))
#define ia(a, n) for(int qw=0;qw<(n);qw++)cin>>(a)[qw];
#define oa(a, n) for(int qw=0;qw<(n);qw++)cout<<(a)[qw]<<" ";
#define im(a, n, m) fb(i,(n))fb(j,(m))cin>>(a)[i][j];
#define om(a, n, m) fb(i,(n))fb(j,(m))cout<<(a)[i][j]<<" \n"[j==(m)-1];
#define eb(v, x) (v).emplace_back(x);
#define seb(s, x) (s).emplace(x);
#define pr(x, y) pair<x,y>
#define vr(x) vector<x>
#define mp(x, y) make_pair(x,y)
#define hm(x, y) map<x,y>
#define um(x, y) unordered_map<x,y>
#define stk(x) stack<x>
#define qu(x) queue<x>
#define dq(x) deque<x>
#define pq(x) priority_queue<x>
#define pqm(x) priority_queue<x,vector<x>,greater<(x)>>
#define mem(a, x) memset(a,(x),sizeof(a));
#define fi(x) (x).first
#define se(x) (x).second
#define ql(x) int tc;tc=(x);if(tc==-1)cin>>tc;while(tc--)
#define srt(x) sort((x).begin(),(x).end());
#define pops(y, x) auto (y)=(x).front();(x).pop();
#define ppc(x) __builtin_popcount((x))
#define all(x) (x).begin(),(x).end()
#define sieve(b, n) bool (b)[(n)];mem((b),true);int sq=int(sqrt(n))+1;(b)[0]=(b)[1]=false;fl(i,2,sq)if((b)[i])fli(j,i*i,n,i)(b)[j]=false;
#define dbg(x) cout<<#x<<" "<<(x)<<"\n";
#pragma endregion
#pragma region Typedefs and Consts
typedef long long int ll;
typedef unsigned long long int ull;
typedef string stg;
typedef float flo;
typedef char chr;
typedef vector<int> vi;
const ull mod = 1000000007;
const int imx = INT_MAX;
const int imn = INT_MIN;
const ll lmx = LLONG_MAX;
const ll lmn = LLONG_MIN;
#pragma endregion
#pragma region Functions
inline ull powm(ull x,ull y,bool b=false,ull m=mod){ if(b){ ull t=1;x%=m;while(y>0){ if(y%2)t=(t*x)%m;y=y>>1;x=(x*x)%m; }return t; }else
    { ull t=1;while(y>0){ if(y&2)t*=x;y=y>>1;x*=x; }return t;}}
inline ll gcd(ll a,ll b){a=abs(a);b=abs(b); while(b!=0){ ll c=a%b;a=b;b=c;}return a;}
#pragma endregion

//cout<<"Case #"+to_string(tc+1)+": "+to_string(z)<<endl;
int main() {
  fio
  string s,t;
  in>>s>>t;
  int n=sz(s),m=sz(t);
  int z[n+1][m+1];
  mem(z,0)
  fb(i,n)
    fb(j,m)
    if(s[i]==t[j])
      z[i+1][j+1]=z[i][j]+1;
  	else
      z[i+1][j+1]=max(z[i][j+1],z[i+1][j]);
  int i=n-1,j=m-1;
  string q;
  while(i>=0 and j>=0){
    if(s[i]==t[j]){
      q+=s[i--];
      j--;
    }
    elif(z[i][j+1]>z[i+1][j])
      i--;
    else
      j--;
  }
  reverse(q.begin(),q.end());
  out<<q;
  return 0;
}

Measured memory_bytes: 35456
N, M, C = map(int, input().split())
B = list( map(int, input().split()))

count = 0

for i in range(N):
    A = list(map(int, input().split()))
    num = C
    for j in range(M):
    	num += A[j] * B[j]
        
    if num > 0:
        count += 1

print(count)
    

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

int main()
{
	int n,t[55][26]={};
	string s,ans="";
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		for(int j=0;j<s.length();j++)
		{
			t[i][s[j]-'a']++;
		}
		for(int j=0;j<26;j++)
		{
			if(i)t[i][j]=min(t[i][j],t[i-1][j]);
		}
	}
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<t[n-1][i];j++)
		{
			ans+='a'+i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    INT x; cin >> x;
    INT sum = 100;
    INT ans = 0;
    while (sum < x) {
        sum = (INT)((double)(sum * 1.01));
        ans++; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
  ll n;
  cin >> n;
  vector<pair<string,ll>> st(n);

  for (ll i = 0; i < n; i++)
  {
    ll t;
    string s;
    cin >> s >> t;

    st[i] = make_pair(s,t);
  }

  string x;
  cin >> x;
  ll ans = 0;

  bool is = false;
  for (ll i = 0; i < n; i++){
    if (is){
      ans+= st[i].second;
    }
    if (st[i].first == x){
      is = true;
    }
  }

    cout<< ans<<endl;

}


Measured memory_bytes: 256
n,k = map(int,input().split())

count = 0
p = []

for i in range(n):
    p.append(0)

for i in range(k):
    d = int(input())
    h = list(map(int,input().split()))
    for j in range(len(h)):
        p[h[j]-1] += 1

for i in range(n):
    if p[i] == 0:
        count += 1

print(count)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int A,B,X;cin>>A>>B>>X;
    if(A<=X && X<=A+B){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;

class Program
{
	//numC2を計算
	static int Combi(int num){
			if(num < 2){
					return 0;
			}else{
					return num * (num-1) / 2;
			}
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] S = Console.ReadLine().Split(' ');

		int N = int.Parse(S[0]);
		int M = int.Parse(S[1]);

		//答えはNC2 + MC2である。（Nから2個 or Mから2個）
		int answer = Combi(N) + Combi(M);

		Console.WriteLine(answer);
	}
}



Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#define ll long long

using namespace std;

ll q,a,b; 

int main()
{
	int q;
	cin >> q;
	for (int query = 0; query < q; ++query)
	{
		ll a, b;
		cin >> a >> b;
		if (a > b)
		{
			swap(a, b);
		}
 
		ll ans = 0;
 
		if (a == 1 && b == 1)
		{
			ans = 0;
		}
		else
		{
 
			ll c = a*b - 1;
			ll x = sqrt(c) + 100;
 
			while (x*x>c)
			{
				x--;
			}
 
 
 
 
 
 
			ans = x * 2;
 
			if (x == c / x)
			{
				ans--;
			}
 
			if (x >= a)
			{
				ans--;
			}
 
			// BEGIN CUT HERE
//			cerr << "a=" << a << " b=" << b << " c=" << c << " x=" << x << " c/x=" << c/x << " ans=" << ans << endl;
			// END CUT HERE
 
 
 
		}
 
 
 
 
		cout << ans << endl;
	}
 
 
 
 
	return 0;
}

// int main(){
	
// 	cin>>q;
// 	while(q){
// 		cin>>a>>b;
// 		if(a==1&&b==1){
// 			cout<<0<<endl;
// 			return 0;
// 		}
// 		ll min1=min(a,b);
// 		ll x=sqrt(a*b)+100;
// 		while(x*x>(a*b)-1)x--;
// 		ll ans=2*x;
// 		if(x>=min1)ans--;
// 		if(x==((a*b)-1)/x)ans--;
// 		cout<<ans<<endl;

// 		q--;
// 	}


// 	return 0;
// }



Measured memory_bytes: 256
import java.util.*;

class Main {
	static int n;
	static int[] v;
	static int[] c;
	static int x;
	static int y;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		v = new int[n];
		c = new int[n];
		for (int i = 0; i < n; i++) {
			v[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			if (v[i] > c[i]) {
				x += v[i];
				y += c[i];
			}
		}
		System.out.println(x - y);
	}
}

Measured memory_bytes: 21716
import sys,bisect
sys.setrecursionlimit(15000)
s = sys.stdin.readline().rstrip()
st = []
ars = []
ar = 0
for i,c in enumerate(s):
  if c == "\\":
    st.append(i)
  elif c == "/":
    if st:
      j = st.pop()
      ar += i-j
      while ars and j < ars[-1][1]:
        ar0,_ = ars.pop()
        ar += ar0
      ars.append([ar,j])
      ar = 0
print(sum([ar for ar,_ in ars]))
if len(ars)==0:
  print(0)
else:
  print(len(ars)," ".join(map(str,[ar for ar,_ in ars])))


Measured memory_bytes: 6232