akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int i,j,k;
	int h,w;

	for (i = 0; 1; i++)
	{
		scanf("%d %d",&h,&w);

		if (h == 0 && w == 0)break;

		for(j = 0; j < h; j++)
		{
			for(k = 0; k < w; k++)
			{
				if ( (j+k) % 2 == 0)
				{
					printf("#");
				}else
				{
					printf(".");
				}
			}

			printf("\n");
		}

		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  REP(i, 0, N) cin >> A[i] >> B[i];

  bool ok = true;
  REP(i, 0, N) ok = ok && A[i] == B[i];
  if(ok) {
    cout << 0 << endl;
    return 0;
  }

  bool t = true;
  REP(i, 0, N) ok = ok && A[i] > B[i];
  if(t) {
    ll ans = accumulate(A.begin(), A.end(), 0LL);
    cout << endl;
  }

  ll ans = 0;
  vector<ll> cand;
  REP(i, 0, N) {
    if(A[i] <= B[i]) {
      ans += B[i];
    } else {
      cand.push_back(B[i]);
    }
  }
  sort(cand.begin(), cand.end());
  REP(i, 1, cand.size()) ans += cand[i];
  cout << ans << endl;
}


Measured memory_bytes: 768
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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


fn solve(a: i64, b: i64) -> &'static str {
    if a == b {
        "Draw"
    } else if a == 1 || (b != 1 && a > b) {
        "Alice"
    } else {
        "Bob"
    }
}

fn main() {
    input!{
        a: i64,
        b: i64,
    }
    println!("{}", solve(a, b));

}


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

int main() {
	int n,m;cin>>n>>m;
	vector<long long> a(n),start(m+1,0);
	vector<pair<int,long long>> end(m+1,make_pair(0,0));
	long long sum=0;
	long long minus,temp=0;
	long long num=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i!=n-1){
			start[a[i]]++;
		}
		if(i!=0){
			end[a[i]].first++;
			long long add=a[i]-a[i-1];
			if(add<0){
				add+=m;
				if((a[i]>a[0])+(a[0]>a[i-1])){
					num++;
					if(a[0]>a[i-1]){
						temp+=a[0]-a[i-1];
					}else{
						temp+=a[0]-a[i-1]+m;
					}
				}
			}else{
				if((a[i-1]<a[0])*(a[0]<a[i])){
					num++;
					temp+=a[0]-a[i-1];
				}
			}
			end[a[i]].second+=add;
			sum+=add;
		}
	}
	temp+=end[a[0]].second;
	num+=end[a[0]].first;
	temp-=num;
	minus=temp;
	int a0=a[0];

	sort(a.begin(),a.end());
	int i=0;
	while(a[i]<a0)i++;
	do{
//		cout<<a[i]<<' '<<temp<<' '<<num<<endl;
		temp-=end[a[i]].second;
		temp+=num;
		num-=end[a[i]].first;
		num+=start[a[i]];
		temp-=num;
		long long ex=i;
		while(a[i]==a[ex]){
			i++;
			if(i==n)i=0;
		}
//		cout<<i<<endl;
		long long add=a[i]-a[ex];
		if(add<0)add+=m;
		temp+=num*add;
		if(minus<temp)minus=temp;


	}while(a[i]!=a0);
	long long ans=sum-minus;
//	cout<<sum<<endl;
//	cout<<minus<<endl;
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 3328
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = float("inf")
for i in range(-101,201):
    if i not in p:
        ans = min(ans,abs(x-i))
if x - ans not in p:
    print(x-ans)
else:
    print(x+ans)

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

int main(){
  int N;
  cin >> N;
  
  vector <int> A(N-1);
  vector <int> B(N,0);
  
  
  rep(i,N-1){
    cin >> A.at(i);
      B.at((A.at(i))-1)++;
  }
  
  rep(i,N){
    cout << B.at(i) << endl;
  }

}


  

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

