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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;

const int N=2e5+100;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int a,b,c;
    int k;
    cin>>a>>b>>c>>k;
    while(a>=b){
        if(!k) break;
        k--;
        b*=2;
    }
    while(b>=c){
        if(!k) break;
        k--;
        c*=2;
    }
    //cout<<a<<" "<<b<<" "<<c<<e
    if(c>b&&b>a) puts("Yes");
    else puts("No");
    return 0;
}



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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (a >= 13 ? b : a >= 6 ? b / 2 : 0) << endl;
}


Measured memory_bytes: 3640
N = int(input())
A = set(map(int,input().split()))

while len(A) > 1:
  min_A = min(A)
  next_A = set([min_A])
  for i in A:
    B = i % min_A
    if B != 0:
      next_A.add(B)
  A = list(next_A)
print(list(A)[0])

Measured memory_bytes: 20012
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a == 1 {
		a += 13
	}
	if b == 1 {
		b += 13
	}

	if a > b {
		fmt.Println("Alice")
	} else if a < b {
		fmt.Println("Bob")
	} else {
		fmt.Println("Draw")
	}
}


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

using ll = long long int;

ll k, a, b;

ll ans;

int main(void) {
  // Here your code !
  scanf("%lld %lld %lld", &k, &a, &b);

  if (b > a + 2) {
    if (a - 1 > k) {
      ans = 1 + k;
    }
    else {
      ll remain = k - (a - 1);

      ans = a + (remain / 2) * (b - a) + (remain % 2);
    }
  }
  else {
    ans = 1 + k;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

int h,w;
vector<vector<int> > A;

int dijkstra(){
  typedef tuple<int,int,int,int> T;
  typedef vector<vector<int> > V;
  vector<V> D(w,V(h,vector<int>(w*h+1,INF)));
  priority_queue<T,vector<T>,greater<T> > Q;
  Q.push(T(0,0,0,0));
  D[0][0][0] = 0;
  
  int dx[] = {0,0,1,-1};
  int dy[] = {1,-1,0,0};
  int res = INF;
  while(!Q.empty()){
    int cost,x,y,dis; tie(cost,x,y,dis) = Q.top();Q.pop();
    
    if(D[x][y][dis] < cost) continue;
    if(dis && D[x][y][dis-1] <= D[x][y][dis]) continue;
    if(x == w - 1 && y == h - 1){ Min(res,cost - dis); continue;}
    
    for(int i=0;i<4;i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
      int ndis = dis + 1;
      int ncost = cost + 2*A[ny][nx]*dis + A[ny][nx] + 1;
      if(ndis > h*w) continue;
      if(D[nx][ny][ndis] <= ncost) continue;
      Q.push(T(ncost,nx,ny,ndis));
      D[nx][ny][ndis] = ncost;
    }
    
  }
  return res;
}

signed main(){
  cin>>h>>w;
  A = vector<vector<int> >(h,vector<int> (w));
  cin>>A;
  
  int ans = dijkstra();
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 17208
//    https://www.youtube.com/watch?v=Dx6OQ7RvDXc

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))
int main()
{
    fast;
    ll t,n,m,i,j,k,l,temp,flag,len,shit,ans=inf;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++) cin>>a[i];
    for(i=1;i<=100;i++){
        for(j=0,temp=0;j<n;j++){
            temp+=((a[j]-i)*(a[j]-i));
        }
        ans=min(ans,temp);
    }
    cout<<ans;
}


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



