akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
	int i;
	int first;
	int weight;
	int fundo;
	while(1){
		first = 1;
		fundo = 1;
		if(scanf("%d",&weight) == EOF){break;}
		for(i = 0; i < 10; i++){
			if(i != 0){
				fundo <<= 1;
			}
			if(weight & fundo){
				printf(first ? "%d":" %d",fundo);
				first = 0;
			}
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define srep(i) for (int i = 0; i < s.size(); i++)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
    using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int n, w;
int weight[105] = {}, value[105] = {};

int dp[105][10005] = {};

int main()
{
    int n,m;
    string s,t;
    map<string, int> mp;
    int ans=0;
    cin>>n;
    rep(i,0,n){
        cin>>s;
        mp[s]++;
    }
    cin>>m;
    rep(i,0,m){
        cin>>t;
        mp[t]--;
    }
    for(auto mp_i : mp){
        ans = max (ans,mp_i.second);
    } 
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <complex>
#include <iterator>
#include <random>
#include <time.h>
#include <tuple>
#include <functional>
#include <list>
#include <limits.h>
using namespace std;

typedef pair<int, int> pii;

const int mod = 1000*1000*1000+7;
int N, M;
char S[3010];
vector<pii> seg;
int st[3010], ed[3010];
int prec[3010], psum[3010];
int in[3010];

int cc[3010][3010];
int dp(int idx, int cnt) {
	if(idx == N) return cnt == psum[N - 1];
	int &ret = cc[idx][cnt];
	if(ret != -1) return ret;

	int cur = psum[prec[idx]] - cnt;
	if(idx && prec[idx - 1] - idx + 1 < psum[prec[idx - 1]] - cnt) return ret = 0;
	if(!in[idx]) return ret = dp(idx + 1, cnt + (S[idx] - '0'));

	ret = 0;
	if(cur) ret += dp(idx + 1, cnt + 1), ret %= mod;
	ret += dp(idx + 1, cnt), ret %= mod;
	return ret;
}

int main() {
	scanf("%d %d", &N, &M);
	scanf("\n");
	for(int i = 0; i < N; i++) {
		scanf("%c", &S[i]);
	}
	for(int i = 0; i < M; i++) {
		int l, r; scanf("%d %d", &l, &r);
		l--; r--;
		if(seg.size() == 0 || seg.back().first < l) {
			if(seg.size() == 0 || seg.back().second < r) seg.push_back(pii(l, r));
		}
		else if(seg.back().second < r) seg.back().second = r;
	}
	memset(st, -1, sizeof(st));
	memset(ed, -1, sizeof(ed));
	for(int i = 0; i < seg.size(); i++) st[ seg[i].first ] = seg[i].second, ed[ seg[i].second + 1 ] = i;
	for(int i = 0; i < N; i++) {
		if(i && prec[i - 1] >= i) in[i] = 1;
		prec[i] = i;
		if(i) prec[i] = max(prec[i], prec[i - 1]);
		if(st[i] != -1) prec[i] = st[i], in[i] = 1;
	}
	for(int i = 0; i < N; i++) {
		psum[i] = S[i] - '0';
		if(i) psum[i] += psum[i - 1];
	}
	memset(cc, -1, sizeof(cc));
	cout<<dp(0, 0);
}

Measured memory_bytes: 35840
fun main(args: Array<String>) {
    val (m, d) = readIntegerList()
    var ans = 0
    for (M in 4..m) {
        for (D in 20..d) {
            val dString = D.toString()
            val d10 = dString[0].toString().toInt()
            val d1 = dString[1].toString().toInt()
            if (d10 >= 2 && d1 >= 2 && (d1 * d10) == M) {
                ans++
            }
        }
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 37896
#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


a, b, c, d = MI()

print(max(a * c, b * d, d * a, b * c))


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    VE v;
    rep(i, 3) {
        int enter;
        cin >> enter;
        v.pb(enter);
    }
    sort(all(v));
    if(v[0] == 5 && v[1] == 5 && v[2] == 7)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s;
  cin >> s;
  int num = s.size();
  
  int TF = 1;
  rep(i, (num/2)/2) {
    if(s[i] != s[(num-3)/2-i]) TF = 0;
    if(s[(num+1)/2+i] != s[num-1-i]) TF = 0;
    if(s[i] != s[(num+1)/2+i]) TF = 0;
    if(s[(num-3)/2-i] != s[num-1-i]) TF = 0;
  }
  if ((num/2)%2) {
    if(s[(num+1)/4-1] != s[3*(num+1)/4-1]) TF = 0;
  }
  
  if(TF) cout << "Yes" << endl;
  else cout << "No" << endl;
    
  return 0;
}

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

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

#define MAXX 10000005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long 

#define mod  1000000007



int main()
{
	FAST;
	ll a, b, k;
	cin >> a >> b >> k;
	ll h = a;
	a -= k;
	if(a < 0){
		a = 0;
	}
	k -= h;
	if(k < 0){
		k = 0;
	}
	if(!a && k){
		b -= k;
	if(b < 0){
		b = 0;
	}
	}
	cout << a << " " << b;
	return 0;
}

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

#define PI 3.1415926535
#define INF 0x7fffffffffffff
typedef long long int LLI;
typedef pair<LLI, LLI> Pair;

int N;
bool need_reverse;
double ans = 1.0/0.0;
LLI xs[2];
LLI ys[2];
vector<Pair> ps;

int main() {
  for (int i=0; i<2; i++) {
    scanf("%lld%lld", &xs[i], &ys[i]);
  }
  if (xs[1] < xs[0]) {
    swap(xs[0], xs[1]);
    swap(ys[0], ys[1]);
  }

  if (ys[1] < ys[0]) {
    need_reverse = true;
    ys[1] = -ys[1];
    ys[0] = -ys[0];
  }

  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    LLI x, y;
    scanf("%lld%lld", &x, &y);
    if (need_reverse) y = -y;
    if (x < xs[0] || xs[1] < x) continue;
    if (y < ys[0] || ys[1] < y) continue;
    ps.emplace_back(Pair(x, y));
  }
  sort(ps.begin(), ps.end());
  vector<LLI> dp(ps.size(), INF);
  for (auto &p : ps) {
    LLI t = p.second;
    *lower_bound(dp.begin(), dp.end(), t) = t;
  }
  LLI t = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
  LLI dx = xs[1]-xs[0];
  LLI dy = ys[1]-ys[0];
  ans = 100.0*(dx+dy) - (2-PI/2)*10*double(t);
  if (t > min(dx, dy)) ans += PI/2*10;
  printf("%.13f\n", ans);
}


Measured memory_bytes: 6512
h, n = gets.chomp.split.map(&:to_i)
a = []
b = []
n.times do
  aa, bb = gets.chomp.split.map(&:to_i)
  a.push aa
  b.push bb
end

inf = (1<<29)

t = [inf] * (h + 1)
t[0] = 0
0.upto(h) do |i|
  next if t[i] == inf
  a.zip(b) do |aa, bb|
    j = i + aa
    j = h if j > h
    k = t[i] + bb
    t[j] = k if t[j] > k
  end
end

puts t[h]


Measured memory_bytes: 1916
import static java.lang.System.*;
import java.util.*;

class UnionFind {
    int[] par;
    int[] num;

    UnionFind(int n) { 
    	par = new int[n];
    	num = new int[n];
        for(int i = 0; i < n; i++) {
        	par[i] = i;
        	num[i] = 1;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x); 
        int ry = root(y);
        if (rx == ry) return; 

        par[rx] = ry;
        num[ry] += num[rx];
    }

    boolean same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int getNum(int n) {
    	return num[root(n)];
    }
}

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

        int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] count = new int[n];
		ArrayList<ArrayList<Integer>> sides = new ArrayList<ArrayList<Integer>>();
		for(int i=0; i<n; i++) sides.add(new ArrayList<Integer>());
		for(int i=0; i<m; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			
			count[a]++;
			count[b]++;
			sides.get(a).add(b);
			sides.get(b).add(a);		
		}
		
		boolean even = true;
		boolean six = false;
		int branch = 0;
		for(int i=0; i<n; i++) {
			even &= ((count[i]%2)==0);
			six |= count[i] >= 6;
			branch += count[i]-2;
		}
		if(branch >= 6) six = true;

		if(even && !six && branch == 4) {
			UnionFind uf = new UnionFind(n);
			for(int i=0; i<n; i++) {
				if(sides.get(i).size() == 2 && sides.get(sides.get(i).get(0)).size() == 2) 
					uf.unite(i, sides.get(i).get(0));
				if(sides.get(i).size() == 2 && sides.get(sides.get(i).get(1)).size() == 2) 
					uf.unite(i, sides.get(i).get(1));
			}
			
			ArrayList<Integer> mid = new ArrayList<Integer>();
			for(int i=0; i<n; i++) {
				if(sides.get(i).size() == 4) {
					if(uf.same(sides.get(i).get(0), sides.get(i).get(1))) {
						mid.add(sides.get(i).get(2));
						mid.add(sides.get(i).get(3));
					}
					else if(uf.same(sides.get(i).get(0), sides.get(i).get(2))) {
						mid.add(sides.get(i).get(1));
						mid.add(sides.get(i).get(3));
					}						
					else if(uf.same(sides.get(i).get(0), sides.get(i).get(3))) {
						mid.add(sides.get(i).get(1));
						mid.add(sides.get(i).get(2));
					}						
					else if(uf.same(sides.get(i).get(1), sides.get(i).get(2))) {
						mid.add(sides.get(i).get(0));
						mid.add(sides.get(i).get(3));
					}						
					else if(uf.same(sides.get(i).get(1), sides.get(i).get(3))) {
						mid.add(sides.get(i).get(0));
						mid.add(sides.get(i).get(2));
					}
					else if(uf.same(sides.get(i).get(2), sides.get(i).get(3))) {
						mid.add(sides.get(i).get(0));
						mid.add(sides.get(i).get(1));
					}						
				}	
			}
			if(mid.size() == 4) {
				if(uf.same(mid.get(0), mid.get(2)) && uf.same(mid.get(1), mid.get(3)) || 
			       uf.same(mid.get(0), mid.get(3)) && uf.same(mid.get(1), mid.get(2))) 
					six = true;
			}
		}
		
		out.println(even && six ? "Yes": "No");
    }
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  int A=in(),B=in(),Q=in();
  vector<ll> s(A+2),t(B+2),x(Q);
  REP(i,A) s[i]=in<ll>();
  s[A]=-1e18,s[A+1]=1e18;
  REP(i,B) t[i]=in<ll>();
  t[B]=-1e18,t[B+1]=1e18;
  sort(ALL(s));
  sort(ALL(t));
  REP(i,Q){
    ll x=in<ll>();
    auto rs = lower_bound(ALL(s),x);
    auto rt = lower_bound(ALL(t),x);
    auto ls = rs-1;
    auto lt = rt-1;
    
    ll s[2]={*ls,*rs};
    ll r[2]={*lt,*rt};
    ll d=1e20;
    REP(u,2){
      REP(v,2){
        d = min((abs(x-s[u])+abs(s[u]-r[v])),d);
        d = min((abs(x-r[v])+abs(s[u]-r[v])),d);
      }
    }
    
    cout << d << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3712
//どの色も2人以上 or 全部異なる色⇔a_iがすべて同じ.
#include <iostream>
#include <algorithm>
using namespace std;

int n;
int a[100000];

int main() {
	int i;
	int mmax = -11451419;
	int mmin = 11451419;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		mmax = max(mmax, a[i]);
		mmin = min(mmin, a[i]);
	}
	
	if (mmax - mmin >= 2) { cout << "No" << endl; return 0; }
	if (mmax == mmin) {
		if (n / mmax >= 2 || mmax == n - 1) { cout << "Yes" << endl; }
		else { cout << "No" << endl; }
		return 0;
	}
	
	int minCnt = 0;
	for (i = 0; i < n; i++) {
		if (a[i] == mmin) minCnt++;
	}
	
	if (mmax <= minCnt) { cout << "No" << endl; return 0; }
	if ((n - minCnt) / (mmax - minCnt) >= 2) { cout << "Yes" << endl; return 0; }
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define long long int
bool true2(int a,int b,int c)
{
	int n=c*0.08;
	int n2=c*0.1;
	return a==n&&b==n2;
}
signed main()
{
	int a,b;
	while(cin>>a>>b)
	{
		bool f=0;
		int k=(b+1)*100;
		for(int i=0;i<=k;i++)
		{
			if(true2(a,b,i)) 
			{
				f=1;cout<<i<<"\n";
				break;
			}
		}
		if(!f) cout<<-1<<"\n";
	}
} 

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

using lint = long long;

lint Knapsack(int limit, vector<int> &v, vector<int> &w) {
    vector<lint> dyn(limit+1, -1); int n = w.size();
    dyn[0] = 0;
    for (int i = 0; i < n; ++i)
        for (int j = limit; j >= w[i]; --j)
            if (dyn[j - w[i]] >= 0)
                dyn[j] = max(dyn[j], dyn[j - w[i]] + v[i]);
    lint result = 0;
    for (int i = 0; i <= limit; ++i) 
        result = max(result, dyn[i]);
    return result;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n,w;
    cin >> n >> w;
    vector<int> v(n), c(n);
    for (int i = 0; i < n; ++i) 
    	cin >> c[i] >> v[i];
    cout << Knapsack(w, v, c) << '\n';
    
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){

    int x, a, b;

    scanf("%d %d %d", &x, &a, &b);

    if(a-b >= 0) printf("%s\n", "delicious");
    else if(b-a <= x) printf("%s\n", "safe"); 
    else printf("%s\n", "dangerous");

    return 0;

}

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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29

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

for(int i=0;i<n;i++){
int k;
cin >> k;
int temp;
for(int j=0;j<k;j++){
cin >> temp;
a[temp-1]++;
}
}
int count=0;
for(int i=0;i<m;i++){
if(a[i]==n)count++;
}

cout << count;

}


Measured memory_bytes: 256
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);
	
	void solve(){
		String a=s.next();
		System.out.println((a+a).contains(s.next())?"Yes":"No");
	}

	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define int long long

