akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

vi C(26), Last(26, -1), T(365);
vector<vi> S(365, vi(26));
vector<vi> table(365, vi(26));
ll ans = 0;
int D, M;

void Query(int d, int q) {
  int prev;
  prev = T.at(d);
  T.at(d) = q;
  ll sabun = 0;
  sabun += (S.at(d).at(q) - S.at(d).at(prev));

  sabun += table.at(d).at(q);
  table.at(d).at(q) = 0;
  for (int i = d + 1; i < D && table.at(i).at(q) != 0; i++) {
    sabun += table.at(i).at(q);
    table.at(i).at(q) = table.at(i - 1).at(q) + C.at(q);
    sabun -= table.at(i).at(q);
  }
  /*
  cout << "table " << q << ": ";
  REP(i, D) cout << table.at(i).at(q) << " ";
  cout << "\n";
  */

  table.at(d).at(prev) =
      (d == 0) ? C.at(prev) : table.at(d - 1).at(prev) + C.at(prev);
  sabun -= table.at(d).at(prev);
  for (int j = d + 1; j < D && table.at(j).at(prev) != 0; j++) {
    sabun += table.at(j).at(prev);
    table.at(j).at(prev) = table.at(j - 1).at(prev) + C.at(prev);
    sabun -= table.at(j).at(prev);
  }
  /*
  cout << "table " << prev << ": ";
  REP(i, D) cout << table.at(i).at(prev) << " ";
  cout << "\n";
  cout << "sabun = " << sabun << endl;
*/
  ans += sabun;
  // cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"

  cin >> D;
  REP(i, 26) cin >> C.at(i);
  REP(i, D) REP(j, 26) cin >> S.at(i).at(j);

  REP(i, D) { T.at(i) = i % 26; }

  for (int i = 0; i < D; i++) {
    REP(j, 26) {
      if (j == T.at(i)) {
        Last.at(j) = i;
        table.at(i).at(j) = 0;
      } else {
        table.at(i).at(j) = C.at(j) * (i - Last.at(j));
      }
    }
    // cout << count << endl;

    // cout << "T = " << T.at(i) << " S = " << S.at(i).at(T.at(i)) << endl;
    ans += S.at(i).at(T.at(i));
  }

  REP(i, D) {
    REP(j, 26) { ans -= table.at(i).at(j); }
  }
  /*
    REP(i, 26) {
      cout << "table " << i << ": ";
      REP(j, D) cout << table.at(j).at(i) << " ";
      cout << "\n";
    }
    cout << ans << endl;
  */

  random_device rnd;
  mt19937 mt((int)time(0));
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  // Query
  REP(i, 100) {
    ll pans = ans;
    vector<vi> oldtable = table;
    int d = rand365(mt), q = rand26(mt);
    // cout << d << " " << q << endl;
    int oq = T.at(d);
    Query(d, q);
    if (ans < pans) {
      ans = pans;
      T.at(d) = oq;
      table = oldtable;
    }
  }

  REP(i, D) cout << T.at(i) + 1 << endl;
  /*
std::random_device rnd;  // 非決定的な乱数生成器を生成
std::mt19937 mt(
    rnd());  //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
std::uniform_int_distribution<> rand100(0, 99);  // [0, 99] 範囲の一様乱数
for (int i = 0; i < 20; ++i) {
  std::cout << rand100(mt) << "\n";
}*/
}


Measured memory_bytes: 3792
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll h,w;
    ll n,x,m;
    ll a,b,d;
    multiset<int> s;
    cin>>str;
    rep(i,str.length()){
        if(i%2&&str[i]=='0') sum++; 
        else if(i%2==0&&str[i]=='1') sum++;
    }
        rep(i,str.length()){
        if(i%2&&str[i]=='1') f++; 
        else if(i%2==0&&str[i]=='0') f++;
    }
    cout<<min(sum,f);
}


Measured memory_bytes: 512
#include<stdio.h>

