akhauriyash/Code-Regression huggingface dataset:
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

use std::collections::BTreeSet;
use std::collections::VecDeque;

fn topological_sort(n: usize,
                    mut incoming_edges: Vec<BTreeSet<usize>>,
                    outgoing_edges: Vec<BTreeSet<usize>>,) -> Vec<usize> {
    let mut roots = VecDeque::new();

    roots.push_back(0);

    while let Some(par) = incoming_edges[roots[0]].iter().nth(0) {
        roots[0] = *par;
    }

    let mut topological_sort = vec![n; n];
    let mut idx = 0;

    while let Some(node) = roots.pop_front() {
        for e in outgoing_edges[node].iter() {
            incoming_edges[*e].remove(&node);
            if incoming_edges[*e].is_empty() {
                roots.push_back(*e);
            }
        }
        topological_sort[node] = idx;
        idx += 1;
    }

    topological_sort
}


fn main() {
    input! {
        n: usize,
        m: usize,
        edges: [(usize1, usize1); n - 1 + m],
    }

    let (incoming_edges, outgoing_edges) = {
        let mut incoming_edges = vec![BTreeSet::<usize>::new(); n];
        let mut outgoing_edges = vec![BTreeSet::<usize>::new(); n];

        for (a, b) in edges {
            incoming_edges[b].insert(a);
            outgoing_edges[a].insert(b);
        }

        (incoming_edges, outgoing_edges)
    };

    let tsort = topological_sort(n,
                                 incoming_edges.clone(),
                                 outgoing_edges);

    for s in incoming_edges {
        if let Some(p) = s.iter().max_by(|&a, &b| tsort[*a].cmp(&tsort[*b])) {
            println!("{}", p + 1);
        } else {
            println!("0");
        }
    }
}


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

using namespace std;

#define lint long long
#define P pair<int, int>

const lint mod = 1E9 + 7;

int main(){
    int N;
    cin >> N;
    
    int A[N + 1];
    int B[N + 1];
    memset(A, 0, sizeof(A));
    memset(B, 0, sizeof(B));
    for(int i = 1; i <= N ; ++i){
        cin >> A[i];
    }

    for(int i = N; i >= 1; --i){
        int sum = 0;
        for(int j = 1; j <= N / i; ++j){
            sum += B[j * i];
        }
        sum %= 2;
        B[i] = abs(A[i] - sum);
    }

    vector<int> ans;
    int cnt = 0;
    for(int i = 1; i < N + 1; ++i){
        if(B[i] == 1){
            ans.push_back(i);
            cnt++;
        }
    }
    cout << cnt << endl;
    for(int i = 0; i < cnt; ++i){
        cout << ans[i] << " ";
    }
}


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

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

  while(N > 0) {
    if(N % 10 == 7) {
      std::cout << "Yes" << '\n';
      return 0;
    }
    N /= 10;
  }
  std::cout << "No" << '\n';
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
//#define TEST

int main(int argc, char** argv) {
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    ll n;
    cin >> n;
    cout << (n-2)*180 << '\n';

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(input().split())
b = []
a = a[::-1]
for i in range(n)[::2]:
    b.append(a[i])
a = a[::-1]
if n % 2 != 0:
    a.pop(0)
for i in range(len(a))[::2]:
    b.append(a[i])
print(' '.join(b))

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

static const int MAX_TASKNUM = 100000;

typedef struct tagSTask {
    char name[10];
    int  time;
} STask;


class CRingBuf
{
public :
    CRingBuf(void) : m_iFront(0), m_iRear(0) {};
    bool  Enqueue(STask* pTask);
    STask Dequeue(void);
    int   BufNum(void) {
        int ret;
        if (m_iFront <= m_iRear) {
            ret = m_iRear - m_iFront;
        }
        else {
            ret = (m_iRear + MAX_TASKNUM) - m_iFront;
        }
        return ret;
    };

private :
    int   m_iFront;
    int   m_iRear;
    STask m_sTask[MAX_TASKNUM];
    bool  IsFull(void) {
        return (m_iFront == ((m_iRear + 1) % MAX_TASKNUM)) ? true : false;
    };
    bool  IsEmpty(void) {
        return (m_iFront == m_iRear) ? true : false;
    };
};

bool CRingBuf::Enqueue(STask* pTask)
{
    bool ret;

    if (IsFull() == false) {
        ret = true;
        m_sTask[m_iRear] = *pTask;
        ++m_iRear;
        if (m_iRear >= MAX_TASKNUM) {
            m_iRear = 0;
        }
    }
    else {
        ret = false;
    }

    return ret;
}

STask CRingBuf::Dequeue(void)
{
    STask task;

    if (IsEmpty() == false) {
        task = m_sTask[m_iFront];
        ++m_iFront;
        if (m_iFront >= MAX_TASKNUM) {
            m_iFront = 0;
        }
    }
    else {
        task.time = -1;
    }

    return task;
}

int main(void)
{
    int i;
    int num;
    int utime;
    STask sTask;
    CRingBuf cRingBuf;
    int total = 0;

    cin >> num;
    cin >> utime;

    for (i = 0; i < num; i++) {
        scanf("%s", sTask.name);
        scanf("%d", &(sTask.time));
        cRingBuf.Enqueue(&sTask);
    }

    while (cRingBuf.BufNum() > 0) {
        sTask = cRingBuf.Dequeue();
        if (sTask.time > utime) {
            sTask.time -= utime;
            cRingBuf.Enqueue(&sTask);
            total += utime;
        }
        else {
            total += sTask.time;
            printf("%s %d\n", sTask.name, total);
        }
    }

    return 0;
}

Measured memory_bytes: 2792
#include "bits/stdc++.h"

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); i++)

