akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    let mut a_s = Vec::with_capacity(n);

    let mut a: usize = 200000;
    if m != 0 {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        a = buf.trim().parse().unwrap();
    }
    else {
    }
    let mut cur_m = 1;

    for i in 0..n {
        // println!("{} {}", i, a);
        if i == a {
            a_s.push(false);

            if cur_m < m {
                let mut buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
                a = buf.trim().parse().unwrap();
                cur_m += 1;
            }
        }
        else {
            a_s.push(true);
        }
    }

    let mod_n = 1000000007usize;

    let mut dp = vec![0; n];

    for i in (0..n).rev() {
        // println!("{} {}", i, a_s[i]);

        if a_s[i] == false {
            continue;
        }

        if i == n-1 {
            dp[i] = 1;
        }
        else if i == n-2 {
            dp[i] = dp[i+1] + 1;
        }
        else {
            dp[i] = (dp[i+1] + dp[i+2]) % mod_n;
        }

        // println!("  {} {}", sum, sum_local);
    }

    println!("{}", dp[0]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

template< typename flow_t >
struct FordFulkerson{
  struct edge {
    int to;
    flow_t cap;
    int rev;
    bool isrev;
  };

  vector<vector<edge>> graph;
  vector<int> used;
  const flow_t INF;

  FordFulkerson(int V):graph(V),used(V),INF(numeric_limits<flow_t>::max()) {}

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

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

  flow_t max_flow(int s,int t){
    flow_t flow=0;
    for(;;){
      for(int i=0;i<graph.size();i++) used[i]=0;

      flow_t f=dfs(s,t,INF);
      if(f>0) flow+=f;
      else return flow;
    }
  }
};

const int INF=1e8;

int main(){
  int H,W;
  cin>>H>>W;
  vector<string> S(H);
  rep(i,H) cin>>S[i];

  FordFulkerson<int> graph(H+W+5);
  int s=H+W;
  int t=s+1;
  for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
          if(S[i][j]=='S'){
              graph.add_edge(s,i,INF);
              graph.add_edge(s,H+j,INF);
          }else if(S[i][j]=='T'){
              graph.add_edge(i,t,INF);
              graph.add_edge(H+j,t,INF);
          }else if(S[i][j]=='o'){
              graph.add_edge(i,H+j,1);
              graph.add_edge(H+j,i,1);
          }
      }
  }

  int flow=graph.max_flow(s,t);
  if(flow>=INF) cout<<-1<<endl;
  else cout<<flow<<endl;

  return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int pp[26];

/* Trie */

struct Trie{
  int val;
  int val2;
  int depth;
  Trie *next[26];
  Trie *warp,*warp_back,*back;
  
  Trie():val(0),val2(0),warp_back(this),back(this) { memset(next,0,sizeof(next)); }
  
  void insert(string &s,int i=0){
    val++; //接頭辞のカウント
    depth = i;
    
    if(s[i]){
      int al = s[i]-'a';
      
      if(next[al]==NULL){
        next[al] = new Trie;
        next[al]->warp = NULL;
        next[al]->back = this;
      }
      
      next[al]->insert(s,i+1);
    }else{
      val2++; //終端のカウント
    }
  }
  
  int find(string &s,int last_val = INF){
    int ret = 0;
    
    if(val == 1) return 0;
    
    if(val == last_val){
      warp_back = back->warp_back;
      back->warp_back->warp = this;
    }

    if(warp && warp!=this){
      return warp->find(s,val);
    }
    
    if(s[depth]){
      int al = s[depth]-'a';

      for(int j=0;pp[j]!=al;j++){
        if(next[pp[j]]) ret += next[pp[j]]->val;
      }
      
      if(next[al])
        return ret + val2 + next[al]->find(s,val);
      else
        return ret + val2;
      
    }else{
      return 0;
    }
  }
};


int main(){
  int n,q;
  char in[400001];
  string s[SIZE];
  Trie trie;
  
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%s",in);
    s[i] = in;
    trie.insert(s[i]);
  }

  scanf("%d",&q);

  int k;
  char p[27];
  
  for(int i=0;i<q;i++){
    scanf("%d%s",&k,p);

    for(int j=0;j<26;j++){
      pp[j] = p[j]-'a';
    }

    printf("%d\n",trie.find(s[k-1])+1);
  }
  
  
  return 0;
}