int main() {
    int i, bill, N, change;
    scanf("%d", &N);

    bill = N / 1000 ;
    if(N == 1000 * bill) {
        printf("0\n");
    } else {
        change = (1000 * (bill + 1)) - N;
        printf("%d\n", change);
    }
    return 0;
}

Measured memory_bytes: 1708
/*
 * test.cpp
 *
 *
 *      Author: Fireworks
 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cmath>
#include<bitset>
#include<set>
#include<iomanip>
#include<fstream>
#include<bitset>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<list>
#include<sstream>

using namespace std;

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<int,ii> iii2;
typedef pair<double,int> di;
typedef pair<ii,ii> iiii;
long long mod = 1000000007LL;
long long base = 37;
long long large = 1000000000000000000LL;

class UnionFind {
	private: vector<int> p,rank;
	public:
	UnionFind(int n){
		rank.assign(n,0);
		p.assign(n,0);
		for(int i=0;i<n;i++){
			p[i]=i;
		}
	}

	int findSet(int i){
		return (p[i]==i)?i:(p[i]=findSet(p[i]));
	}

	bool isSameSet(int i,int j){
		return findSet(i)==findSet(j);

	}

	void unionSet(int i,int j){
		if(!isSameSet(i,j)){
			int x=findSet(i),y=findSet(j);
			if(rank[x]>rank[y]){
				p[y]=x;
			}else{
				p[x]=y;
				if(rank[x]==rank[y]){
					rank[y]++;
				}
			}
		}
	}
};

int main(){

	int n;
	cin>>n;
	vector<int> x(n,0),y(n,0);
	for(int i=0;i<n;i++) cin>>x[i]>>y[i];
	vector<iii> a(n,iii(ii(0,0),0));
	for(int i=0;i<n;i++){
		a[i] = iii(ii(x[i],y[i]),i);
	}
	sort(a.begin(),a.end());
	vector<iii2> e;
	for(int i=0;i+1<n;i++){
		e.push_back(iii2(a[i+1].first.first-a[i].first.first,ii(a[i+1].second,a[i].second)));
	}
	a.clear();
	for(int i=0;i<n;i++){
		a.push_back(iii(ii(y[i],x[i]),i));
	}
	sort(a.begin(),a.end());
	for(int i=0;i+1<n;i++){
		e.push_back(iii2(a[i+1].first.first-a[i].first.first,ii(a[i+1].second,a[i].second)));
	}
	sort(e.begin(),e.end());

	UnionFind uf(n+10);
	int c = 0;
	for(int i=0;i<(int)e.size();i++){
		int u = e[i].second.first;
		int v = e[i].second.second;
		if(!uf.isSameSet(u,v)){
			uf.unionSet(u,v);
			c+=e[i].first;
		}
	}
	cout<<c<<endl;


	/*int totalcase;
	int testcase=0;
	cin>>totalcase;
	ofstream out;
	out.open("result.txt");

	while(totalcase--){
		testcase++;
		out<<"Case #"<<testcase<<": ";
		cout<<testcase<<": "<<endl;

		//GOGOGO


		//END
	}
	out.close();*/

	return 0;
}


Measured memory_bytes: 6900
import sys
import collections
class UnionFind:
    def __init__(self, size):
        self.parent = [-1] * (size + 1)  # 非負なら親ノード，負ならグループの要素数

    def root(self, x):  # root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        elif self.parent[self.parent[x]] < 0:
            return self.parent[x]
        else:
            self.parent[x] = self.root(self.parent[x])  # xをxの根に直接つなぐ
            return self.parent[x]

    def merge(self, x, y):  # merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]:  # xの要素数がyの要素数より「小さい」とき入れ替える
            x, y = y, x
        self.parent[x] += self.parent[y]  # xの要素数を更新
        self.parent[y] = x  # yをxにつなぐ
        return True

    def issame(self, x, y):  # same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)

    def size(self, x):  # size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]
sys.setrecursionlimit(100000000)

N,M = list(map(int,input().split(" ")))
Ps =  list(map(int,input().split(" ")))
u = UnionFind(N)
for i in range(M):
    a,b = list(map(int, input().split(" ")))
    u.merge(a,b)
