akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

void solve(vector<pair<int,int>>& res, int X, int Y, int K){
    const int sgnX = (X < 0 ? -1 : 1);
    const int sgnY = (Y < 0 ? -1 : 1);
    X *= sgnX; Y *= sgnY;
    bool sw = (Y > X);
    if(sw) swap(X, Y);
    if(K%2 == 0 && (X+Y)%2 == 1) return;
    while(X != 0 || Y != 0){
        if((X+Y)%2 == 0 && X+Y < 2*K && X+Y != K){
            int ax = (X+Y)/2;
            int ay = K - ax;
            int bx = ax;
            int by = -ay;
            ay += Y;
            ax -= Y;
            res.emplace_back(ax, ay);
            res.emplace_back(bx, by);
            break;
        }
        int dy = min(K, Y);
        int dx = K - dy;
        X -= dx; Y -= dy;
        if(X < 0) solve(res, X, Y, K);
        res.emplace_back(dx, dy);
        if(X < 0) break;
    }
    if(sw){
        for(auto& p : res) swap(p.first, p.second);
    }
    for(auto& p : res){
        p.first *= sgnX;
        p.second *= sgnY;
    }
}

int main(){
    int K, X, Y;
    while(cin >> K >> X >> Y){
        vector<pair<int,int>> res;
        solve(res, X, Y, K);
        if(res.empty()){
            cout << -1 << endl;
        } else {
            int x = 0, y = 0;
            cout << res.size() << endl;
            for(auto& p : res){
                x += p.first;
                y += p.second;
                cout << x << " " << y << endl;
            }
        }
    }
}

Measured memory_bytes: 3952
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'

typedef int64_t Int;
const double pi = M_PI;

using namespace std;

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

    cout << n * 800 - (n / 15) * 200 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int A[210]={};
int B[210]={};

int main(){
    int N;
    cin >> N;
    rep(i,N-1){
        cin >> B[i];
    }
    A[0] = B[0];
    A[N-1] = B[N-2];
    for(int i=1;i<N-1;i++){
        A[i] = min(B[i-1],B[i]);
    }
    int sum=0;
    rep(i,N){
        sum += A[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
s = list(str(input()))
t = list(str(input()))

s.sort()
t.sort()
t.reverse()


slen = len(s)
tlen = len(t)
if slen >= tlen:
    for i in range(tlen):
        if s[i]<t[i]:
            print('Yes')
            break
        elif s[i] == t[i]:
            if i == tlen-1:
                print('No')
                break
            else :
                continue
        else :
            print('No')
            break
else:
    for i in range(tlen):
        if s[i]<t[i]:
            print('Yes')
            break
        elif s[i] == t[i]:
            if i == slen-1:
                print('Yes')
                break
            else :
                continue
        else :
            print('No')
            break


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

int main() {

 char c;
 cin >> c;
  
  if(c == 'a' || c == 'e' || c== 'i' || c== 'o'|| c=='u'){
    cout << "vowel" << endl;
  }else{ cout << "consonant";
       }

}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	n := scInt()
	hlist := ints(n)
	dp := make([]int, n)
	dp[0] = 0
	dp[1] = abs(hlist[0] - hlist[1])

	for i := 1; i < n-1; i++ {
		diff1 := abs(hlist[i+1]-hlist[i]) + dp[i]
		diff2 := abs(hlist[i+1]-hlist[i-1]) + dp[i-1]
		dp[i+1] = min(diff1, diff2)
	}
	fmt.Println(dp[n-1])
}

func scStr() string {
	var s string
	fmt.Scan(&s)
	return s
}

func scInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func scInt2() (int, int) {
	var x, y int
	fmt.Scan(&x, &y)
	return x, y
}

func scInt3() (int, int, int) {
	var x, y, z int
	fmt.Scan(&x, &y, &z)
	return x, y, z
}

func ints(n int) (slice []int) {
	slice = make([]int, n)
	for i := range slice {
		fmt.Scan(&slice[i])
	}
	return slice
}

func sum(slice []int) (sum int) {
	sum = 0
	for i := range slice {
		sum += slice[i]
	}
	return
}

func unique(strs []string) (unique []string) {
	m := map[string]bool{}
	for _, v := range strs {
		if !m[v] {
			m[v] = true
			unique = append(unique, v)
		}
	}
	return unique
}

func min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

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

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


Measured memory_bytes: 6316
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
#define PB push_back
#define POP pop_back()
#define PII pair<int,int>
#define FI first
#define SE second
#define ULL unsigned long long
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-11;
const int maxn=2e5+10;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int flag=1;
	for(int i=0;i<s1.length();i++){
		if(s1[i]!=s2[i]){
			flag=0;
		}
	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
 	return 0;
}







Measured memory_bytes: 3620
s = str(input())

if len(s) == 1:
    print('YES')
    exit()

d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = 1
    else:
        d[s[i]] += 1
#print(d)

if len(s) == 2 and len(d) == 2:
    print('YES')
    exit()

if len(d) > 2:
    if max(d.values())-min(d.values()) <= 1:
        print('YES')
    else:
        print('NO')
else:
    print('NO')


Measured memory_bytes: 39280
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
int n,x;
cin>>n>>x;
vector<int> l(n);
rep(i,n){
    cin>>l[i];
}

int s=0;
int ans=1;

for(int i=0;i<n;i++){
    s+=l[i];
    if(s<=x)ans++;
    else{
        break;
    }
}

cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[] = new int[114514];
		
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		
		int q = scan.nextInt();
		int ans = 0;
		for (int i=0; i<q; i++) {
			int key = scan.nextInt();
			int ng = -1; int ok = n;
			while (Math.abs(ok-ng) > 1) {
				int mid = (ok+ng)/2;
				if (a[mid] >= key) ok = mid;
				else ng = mid;
			}
			if (a[ok]==key) ans++;
		}
		
		System.out.println(ans);
	}
}




