akhauriyash/Code-Regression huggingface dataset:
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

const ll mod = 1000000007;

inline ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

inline ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

inline ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

const int N = 1e5 + 5;

ll F[N];
ll IF[N];

void init() {
	F[0] = 1;
	for(int i=1; i<N; i++) F[i] = mul(F[i-1], i);
	IF[N-1] = power(F[N-1], mod-2);
	for(int i=N-2; i>=0; i--) IF[i] = mul(IF[i+1], i+1);
}

ll C(ll n, ll k) {
	if(k > n || k < 0) return 0;
	if(k == 0 || n == k) return 1;
	return mul(F[n], mul(IF[k], IF[n-k]));
}

ll n, k;
vector <int> g[N];

ll calc(int u, int p) {
	ll res = mul(C(k-2, sz(g[u])-1), F[sz(g[u])-1]);
	for(int v : g[u]) {
		if(v == p) continue;
		res = mul(res, calc(v, u));
	}
	return res;
}

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

	int x, y;
	cin >> n >> k;
	for(int i=1; i<n; i++) {
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	init();
	ll res = mul(mul(k, C(k-1, sz(g[1]))), F[sz(g[1])]);
	for(int u : g[1]) {
		res = mul(res, calc(u, 1));
	}
	cout << res << endl;

	return 0;
}

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

def pr(list):
    n = len(list)
    for i in range(n):
        if i < n-1:
            print(list[i],end=" ")
        else:
            print(list[i],end="\n")

def sort():
    swap = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            temp = A[i]
            A[i] = A[minj]
            A[minj] = temp
            swap += 1
    pr(A)
    print(swap)

sort()



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {

    int H, A, B;
    cin >> H >> A >> B;
    int ans = 0;
    for (int i=A; i<=B; ++i) {
        if (H%i == 0) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3104
program main
  implicit none
  integer :: i, n
  integer,allocatable :: h(:)
  logical :: out = .true., prev = .false.

  read *, n
  allocate (h(n))
  read *, h

  do i = 2, n
    if (h(i-1) - h(i) >= 2) then
      out = .false.
      exit
    else if (h(i-1) - h(i) == 1) then
      if (prev) then
        out = .false.
        exit
      else
        prev = .true.
      end if
    else if (h(i-1) < h(i)) then
      prev = .false.
    end if
  end do

  if (out) then
    print '(a)', 'Yes'
  else
    print '(a)', 'No'
  end if
end program


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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    lld N,M,K;
    lld A,B;
    lld A_sum[200001],B_sum[200001];
    A_sum[0] = 0;
    B_sum[0] = 0;
    
    cin >> N >> M >> K;
    for (int i = 0; i < N; i++) {
        cin >> A;
        A_sum[i+1] = A_sum[i] + A;
    }
    for (int i = 0; i < M; i++) {
        cin >> B;
        B_sum[i+1] = B_sum[i] + B;
    }

    lld left = 0, right = N+M;
    while(left < right){
        lld mid = (left+right)/2+1;
        bool flg = false;
        for (int i = 0; i <= mid; i++) {
            if(i <= N && mid-i <= M && A_sum[i] + B_sum[mid-i] <= K){
                flg = true;
                break;
            }
        }
        if(flg){
            left = mid;
        } else {
            right = mid-1;
        }
    }
    cout << left << endl;
}

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


//      DEEP


using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fwd(i,a,n) for(int i=a;i<=n;i++)
#define bak(i,a,n) for(int i=a;i>=n;i--)
#define all(v) v.begin(),v.end()
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef set<int> si;
const ll mod = 1e9 + 7;
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}
ull gcd(ull x,ull y){
   if(y==0)return x;
   return gcd(y,x%y);
}
int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double x=6*m;
    double y=30*h+0.5*m;
    double z=abs(x-y);
    if(z>180){
        z=360-z;
    }
    z=z*3.1415926535/180;
    double ans=sqrt(a*a+b*b-2*a*b*cos(z));
    printf("%0.11f\n",ans);

}




Measured memory_bytes: 4224
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
    int x[3];
    while(cin>>x[0]>>x[1]>>x[2])
    {
        sort(x,x+3);
        if (x[0] == 5 && x[1] == 5 && x[2] == 7)
            puts("YES");
        else puts("NO");
    }


    return 0;
}


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

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

	int UpperCount = count_if(s.begin(), s.end(), [](char c) {return isupper(c); });
	int CCount = count(s.begin() + 2, s.end() - 1, 'C');

	bool res = s.front() == 'A' && UpperCount == 2 && CCount == 1;
	puts(res ? "AC" : "WA");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m,ans=0;