Measured memory_bytes: 102016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    double a;
    cin >> a;
    cout << 6.28318530717958623200 * a << endl;
}

Measured memory_bytes: 3788
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    print(n**3)
    return

#B
def B():
    n = II()
    a = LI()
    b = LI()
    c = LI()
    ans = 0
    for i in range(n):
        ans += b[a[i] - 1] + (c[a[i] - 1] if i != n - 1 and a[i] + 1 == a[i + 1] else 0)
    print(ans)
    return

#C
def C():
    n = II()
    b = LI()
    ans = b[0]
    for i in range(n-1):
        if b[i] >= b[i + 1]:
            ans += b[i + 1]
        else:
            ans += b[i]
    print(ans)
    return

#D
def D():
    n, k = LI()
    s = S()
    a = []
    for i in range(n):
        if i == n - 1:
            a.append(s[i])
        elif s[i] != s[i + 1]:
            a.append(s[i])
    print(min(n - 1, n - len(a) + 2 * k))
    return

#E
def E():
    return

#F
def F():
    return


#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 49776
#include <bits/stdc++.h>
#define ld long double
#define int long long
#define fi first
#define se second
using namespace std;
const int N = 2e5 + 12;
const int inf = 2e9;




void run() {
    int x;
    cin >> x;
    if (x % 1000 == 0)
        cout << 0;
    else
        cout << 1000 - x % 1000;

}