signed main(){
	string s, t;
	cin >> s >> t;
	bool ans = false;
	for(char i = 'a'; i <= 'z'; i++){
		if(s + i == t)ans = true;
	}
	if(ans)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3568
#coding:utf-8
h, w, a, b = map(int, input().split())

if a > (w//2) or b > (h//2):
    print('No')
else:
    for _ in range(h-b):
        print('1'*(w-a) + '0'*a)
    for _ in range(b):
        print('0'*(w-a) + '1'*a)


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

namespace Contest
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            long ans = 0;
            for(int i = 0; i < n; i++)
            {
                for(int j = i + 1; j < n; j++)
                {
                    if (s[i] != s[j]) continue;
                    if (i >= 1 && s[i - 1] == s[j - 1]) continue;

                    for(int k = 0; k < n + 1; k++)
                    {
                        int kx = k + i;
                        int ky = k + j;
                        if (kx >= j) break;
                        if (ky >= n) break;
                        if (s[kx] != s[ky]) break;
                        ans = Math.Max(ans, k + 1);
                    }
                }
            }
            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 13236
s=input()
if len(s)==7:
    if s=="keyence":
        print("YES")
    else:
        print("NO")
else:
    if s[:7]=="keyence":
        print("YES")
    elif s[-7:]=="keyence":
        print("YES")
    else:
        for i in range(7-1):
            if s[:i+1]+s[-(7-i-1):]=="keyence":
                print("YES")
                exit()
        print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
ll lcm(ll a,ll b)
{return a/gcd(a,b)*b;}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=1e18;
//------------------------------------------------------------
int N;
int nums[1100];
ll ans=1;

void solve() {

  rep(i,0,5)
  {
    ll a;
    cin >> a;
    if(a==0) ans=i;
  }

  print(ans+1);
  return;
}

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

int main(){
  int A[3];
  cin >> A[0] >> A[1] >> A[2] ;
  sort(A,A+3);
  cout << A[2]-A[0]<< endl;
  return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1)%1000000007;
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


/*最小公倍数*/
/*
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
*/

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll a,b;
    cin>>a>>b;
    //double x=a/(0.08)+b/(0.10);
    //cout<<max(a/0.08,b/0.10)<<endl;
    for(ll i=0;i<1000000;i++){
        //cout<<i*0.08<<endl;
        //cout<<i*0.10<<endl;
        if((ll)(i*0.08)==a&&(ll)(i*0.10)==b){
            cout<<(ll)(i)<<endl;
            exit(0);
        }
    }
    cout<<-1<<endl;

    
    
        
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

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

  int N, M;
  cin >> N;

  unordered_map<string, int> m;

  string s;
  for (int i = 0; i < N; ++i) {
    cin >> s;
    m[s]++;
  }

  cin >> M;
  for (int i = 0; i < M; ++i) {
    cin >> s;
    m[s]--;
  }

  int ans = 0;
  for (const auto& p : m) {
    ans = max(ans, p.second);
  }
  cout << ans << endl;

  return 0;
}


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

int n, m;

int prime(int x){
	for(int i=2; i*i<=x; ++i)
		if(x % i == 0)
			return false;
	return true;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m;
	if(prime(m)){
		cout << 1 << "\n";
		return 0;
	}
	for(int i=n; i<=m; ++i){
		if(m % i == 0){
			cout << m / i << "\n";
			return 0;
		}
	}
}

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

int selectionSort(int A[], int N) {
  int sw = 0;
  for (int i = 0; i < N; i++) {
    int min_j = i;
    for (int j = i; j < N; j++) {
      if (A[j] < A[min_j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      swap(A[i], A[min_j]);
      sw++;
    }
  }
  return sw;
}

int main() {
  int A[100], N, sw;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  sw = selectionSort(A, N);

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



Measured memory_bytes: 3084
A = int(input())
B = int(input())
C = int(input())
X = int(input())
pos = {}
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            v = a*500 + b*100 + c*50
            pos.setdefault(v,0)
            pos[v] += 1
            if v > X:
                break
print(pos.setdefault(X,0))

Measured memory_bytes: 9216
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
 
int main(){
  int N,K;
  cin>>N>>K;
  int l[N];
  FOR(i,0,N) cin>>l[i];
  sort(l,l+N);
  reverse(l,l+N);
  int ans = 0;
  FOR(i,0,K) ans += l[i];
  cout << ans << endl;
  return 0;
}

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

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

int main() {
    string s;

    cin >> s;

    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	
	long long sum = 0;
	for(int i = 1;i < n;i++){
		sum += a[i];
	}
	
	long long sum2 = a[0];
	long long mindiff = sum2-sum > 0 ? sum2-sum : -(sum2-sum);
	for(int i = 1;i < n-1;i++){
		sum2 += a[i];
		sum -= a[i];
		mindiff = min(mindiff, sum2-sum > 0 ? sum2-sum : -(sum2-sum));
	}
	
	cout << mindiff << endl;
	
	return 0;
}

Measured memory_bytes: 1024
import sys
from math import log2
from math import ceil

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, k = MI()
    p = 0
    for i in range(1, min(n+1, k)):
        x = ceil(log2(k/i))
        p += 0.5**x
    p += max(0, n-k+1)
    p /= n
    print(p)

if __name__ == '__main__':
    main()

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}

      public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = (int)inputArray[0];
			var bArray = retreiveLongArray();

			var answers = new List<int>();
			for (var i = N-1; i >= 0; i--) {//挿入手順を逆順で検証する
				var canInsert = false;
				for (var j = i; j >= 0; j--) {
					if (bArray[j] == j+1) {
						canInsert = true;
						answers.Add(j + 1);
						for (var k = j; k < i; k++) {
							bArray[k] = bArray[k + 1];//配列を書き換える
						}
						break;
					}

				}
				if (!canInsert) {
					Console.WriteLine(-1);
					return;
				}
			}

			//答えの出力
			answers.Reverse();
			foreach (var item in answers) {
				Console.WriteLine(item);
			}

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 28344
//A,Elebereth,Gilthoniel mantae!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring> 
#include<map>
using namespace std;
set<int> s;
int main()
{
int n;cin>>n;while(n--)
{
	int a;cin>>a;if(s.count(a)==1) s.erase(a);else s.insert(a);
}cout<<s.size();
	return 0;
}

Measured memory_bytes: 4864
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

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

    int ans = s.length();
    for (char c = 'a'; c <= 'z'; c++) {
        string t = s;

        for (int turn = 0;; turn++) {
            bool all = true;
            for (auto& d : t) {
                if (d != c) {
                    all = false;
                    break;
                }
            }

            string u;
            for (int i = 0; i + 1 < t.length(); i++) {
                if (t[i] == c || t[i + 1] == c)
                    u.push_back(c);
                else
                    u.push_back(s[i]);
            }
            if (all) {
                ans = min(ans, turn);
                break;
            }
            t = u;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;


int n, m,a,b;
string s;

int main() {
	cin >> n >> a >> b;
	cout << min(b, a*n)<<endl;
}

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

def ff(X):
    res = 1
    if X == 0:
        return 0
    if X <= 0:
        res = -1 
        X = -X
    ok = 10000
    ng = -1
    while abs(ok-ng) > 1:
        med = (ok+ng)//2
        if med**5 >= X:
            ok = med
        else:
            ng = med
    if ok**5 == X:
        return res*ok
    return None
X = int(readline())

for b in range(-1000, 10000):
    a = ff(pow(b, 5) + X)
    if a is not None:
        print(a, b)
        break

Measured memory_bytes: 67648
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A % 2 == 1 && B % 2 == 1){
            System.out.println("Alice");
            return;
        }
        if(A % 2 == 0 && B % 2 == 0){
            System.out.println("Alice");
            return;
        }
        System.out.println("Borys");
    }
}


Measured memory_bytes: 23380
# -*- coding: utf-8 -*-
"""
Created on Mon Apr  8 15:45:11 2019

@author: adachi-lab
"""

import math
N = int(input())

T = 0
A = []


for i in range(5):
    X = int(input())
    A.append(X)
    
W1 = A.index(min(A))


T = math.ceil(N/A[W1])+4

print(T)

        


Measured memory_bytes: 3060
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let x: usize = read();
    
    if x < 1200 {
       println!("ABC");
    } else {
       println!("ARC");
    }
}


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

angle_A = (H + M/60)* 30
angle_B = M * 6
angle = angle_A - angle_B
if abs(angle) <= 180:
  print((A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(angle))) ** (1/2))