string s;
int main(){
  cin >> n >> m;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    m-=a[i];
    ans++;
  }
  sort(a,a+n);
  ans+=m/a[0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin>>n;
    vector<int>h(n);
    for(int i=0;i<n;i++){
        cin>>h.at(i);
    }
    // int ans=0;
    int MIN=h.at(n-1);
    for(int i=n-1;i>=0;i--){
        if(h.at(i)-MIN>=2){
            cout<<"No"<<endl;
            return 0;
        }
        if(h.at(i)<=MIN){
            MIN=h.at(i);
        }
    }
    cout<<"Yes"<<endl;





    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner

import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val A = readLine().split(" ").map(_.toInt)

  def solve() = {
    val sorted = A.sorted(Ordering[Int].reverse)
    (1 until n).foldLeft(0L) { (acc, i) => 
      acc + sorted(i/2) 
    }
  }


  println(solve())

}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Solve());
            return;
        }

        private static int Solve()
        {
            var arr = Console.ReadLine()
                .Split(' ')
                .Select(x => int.Parse(x))
                .ToArray();
            var a = arr[0];
            var b = arr[1];
            return b % a == 0 ? a + b : b - a;
        }
    }
}


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

string s, t;

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

    int res = 0;

    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) != t.at(i)) res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 3896
package main

import "fmt"

func main() {
        var N int
        fmt.Scan(&N)

        max := 0
        for n := N; n > 0; n-- {
                count := 0
                for i := n; i > 0; i /= 2 {
                        if i%2 != 0 {
                                break
                        }
                        count++
                }
                if max < count {
                        max = count
                }
        }
        ans := 1
        for i := 1; i <= max; i++ {
                ans *= 2
        }
        fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 2003;
const long long M = 1000000007;

int n;
long long k;
int a[N];

long long ans;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i + 1; j <= n; ++j)
        {
            if (a[i] > a[j])
            {
                ans = (ans + k) % M;
            }
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (a[i] > a[j])
            {
                ans = (ans + (k * (k - 1) / 2)) % M;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line;
            /* input */
            while(true){
                line = br.readLine();
                int n = Integer.parseInt(line.split(" ")[0]), m = Integer.parseInt(line.split(" ")[1]);
                if(n==0&&m==0) break;
 
                ArrayList<Integer> t = new ArrayList<Integer>();
                t.add(0);
                int max = 0;
 
                if(n>0){
                    String[] str = br.readLine().split(" ");
                    for(int i=0;i<n;i++){
                        t.add(Integer.parseInt(str[i]));
                    }
                }
 
                if(m>0){
                    int index = 1;
                    String[] str = br.readLine().split(" ");
                    for(int i=n;i<n+m;i++){
                        int temp = Integer.parseInt(str[i-n]);
                        while(index < t.size() && t.get(index) < temp){
                            index++;
                        }
                        t.add(index,temp);
                    }
                }
                for(int i=0;i<n+m;i++){
                    if(t.get(i+1) - t.get(i) > max) max = t.get(i+1) - t.get(i);
                }
 
                System.out.println(max);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 33396
//#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
#include <set>
//#include <string.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    long long n,k;
    cin >> n>>k;
    long long a=n%k;
    if(a>k/2)a=k-a;
    cout<<a<<endl;
}


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

#define int long long

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

int N, K;
int a[100000], imos[100001] = {}, plus_imos[100001] = {};

signed main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        imos[i + 1] = imos[i] + a[i];
        plus_imos[i + 1] = plus_imos[i] + max(a[i], 0LL);
    }
    int loss = LLONG_MAX;
    for (int i = 0; i <= N - K; i++) {
        loss = min(loss, (plus_imos[i + K] - plus_imos[i]) - (imos[i + K] - imos[i]));
        loss = min(loss, plus_imos[i + K] - plus_imos[i]);
    }
    cout << plus_imos[N] - loss << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

typedef long long LL;
const int p=1000000007;
int n,m,fac[4000100],inv[4000100],f[2010][2010];

int calc(int n,int m)
{
    return LL(fac[n])*inv[m]%p*inv[n-m]%p;
}

int main()
{
    scanf("%d%d",&n,&m);
    if (m==1)
    {
        puts("1");
        return 0;
    }
    fac[0]=inv[0]=fac[1]=inv[1]=1;
    repu(i,2,n*m)
    {
        fac[i]=LL(fac[i-1])*i%p;
        inv[i]=LL(p-p/i)*inv[p%i]%p;
    }
    repu(i,2,n*m)
        inv[i]=LL(inv[i])*inv[i-1]%p;
    f[0][0]=1;
    repu(i,1,n)
        repu(j,0,i)
        {
            f[i][j]=f[i-1][j];
            if (j)
                f[i][j]=(f[i][j]+LL(f[i][j-1])*calc(n-i+(n-j+1)*(m-1)-1,m-2))%p;
        }
    printf("%d\n",LL(f[n][n])*fac[n]%p);
    return 0;
}

Measured memory_bytes: 46336
import sys
sys.setrecursionlimit(1000000)
s_list = list(input())
length = len(s_list)

def func(idx,past):
    if idx==length:
        return 0
    if idx>length:
        return -1
    
    if s_list[idx] == past:
        return func(idx+2,s_list[idx:idx+2]) + 1
    else:
        return func(idx+1,s_list[idx])+1

print(func(0,""))

Measured memory_bytes: 180556
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	int b[9]={0,0,0,0,0,0,0,0,0};
	for(int i=0;i<n;i++){
		if(1<=a[i]&&a[i]<=399)
			if(b[0]==0)b[0]=1;
		if(400<=a[i]&&a[i]<=799)
			if(b[1]==0)b[1]=1;
		if(800<=a[i]&&a[i]<=1199)
			if(b[2]==0)b[2]=1;
		if(1200<=a[i]&&a[i]<=1599)
			if(b[3]==0)b[3]=1;
		if(1600<=a[i]&&a[i]<=1999)
			if(b[4]==0)b[4]=1;
		if(2000<=a[i]&&a[i]<=2399)
			if(b[5]==0)b[5]=1;
		if(2400<=a[i]&&a[i]<=2799)
			if(b[6]==0)b[6]=1;
		if(2800<=a[i]&&a[i]<=3199)
			if(b[7]==0)b[7]=1;
		if(3200<=a[i])
			b[8]+=1;
	}
	int sum=0;
	for(int i=0;i<8;i++){
		sum+=b[i];
	}
	if(sum==0){
		sum++;
		if(b[8]!=0)b[8]--;
	}
	cout << sum << " " << sum+b[8] << endl;
}


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