ans = 0
for i in range(1,N + 1):
    if u.root(i) == u.root(Ps[i-1]):
        ans += 1
print(ans)



Measured memory_bytes: 85996
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<assert.h>
#define gc getchar()
#define lint long long
#define N 300010
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int pl[N],sr[N];char s[N];
int main()
{
	int n=inn(),ans=n;scanf("%s",s+1);
	for(int i=1;i<=n;i++)
		pl[i]=pl[i-1]+(s[i]=='W');
	for(int i=n;i>=1;i--)
		sr[i]=sr[i+1]+(s[i]=='E');
	for(int i=1;i<=n;i++)
		ans=min(ans,pl[i-1]+sr[i+1]);
	return !printf("%d\n",ans);
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned int ui;
typedef unsigned long long ul;
#define ri register int
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define FO(x) { freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout); }
using namespace std;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef vector<int> vi;
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define G \
	struct node { int v; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v) { e[++z].v = v; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v) { adde(u, v); adde(v, u); }
#define W \
	struct node { int v, w; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v, int w) { e[++z].v = v; e[z].w = w; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v, int w) { adde(u, v, w); adde(v, u, w); }
inline int _() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while('0' <= ch && ch <= '9');
	return ret;
}
inline void _(int x) // x >= 0
{
	if(x < 10) { putchar(x + '0'); return ; }
	_(x / 10); putchar(x % 10 + '0');
}
void What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
}
/* Default Code Ends Here. */

#define maxn 100100
int n;
int a[maxn];
int b[maxn];
unordered_map<int, bool> m1, m2;