using namespace std;

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

	string S; cin >> S;

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

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

class Node:
    __slots__ = ['value', 'parent', 'left', 'right']
    def __init__(self, value: int, parent: 'Node' = None):
        self.value = value
        self.parent = parent
        self.left: Node = None
        self.right: Node = None
    def inParse(self):
        if self.value == None:
            return
        if self.left != None:
            self.left.inParse()
        print(' {}'.format(self.value), end='')
        if self.right != None:
            self.right.inParse()
    def preParse(self):
        if self.value == None:
            return
        print(' {}'.format(self.value), end='')
        if self.left != None:
            self.left.preParse()
        if self.right != None:
            self.right.preParse()

class BinarySearchTree:
    __slots__ = ['root']
    def __init__(self):
        self.root: Node = None
    def insert(self, x: int):
        if self.root == None:
            self.root = Node(x)
            return
        parent, current = None, self.root
        while current:
            parent = current
            if x < current.value:
                current = current.left
            else:
                current = current.right
        if x < parent.value:
            parent.left = Node(x, parent)
        else:
            parent.right = Node(x, parent)

def main():
    tree = BinarySearchTree()
    n = int(input())
    for _ in range(n):
        inp = input()
        if inp[0] == 'i':
            com, num = inp.split()
            tree.insert(int(num))
        else:
            tree.root.inParse()
            print()
            tree.root.preParse()
            print()

if __name__=='__main__': main()


Measured memory_bytes: 57572
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,temp,temp1,temp2,temp3,i;
    cin>>n>>m;

    int arr[n+5];
    double sum=0;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        sum=sum+arr[i];
    }
    sort(arr,arr+n,greater<int>());
    int cnt=0;
    for(i=0;i<n;i++)
    {
        double sum1=(arr[i]/sum);
        double sum2=(1.0)/(4*m);
        if(sum1>=sum2)
        {
            cnt++;
        }
    }
    if(cnt>=m)
    {
        cout<<"Yes"<<endl;
    }
else    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<int> vote(1e5, 0);
    REP(i, N) {
        int a;
        cin >> a;
        vote[a]++;
    }
    int res = -1;
    FOR(i, 1, 1e5 - 1) {
        res = max(res, vote[i - 1] + vote[i] + vote[i + 1]);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace WelcomeAtcordet
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int sx = int.Parse(input[0]);
            int sy = int.Parse(input[1]);
            int tx = int.Parse(input[2]);
            int ty = int.Parse(input[3]);
            string to1 = null;
            string from1 = null;

            for (int i = sy; i < ty; i++)
            {
                to1 += "U";
            }
            for (int i = sx; i < tx; i++)
            {
                to1 += "R";
            }
            foreach(char c in to1)
            {
                if (c.Equals('U'))
                {
                    from1 += "D";
                }
                else if (c.Equals('R'))
                {
                    from1 += "L";
                }
            }

            string to2 = "L" + to1[0] + to1 + to1[to1.Length - 1] + "D";
            string from2 = "R" + from1[0] + from1 + from1[from1.Length - 1] + "U";

            Console.WriteLine(to1+from1+to2+from2);
        }
    }
}


Measured memory_bytes: 15300
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int H, W, h, w, ans;
	cin >> H >> W >> h >> w;
	ans = H * W - H * w - h*(W-w);
	cout << ans << endl;
}


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