else:
  angle = 360 - angle
  print((A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(angle))) ** (1/2))

Measured memory_bytes: 9528
import java.io.*
import java.util.*

fun solve(N: Long){
    println((1..N).map{ it.toString().length }.count{ it % 2 != 0 })
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    solve(N)
}



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

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

struct Edge {
    int to; ll t;
    Edge(int _to, ll _t) : to(_to), t(_t) {}
};

struct State {
    int id, v; ll d;
    State(int _id, int _v, ll _d) : id(_id), v(_v), d(_d) {}
    bool operator < (const State &b) const {return d < b.d;}
    bool operator > (const State &b) const {return d > b.d;}
};

typedef pair<int, int> PII;

vector<vector<Edge>> G;

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

    G.resize(N);

    rep(i, M) {
        int X, Y, T;
        cin >> X >> Y >> T;
        X--, Y--;
        G[X].push_back(Edge(Y, T));
        G[Y].push_back(Edge(X, T));
    }

    int V0, A, B, C;
    cin >> V0 >> A >> B >> C;

    priority_queue<State, vector<State>, greater<State>> Q, Q2;
    map<PII, ll> d, d2;

    {
        d[PII(0, V0)] = 0LL;
        Q.push({0, V0, 0LL});

        while (Q.size()) {
            State s = Q.top(); Q.pop();
            // cerr << "(id, v) = (" << s.id << ", " << s.v << ")" << endl;
            if (s.id == N-1) {
                Q2.push(s);
                d2[PII(s.id, s.v)] = s.d;
            }

            if (d.count(PII(s.id, s.v)) && d[PII(s.id, s.v)] < s.d) continue;
            for (auto e : G[s.id]) {
                ll ncost = s.d + s.v * e.t;
                int nv = (A * s.v + B) % C;

                if (!d.count(PII(e.to, nv)) || d[PII(e.to, nv)] > ncost) {
                    d[PII(e.to, nv)] = ncost;
                    Q.push(State(e.to, nv, ncost));
                }
            }
        }
    }

    // cerr << "-------------------" << endl;

    ll ans = INFLL;
    {
        while (Q2.size()) {
            State s = Q2.top(); Q2.pop();
            // cerr << "(id, v) = (" << s.id << ", " << s.v << ")" << endl;

            if (s.id == 0) {
                ans = s.d;
                break;
            }

            if (d2.count(PII(s.id, s.v)) && d2[PII(s.id, s.v)] < s.d) continue;
            for (auto e : G[s.id]) {
                ll ncost = s.d + s.v * e.t;
                int nv = (A * s.v + B) % C;

                if (!d2.count(PII(e.to, nv)) || d2[PII(e.to, nv)] > ncost) {
                    d2[PII(e.to, nv)] = ncost;
                    Q2.push(State(e.to, nv, ncost));
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 8136
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    rep(i,k){
        if(!(a<b)){
            b*=2;
        }else if(!(b<c)){
            c*=2;
        }
    }
    cout<<(a<b&&b<c?"Yes":"No")<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <set>
#define ll long long
using namespace std;

int main() 
{
    ll n;
    cin >> n;
    vector<ll> h(n), min_cost(n);
    for(ll i = 0; i < n; i++) {
        cin >> h.at(i);
    }

    min_cost.at(0) = 0;
    min_cost.at(1) = abs(h.at(1) - h.at(0));
    for(ll i = 2; i < n; i++) {
            min_cost.at(i) = min((min_cost.at(i - 2) + abs(h.at(i) - h.at(i - 2))), (min_cost.at(i - 1) + abs(h.at(i) - h.at(i - 1))));
    }

    cout << min_cost.at(n - 1) << endl;
}

Measured memory_bytes: 1792
import Control.Applicative

main :: IO ()
main = do
  [dice1, dice2] <- map (roll . (take 3) . map read . words) . lines <$> getContents :: IO [[Int]]
  putStrLn $ if dice1 == dice2 then "Yes" else "No" 

roll :: [Int] -> [Int]
roll xs@(a:b:c:_) = 
  let
    cnt = length $ filter (>= 4) $ xs
    dice = map (\x -> min x (7 - x)) $ if (even cnt) then xs else a:c:b:[]
    (as, bs) = break (== 1) dice
  in
    bs ++ as

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
	static boolean bElapsed = false;
	List<String> list = new ArrayList<>();
	Set<String> set = new HashSet<>();
	Map<String,Integer> map = new HashMap<>();

	int h;
	int w;

	void solve(BufferedReader br) throws Exception {
		String line = br.readLine();
		String[] flds = line.split(" ");
		h = Integer.parseInt(flds[0]);
		w = Integer.parseInt(flds[1]);
		int n = Integer.parseInt(flds[2]);
		for (int i=0; i<n; i++) {
			line = br.readLine();
			flds = line.split(" ");
			int a = Integer.parseInt(flds[0]);
			int b = Integer.parseInt(flds[1]);
			add(a-2, b-2);
			add(a-1, b-2);
			add(a+0, b-2);
			add(a-2, b-1);
			add(a-1, b-1);
			add(a+0, b-1);
			add(a-2, b+0);
			add(a-1, b+0);
			add(a+0, b+0);
		}
		int[] cnt = new int[10];
		for (String key : map.keySet()) {
			int idx = map.get(key);
			cnt[idx]++;
		}
		long total = (long)(h-2) * (w-2);
		pln(total-map.size());
		for (int i=1; i<=9; i++) {
			pln(cnt[i]);
		}
	}

	void add(int y, int x) {
		if (x < 1 || y < 1 || x+2 > w || y+2 > h) {
			return;
		}
		String key = x + "," + y;
		//pln(key);
		Integer i = map.get(key);
		if (i == null) {
			map.put(key, 1);
		} else {
			map.put(key, i+1);
		}
	}

	void p(char c) {
		System.out.print(c);
	}
	void pln(char c) {
		System.out.println(c);
	}
	void p(long l) {
		System.out.print(l);
	}
	void pln(long l) {
		System.out.println(l);
	}
	void p(String s) {
		System.out.print(s);
	}
	void pln(String s) {
		System.out.println(s);
	}
	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		new Main().solve(br);
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.out.println((end-start) + "ms");
		}
	}
}


Measured memory_bytes: 161464
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
typedef pair<int, int>P;
typedef pair<P, int> PP;
#define int long long

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

signed main() {
	int x, y; cin >> x >> y;
	if (x%y == 0) {
		puts("-1");
		return 0;
	}
	cout << x*y - x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mid (l+r)/2
#define int long long
using namespace std;
int n,Q,p,q,seg[2][800001],ans;
void segadd(int nu,int u,int l,int r,int nl,int nr,int np){
	if(l>nr||r<nl)return;
	else if(l>=nl&&r<=nr){
		seg[nu][u]=min(seg[nu][u],np);
		return;
	}else{
		segadd(nu,u*2,l,mid,nl,nr,np),segadd(nu,u*2+1,mid+1,r,nl,nr,np);
		return;
	}
}
int segreq(int nu,int u,int l,int r,int np,int nx){
	if(l==r){
		return min(nx,seg[nu][u]);
	}else{
		if(np<=mid)return segreq(nu,u*2,l,mid,np,min(nx,seg[nu][u]));
		else return segreq(nu,u*2+1,mid+1,r,np,min(nx,seg[nu][u]));
	}
}
signed main(){
	cin>>n>>Q;
	for(int i=1;i<=4*n;i++)seg[0][i]=seg[1][i]=n;ans=(n-2)*(n-2);
	for(int i=1;i<=Q;i++){
		cin>>p>>q;
		if(p==1){
			int np=segreq(0,1,1,n,q,n);ans-=np-2;
			segadd(1,1,1,n,1,np-1,q);
		}else if(p==2){
			int np=segreq(1,1,1,n,q,n);ans-=np-2;
			segadd(0,1,1,n,1,np-1,q);
		}
	}
	printf("%lld\n",ans);
	return 0;
}
/*
100 4 17
10 4 7
*/

Measured memory_bytes: 16192
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
       printf("a < b\n");
       }
    if(a>b){
      printf("a > b\n");
      }
    if(a==b){
      printf("a == b\n");
      }
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 2e5+5;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int a, b, x, y;

    cin >> a >> b;

    if (b <= a) x = b, y = a;
    else x = a, y = b;

    for (int i = 0; i < y; i++) {

        cout << x;
    }

    return 0;
}


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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){out << q.F << " " << q.S; return out;}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){return {p1.F-p2.F, p1.S-p2.S};}

