akhauriyash/Code-Regression huggingface dataset:
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> v = {100, 101, 102, 103, 104, 105};
    for(int i = 0; i <= n / v[0]; i++){
        for(int j = 0; j <= n / v[1]; j++){
            for(int k = 0; k <= n / v[2]; k++){
                for(int l = 0; l <= n / v[3]; l++){
                    for(int m = 0; m <= n / v[4]; m++){
                        for(int p = 0; p <= n / v[5]; p++){
                            int x = i * v[0] + j * v[1] + k * v[2] + l * v[3] + m * v[4] + p * v[5];
                            if(x == n){
                                cout << 1;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << 0;
    return 0;
}
/*
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

int main(){
    int n, a[30], b[30], c[30];
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];

    int ans = 0;

    rep(i, n) {
        ans += b[a[i]-1];
        if (i > 0) {
            if (a[i] == a[i-1] + 1) {
                ans += c[a[i-1]-1];
            }      
        }
    }

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

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

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

typedef long long ll;

int main(int argc, char const *argv[]) {
    int R;
    scanf("%d",&R);
    if(R<1200){
        printf("ABC");
    }else if(R<2800){
        printf("ARC");
    }else{
        printf("AGC");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
    char suit, value; 
} Card;

void bubbleSort(Card a[], int n);
void selectionSort(Card a[], int n);
void print(Card a[], int n);
void strCastCard(Card *t,char str[]);
int checkStable(Card c1[], Card c2[], int n);

int main(void) {
  Card c1[100], c2[100];
  int n, i;
  char str[3];

  scanf("%d", &n);
  for(i=0; i < n; i++) {
    scanf("%s", str);
    strCastCard(&c1[i], str);
  }

  for(i = 0; i < n; i++) c2[i] = c1[i];

  bubbleSort(c1, n);
  selectionSort(c2, n);

  print(c1, n);
  printf("Stable\n");
  print(c2, n);
  if(checkStable(c1, c2, n)) {
    printf("Stable\n");
  }
  else {
    printf("Not stable\n");
  }

  return 0;
}


void bubbleSort(Card a[], int n) {
  int i,j;
  Card t;

  for(i = 0; i < n; i++) {
    for(j = n-1; j >= i; j--) {
      if(a[j].value < a[j-1].value) {
        t = a[j];
        a[j] = a[j-1];
        a[j-1] = t;
      }
    }
  }
}

void selectionSort(Card a[], int n) {
  int i, j, minj;
  Card t;

  for(i = 0; i < n; i++) {
    minj = i;
    for(j = i; j < n; j++) {
      if(a[j].value < a[minj].value) minj = j;
    }
    t = a[i];
    a[i] = a[minj];
    a[minj] = t;
  }
  return;
}

void print(Card a[], int n) {
  int i;

  for(i = 0; i < n; i++) {
    if(i > 0) printf(" ");
    printf("%c%d", a[i].suit, a[i].value);
  }
  printf("\n");
  return;
}

void strCastCard(Card *t, char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
    return;
}

int checkStable(Card c1[], Card c2[], int n) {
  int i;

  for(i = 0; i < n; i++) {
    if(c1[i].suit != c2[i].suit) return 0;
  }
  return 1;
}


Measured memory_bytes: 2076
#include<iostream>
#include <iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

ll n,h[100010],g[100010],a,b;

bool can(ll x){
    ll s=a-b,cnt=0;
    rep(i,n){
        g[i]=h[i];
        g[i]-=b*x;
        if(g[i]>0){
            cnt+=g[i]/s+bool(g[i]%s);
        }
    }
    if(cnt<=x) return true;
    else return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    rep(i,n)cin>>h[i];
    sort(h,h+n);
    ll M=h[n-1]/b+bool(h[n-1]%b),m=0; 
    while(M>m){
        ll mid=(M+m)/2;
        if(can(mid)) M=mid;
        else m=mid+1;
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<utility>

using namespace std;
int n, array[1000000] = {0}, s, ptr, size = 1;

void Sort()
{
  int i, j;
  for(int i = 1; i < size; i++){
    j = i;
    while(j >= 1 && array[j - 1] > array[j]){
      swap(array[j - 1], array[j]);
      j--;
    }
  }  
}

bool Search(int left, int right, int x)
{
    int center = (left + right) / 2;
    if(left >= right)
      return false;

    if(x == array[center])
      return true;
    else if(x < array[center])
      Search(left, center, x);
    else
      Search(center + 1, right, x);
}

int main()
{
  cin >> s;
  array[0] = s;
  while(true){
    if(s % 2 == 0){
      n = s / 2;
      if(Search(0, size, n))
        break;
      else{
        array[size++] = n;
        Sort();
        s = n;
      }
    }else{
      n = 3 * s + 1;
      if(Search(0, size, n))
        break;
      else{
        array[size++] = n;
        Sort();
        s = n;
      }
    }
  }

  cout << size + 1 << endl;

  return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define pi std::pair<int, int>
#define mkp std::make_pair
#define ll long long
#define pb push_back
#define fi first
#define se second

//{{{IO
namespace IO{
	template <class I> void read(I &x){
		x = 0; char ch = getchar(); bool f = false;
		for(; !isdigit(ch); ch = getchar()) f |= (ch == '-');
		for(; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + ch - '0';
		return ;
	}

	int read_int(){ int x; return read(x), x;}
	ll read_ll(){ ll x; return read(x), x;}
	template <class I>
		void chmax(I &x, I y){x = x > y ? x : y;}
	template <class I>
		void chmin(I &x, I y){x = x < y ? x : y;}
#define ri read_int()
#define rl read_ll()
}
using IO::read_int;
using IO::read_ll;
using IO::chmax;
using IO::chmin;
//}}}

//{{{Mod
namespace Mod{
//	const int mod = 1e9 + 7;
//	const int mod = 1004535809;
	const int mod = 998244353;
	
	inline void MOD(int &x){ x -= x >= mod ? mod : 0;}
	inline void add(int &x, int y){ x = x + y >= mod ? x + y - mod : x + y;}
	inline int Add(int x, int y){ return x + y >= mod ? x + y - mod : x + y;}
	inline void mul(int &x,  int y){ x = 1ll * x * y % mod;}
	inline int Mul(int x, int y){ return 1ll * x * y % mod;}
}
//}}}

#define N 2003

int n, m, top;
int st[N], fa[N][12], dep[N], lca[N][N];

std::queue<pi> Q;
std::vector<int> e[N];
std::bitset<N> p[N], s[N], g[N], all;

void dfs(int u, int f){
	st[++top] = u; fa[u][0] = f; dep[u] = dep[f] + 1;
	for(int i = 1; i <= 11; ++i)
		fa[u][i] = fa[fa[u][i - 1]][i - 1];
	for(int i = 1; i <= top; ++i)
		s[st[i]].set(u), p[u].set(st[i]);
	for(auto v : e[u])
		if(v != f)
			dfs(v, u);
	--top;
	return ;
}

int get_lca(int x, int y){
	if(dep[x] < dep[y]) std::swap(x, y);
	for(int i = 11; ~i; --i)
		if(dep[fa[x][i]] >= dep[y])
			x = fa[x][i];
	if(x == y) return x;
	for(int i = 11; ~i; --i)
		if(fa[x][i] != fa[y][i])
			x = fa[x][i], y = fa[y][i];
	return fa[x][0];
}

int jump(int u, int k){
	for(int i = 11; ~i; --i)
		if(k & (1 << i)) 
			u = fa[u][i];
	return u;
}

int main(){
	n = ri, m = ri;
	for(int i = 2; i <= n; ++i){
		int u = ri, v = ri;
		e[u].pb(v), e[v].pb(u);
	}
	dfs(1, 0);
	for(int i = 1; i <= n; ++i)
		all.set(i);
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n; ++j)
			lca[i][j] = lca[j][i] = get_lca(i, j);
	for(int i = 1; i <= m; ++i){
		int u = ri, v = ri;
		g[u].set(v); g[v].set(u);
		Q.push(mkp(u, v));
	}
	while(!Q.empty()){
		pi tmp = Q.front(); Q.pop();
		int u = tmp.fi, v = tmp.se;
		if(dep[u] > dep[v]) std::swap(u, v);
		std::bitset<N> x = g[u] ^ g[v], y = (p[u] ^ p[v]) | s[v];
		if(lca[u][v] == u)
			y |= all ^ s[jump(v, dep[v] - dep[u] - 1)];
		else
			y |= s[u];
		y.set(lca[u][v]); x &= y;
		for(int p = x._Find_first(); p <= n; p = x._Find_next(p)){
			if(p == u || p == v) continue;
			if(g[u].test(p)){
				g[v].set(p); g[p].set(v);
				++m; Q.push(mkp(v, p));
			} else{
				g[u].set(p); g[p].set(u);
				++m; Q.push(mkp(u, p));
			}
		}
	}
	printf("%d\n", m);
	return 0;
}


Measured memory_bytes: 34100
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	for(int i = 1; i <= 100000; i++){
		if((i * 108) / 100 == n){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll N;

ll qsm(ll x,ll y)
{
	ll ans=1;
	while(y)
	{
		if(y&1) ans=ans*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}
	return ans;
}

int main()
{
	ios;
	cin>>N;
	cout<<((qsm(10,N)-2*qsm(9,N)+qsm(8,N))%MOD+MOD)%MOD<<"\n";
	return 0;
}

Measured memory_bytes: 3616
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define VECV(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int S,W;
  cin>>S>>W;
  if(S<=W)
    cout<<"unsafe"<<endl;
  else
    cout<<"safe"<<endl;

}

Measured memory_bytes: 3640
N, M = map(int, input().split())
PY = [[i]+list(map(int, input().split())) for i in range(M)]

PY = sorted(PY, key=lambda x: (x[1], x[2]))
cur = [0 for _ in range(N)]
ans_list = []
for i in range(M):
    ans = '0'*(6-len(str(PY[i][1]))) + str(PY[i][1])
    cur[PY[i][1]-1] += 1
    ans += '0'*(6-len(str(cur[PY[i][1]-1]))) + str(cur[PY[i][1]-1])
    ans_list.append([PY[i][0], ans])

ans_list = sorted(ans_list, key=lambda x: x[0])
for i, v in enumerate(ans_list):
    print(v[1])


Measured memory_bytes: 106200
#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  bool ans = true;
  for (int i = 0; i < s.size(); i++) {
    string s1 = "RUD", s2 = "LUD";
    if ((i % 2 == 1 && s2.find(s[i]) == string::npos) ||
        (i % 2 == 0 && s1.find(s[i]) == string::npos)) {
      ans = false;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void)
{
	int h[300];
	int w[300];
	int i = -1, j, k, l;
	do{
		i++;
		scanf("%d%d", &h[i], &w[i]);
	} while (h[i] != 0 || w[i] != 0);
	for (j = 0; j <= i; j++){
		for (l = 0; l < h[j]; l++){
			for (k = 0; k < w[j]; k++) {
				if (l % 2 == 1 && k % 2 == 1)printf("#");
				else if (l % 2 == 0 && k % 2 == 0)printf("#");
				else printf(".");
			}
			printf("\n");
		}
		if (j != i)printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1740
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	string s;

	cin >> s;
	
	for (int i = 0; i < 4; ++i) {
		cout << s[i];
	}
	cout << " ";
	for (int i = 0; i < 8; ++i) {
		cout << s[i + 4];
	}
	cout << endl;
}


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

int main(void)
{
    int a,b;
    cin >> a >> b;

    if( (a * b) % 2 == 0  ){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }

    return 0;
}

Measured memory_bytes: 3552
import java.util.*;

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();
		int max = n / 3;
		int p1 = 0;
		int p2 = 0;
		int p3 = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if (x <= a) {
				p1++;
			} else if (x <= b) {
				p2++;
			} else {
				p3++;
			}
		}
		max = Math.min(p1, max);
		max = Math.min(p2, max);
		max = Math.min(p3, max);
		System.out.println(max);
	}
}


Measured memory_bytes: 21844
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,ans,i,j,x,y,k;
vector<int>a[2001];
int dfs(int x,int p,int d)
{
	int sum=1;
	if(d!=k/2)for(int i=0;i<a[x].size();i++)if(a[x][i]!=p)sum+=dfs(a[x][i],x,d+1);
	return sum;
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>k;
	for(i=1;i<n;i++)	
	{
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	if(!(k&1))for(i=1;i<=n;i++)ans=max(ans,dfs(i,-1,0));
	else for(i=1;i<=n;i++)for(j=0;j<a[i].size();j++)ans=max(ans,dfs(i,a[i][j],0)+dfs(a[i][j],i,0));
	cout<<n-ans<<endl;
    return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    ll ans = 0;
    rep(i,h)rep(j,w){
        ll a;
        cin >>a;

        ll L = (i+1)*(j+1);
        ll R = (h-i)*(w-j);
        ans += L*R*a;
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int a[4],res;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    res+=a[3]-a[2];
    a[1]+=res;
    //cout<<res<<" "<<a[1]<<endl;
    res += (a[3]-a[1]+1)/2 + ((a[3]-a[1])%2);
    cout<<res;
}


Measured memory_bytes: 256
from operator import itemgetter

N = int(input())
xyh = [[int(i) for i in input().split()] for _ in range(N)]

xyh.sort(key = itemgetter(2))
tx, ty, th = xyh[-1]
for Cx in range(101):
  for Cy in range(101):
    H = th + abs(tx-Cx) + abs(ty-Cy)
    if all(h == max(H-abs(x-Cx)-abs(y-Cy), 0) for x, y, h in xyh):
      print(Cx, Cy, H)
      exit()

Measured memory_bytes: 3064
object Main {

  def printArray(arr: Array[Int]): Unit =
    println(arr.mkString("\n"))

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    // 1以上N以下の任意の整数iについて, iの倍数が書かれた箱に入っている
    // ボールの個数の和を2で割った余りがa_iである

    val N = sc.nextInt()
    val A = Array.fill(N)(sc.nextInt() match {
      case 1 => true
      case 0 => false
    })

    // 言い換えると, 1以上,N以下の任意のiについて
    // iの倍数の個数を2で割った余りがa_iであるかどうか
    val B = new Array[Boolean](N)
    var i = N
    while (i > 0) {
      var s = false
      var j = 2
      while (i * j <= N) {
        s ^= B(i * j - 1)
        j += 1
      }
      if (s != A(i-1))
        B(i-1) = true
      i -= 1
    }
    val boxes = B.zipWithIndex.filter(_._1)
    val M = boxes.length
    val results = boxes.map(_._2 + 1).mkString(" ")
    println(M)
    if (M != 0)
      println(results)
  }

}


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

int main(){
  int n;
  string s="";
  cin>>n;
  while(n){
    if(n%-2){
      n--;
      s="1"+s;
    }else{
      s="0"+s;
    }
    n/=-2;
  }
 if(s==""){
   s="0";
 }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

ll A[200010], dp[200010][5]={};

int main(void){
    int L;
    cin >> L;
    for(int i=0; i<L; ++i) cin >> A[i];
    for(int i=0; i<L; ++i){
        ll mn=1e18;
        for(int j=0; j<5; ++j){
            mn=min(mn, dp[i][j]);
            if(j==0 || j==4) dp[i+1][j]=mn+A[i];
            else if(j==2) dp[i+1][j]=mn+(1-A[i]%2);
            else if(A[i]>0) dp[i+1][j]=mn+A[i]%2;
            else dp[i+1][j]=mn+2;
        }
    }
    ll ans=1e18;
    for(int i=0; i<5; ++i) ans=min(ans, dp[L][i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int N, D, X;  cin >> N >> D >> X;
    vector<int> A(N);  rep(i, N) cin >> A[i];

    int ans = 0;
    rep(i, D) {
        rep(j, N) {
            if (D >= i * A[j] + 1) ans++;
        }
    }

    cout << ans + X << endl;
}




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

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut to: Vec<Vec<Edge>> = vec![Vec::new(); n];

    for i in 1..n {
        let (a, b) = (read::<usize>()-1, read::<usize>()-1);
        to[a].push(Edge{to: b, id: i-1});
        to[b].push(Edge{to: a, id: i-1});
    }
    let mut m = 0;
    for i in 1..n {
        m = std::cmp::max(m, to[i-1].len());
    }

    let mut ans: Vec<usize> = vec![0;n-1];
    dfs(0, n, n, &mut to, &mut ans);
    println!("{}", m);
    for i in 0..ans.len() {
        println!("{}", ans[i]+1);
    }
}

#[derive(Clone)]
struct Edge {
    to: usize,
    id: usize
}

fn dfs(i: usize, p: usize, pc: usize, to: &mut Vec<Vec<Edge>>, ans: &mut Vec<usize>) {
    let mut col = 0;
    for u in 0..to[i].len() {
        if to[i][u].to == p {
            continue;
        }
        if pc == col {
            col+=1;
        }
        ans[to[i][u].id] = col;
        dfs(to[i][u].to.clone(), i, col, to, ans);
        col += 1;
    }
}


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

set<ll> st;

int ctoi(char c){
    if('0' <= c && c <= '9')
        return (c-'0');
    return -1;
}

void dfs(int d, ll num){ // d : 桁数(1~6), num : 数字
    if(d >= 10)
        return;
    // 数字→文字列
    string s = to_string(num);
    int l = s.size();
    char c = s[l-1];
    ll n = ctoi(c);
    
    string tmp;
    ll m;
    if(n > 0){
        tmp = s + to_string(n-1);
        m = stol(tmp);
        st.insert(m);
        dfs(d+1, m);
    }

    tmp = s + to_string(n);
    m = stol(tmp);
    st.insert(m);
    dfs(d+1, m);

    if(n < 9){
        tmp = s + to_string(n+1);
        m = stol(tmp);
        st.insert(m);
        dfs(d+1, m);
    }
}
 
int main(){
    int K;
    cin >> K;

    for(ll i=1;i<=9;i++){
        dfs(1, i);
        st.insert(i);
    }
    
    /*
    for(auto itr = st.begin(); itr != st.end(); ++itr) {
        std::cout << *itr << "\n";      // イテレータの指す先のデータを表示
    }
    */

    
    auto itr = st.begin();
    for(int i=0;i<K-1;i++)
        itr++;
    
    cout << *itr << endl;

}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool IsPalindromicNumber(int n)
{
    stringstream ss;
    ss << n;
    string s;
    ss >> s;
    rep(i, 0, s.size() / 2)
    {
        if (s[i] != s[s.size() - 1 - i])
        {
            return false;
        }
    }
    return true;
}

void _main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    rep(i, A, B + 1)
    {
        if (IsPalindromicNumber(i))
        {
            ++ans;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

int N, ans = 0;
int a[MAX];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
		if(i) ans = __gcd(a[i],ans);
		else ans = a[i];
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

vector<vector<int>> G;
vector<vector<int>> RG;
vector<bool> visited;
vector<int> A,Aa,Ans;
int jun=0;

void dfs(int pos){
    //cout<<pos<<endl;
    visited[pos]=true;
    for(auto i:G[pos]){
        if(visited[i]){
            continue;
        }
        else{
            dfs(i);
        }
    }
    A[pos]=jun;
    Aa[jun]=pos;
    ++jun;
}

void dfs2(int pos,int t){
    //cout<<pos<<endl;
    visited[pos]=true;
    Ans[pos]=t;
    for(auto i:RG[pos]){
        if(visited[i]){
            continue;
        }
        else{
            dfs2(i,t);
        }
    }
}

int main(){
    //ifstream input("ctestin.in");
    int n,m;
    cin>>n>>m;
    //input>>n>>m;
    G.resize(n);
    RG.resize(n);
    visited.assign(n,false);
    A.assign(n,-1);
    Aa.assign(n,-1);
    Ans.assign(n,-1);
    for (int i = 0; i < m; ++i) {
        int a,b;
        cin>>a>>b;
        //input>>a>>b;
        --a;--b;
        G[a].emplace_back(b);
        RG[b].emplace_back(a);
    }

    for (int i = 0; i < n; ++i) {
        if(visited[i])continue;
        dfs(i);
    }

    visited.assign(n,false);
    int d=0;
    for (int i = Aa.size()-1; i >= 0; --i) {
        if(visited[Aa[i]])continue;
        dfs2(Aa[i],d);
        ++d;
    }


    for (int i = 0; i < n; ++i) {
        vector<int> ans;
        for (int j = 0; j < n; ++j) {
            if(Ans[i]==Ans[j])ans.emplace_back(j);
        }
        sort(ans.begin(),ans.end());
        for (int k = 0; k < ans.size(); ++k) {
            cout<<ans[k]+1;
            if(k==ans.size()-1)cout<<endl;
            else cout<<" ";
        }
    }

    return 0;
}



Measured memory_bytes: 4172
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
	ld a , b ;
	cin >> a >> b ;
	for(int i = 2 ; i <= 2000 ; i++){
		int x = i/10 ;
		int y = (i*8)/100 ;
		if(x==b && y == a){
			cout << i << endl ;
			return ;
		}
	}
	cout << -1 << endl ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 512
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=400010;
struct node{int u,v,w;}e[N<<1];
bool operator<(node a,node b){return a.w<b.w;}
int f[N];
int find(int x){if(f[x]!=x)f[x]=find(f[x]);return f[x];}
int a[N],n,m,cnt;
int main(){
	n=gi();m=gi();memset(a,63,sizeof(a));
	for(int i=1;i<=m;i++){
		int x=gi()+1,y=gi()+1,z=gi();
		a[x]=min(a[x],z+1);
		a[y]=min(a[y],z+2);
		e[++cnt]=(node){x,y,z};
	}
	for(int i=1;i<=n;i++)a[i]=min(a[i],a[(i-2+n)%n+1]+2);
	for(int i=1;i<=n;i++)a[i]=min(a[i],a[(i-2+n)%n+1]+2);	
	for(int i=1;i<n;i++)e[++cnt]=(node){i,i+1,a[i]};
	e[++cnt]=(node){n,1,a[n]};
	sort(e+1,e+cnt+1);for(int i=1;i<=n;i++)f[i]=i;
	ll ans=0;
	for(int i=1;i<=cnt;i++){
		int u=find(e[i].u),v=find(e[i].v);
		if(u!=v){
			ans+=e[i].w;
			f[v]=u;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    int ans = 0;
    rep(i, n)
    {
        rep2(j, i + 1, n)
        {
            ans += (d[i] * d[j]);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "container/heap"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

type Item struct {
  Comparison  int
}
type PriorityQueue []*Item
func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
  return pq[i].Comparison < pq[j].Comparison
}
func (pq PriorityQueue) Swap(i, j int) {
  pq[i], pq[j] = pq[j], pq[i]
}
func (pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n - 1]
  *pq = old[0:n - 1]
  return item
}
func (pq *PriorityQueue) Push(x interface{}) {
  item := x.(*Item)
  *pq = append(*pq, item)
}

func Insert(L, S *PriorityQueue, C *[]int, a int) (l, s int) {
  if len((*C)) > 0 {
    c := (*C)[0]
    (*C) = []int{}
    if a < c {
      heap.Push(L, &Item{c})
      heap.Push(S, &Item{-a})
      return c, a
    } else {
      heap.Push(L, &Item{a})
      heap.Push(S, &Item{-c})
      return a, c
    }
  } else if L.Len() == 0 {
    (*C) = []int{a}
    return 0, 0
  } else {
    l := heap.Pop(L).(*Item).Comparison
    s := heap.Pop(S).(*Item).Comparison
    s *= -1
    if a < s {
      heap.Push(L, &Item{l})
      heap.Push(S, &Item{-a})
      (*C) = []int{s}
      return 0, a - s
    } else if l < a {
      heap.Push(L, &Item{a})
      heap.Push(S, &Item{-s})
      (*C) = []int{l}
      return a - l, 0
    } else {
      heap.Push(L, &Item{l})
      heap.Push(S, &Item{-s})
      (*C) = []int{a}
      return 0, 0
    }
  }
}

func main() {
  Q := NextInt()
  B := 0
  var x int
  var Large, Small PriorityQueue
  L, S := 0, 0
  C := []int{}
  for i := 0; i < Q; i++ {
    Query := NextIntVec()
    if Query[0] == 1 {
      l, s := Insert(&Large, &Small, &C, Query[1])
      L += l
      S += s
      B += Query[2]
    } else {
      if len(C) > 0 {
        x = C[0]
      } else {
        x = heap.Pop(&Small).(*Item).Comparison
        x *= -1
        heap.Push(&Small, &Item{-x})
      }
      fx := L - S + B
      WriteIntVec([]int{x, fx})
    }
  }
  Output()
}

Measured memory_bytes: 11520
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
K = int(input())
A,B = map(int,input().split())	
cnt = 0
for i in range(A,B+1):
    if i%K==0:
       cnt +=1
       break
    
if cnt>=1:
    print("OK")
else:
    print("NG")







Measured memory_bytes: 61808
#include<bits/stdc++.h>
using namespace std;
 
using lint=long long;

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

   int a,b,c; cin>>a>>b>>c;
   if(a==b and c!=a or a==c and b!=a or b==c and a!=b) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
mlmis = lambda: [-int(x) for x in input().split()]
INF = float('inf')
#

def main():
    N,M = mis()
    A = mlmis()
    import heapq
    heapq.heapify(A)
    for _ in range(M):
        a = heapq.heappop(A)
        heapq.heappush(A, a/2)
    print(sum(-int(a) for a in A))



main()


Measured memory_bytes: 14484
S,T=input(),input()
s,t=len(S),len(T)
l=[]
for i in range(len(S)-t+1):
  for j in range(t):
    if S[i+j] not in (T[j],'?'): break
  else: l.append((S[:i]+T+S[i+t:]).replace('?','a'))
print(min(l) if l else 'UNRESTORABLE')

Measured memory_bytes: 3064
N, K = map(int, input().split())
MOD = 998244353

nums = []

for i in range(K):
    l, r = map(int, input().split())
    nums.append([l, r])
# nums.sort()
# print(nums)


dp = [0] * (N + 1)
dp[1] = 1
cumsum = [0, 1]

for i in range(2, N + 1):
    for l, r in nums:
        # print(l,r)
        if i - l > 0:
            # print(i, l, r)
            # r = min(r, N)
            dp[i] += (cumsum[i - l] - cumsum[max(i - r - 1, 0)]) % MOD
    cumsum.append(cumsum[-1] + dp[i])

print(dp[-1] % MOD)
# print(dp)
# print(cumsum)


Measured memory_bytes: 81260
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll X, Y;
    cin >> X >> Y;
    rep(0, i, X + 1)
    {
        rep(0, j, X + 1)
        {
            ll sum = 2 * i + 4 * j;
            if (sum == Y && i + j == X)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())

    cnt = Counter(A)
    sum_v = sum(A)
    for _ in range(Q):
        b, c = map(int, input().split())

        sum_v += cnt[b] * (c - b)
        cnt[c] += cnt[b]
        cnt[b] = 0
        print(sum_v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 89316
#include <bits/stdc++.h>
#define i64 long long
using namespace std;
int freq[26] = {0};
int main() {
	// your code goes here
	string s; cin>>s;
	for(int i=0;i<s.size();i++) freq[s[i]-'a']++;
	bool different = true;
	for(int i=0;i<26 and different;i++){
		if(freq[i]>1) different = false;
	}
	printf("%s\n", different ? "yes" : "no");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0

def check_five(N):
    count = 0
    i = 10
    while True:
        divided = N // i
        if divided == 0:
            break
        count += divided
        i = i * 5
    return count

if N % 2 == 0:
    ans = check_five(N)
else:
    ans = 0

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = s; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   vector<int> h(n);
   rep(i, 0, n) { cin >> h[i]; }
   vector<int> dp(n);
   rep(i, 1, n + 1) {
      if (i == 1)
         dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
      else
         dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                     dp[i - 1] + abs(h[i] - h[i - 1]));
   }
   cout << dp[n - 1] << endl;
   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;

int main(){
	while(cin >> n){
		vector<int> v(n);
		for(int i=0;i<n;i++){
			cin >> v[i];			
		}
		reverse(v.begin(),v.end());
		for(int i=0;i<n;i++){
			if(i!=n-1) cout << v[i] << " ";
			else cout << v[i] <<endl;
		}
	}
}


Measured memory_bytes: 3100
n = int(input())
cnt = 0
cnt += (n - 10 ** (len(str(n)) - 1) + 1) * (len(str(n)) % 2 == 1)
n -= n - 10 ** (len(str(n)) - 1) + 1
if n == 0:
    print(cnt)
    exit()
for i in range(len(str(n))):
    if (len(str(n)) - i) % 2 == 1:
        cnt += 10 ** (len(str(n)) - i - 1) * 9
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#include <cstring>
#include <queue>
 
#define MK make_pair
 
int date[128][128], cnt[128][128];
int data_[120][120] = { 0 };
bool flg_date[128][128], flg_rec[128][128];//????????????????????????????????????????????????
int x_move[2][6] = { { +1,-1,+1,0,+1,0 }, { +1,-1,0,-1,0,-1 } }, y_move[2][6] = { { 0,0,+1,+1,-1,-1 }, { 0,0,+1,+1,-1,-1 } };
 
int rec(int x,int y,int count);
 
int main(void){
 
    int w, h;
    memset(cnt, 0, sizeof(cnt));
    memset(date, -1, sizeof(date));
    memset(flg_date, false, sizeof(flg_date));
    memset(flg_rec, false, sizeof(flg_rec));
 
    cin >> w >> h;
    for (int i = 1; i <= h+2; i++){
        for (int j = 1; j <= w+2; j++){
            if (i == 1 || i == h + 2 || j == 1 || j == w + 2){ date[i][j] = 0; continue; }
            cin >> date[i][j];
        }
    }
 
    cout << rec(1, 1, 0) << endl;
}
 
int rec(int x, int y, int count){
 
    flg_rec[y][x] = true;
    for (int k = 0; k < 6; k++){
        if (!flg_rec[y + y_move[y % 2][k]][x + x_move[y % 2][k]] && date[y + y_move[y % 2][k]][x + x_move[y % 2][k]] == 0){
            count = rec(x + x_move[y % 2][k], y + y_move[y % 2][k],count);
        }
        else if (date[y + y_move[y % 2][k]][x + x_move[y % 2][k]] == 1){ data_[y][x]++; count++; /*cout << x << ',' << y << ':' << x + x_move[y % 2][k] << ',' << y + y_move[y % 2][k] << endl;*/ cnt[y + y_move[y % 2][k]][x + x_move[y % 2][k]]++; }
    }
 
    return count;
}

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

int main()
{
    ld a, b, x;
    cin >> a >> b >> x;
    ld res;
    if (a*b / 2 <= x / a) {
        ld num = a * a*a;
        num /= 2;
        num /= a * a*b - x;
        res = atan(num);
    }
    else {
        res = atan(2 * x / (a*b*b));
    }
    res /= 3.141592653589793;
    res *= 180;
    res = 90 - res;
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}


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

int main () {
  int K , T ;
  cin >> K >> T ;
  int Max = 0 ;
  for(int i = 0 ; i < T ; i++ ) {
    int a ;
    cin >> a ;
    Max = max(Max,a) ;
  }
  int ans = 0 ;
  if(K%2==0){
    if(K/2>=Max) {
      ans = 0 ;
    } else {
      ans = (Max-K/2) * 2 - 1 ;
    }
  } else {
    if((K+1)/2>=Max) {
      ans = 0 ;
    } else {
      ans = (Max-(K+1)/2) * 2 - 1 ;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dl;
const int iNF = 1e9 + 100;
const ll INF = 1e18 + 100;
typedef pair<int, int> pii;

int main(){
   string a, b;
   cin >> a >> b;
   if(a.length() == b.length() - 1){
      for(int i = 0; i < a.length(); i++){
         if(a[i] != b[i]){
            cout << "No" << endl;
            return 0;
         }
      }
      cout << "Yes" << endl;
   }else{
     cout << "No" << endl;
   }
   return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main() {
	int x, y;
	cin >> x >> y;
	int ans(2e9 + 2);
	if(y >= x) {
		ans = min(ans, y - x);
	}
	if(y >= -x) {
		ans = min(ans, y - (-x) + 1);
	}
	if(-y >= x) {
		ans = min(ans, -y - x + 1);
	}
	if(-y >= -x) {
		ans = min(ans, -y - (-x) + 2);
	}
	cout << ans << endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, x;
  cin >> n >> x;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a.at(i) <= x) {
      x -= a.at(i);
      ans++;
    }
    else break;
  }
  if (a.back() == x) ans++;
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
long long x[N],y[N];
char ch[]={'U','D','R','L'};
int main() 
{
	ios::sync_with_stdio(false); 
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>x[i]>>y[i];
	int m2=0;
	if((x[0]+y[0])%2==0) 
	{
		m2=1;
		for(int i=0;i<n;i++)
			x[i]--;
	}
	for(int i=0;i<n;i++) 
	{
		if((x[i]+y[i])%2==0) 
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	vector<long long>v;
	for(int i=0;i<=31;i++)
		v.push_back(1ll<<i);
	if(m2)
		v.push_back(1);
	reverse(v.begin(),v.end());
	cout<<v.size()<<endl;
	for(auto i=0;i<v.size();i++)
		cout<<v[i]<<" ";
	cout<<endl;
	for(int i=0;i<n;i++) 
	{
		string s;
		if(m2)
			s+="R";
		for(int j=31;j>=0;j--) 
		{
			int tmp=-1;
			long long now=LLONG_MAX;
			for(int k=0;k<4;k++) 
			{
				long long cur=abs(x[i]-dx[k]*(1ll<<j))+abs(y[i]-dy[k]*(1ll<<j));
				if(cur<now)
				{
					now=cur;
					tmp=k;
				}
			}
			x[i]-=dx[tmp]*(1ll<<j);
			y[i]-=dy[tmp]*(1ll<<j);
			s+=ch[tmp];
		}
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (int)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }  

typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h,w;cin>>h>>w;
    ll a=min(h,w),b=max(h,w),ans;
    if(a==1)
        ans=1;
    else
        ans=((a+1)/2)*((b+1)/2)+(a/2)*(b/2);
    cout<<ans<<'\n';
    return 0;
}

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

int main() {
  int answer[3][101];
  int x = 0;
  for (int i = 1; i <= 100; i++) {
    while (true) {
      x++;
      if (x%100 != 0) {
        answer[0][i] = x;
        break;
      }
    }
  }
  x = 0;
  for (int i = 1; i <= 100; i++) {
    while (true) {
      int count = 0;
      x += 100;
      int v = x;
      while (v%100 == 0) {
        v/=100;
        count++;
      }
      if (count == 1) {
        answer[1][i] = x;
        break;
      }
    }
  }
  x = 0;
  for (int i = 1; i <= 100; i++) {
    while (true) {
      int count = 0;
      x += 10000;
      int v = x;
      while (v%100 == 0) {
        v/=100;
        count++;
      }
      if (count == 2) {
        answer[2][i] = x;
        break;
      }
    }
  }
  int D, N; cin >> D >> N;
  cout << answer[D][N] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int main(){
	long long n;
	cin >> n;
	if (n % 2 != 0)
		printf("%d", 0);
	else{
		n = n / 2;
		long long  sum = 0;
		long long temp = 5;
		while (n / temp > 0)
		{
			sum += n / temp;
			temp *= 5;
		}
		printf("%lld", sum);
	}
	return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n;
  double dist=0;
  cin >> n;
  vecll x(n), y(n);
  forll(i, 0, n)
	cin >> x[i] >> y[i];
  forll(i, 0, n){
	forll(j, i, n){
	  dist += sqrt(pow((x[i] - x[j]), 2.0) + pow((y[i] - y[j]), 2.0));
	}
  }
  cout << setprecision(10) << dist * 2 / n << endl;
}


Measured memory_bytes: 256
use proconio::input;

fn gcv(a: isize, b:isize) -> isize {
  if b == 0 {
    a
  } else {
    gcv(b, a % b)
  }
}

fn lcm(a: isize, b:isize) -> isize {
  a * b / gcv(a, b)
}

fn main() {
  input! {
    a: isize,
    b: isize,
    c: isize,
    d: isize
  }
  
  let a = a - 1;
  let common = lcm(c, d);
  let result = b - (b/c + b/d - b/common) - (a - (a/c + a/d - a/common));
  println!("{}", result);
}

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

using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define f first
#define se second
#define pii pair<int,int>
string s, t;
vector<vector<int> > dp(3002, vector<int> (3002, -1));
vector<vector<int> > w(3002, vector<int>(3002, -1));
int get_ans(int i,int j){
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    if(sz(s) <= i || sz(t) <= j){
        return 0;
    }
    if(s[i] == t[j]){
        w[i][j] = 2;
        return dp[i][j] = 1 + get_ans(i + 1, j + 1);
    }
    int x = get_ans(i, j + 1);
    int y = get_ans(i + 1, j);
    if(x >= y){
        w[i][j] = 0;
        return dp[i][j] = x;
    }
    w[i][j] = 1;
    return dp[i][j] = y;
}
decltype(0) main() {
    ios::sync_with_stdio(0);
    cin >> s >> t;
    int len = get_ans(0, 0);
    int i = 0, j = 0;
    string res = "";
    while(i < sz(s) && j < sz(t) && w[i][j] != -1){
        if(w[i][j] == 2){
            res += s[i];
            i++, j++;
        }else if(w[i][j] == 0){
            j++;
        }else if(w[i][j] == 1){
            i++;
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 141568