int main() {
	string s;
	cin >> s;
	int YM = atoi(s.substr(0, 2).c_str());
	int MY = atoi(s.substr(2, 2).c_str());

	bool h1 = false, h2 = false;

	if (12 >= YM && YM >= 1) h1 = true;
	if (12 >= MY && MY >= 1) h2 = true;

	if (h1 && h2) {
		cout << "AMBIGUOUS";
	}
	else if (!h1 && !h2) {
		cout << "NA";
	}
	else if (!h1 && h2) {
		cout << "YYMM";
	}
	else {
		cout << "MMYY";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
from collections import defaultdict

n=int(input())
a=[int(x) for x in input().split()]
d=defaultdict(int)
for i in a:
    d[i]+=1
#print(d)
b=[[-2,0],[-1,0]]
for i in d:
    b.append([i,d[i]])
b.sort()

ans=1
m=len(b)
for i in range(m):
    ans=max(ans,b[i][1])
    if i+1<m and b[i][0]+1==b[i+1][0]:
        ans=max(ans,b[i][1]+b[i+1][1])
    if i+2<m and b[i][0]+1==b[i+1][0] and b[i+1][0]+1==b[i+2][0]:
        ans=max(ans,b[i][1]+b[i+1][1]+b[i+2][1])
print(ans)

Measured memory_bytes: 16864
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll a[100],p[100];

ll f(int N,ll X){
  if(X==0) return 0;
  else if(N==0) return 1;
  else if(X==1) return 0;
  else if(X<=1+a[N-1]) return f(N-1,X-1);
  else if(X==2+a[N-1]) return p[N-1]+1;
  else if(X<=2+2*a[N-1]) return p[N-1]+1+f(N-1,X-2-a[N-1]);
  else return 2*p[N-1]+1;
}

int main(){
  a[0]=1; p[0]=1;
  for(int i=1;i<=50;i++){
    a[i]=a[i-1]*2+3;
    p[i]=p[i-1]*2+1;
  }
  
  int N;
  ll X;

  cin>>N>>X;

  cout<<f(N,X)<<endl;
}


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

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


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

int main() 
{
  int N , A , B;
  cin >> N >> A >> B;
  int plan1 = N * A;
  int plan2 = B;
  
  if (plan1 > plan2) cout << plan2 << endl;
  if (plan1 < plan2) cout << plan1 << endl;
  if (plan1 == plan2) cout << plan1 << endl;
  
}

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

using namespace std;

#define EPS (1e-10)

class Point {
public:
	double x, y;
	Point(double x, double y) :
			x(x), y(y) {
	}

	Point operator -(Point p) {
		return Point(x - p.x, y - p.y);
	}

	double norm() {
		return x * x + y * y;
	}
};

class Segment {
	Point p1, p2;
	Segment(Point p1, Point p2) :
			p1(p1), p2(p2) {
	}
};

double dot(Point p1, Point p2) {
	return p1.x * p2.x + p1.y * p2.y;
}
double cross(Point p1, Point p2) {
	return p1.x * p2.y - p1.y * p2.x;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ON_SEGMENT = 0;
static const int ONLINE_FRONT = -2;

int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0;
	Point b = p2 - p0;
	if (cross(a, b) > EPS)
		return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS)
		return CLOCKWISE;
	if (dot(a, b) < -EPS)
		return ONLINE_BACK;
	if (a.norm() < b.norm())
		return ONLINE_FRONT;

	return ON_SEGMENT;
}

bool intersect(Point p0, Point p1, Point p2, Point p3) {
	return ccw(p0, p1, p2) * ccw(p0, p1, p3) <= 0 && ccw(p2, p3, p0) * ccw(p2, p3, p1) <= 0;
}
int main() {

	int q;
	scanf("%d", &q);

	for (int i = 0; i < q; ++i) {
		int p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
		scanf("%d %d %d %d %d %d %d %d", &p1x, &p1y, &p2x, &p2y, &p3x, &p3y, &p4x, &p4y);
		Point p1(p1x, p1y);
		Point p2(p2x, p2y);
		Point p3(p3x, p3y);
		Point p4(p4x, p4y);

		if (intersect(p1, p2, p3, p4)) {
			cout << 1 << endl;
		} else {
			cout << 0 << endl;
		}
	}

	return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    int N, K; cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];
    sort(rall(h));
    int cnt = 0;
    rep(i, N) {
        if (h[i] >= K) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;

}

Measured memory_bytes: 640
#include <cstdio>
#define maxn 100010
char s[maxn], t[maxn];
int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	int n, m;
	scanf("%d%d%s%s", &n, &m, s, t);
	int x, y, g;
	long long l;
	g = gcd(n, m);
	l = (long long) n * m / g;
	x = n / g, y = m / g;
	bool valid = true;
	for(int i = 0; i < g; ++i) if(s[i * x] != t[i * y]) valid = false;
	printf("%lld", valid ? l : -1);
}

Measured memory_bytes: 384
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [s, w] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  putStrLn $ if s <= w then "unsafe" else "safe"

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N;
  cin >> N;
  for(LL x1=1;x1<=3500;++x1){
	for(LL x2=1;x2<=3500;++x2){
	  LL y = 4 * x1 * x2 - N * x2 - N * x1;
	  if(y > 0 && N * x1 * x2 % y == 0){
		LL x3 = N * x1 * x2 / y;
		cout << x1 << " " << x2 << " " << x3 << endl;
		return 0;
	  }
	}
  }

  return 0;
}


Measured memory_bytes: 256
#if 0
2019.12.25