void solve() {
    long double a;
    long double b;
    cin >> a >> b;
    cout << (int)(a*b) << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    // cin >> t;
    
    for(int i = 1; i <= t; ++i){
        solve();
    }
    //cerr << time(start);
    return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,g=0;
  cin>>N;
  vector<int> A(N+2,0),B(N+1);
  for(int i=1;i<=N;i++)
    cin>>A[i];
  for(int i=0;i<N+1;i++)
    B[i]=abs(A[i]-A[i+1]),g+=B[i];
  for(int i=1;i<=N;i++)
    cout<<g-(B[i-1]+B[i])+abs(A[i-1]-A[i+1])<<endl;
}

Measured memory_bytes: 4840
import java.util.*;
import java.io.*;
public class Main {
    public static double dp[][][];
    public static double solve(int X , int Y , int Z , int n){
        if(X < 0 || Y < 0 || Z < 0) return 0;
        if(X <= 0 && Y <= 0 && Z <= 0) return 0;

        if(dp[X][Y][Z] > -0.9) return dp[X][Y][Z];

        return dp[X][Y][Z] = (n + (X * solve(X-1,Y,Z,n)) + (Y * solve(X+1,Y-1,Z,n)) + (Z * solve(X,Y+1,Z-1,n)) )/(X+Y+Z);
    }
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int one = 0;
        int two = 0;
        int three = 0;
        dp = new double[n+1][n+1][n+1];
        for(int i = 0 ; i <= n ; i++){
            for(int j = 0 ; j <= n ; j++){
                for(int k = 0 ; k <= n ; k++){
                    dp[i][j][k] = -1;
                }
            }
        }
        for(int i = 1 ; i <= n ; i++){
            int temp = s.nextInt();
            if(temp == 1) one++;
            else if(temp == 2) two++;
            else three++;
        }
        System.out.println(solve(one , two , three , n));
    }
}

Measured memory_bytes: 281080
#include<bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;

int main(){
  str s;
  getline(cin,s);
  split_str(s,',')
    printf("%s ",res.c_str());

  return 0;
}

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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	string s;
	cin >> s;

	for(auto i : s)
	if(i == '9')
	cout << 1 ;
	else if(i == '1')
	cout << 9;
	else
	cout << i;

	cout << endl;	

	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll X ,K ,D;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> X >> K >> D;
    if(X < 0) X = -X;
    if(X/D > K){
        cout << X-K*D << endl;
    }else{
        ll t = X/D;
        K -= t;
        X -= t*D;
        if(K%2 == 0){
            cout << X << endl;
        }else{
            cout << D-X << endl;
        }
    }
}

Measured memory_bytes: 3644