int main(){

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

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 2000001
#define inf 1e17
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,b,a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,n,m,m1,m2,n1,n2,o,p1,p2,p3,p4,
q1,q2,q3,q4,r,s,t,x,y,z,sum,mn,flg,flg1,flg2,id1,id2,id3,lim,cost;
char str[10];
int main()
{
    scanf("%s",str);
    if(str[1]=='B'){
        str[1]='R';
    }else str[1]='B';
    printf("%s\n",str);
    // solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


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

typedef uint32_t u32;

template<u32 N_>
class UnionFindTree {
private:
  u32 par[N_];
  u32 rank[N_];
public:
  UnionFindTree(u32 n) {
    assert(n < N_);
    for(u32 i = 0; i < n; ++i) {
      par[i] = i;
      rank[i] = 0;
    }
    return;
  }
  int find(u32 x) {
    if( par[x] == x ) return x;
    return par[x] = find(par[x]);
  }
  void unite(u32 x, u32 y) {
    x = find(x);
    y = find(y);
    if( x == y ) return;
    if( rank[x] < rank[y] ) {
      par[x] = y;
      return;
    }
    par[y] = x;
    if( rank[x] == rank[y] ) rank[x] += 1;
    return;
  }  
};

int main() {

  u32 n, m;
  std::cin >> n >> m;

  UnionFindTree<200000> uft(n);

  for(u32 i = 0; i < m; ++i) {
    u32 x, y;
    std::cin >> x >> y;
    uft.unite(x, y);
  }

  u32 q;
  std::cin >> q;

  for(u32 i = 0; i < q; ++i) {
    u32 x, y;
    std::cin >> x >> y;
    std::cout << (uft.find(x) == uft.find(y) ? "yes" : "no") << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1944
#include <stdio.h>

int main(void)
{
	int a[7], b[7];
	int i;
	for( i = 0; i < 7; i++ )
	{
		scanf( "%d %d", &a[i], &b[i] );
	}
	for( i = 0; i < 7; i++ )
	{
		printf( "%d\n", a[i]-b[i] );
	}
	return 0;
}


Measured memory_bytes: 2108
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

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")
}

struct Main {}

impl Main {
    fn invoke() {}
}

fn main() {
    let s: String = read();
    let cs = s.chars().collect::<Vec<char>>();
    if cs[2] == cs[3] && cs[4] == cs[5] {
        println!("Yes");
    } else {
        println!("No")
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int a, b;
	cin >> a >> b;
	print((a - 1)*(b - 1));

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0

for i in range(n):
    cnt = cnt + a[i]

a = sorted(a, reverse=True)

chflg = True

for i in range(m):
    if a[i] < cnt * 1 / (4 * m):
        chflg = False

if chflg == True:
    print('Yes')
else:
    print('No')


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll dp[100005];

map<ll, vector<ll>> m;

ll rec(ll v) {
  if (dp[v] >= 0) {
    return dp[v];
  }

  auto ite = m[v].begin();

  ll r = 0;

  for (; ite != end(m[v]); ite++) {
    // cout << (*ite) << endl;
    r = max(r, rec(*ite) + 1);
  }

  dp[v] = r;

  return r;
}

int main() {
  ll N, M;
  scanf("%lld %lld", &N, &M);

  for (ll i = 0; i < M; i++) {
    ll x, y;
    scanf("%lld %lld", &x, &y);
    x--;
    y--;

    m[x].emplace_back(y);
  }

  fill_n(dp, 100005, -1);

  ll ans = 0;

  for (ll i = 0; i < N; i++) {
    ans = max(ans, rec(i));
  }

  cout << ans << endl;
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void Pr(bool f){
    cout << (f ? "Possible" : "Impossible") << endl;
    if(!f) exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, l;
    cin >> n >> l;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    vll ans;
    ll ans0;
    rep(i, n-1){
        if(a[i]+a[i+1]>=l){
            ans.emplace_back(i+1);
            ans0 = i+1;
            Pr(1);
            break;
        }
        if(i == n-2){
            Pr(0);
        }
    }
    repr(i, ans0+1, n){
        ans.emplace_back(i);
    }
    reprb(i, ans0, 1){
        ans.emplace_back(i);
    }
    reverse(ALL(ans));
    rep(i, n-1){
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 2548
public class Main {

	/**
	 * ????????????????????????
	 *
	 */
	public static void main(String[] args) {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				System.out.println(i + "x" + j + "=" + i*j);
			}
		}
	}
}

Measured memory_bytes: 24008
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


int main() {
	ll n, k, a[100010], rui[100010], sei[100010], ans = 0;
	cin >> n >> k;
	for (int i = 1;i <= n;i++) {
		cin >> a[i];
		rui[i] = rui[i - 1] + a[i];
		if (a[i] > 0)sei[i] = sei[i - 1] + a[i];
		else sei[i] = sei[i - 1];
	}
	for (int i = 1;i <= n - k+1;i++) {
		ll sum = 0;
		sum += sei[i - 1] + sei[n] - sei[i + k - 1];
		sum = max(sum, sum + rui[i + k - 1] - rui[i - 1]);
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b) swap(a,b);
    if(a>c) swap(a,c);
    if(b>c) swap(b,c);
    cout<<a<<" "<<b<<" "<<c<<endl;

    return 0;
}




Measured memory_bytes: 3092
import fs = require('fs')

var sum  = function(arr) {
    return arr.reduce(function(prev, current, i, arr) {
        return prev+current;
    });
};

function main (input){
    const pqr = input.trim().split(" ").map(n=>Number(n));
    console.log(sum(pqr) - Math.max(...pqr));
};

main(fs.readFileSync('/dev/stdin','utf8').trim())

Measured memory_bytes: 7372
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


class DGraph:
    def __init__(self, n, edges):
        self._vertice = [{} for _ in range(n)]
        for e in edges:
            self._vertice[e[0]][e[1]] = e[2] if len(e) == 3 else 1

    def __len__(self):
        return len(self._vertice)

    def edges(self, n=None):
        srcs = range(len(self)) if n is None else [n]
        return sum([[(s, d, c) for d, c in self._vertice[s].items()] for s in srcs], [])

    def transpose(self):
        tedges = [(t, f, c) for f, t, c in self.edges()]
        return DGraph(len(self), tedges)

    def cost(self, src, dst):
        return self._vertice[src].get(dst, float('inf'))

class Graph(DGraph):
    def __init__(self, n, edges):
        nd_edges = edges + [(d, s, c) for s, d, c in edges]
        super().__init__(n, nd_edges)

    def transpose(self):
        return self


def solve(N: int, x: "List[int]", y: "List[int]"):
    xs = {v:i for i, v in enumerate(set(x))}
    ys = {v:i for i, v in enumerate(set(y), len(xs))}
    
    n = len(xs) + len(ys)
    es = [(xs[cx], ys[cy], 1) for cx, cy in zip(x, y)]
    g = Graph(n, es)

    visited = [False] * len(g)
    def dfs(g, src):
        nonlocal visited
        stack = [(src, 0)]
        while stack:
            n, c = stack.pop()
            if visited[n]:
                continue
            visited[n] = True

            for _, d, _ in g.edges(n):
                #yield d
                stack.append((d, c + 1))
            yield n

    def _f(i):
        ls = list(i)
        if len(ls) == 0:
            return 0

        xc = 0
        yc = 0
        es = 0
        for i in ls:
            es += len(g.edges(i))
            if i < len(xs):
                xc += 1
            else:
                yc += 1
        es //= 2

        if xc < 2 or yc < 2:
            return 0

        return xc * yc - es

    return sum([_f(dfs(g, i)) for i in range(n)])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    result = solve(N, x, y)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69628
#include <iostream>

using namespace std;

int main()
{
    char S[3];
    int count = 0;

    for (int i = 0; i < 3; i++)
    {
        scanf("%c", &S[i]);
        if (S[i] == 'A')
            count++;
    }

    count == 1 || count == 2 ? cout << "Yes" : cout << "No";
    cout << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;


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

    vector<long> point(N, K -Q); //参加者Ｎ人、持ち点Ｋ-Q点
    vector<long> A(Q);
    rep(i, Q) {
        cin >> A.at(i);
        point.at(A.at(i) - 1)++;
    }

    rep(i, N) {
        if (point.at(i) > 0) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2+2], R[MAX/2+2];
int count;

void merge(int A[], int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for(int k = left; k < right; k++){
        count++;
        if(L[i] <= R[j]){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main(){
    int A[MAX], n, i;
    count = 0;
    cin >> n;
    for(i = 0; i < n; i++) cin >> A[i];

    mergeSort(A, n, 0, n);
    for(i = 0; i < n; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 6972
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>

using namespace std;

struct team{
    int num;
    int ac;
    int pen;

    bool operator<(const team &arg) const{
        if(ac != arg.ac){
            return ac > arg.ac;
        }else if(pen != arg.pen){
            return pen < arg.pen;
        }else{
            return num < arg.num;
        }
    }

    team(int _n, int _ac, int _pen):num(_n),ac(_ac),pen(_pen){}

};

int main(){
    int t,p,r;

    while(cin >> t >> p >> r){
        if((t|p|r) == 0) break;
        vector<team> teams;
        int wa_cnt[t+1][p+1];
        bool aced[t+1][p+1];
        int tid,pid,time;
        string mes;

        memset(wa_cnt, 0, sizeof(wa_cnt));
        memset(aced, 0, sizeof(aced));


        for(int i=0;i<t;i++){
            teams.push_back(team(i+1,0,0));
        }

        for(int i=0;i<r;i++){
            cin >> tid >> pid >> time >> mes;
            if(aced[tid][pid]) continue;

            if(mes == "CORRECT"){
                teams[tid-1].ac++;
                teams[tid-1].pen += wa_cnt[tid][pid] * 1200 + time;
                aced[tid][pid] = true;
            }else{
                wa_cnt[tid][pid]++;
            }
        }
        sort(teams.begin(), teams.end());
        for(int i=0;i<t;i++){
            cout << teams[i].num << " " << teams[i].ac << " " << teams[i].pen << endl;
        }
    }
}

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

using namespace std;
using ll = long long;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    if(a < b) swap(a, b);
    vector<int> ans;
    for(int i = 1; i <= b; i++) {
        if(a % i == 0 && b % i == 0){
            ans.push_back(i);
        }else continue;
    }
    sort(ans.rbegin(), ans.rend());
    cout << ans[k-1] << 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 rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int cnt = 0;
    for (int m = 1; m <= M; m++) {
        for (int d = 1; d <= D; d++) {
            int d1 = d % 10;
            int d10 = d / 10;
            if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
L=[]
for i in range(N):
  a=list(map(int,input().split()))
  for b in a[1:]:
    L.append(b)
ans=0
for i in range(31):
  if L.count(i)==N:
    ans=ans+1
print(ans)

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
vector<ll> storage;
ll INF=(1ll*1000*1000*1000)*(1ll*1000*1000);
int n=1;
void updateLeaf(int i,ll v) {
    i+=n-1;
    if (storage[i]<=v)return;
    storage[i]=v;
    while(i>0) {
        i=(i-1)/2;
        storage[i]=min(storage[i*2+1],storage[i*2+2]);
    }
}
ll rangeMin(int a, int b, int k, int l, int r) {
    if(b<=l || a>=r) return INF;
    if(a<=l && b>=r) {
        return storage[k];
    } else {
        ll tl = rangeMin(a,b,k*2+1,l,(l+r)/2);
        ll tr = rangeMin(a,b,k*2+2,(l+r)/2,r);
        return min(tl,tr);
    }
}
ll N,M;
struct Se{ll L,R,C;};
vector<Se> LRCs;
int main() {
    cin >> N >> M;
    n=1;
    while(n<N)n*=2;
    storage.resize(n*2,INF);
    updateLeaf(0,0);
    REP(i,M) {
        ll L,R,C;
        cin >> L >> R >>C;
        L--;R--;
        LRCs.pb({L,R,C});
    }
    sort(ALL(LRCs),[](Se& a, Se& b){return a.L<b.L;});
    REP(i,M){
        Se& t=LRCs[i];
        ll v=rangeMin(t.L,t.R,0,0,n);
        updateLeaf(t.R,v+t.C);
    }
    ll ans=rangeMin(N-1,N,0,0,n);
    if (ans==INF)cout<<-1<<endl;
    else cout << ans << endl;

    return 0;
}


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

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

	string s;
	int n,i,a;
	list<int> li;
	list<int>::iterator p=li.begin();
	cin >> n;
	for(i=0;i<n;i++){
		cin >> s;
		if(s=="insert"){
			cin >> a;
			li.push_front(a);
		}
		else if(s=="delete"){
			cin >> a;
			p=find(li.begin(),li.end(),a);
			if(p!=li.end()) li.erase(p);
			
		}
		else if(s=="deleteFirst"){
			li.pop_front();
		}
		else if(s=="deleteLast"){
			li.pop_back();
		}

	}
	p=li.begin();

	while(p != li.end()){
		cout << *p;
		p++;
		if(p!=li.end()) cout << " ";
		else cout << endl;
	}

	return 0;
	
}

Measured memory_bytes: 32476
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  [n,y] <- map read . words <$> getLine :: IO [Int]                                                                                                   
  putStrLn $ case bill n y (0,0) of                                                                                                                   
    Nothing -> "-1 -1 -1"                                                                                                                             
    Just (p,q) -> show p ++ " " ++ show q ++ " " ++ show (n - p - q)                                                                                  
                                                                                                                                                      
bill :: Integral a => a -> a -> (a,a) -> Maybe (a,a)                                                                                                  
bill m x (a,b)                                                                                                                                        
  | b > m = Nothing                                                                                                                                   
  | a+b <= m && 10000*a + 5000*b + 1000*(m-a-b) == x = Just (a,b)                                                                                     
  | a+b > m = bill m x (0,b+1)                                                                                                                        
  | otherwise = bill m x (a+1,b)

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

int main()
{
	 string s;
	 cin>>s;
	 vector<char>v;
	 v.push_back(s[0]);
	 v.push_back(s[1]);
	 v.push_back(s[2]);
	 v.push_back(s[3]);
	 sort(v.begin(),v.end());
	 if(v[0]==v[1]&&v[2]==v[3]&&v[1]!=v[2]){
        cout<<"Yes"<<endl;
	 }
	 else{
        cout<<"No"<<endl;
	 }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

int a[100000];
int D[100000];

int comp(const void* x, const void* y){
    return D[*(int *)x] - D[*(int *)y];
}

int main(void){
    int N;
    ll ans = 1;
    ll node[100000];
    ll via = 1;
    int cnt = 1;
    int node_sum = 1;
    node[0] = 1;


    scanf("%d", &N);
    int i;
    for(i = 0; i< N; i++){
        scanf("%d", &D[i]);
        a[i] = i;
    }
    if(D[0] != 0){
        printf("0");
        return 0;
    }
    qsort(a, N, sizeof(int), comp);
    if(D[a[1]] != 1){
        printf("0");
        return 0;
    }
    int j;
    for(i = 1; i < N; i++){
        if(cnt != D[a[i]] && cnt != 0){
            node[cnt] = i-node_sum;
            node_sum += node[cnt];
            cnt++;
        }
    }
    node[cnt] = i-node_sum;

    for(i = 1; i < N; i++){
        if(D[a[i-1]] != D[a[i]]){
            if(D[a[i]]-D[a[i-1]] != 1){
                printf("0");
                return 0;
            }
            for(j = 0; j < node[D[a[i]]]; j++){
                via = (via*node[D[a[i-1]]])%998244353;
            }
            ans = ans*via%998244353;
            via = 1;
        }

    }
    
    printf("%lld", ans%998244353);
    return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
int member[200005];
 
int main() {
  int n;
  cin>>n;
  for(int i=2;i<=n;i++) {
    int a;
    cin>>a;
    member[a]++;
  }
  for(int i=1;i<=n;i++) {
    cout<<member[i]<<endl;
  }
  return 0;
}

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

class Main{
    private static long c = 0;
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final String[] in = br.readLine().split(" ");
        final int[] s = new int[n];
        for(int i = 0; i<n; i++)
            s[i] = Integer.parseInt(in[i]);
        mergeSort(s, 0, n);
        System.out.println(c);
    }
    private static void mergeSort(int[] a, int l, int r){
        if(l+1<r){
            final int m = (l+r)>>>1;
            mergeSort(a, l, m);
            mergeSort(a, m, r);
            merge(a, l, m, r);
        }
    }
    private static void merge(int[] a, int l, int m, int r){
        final int n1 = m-l;
        final int n2 = r-m;
        final int[] L = new int[n1+1];
        final int[] R = new int[n2+1];
        System.arraycopy(a, l, L, 0, n1);
        System.arraycopy(a, m, R, 0, n2);
        L[n1] = R[n2] = Integer.MAX_VALUE;
        int i = 0, j = 0;
        for(int k = l; k<r; k++){
            if(L[i]<=R[j]){
                a[k] = L[i++];
                c += j;
            }else a[k] = R[j++];

        }
    }
}

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

const int maxn=1e6+5;
#define ll long long
vector<pair<ll,ll> >e[maxn];//二维数组，第一维是点的序号，第二维是该点所连接的点的数量
//first是该点连接的点的序号，second是该点到所连接点的权值

ll n,m,dis[maxn];

void init()
{
    for(ll i=0;i<maxn;i++)e[i].clear();
    for(int i=0;i<maxn;i++)dis[i]=(1ll<<60)-1;
}

void dij(ll s)
{
    priority_queue<pair<ll,ll> >q;
    dis[s]=0;
    q.push(make_pair(-dis[s],s));
    while(!q.empty())
    {
        ll now=q.top().second;//当前离起点最近的点（最短路已经确定的点）
        q.pop();
        for(int i=0;i<e[now].size();i++)
        {
            ll v=e[now][i].first;//更新该点所连接的所有点
            if(dis[v]>dis[now]+e[now][i].second)
            {
                dis[v]=dis[now]+e[now][i].second;
                q.push(make_pair(-dis[v],v));//更新成功则入队
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    while(cin>>n)
    {
        int q;
        init();
        for(int i=1;i<n;i++)
        {
            ll x,y,z;
            cin>>x>>y>>z;
            e[x].push_back(make_pair(y,z));
            e[y].push_back(make_pair(x,z));
        }
        ll s,t;
        cin>>q>>s;
        dij(s);
        //cout<<dis[9]<<" "<<dis[10]<<endl;
        while(q--)
        {
            ll a,b;
            cin>>a>>b;
            cout<<dis[a]+dis[b]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 39280
#include <bits/stdc++.h>
#define N 100005

using namespace std;
typedef pair<int,int> ii;
struct data
{
    int dist,u,company;
};
map<int,int> d[N];
vector<vector<ii>> AdjList(N);

void dijistra()
{
    d[1][0] = 0;
    deque<data> q;
    q.push_back(data{0,1,0});

    while(!q.empty())
    {
        data f = q.front();
        q.pop_front();

        int dist = f.dist,u = f.u,c = f.company;
        if(dist!=d[u][c])
            continue;

        if(!d[u].count(0)||d[u].count(0)&&d[u][0]>dist)
        {
            d[u][0] = dist;
            q.push_front(data{dist,u,0});
        }

        if(c)
        {
            int pos = lower_bound(AdjList[u].begin(),AdjList[u].end(),ii(c,0)) - AdjList[u].begin() ;
            while(pos<AdjList[u].size()&&AdjList[u][pos].first==c)
            {
                int v = AdjList[u][pos].second;
                if(!d[v].count(c)||d[v].count(c)&&d[v][c]>dist)
                {
                    d[v][c] = dist;
                    q.push_front(data{dist,v,c});
                }
                pos++;
            }
        }
        else
        {
            for(auto i:AdjList[u])
            {
                int v = i.second,company = i.first;
                if(!d[v].count(company)||d[v].count(company)&&d[v][company]>dist+1)
                {
                    d[v][company] = dist+1;
                    q.push_back(data{dist+1,v,company});
                }
            }
        }
    }
}

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

    while(m--)
    {
        int u,v,c;
        cin>>u>>v>>c;
        AdjList[u].push_back(ii(c,v));
        AdjList[v].push_back(ii(c,u));
    }

    for(int i=1;i<=n;i++)
        sort(AdjList[i].begin(),AdjList[i].end());

    dijistra();

    if(!d[n].count(0))
        cout<<-1;
    else
        cout<<d[n][0];
}


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

int main(){
    float dishes[5];
    int Up_dishes[5];
    int diff = 0;
    int diff_num = 0;
    int sum = 0;

    for(int i = 0; i < 5; ++i){
        cin >> dishes[i];
        Up_dishes[i] = dishes[i]*0.1+1;
        Up_dishes[i]*=10;
        if(Up_dishes[i]-dishes[i] == 10){
            Up_dishes[i] = dishes[i];
        }
        if((Up_dishes[i]-dishes[i])>diff){
            diff = Up_dishes[i]-dishes[i];
            diff_num = i;
        } 
    }
    for(int i = 0; i < 5; ++i){
        if(i!=diff_num){
            sum+=Up_dishes[i];
        }
        else
        {
            sum+=dishes[i];
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define LL long long

using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
typedef pair<int, int> P;

int add(int x, int y) {
    if((x += y) >= mod) x -= mod;
    return x;
}

int mul(int x, int y) {
    LL z = (LL)x * y;
    return z - z / mod * mod;
}

int p[maxn], inv[maxn], pv[maxn];
int a[maxn], s[maxn], ls[maxn], rs[maxn];


int main() {
#ifdef TT
    freopen("xxx.in", "r", stdin);
#endif // TT
    int n, i, j, w = 0, u, dl, dr;
    scanf("%d", &n);
    for(i = 1;i <= n; i++) scanf("%d", &a[i]);
    for(i = p[0] = 1;i < maxn; i++) p[i] = mul(p[i - 1], i);
    inv[0] = inv[1] = 1;
    for(i = 2;i < maxn; i++) inv[i] = mul(mod - mod / i, inv[mod % i]);
    for(i = pv[0] = 1;i < maxn; i++) pv[i] = mul(pv[i - 1], inv[i]);
    for(i = 1;i <= n; i++) ls[i] = add(ls[i - 1], mul(a[i], i));
    for(i = 1;i <= n; i++) rs[i] = add(rs[i - 1], mul(a[n - i + 1], i));
    for(i = 1;i <= n; i++) s[i] = add(s[i - 1], a[i]);
    for(i = 0;i < n; i++) {
        if(i * 2 > n) j = n - i - 1;
        else j = i;
        u = add(ls[j], rs[j]);
        u = add(u, mul(j + 1, add(s[n - j], mod - s[j])));
        dl = s[i + 1];
        dr = add(s[n], mod - s[n - i - 1]);
        u = add(u, mod - dl);
        if(i + 1 != n) u = add(u, mod - dr);
        w = add(w, mul(mul(u, 2), mul(inv[i + 2], inv[i + 3])));
        if(i + 1 == n) w = add(w, dl);
        else w = add(w, mul(inv[i + 2], add(dl, dr)));
    }
    w = mul(w, p[n]);
    printf("%d\n", w);
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;


int main()
{
    int a, b, w, c;
    while(scanf("%d%d%d", &w, &a, &b) != EOF)
    {
        if(a > b)
        {
            c = a - b - w;
            if(c < 0)
                c = 0;
        }
        else
        {
            c = b - a - w;
            if(c < 0)
                c = 0;
        }
        printf("%d\n", c);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, m, l;
  scanf("%d%d%d", &n, &m, &l);
  int A[n][m];
  int B[m][l];
  int i, j, k;
  long long sum;
  for(i=0; i<n; ++i){
	for(j=0; j<m; ++j){
	  scanf("%d", &A[i][j]);
	}
  }
  for(i=0; i<m; ++i){
	for(j=0; j<l; ++j){
	  scanf("%d", &B[i][j]);
	}
  }
  for(i=0; i<n; ++i){
	for(j=0; j<l; ++j){
	  sum=0;
	  for(k=0; k<m; ++k){
		sum+=A[i][k]*B[k][j];
	  }
	  printf("%lld", sum);
	  if(j<l-1)
		printf(" ");
	}
		printf("\n");

  }
  return 0;
}



Measured memory_bytes: 2100
A,B = map(int,input().split())

isok = False
for i in range(1,2000):
    n1 = i * 0.08
    n2 = i * 0.1
    n1 = n1//1
    n2 = n2//1
    
    if(n1==A and n2==B):
        print(i)
        isok=True
        break

if(not isok):
    print(-1)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
long long n,m;
int main()
{
	cin>>n>>m;
	string a[n+10];
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++) cout<<a[i];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int A,B;
string S;
cin >> A >> B >> S;
for (int i = 0;i < A+B+1;i++) {
  if (i == A){
    if (S.at(i) == '-') continue;
    else {
      cout << "No" << endl;
      return 0;
    }
  } 
  if (S.at(i) == '-') {
    cout << "No" << endl;
    return 0;
  }
  
}
cout << "Yes" << endl;


return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

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

    //input
    int d = sc.nextInt();
    /*
    int[] c = new int[26]; //array of decrease
    for(int i = 0; i < c.length; i++){
      c[i] = sc.nextInt();
    }
    */

    ArrayList<Integer> c = new ArrayList<Integer>();
    for(int i = 0; i < 26; i++){
      c.add(sc.nextInt());
    }

    int[][] s = new int[d][26]; //two dimensional array of increase
    for(int row = 0; row < s.length; row++){ //day
      for(int col = 0; col < s[row].length; col++){ //contest number
        s[row][col] = sc.nextInt();
      }
    }
    /*
    int[] t = new int[d]; //array of contest numbers of the day
    for(int i = 0; i < t.length; i++){
      t[i] = sc.nextInt();
    }
    */

    //output
    //based on increase
    /*
    int largestNum = s[0][0];
    int largestNumRow = 0;
    int largestNumCol = 0;
    for(int row = 0; row < s.length; row++){
      for(int col = 0; col < s[row].length; col++){
        if( s[row][col] > largestNum ){
          largestNum = s[row][col];
          largestNumRow = row;
          largestNumCol = col;
        }
      }
    }
    for(int i = 0; i < d; i++){
      //System.out.println((int)(Math.random()*26+1));
      System.out.println(largestNumCol+1);
    }
    */

    for(int i = 0; i < d; i++){
      int largestNum = c.get(0);
      int largestNumPos = 0;
      for(int j = 0; j < c.size(); j++){
        if( c.get(j) > largestNum ){
          largestNum = c.get(j);
          largestNumPos = j;
        }
      }
      //c.remove(largestNumPos);
      System.out.println(largestNumPos+1);
    }


    /*
    int value = 0;
    for(int i = 0; i < t.length; i++){
      int contestNum = t[i]-1;
      int day = i+1;
      value += s[day-1][contestNum]; //increase
      for(int j = 0; j < c.length; j++){
        if( !(j == contestNum) ){
          int daySinceLast = day;
          for(int m = 0; m < i; m++){
            if( j == t[m]-1 ){
              daySinceLast = day-m-1;
            }
          }
          value -= c[j]*(daySinceLast); //decrease (amount of decrease * days since last one)
        }
      }
      System.out.println(value);
    }
    */

  }
}


Measured memory_bytes: 38008
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int vec[n];
    int cont = 0;
    for(int i = 0; i < n; ++i)
        scanf("%d", &vec[i]);
        
    for (int i = 0; i < n; ++i){
        if (((i+1)%2 !=  0) && (vec[i]%2 != 0))
            cont += 1;
    }
    
    printf("%d\n", cont);
    

    return 0;
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int b = 0;
    int sum = 0;
    while(!sum){
        b++;
        for(int i = 0; i < n; i++) sum += a[i] % (int)pow(2,b);
    }
    cout << b  - 1 << endl;
    return 0;
}



Measured memory_bytes: 256
/* ex4-1
   kas056*/

#include <stdio.h>
#include <stdlib.h>

#define SIZE 15

typedef struct{
    int size;//格納最大数
    int count;//現在のデータ数
    char data[SIZE];//データ配列
    char *top;//topのポインタ
    char *bottom;//一番下のポインタ
}stack;

//初期化
void initialize(stack *stk){
    stk -> count = 0;
    stk -> size = SIZE;
    stk -> top = &(stk->data[SIZE]);//配列の最終要素の一つ手前
    stk -> bottom = &(stk->data[SIZE]);//初期配列の要素の一つ手前
}

void push(stack *stk, char s){
    if(stk->count >= stk -> size){//格納最大数を超えたらエラー
        fprintf(stderr, "Error: Stack overflow. (s=%c)\n", s);
    }
    else{
        stk -> top--;//一つ上にあげる(=一つ手前に移動)
        *(stk->top) = s;
        stk->count++;
    }
}

void pop(stack *stk){
    //popが指示されたとき、
    if(stk->count > 0){//要素があれば取り出すようにする。
        stk->top++;//一つ下に移動(=一つ後に移動)
        stk->count--;
    }
}

void print_stack(stack *stk){
    char *c;
    int i;
    c = stk->bottom-1;//配列の一番下のポインタを指定する。
    
    for(i = stk->count-1; i>-1; i--){//スタック内の文字数分操作
        printf("%c", *c--);//出力したら一つ上にあげる。
    }
}


stack stk;
int main(void){
    char sentence[SIZE];
    int i;

    initialize(&stk);

    scanf("%s", sentence);

    for(i=0; i<SIZE; i++){
        if(sentence[i] == '0' || sentence[i] == '1'){
            push(&stk, sentence[i]);//B以外はpush
        }
        else if(sentence[i] == 'B'){
            pop(&stk);//Bがでたらpop
        }
        else{
            continue;
        }
    }

    print_stack(&stk);

    return 0;
    

}

Measured memory_bytes: 1648
#include<iostream>
#include<algorithm>
#include <stdio.h>
using namespace std;
typedef pair<int,int> p;
#define TREE_N (1<<17)

int c,n;
p tree[ TREE_N * 2 -1],ans;

void update(int i,int x,int t){
  i+=TREE_N-1;
  if(t==-1)tree[i]=p(-1,x);
  else ans=tree[i];
  while(i>0){
    i=(i-1)/2;
    if(t==-1)tree[i]=p(t,x);
    else ans=max(ans,tree[i]);
  }
}

void rec(int t,int a,int b,int k=0,int l=0,int r=TREE_N){
  if((l<a&&a<r)||(l<b&&b<r)){
    int m=(l+r)/2;
    rec(t,a,b,k*2+1,l,m);
    rec(t,a,b,k*2+2,m,r);
  }else if(a<=l&&r<=b){
    tree[k]=p(t,c);
  }
}

/*int Rec(int a,int b,int k=0,int l=0,int r=TREE_N){
  if((l<a&&a<r)||(l<b&&b<r)){
    int m=(l+r)/2;
    int left = Rec(a,b,k*2+1,l,m);
    int right = Rec(a,b,k*2+2,m,r);
    return min(left,right);
    
  }else if(a<=l&&r<=b){
    return tree[k];
  }else{
    return 2147483647;
  }
  }*/

int main(){
  int q,com,a,b;
  cin>>n>>q;
  for(int i=0;i<n;i++)update(i,2147483647,-1);
  for(int i=0;i<q;i++){
    cin>>com;
    if(com){
      cin>>a;
      update(a,0,0);
      cout<<ans.second<<endl;
    }
    else {
      cin>>a>>b>>c;
      rec(i,a,b+1);
    }
  }
  return 0;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
    return 0;
}

Measured memory_bytes: 3640
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
      x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
  

n,m = map(int, input().split())
p = list(map(int, input().split()))

uf = UnionFind(n)
for i in range(m):
  x,y = map(int, input().split())
  uf.union(x-1,y-1)
  
count = 0
for i in range(n):
  if uf.same(p[i]-1, i):
    count += 1
    
print(count)
  
  

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int D, G;
  cin >> D >> G;
  vector<int> P(D), C(D);
  for (int i = 0; i < D; i++) {
    cin >> P[i] >> C[i];
  }
  int res = 1 << 28;
  for (int k = 0; k < (1 << D); k++) {
    int score = 0, cnt = 0;
    for (int i = 0; i < D; i++) {
      if ((k >> i) & 1) {
        score += C[i] + 100 * P[i] * (i + 1);
        cnt += P[i];
      }
    }
    if (score >= G) {
      res = min(res, cnt);
      continue;
    }
    for (int i = D - 1; i >= 0; i--) {
      if ((k >> i) & 1) continue;
      int p = (max(0, G - score) + (100 * (i + 1) - 1)) / (100 * (i + 1));
      if (p < P[i]) {
        res = min(res, cnt + p);
      }
      break;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
n = int(input())
M = [list(map(int, input().split())) for _ in range(n)]

WHITE = 0
GREY = 1
BLACK = 2
INFTY = 10**10

color = [WHITE] * n
d = [INFTY] * n
p = [-1] * n


def prim():
    # すべての頂点u について color[u] をwhiteとして、d[u]をINFINITYへ
    d[0] = 0
    p[0] = -1  # 親なし

    while True:
        mincost = INFTY
        for i in range(0, n):
            if color[i] != BLACK and d[i] < mincost:
                # まだ未訪問でコストが最小になるところを探す。
                # WHITEなところはd[i]=INFTYなので来ない
                mincost = d[i]
                # 最小コストになる場所を見つける
                u = i
                # 訪れる場所を決定
        if mincost == INFTY:
            break

        color[u] = BLACK
        # 起点座標の決定

        for v in range(0, n):
            if color[v] != BLACK and M[u][v] != -1:
                if M[u][v] < d[v]:
                    # 最初コストになるノードを探索
                    d[v] = M[u][v]
                    p[v] = u
                    color[v] = GREY


prim()
print(sum(d))



Measured memory_bytes: 5896
import sys
input = sys.stdin.readline

def judge(x):
    cnt = 0
    
    for Ai in A:
        cnt += (Ai+x-1)//x-1
    
    return cnt<=K

def binary_search():
    l, r = 1, 10**9+100
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            r = m-1
        else:
            l = m+1
    
    return l

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

Measured memory_bytes: 103724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  ll l,r;
  cin>>l>>r;
  int ans=2018;
  r=min(r,l+2019);
  for(ll i=l;i<=r;i++){
    for(ll j=i+1;j<=r;j++){
      int x=(i*j)%2019;
      ans=min(ans,x);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    int a,b;
    cin >> a>>b;
    for(int i=0;;i++){
        if(1+i*(a-1)>=b){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
const ll M = 1e9 + 7;
using namespace std;  
int main() 
{
	FAST
	ll n;
	cin>>n;
	vector<pair<ll,ll>> v;
	for(ll i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		v.push_back({x,y});
	}
	double ans=0.0;
  	sort(v.begin(),v.end());
	do 
	{ 
        for(ll i=0;i<v.size()-1;i++)
		{
			double sum1=abs((double)v[i].first-(double)v[i+1].first);
			sum1=sum1*sum1;
			double sum2=abs((double)v[i].second-(double)v[i+1].second);
			sum2=sum2*sum2;
			sum2+=sum1;
			ans+=sqrt(sum2);
		} 
    } while(next_permutation(v.begin(),v.end()));
  	ll s=1;
  	for(ll i=1;i<=n;i++) s=s*i;
    cout<<fixed<<setprecision(10)<<(double)(ans/(double)s);
	return 0;
}

Measured memory_bytes: 256