首先默认将三元组 (a, b, c) 替换为二元组 (e=b-a, f=c-a) （先默认所有人拿金币）。
然后问题转换为在 n 个二元组中选 y 个获得 e 收益，选 z 个获得 f 收益，最大化总收益。
对于两个二元组 (e[i], f[i]), (e[j], f[j]) 假设 i 选 f 且 j 选 e ，
考虑什么时候交换他们的选择收益不会变少，也就是 e[i] + f[j] >= e[j] + f[i] ，
移项得 e[i] - f[i] >= e[j] - f[j] ，那么通过排序使得二元组按 e - f 单调不降，
就有对于任意 i < j ，如果 i 选 f 且 j 选 e ，那么交换两者状态一定不会变差。
换言之，存在最优解满足选 e 的全在选 f 的左边，
也就是说存在一个 k 使得有最优解在 1 到 k 中取 y 个 e 在 k + 1 到 n 中取 z 个 f 。
那么只需要通过优先队列预处理出每个前缀前 y 大的 e 的和以及每个后缀前 z 大的 f 的和。
然后枚举 k 即可得出答案。
#endif
#include <cstdio>
#include <algorithm>
#include <queue>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 100005;
struct obj {
	int a, b;
};
obj ob[maxn];
ll lget[maxn], rget[maxn];

