akhauriyash/Code-Regression huggingface dataset:
// B - Power Socket
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int c = 1; c < b; c += a - 1) ans++;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
    ll a;
    long double b;
    cin >> a >> b;
    b *= 100;
    ll ans = a * b / 100;
    cout << ans << endl;
}


Measured memory_bytes: 3720
#include <stdio.h>

#define mod 1000000007
int main(void) {
  int s;
  scanf("%d", &s);
  long A[2001] = { 1 };
  if(s < 3) {
    puts("0");
    return 0;
  }
  for (int i = 3;i <= s;i++) {
    A[i] = A[i-1] + A[i-3];
    A[i] %= mod;
  }
  printf("%ld\n", A[s]);
  return 0;
}



Measured memory_bytes: 2144
import heapq
n = int(raw_input())
heap = [map(int, raw_input().split(' '))[::-1] for _ in range(n)]
heapq.heapify(heap)

def f(heap):
	t = 0
	while(heap):
		nd,ct = heapq.heappop(heap)
		while(heap and heap[0][0] == nd): ct += heapq.heappop(heap)[1]
		gap = nd - ct - t
		if gap < 0:
			return False
		while(heap and heap[0][1] <= gap):
			u,v = heapq.heappop(heap)
			gap -= v
			t += v
		t += ct
	return True
print 'Yes' if f(heap) else 'No'

Measured memory_bytes: 54588
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n;
string s;

int main()
{
    cin >> n;
    cin >> s;
    vi chars; rep(i, n) chars.pb(s[i] - 'a');
    vi right_nums(30, 0); rep(i, n) right_nums[chars[i]]++;
    vi left_nums(30, 0);

    int ans = 0;
    rep(i, n){
        right_nums[chars[i]]--;
        left_nums[chars[i]]++;
        int cc = 0;
        rep(c, 30) if(right_nums[c] != 0 && left_nums[c] != 0) cc++;
        ans = max(ans, cc);
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    ll a = 11, b = 10, x = 10, lim = 10, mx = 0;
    cin >> a >> b >> x;
    ll i = min(b - 1, x);
    ll A = ((a * i)/b) - a * (i/b);
    cout << A;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    vector<ll> x(n),y(n),X(n),Y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
        X[i]=x[i]+y[i];
        Y[i]=x[i]-y[i];
    }

    sort(all(X));
    ll tmp1=X[n-1]-X[0];
    sort(all(Y));
    ll tmp2=Y[n-1]-Y[0];
    ll ans=max(tmp1,tmp2);
    cout<<ans<<endl;
} 


Measured memory_bytes: 9540
from itertools import accumulate
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
b=[0]*(2*a[0]+1)
for i in range(n):
  b[a[i]]+=1
b=list(accumulate(b[::-1]))[::-1]
s=list(accumulate([0]+a))
ok=0
ng=2*a[0]+1
while ng-ok>1:
  mid=(ng+ok)//2
  cnt=0
  for i in range(n):
    cnt+=b[max(0,mid-a[i])]
  if cnt>=m:
    ok=mid
  else:
    ng=mid
cnt=0
ans=0
for i in range(n):
  t=min(b[max(0,ng-a[i])],m-cnt)
  ans+=s[t]+a[i]*t
  cnt+=t
ans+=(m-cnt)*ok
print(ans)

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

int main()
{
    ll N; cin >> N;
    vector<ll> A(N, 0);
    ll left = 0;
    ll right = 0;
    rep(i,N) {
        ll tmp; cin >> tmp;
        A[i] = tmp;
    }
    ll num = 0;
    ll kin = 1000;
    rep(i,N-1) {
        if (A[i] < A[i+1]) {
            num = kin / A[i];
            kin -= (num * A[i]);
            kin += (num * A[i+1]);
            num = 0;
        }
    }
    cout << kin << endl;


}