Measured memory_bytes: 80204
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let Alice = Number(input[0].split(' ')[0])
	let Bob = Number(input[0].split(' ')[1])
	let cards = []
	for(let i = 2; i <= 13; i++) {
		cards.push(i)
	}
	cards.push(1)

	if(cards.indexOf(Alice) > cards.indexOf(Bob)) {
		console.log('Alice')
	} else if(cards.indexOf(Alice) < cards.indexOf(Bob)) {
		console.log('Bob')
	} else {
		console.log('Draw')
	}
}   
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

long long a[100005], dp[100005], n;

int main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        dp[i] = 1e9;
    }
    dp[1] = 0;
    for (int i = 1; i <= n; i++){
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
long long a, b, n;
long long check(long long limit)
{
	return (a * limit / b) - a * (limit / b);
}
int main()
{
	cin >> a >> b >> n;
	long long l, r, lmid, rmid;
	l = 0, r = min(b, n);
	while (l < r)
	{
		lmid = l + (r - l) / 3;
		rmid = r - (r - l) / 3;
		if (check(lmid) > check(rmid))
		{
			r = rmid - 1;
		}
		else
		{
			l = lmid + 1;
		}
	}
	cout << check(l) << endl;
	return 0;
}

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

using Point = pair<int, int>;

void up(int& x, int &y) {
    cout << "U";
    y++;
}

void down(int& x, int &y) {
    cout << "D";
    y--;
}

void left(int& x, int &y) {
    cout << "L";
    x--;
}

void right(int& x, int &y) {
    cout << "R";
    x++;
}


int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int x = sx,
        y = sy;
    // 1回目
    while (x + 1 <= tx) right(x, y);
    while (y + 1 <= ty) up(x, y);
    while (x - 1 >= sx) left(x, y);
    while (y - 1 >= sy) down(x, y);

    // 2回目
    down(x, y);
    while (x <= tx) right(x, y);
    while (y + 1 <= ty) up(x, y);
    left(x, y);
    up(x, y);
    while (x >= sx) left(x, y);
    while (y - 1 >= sy) down(x, y);
    right(x, y);

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
"use strict"

function main(input) {
  input = ~~input

  let total = 0
  for (let i = 1; i <= input; i += 2) {
    let cnt = 0
    for (let j = 1; j <= i; j++) {
      cnt += i % j == 0 ? 1 : 0
    }
    total += cnt == 8 ? 1 : 0
  }
  console.log(total)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 21064
using System;

class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] input =new string[n];
		input = Console.ReadLine().Split(' ');

		BubbleSort(input);	
		SelectSort(input);
	}


	static void BubbleSort(string[] input)
	{
		string[] array = new string[input.Length];
		Array.Copy(input, array, input.Length);

		for (int i=0; i<array.Length; i++)
		{
			for (int j=0; j<array.Length-i-1; j++)
			{
				int a = int.Parse(array[j].Substring(1, 1));
				int b = int.Parse(array[j+1].Substring(1, 1));
				if (a > b)
				{
					Swap(ref array[j], ref array[j+1]);
				}
			}
		}

		Write(array, input);
	}

	static void SelectSort(string[] input)
	{
		string[] array = new string[input.Length];
		Array.Copy(input, array, input.Length);

		for (int i=0; i<array.Length; i++)
		{
			int min = i;
			for (int j=i+1; j<array.Length; j++)
			{
				int a = int.Parse(array[min].Substring(1, 1));
				int b = int.Parse(array[j].Substring(1, 1));
				if (a > b)
				{
					min = j;
				}
			}

			if (min != i)
			{
				Swap(ref array[i], ref array[min]);
			}
		}

		Write(array, input);
	}

	static void Swap(ref string a, ref string b)
	{
		string buf = a;
		a = b;
		b = buf;
	}

	static void Write(string[] array, string[] input)
	{
		bool is_stable = true;
		for (int i=0; i<array.Length; i++)
		{
			if(i > 0)
			{
				int a = int.Parse(array[i].Substring(1, 1));
				int b = int.Parse(array[i-1].Substring(1, 1));
				if(a == b)
				{
					for(int j=0; j<array.Length; j++)
					{
						if(array[i].Equals(input[j]))
						{
							is_stable = false;
							break;
						}
						else if(array[i-1].Equals(input[j]))
						{						
							break;
						}
					}
				}
			}
			Console.Write((i > 0 ? " " : "") + array[i]);
		}
		Console.WriteLine();
		Console.WriteLine(is_stable ? "Stable" : "Not stable");
	}
}