N, u, v = list(map(int, input().split()))
E = [[] for _ in range(N)]
for _ in range(N-1):
    A, B = list(map(int, input().split()))
    E[A-1].append(B-1)
    E[B-1].append(A-1)

#print(E)

parent = [None]*N
parent[v-1] = -1
depth = [None]*N
depth[v-1] = 0

queue = [v-1]
d=1
while queue:
    queue_new = []
    for q in queue:
        for e in E[q]:
            if parent[e] is not None: continue
            parent[e] = q
            queue_new.append(e)
            depth[e] = d

    queue = queue_new
    d+=1

#print(parent)
#print(depth)

w = u-1
x = (depth[u-1]-1)//2
for _ in range(x):
    w = parent[w]
    #print('rewind')

#print(w)

depth_from_w = 0
queue = [w]
while queue:
    queue_new = []
    for q in queue:
        for e in E[q]:
            if e==parent[q]: continue
            queue_new.append(e)

    queue = queue_new
    depth_from_w+=1

#print(depth_from_w-1)
print(depth[w] + depth_from_w-2)

Measured memory_bytes: 28596
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum = 0;
ll A[500][10] = {}, B[500000] = {}, rui[500010] = {}, dp[50][2600] = {};
str S; bool check = true;	vector<ll> v(a);