int main() {
  string A, B;
  cin >> A >> B;
  if(A.size()>B.size()) {
      puts("GREATER");
      return 0;
  }
  else if(A.size()<B.size()) {
      puts("LESS");
      return 0;
  }
  for (int i = 0; i < A.size(); i++) {
      if (A.at(i)-'0'>B.at(i)-'0') {
          puts("GREATER");
          return 0;
      }
      else if (A.at(i)-'0'<B.at(i)-'0') {
          puts("LESS");
          return 0;
      }
  }
  puts("EQUAL");
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main() {
	int a, b;
	cin >> a; //[a,a+1)
	cin >> b;
	double oa1 = a / 0.08, oa2 = (a + 1) / 0.08;
	int ob1 = b * 10, ob2 = (b + 1) * 10;
	if (oa1 < ob2 && ob1 < oa2) {
		cout << ceil((oa1 < ob1) ? ob1 : oa1) << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    cin>>s;
    set<int> si;
    for(auto u : s){
        si.insert(u);
    }
    if(si.size()==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

cnt = 0
s = 0
minabs = 10**11
for a in A:
    if a <= -1:
        cnt += 1
    s += abs(a)
    minabs = min(minabs, abs(a))

if cnt % 2 == 0:
    print(s)
else:
    print(s-minabs*2)


Measured memory_bytes: 64880
M, D = map(int, input().split())
count = 0
for d in range(1, D + 1):
    d1 = d % 10
    d10 = d // 10
    if d1 < 2 or d10 < 2:
        continue
    if 1 <= d1 * d10 <= M:
        count += 1
print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int n,A[50];
int s(int i,int m)
{
	if(m == 0) return 1;
	else if(i >= n) return 0;
	int ans = s(i + 1,m) || s(i + 1,m - A[i]);
	return ans;
}
int main(int argc, char const *argv[])
{
	int q,m,i;
	cin>>n;
	for(i = 0; i < n;i++) cin>>A[i];
	cin>>q;
	for(i = 0;i < q;i++)
	{
		cin>>m;
		if(s(0,m)) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 3048
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)

def upper_case(lst, key):
	ng = -1
	ok = len(lst)
	while (abs(ok - ng) > 1):
		mid = (ok + ng) // 2
		if lst[mid] > key:
			ok = mid
		else:
			ng = mid
	return ok




def main():
	log = Logger(0)
	n, m, k = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	for i in range(1, n):
		a[i] += a[i-1]
	for i in range(1, m):
		b[i] += b[i-1]
	log.print(a, b)
	ans = upper_case(b, k)
	log.print(ans, b, k)
	for i in range(-1, n):
		if a[i] > k:
			continue
		ans = max(ans, i+1+upper_case(b, k-a[i]))
		log.print(i, k-a[i], upper_case(b, k-a[i]))
	print(ans)


main()

Measured memory_bytes: 42132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e5 + 5;

int n;
int a[N], b[N], c[N];
int dp[N][5];

void getDP() {
    // i = index, j = now
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= 3; j++) {
            int &sol = dp[i][j];
            if(j == 0) 
                sol = max(dp[i - 1][1] + a[i - 1],
                      max(dp[i - 1][2] + b[i - 1],
                          dp[i - 1][3] + c[i - 1]));
            else if(j == 1) 
                sol = max(dp[i - 1][2] + b[i - 1],
                          dp[i - 1][3] + c[i - 1]);
            else if(j == 2) 
                sol = max(dp[i - 1][1] + a[i - 1],
                          dp[i - 1][3] + c[i - 1]);
            else 
                sol = max(dp[i - 1][1] + a[i - 1],
                          dp[i - 1][2] + b[i - 1]);
        }
    }
}

void solve() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    getDP();
    cout << max(dp[n][1] + a[n], max(dp[n][2] + b[n], dp[n][3] + c[n])) << "\n";
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

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

public class Main {

	private static final long CAPACITYMAX = 100000 * 10000 + 1;

	public static void main(String[] args) throws Exception, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sStr = br.readLine().split(" ");
		int weightCount = Integer.parseInt(sStr[0]);
		int truckCount = Integer.parseInt(sStr[1]);

		int[] weightAry = new int[weightCount];

		for(int i = 0 ; i < weightCount; i++){
			weightAry[i] = Integer.parseInt(br.readLine());
		}

		long max = CAPACITYMAX + 1;
		long mid = 0;
		long min = 0;
		long currentCap = 0;

		while(min < max){
			mid = (max+min) / 2;
			if(search(truckCount,weightAry,mid)){
				max = mid;
				currentCap = mid;
			}else{
				min = mid + 1;
			}
		}

		System.out.println(currentCap);

	}

	private static boolean search(long truckCount,int[] weightAry,long capacity){

		int weight = 0;
		int truckNo = 0;
		for(int i = 0; i < weightAry.length ; i++ ){
			weight += weightAry[i];
			if(capacity < weight){
				weight = 0;
				i--;
				truckNo++;
		    }
			if(truckCount < truckNo){
				break;
			}
		}
		if(truckNo < truckCount){
			return true;
		}

		return false;
   }
}

Measured memory_bytes: 35400
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     setbits(x)  __builtin_popcountll(x)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e3+5;
const int mod=1e9+7;

int n,x,y;
int dist[N][N];
vector<int>v[N];
void bfs(int x){
    queue<int>q;
    q.push(x);
    vector<int>d(n+5,1e9);
    d[x]=0;
    int src=x;
    while(!q.empty()){
        x=q.front();
        q.pop();
        for(int i:v[x]){
            if(d[i]>d[x]+1){
                d[i]=d[x]+1;
                q.push(i);
            }
        }
    }
    rep(i,1,n) dist[src][i]=d[i];
}
signed main(){
    FastIO;
    cin>>n>>x>>y;
    rep(i,1,n-1){
        v[i].pb(i+1);
        v[i+1].pb(i);
    }
    v[x].pb(y);
    v[y].pb(x);
    rep(i,1,n) bfs(i);
    map<int,int>m;
    rep(i,1,n) rep(j,1,n) m[dist[i][j]]++;
    rep(i,1,n-1) cout<<m[i]/2<<'\n';
    return 0;
}


Measured memory_bytes: 16128
#include <iostream>
#include <cstdio>
using namespace std;
int main(void) {
  int candy, count;

  while(scanf("%d", &candy) != EOF) {
    count = 0;
    while(candy != 0) {
      candy--;
      count++;
      if(count == 39) count = 0;
    }
    if(count == 0) cout << "3C39" << endl;
    else if(count < 10) cout << "3C0" << count << endl;
    else cout << "3C" << count << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  string n; cin >> n;
  string result = "No";
  rep(i,3) {
  	if (n[i] == '7') result = "Yes";
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3608
N = int(input())

mod_first = 7 % N
mod_next = mod_first * 11 % N

if mod_first == 0:
    print("1")
    exit()
if mod_next == 0:
    print("2")
    exit()

for i in range(10000000):
    mod_next = (mod_next * 10 + mod_first) % N
    if mod_next == 0:
        print(i + 3)
        exit()

print("-1")



Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a, b, n;
	cin >> a >> b >> n;
	int x = min(b - 1, n);
	cout << a * x / b - a * (x / b) << endl;
}

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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int n;
    cin >> n;
    n%=10;
    if(n == 3)cout << "bon";
    else if(n == 0 || n == 1 || n == 6 || n == 8)cout << "pon";
    else cout << "hon";
    return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    if((n-k)%(k-1) == 0) cout << ((n-k)/(k-1))+1 << endl;
    else cout << ((n-k)/(k-1))+2 << endl;
    return 0;
}

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

typedef struct{
  char name[11];
  int time;
}Record;

Record A[N];
int head=0,tail,n;
void enqueue(Record);
Record dequeue(void);

void enqueue(Record x){
  if(head == (tail + 1) % N){
    printf("error %d\n",tail);
    exit(1);
  }
  A[tail] = x;
  if(tail + 1 == N){
    tail = 0;
  }else{
    tail++;
  }
}

Record dequeue(){
  if(head == tail){
    printf("error2\n");
    exit(1);
  }
  Record x = A[head];
  if(head + 1 ==  N){
    head == 0;
  }else{
    head++;
  }
  return x;

}

int main(){
  int i,q,t=0,s;
  Record B;
  scanf("%d %d",&n,&q);

  for(i=0;i<n;i++){
    scanf("%s %d",A[i].name ,&A[i].time);
     }
  tail = n;

  while(head != tail){
    B = dequeue();
    if(q < B.time){
      s = q;
    }else{s = B.time;}
    B.time -= s;
    t += s;
    if(B.time > 0){
      enqueue(B);
    }else{printf("%s %d\n",B.name,t);
    }
  }

  return 0;
}



Measured memory_bytes: 4700
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N];
		int x = 1;
		for(int i=0;i<N;i++){
			C[P[i]-1] = x;
			x++;
		}
		
		
		A[0] = C[0];
		B[0] = 0;
		
		for(int i=1;i<N;i++){
			A[i] = A[i-1] + C[i];
			B[i] = -A[i-1];
		}
		
		int Bm = - (B.Min());
		for(int i=0;i<N;i++)B[i] += Bm+1;
		Console.WriteLine(String.Join(" ",A));
		Console.WriteLine(String.Join(" ",B));
	}
	int N;
	int[] P;
	public Sol(){
		N = ri();
		P = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 9048
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int,int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod 1000000007
#define intmax 2147483647
#define intmin -2147483648
#define longmax 9223372036854775807
#define longmin -9223372036854775808
#define black 0
#define gray 127
#define white 255
int main() {
	int N;
	cin >> N;
	vvp A(N);
	for (int i = 0; i < N; i++)
	{
		int u,k;
		cin >> u>>k;
		for (int j = 0; j < k; j++)
		{
			int v, w;
			cin >> v >> w;
			A[u].push_back(make_pair(v,w));
		}
	}
	vi color(N,black);
	priority_queue<pii,vp,greater<pii> > pq;
	vi mincost(N,intmax);
	color[0] = gray;
	pq.push(make_pair(0,0));
	mincost[0] = 0;
	while (!pq.empty()) {
		pii minp = pq.top();
		pq.pop();
		color[minp.second] = white;
		if (mincost[minp.second]<minp.first) continue; 
		for (int i = 0; i < A[minp.second].size(); i++)
		{
			int u = A[minp.second][i].first;
			if (color[u]!=white&&mincost[u]>mincost[minp.second]+ A[minp.second][i].second) {
				mincost[u] = mincost[minp.second] + A[minp.second][i].second;
				pq.push(make_pair(mincost[u],u));
				color[u] = gray;
			}
		}
	}
	for (int i = 0; i < N; i++)
	{
		cout << i << " " << mincost[i] << endl;
	}
};



Measured memory_bytes: 7784
#include "bits/stdc++.h"
using namespace std;
vector<string> V;
map<string,int> M;
map<string,int>::iterator it;	
char A[105];

int main(){
	int N , i;
	string Str;
	scanf( "%d" , &N );

	for( i = 1 ; i <= N ; ++i ){
		scanf( "%s" , A );
		Str = A;
		V.emplace_back( Str );
		it = M.find( Str );

		if( it == M.end() ) M[Str] = 1;
		else ++it->second;
	}

	for( it = M.begin() ; it != M.end() ; ++it ){
		if( it->second > 1 ){
			puts( "No" );
			return 0;
		}
	}

	for( i = 1 ; i < V.size() ; ++i ){
		if( V[i][0] != V[i - 1][int(V[i - 1].size()) - 1] ){
			puts( "No" );
			return 0;
		}
	} 

	puts( "Yes" );
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
 	
signed main(){
	fast
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	 cin>>a[i];
	map<int,int> m;
	for(int i=0;i<n;i++)
	 m[a[i]]+=1;
	int s=0;
	for(auto u:m){
		if(u.second>1)
		 s=s+(u.se*(u.se-1))/2;
	}
	for(int i=0;i<n;i++){
		int y=m[a[i]];
		if(y<2)
		 cout<<s<<endl;
		else{
			int s1=s;
			s1=s1-(y*(y-1))/2;
			y=y-1;
			if(y>1)
			 s1=s1+(y*(y-1))/2;
			cout<<s1<<endl;
		}
	}  
}



Measured memory_bytes: 12672
N,M = (int(x) for x in input().split())

max_i = 0
for i in range(1, int(M**0.5)+1):
    if M%i == 0:
        if M//i >= N:
            max_i = max(max_i, i)
        if i >= N:
            max_i = max(max_i, M//i)
print(max_i)


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {
  int A, B, C, K;
  int ans=0;
  cin >> A >> B >> C >> K;
  if (K > A) {
    ans += A;
    K -= A;
  } else {
    ans = K;
    K = 0;
  }
  if (K > B) {
    K -= B;
  } else {
    K = 0;
  }
  if (K) {
    ans -= K;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

long long int gcd(long long int a, long long int b) {
    while(1) {
        if(a < b) swap(a, b);
        if(!b) break;
        a %= b;
    }
    return a;
}

int main(){
    long long int n;
    
    cin >> n;
    long long int a;
    
    long long int i, ans;
    
    cin >> ans;
    
    for(i = 1; i < n; i++){
        cin >> a;
        ans = gcd(ans, a);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n;
  scanf("%d", &n);
  
  double a[101];
  double sum = 0;
  double ans;
  
  for(int i = 0; i < n; i++){
    scanf("%lf", &a[i]);
    a[i] = 1 / a[i];
    sum += a[i];
  }
  
  ans = 1 / sum;
  printf("%f", ans);
  
  return 0;
}


Measured memory_bytes: 128
string = input()
 
v = string.split(" ")
 
if not len(v) == 2:
  print(-1)
 
a = int(v[0])
b = int(v[1])
 
if 0 < a < 10 and 0 < b < 10:
   print(a * b)
else: 
    print(-1)

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

int main() {
    int a[10] = {};
    int cnt = 0;
    for (int i = 1; i <= 3; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        ++a[u];
        ++a[v];
    }
    int cnt2 = 0;
    for (int i = 1; i <= 4; ++i) {
        if (a[i] == 2) {
            ++cnt;
        }
        if (a[i] == 1) {
            ++cnt2;
        }
    }
    if (cnt == 2 && cnt2 == 2) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

fun solve(out: PrintWriter): Boolean = with(out) {
    readLine()!!
    // ASC
    val vs = readLine()!!.split(" ")
        .map{ it.toDouble() }
        .sorted()

    var ans = vs[0]
    vs.drop(1)
    for (v in vs) {
        ans += v
        ans /= 2.0
    }

    println(ans)
    return false
}

fun main(args: Array<String>) = with(PrintWriter(System.out)){
    while(solve(this));
    flush()
}

Measured memory_bytes: 37992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    string s[h];
    int t[h][w + 1] = {};
    for (int i = 0; i < h; i++) {
        cin >> s[i];
        for (int j = 0; j < w; j++) {
            t[i][j + 1] = t[i][j] + (s[i][j] == '1');
        }
    }

    ll ans = 1e9;
    for (int i = 0; i < (1 << (h - 1)); i++) {
        ll tmp = 0;
        int to[h] = {};
        for (int j = 0; j < h - 1; j++) {
            to[j] = tmp;
            if (i & (1 << j)) {
                tmp++;
            }
        }
        to[h - 1] = tmp;
        //cerr << to[0] << to[1] << to[2] << to[3] << endl;
        int bef = 0, j = 1;
        while (j <= w) {
            int at[h] = {}, at2[h] = {}, mx = 0, mx2 = 0;
            for (int p = 0; p < h; p++) {
                at[to[p]] += t[p][j] - t[p][bef];
                at2[to[p]] += t[p][j] - t[p][j - 1];
            }
            for (int p = 0; p < h; p++) {
                mx = max(mx, at[p]);
                mx2 = max(mx2, at2[p]);
            }
            //cerr << j _ at[0] << at[1] << at[2] _ mx _ mx2 << endl;
            if (mx > k) {
                //if (j - bef == 1) tmp = 1e9;
                if (mx2 > k) {
                    tmp = 1e9;
                    break;
                }
                tmp++;  bef = j - 1;
            }
            j++;
        }
        ans = min(ans, tmp);
        //cerr << i _ tmp << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
    int n;
    int a=0,w=0,t=0,r=0;
    cin >>n;
    string arr[n];
    for(int i=0;i<n;i++ ){
        cin>>arr[i];
        if(arr[i]=="AC"){a++;}
        else if (arr[i]=="WA"){w++;}
        else if (arr[i]=="TLE"){t++;}
        else if (arr[i]=="RE"){r++;};
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;
        return 0;
}


Measured memory_bytes: 6740
s = gets.chomp.split("")
t = gets.chomp.split("")
flag = 0
if s == t
  flag = 1
else
  for en in 0..(s.length-2)
    tmp = s.dup
    tmp.slice!(0..en)
    if t.join == tmp.push(s[0..en]).join
      flag = 1
      break
    end
  end
end

flag == 1 ? (puts "Yes"):(puts "No")  

Measured memory_bytes: 1916
class DisjointSet:
    def __init__(self, N):
        self.head = [int(i) for i in range(N)]
        self.inc = (N * (N - 1))//2
        self.sizes = [1] * N
        self.size = N
        self.components = N
    
    def getRoot(self, u):
        while (u != self.head[u]):
            self.head[u] = self.head[self.head[u]]
            u = self.head[u]
        return u
    
    def merge(self, u, v):
        ru = self.getRoot(u)
        rv = self.getRoot(v)
        if (ru != rv):
            self.head[ru] = rv
            self.components -= 1
            self.inc -= self.sizes[rv] * self.sizes[ru]
            self.sizes[rv] += self.sizes[ru] 

N,M = map(int,input().split())

mergeOrder = []
inc = []
for i in range(M):
	a,b = map(int,input().split())
	mergeOrder.append((a-1,b-1))
	
D = DisjointSet(N)

for i in range(len(mergeOrder)-1,-1,-1):
	inc.append(D.inc)
	p,q = map(int,mergeOrder[i])
	D.merge(p, q)

for i in range(len(inc) - 1,-1,-1):
	print(inc[i])

Measured memory_bytes: 25912
from collections import Counter

n=int(input())
x = list(map(int,input().split()))
c = Counter(x)
y=[0]*(10**5+1)
for i in c.keys():
	y[i]=c[i]
ad=0
su=sum(x)
q=int(input())
for i in range(q):
	b , c = map(int, input().split())
	su=su-y[b]*b+y[b]*c
	y[c]+=y[b]
	y[b]=0
	print(su)
	

Measured memory_bytes: 21432
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N, D;
    cin >> N >> D;
    int X[N][D];
    rep(i, N){
        rep(j, D){
            cin >> X[i][j];
        }
    }
    int count  = 0;
    rep(i, N){
        for(int j = i + 1; j < N; j++){
            if(i != j){
                double length_pre = 0;
                rep(m, D){
                    length_pre += pow(X[i][m] - X[j][m], 2);
                }
                double length_ans = sqrt(length_pre);
                if(length_ans == (int)length_ans){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int num[1000];
int main()
{
	long long a,sum=1,k=0,i;
	cin>>a;
	if(a==0)
		num[k++]=0;
	while(a!=0)
	{
		if(a%-2<0)
		{
			if(a/-2<0)
				a=(a/-2)-1;
			else
				a=(a/-2)+1;
			num[k++]=1;
		}
		else
		{
			num[k++]=a%-2;
			a/=-2;
		}
	}
	for(i=k-1;i>=0;i--)
		printf("%d",num[i]);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
 double a,b,c,d,e,f,x,y;
 while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
  y = ((c*d)-(a*f)) / ((b*d)-(a*e));
  x = ((c-b*y)/a);
  printf("%.3lf %.3lf\n",x,y);
 }
return 0;
}

Measured memory_bytes: 652
// AOJ 1134: Name the Crossing
// 2017.11.13 bal4u@uu

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

#define HASHSIZ 503
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;			// Hash table

int insert(char *s, int w, int id)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
	return -1;
}

int lookup(char *s, int w)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	return -1;
}

#define INT 0x11111111
char name[202][36]; int sz;
int rel[202][202];

int main()
{
	int n, m, w, i, j, k, f;
	char buf[36], *p, *q;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		memset(hash, 0, sizeof(hash));
		memset(rel, INT, sizeof(rel));

		n = atoi(buf), sz = 0;
		while (n--) {
			fgets(name[sz], 35, stdin);
			p = q = name[sz]; while (*p != '-') p++; w = p - q, *p++ = 0;
			if ((i = insert(q, w, sz)) < 0) i = sz++;
			q = p; while (*p > ' ') p++; w = p - q, *p = 0;
			if ((j = insert(q, w, sz)) < 0) j = sz++;
			rel[i][j] = 1;
		}
		printf("%d\n", sz);

		for (i = 0; i < sz; i++) for (j = 0; j < sz; j++) if (i != j) {
			f = 0;
			for (k = 0; k < sz; k++) {
				if ((rel[i][k] == 1 && rel[k][j] == 1) ||
					(rel[j][k] == 1 && rel[k][i] == 1)) { f = 0; break; }
				if ((rel[i][k] == 1 && rel[j][k] == 1) ||
					(rel[k][i] == 1 && rel[k][j] == 1)) f = 1;
			}
			if (f) rel[i][j] = rel[j][i] = 0;
		}

		for (k = 0; k < sz; k++) for (i = 0; i < sz; i++) for (j = 0; j < sz; j++)
			if (rel[i][j] > rel[i][k] + rel[k][j]) rel[i][j] = rel[i][k] + rel[k][j];

		fgets(buf, 10, stdin); m = atoi(buf);
		while (m--) {
			fgets(buf, 35, stdin);
			p = q = buf; while (*p != '-') p++;	w = p - q, *p++ = 0;
			if ((i = lookup(q, w)) < 0) goto no;
			q = p; while (*p > ' ') p++; w = p - q, *p = 0;
			if ((j = lookup(q, w)) < 0) goto no;
			if (rel[i][j] < INT && (rel[i][j] & 1)) puts("YES");
			else {
no:				puts("NO");
			}
		}
	}
	return 0;

}

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

int gcd(int a, int b) {
  return a % b ? gcd(b, a%b) : b;
}

int main() {
  int K;
  cin >> K;
  
  int ans = 0;
  
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      for (int k = 1; k <= K; k++) {
        ans += gcd(gcd(i,j), k);
      }
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    std::vector<int64_t> B;

    for (int64_t i = N-1; i >= 0; i -=2) {
        B.push_back(A[i]);
    }
    if (N % 2 == 0) {
        // 偶数
        for (int64_t i = 0; i < N; i += 2) {
            B.push_back(A[i]);
        }
    }
    else {
        // 奇数
        for (int64_t i = 1; i < N; i += 2) {
            B.push_back(A[i]);
        }
    }

    for (auto& b: B) {
        std::cout << b << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 5488
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    deque<int> dq;
    rep(i,n){
        int x; cin >> x;
        if(i%2 == n%2) dq.pb(x);
        else dq.pf(x);
    }
    for(int i: dq) cout << i << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

k = int(input())
res = [0] * (k + 1)

ans = 0

for i in range(1, k + 1):
    for j in range(1, k + 1):
        res[gcd(i, j)] += 1

for n in range(1, k + 1):
    for r in range(1, k + 1):
        ans += gcd(r, n) * res[r]

print(ans)

Measured memory_bytes: 9212
/*  ex9_1 Stack (Keyboard)
    pandacodeb  */

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

#define SIZE 10

//スタックの構造体(配列型)
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
}stack;

//スタックを初期化
void init_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//スタックに要素を入れる
void push(stack *stk, char key){
    if (stk->count >= stk->size)
        exit(1);
    else{
        stk->top--;
        *(stk->top) = key;
        stk->count++;
    }
}

//スタックを最後に入れたキーを取り出す
char pop(stack *stk){
    char latest;
    if (stk->count <= 0){
        return ' ';
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

//スタックを表示
void print_s(stack *stk){
    char *ptr;
    ptr = (stk->top)+(stk->count)-1;
    for (int i = 0; i < stk->count; i++)
        printf("%c", *ptr--);
    printf("\n");
}

int main(void){
    int i;
    char del;

    //入力用
    char* text;
    text = (char*) malloc(sizeof(char)*10);
    scanf("%s", text);

    //スタックの宣言
    stack stk;
    init_stack(&stk);

    //最後の入力キーまで
    for (i = 0; i < strlen(text); i++){
        //キーが 0 あるいは 1 の場合 -> スタックに入れる
        if (text[i] == '0' || text[i] == '1')
            push(&stk, text[i]);
        //キーが B の場合 -> スタックを最後に入れたキーを取り出す
        else if (text[i] == 'B')
            del = pop(&stk);
    }

    //出力 (スタックの底からトップまで)
    print_s(&stk);
    
    return 0;
}

Measured memory_bytes: 1660
#include<iostream>

using namespace std;

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

    int nums = 0;

    for(int i=0; i<n; i++){
        int minj = i;
        for(int j=i; j<n; j++){
            if(a[j]<a[minj]){
                minj = j;
            }
        }
        int tmp = a[i];
        if(i<minj){
            a[i] = a[minj];
            a[minj] = tmp;
            nums += 1;
        }
    }

    for(int i=0; i<n-1; i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    cout << nums << endl;

}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  if(s.at(0)==s.at(1)&&s.at(0)!=s.at(2)&&s.at(2)==s.at(3))
    cout << "Yes" << endl;
  else if(s.at(0)==s.at(2)&&s.at(0)!=s.at(1)&&s.at(1)==s.at(3))
    cout << "Yes" << endl;
  else if(s.at(0)==s.at(3)&&s.at(0)!=s.at(1)&&s.at(1)==s.at(2))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

int a, b;

int main() {
	scanf("%d%d", &a, &b);

	if (a <= 0 && 0 <= b) {
		puts("Zero");
		return 0;
	}

	if (0 < a) {
		puts("Positive");
		return 0;
	}

	int t = b - a;
	if (t % 2) {
		puts("Positive");
	} else {
		puts("Negative");
	}

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    val L = Array(n + 1) { 0L }
    L[0] = 2
    L[1] = 1

    for (i in 2..n) L[i] = L[i - 1] + L[i - 2]

    println(L[n])

}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 29728
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

void process();

int main(){
    int X;
    int happy = 0;
    cin >> X;
    happy = (X / 500) * 1000;
    X = X % 500;
    happy += (X/5) * 5;
    cout << happy << endl;
    
    return 0;
}

void process(){
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n[4];
  REP(i, 4) cin>>n[i];
  sort(n, n+4);
  bool w=true;
  if(n[0]!=1)w=false;
  if(n[1]!=4)w=false;
  if(n[2]!=7)w=false;
  if(n[3]!=9)w=false;

  if(w){
    cout<<"YES"<<endl;
  }
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
//AOJ::ALDS1_1_A「Insertion Sort」
#include <bits/stdc++.h> //一括include
using namespace std;

void out(int array[], int x) //表示
{
    printf("%d", array[0]);
    for (int num = 1; num < x; num++)
    {
        printf(" %d", array[num]);
    }
    printf("\n");
}

int insertionsort(int A[], int N) //N個の要素を含む0～1000の配列A
{
    int i, v, j;
    for (i = 1; i <= N - 1; i++)
    {
        out(A, N);
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
    }
    return A[100];
}

int main()
{
    int n;
    int a[100] = {};
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    insertionsort(a, n);
    out(a, n);
}



Measured memory_bytes: 3212
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final PrintStream so = System.out;
    static final Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int A = ni();
        int B = ni();
        int T = ni();
        so.println(T/A * B);
    }
    
    static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
        
       
    static int ni() {
        return sc.nextInt();
    }
    
    static long nl() {
        return sc.nextLong();
    }

    static char[] nsToChars() {
        return sc.next().toCharArray();
    }
}


Measured memory_bytes: 23380
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,K;
int A[200010];

signed main(){
	cin>>N>>K;
	REP(i,N){
		cin>>A[i];
	}
	double sum=0;
	REP(i,N){
		if(i<K){
			sum+=log(A[i]);
		}
		else{
			double sum2=sum;
			sum2+=log(A[i]);
			sum2-=log(A[i-K]);
			if(sum<sum2){
				cout<<"Yes"<<endl;
			}
			else{
				cout<<"No"<<endl;
			}
			sum=sum2;
		}
	}
	return 0;
}


Measured memory_bytes: 5468