int main() {
	int x = read, y = read, z = read;

	int n = x + y + z;
	ll ans = 0;
	for(int i = 1; i <= n; i ++) {
		int v = read;
		ans += v;
		ob[i].a = read - v;
		ob[i].b = read - v;
	}

	std::sort(ob + 1, ob + n + 1, [](obj x, obj y) {
				return x.a - x.b > y.a - y.b;
			});

	/* debug("%lld\n", ans); */
	/* for(int i = 1; i <= n; i ++) */
	/* 	debug("%d %d\n", ob[i].a, ob[i].b); */

	std::priority_queue<int, std::vector<int>, std::greater<int> > biggest;

	for(int i = 1; i <= n; i ++) {
		lget[i] = lget[i - 1] + ob[i].a;
		biggest.push(ob[i].a);
		if(int(biggest.size()) > y) {
			lget[i] -= biggest.top();
			biggest.pop();
		}
	}

	while(!biggest.empty()) biggest.pop();
	for(int i = n; i; i --) {
		rget[i] = rget[i + 1] + ob[i].b;
		biggest.push(ob[i].b);
		if(int(biggest.size()) > z) {
			rget[i] -= biggest.top();
			biggest.pop();
		}
	}

	/* for(int i = 1; i <= n; i ++) */
	/* 	debug("l=%lld r=%lld\n", lget[i], rget[i]); */

	ll max = - 1000000000000000000;
	for(int k = y; k <= n - z; k ++)
		max = std::max(max, lget[k] + rget[k + 1]);

	printf("%lld\n", ans + max);
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
using namespace std;
int INF = 1e10;

signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ret = 1;
    for(int i = 0;i < N - 1;i++) {
        if(S.at(i) != S.at(i + 1)) {
            ret++;
        }
    }
    cout << ret << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll res1 = 0, res2 = 0, sum = 0;
  rep(i, n) {
    sum += a[i];
    int goal = pow(-1, i % 2);
    res1 += max(0LL, 1 - 1 * goal * sum);
    sum = (i % 2 == 0) ? max(sum, 1LL) : min(sum, -1LL);
  }
  sum = 0;
  rep(i, n) {
    sum += a[i];
    int goal = pow(-1, i % 2 + 1);
    res2 += max(0LL, 1 - 1 * goal * sum);
    sum = (i % 2 == 1) ? max(sum, 1LL) : min(sum, -1LL);
  }
  cout << min(res1, res2) << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ld INF = (ld)10000000000000;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
map<int, int> mp;
vector<int> u;
int main() {
	int n, m; cin >> n >> m;
	vector<int> a, b;
	rep(i, n) {
		int z; cin >> z; a.push_back(z);
		mp[z]++; u.push_back(z);
	}
	rep(i, m) {
		int z; cin >> z; b.push_back(z);
		mp[z]++; u.push_back(z);
	}
	//and
	vector<int> an;
	rep(i, n) {
		if (mp[a[i]] >= 2)an.push_back(a[i]);
	}
	rep(i, m) {
		if (mp[b[i]] >= 2)an.push_back(b[i]);
	}
	sort(an.begin(), an.end());
	int len = unique(an.begin(), an.end()) - an.begin();
	cout << len << " ";
	sort(u.begin(), u.end());
	int len2 = unique(u.begin(), u.end()) - u.begin();
	cout << len2 << endl;
	rep(i, len) {
		cout << an[i] << endl;
	}
	rep(i, len2) {
		cout << u[i] << endl;
	}
	//stop
	return 0;
}



Measured memory_bytes: 15320
#include <bits/stdc++.h>
#define N (int) 5e5+5
using namespace std;
int n, q;
char chr[N];
struct Bit {
	int c[N];
	int lowbit (int x) {
		return x & (- x);
	}
	void update (int pos, int val) {
		while (pos <= n) c[pos] += val, pos += lowbit (pos);
	}
	int query (int pos) {
		int ret = 0;
		while (pos) ret += c[pos], pos -= lowbit (pos);
		return ret;
	}
} bit[30];

int main () {
	cin >> n >> chr >> q;
	for (int i = 0; i < n; i ++) bit[chr[i]-'a'].update (i+1, 1);
	while (q --) {
		int op, x;
		cin >> op >> x;
		if (op == 1) {
			char y; cin >> y;
			bit[chr[x-1]-'a'].update (x, -1);
			bit[y-'a'].update (x, 1);
			chr[x-1] = y;
		} else {
			int y; cin >> y;
			int ans = 0;
			for (int i = 0; i < 26; i ++) {
				ans += (bit[i].query (y) - bit[i].query (x-1) != 0);
			}
			cout << ans << endl;
		}
	}
	
	return 0;
}

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

int main()
{
	string S, T;
	cin >> S;
	cin >> T;

	int ans = T.size();
	int cnt = 0;

	for (size_t i = 0; i < S.size() - T.size() + 1; i++)
	{
		cnt = 0;

		for (size_t j = 0; j < T.size(); j++)
		{
			if (S[i+j]!=T[j]) cnt++;
		}

		if (cnt<ans) ans = cnt;
	}

	cout << ans << endl;
}

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

typedef long long ll;


int main () {


    ll N;
    cin >> N;

    ll i,sum = 0;
    for( i=1; i<=N; i++) {
	sum += i;
	if( sum >= N ) {
	    break;
	}
    }
   sum = N;
    for(; i>0; i--) {
	if( sum - i < 0 ) continue;
	cout << i << endl;
	sum -= i;
    }
    

    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template <class T> inline T gcd(T a, T b) {if(a==0) return b; return gcd(b%a,a);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd(a,b);}
template <class T> inline T sum(vector<T> &vec) {T res=0; for (int i = 0; i < vec.size(); i++) res += vec[i]; return res;}
template <class T> inline T mpow(T a, T b) {if(b==0)return 1; T c = mpow(a,b/2);if(b%2==1)return c*c*a; return c*c;}
const int INF = 1 << 30;
const long long INFLL = 1LL << 60;
typedef pair<int, int> P;

#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define FOR(i,n) for (int (i)=0;(i)<(n);(i)++)
#define REPB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define FORB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define SORT(A) sort((A).begin(),(A).end())

int main() {
    string S, T;
    cin >> S >> T;
    cout << T + S << endl;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
const int INF=1<<29;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
map<char,int> m;
void solve(){  
    int n,m;
    cin>>n>>m;
    int ans=m*1900;
    ans+=(n-m)*100;
    for(int i=0;i<m;i++)ans<<=1;
    cout<<ans<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


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

int main() {
   string S;
   cin >> S;
   
   int length = S.size()-1;
   int len = 0;
   long long ans = 0;
   long long term = 0;
//   cout << length << endl;

   rep(i, (1<<length)){
      bitset<10> pluss(i);
      rep(j,length){
         if(pluss.test(j)) {
            term = stoll(S.substr(j-len,len+1));
            ans += term;
//            cout << term << endl;
            len = 0;
         }
         else len++;
//         cout << "len : " << len << endl;
      }
      term = stoll(S.substr(length-len,len+1));
      ans += term;
//      cout << term << endl << endl;
      len = 0;
   }

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

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

using namespace std;



int main()
{
  int N;
int A[1000000]; 
int B[1000000]; 
int C[1000000]; 

	cin >> N;
	for (int i = 0; i < N; i++) scanf("%d", A + i);
	for (int i = 0; i < N; i++) scanf("%d", B + i);
	for (int i = 0; i < N; i++) scanf("%d", C + i);

	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);
	long long res = 0;
	for (int i = 0; i < N; i++) {
		long long t1 = lower_bound(A, A + N, B[i]) - A;
		long long t2 = N - (upper_bound(C, C + N, B[i]) - C);
		res += t1 * t2;
	}
	cout << res << endl;
	return 0;
}


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

n, m = [int(x) for x in input().split()] # nは頂点の数、mは辺の数
g = [[] for _ in range(n)] # 隣接リスト

for _ in range(m):
    a, b = [int(x)-1 for x in input().split()]
    g[a].append(b)
    g[b].append(a)

from collections import deque

def bfs(u):
    queue = deque([u])
    d = [None] * n # uからの距離の初期化
    path = [None] * n
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                path[i] = v+1
                queue.append(i)
    return d, path

# 0からの各頂点の距離
d, p = bfs(0)
if None in d:
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print(p[i])

Measured memory_bytes: 37700
n, _m, c = gets.split.map(&:to_i)
ms = gets.split.map(&:to_i)
as = []
n.times do |_i|
  as.push(gets.split.map(&:to_i))
end
arr = as.select do |a|
  a.map.with_index {|ai, i| ai * ms[i]}.inject(:+) + c > 0
end
puts arr.count


Measured memory_bytes: 1916
# import numpy as np
import itertools

if __name__ == "__main__":

	N,K = map(int,input().split())
	P = [ int(p)-1 for p in input().split() ]
	C = list(map(int,input().split()))

	# print(P)
	# 一度計算したサイクル情報をキャッシュしておくための配列
	# cycleIDs = np.full( N, -1, np.int64 )
	cycleIDs = [ -1 for _ in range(N)]
	cycleInfs = []
	cycleID = 0
	procCnt = 0

	for n in range(N):
		v = n

		if cycleIDs[v] != -1:
			continue
		else:
			currentCycleCosts = []
			while True:
				# 全頂点について、属するサイクルを計算する
				currentCycleCosts.append( C[v] )
				cycleIDs[v] = cycleID

				v = P[v]
				if cycleIDs[v] != -1:
					# サイクル終了
					# ループを含めない最大の処理回数
					procCnt = K % len( currentCycleCosts )
					# それで足りてるのかわからないが、Last2周分は、ループ合計がプラスでも必ずしもループするとは限らない
					# その部分は、ちゃんと計算する
					# -------------------------------------------------
					# 4 101
					# 2 3 4 1
					# 50 -49 -50 50
					# 上記のようなパターンの場合、
					# 最大25回ループ + 1回処理可能だが、その場合、25 + 50 = 75
					# 24回ループ + 2回処理でやめると、124になる
					# 無条件でループする回数は、ループ可能な最大の回数-1らしい
					# -------------------------------------------------
					# 割り切れて、尚且つサイクル合計がマイナスのパターンで、最低１個は処理するのにもここで対応
					if len( currentCycleCosts ) + procCnt <= K:
						procCnt += len( currentCycleCosts )

					cycleInfs.append( ( procCnt, len(currentCycleCosts), currentCycleCosts * 3 ) )
					cycleID += 1
					break



	# scores = []
	# procCnt = 0
	ans = -10 ** 9
	for procCnt, currentCycleSize, currentCycleCosts in cycleInfs:

		# サイクル内でループしてスコアを稼ぐ場合の考慮
		loopScore = 0
		if sum(currentCycleCosts) > 0:
			cycleLoopCnt =  ( K - procCnt ) // currentCycleSize
			loopScore = cycleLoopCnt * sum(currentCycleCosts[:currentCycleSize])
			# print("loopScore",loopScore,procCnt)

		# このサイクルに属する全頂点分をまとめて計算する
		for i in range(currentCycleSize):
			# print(np.roll( currentCycleCosts, i ).cumsum()[:procCnt])
			ans = max( ans, max( itertools.accumulate( currentCycleCosts[i:i+procCnt] ) ) + loopScore )


	print(ans)
	# print(max(scores))


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  vector<int> W(N,0);
  for(int i=0;i<N;i++){
    if(i==0 && S.at(i)=='W') W.at(i) = 1;
    else if(i==0 && S.at(i)=='E') W.at(i) = 0;
    else if(S.at(i)=='W') W.at(i) = W.at(i-1) +1;
    else W.at(i) = W.at(i-1);
  }
  int p_min = 0;
  for(int i=0;i<N;i++){
    if(i==0) p_min = N - 1 - W.at(N-1) + W.at(i);
    else if(p_min > W.at(i-1) + ( N - (i+1) ) - ( W.at(N-1) - W.at(i) ) ){
      p_min = W.at(i-1) + ( N - (i+1) ) - ( W.at(N-1) - W.at(i) );
    }
  }
  cout << p_min << endl;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 1000000007;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-1, 0, 1, 1};
int dx[4] = {0, 1, 0, 1};

int n;
vector<double> x;
vector<double> y;
double d;
double ret;

int fac(int k) {
	if(k==0) return 1;
	return k * fac(k-1);
}

double getD(int i, int j) {
	double ret = pow(x[i]-x[j],2) + pow(y[i]-y[j],2);
	return sqrt(ret);
}

void solve() {
	vi cand;
	rep(i,0,n) {
		cand.pb(i);
	}

	do {
		double total = 0;
		rep(i,0,n-1) {
			total += getD(cand[i], cand[i+1]);
		}
		ret += total;
	} while(next_permutation(all(cand)));

}

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	x = vector<double>(n);
	y = vector<double>(n);
	rep(i,0,n) {
		cin >> x[i] >> y[i];
	}
	d = fac(n);
	ret = 0;
	solve();
	cout << fixed << setprecision(10) << ret/d << '\n';
	return 0;
}


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

int main(){
  string s,t;
  cin >> s >> t;
  cout << t << s;
}

Measured memory_bytes: 3600
s1=[x for x in input()]
s2=[x for x in input()]
s3=[x for x in input()]

t = s1.pop(0)
while(1):
    if t=='a':
        if s1 == []:
            print('A')
            break
        t=s1.pop(0)
    elif t=='b':
        if s2 == []:
            print('B')
            break
        t=s2.pop(0)
    else:
        if s3 == []:
            print('C')
            break
        t=s3.pop(0)
    

Measured memory_bytes: 3060
from collections import deque


n = int(input())
info = [list(map(int, input().split())) for i in range(n - 1)]

tree = [[] for i in range(n)]
for a, b in info:
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)
    
root = 0
par = {root: -1}
q = deque([root])
topo = []
while q:
    v = q.popleft()
    topo.append(v)
    for nxt_v in tree[v]:
        if nxt_v in par:
            continue
        par[nxt_v] = v
        q.append(nxt_v)

used = [False] * n
for v in topo[::-1]:
    if used[v]:
        continue
    else:
        used[v] = True
        if par[v] == -1:
            print("First")
            exit()
        if used[par[v]]:
            print("First")
            exit()
        used[par[v]] = True
print("Second")

Measured memory_bytes: 93400
// --霊長類の暇つぶし競プロ
// --（飲んだくれ中 @ 飲み屋）
// -- 生中３杯目
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)
#define SWAP(x,y) 		((x!=y)&&(x^=y,y^=x,x^=y))

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