signed main() {
    #ifdef local
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int test;
    run();
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S, T; cin >> S >> T;
    int n = S.size();

    const int m = 26;
    vector<vi> G(m, vi(m));

    rep(i, n){
        int a = S[i] - 'a';
        int b = T[i] - 'a';
        G[a][b] = true;
    }

    bool res = true;
    rep(i, m){
        int cnti = 0;
        int cnto = 0;
        rep(j, m){
            if(G[i][j]) cnto++;
            if(G[j][i]) cnti++;
        }
        res &= (cnti <= 1 and cnto <= 1);
    }

    cout << (res ? "Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 916
from collections import Counter
ans = 0
H, W, M = map(int, input().split())
HW = set()
Hlist, Wlist = [], []
for _ in range(M):
    h, w = map(int, input().split())
    Hlist.append(h)
    Wlist.append(w)
    HW.add((h,w))

cntH = Counter(Hlist)
cntW = Counter(Wlist)

maxhk, maxhv = cntH.most_common()[0]
ans = max(ans, maxhv)
for i in range(1,1+W):
    tmp = cntW[i]
    if (maxhk, i) in HW:
        tmp -= 1
    ans = max(ans, tmp+maxhv)

maxwk, maxwv = cntW.most_common()[0]
ans = max(ans, maxwv)
for i in range(1,1+H):
    tmp = cntH[i]
    if (i, maxwk) in HW:
        tmp -= 1
    ans = max(ans, tmp+maxwv)

print(ans)


Measured memory_bytes: 227808
#include<bits/stdc++.h>
using namespace std;
int main()
{   int a,b;
	cin>>a>>b;

	if(a==b)
    cout<<"Draw";

	else if(a==1)
	cout<<"Alice";
    else if(a>b&&b!=1)
    cout<<"Alice";
	else
    cout<<"Bob";

	return 0;
}



Measured memory_bytes: 3624
n = int(input())
xs = list(map(lambda x: int(x) - 1, input().split()))
a = 0
ys = set(range(n))
while ys:
    i = ys.pop()
    j = xs[i]
    if xs[j] == i:
        a += 1
        ys.remove(j)
print(a)


Measured memory_bytes: 16996
import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B

import           Data.Array.IArray
import           Data.Array.IO
import           Data.Array.MArray

readi :: B.ByteString -> Int
readi bs | Just (n, _) <- B.readInt bs = n

preOrder :: Int -> Array Int [Int] -> [Int]
preOrder (-1) _ = []
preOrder n    a = [n] ++ preOrder l a ++ preOrder r a
  where
    [l, r] = a ! n

inOrder :: Int -> Array Int [Int] -> [Int]
inOrder (-1) _ = []
inOrder n    a = inOrder l a ++ [n] ++ inOrder r a
  where
    [l, r] = a ! n

postOrder :: Int -> Array Int [Int] -> [Int]
postOrder (-1) _ = []
postOrder n    a = postOrder l a ++ postOrder r a ++ [n]
  where
    [l, r] = a ! n

main :: IO ()
main = do
    n <- readLn :: IO Int
    let f [a,b,c] = (a, [b, c])
    xss <- fmap (f. fmap readi . B.words) . B.lines <$> B.getContents
    -- xss :: [(Int, [Int])]

    let ac = array (0, n-1) xss :: Array Int [Int]

    apM <- newArray (0, n-1) (-1) :: IO (IOUArray Int Int)
    forM_ xss $ \(i, cs) -> do
        forM_ cs $ \c -> do
            when (c /= -1) $ writeArray apM c i
    ap <- freeze apM :: IO (Array Int Int)

    let root = fst . head . filter ((== -1) . snd) $ assocs ap

    putStrLn "Preorder"
    putStrLn . (' ':) . unwords . fmap show $ preOrder root ac
    putStrLn "Inorder"
    putStrLn . (' ':) . unwords . fmap show $ inOrder root ac
    putStrLn "Postorder"
    putStrLn . (' ':) . unwords . fmap show $ postOrder root ac



Measured memory_bytes: 3860
#include <iostream>

using namespace std;

int main()
{
  double v;
  while (cin >> v)
  {
    double t = v / 9.8;
    double y = 4.9 * t * t;
    
    int N = (y + 5) / 5 + 1;
	cout << N << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1224
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
ll modpow(ll a, ll n, ll mod = MOD) {
    ll res = 1;
    while(n > 0) {
        if(n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> ans(k + 1, 0);
    vector<ll> dp(k + 1, 0);
    for(ll i = 1; i <= k; i++) {
        dp[i] = modpow(k / i, n);
    }

    for(ll x = k; x >= 1; x--) {
        ans[x] = dp[x];
        for(int j = 1; x + j * x <= k; j++) {
            ans[x] -= ans[x + j * x];
            ans[x] = (ans[x] + MOD) % MOD;
        }
    }
    ll sum = 0;
    for(int i = 0; i < k; i++) {
        sum += (i + 1) * ans[i + 1];
        sum %= MOD;
    }
    cout << sum << endl;
}


Measured memory_bytes: 4840
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
    int a, b;
} pair;

int paircmp(const void *a, const void *b) {
    pair c = *(pair *)a, d = *(pair *)b;
    if (c.a < d.a) return -1;
    else if (c.a == d.a && c.b < d.b) return -1;
    else if (c.a == d.a && c.b == d.b) return 0;
    else return 1;
}

int main(void) {
    int i, N, X;
    pair p[100010];
    long long K;
    scanf("%d%lld", &N, &K);
    for (i=0;i<N;i++) scanf("%d%d", &p[i].a, &p[i].b);

    qsort(p,N,sizeof(pair),paircmp);
    for (i=0;i<N && K>0;i++) {
        if (K>p[i].b) K -= p[i].b;
        else {
            X = p[i].a; break;
        }
    }

    printf("%d\n", X);
    return 0;
}

Measured memory_bytes: 1788
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([1]*n)
cnt = np.array([0]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] < h[b-1]:
        high[a-1] *= 0
    
    elif h[a-1] > h[b-1]:
        high[b-1] *= 0
    
    else:
        high[a-1] *= 0
        high[b-1] *= 0

ans = np.count_nonzero(high==1)

print(ans)

Measured memory_bytes: 38592
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6+1)
input=stdin.readline

n,q=map(int,input().split())
a=[[] for _ in range(n)]
for _ in range(q):
    c,*t=map(int,input().split())
    if c==0:
        a[t[0]].append(t[1])
    elif c==1:
        print(*a[t[0]])
    else:
        a[t[0]].clear()
    #print(*a)


Measured memory_bytes: 29760
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// doot diddly donger cuckerino Hahahahahah
// Created by White Knife on 15/04/20.
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC target("popcnt")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           (long long) (x).size()
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> range(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << range(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template <typename T> T gcd(T x, T y) { return (y == 0) ? x : gcd(y, x % y); }
template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// @formatter:on


class AWeLoveGolf {
public:
  
  void solveOne(istream &cin, ostream &cout) {
  
  }
  
  void solve(std::istream &cin, std::ostream &cout) {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = 1; i < 1000; ++i) {
      if (a <= k * i and k * i <= b) {
        cout << "OK" << '\n';
        return;
      }
    }
    cout << "NG\n";
  }
};

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
	AWeLoveGolf solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int parent[100001];
int length[100001];
int   club[100001]={0};
int A[200001],B[200001],C[200001];
int main(void)
{
	int N,M,K;
	
	int x,y;
	int i;
	int cnt=0;
	
	bool flg=false;
	
	cin>>N>>M>>K;
	
	for(i=1;i<=K;i++){
		cin>>A[i]>>B[i]>>C[i];
	}
	
	for(i=1;i<=N;i++){
		length[i]=1;
		parent[i]=i;
	}
	
	for(i=1;i<=K;i++){
		if(A[i]==1){
			
			x=B[i];
			
			while(x!=parent[x]){
				x=parent[x];
			}
			
			y=C[i];
			
			while(y!=parent[y]){
				y=parent[y];
			}
			
			if(x!=y){
				
				if(length[x]>length[y]){
					parent[y]=x;
					if(club[y]==0){
						club[y]=club[x];
					}
					else if(club[y]!=0&&club[x]!=0&&
							club[y]!=club[x]){
								cnt=i;
								flg=true;
								break;
							}
				}
				else if(length[x]<length[y]){
					parent[x]=y;
					if(club[x]==0){
						club[x]=club[y];
					}
					else if(club[x]!=0&&club[y]!=0&&
							club[x]!=club[y]){
								cnt=i;
								flg=true;
								break;
							}
				}
				else{
					parent[y]=x;
					length[x]++;
					if(club[x]==0){
						club[x]=club[y];
					}
					else if(club[x]!=0&&club[y]!=0&&
							club[x]!=club[y]){
								cnt=i;
								flg=true;
								break;
							}
				}
			}
		}
		else{
			y=B[i];
			
			while(y!=parent[y]){
				y=parent[y];
			}
			
			if(club[y]==0||club[y]==C[i]){
				club[y]=C[i];
			}
			else{
				cnt=i;
				flg=true;
				break;
			}
		}
	}
	
	cout<<((flg)?cnt:0)<<endl;
	return 0;
}

				
	
	


Measured memory_bytes: 6612
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


int main(){
    int A,B;
    cin >> A >>B;
    cout << (B-3+A)/(A-1) << endl;



}

Measured memory_bytes: 3588
import sys
ds = sys.stdin.readlines()
for d in ds:
    L = list(map(int, d.split(',')))
    l = sum(L[:-2])
    t = l/(L[-1] + L[-2])
    x = t * L[-2]
    for i in range(10):
        x = x - L[i]
        if x <= 0:
            print(i+1)
            break

Measured memory_bytes: 7556
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

#define int long long

int n, k;
int dp[1010][1010];

int poyo(int i=0, int uyu=1011)
{
  int& ret = dp[i][uyu];
  if (i == n) return 1;
  if (ret != -1) return ret;
  
  ret = 0;
  
  REP(j, k){
    if (uyu == j) continue;
    ret += poyo(i + 1, j);
  }

  return ret;
}

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

  cin >> n >> k;

  memset(dp, -1, sizeof(dp));
  cout << poyo() << endl;
}



Measured memory_bytes: 8320
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp
/*
??????
0-1 ???????????¶????????????
????????? vi ????????? wi ??§??????????????? N ??????????????¨???????????? W ??????????????¶????????????????????????
?¬?????????¶?????????????????????????????????????????§???????????¶???????????\????????????

???????????????????????????????¨??????§???????????????????????????
???????????????????????????????????? W ????¶?????????????
?????????????¨?????????§???????±??????????????????????

*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, W; cin >> N >> W;
	vector<ll> v(N), w(N);
	for (int i = 0; i < N;i++) cin >> v[i] >> w[i];

	/*
	vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
	for (int i = 0; i < N;i++) {
		for (int j = 0; j <= W;j++) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if (j + w[i] <= W) {
				dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
			}
		}
	}
	cout << dp[N][W] << endl;
	*/

	vector<ll> dp(W + 1, 0);
	for (int i = 0; i < N;i++) {
		for (int j = W; j >= 0;j--) {
			if (j + w[i] <= W) {
				dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
			}
		}
	}
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3232
from math import factorial

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

x,y=map(int, input().split())

if y < x:
    tmp=y
    y=x
    x=tmp

if (y-x) > x or (x-(y-x))%3 !=0:
    print(0)
    exit()

mo12=0
mo21=0

if y != x:
    tmp=y-x
    y-=2*tmp
    x-=tmp
    mo12=tmp

mo12+=y/3
mo21+=y/3

print(comb(int(mo12+mo21), int(mo21), 1000000007))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;


vl pow_;
void pow_ini(ll n) {
	pow_.clear();
	pow_.push_back(n);
	rep(j, 62) {
		ll nxt = pow_[j] * pow_[j];
		nxt %= mod;
		pow_.push_back(nxt);
	}
	return;
}

ll pow1(ll k) {
	ll ans = 1;
	rep(ntmp, 62) {
		if ((k >> ntmp) % 2 == 1) {
			ans *= pow_[ntmp];
			ans %= mod;
		}
	}
	return ans;
}

vl fact;
vl fact_inv;

void fact_ini(ll n) {
	fact.resize(n + 1);
	fact[0] = 1;
	for (ll i = 1; i <= n; i++) {
		ll fact_tmp = fact[i - 1] * i;
		fact_tmp %= mod;
		fact[i] = fact_tmp;
	}
	fact_inv.resize(n + 1);
	pow_ini(fact[n]);
	fact_inv[n] = pow1(mod - 2);
	for (ll i = n - 1; i >= 0; i--) {
		fact_inv[i] = fact_inv[i + 1] * (i + 1);
		fact_inv[i] %= mod;
	}
}

ll nPm(ll n, ll m) {
	assert(m >= 0);
	assert(n < fact.size());
	assert(n >= m);
	ll ans = fact[n] * fact_inv[n - m];
	ans %= mod;
	return ans;
}

ll nCm(ll n, ll m) {
	assert(m >= 0);
	assert(n < fact.size());
	assert(n >= m);
	ll ans = fact[n] * fact_inv[m];
	ans %= mod;
	ans *= fact_inv[n - m];
	ans %= mod;
	return ans;
}

int main() {
	fact_ini(220000);
	ll S;
	cin >> S;
	ll ans = 0;
	ll k = 1;
	while (1) {
		ll n = S - 3*k;
		if (n < 0)
			break;
		ll m = k - 1;
		ans += nCm(n + m, m);
		ans %= mod;
		k++;
	}


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

Measured memory_bytes: 6552
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define srep(i,s,t) for (ll i = s; i < t; ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    ll ans = 1;
    if(n >= 3)ans++;

    srep(i, 2, 10000000){
        if(i * i > n)break;
        if(i * i == n){
            ans++;
            break;
        }
        if(n % i == 0){
            ll k = n / i;
            ll kk = i;
            ll nn = n;
            while(nn >= k){
                if(nn % k == 0)nn /= k;
                else nn = nn % k;
            }
            if(nn == 1)ans++;
            nn = n;
            k = kk;
            while(nn >= k){
                if(nn % k == 0)nn /= k;
                else nn = nn % k;
            }
            if(nn == 1)ans++;
        }
    }

    srep(i, 2, 10000000){
        if(i * i > n - 1)break;
        if(i * i == n - 1){
            ans++;
            break;
        }
        if((n - 1) % i == 0){
            ans += 2;
        }
    }

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


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	vector<ll> A(N);
	ll S = 0, m = INF;
	int minus = 0, zero = 0;
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		S += abs(A[i]);
		if(A[i] < 0) minus++;
		else if(A[i] == 0) zero++;
		m = min(m, abs(A[i]));
	}
	if(zero != 0 || minus % 2 == 0) {
		cout << S << endl;
		return 0;
	}
	else {
		cout << S - 2 * m << endl;
		return 0;
	}
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int R, C; cin >> R >> C;
	int N; cin >> N;
	int xstart, ystart; cin >> xstart >> ystart;
	string S, T; cin >> S >> T;
	int xlo = 1, xhi = R, ylo = 1, yhi = C; // inclusive range of A winning
	for (int i = N-1; i >= 0; i--) {
		assert(xlo <= xhi && ylo <= yhi);

		switch (T[i]) {
			case 'L':
				yhi++;
				break;
			case 'R': 
				ylo--;
				break;
			case 'U':
				xhi++;
				break;
			case 'D':
				xlo--;
				break;
			default: assert(false);
		}

		assert(xlo <= xhi && ylo <= yhi);

		xlo = max(xlo, 1);
		xhi = min(xhi, R);
		ylo = max(ylo, 1);
		yhi = min(yhi, C);

		assert(xlo <= xhi && ylo <= yhi);

		//cerr << xlo << '-' << xhi << ' ' << ylo << '-' << yhi << '\n';

		switch (S[i]) {
			case 'L':
				ylo++;
				break;
			case 'R': 
				yhi--;
				break;
			case 'U':
				xlo++;
				break;
			case 'D':
				xhi--;
				break;
			default: assert(false);
		}

		//cerr << xlo << '-' << xhi << ' ' << ylo << '-' << yhi << '\n';

		if (!(xlo <= xhi && ylo <= yhi)) {
			cout << "NO" << '\n';
			exit(0);
		}

		assert(xlo <= xhi && ylo <= yhi);
	}

	bool good = (xlo <= xstart && xstart <= xhi) && (ylo <= ystart && ystart <= yhi);
	cout << (good ? "YES" : "NO") << '\n';

	return 0;
}


Measured memory_bytes: 920
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, t := scanInt(), scanInt()
	ans := 1 << 60
	for i := 0; i < n; i++ {
		c, a := scanInt(), scanInt()
		if t >= a {
			ans = min(ans, c)
		}
	}
	if ans == 1<<60 {
		fmt.Fprintln(wr, "TLE")
	} else {
		fmt.Fprintln(wr, ans)
	}
}


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

int main() {
   	int n,d;
	cin>>n>>d;
	long long int arr[n][2];
	for(int i=0;i<n;i++)
	cin>>arr[i][0]>>arr[i][1];
	int res=0;
	for(int i=0;i<n;i++)
	{
	   long long int p= arr[i][0];
	   long long  int q=arr[i][1];
	   long long int sum=p*p+q*q;
	    if(sqrt(sum)<=d)
	    res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 6764
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        // int n=sc.nextInt();
        char c[]=sc.nextString().toCharArray();
        long n=sc.nextLong(),x=0;
        char ans='1';
        for (int i=0; i<min(c.length,n); i++) {
            if(c[i]!='1'){ ans=c[i];break;}
        }

        out.println(ans);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 22356
#include <stdio.h>
#include <string.h>

bool w[1000000];
int a[1000000];

int main()
{
	for(int i = 0; i < 1000000; i++)
	{
		w[i] = true;
	}
	int all = 0;
	a[0] = 0;
	a[1] = 0;
	for(int i = 2; i < 1000000; i++)
	{
		if(w[i])
		{
			all++;
			for(int j = 2; i * j < 1000000; j++)
			{
				w[i * j] = false;
			}
		}
		a[i] = all;
	}
	while(1)
	{
		int n;
		if(EOF == scanf("%d",&n))
		{
			break;
		}
		printf("%d\n",a[n]);
	}
	return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pll a, pll b){
    return a.first*b.second<a.second*b.first;
}

const ll mod = 1e9+7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}

int main(){
    //clock_t tm = clock();
    fastio;
    int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct Combination{
	const int MAX = 5000010;
	vector<fint64> FAC;
	vector<fint64> INV;
	vector<fint64> FAC_INV;
	Combination() {
		FAC = vector<fint64>(MAX);
		INV = vector<fint64>(MAX);
		FAC_INV = vector<fint64>(MAX);
		FAC[0] = INV[1] = FAC_INV[0] = 1;
		for(int i = 1; i < MAX; ++i) {
			FAC[i] = FAC[i-1] * i % MOD;
			if(i > 1) INV[i] = MOD - INV[MOD % i] * (MOD / i) % MOD;
			FAC_INV[i] = FAC_INV[i - 1] * INV[i] % MOD;
		}
	}
	fint64 C(int n, int r){
		if(n < 0 or r < 0 or n<r) return 0;
		return FAC[n] * FAC_INV[r] % MOD * FAC_INV[n-r] % MOD;
	}
	fint64 P(int n, int r){
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[n-r] % MOD;
	}
	fint64 H(int n, int r){
		if(r == 0) return 1;
		return C(n+r-1, r);
	}
};

int main() {
	Combination<MOD> com;
	int n,k; cin>>n>>k;
	int b=k,r=n-k;
	for(int i=1;i<=k;i++){
		cout<<com.C(b-1,i-1)%MOD*com.H(i+1, r-(i-1))%MOD<<endl;
	}
	return 0;
}

Measured memory_bytes: 117504
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner parameter = new Scanner(System.in);

        String[] input = parameter.nextLine().split(" ");

        Integer parameter1 = Integer.valueOf(input[0]);
        Integer parameter2 = Integer.valueOf(input[1]);

        if ((parameter1 + parameter2) % 2 == 0) {

        	System.out.println((parameter1 + parameter2) / 2);
        } else {

        	System.out.println("IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 21844
s = list(input())

s1 = s[:len(s)//2]
s2 = s[-(-len(s)//2):][::-1]

cnt = 0
while True:
    if s1 == s2:
        break
    for i in range(len(s1)):
        if s1[i] != s2[i]:
            s1[i] = s2[i]
            cnt += 1

print(cnt)

Measured memory_bytes: 9044
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        bool f[100][100];
        int l[100];
        int ln;
        fill_n(*f,100*100,false);
        for(int i=0;i<n;i++){
            int m;
            scanf("%d",&m);
            for(int j=0;j<m;j++){
                int to;
                scanf("%d",&to);
                to--;
                f[i][to]=true;
            }
        }
        scanf("%d",&ln);
        for(int i=0;i<ln;i++){
            scanf("%d",&l[i]);
            l[i]--;
        }
        int ans=-1;
        for(int i=0;i<n;i++){
            bool flag=true;
            for(int j=0;j<ln;j++){
                flag&=f[i][l[j]];
            }
            if(flag){
                if(ans==-1)ans=i;
                else if(ans!=-100){
                    ans=-100;
                }
            }
        }
        if(ans==-1||ans==-100)puts("-1");
        else printf("%d\n",ans+1);
    }
    return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	ll k, a, b; cin >> k >> a >> b;
	if (k <= a) {
		cout << 1 << endl;
		return 0;
	}
	if (a - b <= 0) {
		cout << -1 << endl;
		return 0;
	}
	ll ans = 2 * ((k - a) / (a - b));
	if ((k - a) % (a - b) != 0) ans += 2;
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
#define ll long long
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> //lower_bound , upper_bound
// using namespace __gnu_pbds;//kth smallest : *pd.find_by_order(k-1) , no. of elem < X : pd.order_of_key(X) , delete X : pd.erase(X).
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl '\n'
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod=(1e+9)+7;
const ll sz = 2e5+9;
ll gcd(ll a,ll b) {if(b==0)return a;return gcd(b,a%b);}
ll power(ll a,ll b,ll m = mod) {ll res = 1;while(b>0){if(b&1)res = (res*a)%m;b = b>>1;a = (a*a)%m;}return res;}
#define maxheap priority_queue<ll>
#define minheap priority_queue <ll, vector<ll>, greater<ll>>
#define nude(a)           \
    for (auto i : a)      \
        cout << i << " "; \
    cout << nl; \

ll fun(vector<vector<ll>> &dp,ll i,ll j,ll n, ll k){
    if(i==n || j==k || dp[i][j]==0) return 0LL;
    if(dp[i][j]==-1){
        dp[i][j]=(fun(dp,i+1,j,n,k)%mod+fun(dp,i,j+1,n,k)%mod)%mod;
    }
    return dp[i][j];
}



void solve()
{
   ll n,k;
   cin>>n>>k;
   vector<vector<ll>> dp(n,vector<ll>(k,-1));
   vector<string> v;
   string s;
   f(i,0,n) {
       cin>>s;
       v.pb(s);
       f(j,0,k) if(s[j]=='#') dp[i][j]=0;
   }
   if(dp[n-1][k-1]==0) cout<<0<<nl;
   else{
       dp[n-1][k-1]=1;
       cout<<fun(dp,0,0,n,k)<<nl;
   }

}
 
int main()
{
    #ifdef JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    clock_t beg = clock();
    solve();
    clock_t end = clock();
    fprintf(stderr, "%.3f sec, Copyright %c 2019 PyThor. \n", double(end - beg) / CLOCKS_PER_SEC , 184);
    return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

const int sqr = 700;
int n, q, arr[500005], ans[500005], l, r, occ[500005], cur;
vpii Q;

bool cmp(pii a, pii b) {
	if (a.f.f/sqr != b.f.f/sqr) return a.f.f < b.f.f;
	return (a.f.f/sqr % 2 ? a.f.s < b.f.s : a.f.s > b.f.s);
}

void add(int x) {
	occ[arr[x]]++;
	cur += (occ[arr[x]] == 1);
}

void rem(int x) {
	occ[arr[x]]--;
	cur -= (occ[arr[x]] == 0);
}

int main() {
	fastio; cin >> n >> q;
	FOR(i, 1, n) cin >> arr[i];
	FOR(i, 1, q) {
		int a, b; cin >> a >> b;
		Q.pb(pii(pi(a, b), i));
	}
	sort(all(Q), cmp);
	for (auto it:Q) {
		int a = it.f.f, b = it.f.s, idx = it.s;
		while (r < b) add(++r);
		while (l > a) add(--l);
		while (r > b) rem(r--);
		while (l < a) rem(l++);
		ans[idx] = cur;
	}
	FOR(i, 1, q) cout << ans[i] << "\n";
}


Measured memory_bytes: 15616
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int n ,k;
    cin >> n >> k ;
    vector<int> snk(n);

    FOR(i, 0, k) {
        int d,a;
        cin >> d;
        FOR(j, 0, d) {
            cin >> a;
            snk[a-1]++;
        }
    }

    int ans = 0;
     FOR(i, 0, n) {
         if(snk[i]==0)ans++;
     }

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

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


int main()
{
    string S, T;
    cin >> S >> T;
    T.erase(T.size()-1, 1);

    if(S == T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n - m + 1):
  for j in range(n - m + 1):
    isMatch = True
    for k in range(m):
      for l in range(m):
        if a[i + k][j + l] != b[k][l]:
          isMatch = False
    if isMatch == True:
      print("Yes")
      exit()
print("No")


Measured memory_bytes: 3060
#include <stdio.h>
#define mod 1000000007
int H, W, K, fact[300000], inv[300000], factinv[300000];
int ncr(int n, int r) { return (n - r >= 0 && r >= 0) ? 1LL * fact[n] * factinv[r] % mod * factinv[n - r] % mod : 0; }
int cal(int a, int b) { return (ncr(a + b, b) - ncr(a + b, b - 1) + mod) % mod; }
int main() {
	scanf("%d%d%d", &H, &W, &K);
	fact[0] = 1;
	for (int i = 1; i < 300000; i++) fact[i] = 1LL * fact[i - 1] * i % mod;
	inv[1] = 1;
	for (int i = 2; i < 300000; i++) inv[i] = 1LL * inv[mod % i] * (mod - mod / i) % mod;
	factinv[0] = 1;
	for (int i = 1; i < 300000; i++) factinv[i] = 1LL * factinv[i - 1] * inv[i] % mod;
	int ret = 0;
	for (int i = 0; i <= K; i++) {
		int tx = i;
		int ty = K - i;
		int res = 1LL * cal(W + tx, tx) * cal(H + ty, ty) % mod * ncr(H + W + 2 * K, W + 2 * tx) % mod;
		ret = (ret + res) % mod;
	}
	printf("%d\n", ret);
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()

using pii=pair<int,int>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }

string S;
int Len;
bool used[500];
int dfs(int n){
  if(n==Len) return Len;

  //まずm
  if(S[n]!='m') return Len;
  used[n]=true;
  //CAT
  n++;
  bool rt=true;
  //mが見つかるたび潜る
  while(n<Len&&S[n]=='m'){
    n=dfs(n);
  }
  //次はe
  if(n>=Len||S[n]!='e') return Len;
  used[n]=true;
  n++;
  //mが見つかるたび潜る
  while(n<Len&&S[n]=='m'){
    n=dfs(n);
  }
  //最後はw
  if(n>=Len||S[n]!='w') return Len;
  used[n]=true;
  n++;
  return n;
}

bool solve(){
  cin >> S;
  Len = S.size();
  rep(i,Len) used[i]=false;
  auto res = dfs(0);
  if(res!=Len) return false;

  rep(i,Len) if(!used[i]) return false;
  return true;
}

int main(){
  out(solve()?"Cat":"Rabbit");
}



Measured memory_bytes: 3212