Measured memory_bytes: 9044
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k,g[200001][65]; 
signed main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&g[i][0]);
	for(int l=1;l<=63;l++)
		for(int i=1;i<=n;i++)
			g[i][l]=g[g[i][l-1]][l-1];
	int now=1,cnt=0;
	while(k)
	{
		if(k&1)
			now=g[now][cnt];
		cnt++;
		k/=2;
	}
	cout<<now;
	return 0;
}

Measured memory_bytes: 105252
#include<cstdio>
#include<vector>
using namespace std;

struct edge{int to,cap,rev;};
const int INF = 1000000000;
vector<edge> G[100];
bool used[100];

void add_edge(int from,int to,int cap){
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
	if(v==t) return f;
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		edge &e = G[v][i];
		if(!used[e.to]&&e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t,int V){
	int flow = 0;
	for(;;){
		fill(used,used+V,false);
		int f = dfs(s,t,INF);
		if(f==0) return flow;
		flow += f;
	}
}

int main(){
	int v,e;
	scanf("%d %d",&v,&e);
	for(int i=0;i<e;i++){
		int u,v,c;
		scanf("%d %d %d",&u,&v,&c);
		add_edge(u,v,c);
	}
	printf("%d\n",max_flow(0,v-1,v));
	return 0;
}

Measured memory_bytes: 2812
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int a = 0, b = 0, c = 0;
    char cur = 'a';
    while (true) {
        if (cur == 'a') {
            if (a >= sa.length())break;
            cur = sa[a];
            a++;
        }
        else if (cur == 'b') {
            if (b >= sb.length())break;
            cur = sb[b];
            b++;
        }
        else {
            if (c >= sc.length())break;
            cur = sc[c];
            c++;
        }
    }
    cout << (char)(cur - 0x20) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cmath>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> p;
typedef vector<p> vp;
const int INF=1e9;
ll n;

int main(int argc,char const* argv[])
{
  int n,k;
  ll ans=1e14;
  cin >> n >> k;
  ll x[100005];
  bool pluex=false;
  bool minex=false;
  int pluindex=-1;
  int minindex=-1;
  for(int i=0;i<n;i++)
    {
      cin >> x[i];
      if(x[i]==0) 
	{
	  k-=1;
	}
      if(x[i]<0) 
	{
	  minindex=i;
	  minex=true;
	}
      if(x[i]>0 && !pluex) 
	{
	  pluindex=i;
	  pluex=true;
	}
    }
  if(pluindex==-1 && minindex!=-1)
    {
      cout << abs(x[minindex-k+1]) << endl;
      return 0;
    }
  else if(minindex==-1 && pluindex!=-1)
    {
      cout << abs(x[pluindex+k-1]) << endl;
      return 0;
    }
  for(int i=0;i<=k;i++)
    {
      if((minindex-i+1)<0 || (pluindex+(k-i)-1)>(n-1)) continue;
      ans=min(ans,2*abs(x[minindex-i+1])+abs(x[pluindex+(k-i)-1]));
      ans=min(ans,2*abs(x[pluindex+(k-i)-1])+abs(x[minindex-i+1]));
    }
  if(k==0)
    {
      cout << 0 << endl;
      return 0;
    }
  cout << ans << endl;
}


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

using namespace std;


int main(){
    unsigned int a,b;
    
    cin >> a >> b ;
    bitset<32> a_bit(a);
    bitset<32> b_bit(b);

    cout << (a_bit & b_bit) << "\n";
    cout << (a_bit | b_bit) << "\n";
    cout << (a_bit ^ b_bit) << "\n";
    return 0;   
}



Measured memory_bytes: 3172
S = input()
p = 0
head = ''
end = ''
Q = int(input())
for _ in range(Q):
  Qr = list(input().split())
  if int(Qr[0])==1:
    p = not p
  else:
    if int(Qr[1])==1:
      if p:
        end += Qr[2]
      else:
        head = Qr[2]+head
    else:
      if p:
        head = Qr[2]+head
      else:
        end += Qr[2]
S = head + S + end
if p:
  print(S[::-1])
else:
  print(S)

Measured memory_bytes: 4588
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()
	ships := make([][]int, N)
	for i := 0; i < M; i++ {
		a, b := sc.nextInt()-1, sc.nextInt()-1
		ships[a] = append(ships[a], b)
	}
	ok := false
	for _, to := range ships[0] {
		for _, t := range ships[to] {
			if t == N-1 {
				ok = true
			}
		}
	}

	if ok {
		fmt.Fprintln(wtr, "POSSIBLE")
	} else {
		fmt.Fprintln(wtr, "IMPOSSIBLE")
	}
	wtr.Flush()
}