int main(int argc, char* argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N,L;

	cin >> N >> L;

	vector<pair<string, string> > pairs(N);

	for(int i=0;i<N;i++){
		string str;
		cin >> str;
		pairs[i] = make_pair(str[0],str);
	}

	Sort(pairs);

	for(int i=0;i<pairs.size();i++){
		cout << pairs[i].second;
	}

	cout << endl;

	return 0;
}



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

int main(){
  int n;
  cin >> n ;
  vector<int>a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  bool b = 1;
  rep(i,n){
    if ( i == 0 ) continue;
    if ( a.at(i) == a.at(i-1) ){
      b = 0;
      break;
    }
  }
  if( b == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}



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

int main(){
	double a, b, c, d;
	cin >> a >> b >> c >> d;
	double ans = sqrt((a - c) * (a - c) + (b - d) *(b - d));
	printf("%.10f\n", ans);
	return 0;
}


Measured memory_bytes: 3288
import java.util.Scanner;
class Main {
    public static void main(String[] args){
       Scanner scan = new Scanner(System.in);
       int a = scan.nextInt();
       int b = scan.nextInt();
       int c = scan.nextInt();
       int i = 0;
       
       for(int x = a; x <= b; x++){
         if(c % x == 0) i++;
       }
       
       System.out.println(i);
    }
}

Measured memory_bytes: 26356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int main(){
	ll n=read(),ans=0;
	for(ll l=1,r;l<=n;l=r+1){
		r=n/(n/l);
		if(n%(n/l)!=0) continue;
		if(l!=r) ans+=r-1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
c = input()

rw = [0, 0]
for i in range(N):
  if c[i] == 'R':
    rw[0] += 1
  else:
    rw[1] += 1
    
ans = N
left_rw = [0, 0]
right_rw = rw[:]
for i in range(N+1):
  if i == 0:
    pass
  else:
    if c[i-1] == 'R':
      left_rw[0] += 1
      right_rw[0] -= 1
    else:
      left_rw[1] += 1
      right_rw[1] -= 1
      
  ans = min(max(left_rw[1], right_rw[0]), ans)
  
print(ans)

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

int gcd_impl( int n, int m ) {
	for(int i = 0; i < 10; ++i) {
		int t = n - m;
		bool q = m > t;
		n = q ? m : t;
		m = q ? t : m;
		if(m == 0) return n;
	}
	return gcd_impl(m, n % m);
}

int gcd(int n, int m) {
	return (n > m) ? gcd_impl(n, m) : gcd_impl(m, n);
}

int main(){
	int k;
	scanf("%d", &k);
	int ans = 0;
	for(int i=0; i < k; i++) {
		for(int j=0; j < k; j++) {
			for(int l=0; l < k; l++) {
				ans += gcd(gcd(i+1, j+1), l+1);
			}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3804
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M;
        public Data[] D;
        public int[] C;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
            }

            D = new Data[M];
            C = new int[N];

            for (int i = 0; i < M; i++)
            {
                var line = Input.ReadIntArray();
                var x = line[0] - 1;
                var y = line[1] - 1;
                if (x > y)
                {
                    var tmp = x;
                    y = x;
                    x = tmp;
                }

                var d = new Data { X = x, Y = y };
                D[i] = d;
                C[d.Y]++;
            }

            Array.Sort(D, Data.CompareTo);

            {
                int R = 0;
                int i = 0;
                int ret = 0;
                while (R < N)
                {
                    if (C[R] != 0)
                    {
                        ret++;
                        while (i < M && D[i].X < R)
                        {
                            C[D[i].Y]--;
                            i++;
                        }
                    }
                    R++;
                }

                Console.WriteLine(ret);
            }

        }

    }

    // libs ----------
    class Data
    {
        public int X;
        public int Y;

        public static int CompareTo(Data d1, Data d2)
        {
            int result = d1.X.CompareTo(d2.X);
            if (result == 0)
                result = d1.Y.CompareTo(d2.Y);
            return result;
        }

    }

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 22712
// A - Kyu in AtCoder
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  // 初期値
  int X;
  cin >> X;
  
  // Main 
    
  //Main loop
  if (X >= 1800){
    cout << "1"; 
  } else if (X >= 1600){
    cout << "2";
  } else if (X >= 1400){
    cout << "3"; 
  } else if (X >= 1200){
    cout << "4"; 
  } else if (X >= 1000){
    cout << "5"; 
  } else if (X >= 800){
    cout << "6"; 
  } else if (X >= 600){
    cout << "7"; 
  } else if (X >= 400){
    cout << "8"; 
  }
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;

const int INF=1001001001001001001ll*3;

int N,A,B;

int S[111111];

int sum[111111];
int dp[111111];

signed main(){
    scanf("%lld%lld%lld",&N,&A,&B);
    if(A>B)swap(A,B);

    S[0]=-INF;
    rep(i,N)scanf("%lld",&S[i+1]);
    S[N+1]=INF;

    N+=2;

    rep(i,N-2){
        if(S[i+2]-S[i]<A){
            cout<<0<<endl;
            return 0;
        }
    }

    dp[0]=1;
    sum[0]=1;

    int l=0;
    int r=0;
    for(int i=1;i<N;i++){
        while(S[i]-S[r+1]>=B)r++;
        if(l<=r){
            dp[i]=sum[r];
            if(l)dp[i]=(dp[i]-sum[l-1]+mod)%mod;
        }
        sum[i]=(sum[i-1]+dp[i])%mod;

        if(S[i]-S[i-1]<A)l=i-1;
    }

    cout<<dp[N-1]<<endl;
    return 0;
}


Measured memory_bytes: 2560
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

N, X  = (int(x) for x in input().split())
L = list(int(x) for x in input().split())

logging.info(L)

length = 0
counter = 1

for i in L:
    length += i
    if length <= X:
        counter += 1
    
print(counter)


Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N=2e5+10;
LL n,k,a[N],b[N];
inline bool cmp(LL x,LL y){
	return x>y;
}
inline bool check(LL x){
	LL tmp=k;
	for(LL i=1; i<=n; ++i)
		if(a[i]*b[i]>x){
			tmp-=a[i]-x/b[i];
			if(tmp<0)return 0;
		}
	return 1;
}
int main(){
	scanf("%lld%lld",&n,&k);
	for(LL i=1; i<=n; ++i)scanf("%lld",&a[i]);
	for(LL i=1; i<=n; ++i)scanf("%lld",&b[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1,cmp);
	LL l=0,r=1e18;
	while(l<r-1){
		LL mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	while(r&&check(r-1))--r;
	printf("%lld",r);
	return 0;
}

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

bool likeNumber(int num, vector<bool> dislikes) {
    int i = 0;
    int residual;
    while(pow(10,i) <= num) {
        residual = (num / (int)pow(10,i)) % 10;
        if(dislikes.at(residual)) {
            return false;
        }
        num;
        i++;
    }
    return true;
}

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> d(k);
    vector<bool> booleans(10, false);
    for(int i = 0; i < k; i++) {
        cin >> d.at(i);
        booleans.at(d.at(i)) = true;
    }
    while(likeNumber(n,booleans) == false) {
        n++;
    }
    cout << n << endl;
}

Measured memory_bytes: 4068
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,p,ans=1;
main()
{
	re(n),re(p);
	if(n==1)
	{
		printf("%lld\n",p);
		return 0;
	}
	for(int i=2;i*i<=p;++i)
	{
		int cnt=0;
		while(p%i==0)
			p/=i,++cnt;
		cnt/=n;
		while(cnt--)ans*=i;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>  
#include <cstdlib>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

int main() {
    int N;
    cin >> N;
    int A, B;
    map<int, int> mp;
    rep1(i,N) {
        cin >> A >> B;
        mp[B] += A;
    }
    
    int time = 0;
    for(auto& p : mp) {
        time += p.second;
        if (time>p.first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 9600
#include<iostream>
using namespace std;
#define yes(n) cout << ((n) ? "Yes" : "No") << endl
int main()
{
    int n,sum;
    cin >> n >> sum;
    if(sum <= n * 500)
    {
        yes(true);
    }
    else
    {
        yes(false);
    }
}

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

using ll = long long;

using namespace std;

int main() {
    int n;
    long k;
    cin >> n >> k;
    long sum=0, a[n], f[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    for (auto &fi:f) cin >> fi;
    sort(a, a+n);
    sort(f, f+n, greater<long>());
    long l=-1, r=10000000000000;
    while (r - l > 1) {
        long m = (l + r + 1) / 2, train=0;
        for (int i=0; i<n; i++) {
            train += min(a[i], m / f[i]);
        }
        if (train + k < sum) l = m;
        else r = m;
    }
    cout << r << '\n';
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int N, C;
int solve(vector<int> x, vector<int> v) {
	int p = 0;
	int k = 0;
	int r = 0;
	vector<int> mx(N + 1, 0);
	p = C;
	for (int i = N - 1; i >= 0; i--) {
		mx[i] = mx[i + 1];
		mx[i] += v[i];
		mx[i] -= p - x[i];
		p = x[i];
	}
	for (int i = N - 1; i >= 0; i--) {
		mx[i] = max(mx[i], mx[i + 1]);
	}
	/*for (int i = 0; i < N; i++) {
		cerr << mx[i] << " ";
	}
	cerr << endl;*/
	p = 0;
	k = 0;
	r = 0;
	int res = 0;
	for (int i = 0; i < N; i++) {
		r -= x[i] - p;
		k -= x[i] - p;
		k += v[i];
		res = max(res, k);
		res = max(res, k + r + mx[i + 1]);
		p = x[i];
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> C;
	vector<int> x(N);
	vector<int> v(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> v[i];
	}
	res = solve(x, v);
	for (int i = 0; i < N; i++) {
		x[i] = C - x[i];
	}
	reverse(x.begin(), x.end());
	reverse(v.begin(), v.end());
	res = max(res, solve(x, v));

	cout << res << endl;
}

Measured memory_bytes: 4224
#include<cstdio>
#include<cmath>
int main(){
	int N,K,X,Y,A;
	scanf("%d %d",&N,&K);
	X=K-1;
	Y=N-1;
	A=pow(X,Y);
	if(N == 1) printf("%d\n",K);
	if(N >= 2) printf("%d\n",K*A);
	return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n, k; cin >> n >> k;

    int upper = (n-2)*(n-1)/2;

    if(k > upper) {
        cout << -1 << endl;
    } else {
        vector<pair<int, int>> edges;
        for(int i = 1; i < n; ++i) {
            edges.push_back({i, n});
        }

        while(upper > k) {
            for(int i = 1; i < n-1; ++i) {
                for(int j = i+1; j < n; ++j) {
                    edges.push_back({i, j});
                    upper--;
                    if(upper == k) break;
                }
                if(upper == k) break;
            }
        }

        cout << edges.size() << endl;
        for(auto p : edges) {
            cout << p.first << " " << p.second << endl;
        }
    }
    
    return 0;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;

#ifdef BTK
#define DEBUG if(1)
#else
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

typedef vector<int> V;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    reverse(ALL(s));
    V len(26,0);
    V id(26,-1);
    V nxt(n,-1);
    V k(n,0);
    REP(i,n){
        REP(j,26){
            if(len[k[i]]>len[j]){
                k[i]=j;
            }
        }
        nxt[i]=id[k[i]];
        id[s[i]-'a']=i;
        len[s[i]-'a']=len[k[i]]+1;
    }
    int v=0;
    REP(i,26)if(len[v]>len[i])v=i;
    string ret;
    ret+=(char)('a'+v);
    v=id[v];
    
    while(v!=-1){
        DEBUG cout<<v<<endl;
        ret+=(char)('a'+k[v]);
        v=nxt[v];
    }
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr ll INF = (ll)1e9;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, H, W; cin >> N >> H >> W;
	int ans = N - H + N - W + (N - H) * (N - W) + 1;
	cout << ans << "\n";

	return 0;
}


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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	ll h, w;
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0) {cout << 0; return 0;}
	ll ans = 1e12;
	for (ll i = 0; i <= w; i++) {
		ll p1 = h*i;
		ll p2, p3;
		if (h % 2 == 0 || (w-i) % 2 == 0) {p2 = (h*w - p1)/2;}
		else {
			if (h >= (w-i)) {
				p2 = (h/2)*(w-i);
			} else {
				p2 = (w-i)/2 * h;
			}
		}
		p3 = h*w - p1 - p2;
		ll a, b;
		a = max(p1, max(p2, p3));
		b = min(p1, min(p2, p3));
		if (a-b < ans) {ans = a-b;}
	}
	swap(w, h);
	for (ll i = 0; i <= w; i++) {
		ll p1 = h*i;
		ll p2, p3;
		if (h % 2 == 0 || (w-i) % 2 == 0) {p2 = (h*w - p1)/2;}
		else {
			if (h >= (w-i)) {
				p2 = (h/2)*(w-i);
			} else {
				p2 = (w-i)/2 * h;
			}
		}
		p3 = h*w - p1 - p2;
		ll a, b;
		a = max(p1, max(p2, p3));
		b = min(p1, min(p2, p3));
		if (abs(a-b) < ans) {ans = abs(a-b);}
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256