Measured memory_bytes: 3624
(function (p, n, s, t) {
  p = p.split('\n');

  n = Number(p[0].split(' ')[0]);
  s = String(n);
  t = p[1].split(' ');

  while (true) {
    for (var i = 0; i < t.length; i++) {
      if (s.indexOf(t[i]) >= 0) {
        s = String(++n);
        break;
      }
    }
    if (i == t.length) {
      break;
    }
  }
  console.log(n);

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


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

int main(){
  int N;  cin >> N;
  vector<int> num(N);
  int cnt = 0;
  for(int i = 0; i < N; i++){
    cin >> num.at(i);
    cnt += num.at(i);
  }
  
  int maximum = num.at(0);
  for(int j = 0; j < N-1; j++){
    if(maximum < num.at(j+1)){
      maximum = num.at(j+1);
    }
  }
  
  if(maximum < cnt - maximum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;
typedef long long LL;
const LL MOD=1e9+7;

// a x + b y = gcd(a, b)
// O(log (a+b) )
LL extgcd(LL a, LL b, LL &x, LL &y) {
  LL g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

// m????????¨??????a?????????
// O(log a)
LL invMod(LL a) {
    LL x, y;
    if (extgcd(a, MOD, x, y) == 1)return (x + MOD) % MOD;
    else    return 0; // unsolvable
}

// ??????
// O(n)
#define SZ 1000010
LL fact[SZ];
LL inv[SZ];
struct fact_{
    fact_(){
        fact[0]=1;
        inv[0]=1;
        for(int i=1;i<SZ;i++){
            fact[i]=fact[i-1]*i%MOD;
            inv[i]=invMod(fact[i]);
        }
    }
}fact_init;
    

// ???????????????nCk (mod MOD)
// O(log n)
LL Comb(LL n,LL k){
    LL u=fact[n];
    LL d=(inv[k]*inv[n-k])%MOD;
    return (u*d)%MOD;
}


LL LR[10010];
LL UD[10010];
LL mem[20030];
int main(){
    LL N,M,K;
    cin>>N>>M>>K;
    fill(LR,LR+K+10,0ll);
    fill(UD,UD+K+10,0ll);
    fill(mem,mem+2*K+20,0ll);
    LL *dp=mem+10,*nxt=mem+K+20;
    dp[0]=1;
    for(LL i=1;i<=2*K;i++){
        for(LL j=0,pos=i;j<=K&&pos>=0;j++,pos-=2){
            nxt[j]=dp[j]+dp[j-1];
            if(nxt[j]>=MOD)nxt[j]-=MOD;
            if(pos==M)
                (LR[j]+=nxt[j])%=MOD;
            if(pos==N)
                (UD[j]+=nxt[j])%=MOD;
        }
        swap(dp,nxt);
    }
    
    for(LL l=0;l<=K;l++){
        LL pos=2*K-2*l;
        for(LL ll=0;l+ll<=K;ll++){
            LL r=M-pos+ll;
            if(r>=0&&r+ll!=0)(LR[l+ll]+=dp[l]*Comb(ll+r,ll)%MOD)%=MOD;
            r=N-pos+ll;
            if(r>=0&&r+ll!=0)(UD[l+ll]+=dp[l]*Comb(ll+r,ll)%MOD)%=MOD;
        }
    }
    
        
    LL res=0;
    for(LL l=0;l<=K;l++){
        LL d=K-l;
        LL sum=LR[l]*UD[d]%MOD;
        sum*=Comb(N+M+2*K,M+2*l);
        sum%=MOD;
        res+=sum;
        res%=MOD;
    }
    cout<<res<<endl;
    return 0;
}          

Measured memory_bytes: 19172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d;
    cin>>a;
    if(a==1)
    {
        cout<<"1";
    }
    else
    {
        b=a;

        long long ct=1,bt;
       // b=floor(b/2);
        while(b!=0)
        {
            bt=2*ct;
            ct=+bt;
            b=floor(b/2);

        }
        cout<<ct-1;


    }



}


Measured memory_bytes: 256
import bisect
N=int(input())
L=sorted(list(map(int,input().split())))
count=0
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        m=bisect.bisect_left(L,L[d1]+L[d2])
        if m>d2+1:count+=m-(d2+1)
print(count)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    ll maxi=0;
    rep(i,n){
       ll h;cin>>h;
       if(h==maxi)continue;
       else if(chmax(maxi,h))maxi--;
       else{
           cout<<"No"<<endl;
           return 0;
       }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3576
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        n = (int) (Math.log10(n) / Math.log10(2));
        System.out.println((int) Math.pow(2,n));
        sc.close();
    }
}

Measured memory_bytes: 35604
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    priority_queue<pair<ll, int>> prQ;
    
    rep(i, n) {
        ll a;
        cin >> a;
        prQ.push(make_pair(a, 1));
    }

    rep(i, m) {
        int b;
        ll c;
        cin >> b >> c;
        prQ.push(make_pair(c, b));
    }

    ll ans = 0;
    rep(i, n) {
        auto x = prQ.top();
        prQ.pop();
        ans += x.first;
        x.second--;
        if(x.second >= 1) {
            prQ.push(x);
        }
    }

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

Measured memory_bytes: 6512
#include <stdio.h>

int main(void) {
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);
  //printf("y=%d, m=%d, d=%d\n", y, m ,d);

  if((y < 2019) ||
     (y == 2019 && m <= 3) ||
     (y == 2019 && m == 4 && d <= 30)) {
    printf("Heisei\n");
  } else {
    printf("TBD\n");
  }

  return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a==b && b==c){
    cout << 1 << endl;
  }
  else if(a==b || b==c || c == a){
    cout << 2 << endl;
  }
  else{
    cout << 3 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
defmodule Main do
  def main do
    [a, b] =
      IO.read(:line)
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)
 
    ans = if a < 10 and b < 10 do
    		a * b
          else
            -1
          end
    IO.puts(ans)
  end
end


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

int main() {
	while(true){
		int n,m,p;
		cin>>n>>m>>p;
		if(n==0&&m==0&&p==0)break;
		vector<int>x(n);
		for(int i=0;i<n;i++)cin>>x[i];
		int sum=0;
		for(int i=0;i<n;i++)sum+=x[i];
		if(x[m-1]==0)cout<<0<<endl;
		else cout<<sum*(100-p)/x[m-1]<<endl;	
	}
	return 0;
}


Measured memory_bytes: 3000
n=int(input())
v=list(map(int,input().split()))
v0=[]
v1=[]
m=int(n/2)
for i in range(m):
    v0.append(v[i*2])
    v1.append(v[i*2+1])
v0.sort()
v1.sort()
mv0=[0,0]
mv1=[0,0]
jmv0=[0,0]
jmv1=[0,0]
c0=[0,0]
c1=[0,0]
for i in range(m):
    if c0[0]==v0[i]:
        c0[1]+=1
    else:
        if mv0[1]<=c0[1]:
            jmv0=mv0
            mv0=c0
        elif jmv0[1]<=c0[1]:
            jmv0=c0
        c0=[v0[i],1]

    if c1[0]==v1[i]:
        c1[1]+=1
    else:
        if mv1[1]<=c1[1]:
            jmv1=mv1
            mv1=c1
        elif jmv1[1]<=c1[1]:
            jmv1=c1
        c1=[v1[i],1]

if mv0[1]<=c0[1]:
            jmv0=mv0
            mv0=c0
elif jmv0[1]<=c0[1]:
            jmv0=c0

if mv1[1]<=c1[1]:
            jmv1=mv1
            mv1=c1
elif jmv1[1]<=c1[1]:
            jmv1=c1

if mv0[0]!=mv1[0]:
    print(n-mv0[1]-mv1[1])
else:
    print(min(n-mv0[1]-jmv1[1],n-jmv0[1]-mv1[1]))

Measured memory_bytes: 14024
#include <iostream>
#include <vector>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int m;
	while(cin >> m, m)
	{
		vector<P> before(m);
		for(int i = 0; i < m; ++i)
		{
			cin >> before[i].first >> before[i].second;
		}
		int n;
		cin >> n;
		vector<P> after(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> after[i].first >> after[i].second;
		}
		for(int i = 0; i < n; ++i)
		{
			bool flag = true;
			int dx = after[i].first - before[0].first;
			int dy = after[i].second - before[0].second;
			for(int j = 0; j < m; ++j)
			{
				int x = before[j].first + dx;
				int y = before[j].second + dy;
				bool exist_flag = false;
				for(int k = 0; k < n; ++k)
				{
					if(after[k].first == x && after[k].second == y)
					{
						exist_flag = true;
						break;
					}
				}
				if(!exist_flag)
				{
					flag = false;
					break;
				}
			}
			if(flag)
			{
				cout << dx << " " << dy << endl;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1200
using System;

public class Coins
{
    public int c10 { get; set; }
    public int c50 { get; set; }
    public int c100 { get; set; }
    public int c500 { get; set; }
    public int ctotal { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var first = true;
        while (true)
        {
            var a = int.Parse(Console.ReadLine().Trim());
            if (a == 0) break;
            string[] line = Console.ReadLine().Trim().Split(' ');
            var c10 = int.Parse(line[0]);
            var c50 = int.Parse(line[1]);
            var c100 = int.Parse(line[2]);
            var c500 = int.Parse(line[3]);
            var ctotal = c10 + c50 + c100 + c500;
            var minc0 = new Coins { c10 = c10, c50 = c50, c100 = c100, c500 = c500, ctotal = ctotal };
            var w1 = new Coins();
            var minc = 999999999; var minca = new Coins(); var mincb = new Coins();
            for (int i = 0; i <= c10; i++)
                for (int j = 0; j <= c50; j++)
                    for (int k = 0; k <= c100; k++)
                        for (int L = 0; L <= c500; L++)
                        {
                            var wt = i * 10 + j * 50 + k * 100 + L * 500;
                            if (wt >= a)
                            {
                                w1.c10 = i; w1.c50 = j; w1.c100 = k; w1.c500 = L; w1.ctotal = i + j + k + L;
                                var w2 = getChenge(wt - a);
                                if (ctotal + w2.ctotal - w1.ctotal < minc)
                                {
                                    minc = ctotal + w2.ctotal - w1.ctotal;
                                    minca.c10 = w1.c10;
                                    minca.c50 = w1.c50;
                                    minca.c100 = w1.c100;
                                    minca.c500 = w1.c500;
                                    mincb.c10 = w2.c10;
                                    mincb.c50 = w2.c50;
                                    mincb.c100 = w2.c100;
                                    mincb.c500 = w2.c500;
                                }
                            }
                        }
            print(minc0, minca, mincb , first );
            if (first) first = false;
        }
    }
    public static void print(Coins c0, Coins c1, Coins c2 , bool first)
    {
        if (!first) Console.WriteLine();
        var w10 = c1.c10 - c2.c10;
        var w50 = c1.c50 - c2.c50;
        var w100 = c1.c100 - c2.c100;
        var w500 = c1.c500 - c2.c500 ;
        if (w10 >= 1) Console.WriteLine("10 {0}",w10);
        if (w50 >= 1) Console.WriteLine("50 {0}", w50);
        if (w100 >= 1) Console.WriteLine("100 {0}", w100);
        if (w500 >= 1) Console.WriteLine("500 {0}", w500);
    }
    public static Coins getChenge(int a)
    {
        var c = new Coins();
        c.c500 = a / 500;
        var a2 = a % 500;
        c.c100 = a2 / 100;
        var a3 = a2 % 100;
        c.c50 = a3 / 50;
        var a4 = a3 % 50;
        c.c10 = a4 / 10;
        c.ctotal = c.c10 + c.c50 + c.c100 + c.c500;
        return c;
    }
}



Measured memory_bytes: 9292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll fastpow(ll a,ll n){
	ll base=a;
	ll res=1;
	while(n){
		if(n&1)res*=base;
		base*=base;
		n>>1;
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll n,m,ans=0;
	cin>>n;
	ll t=log2(n);
	cout<<(ll)pow(2,t+1)-1<<endl;
	return 0;
}

Measured memory_bytes: 256
mod = 998244353
n = int(input())
l = [tuple(map(int, input().split())) for _ in range(n)] + [(10**10, 0)]
l.sort()
st = [n]
nex = [n]*n
for i in range(n-1,-1,-1):
  x,d = l[i]
  v = x + d
  while l[st[-1]][0] < v: st.pop()
  nex[i] = st[-1]
  st.append(i)
dp = [0]*(n+1)
dp[n] = 1
for i in range(n-1,-1,-1):
  dp[i] = (dp[i+1] + dp[nex[i]]) % mod
print(dp[0])

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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        r: u32
    }
    println!("{}", 3 * r * r);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cmath>

double x[3],y[3];
struct line{
	double gr,in;
	int f;
	line(){}
	line(double gradient,double intercept,int flag){
		gr=gradient;
		in=intercept;
		f=flag;
	}
};

struct point{
	double x,y;
	point(){}
	point(double xx,double yy){
		x=xx;
		y=yy;
	}
};

line make_line(int i,int j){
	if(x[i]==x[j])return line(0,x[i],1);
	double gr=(y[j]-y[i])/(x[j]-x[i]);
	double in=y[i]-x[i]*gr;
	return line(gr,in,0);
}

point cross(line l,int j){
	line l2;
	l2.gr=-1.0/l.gr;
	l2.in=y[j]-x[j]*l2.gr;
	point p;
	p.x=(l2.in-l.in)/(l.gr-l2.gr);
	p.y=l.gr*p.x+l.in;
	return p;
}

point symmetry(line l,int v){
	if(l.f==1)return point(-x[v]+l.in+l.in,y[v]);
	if(l.gr==0)return point(x[v],-y[v]+l.in+l.in);
	point p=cross(l,v);
	return point(p.x+p.x-x[v],p.y+p.y-y[v]);
}

int main(void){
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2])){
		line l1=make_line(0,1);
		point p=symmetry(l1,2);
		printf("%.6f %.6f\n",p.x,p.y);
	}

	return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define bpc __builtin_popcount
#define MOD (ll)(1e9+7)
#define INF (2e9)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL_AND_ELECTRIC true
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL_AND_ELECTRIC);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[3010][3010];
char src[3010][3010];

int32_t main() {
	INIT();
	//code...
	string s,t; cin>>s>>t;
	For(i,0,sz(s)-1) For(j,0,sz(t)-1){
		if(s[i]==t[j]){
			if(i==0 || j==0) dp[i][j]=1;
			else dp[i][j]=dp[i-1][j-1]+1;
		}else if(i==0 && j==0){
			dp[i][j]=0;
		}else if(i==0){
			src[i][j]='L';
			dp[i][j]=dp[i][j-1];
		}else if(j==0){
			src[i][j]='U';
			dp[i][j]=dp[i-1][j];
		}else{
			if(dp[i-1][j]>dp[i][j-1]){
				src[i][j]='U';
				dp[i][j]=dp[i-1][j];
			}else{
				src[i][j]='L';
				dp[i][j]=dp[i][j-1];
			}
		}
	}
	int a=sz(s)-1,b=sz(t)-1;
	string ans;
	while(a>=0 && b>=0){
		if(s[a]==t[b]){
			ans=s[a]+ans;
			a--; b--;
		}else if(src[a][b]=='L'){
			b--;
		}else{
			a--;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 82996
#include <stdio.h>
#include <math.h>
typedef long long LL;

int judge(LL n, int x)
{
	do{
		n /= x;
	}while(n % x == 0);
	return n % x == 1;
}

int main()
{		
	LL n, tn;
	int ans = 1, i, k, x, s;
	
	scanf("%lld", &n);
	for(i = 2, k = sqrt(tn = n - 1); i <= k; i++){
		if(tn % i == 0){
			x = 1;
			do{
				tn /= i;
				x++;
			}while(tn % i == 0);
			ans *= x;
			k = sqrt(tn);
		}
	}
	if(tn > 1) ans <<= 1;
	
	for(i = 2, k = sqrt(tn = n); i <= k; i++){
		if(n % i == 0) ans += judge(n, i);
	}
	printf("%d\n", ans);
			
	return 0;
}

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

int main(){
    int n;cin>>n;
    vector<int> a(n),b(n),c(n-1);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>c[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
        if(i!=0&&((a[i-1]+1)==a[i])){
            ans+=c[a[i]-2];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#ABC070C
import math
from functools import reduce
N=int(input())
T=[int(input()) for i in range(N)]
#def lcm_base(x, y):
#    interium=x//math.gcd(x, y)
#    return (interium*y)
#print(reduce(lcm_base, T))
ans=1
def grcode(x, y):
    if y==0:
        return (x)
    else:
        return grcode(y, x%y)
for i in range(N-1):
    T[i]=T[i]//grcode(T[i],T[i+1])
    T[i+1]=T[i]*T[i+1]
print(T[N-1])

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll N,K;
  cin >> N >> K;
  if(N < K){
    cout << 0 << endl;
    return 0;
  }
  vector<ll> H(N);
  rep(i,N){
    cin >> H.at(i);
  }
  sort(H.begin(),H.end());
  ll ans = 0;
  rep(i,N-K){
    ans += H.at(i);
  }
  cout << ans << endl;
  return 0;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int x;
	cin >> x;
	for (int i = 1; true; i++) {
		int val = i * 360;
		if (val % x == 0) {
			cout << val / x << endl;
			return 0;
		}
	}

	return 0;
}

//!

Measured memory_bytes: 3644
let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let kss =
    Array.init m @@ fun _ ->
      Scanf.scanf "%d " @@ fun k ->
        Array.init k @@ fun _ -> Scanf.scanf "%d " @@ fun s -> s in
  let ps = Array.init m @@ fun _ -> Scanf.scanf "%d " @@ fun p -> p in
  Array.make n [true; false]
  |> Array.fold_left (fun candidates bs ->
      List.concat @@ List.map (fun b ->
        List.map (fun bs -> b :: bs) candidates) bs) [[]]
  |> List.filter (fun bs ->
      let bs' = Array.of_list bs in
      Array.fold_left ( && ) true @@
      Array.init m @@ fun i ->
        ( = ) (ps.(i) land 1) @@
        Array.fold_left (fun acc b ->
          acc lxor if bs'.(b - 1) then 1 else 0) 0 kss.(i))
  |> List.length
  |> Printf.printf "%d\n"

Measured memory_bytes: 4480
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define all(v) v.begin(),v.end()
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    double t,r=1,r1=0,r2=0,k=0,a,b,c,m,d=0,n,e,f,x,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4,s5;
    cin>>n;
    a=n/3.0;
    b=n/3.0;
    c=n-(a+b);
     x=a*b*c;
cout<<setprecision(12)<<fixed<<x<<endl;
}





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

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

bool dp[100010];

int main() {
    string S; cin >> S;
    string divide[4] = {"dream","dreamer","erase","eraser"};
    dp[0] = 1;
    rep(i,S.size()){
        if(!dp[i]) continue;
        for(int j = 0; j < 4; j++){
            string d = divide[j];
            if(S.substr(i,d.size()) == d){
                dp[i + d.size()] = 1;
            }
        }
    }
    cout << (dp[S.size()] ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

  int64_t N, M;
  cin >> N >> M;

  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());

  auto compare = [](pair<int64_t, int64_t> b, pair<int64_t, int64_t> c) {
    return b.second < c.second;
  };

  priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>,
                 decltype(compare)>
      BC{compare};

  for (int64_t i = 0; i < M; i++) {
    int64_t tmp_b, tmp_c;
    cin >> tmp_b >> tmp_c;
    BC.push(make_pair(tmp_b, tmp_c));
  }

  int64_t sum = 0;
  int64_t c_pos = 0;
  while (BC.size() > 0) {
    auto tmp = BC.top();
    BC.pop();
    for (int64_t i = 0; i < tmp.first and c_pos < A.size(); i++) {
      if (A.at(c_pos) < tmp.second) {
        A.at(c_pos) = tmp.second;
        c_pos++; 
      } else {
        break; 
      }
    }
  }
  for (int64_t i = 0; i < A.size(); i++) {
    sum += A.at(i);
  }

  cout << sum;

  return 0;
}


Measured memory_bytes: 6128
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

int H, W, K;
int result;

void process(vector<vector<int>> map_info, int row_cnt, int row_start, int col_cnt, int col_start)
{
	if (row_cnt > 0)
	{
		for (int i = row_start; i < H; i++)
		{
			vector<vector<int>> new_map_info = map_info;
			for (int j = 0; j < W; j++)
			{
				new_map_info[i][j] = 0;
			}
			process(new_map_info, row_cnt - 1, i + 1, col_cnt, col_start);
		}
	}
	else if (col_cnt > 0)
	{
		for (int i = col_start; i < W; i++)
		{
			vector<vector<int>> new_map_info = map_info;
			for (int j = 0; j < H; j++)
			{
				new_map_info[j][i] = 0;
			}
			process(new_map_info, row_cnt, row_start, col_cnt - 1, i + 1);
		}
	}
	else
	{
		int total_cnt = 0;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				total_cnt += map_info[i][j];
			}
		}

		if (K == total_cnt)
		{
			result++;
		}
	}
}

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

	cin >> H >> W >> K;

	vector<vector<int>> map_info(H, vector<int>(W, 0));

	int total_cnt = 0;
	for (int i = 0; i < H; i++)
	{
		string line;
		cin >> line;

		for (int j = 0; j < W; j++)
		{
			if (line[j] == '#')
			{
				map_info[i][j] = 1;
				total_cnt++;
			}
		}
	}

	process(map_info, 0, 0, 0, 0);
	for (int i = 1; i <= H; i++)
	{
		process(map_info, i, 0, 0, 0);
	}

	for (int i = 1; i <= W; i++)
	{
		process(map_info, 0, 0, i, 0);
	}

	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			process(map_info, i, 0, j, 0);
		}
	}

	cout << result;
	
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)


int main()
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << fixed  << W * H / 2. << " " << (2 * x == W && 2 * y == H )<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000

struct Node{
	int parent;
	int left;
	int right;
};

struct Node T[MAX];
int n;


void preParse(int u){
	if( u==-1 ){ return; }
	printf(" %d", u);
	preParse(T[u].left);
	preParse(T[u].right);
}

void inParse(int u){
	if( u==-1 ){ return; }
	inParse(T[u].left);
	printf(" %d", u);
	inParse(T[u].right);
}

void postParse(int u){
	if( u==-1 ){ return; }
	postParse(T[u].left);
	postParse(T[u].right);
	printf(" %d", u);
}

int main(void){
	int i, num, left, right, root;
	
	scanf("%d", &n);
	for(i=0; i<n; i++){
		T[i].parent = -1;
	}
	
	for(i=0; i<n; i++){
		scanf("%d %d %d", &num, &left, &right);
		T[num].left = left;
		T[num].right = right;
		if( left != -1 ){ T[left].parent = num; }
		if( right != -1 ){ T[ right].parent = num; }
	}
	
	for(i=0; i<n; i++){
		if( T[i].parent == -1 ){ root = i; }
	}
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
}



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

const int INF = 1e9 + 7;

map<tuple<int, char, char, char>, long long> dp;

long long dfs(int n, char b1, char b2, char b3)
{
	if (n == 0) return 1;
	auto status = make_tuple(n, b1, b2, b3);
	if (dp.count(status)) return dp[status];
	static string str = "ACGT";
	long long res = 0;
	for(auto&& c : str)
	{
		if(c == 'C')
		{
			if (b1 == 'G' && (b2 == 'A' || b3 == 'A')) continue;
			if (b1 == 'A' && b2 == 'G') continue;
			if (b3 == 'A' && b2 == 'G') continue;
			res += dfs(n - 1, c, b1, b2);
			res %= INF;
		}
		else if(c == 'G')
		{
			if (b1 == 'C' && b2 == 'A') continue;
			res += dfs(n - 1, c, b1, b2);
			res %= INF;
		}
		else
		{
			res += dfs(n - 1, c, b1, b2);
			res %= INF;
		}
	}
	return dp[status] = res;
}

int main()
{
	int n;
	cin >> n;
	cout << dfs(n, 'D', 'D', 'D') << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds; 
using namespace std;



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
 
//defines
typedef long long ll;
typedef long double ld;
ll n,m,k,tar,a,b,d,e;
map<ll,ll>ff;


void solve()
{
   string s;cin>>s;
   for(ll i=0;i<s.size();i++)
   {
       if(s[i]=='?')s[i]='D';
   }
   cout<<s;
   return ;
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   
        solve();
    
        
    return 0;
}


Measured memory_bytes: 3768
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc131_b

n, l = map(int, input().strip().split())
res = n * (2 * l + n - 1) / 2
if l > 0:
    res -= l
elif l + n - 1 < 0:
    res -=  l + n - 1
print(int(res))



Measured memory_bytes: 9096
#include<iostream>
using namespace std;
 
int main(){
  int r, d, x, ans[100];
  cin >> r >> d >> x;
  for(int i = 0;i < 10;i++){
    if(i == 0){
    ans[0] = x * r - d;
    }
    else{
      ans[i] = ans[i - 1] * r - d;
    }
    cout << ans[i] <<endl;
  }
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int a[100005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	int count = 0;
	long long int sum = 0;
	long long int min = 2000000009;
	for (i = 0; i < n; i++)
	{
		if (a[i] < 0)
		{
			count++;
			a[i] *= -1;
		}
		sum += a[i];
		if (min > a[i])
			min = a[i];
	}
	if (count % 2 == 0)
		printf("%lld\n", sum);
	else
		printf("%lld\n", sum - 2 * min);
	return 0;
}


Measured memory_bytes: 896
use std::io;
use std::io::{stdout, Write};

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn input_vector<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let s = input_line_str();
        let split_result = s.split_whitespace();
        let mut vec_line: Vec<T> = Vec::new();
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            vec_line.push(buf);
        }
        v.push(vec_line);
    }
    v
}

fn main() {
    let h: usize;
    let w: usize;
    let mut v: Vec<Vec<char>> = Vec::new();
    input!(h, w);

    for i in 0..h {
        let s = input_line_str();
        let mut vr: Vec<char> = Vec::new();
        for z in s.chars() {
            if z == '#' {
                vr.push('#');
            } else {
                vr.push('.');
            }
        }
        v.push(vr);
    }

    for i in 0..h {
        let f = checkwhitey(&v, 0, i, h, w);
        if f {
            for j in 0..w {
                v[i][j] = '0';
            }
        }
    }
    for i in 0..w {
        let f = checkwhitex(&v, i, 0, h, w);
        if f {
            for j in 0..h {
                v[j][i] = '0';
            }
        }
    }

    for i in v {
        let mut flag = true;
        for j in i {
            if j != '0' {
                flag = false;
                write!(io::stdout(), "{}", j);
            }
        }
        if !flag {
            println!("");
        }
    }
}

fn checkwhitex(v: &Vec<Vec<char>>, x: usize, y: usize, h: usize, w: usize) -> bool {
    if y >= h || x >= w {
        return true;
    }

    if v[y][x] == '#' {
        return false;
    }

    checkwhitex(v, x, y + 1, h, w)
}

fn checkwhitey(v: &Vec<Vec<char>>, x: usize, y: usize, h: usize, w: usize) -> bool {
    if y >= h || x >= w {
        return true;
    }

    if v[y][x] == '#' {
        return false;
    }

    checkwhitey(v, x + 1, y, h, w)
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	vll h(n);
	rep(i, n) cin>>h[i];
	ll ans=0, cnt=0;
	rep(i, n-1){
		if (h[i]>=h[i+1]){
			cnt++;
		}else{
			ans = max(ans, cnt);
			cnt=0;
		}
	}
	ans = max(ans, cnt);

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
 
using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;
constexpr ll MOD = 1000000007;

// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

ll pow2(ll n) {
  if (n == 0) return 1;
  else if ((n%2) == 1) return (2 * pow2(n-1)) % MOD;
  else {
    ll h = pow2(n/2);
    return h * h % MOD;
  }
}

ll calc(ll n) {
  ll p2 = pow2(n);
  ll pi2 = inv(p2, MOD);
  return (p2 + MOD - 1) * pi2 % MOD;
}

ll solve(const vector<vecint>& t, vecll& ex, int i, int p) {
  vecll cp;
  ll cntc = 0;
  for(int j:t[i]) {
    if(j==p) continue;
    ll cs = solve(t,ex,j,i);
    cp.push_back(calc(cs));
    cntc += cs;
  }
  cp.push_back(calc(t.size() - cntc - 1));
  vecll fwd;
  vecll bwd;
  ll imul = 1;
  for(auto&& e:cp) {
    fwd.push_back(imul);
    imul *= (1 + (MOD - e)) % MOD;
    imul %= MOD;
  }
  boost::reverse(cp);
  imul = 1;
  for(auto&& e:cp) {
    bwd.push_back(imul);
    imul *= (1 + (MOD - e)) % MOD;
    imul %= MOD;
  }
  boost::reverse(cp);
  boost::reverse(bwd);
  ll ans = 1 + (MOD - imul);
  ans %= MOD;
  for(auto&& j:irange(0ul,cp.size())) {
    ll tmp = fwd[j] * bwd[j];
    tmp %= MOD;
    tmp *= cp[j];
    tmp %= MOD;
    ans += (MOD - tmp) % MOD;
    ans %= MOD;
  }
  ans *= inv(2, MOD);
  ans %= MOD;
  ex[i] = ans;
  return cntc + 1;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  vector<vecint> t(n);
  for(auto&& i:irange(0l,n-1)) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  vecll ex(n, 0);
  solve(t, ex, 0, -1);
  ll ans = 0;
  for(auto&& e : ex) {
    ans += e;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}


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

int K;
int cost[100001];

int main(){
  cin >> K;

  for(int i = 0; i <= 100000; i++){
    cost[i] = 200000;
  }

  deque<int> deq;
  cost[1] = 1;
  deq.push_back(1);

  while(deq.front() != 0){
    int now = deq.front(); deq.pop_front();
    if(cost[(now * 10) % K] > cost[now]){
      deq.push_front((now * 10) % K);
      cost[(now * 10) % K] = cost[now];
    }
    if(cost[(now + 1) % K] > cost[now] + 1){
      deq.push_back((now + 1) % K);
      cost[(now + 1) % K] = cost[now] + 1;
    }
  }
  cout << cost[0] << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int a, b, c;
	cin >> a >> b >> c;

	if (c >= a &&
		c <= b)
		cout << "Yes";
	else
		cout << "No";

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
class UnionFind{
  public:
    vector<int> par;
    vector<int> siz;

  UnionFind(int n){
    siz=vector<int>(n,1);
    par=vector<int>(n,-1);
  }

  int root(int x){
    if(par[x]==-1){
      return x; //根
    }else{
      return par[x]=root(par[x]); //経路圧縮
    }
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }

  void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return;
    if(siz[y]<siz[x])swap(x,y);
    siz[y]+=siz[x];
    par[x]=y;
  }
  int size(int x){
    return siz[x];
  }
};
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n,k,l;
  cin >> n >> k >> l;
  vector<int> p(k),q(k),r(l),s(l);
  rep(i,k){
    cin >> p[i] >> q[i];
    p[i]--; q[i]--;
  }
  rep(i,l){
    cin >> r[i] >> s[i];
    r[i]--; s[i]--;
  }
  UnionFind u1(n),u2(n);
  rep(i,k){
    u1.unite(p[i],q[i]);
  }
  rep(i,l){
    u2.unite(r[i],s[i]);
  }
  map<pair<int,int>,int> mp;
  rep(i,n){
    mp[{u1.root(i),u2.root(i)}]++;
  }
  rep(i,n){
    cout << mp[{u1.root(i),u2.root(i)}] << endl;
  }
}


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

const double PI=3.141592653589;

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

  cout << 2 * r * PI << endl;

  return 0;
}


Measured memory_bytes: 3784
const lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    a,b,c=intLine()
    println(min(c,Int(floor(b/a))))
end
main()

Measured memory_bytes: 115452
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, ans = 1;
    cin>>n;
    int a[n+3];
    f(i,n)cin>>a[i];
    int mn = a[0];
    for(int i = 1; i < n; i++){
        if(mn > a[i])ans++;
        mn = min(mn,a[i]);
    }
    cout<<ans;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 1792
S = input()
T = input()
q = int(input())
A = [list(map(int, input().split())) for _ in range(q)]

count_s = [{"A": 0, "B":0} for i in range(len(S))]
count_t = [{"A": 0, "B":0} for i in range(len(T))]

for i in range(len(S)):
  if(S[i] == "A"):
    count_s[i]["A"] += 1
    if(i == len(S) -1):
      break
    count_s[i+1] = count_s[i].copy()
  else:
    count_s[i]["B"] += 1
    if(i == len(S) -1):
      break
    count_s[i+1] = count_s[i].copy()


for i in range(len(T)):
  if(T[i] == "A"):
    count_t[i]["A"] += 1
    if(i == len(T) -1):
      break
    count_t[i+1] = count_t[i].copy()
  else:
    count_t[i]["B"] += 1
    if(i == len(T) -1):
      break
    count_t[i+1] = count_t[i].copy()


for i in range(q):
  if(S[A[i][0] - 1] == "A"):
    count_S = {"A": count_s[A[i][1] - 1]["A"] - count_s[A[i][0] - 1]["A"] + 1, "B": count_s[A[i][1] - 1]["B"] - count_s[A[i][0] -1]["B"]}
  else:
    count_S = {"A": count_s[A[i][1] - 1]["A"] - count_s[A[i][0] - 1]["A"], "B": count_s[A[i][1] - 1]["B"] - count_s[A[i][0] -1]["B"] + 1}
  if(T[A[i][2] - 1] == "A"):
    count_T = {"A": count_t[A[i][3] - 1]["A"] - count_t[A[i][2] - 1]["A"] + 1, "B": count_t[A[i][3] - 1]["B"] - count_t[A[i][2] - 1]["B"]}
  else:
    count_T = {"A": count_t[A[i][3] - 1]["A"] - count_t[A[i][2] - 1]["A"], "B": count_t[A[i][3] - 1]["B"] - count_t[A[i][2] - 1]["B"] + 1}

  if(count_S["A"] - count_T["A"] > 0):
    tmp = count_S["A"] - count_T["A"] - (count_S["B"] - count_T["B"])
    if(tmp % 3 == 0):
      print("YES")
    else:
      print("NO")

  else:
    tmp = count_T["A"] - count_S["A"] - (count_T["B"] - count_S["B"])
    if(tmp % 3 == 0):
      print("YES")
    else:
      print("NO")

Measured memory_bytes: 102280
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin >> a >> b;
	int mn = (int)1e9;
	for(int x = 1;x <= (int)2e6 + 100;x++){
		int a1 = (x * 8) / 100;
		int b1 = x / 10;
		if(a1 == a && b1 == b)mn = min(mn, x);
	}
	if(mn == (int)1e9)cout << -1; else
	cout << mn;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

min_cost = 40000000
target = 0
for i in range(-100, 101):
    sum_cost = 0
    for a in A:
        num = a-i
        sum_cost += num*num
    if sum_cost < min_cost:
        target = i
        min_cost = sum_cost
print(min_cost)


Measured memory_bytes: 2940
//ポイント:P > max, はじめからかこえるだけかこっていくというやり方が理想の切り方
#include <cstdio>
#include <iostream>
#include <cmath>
#define MAX_LUGGAGE 100000//最大の荷物の数
#define MAX_truck 100000//最大のトラックの数
#define MAX_WEIGHT 10000//荷物の最大重量
#define ZERO 0

using namespace std;

int l_num;//number of luggage
int t_num;//num of truck
int luggage_array[MAX_LUGGAGE+1];//荷物の重量を保管する配列
int luggage_set[MAX_LUGGAGE+1];

int main(){
	int max = ZERO;//最大重量の荷物の重量
	int tmp_sum = 0;
	int P;
	int sum = 0;
	scanf("%d",&l_num);
	scanf("%d",&t_num);

	for(int i = 0;i < l_num;i++) scanf("%d",&luggage_array[i]);
	for(int i = 0;i < l_num;i++){
		if(luggage_array[i] > max) max = luggage_array[i];
		sum += luggage_array[i];
	}

	if(sum/t_num > max) P = sum/t_num;
	else P =max;
	for(;;P++){
		int t_tmp = 1;
		for(int i = 0;i < l_num;i++){
			tmp_sum += luggage_array[i];
			if(tmp_sum > P){
				t_tmp++;
				tmp_sum = luggage_array[i];
			}
		}
		tmp_sum = 0;
		if(t_tmp <= t_num) break;
	}

	cout <<P <<endl;
	return 0;
}

Measured memory_bytes: 1604
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
P<int, int> p[3];
double t[3];
double f(P<int, int> a, P<int, int> b, P<int, int> c){
  b.fi -= a.fi; b.se -= a.se;
  c.fi -= a.fi; c.se -= a.se;
  double bb = b.fi*b.fi+b.se*b.se;
  double cc = c.fi*c.fi+c.se*c.se;
  double t = double(abs(b.fi*c.se-b.se*c.fi))/sqrt(bb)/sqrt(cc);
  t = asin(t);
  return 1.0/tan(t/2);
}
double g(P<int, int> A, P<int, int> B, P<int, int> C){
  double b=f(B, C, A), c=f(C, A, B), d=sqrt((B.fi-C.fi)*(B.fi-C.fi)+(B.se-C.se)*(B.se-C.se));
  return d/(b+c+2);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double ans=0;
  FOR(i, 0, 3) cin >> p[i].fi >> p[i].se;
  FOR(i, 0, 3) maxs(ans, g(p[i], p[(i+1)%3], p[(i+2)%3]));
  printf("%.12f\n", ans);
}

Measured memory_bytes: 256