Measured memory_bytes: 11904
#include<iostream>
#include<set>
#include<map>
#include<string>
#include<cstdint>

int main() {
  int N, M; std::cin >> N >> M;
  std::set<int> ac;
  std::map<int,int> wa;
  for(int i = 0; i < M; ++i) {
    int p; std::string S; std::cin >> p >> S;
    if(S == "AC") ac.insert(p);
    else if(ac.count(p) < 1) ++wa[p];
  }
  int64_t nWA = 0;
  for(auto i: ac) nWA += (int64_t)wa[i];
  std::cout << ac.size() << " " << nWA << std::endl;
  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll A, B;
    cin>>A>>B;
    cout<<max((ll)0, A-B*2)<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::LinkedList;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: BufRead> {
  reader: R,
  iter: std::vec::IntoIter<String>
}

#[allow(dead_code)]
impl<R: BufRead> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader, iter: vec![String::new()].into_iter() }
  }
  fn new_line(&mut self) {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    self.iter = line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>().into_iter();
  }
  fn get<T: FromStr>(&mut self) -> T {
    self.iter.next().unwrap().parse().ok().unwrap()
  }
  fn get_as_vec<T: FromStr>(&mut self) -> Vec<T> {
    self.iter.clone().map(|v| v.parse().ok().unwrap()).collect()
  }
  fn get_line(&mut self) -> String {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    line.trim().to_string()
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  sc.new_line();
  let n = scan!(sc; i32);
  let mut list: LinkedList<i32> = LinkedList::new();
  for _ in 0..n {
    sc.new_line();
    let query = scan!(sc; String);
    match &query[..] {
      "insert" => {
        let x = scan!(sc; i32);
        list.push_front(x);
      },
      "delete" => {
        let x = scan!(sc; i32);
        let idx = list.iter().position(|&e| e == x);
        if let Some(idx) = idx {
          let mut s = list.split_off(idx);
          s.pop_front();
          list.append(&mut s);
        }
      },
      "deleteFirst" => {
        list.pop_front();
      },
      "deleteLast" => {
        list.pop_back();
      },
      _ => {}
    } 
  }
  println!("{}", list.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(" "));
}



Measured memory_bytes: 35632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
typedef long long LL;

int Ctoi(char c){
    return c-'0';
}
LL Stoi(string s){
    LL d=1;
    LL res=0;
    for(int i=s.size()-1;i>=0;i--){
        res=res+d*Ctoi(s[i]);
        d=d*10;
    }
    return res;
}