int main()
{
	What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us();
	
	cin >> n;
	enum(i, 1, n)
		cin >> a[i];
	memcpy(b, a, sizeof b);
	sort(b + 1, b + n + 1);
	enum(i, 1, n)
		m1[a[i]] = i & 1;
	enum(i, 1, n)
		m2[b[i]] = i & 1;
	int Ans = 0;
	enum(i, 1, n)
		if(m1[a[i]] ^ m2[a[i]])
			Ans ++;
	cout << Ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 9252
#include<stdio.h>
#include <string.h>
int main()
{
	int n,k,a,b;
	scanf("%d%d",&n,&k);
	a=n%k;
	if(a>0){
		b=1;
		printf("%d\n",b);
	}
	else {
		b=0;
		printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(void) {
  double N, C, p = 0, temp;
  cin >> N >> C;
  N++;
  for (int i = 0; i < C; i++) {
    cin >> temp;
    p += temp;
  }
  cout << ceil(p/N) << endl;
  return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

vector<ll> fac(3000001); //n!(mod M)
vector<ll> ifac(3000001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
};

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

int main() {
  ll n;
  cin >> n;
  mint ans=mpow(2,n)-1;
  fac[0] = 1;
  ifac[0] = 1;
  for(ll i = 0; i<3000000; i++){
    fac[i+1] = fac[i]*(i+1) % mod; // n!(mod M)
    ifac[i+1] = ifac[i]*mpow(i+1, mod-2) % mod; // k!^{M-2} (mod M) ←累乗にmpowを採用
  }
  ll a,b;cin >> a >> b;
  mint ma=1,mb=1;
  rep(i,a){
      ma*=n;
      n--;
  }
  n+=a;
  rep(i,b){
      mb*=n;
      n--;
  }
  n+=b;
  ma*=ifac[a],mb*=ifac[b];
  ans=ans.x-ma.x-mb.x;
  cout << ans.x<< endl;
}

Measured memory_bytes: 50096
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    string s, t;
    cin >> s >> t;
    for (size_t i = 0; i < s.size(); i++) {
        if (s.at(i) != t.at(i)) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    string s, t, u; 
    cin >> s >> t >> a >> b >> u;
    cout << a - (s == u) << " " << b - (t == u) << "\n";
    return 0;
}

Measured memory_bytes: 256
import itertools

if __name__ == '__main__':

	n,m = map(int,input().split())

	A =[]
	for i in range(n):
		A.append(list(map(int,input().split())))

	P = list(itertools.product([1,-1],repeat=3))

	maxval = 0

	for p in P:
		B=[]
		for a in A:
			val = (a[0] * p[0]) + (a[1] * p[1]) + (a[2] * p[2])
			B.append(val)

		#結果をソートして上位ｍ番目までの合計を計算する	
		C = sorted(B,reverse=True)
		maxval = max(maxval,sum(C[:m]))

	print(maxval)


Measured memory_bytes: 3444
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(dead_code)]
pub const M: i64 = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        m: usize,
        x: [i64;n],
        y: [i64;m]
    }

    let mut x_sum = 0i64;
    for i in 0..n {
        let mut delta = (2 * i as i64 - n as i64 + 1) * x[i];
        delta %= M;
        if delta < 0 {
            delta += M;
        }
        x_sum += delta;
        x_sum %= M;
    }

    let mut y_sum = 0i64;
    for i in 0..m {
        let mut delta = (2 * i as i64 - m as i64 + 1) * y[i];
        delta %= M;
        if delta < 0 {
            delta += M;
        }
        y_sum += delta;
        y_sum %= M;
    }
    let mut ret = x_sum * y_sum;
    ret %= M;
    println!("{}", ret);
}

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

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    int da=abs(x-a);
    int db=abs(x-b);
    if(da>db)
    cout << 'B' << endl;
    else
    cout << 'A' << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
const int N = 100010;
int n;
char s[N];
int id[N];
vector<int>pos;
int main(){
	scanf("%s",s + 1);
	n = strlen(s + 1);
	if(s[1] == '0' || s[n] == '1')return puts("-1"),0;
	for(int i = 1;i <= n/2;++i){
		if(s[i] != s[n - i])return puts("-1"),0;
		if(s[i] == '1'){
			pos.push_back(i);
			pos.push_back(n - i);
		}
	}
	sort(pos.begin(),pos.end());
	pos.push_back(n);
	for(int i = 0;i < pos.size() - 1;++i)
		for(int j = pos[i];j < pos[i + 1];++j)printf("%d %d\n",j,pos[i + 1]);
	return 0;
}

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

int n,d[1001];
bool D[1000000]={};

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

  reverse(d,d+n);

  for(int i=0;i<n;i++){
    int num=d[i],k=1;
    D[num]=true;
    for(int j=i+1;j<n;j++){
      if(k>4)break;
      num+=d[j]*pow(10,k);
      D[num]=true;
      k++;
    }
  }
  for(int i=0;i<100000;i++){
    if(!D[i]){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int count = 0;
    for (int i = 0; i < n; i++) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) {
            count++;
            if (count == 3) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            count = 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

bool is(ll n)
{
        string x = to_string(n);
        rep(i, 0, len(x)/2) {
                if (x[i] != x[len(x)-1-i]) return false;
        }
        return true;
}

int main()
{
        ll A, B;
        cin >> A >> B;
        ll ans = 0;
        rep(i, A, B+1) {
                if (is(i)) ++ ans;
        }
        cout << ans << endl;
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    s.push_back(s[0]);
    s.erase(0,1);
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        int[] A = new int[n];
        double voteSum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            voteSum += a[i];
        }
        Arrays.sort(a);
        for (int j = 0; j < m; j++) {
            if (a[n - j - 1] >= voteSum / (4 * m)) {
            } else {
                System.out.println("No");
                System.exit(0);
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 35936
import math
#import itertools
#import statistics
#import numpy as np
#import collections
#n = int(input())
n, m = list(map(int, input().split()))
#a = list(map(int, input().split()))
a = []
b = []
c = []
d = []

for i in range(n):
    x,y = [int(j) for j in input().split()]
    a.append(x)
    b.append(y)

for i in range(m):
    x,y = [int(j) for j in input().split()]
    c.append(x)
    d.append(y)

for i in range(n):
    dist_min = 1000000000
    dist_index = n+m
    for j in range(m):
        dist = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if dist <= dist_min:
            if dist!=dist_min:
                dist_index = j
            dist_min = dist

        
        #print("dist="+str(dist)+" distmin="+str(dist_min)+" distidx="+str(dist_index))
    print(dist_index+1)



Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define in insert
#define sz(v) v.size()
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const ll INF = 1e18 + 5;

void solve(){
    int n;
    cin>>n;
    vi v(n+1);
    vi s;
    for(int i=1;i<=n;i++) cin>>v[i];
    int cnt=0;
    for(int i = 2; i < n; i++){
        s.clear();
        s.pb(v[i-1]);
        s.pb(v[i]);
        s.pb(v[i+1]);
        sort(all(s));
        if(s[1]==v[i]) cnt++;
    }
    cout<<cnt;
}
int main(){
    int T=1;        //! COMMENT IF THERE IS NO TEST CASES
    //cin>>T;             
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

S = input()

for i in range(2):
    if S[i] == S[i+1] == S[i+2]:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3064
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInts	>>= putStrLn . which "Yes" "No" . all odd

Measured memory_bytes: 380
#include <iostream>

using namespace std;

int main() {
  int N;
  int A[100];
  
  cin >> N;
  for (int i=0; i<N; i++) cin >> A[i];
  
  bool flag = true;
  int cnt = 0;
  while (flag) {
    flag = false;
    for (int i=N-1; i>=1; i--) {
      if (A[i] < A[i-1]) {
        int tmp = A[i];
        A[i] = A[i-1];
        A[i-1] = tmp;
        cnt++;
        flag = true;
      }
    }
  }
  for (int i=0; i<N; i++) cout << (i != 0 ? " " : "") << A[i];
  cout << endl << cnt << endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    int n,k;cin>>n>>k;
    vi h(n);rep(i,n)cin>>h[i];
    ll dp[100005];mem(dp,1000000);
    dp[0]=0;
    for(int i=1;i<n;++i){
        for(int j=1;j<=k;++j){
            if(i>=j){
                dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(){
  char s[100000];
  int flag=0;

  scanf("%s",s);

  int i=0;
  while(s[i]!='\0'){
    if((i+1)%2){
      if(s[i]=='L')flag=1;
    }else{
      if(s[i]=='R')flag=1;
    }
    if(flag){
      printf("No\n");
      return 0;
    }
    i++;
  }

  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__);
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(string, a, b);
    while(a.length() < 102) a.insert(a.begin(), '0');
    while(b.length() < 102) b.insert(b.begin(), '0');
    Cout(a < b ? "LESS" : a > b ? "GREATER" : "EQUAL")
}


Measured memory_bytes: 256
import java.util.Scanner;


/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int D = in.nextInt();
        if (A*B < C*D) {
            System.out.println(C*D);
        }else {
            System.out.println(A*B);
        }
    }
}


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

using namespace std;
int main(){
    //freopen("in", "r", stdin);

    int v,e;
    cin >> v >> e;
    const long INF = (1L << 32);
    vector<vector<long>> dp(v,vector<long>(v,INF));
    for (int i = 0; i < v; ++i)for (int j = 0; j < v; ++j) dp[i][j] = ((i == j) ? 0:INF);
    for (int i = 0; i < e; ++i) {
        int s,t,cost;
        cin >> s >> t >> cost;
        dp[s][t] = cost;
    }

    for (int k = 0; k < v; ++k) {
        for (int i = 0; i < v; ++i) {
            if (dp[i][k] == INF) continue;
            for (int j = 0; j < v; ++j) {
                if (dp[k][j] == INF) continue;
                dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
            }
        }
    }

    for (int i = 0; i < v; ++i) if (dp[i][i] < 0) { cout << "NEGATIVE CYCLE" << endl;return 0;}
    for (int i = 0; i < v; ++i){
        for (int j = 0; j < v; ++j) {
            if(j)cout << " ";
            if (dp[i][j] == INF)
                cout << "INF";
            else
                cout << dp[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

int n;
ll ans,r,g,b,rb,rg,gr,gb,br,bg;
char s[5000];

int main()
{
    scanf("%d%s",&n,s);
    for(int i=1;i<n;i++)
        for(int j=0;j+2*i<n;j++)
            if(s[j]!=s[j+i]&&s[j]!=s[j+i+i]&&s[j+i]!=s[j+i+i]) ans--;
    for(int i=0;i<n;i++)
        if(s[i]=='R') ans+=gb+bg,rg+=g,rb+=b,r++;
        else if(s[i]=='G') ans+=br+rb,gb+=b,gr+=r,g++;
        else if(s[i]=='B') ans+=rg+gr,br+=r,bg+=g,b++;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3840
n = int(input())
ab = [input().split() for _ in [0]*n]
a = [int(i) for i, j in ab][::-1]
b = [int(j) for i, j in ab][::-1]
ans = 0
for i in range(n):
    a[i] += ans
    if a[i] % b[i] != 0:
        ans += b[i] - (a[i] % b[i])
print(ans)


Measured memory_bytes: 49080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()

int main() {
    int N;
    cin >> N;
    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 && i % 5 == 0)
            continue;
        else if (i % 3 == 0)
            continue;
        else if (i % 5 == 0)
            continue;
        else
            sum += (ll)i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3640
N, A, B, C, D = gets.chomp.split(" ").map(&:to_i)
s = []
s = gets.chomp.split("")

# すぬけ君の初期位置と可能性
sunuke = {:name => "sunuke", :point => A - 1, :able => nil, :goal => C - 1}
# ふぬけ君の初期位置と可能性
funuke = {:name => "funuke", :point => B - 1, :able => nil, :goal => D - 1}


$batton = true

def kenken(walker, stopping, s)
  if walker[:point] == walker[:goal] then
    # p "able true"
    # p walker[:name]
    $batton = false
    walker[:able] = true
    true
  elsif (walker[:point] + 1 == stopping[:point] && s[walker[:point] + 2] == "#"  || \
        walker[:point] + 2 == stopping[:point] && s[walker[:point] + 1] == "#") && \
        stopping[:point] != stopping[:goal] then
    $batton = false
    true

  elsif walker[:point] > 0 && $batton && s[walker[:point] + 2] == "#" \
        && s[walker[:point] - 1] == "." && s[walker[:point] + 1] == "." then
    $batton = false
    # p walker[:name]
    # p "..."
    true
  elsif s[walker[:point] + 1] == "." && (walker[:point] + 1 != stopping[:point]) then
    walker[:point] += 1
    #$batton = true
    # p walker[:name]
    # p walker[:point] + 1
    false
  elsif s[walker[:point] + 2] == "." && (walker[:point] + 2 != stopping[:point]) then
    walker[:point] += 2
    #$batton = true
    # p walker[:name]
    # p walker[:point] + 1
    false
  else
    #$batton = false
    walker[:able] = false
    # p "able false"
    # p walker[:name]
    false
  end
end

until sunuke[:able] && funuke[:able] do
  if kenken(funuke, sunuke, s) then
    until sunuke[:able] && funuke[:able] do
      if kenken(sunuke, funuke, s) then
        kenken(funuke, sunuke, s)
        break
      end
      if sunuke[:able] == false || funuke[:able] == false
        break
      end
    end
  end
  if sunuke[:able] == false || funuke[:able] == false
    break
  end
end

if sunuke[:able] && funuke[:able] then
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 16764
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 100001;
const int mod = 1000000007;

int main(){
    int n;
    ll k;
    cin>>n>>k;
    ll a[n];
    fr(i,n)cin>>a[i];

    bool dp[k+1];
    dp[0] = 0;

    for(int i = 1; i <= k; i++){
        dp[i] = 0;
        for(int j=0; j < n; j++){
            if(i >= a[j])dp[i] = dp[i] || (!dp[i-a[j]]);
        }
    }

    if(dp[k])cout<<"First\n";
    else cout<<"Second\n";

}


Measured memory_bytes: 384
N = gets.to_i
A_1 = gets.split.map(&:to_i)
A_2 = gets.split.map(&:to_i)

max = A_1.inject(&:+)
N.times do |i|
  sum = A_1.slice(0..i).inject(&:+)
  sum += A_2[i..-1].inject(&:+)

  max = [max, sum].max
end

puts max

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string s;
	string t;
	cin>>s>>t;
	int dp[3001][3001]={};
	int n=s.size(), m=t.size();
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
			if(s[i-1]==t[j-1]) dp[i][j]=max(dp[i][j], dp[i-1][j-1]+1);
		}
	}
	int i=n, j=m;
	string ans;
	while(dp[i][j]>0){
		if(s[i-1]==t[j-1] && dp[i-1][j-1]+1==dp[i][j]){
			ans+=s[i-1];
			i--; j--;
		}else if(dp[i][j]==dp[i][j-1]){
			j--;
		}else{
			i--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, l[112345], r[112345];

    cin >> n;
    REP(i, n)
    cin >> l[i] >> r[i];

    vector<P> vl, vr;

    REP(i, n)
    {
        vl.push_back({l[i], i});
        vr.push_back({r[i], i});
    }

    SORT(vl);
    SORT(vr);

    reverse(vl.begin(), vl.end());

    ll res = 0;

    ll tmp = 0;

    REP(i, n)
    {
        tmp += vl[i].first;
        res = max(tmp, res);
        tmp += -vr[i].first;
        res = max(tmp, res);
    }

    tmp = 0;

    REP(i, n)
    {
        tmp += -vr[i].first;
        res = max(tmp, res);
        tmp += vl[i].first;
        res = max(tmp, res);
    }

    cout << res * 2 << endl;

    return 0;
}

Measured memory_bytes: 2804
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/

int k, a, b;
signed main() {
	cin >> k >> a >> b;
	if (a - b <= 0 && a < k)cout << -1 << endl;
	else if (a - b <= 0 || k <= a)cout << 1 << endl;
	else {
		cout << ((k - a - 1) / (a - b) + 1) * 2 + 1 << endl;
	}
	endre;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b))?(b):(a))
#define chmin(a, b) a = (((a)<(b))?(a):(b))

const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool contain(int mask, int position){
  if((mask&(1<<position))) return true;
  else return false;
}

// GCD,LCMを求める関数
ll gcd(ll a,ll b){
	if(a%b==0) return(b);
	else return(gcd(b,a%b));
}
ll lcm(ll a, ll b){
	return a*b/gcd(a,b);
}


signed main(){
	int n; cin>>n;
  string s; cin>>s;
  int ans = 0;
  rep(i,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
kawaisou = 0
if a == b and b != c:
    kawaisou = 1
elif b == c and c != a:
    kawaisou = 1
elif c == a and a != b:
    kawaisou = 1
    
if kawaisou == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
//
// Created on 2020/05/03.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans = 0;
    int n,m;
    cin>>n>>m;
    vector<int>high(n);
    vector<vector<int>>edge(n,vector<int>());

    for (int i = 0; i < n; ++i) {
        cin>>high[i];
    }
    for (int j = 0; j < m; ++j) {
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for (int k = 0; k < n; ++k) {
        bool ok = true;
        for (int i = 0; i < edge[k].size(); ++i) {
            if(high[edge[k][i]] >= high[k]){
                ok = false;
                break;
            }
        }
        if(ok) ans ++;
    }

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


Measured memory_bytes: 8800
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

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

  string s; cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)
n = int(input())
nodes = [[] for _ in range(n+1)]
done = [1 for _ in range(n+1)]
mod = int(1e9+7)
def dfs(next):
    w=1
    b=1
    for v in nodes[next]:
        if done[v]:
            done[v]=0
            white,black= dfs(v)
            w *= white+black
            b *= white
            w%=mod
            b%=mod
    return (w,b)
 
for i in range(n-1):
    a,b = map(int,input().split())
    nodes[a].append(b)
    nodes[b].append(a)
done[1]=0
 
ans = dfs(1)
print(sum(ans)%mod)

Measured memory_bytes: 100532
s=input()
n=len(s)-1

for i in range(2**n):
    ans=int(s[0])
    p=str(s[0])

    for j in range(n):
        if((i>>j)&1):
            ans += int(s[j+1])
            p=p+'+'+s[j+1]
        else:
            ans -= int(s[j+1])
            p=p+'-'+s[j+1]
    if ans==7:
        print(p+'=7')
        break

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    
    int A=sc.nextInt();
    int B=sc.nextInt();
    int C=sc.nextInt();
    int D=sc.nextInt();
    
    if((A*B)>(C*D)){
      System.out.println(A*B);
    }else if((A*B)<(C*D)){
      System.out.println(C*D);
    }else{
      System.out.println(A*B);
    }
  }
}

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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e3 + 5;
bool isPrime[MAXN];

void sevie() {
    memset(isPrime, 1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i * i <= MAXN; i++) {
        if (isPrime[i]) {
            for (ll j = i * 2; j <= MAXN; j += i) {
                isPrime[j] = 0;

            }
        }
    }
}

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (b%2==0) {
        return (fastPow((x * x)%mod, b / 2))%mod;
    } else
        return (x * fastPow((x * x)%mod, (b - 1) / 2))%mod;
}

//__builtin_popcount ();
bool isPrim(int n) {
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}
ll nck(ll n,ll k)
{
    if(k>n-k)
        k=n-k;
    ll res=1;
    for(int i=1;i<=k;i++)
    {
        res=res*(n-i+1);
        res%=mod;
        res*=fastPow(i,mod-2)%mod;
        res%=mod;
    }
    return res%mod;
}
int main() {
    FAST
   ll n, a, b;
    cin >> n >> a >> b;
    ll ansP=fastPow(2,n)-1;
    ll ans1=(nck(n,a)+mod)%mod;
    ll ans2=(nck(n,b)+mod)%mod;
    cout<<(((((ansP-ans1)%mod)-ans2)%mod)+mod)%mod<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <algorithm>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 400010;

int n, p, V, X[N];
int tor[N][20], tol[N][20];
int dpl[N], dpr[N], cnt[N];

int main(){
	scanf("%d%d", &n, &V);
	For(i, 1, n) scanf("%d", &X[i]);
	X[0] = -2e9, X[n + 1] = 2e9;
	For(i, 0, 19){
		int l = 1;
		For(j, 1, n) 
			if(1ll * X[j + 1] - X[j] > V){
				For(k, l, j) tol[k][i] = l, tor[k][i] = j;
				l = j + 1;
			}
		tor[n + 1][i] = tor[0][i] = n + 1;
		tol[0][i] = tor[n + 1][i] = 0;
		if(!V){
			p = i;
			break;
		}
		V >>= 1;
	}
	int S = (1 << p) - 1;
	dpl[0] = 0;
	For(i, 1, S){
		dpl[i] = 0;
		For(j, 1, p) if(i & (1 << (j - 1))) dpl[i] = max(dpl[i], tor[dpl[i ^ (1 << (j - 1))] + 1][j]);
	}
	dpr[0] = n + 1;
	For(i, 1, S){
		dpr[i] = n + 1;
		For(j, 1, p) if(i & (1 << (j - 1))) dpr[i] = min(dpr[i], tol[dpr[i ^ (1 << (j - 1))] - 1][j]);
	}
	For(i, 0, S){
		int L = dpl[i] + 1, R = dpr[S ^ i] - 1;
		if(tor[L][0] >= R) cnt[tol[L][0]]++, cnt[tor[R][0] + 1]--;
	}
	For(i, 1, n){
		cnt[i] += cnt[i - 1];
		if(cnt[i]) puts("Possible");
		else puts("Impossible");
	}
	return 0;
}

Measured memory_bytes: 43008