int main() {
	//Code Line
	cin >> n;

	c = 5;

	while (n / c > 0) {

		b += n / c / 2;
		c *= 5;

	}
	if (n % 2 == 1)b = 0;
	cout << b << endl;

	return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

class sqrt_decomposition{
    public:
    const i64 B=1000;
    int n;
    vector<i64> data,unif,sum; //uni??????????????????????§?????¶?????????????
    sqrt_decomposition(int n,i64 init):n(n),data(n,init),unif((n+B-1)/B),sum((n+B-1)/B){
        rep(i,0,(n+B-1)/B) unif[i]=init;
        rep(i,0,n) sum[i/B]+=init;
    }

    //[s,t)???x??????????????´???[s,t)???????¨??????????
    i64 add(int s,int t,i64 x){
        i64 res=0;
        while(s<t and s%B!=0){
            data[s]+=x;
            sum[s/B]+=x;
            res+=data[s]+unif[s/B];
            ++s;
        }
        while(s<t and t%B!=0){
            --t;
            data[t]+=x;
            sum[t/B]+=x;
            res+=data[t]+unif[t/B];
        }

        while(s<t){
            int i=s/B;
            unif[i]+=x;
            sum[i]+=x*B;
            res+=sum[i];
            s+=B;
        }
        return res;
    }
};

void solve(){
    int n,q;
    cin >> n >> q;
    sqrt_decomposition sd(n,0);

    rep(i,0,q){
        int k;
        cin >> k;
        if(k==0){
            int s,t,x;
            cin >> s >> t >> x;
            --s;
            sd.add(s,t,x);
        }else{
            int s,t;
            cin >> s >> t;
            --s;
            cout << sd.add(s,t,0) << endl;
        }
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 3572
H,M = list(map(int,input().split()))
N = int(input())
a = list(map(int,input().split()))


space = []
mass = [[0 for i in range(M)] for j in range(H)]
count = 0


for i in range(N):
    for j in range(a[i]):
        space.append(i+1)  



for k in range(H):
    for n in range(M):
        mass[k][n] = str(space[count])
        count += 1

for l in range(H):
  if l%2 == 1:
      mass[l].reverse()


for x in range(H):
  print(" ".join(mass[x]))

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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    int res = 0;
    for(int i=1,x;i<=n;i++) {
        cin >> x;
        if(i % 2 == 1 && x % 2 == 1) res++;
    }
    cout << res << endl;
    return;
} 

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <cstring>

using namespace std;
typedef long long LL;
typedef double db;
typedef pair<int, int> PII;
const int N = 1e5 + 5;
char s[N];
int len, lft[N], rig[N], exi[N], ans;
inline LL read() {
    LL x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
queue<PII> q;
int main() {
    //freopen("data.in", "r", stdin);

    scanf("%s", s); len = strlen(s);
    for (int i = 0; i < len; ++i) {
        exi[i] = 1;
        if (i != 0) lft[i] = i - 1; else lft[i] = -1;
        if (i != len - 1) rig[i] = i + 1; else rig[i] = -1;
        if (i != 0 && s[i] != s[i - 1]) {
            q.push(make_pair(i - 1, i));
            //printf("%d %d\n", i - 1, i);
        }
    }
    while (!q.empty()) {
        int x = q.front().first, y = q.front().second; q.pop();
        //printf("%d %d\n", i, rig[i]);
        if (exi[x] && exi[y]) {
            ans += 2;//printf("%d %d\n", x, y);
            exi[x] = exi[y] = 0;
            if (exi[lft[x]] && exi[rig[y]] && s[lft[x]] != s[rig[y]]) q.push(make_pair(lft[x], rig[y]));
            if (lft[x] != -1)rig[ lft[x] ] = rig[y];
            if (rig[x] != -1)lft[ rig[y] ] = lft[x];
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

using ll = long long;

template<class T>
struct Graph {
    struct Edge {
        int dst; T w;
        Edge(int _d, T _w) : dst(_d), w(_w) {}
    };
 
    const int n, s;
    const T INF;
    bool is_neg_cycle;
    std::vector<std::vector<Edge>> adj;
    std::vector<T> d;
 
    Graph(int _n, int _s)
        : n(_n), s(_s), INF(std::numeric_limits<T>::max()),
          is_neg_cycle(false), adj(n), d(n, INF) { }
 
    void add_edge(int u, int v, T w) { adj[u].emplace_back(Edge(v, w)); }
    T ShortestDistance(const int t) const { return d[t]; }
    bool IsNegativeCycleFromS() const { return is_neg_cycle; }
 
    bool CheckNegativeCycle() {
        std::fill(d.begin(), d.end(), 0);
        BellmanFord();
        return is_neg_cycle;
    }
 
    void BellmanFord() {
        d[s] = 0;
        for (int i = 0; ; ++i) {
            bool update = false;
            for (int v = 0; v < n; ++v)
                for (const auto &e : adj[v])
                    if (d[v] < INF && d[v] + e.w < d[e.dst]) {
                        d[e.dst] = d[v] + e.w;
                        update = true;
                        if (e.dst == n - 1 && n <= i) is_neg_cycle = true;
                    }
            if (!update) break;
            if (i == 2 * n) { break; }
        }
    }
};

// template<class T>
// struct Graph {
//     const int n, src;
//     const T INF;
//     bool is_neg_cycle;
//     std::vector<std::vector<std::pair<int, T>>> adj;
//     std::vector<T> d;

//     Graph(int _n, int _s)
//         : n(_n), src(_s), INF(std::numeric_limits<T>::max()),
//           is_neg_cycle(false), adj(n), d(n, INF) { }

//     void add_edge(int u, int v, T w) { adj[u].push_back(std::make_pair(v, w)); }
//     T ShortestDistance(const int t) const { return d[t]; }
//     bool IsNegativeCycleFromS() const { return is_neg_cycle; }
//     void ChangeSource(int _s) { src = _s; fill(d.begin(), d.end(), INF); }

//     void BellmanFord() {
//         d[src] = 0;
//         for (int i = 0; ; ++i) {
//             bool update = false;
//             for (int v = 0; v < n; ++v)
//                 for (const auto &e : adj[v])
//                     if (d[v] < INF && d[v] + e.second < d[e.first]) {
//                         d[e.first] = d[v] + e.second;
//                         update = true;
//                     }
//             if (!update) break;
//             if (i == n - 1) { is_neg_cycle = true; break; }
//         }
//     }
// };

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

    int n, m;
    cin >> n >> m;

    Graph<ll> g(n, 0);
    for (int i = 0; i < m; ++i) {
        ll a, b, c;
        cin >> a >> b >> c;
        g.add_edge(a - 1, b - 1, -c);
    }

    g.BellmanFord();
    if (g.is_neg_cycle) cout << "inf\n";
    else cout << -g.ShortestDistance(n - 1) << endl;

    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=1e3+10;
int vis[N],a[N],n,k;

int main()
{
    cin>>n>>k;
    rep(i,1,k){
        int d;scanf("%d",&d);
        while(d--)
        {
            int x;
            scanf("%d",&x);
            vis[x]++;
        }
    }
    int ans=0;
    rep(i,1, n)
    {
        if(vis[i]==0) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  for(int i=1;i<s.size();++i){
    set<char>s1;
    set<char>s2;
    for(int j=0;j<i;++j)  s1.insert(s[j]);
    for(int j=i;j<s.size();++j) s2.insert(s[j]);
    int cnt=0;
    for(auto itr1=s1.begin();itr1!=s1.end();++itr1){
      for(auto itr2=s2.begin();itr2!=s2.end();++itr2){
        if(*itr1==*itr2) cnt++;
      }
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

struct UnionFind{
	vl p;
	vl rank;
	vl cnt;

	UnionFind(ll n){
		rank.resize(n,0);
		p.resize(n,0);
		cnt.resize(n,0);
		rep(i,n){
			p[i] = i;
			rank[i] = 0;
			cnt[i] = 1;
		}
	}

	ll find(ll x){
		if(x != p[x]) p[x] = find(p[x]);
		return p[x];
	}

	bool same(ll x, ll y){
		return find(x) == find(y);
	}

	void unite(ll x, ll y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x] > rank[y]){
			p[y] = x;
			cnt[x] += cnt[y];
		}else{
			p[x] = y;
			cnt[y] += cnt[x];
			if(rank[x] == rank[y]) rank[y]++;
		}
	}

	ll size(ll x){
		return cnt[find(x)];
	}
};

int main(){
	int n,m; cin >> n >> m;
	UnionFind uf(n);
	vb visit(n,false);
	rep(i,m){
		int a,b; cin >> a >> b; a--; b--;
		uf.unite(a,b);
	}
	int ans = 0;
	rep(i,n){
		if(visit[uf.find(i)]) continue;
		visit[uf.find(i)] = true;
		ans++;
	}
	ans--;
	cout << ans << "\n";
}

Measured memory_bytes: 5512
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	return x*f;
}


int main()
{
	int k,x;
	k=read(),x=read();
	for(int i=x-k+1;i<=k+x-1;i++)printf("%d ",i);
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s, t; cin >> s >> t;
  int m = s.size();

  VV lc(26, V());
  rep(i, m) {
    int x = s[i] - 'a';
    lc[x].push_back(i);
  }

  int i = -1;
  ll ans = 0;
  for (auto c : t) {
    int x = c - 'a';
    if (lc[x].size() == 0) {
      cout << -1 << "\n";
      return 0;
    }
    auto it = lower_bound(all(lc[x]), i+1);
    if (it == lc[x].end()) {
      i = lc[x][0];
      ans += m;
    }
    else i = *it;
  }
  ans += i+1;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4152
#include <stdio.h>
#include <string.h>
int main(void)
{
	int num[2],a;
	char ans[32];
	while(scanf("%d %d",&num[0],&num[1])!=EOF){
		sprintf(ans,"%d",num[0]+num[1]);
		printf("%d\n",strlen(ans));
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


const int N_MAX = 100001;
VI prime;
void generate_prime() {
    prime.push_back(2); 
    FOR(i, 3, N_MAX) {
        for(auto p : prime) {
            if(i % p == 0) break;
            if(p > sqrt(i)) {
                prime.push_back(i);
                break;
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    generate_prime();
    set<int> prime1(ALL(prime));
    set<int> prime2;
    for(auto& p : prime1) {
        if(p == 2) continue;
        if(prime1.count((p + 1) / 2) == 1) prime2.insert(p);
    }
    VI ans(N_MAX);
    ans[0] = 0;
    FOR(i, 1, N_MAX - 1) {
        if(prime2.count(i) == 1) ans[i] = ans[i - 1] + 1;
        else ans[i] = ans[i - 1];
    }
    
    int q;
    cin >> q;
    REP(i, q) {
        int l, r;
        cin >> l >> r;
        cout << ans[r] - ans[l - 1] << '\n';
    }
    return 0;
}


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

constexpr ll p = 1000000007;

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int l = s.size(), i = 0;
    s += "0";
    int total = 0, carry = 0;
    while(i < l) {
        int c = (int)s[i] - 48 + carry;
        carry = 0;
        if(c == 0) {
            i++;
            continue;
        }
        if(c <= 4 || c == 5 && (int)s[i + 1] - 48 < 5) {
            total += c;
            i++;
            continue;
        }
        carry = 1;
        total += 10 - c;
        i++;
        while(i < l && (int)s[i] - 48 == 9) i++;
    }

    cout << total + carry << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double eps = -1e10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

//誤差を考慮して足し算
double add(double a, double b) {
	if (abs(a + b) < eps*(abs(a) + abs(b))) {
		return 0;
	}
	return a + b;
}

//二次元ベクトル構造体
struct pp {
	double x, y;
	pp() {}
	pp(double x, double y) :x(x), y(y) {}
	pp operator+(pp p) {
		return pp(add(x, p.x), add(y, p.y));
	}
	pp operator-(pp p) {
		return pp(add(x, -p.x), add(y, -p.y));
	}
	pp operator*(double d) {
		return pp(add(x, d), add(y, d));
	}
	double dot(pp p) {//内積
		return add(x*p.x, y*p.y);
	}
	double det(pp p) {//外積
		return add(x*p.y, -y * p.x);
	}
};

double dist(pp p, pp q) {//距離の二乗
	return (p - q).dot(p - q);
}

double distance(pp p, pp q) {
	return sqrt(dist(p, q));
}


bool cmp_x(const pp& p, const pp& q) {
	if (p.x != q.x)return p.x < q.x;
	return p.y < q.y;
}


//凸包
vector<pp>convex_full(pp* ps, int N) {
	sort(ps, ps + N, cmp_x);
	int k = 0;
	vector<pp>qs(N * 2);
	//下側凸包
	for (int i = 0;i < N;i++) {
		while (k > 1 && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0)k--;
		qs[k++] = ps[i];
	}
	//上側凸包
	for (int i = N - 2, t = k;i >= 0;i--) {
		while (k > t && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0)k--;
		qs[k++] = ps[i];
	}
	qs.resize(k - 1);
	return qs;
}

double Cosine_theorem(pp a, pp b, pp c) {//余弦定理　角Bが求めたい角度
	double ba = dist(a, b);
	double bc = dist(b, c);
	double ac = dist(a, c);
	double cos_sita = (ba + bc - ac) / (2.0 * sqrt(ba)*sqrt(bc));
	return cos_sita;
}

double get_vector_length(pp v) {//ベクトルのスカラー値
	return pow((v.x * v.x) + (v.y * v.y), 0.5);
}

double Angle(pp A, pp B, pp C)//内積から角度　角Bを求めたい
{
	double length_A = get_vector_length(B - A);
	double length_B = get_vector_length(B - C);

	double cos_sita = (B - A).dot(B - C) / (length_A * length_B);

	if (abs(cos_sita) > 1)return INF;
	else return cos_sita;
	double sita = acos(cos_sita);
}

double Helon(double x, double y, double z) {//ヘロンの公式
	double s = (x + y + z) / 2;
	return sqrt(s*(s - x)*(s - y)*(s - z));
}

pp a, b, c;
double mx, R, l, r, mid;

int main() {
	cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
	mx = max({ distance(a,b),distance(b,c),distance(a,c) });
	R = 2 * Helon(distance(a, b), distance(b, c), distance(a, c)) / (distance(a, b) + distance(b, c) + distance(a, c));
	r = R;
	for (int i = 0;i < 1000;i++) {
		mid = (l + r) / 2;
		if (mx*(R - mid) / R <= mid * 2)r = mid;
		else l = mid;
	}
	cout<<setprecision(16) << r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N[3];
    int i;
    for(i=0;i<3;i++){
    cin >> N[i] ;
    }
    sort(N,N+3);
    int ans = N[0] + N[1];
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
const int M=2*1e5+5;
int n,k,m,a[M],b[M],j,vis[M];
vector<vector<int> >v,u;
void dfs(int x)
{
	vis[x]=1;
	a[x]=j;
	for(int i=0;i<v[x].size();i++)
		if(!vis[v[x][i]])
			dfs(v[x][i]);
}
void DFS(int x)
{
	vis[x]=2;
	b[x]=j;
	for(int i=0;i<u[x].size();i++)
		if(vis[u[x][i]]!=2)
			DFS(u[x][i]);
}
int main()
{
	scanf("%d%d%d",&n,&k,&m);
	v.resize(n+1);
	u.resize(n+1);
	for(int i=0;i<k;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for(int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		u[x].push_back(y);
		u[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			++j;
			dfs(i);
		}
	for(int i=1;i<=n;i++)
		if(vis[i]!=2)
		{
			++j;
			DFS(i);
		}
	map<pair<int,int>,int>freq;	
	for(int i=1;i<=n;i++)
		freq[make_pair(a[i],b[i])]++;
	for(int i=1;i<n;i++)
		printf("%d ",freq[make_pair(a[i],b[i])]);
	printf("%d",freq[make_pair(a[n],b[n])]);
}

Measured memory_bytes: 28544
#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;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<string> vs;

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

  int n;
  cin >> n;
  int m=n, s=0;
  while(m>0){
    s+=m%10;
    m/=10;
  }

  printf(n%s==0 ? "Yes\n" : "No\n");

  return 0;
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define v(d_type) vector<d_type>
#define loop(i, s, n) for(int i = s; i < n; i++)
#define print_vec(X) loop(i, 0, X.size()) cout << X[i] << "\n"
#define nl "\n"
#define fat 1000000007

int main()
{
    boost;
    ll n;

    cin >> n;

    n--;
    
    ll ans = (n*(n + 1)) / 2;

    cout << ans << nl; 

    return 0;
}

Measured memory_bytes: 256
//?????????????????????????????????????????????
using System;

namespace DefaultNamespace
{
	/// <summary>
	/// Description of Class1.
	/// </summary>
	public class Class1
	{
		public static void Main(String[] args)
		{				
			new listArray();
                        
			//listA.start();
			//listA.finish();
		}
	
	}

	public class listArray
	{
		public int first = 0;
		public int last = 0;
		public int[] list = new int[1000000];
		
		public  listArray()
		{
			int n = int.Parse(Console.ReadLine());
			for (int i = 0; i < n; i++) {
				string com = Console.ReadLine();
				string[] command = com.Split();
				switch (command[0]) {
					case "insert":
						list[first] = int.Parse(command[1]);//first?????¨????????????first-1????????????????????\??£?????????
						first++;
						break;
					case"deleteFirst":
						//deleteFirst();
						first--;
						while (list[first - 1] == -1) {
							first--;
						}
					
						break;
					case"deleteLast":
						//deleteLast();
						
						last++;
						while (list[last] == -1) {
							last++;
						}
						
						break;
					case "delete":
						//delete(int.Parse(command[1]));
						for (int j = first - 1; j >= last; j--) {
							if (list[j] == int.Parse(command[1])) {
								list[j] = -1;//?????????????????????-1???????????????
								while (list[first - 1] == -1) {
									first--;
								}
								while (list[last] == -1) {
									last++;
								}
								break;
							}
						}
						
						
						break;				
				}
			}
			finish();
		}
		/*
		public void insert(int val)
		{
			list[first]=val;//first?????¨????????????first-1????????????????????\??£?????????
			first++;
		}
		
		public void deleteFirst()
		{
			first--;
			while(list[first-1]==-1)
			{
				first--;
			}
		}
		
		public void deleteLast()//last???????????\??£????????????
		{
			last++;
			while(list[last]==-1)
			{
				last++;
			}
		}
		
		public void delete(int val)
		{
			for(int j=first-1;j>=last;j--)
			{
				if(list[j]==val)
				{
					list[j]=-1;//?????????????????????-1???????????????
					while(list[first-1]==-1)
					{
						first--;
					}
					while(list[last]==-1)
					{
						last++;
					}
					return;
				}
			}
			return;
		}
		*/
		public void finish()
		{
			for (int k = first - 1; k > last; k--) {
				if (list[k] != -1) {
					Console.Write(list[k] + " ");
				}				
			}			
			Console.WriteLine(list[last]);	
		}
	}
}

Measured memory_bytes: 16448
#include<bits/stdc++.h>
using namespace std;
long long k,a,b,ji;               
int main()
{
    cin>>k>>a>>b;
    if(a>=k) {cout<<1<<"\n";return 0;}
    if(b>=a) {cout<<-1<<"\n";return 0;}
    if((k-a)%(a-b)>=1) ji=1;
    cout<<((k-a)/(a-b)+ji)*2+1;
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, m, d; cin >> n >> m >> d;
	if (d == 0) {
		cout << n * (m - 1) / (double)(n * n) << endl;
	}
	else {
		cout << (n - d) * (m - 1) * 2 / (double)(n * n) << endl;
	}
	return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (106)
ll n,m,grid[MAXN][MAXN],A[MAXN][MAXN],B[MAXN][MAXN];
vector<pi> v[MAXN];
int match[MAXN];//match[i]=index of edge from i
ll paired[MAXN];
bitset<MAXN>vis;
void bp() {
	mmst(match,-1);mmst(paired,-1);
	FOR(i,0,n-1){
		FOR(j,0,siz(v[i])-1)if(paired[v[i][j].f]==-1){
			paired[v[i][j].f]=i;
			match[i]=j;
			break;
		}
	}
	function<ll(ll)>dfs=[&](ll x){
		if(vis[x])return 0;
		vis[x]=1;
		ll co=0;
		for(auto i:v[x]){
			if(paired[i.f]==-1 || dfs(paired[i.f])){
				paired[i.f]=x;
				match[x]=co;
				return 1;
			}
			++ co;
		}
		return 0;
	};
	FOR(i,0,n-1)if(match[i]==-1)vis.reset(),dfs(i);
}
int main(){
	FAST
	cin>>n>>m;
	auto which_row=[&](ll x){
		return x/m;
	};
	FOR(i,0,n-1)FOR(j,0,m-1)cin>>grid[i][j],--grid[i][j];
	FOR(i,0,n-1)FOR(j,0,m-1){ll k=which_row(grid[i][j]);v[i].eb(k,grid[i][j]);}	FOR(i,0,n-1)shuffle(all(v[i]),rng);
	FOR(j,0,m-1){
		bp();
		FOR(i,0,n-1){
			assert(match[i]!=-1&&siz(v[i])>match[i]);
			A[i][j]=v[i][match[i]].s;
			v[i].erase(v[i].begin()+match[i]);
		}
	}
	FOR(i,0,n-1)assert(v[i].empty());
	FOR(i,0,n-1)FOR(j,0,m-1)cout<<A[i][j]+1<<" \n"[j==m-1];
	FOR(j,0,m-1){
		set<int>s;
		FOR(i,0,n-1)s.ins(which_row(A[i][j]));
		assert(s.size()==n);
	}
	FOR(j,0,m-1){
		FOR(i,0,n-1){
			B[which_row(A[i][j])][j]=A[i][j];
		}
	}
	FOR(i,0,n-1)FOR(j,0,m-1)cout<<B[i][j]+1<<" \n"[j==m-1];
}


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

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

    sort(a.begin(), a.end());
    int maxa = a[n - 1];
    sort(b.begin(), b.end());
    int current = n - 1, ans = 0;
    while (h > 0)
    {
        if (current < 0 || maxa >= b[current])
        {
            ans += h / maxa + (h % maxa != 0);
            h = 0;
            break;
        }
        else
        {
            h -= b[current];
            current -= 1;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <string>
#include <tuple>
using namespace std;

typedef long long LL;

#define FOR(i,a,b) for (int i=(a); i<(b); ++i)

int N;
char S[50];


map<tuple<int, int, string>, LL> memo;
LL go(int L, int R, string suf) {
if (suf.size() > R-L) return 0;
if (L == R) return suf.empty();

auto entry = tuple<int, int, string>(L, R, suf);
if (memo.find(entry) != memo.end()) return memo[entry];


LL result = 0;
if (!suf.empty()) {
if (S[L] == suf.back()) {
result += go(L+1, R, suf.substr(0, suf.size() - 1));
}
FOR(i,L+1,R) if (S[L] == S[i]) {
result += go(L+1,i,string(S+i+1,S+R)+suf);
}
} else {
FOR(i,L+1,R) if (S[L] == S[i]) {
result += 2*go(L+1,i,string(S+i+1,S+R));
}
}

return memo[entry] = result;
}


int main() {
	scanf("%d", &N);
	scanf("%s", S);
	printf("%lld\n", go(0,2*N,string()));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////


int main(){
    ll n;cin>>n;
    ll a[n],b[n];rep(i,0,n-1)cin>>a[i];
    rep(i,0,n-1)cin>>b[i];
    ll suma=0,sumb=0;
    rep(i,0,n-1){
        suma+=a[i];
        sumb+=b[i];
    }
    if(suma<sumb){
        cout<<-1;return 0;
    }
    vector<ll>plus;
    ll minus=0;
    ll ans=0;
    rep(i,0,n-1){
        if(a[i]>b[i]){
            plus.pb(a[i]-b[i]);
        }else if(a[i]<b[i]){
            minus+=b[i]-a[i];
            ans++;
        }
    }
    sort(plus.begin(),plus.end());
    reverse(plus.begin(),plus.end());
    
    if(minus>0)for(auto x:plus){
        ans++;
        minus-=x;
        if(minus<=0)break;
    }
    cout<<ans<<endl;
    
    return 0;
}






Measured memory_bytes: 2428
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    long long N,ai,i,fourCount,twoCount,oneCount;
    oneCount = 0;
    twoCount = 0;
    fourCount = 0;
    cin >> N;
    for (i= 0;i<N;i++){
        cin >> ai;
        if (ai % 4 == 0){
            fourCount++;
        }else if(ai % 2 == 0){
            twoCount++;
        }else{
            oneCount++;
        }
    }

    if((twoCount == 0 && fourCount >= oneCount - 1) || (twoCount > 0 && fourCount >= oneCount)){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384