int main()
{ 
    string s;
    cin>>s;
    int n;
    n=s.size();
    LL exp2[n+1];
    exp2[0]=1;
    for(int i=1;i<=n;i++){
        if(i==1){exp2[i]=1;}
        else{exp2[i]=exp2[i-1]*2;}
    }
    LL ans=0;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            ans=ans+(exp2[i]*exp2[n-j-1]*Stoi(s.substr(i,j-i+1)));
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, x;
    cin >> a >> b >> x;
    if (a <= 2 * b) {
        if (x % 1000 == 0) {
            cout << (x / 1000) * a << '\n';
        } else {
            if (x % 1000 <= 500) {
                cout << (x / 1000) * a + min(a, b) << '\n';
            } else {
                cout << (x / 1000) * a + a << '\n';
            }
        }
    } else {
        if (x % 500 == 0) {
            cout << (x / 500) * b << '\n';
        } else {
            cout << (x / 500) * b + min(a, b) << '\n';
        }
    }
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll x, a, b;
    cin >> x >> a >> b;
    ll res = (x-a)%b;
    cout << res << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int H, W; cin >> H >> W;
    vector<string> A(H); for (auto &s : A) cin >> s;
    int cnt = 0;
    for (auto &s : A) cnt += count(begin(s), end(s), '#');
    cnt--;
    int y = 0, x = 0;
    for (;;) {
        if (y == H-1 && x == W-1) {
            cout << (cnt == 0 ? "Possible" : "Impossible") << endl;
            break;
        } else if (x + 1 < W && A[y][x+1] == '#') {
            x = x + 1;
            cnt--;
        } else if (y + 1 < H && A[y+1][x] == '#') {
            y = y + 1;
            cnt--;
        } else {
            cout << "Impossible" << endl;
            break;
        }
    }
    return 0;
}

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

int main() {
	int N; cin >> N;
	int s;
	int out=0;
	for(int i=105; i<=N; i+=2){
	    s=0;
	    for(int j=1; j<=i; j+=2) if(i%j==0) ++s;
	    if(s==8) ++out;
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

#define MAXN 100010
#define ll long long

const ll INF = 1e18;

int n, k;
ll h[MAXN], f[MAXN];

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++ i)
		scanf("%lld", &h[i]);
	for (int i = 2; i <= n; ++ i)
	{
		f[i] = INF;
		for (int j = max(1, i - k); j < i; ++ j)
			f[i] = min(f[i], f[j] + (ll)abs(h[i] - h[j]));
	}
	printf("%lld", f[n]);
	return 0;
}

Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Buffer(make([]byte, 0), 1e6) // maxTokenSize
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code --- */

	n := nextInt64() - 1
	str := ""
	for n >= 0 {
		flagment := n % 26
		n = n/26 - 1
		str = string('a'+flagment) + str
	}
	fmt.Println(str)

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 1776
import java.io.BufferedReader
import java.util.*
import kotlin.math.max
import kotlin.math.min

fun main() = abc119d()

@OptIn(ExperimentalStdlibApi::class)
fun abc119d() = SimpleFastIOWithToken_abc119d().exec {
    val infinity = Long.MAX_VALUE / 100
    fun List<Long>.addPosNegInfinity() = buildList {
        add(-infinity);addAll(this@addPosNegInfinity);add(infinity)
    }.toLongArray()

    val (a, b, q) = List(3) { readInt() }
    val shrines = List(a) { readLong() }.addPosNegInfinity()
    val temples = List(b) { readLong() }.addPosNegInfinity()

    fun LongArray.lowerBound(key: Long): Int {
        var ng = -1
        var ok = size

        while (ok - ng > 1) {
            val mid = (ok + ng) / 2
            if (this[mid] >= key) ok = mid else ng = mid
        }
        return ok
    }

    fun minOf(a: Long, b: Long, c: Long, d: Long) = min(min(a, b), min(c, d))

    val answer = StringBuilder()

    repeat(q) {
        val x = readLong()
        val rightShrineIndex = shrines.lowerBound(x)
        val rightTempleIndex = temples.lowerBound(x)

        val leftShrine = shrines[rightShrineIndex - 1]
        val rightShrine = shrines[rightShrineIndex]
        val leftTemple = temples[rightTempleIndex - 1]
        val rightTemple = temples[rightTempleIndex]

        val min = minOf(
            // left shrine, left temple
            x - min(leftShrine, leftTemple),
            // left shrine, right temple
            rightTemple - leftShrine + min(rightTemple - x, x - leftShrine),
            // right shrine, left temple
            rightShrine - leftTemple + min(rightShrine - x, x - leftTemple),
            // right shrine, right temple
            max(rightShrine, rightTemple) - x
        )

        answer.appendln(min)
    }

    print(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc119d(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc119d.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


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

const int maxn=10005;
char s[maxn];

int main(){
    while(~scanf("%s", s)){
        int len=strlen(s);
        for(int i=0;i<len-8;i++){
            printf("%c", s[i]);
        }
        puts("");
    }
    return 0;
}



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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
int n;
  cin>>n;
  vin a(n);
  rep(i,0,n){
    cin>>a[i]; 
  }
  int mn=0;
  rep(i,0,n-1){
     rep(j,i+1,n){
       mn=max(mn,abs(a[i]-a[j]));
     }
  }
  cout<<mn<<endl;
}











Measured memory_bytes: 3616
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
def main():
    S_ = S()
    x = len(S_)
    ans = 'x' * x
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 74400
#include <iostream>
using namespace std;
int main()
{
	int x, y;

	while (true) {
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		else {
			if (x < y)cout << x <<" "<< y << endl;
			else cout <<y<<" " <<x<< endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[]A = new int[N];
		int[]A2 = new int[N];
		string[] str = Console.ReadLine().Split();
		int[]B = new int[100001];
		int[]B2 = new int[100001];
		int[]C = new int[100001];
		int[]C2 = new int[100001];
		int[]D = new int[100001];
		int[]D2 = new int[100001];
		for(var i=0;i<N/2;i++){
			A[i] = int.Parse(str[i*2]);
			B[A[i]] += 1;
			A2[i] = int.Parse(str[i*2+1]);
			B2[A2[i]] += 1;
		}
		long ans = 0;
		Array.Sort(B, (x,y) => y - x);
		Array.Sort(B2, (x,y) => y - x);
		ans += N/2 - B[0];
		ans += N/2 - B2[0];
		for(var i=0;i<N/2;i++){
			C[A[i]] += 1;
			C2[A2[i]] += 1;
		}
		long at = -1;
		long ac = 0;
		long bt = -1;
		long bc = 0;
		for(var i=0;i<100001;i++){
			if(C[i] == B[0]){
				at = i;
				ac += 1;
			}
			if(C2[i] == B2[0]){
				bt = i;
				bc += 1;
			}
		}
		if(ac == 1 && bc == 1 && at == bt){
			ans = Math.Min(N/2 - B[0] + N/2 - B[1],N/2 - B2[0] + N/2 - B2[1]);
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 21728
s = input()
length = len(s)

if length == 2:
    print('1 2') if s[0] == s[1] else print('-1 -1')
else:
    end = 0
    for i in range(length-2):
        if s[i] == s[i+1] :
            end = 1
            print(str(i + 1) + ' ' + str(i + 2))
            break

        if s[i] == s[i+2] :
            end = 1
            print(str(i + 1) + ' ' + str(i + 3))
            break


    if end == 0 :
        print('-1 -1')

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <limits.h>

using namespace std;



class Card {
public:
	int number;
	char mark;

	Card& operator=(const int number);

};

Card& Card::operator=(const int number) {
	this->number = number;
	return *this;
}

bool operator<=(const Card c1,const Card c2) {
	return (c1.number <= c2.number) ? true : false;
}


Card A[100000];
Card tmp[100000];

template <typename T>
int partition(T A[], int p, int r)
{
	T x = A[r];
	int i = p - 1;

	for (int j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			T tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}

	T tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;

	return i + 1;
}

template <typename T>
void quickSort(T A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}

template <typename T>
void merge(T A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;

	T *L = new T[n1 + 1];
	T *R = new T[n2 + 1];


	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] = INT_MAX;

	int i = 0;
	int j = 0;

	for (int k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}

	delete[] R;
	delete[] L;

}

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

bool isStable(Card A[], Card B[],int n) {
	for (int i = 0; i < n; i++) {
		if (A[i].number != B[i].number || A[i].mark != B[i].mark) {
			return false;
		}
	}
	return true;
}

int main(void)
{

	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> A[i].mark >> A[i].number;
		tmp[i] = A[i];
	}

	quickSort(A, 0, n-1);
	mergeSort(tmp, 0, n);

	cout << ((isStable(A, tmp, n)) ? "Stable" : "Not stable") << endl;

	for (int i = 0; i < n; i++) {
		cout << A[i].mark << ' ' << A[i].number << endl;
	}

	return 0;
}

Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const ll inf=1e18;
ll a[maxn];
ll dp[3][maxn];
char op[10];
int main(){
    int n;
    scanf("%d",&n);
    scanf("%lld",&a[1]);
    for(int i=2;i<=n;i++) {
        scanf("%s %lld",op,&a[i]);
        if(op[0]=='-')a[i]=-a[i];
    }
    for(int i=0;i<maxn;i++) dp[1][i]=dp[2][i]=-inf;
    ll ans=0;
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        if(a[i]>=0){
            dp[0][i]=max(max(dp[0][i-1]+a[i],dp[1][i-1]-a[i]),dp[2][i-1]+a[i]);
            dp[1][i]=dp[1][i-1]==-inf?-inf:max(dp[1][i-1]-a[i],dp[2][i-1]+a[i]);
            dp[2][i]=dp[2][i-1]==-inf?-inf:dp[2][i-1]+a[i];
        }else {
            dp[0][i]=max(dp[0][i-1]+a[i],max(dp[1][i-1]-a[i],dp[2][i-1]+a[i]));
            dp[1][i]=max(dp[1][i-1]-a[i],max(dp[0][i-1]+a[i],dp[2][i-1]+a[i]));
            dp[2][i]=max(dp[2][i-1]+a[i],dp[1][i-1]-a[i]);
        }
    }
//    for(int i=1;i<=n;i++) cout<<dp[0][i]<<" ";
//    cout<<endl;
//    for(int i=1;i<=n;i++) cout<<dp[1][i]<<" ";
//    cout<<endl;
    cout<<max(dp[0][n],max(dp[1][n],dp[2][n]))<<endl;
}


Measured memory_bytes: 3328
fun main(args: Array<String>) {
    while (true) {
        val n = readLine()!!.toInt()
        if (n == 0) break
        val s = readLine()!!.split(" ").map(String::toInt)
        println(Math.sqrt(s.map { Math.pow(it - s.average(), 2.0) }.sum().div(n)))
    }
}


Measured memory_bytes: 33276
#I
N=int(input())
P=[0]+[float(x) for x in input().split()]

dp=[0 for i in range(N+1)]
for i in range(N+1):
    dp[i]=[0 for j in range(i+1)]

dp[1][0]+=1-P[1]
dp[1][1]+=P[1]
for i in range(1,N):
    for j in range(i+1):
        p=P[i+1]
        dp[i+1][j+1]+=dp[i][j]*p
        dp[i+1][j]+=dp[i][j]*(1-p)
ans=0        
for i in range(int((N-1)/2)+1,N+1):
    ans+=dp[N][i]
    
print(ans)

Measured memory_bytes: 150792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <utility>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
ll mod = 1000000007;
//ll mod = 998244353;

ll powtwo(ll n) {
	ll cnt = 0;
	while (n > 0) {
		n /= 2;
		cnt++;
	}
	return (1 << cnt);
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	map<ll, ll> mp;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mp.insert(P(a[i], 0));
		mp[a[i]]++;
	}
	sort(all(a));
	a.push_back(LINF);
	ll ans = 0;
	vector<bool> flag(n, true);
	for (int i = n - 1; i >= 0; i--) {
		if (!flag[i]) continue;
		mp[a[i]]--;
		ll find = powtwo(a[i]) - a[i];
		ll pl = lower_bound(all(a), find) - a.begin();
		if (!mp[find]) continue;
		pl += mp[find] - 1;
		if (flag[pl]) {
			flag[pl] = false;
			flag[i] = false;
			mp[find]--;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 28260
function Main(input) {
    input = input.split("\n");
    for (i=0; i < input.length-1; i++) {
        tmp = input[i].split(" ")
        var a = tmp[0]
        var b = tmp[1]
        var c = tmp[2]
        var num = []
        num.push(a, b, c)
        num.sort()
        console.log(num[0], num[1], num[2])
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15112
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	string X; cin >> X;
	stack<char> ans;
	rep(i, 0, X.length()) {
		if (ans.empty() == true)ans.push(X[i]);
		else {
			if (ans.top() == 'S') {
				if (X[i] == 'S')ans.push('S');
				else ans.pop();
			}
			else ans.push(X[i]);
		}
	}

	cout << ans.size() << endl;

	return 0;
}


Measured memory_bytes: 644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
	
	ArrayList<ArrayList<Integer>> edgeList;

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int m = fs.nextInt();
		
		edgeList = new ArrayList<>(n);
		for(int i = 0; i < n; i++) {
			edgeList.add(new ArrayList<>());
		}
		
		for(int i = 0; i< m; i++) {
			int from = fs.nextInt()-1;
			int to = fs.nextInt()-1;
			edgeList.get(from).add(to);
		}
		
		int start = fs.nextInt()-1;
		int end = fs.nextInt()-1;
		
		int[][] visitedNode = new int[3][n];
		ArrayDeque<Node> queue = new ArrayDeque<>();
		queue.add(new Node(start, 0, 0));
		visitedNode[0][start] = 1;
		
		while(!queue.isEmpty()) {
			Node thisNode = queue.poll();
			
			if(thisNode.id == end && thisNode.status == 0) {
				System.out.println(thisNode.depth/3);
				return;
			}
			
			for(Integer nextNode : edgeList.get(thisNode.id)) {
				if(visitedNode[(thisNode.status + 1) % 3][nextNode] == 1) {
					continue;
				}
				
				visitedNode[(thisNode.status + 1) % 3][nextNode] = 1;
				queue.add(new Node(nextNode, thisNode.depth+1, (thisNode.status + 1) % 3));
			}
		}
		
		System.out.println(-1);
	}
	
	class Node{
		int depth;
		int id;
		int status;
		Node(int id, int depth, int status){
			this.id = id;
			this.depth = depth;
			this.status = status;
		}
	}
	
	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 58756
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e3 + 5;
const double eps = 1e9;
typedef long long LL;
#define ls o<<1
#define rs o<<1|1
#define m(o) (q[o].l+((q[o].r-q[o].l)>>1))

LL n, a, b;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> a >> b;
	if (a*b<n || a + b - 1>n) {
		cout << -1 << endl;
	}
	else {
		cout << n - a + 1;
		for (int i = n - a + 2; i <= n; i++) {
			cout << " " << i;
		}
		if (b != 1) {
			int t = (n - a) / (b - 1);
			int r = (n - a) % (b - 1);
			int cur = n - a;
			for (int i = 1; i < b; i++) {
				if (r) {
					for (int i = t; i >= 0; i--) {
						cout << " " << cur - i;
					}
					cur = cur - t - 1;
					r--;
				}
				else {
					for (int i = t - 1; i >= 0; i--) {
						cout << " " << cur - i;
					}
					cur = cur - t;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double n = sc.nextInt();
        double m = sc.nextInt();
        double d = sc.nextInt();
        double pro = 0.0;
        if(d == 0){
            pro = (m-1)/n;
        }
        else{
            pro = 2*(m-1)*(n-d) / (n*n);
        }
        System.out.printf("%.10f\n",pro);
    }
}


Measured memory_bytes: 21844
def factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
print(str(n)+':', ' '.join([str(i) for i in factorize(n)]))


Measured memory_bytes: 5608
fn main(){
	loop {
		match read_line() {
			Some(line) => {
				let v = split_parse::<i32>(&line);
				println!("{}", (v[0] + v[1]).to_string().len());
			},
			None => { break; },
		}
	}
}
 
fn split_parse<T: std::str::FromStr>(s: &str) -> Vec<T> {
	s.trim().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_line() -> Option<String> {
	let mut input = String::new();
	match std::io::stdin().read_line(&mut input) {
    	Ok(n) if n > 0 => { Some(input) },
    	_ => { None },
	}
}


Measured memory_bytes: 5020
var
	i,n,s:longint;
function primes(x:longint):longint;
var
	j,s:longint;
begin
	s:=0;
	for j:=1 to trunc(sqrt(x)) do
		if x mod j=0 then s:=s+2;
	if trunc(sqrt(x))=sqrt(x) then dec(s);
	exit(s);
end;
begin
	readln(n);
	s:=0;
	for i:=1 to n do
		if i mod 2=1 then
			if primes(i)=8 then inc(s);
	writeln(s);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }

signed main(){
  string a;
  cin>>a;
  int g=0;
  for(int i=0;i<a.size();i++){
    if(a.at(i)=='g')
      g++;
  }
  int g1=$(a.size(),2);
  cout<<g-g1<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
int a,b;
scanf("%d %d", &a, &b);
if(a+b==15){
printf("+\n");
return 0;
}else if(a*b==15){
printf("*\n");
return 0;
}else{
printf("x\n");
}
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long n,a,cha,ko[111111],cnt,ts,cur,pp;
int main()
{
	cin>>n>>a;
	cha=n-a;
	if (cha<0) cout<<-1<<endl;
	else if (!cha) cout<<n+1<<endl;
	else
	{
		for (int i=1;i<=sqrt(cha);i++)
		{
			if (cha%i==0)
			{
				ko[++cnt]=i;
				cur=0;ts=n;
				while(ts)
				{
					cur+=(ts%(i+1));
					ts/=(i+1);
				}
				if (cur==a)
				{
					cout<<i+1<<endl;
					return 0;
				}
			}
		}
		for (int i=cnt;i>=1;i--)
		{
			pp=cha/ko[i];
			cur=0;ts=n;
			while(ts)
			{
				cur+=(ts%(pp+1));
				ts/=(pp+1);
			}
			if (cur==a)
			{
				cout<<pp+1<<endl;
				return 0;
			}
		}
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    int k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
        int ans[n+1];
    ans[0]=0;
    for(int i=1;i<=n;i++){
        ans[i]=1000000000;
    }

    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
    if(i+j<n){
            ans[i+j]=min(ans[i+j],+ans[i]+abs(a[i]-a[i+j]));
        }
        else{
            break;
        }
        }
    
       
    }
    cout<<ans[n-1];

    return 0;
}

Measured memory_bytes: 1024