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

#define int long long
template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

const int mod = 1e9+7;

string L;
int dp[100010][2]; // dp[i][j]: i桁目までみて、フラグがjの時の組み合わせの数。フラグが0なら以下、1なら未満

int rec(int digit, int smaller) {
	// 終了
	if (digit >= L.size()) {
		return dp[digit][smaller] = 1;
	}

	// 再計算を防ぐ
	if (dp[digit][smaller] != -1) {
		return dp[digit][smaller];
	}

	int ret = 0;

	// 以下にする場合 flag(0 -> 0)
	if (smaller == 0) {
		if (L[digit] == '1') {
			Add(ret, rec(digit+1, 0)*2);
		} else {
			Add(ret, rec(digit+1, 0));
		}
	}

	// 未満にする場合 flag(0 -> 1)
	if (smaller == 0) {
		if (L[digit] == '1') {
			Add(ret, rec(digit+1, 1));
		}
	}

	// すでに未満なのでなんでもありの場合 flag(1 -> 1)
	if (smaller == 1) {
		Add(ret, rec(digit+1, 1)*3);
	}

	return dp[digit][smaller] = ret;
}

signed main() {
	cin >> L;

	// DPテーブル初期化
	for (int i = 0; i < 100010; i++) {
		for (int j = 0; j < 2; j++) {
			dp[i][j] = -1;
		}
	}

	int ans = rec(0, 0);
	cout << ans << endl;

	return 0;
}

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

constexpr long mod = 998244353;
// constexpr long mod = 1000000007;
vector<long> fact, inv;

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return res;
}

void init(int n) {
  fact.push_back(1);
  inv.push_back(1);
  for (int i = 0; i < n; i++) {
    fact.push_back(fact.at(i) * (i + 1) % mod);
    inv.push_back(mpow(fact.at(i + 1), mod - 2));
  }
}

long ncr(long n, long r) {
  return fact.at(n) * inv.at(r) % mod * inv.at(n - r) % mod;
}

long com(long n, long r) {
  long res = 1;
  for (long i = 0; i < r; i++) {
    (res *= n - i) %= mod;
    (res *= mpow(i + 1, mod - 2)) %= mod;
  }
  return res;
}

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  init(N);
  long ans = 0;
  for (int i = 0; i <= K; i++) {
    (ans += M * mpow(M - 1, N - i - 1) % mod * ncr(N - 1, i) % mod) %= mod;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 6628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 5e5;
int a[N];
ll n;
ll suf[N];
ll aux[N];
ll bit[N];
void add(int idx, int val){
    for(int i=idx;i>0;i-=(i&-i)){
        bit[i]+=val;
    }
}
ll sum(int idx){
    ll ret = 0;
    for(int i=idx;i<N;i+=(i&-i)){
        ret+=bit[i];
    }
    return ret;
}
bool ch(ll x){
    for(int i=0;i<N;i++)bit[i] = 0;
    ll k = n*(n+1ll)/2;k = k/2+1;
    suf[n+1] = 0;
    aux[n+1] = 0;
    int trt = 1;
    for(int i=n;i>=1;i--){
        suf[i] = suf[i+1];
        if(a[i]<=x)suf[i]++;
        aux[i] = 2*suf[i]-trt++;
    }
    ll ans = 0;
    int zero = n+100;
    for(int i=1;i<=n+1;i++){
        ans+=sum(zero+aux[i]+1);
        add(zero+aux[i],1);
    }
    if(ans<k)return true;
    return false;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    ll st = 0;
    ll en = 1e18;
    while(st<=en){
        ll mid = (st+en)/2ll;
        if(ch(mid)){
            st = mid+1;
        }
        else{
            en = mid-1;
        }
    }
    cout<<st<<endl;
    return 0;
}


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

string s;

long long sum;

map<char,int> col;

int main(){
	cin >> s;
	for(int i = 0; i < (int)s.size(); i++){
		sum += (i - col[s[i]]);
		col[s[i]]++;	
	}
	cout << sum + 1;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n);
    vector<int> mp(200005,0);

    rep(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }

    int kind = 0;
    sort(all(a));

    rep(i,n-1) if(a[i] != a[i+1]) kind++;

    sort(all(mp));
    reverse(all(mp));

    int ans = n;

    rep(i,k) ans-= mp[i];

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main () {
	int n, k,output=1;//N-> jumlh operasi, K-> nilai yg ditambahkan

	scanf ("%d %d",&n,&k);
	
	for(int i=0;i<n; i++){
		(output+k>output*2) ? output*=2: output +=k;

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

Measured memory_bytes: 1732
N,*s = open(0).read().split()
ans = sum(x.count('AB') for x in s)
bxa, xa, bx = 0, 0, 0
for x in s:
    if x[0] == 'B':
        if x[-1] == 'A':
            bxa += 1
        else:
            bx += 1
    elif x[-1] == 'A':
        xa += 1
if bxa > 0:
    ans += bxa - 1
    if xa > 0:
        ans += 1
        xa -= 1
    if bx > 0:
        ans += 1
        bx -= 1
    ans += min(xa,bx)
else:
    ans += min(xa,bx)
print(ans)

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

int main(){
    i64 h,n,sum=0;
    cin>>h>>n;
    for(i64 i=0;i<n;i++){
        int a;
        cin>>a;
        sum+=a;
    }
    cout<<(sum<h?"No":"Yes")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define df 0
#define MOD 1000000007

int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  int i,j,s[n],t[m];
  long int count[m];
  for(i=0;i<n;i++)
    scanf("%d",&s[i]);
  for(j=0;j<m;j++)
    scanf("%d",&t[j]);
  for(j=0;j<m;j++) count[j]=0;
  for(i=0;i<n;i++){
    int a=s[i];
    long int c=1;
    for(j=0;j<m;j++){
      long int temp=c;
      c=(c+count[j])%MOD;
      if(a==t[j])count[j]=(count[j]+temp)%MOD;
      if(df) printf(" %ld",count[j]);
    }
    if(df) printf("\n");
  }
  long int ans=1;
  for(j=0;j<m;j++){
    ans+=count[j];
    ans%=MOD;
  }

  printf("%ld",ans);
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 256
def main():
    a = int(input())
    ans = 0
    for now_num_kari in range(105, a + 1)[::2]:
        data = []
        now_num = now_num_kari
        for i in range(2, 50):
            count = 0
            while now_num % i == 0:
                count += 1
                now_num //= i
            if count > 0:
                data.append(count)

        if now_num > 1:
            data.append(1)

        yakusuu = 1
        for ele in data:
            yakusuu *= (ele + 1)

        if yakusuu == 8:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>

using namespace std;

int main() {
  int a,b;
  cin >>a>>b;
  int result = 0;
  int total = 1;
  while (total < b) {
    result++;
    total += a-1;
  }
  
  cout << result <<endl;
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split(' ').map(&:to_i)

rsums = []
rsum = 0
as.reverse_each do |a|
  rsum += a
  rsums.unshift(rsum)
end

M = (10 ** 9) + 7

sum = 0
(0...n-1).each do |i|
  sum = (sum + as[i] * rsums[i + 1]) %  M
end
puts sum


Measured memory_bytes: 35852
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;

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

    int r,d,x[15];
    cin>>r>>d>>x[0];

    reps(i,10){
	x[i]=x[i-1]*r-d;
    
	cout<<x[i]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
//ll mod=1000000007;
//ll mod=67280421310721;
ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n,k;
		cin>>n>>k;
		set<int> fak;
		int d,a;
		FOR(i,0,k)
		{
			cin>>d;
			FOR(j,0,d)
			{
				cin>>a;
				fak.insert(a);
			}
		}
		cout<<n-fak.size();
	}
	return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    boss = [0] * N
    for i in range(len(A)):
        boss[A[i]-1]+=1
    for b in boss:
        print(b)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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 int64 mod = 1e9+7;

int N, M;
vector<int64> x, y, z;

int main(void){
	cin >> N >> M;
	x.resize(N); y.resize(N); z.resize(N);
	REP(i, N) cin >> x[i] >> y[i] >> z[i];

	int64 res = -INF_LL;
	REP(a, 1 << 3){
		vector<PLL> v;
		REP(i, N){
			int64 sum = 0;
			if((a >> 0) & 1) sum += x[i];
			else sum += -x[i];
			if((a >> 1) & 1) sum += y[i];
			else sum += -y[i];
			if((a >> 2) & 1) sum += z[i];
			else sum += -z[i];
			v.push_back(PLL(sum, i));
		}
		int64 sx = 0, sy = 0, sz = 0;
		sort(all(v), greater<PLL>());
		REP(i, M){
			sx += v[i].fs;
		}
		chmax(res, sx);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
#define pii pair<int,int>
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 1e5;
int n,en;
struct Edge {int v,nxt;} e[mxN*2+3]; int fe[mxN+3];
llong d[mxN+3]; map<llong,int> mp;
int id[mxN+3];
int sz[mxN+3];
vector<pii> way;

bool cmp(int x,int y) {return d[x]<d[y];}

void addedge(int u,int v) {en++; e[en].v = v; e[en].nxt = fe[u]; fe[u] = en;}

llong dfs(int u,int x)
{
	llong ret = x;
	for(int i=fe[u]; i; i=e[i].nxt)
	{
		int v = e[i].v;
		ret += dfs(v,x+1);
	}
	return ret;
}

int main()
{
	n = read(); for(int i=1; i<=n; i++) id[i] = i;
	for(int i=1; i<=n; i++) {scanf("%lld",&d[i]); mp[d[i]] = i;}
	sort(id+1,id+n+1,cmp);
	for(int i=1; i<=n; i++) sz[i] = 1;
	for(int i=n; i>1; i--)
	{
		int u = id[i]; d[u] -= n-2ll*sz[u];
		if(!mp.count(d[u])) {puts("-1"); return 0;}
		int v = mp[d[u]]; sz[v] += sz[u]; way.push_back(mkpr(u,v)); addedge(v,u);
	}
	if(dfs(id[1],0)!=d[id[1]]) {puts("-1"); return 0;}
	for(int i=0; i<n-1; i++) {printf("%d %d\n",way[i].x,way[i].y);}
	return 0;
}

Measured memory_bytes: 15452
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin >> N;
  ll sum = 0;
  for(int i = 0; i <= N; i++){
    if(!(i % 3 == 0 || i % 5 == 0)) sum += i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#define LEN 100005
#pragma warning(disable:4996)
using namespace std;

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b){ return a < b ? a : b; } // ????°?????????????

int main(){
	int elaps = 0, c;
	int i, q;
	P u;
	cin >> n >> q;

	// ??¨??????????????????????????\???????????????????????????
	for(i=1; i<=n; i++){
		cin >> Q[i].name;
		cin >> Q[i].t;
	}
	head = 1;
	tail = n + 1;

	// ????????\??¬????????§???
	while(head != tail){
		u = dequeue();
		c = min(q,u.t);
		u.t -= c;
		elaps += c;
		if(u.t > 0) enqueue(u);
		else{
			cout << u.name << ' ' << elaps << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 13224
#include <iostream>
#include <stack>
#include <algorithm>
#include <string>
#include <vector>

int main()
{
	using namespace std;
	stack<int> S1;
	stack<pair<int, int> > S2;
	vector<int> V1;
	char ch;
	int total = 0;
	for (int i = 0; cin >> ch; i++)
	{
		switch (ch)
		{
		case '\\':
			S1.push(i);
			break;
		case '/':
			if (!S1.empty())
			{
				int start = S1.top();
				S1.pop();
				total += i - start;
				int t_area = i - start;
				while (!S2.empty() && (S2.top().first > start))
				{
					t_area += S2.top().second;
					S2.pop();
				}
				S2.push(make_pair(start, t_area));
			}
			break;
		default:
			break;
		}
	}

	while (!S2.empty())
	{
		V1.push_back(S2.top().second);
		S2.pop();
	}
	reverse(V1.begin(), V1.end());
	cout << total << endl;
	cout << V1.size();
	for (int i = 0; i < V1.size(); i++)
	{
		cout << ' ' << V1[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	char u;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u;
		if (u == 'Y') {
			cout << "Four\n";
			return 0;
		}
	}
	cout << "Three\n";
	getchar(); getchar();
}


Measured memory_bytes: 256
import java.io.PrintWriter;
        import java.util.ArrayList;
        import java.util.Collections;
        import java.util.List;
        import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
        int int3 = Integer.parseInt(scan.next());
        int int4 = Integer.parseInt(scan.next());
        String ans = null;
        if((Math.abs(int3 - int1)<=int4) || (Math.abs(int2 - int3) <= int4 && Math.abs(int2 - int1) <= int4) || int3 == int1){
            ans = "Yes";
        }else{
            ans = "No";
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

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


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

int main() {
  int n;
  cin >> n;
  int d[n][2], count = 0;
  for (int i = 0; i < n; i++) {
    cin >> d[i][0] >> d[i][1];
    if (d[i][0] == d[i][1]) {
      count++;
      if (count >= 3) {
        cout << "Yes";
        return 0;
      }
    } else count = 0;
  }
  
  cout << "No";
  
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>

int main (void)
{
    int a, b, c;
    int A, B, C;
    int k;
    int n = 0;

    scanf("%d %d %d¥n", &a, &b, &c);
    scanf("%d", &k);

    while (n <= 7) {
        A = a;
        B = pow(2, n) * b;
        C = pow(2, k-n) * c;
        if (A < B && B < C) {
            printf("Yes");
            return 0;
        }
        n++;
    }
    printf("No");
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  char Z;
  int A,B,C,D,E;
  A=B=C=D=E=0;
  for(int i=0;i<N;i++){
    cin>>Z;
    if(Z=='P')
      A++;
    else if(Z=='W')
      B++;
    else if(Z=='G')
      C++;
    else if(Z=='Y')
      D++;
  }
  
  if(A*B*C*D!=0)
    cout<<"Four"<<endl;
  else
    cout<<"Three"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(ll i=a;i<=(ll)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    string s;cin>>s;
    int l=s.size(),t=M;
    rep(i,l-2) t=min(t,abs(753-stoi(s.substr(i,3))));
    cout<<t;
}

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

using namespace std;

int main()
{
    string s;
    int n,cnt=0;
    cin >> s;
    n=s.size();
    for(int  i=1;i<n;i++)
    {
        if(s[i]+s[i-1]-'0'-'0'!=1)
        {
            s[i]=(char)('1'-s[i]+'0');
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  ll K,A,B ;
  cin >> K >> A >> B ;
  if( A >= B-2)
    cout << K+1 << endl;
  else{
    if(K <= A)
      cout << K+1 << endl;
    else{
      if( (K-A) % 2 == 1){
        ll l = (K-A)/2 ;
        cout << (l+1)*B-l*A << endl;
      }
      else{
        ll l = (K-A)/2 ;
        cout << l*B-(l-1)*A+1 << endl;
      }
    }
  }
}
      

Measured memory_bytes: 256
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    i64 k;
    cin >> k;
    vector<i64> a_s(n), f_s(n);
    rep(i, n)
    {
        cin >> a_s[i];
    }
    rep(i, n)
    {
        cin >> f_s[i];
    }
    sort(a_s.begin(), a_s.end());
    sort(f_s.rbegin(), f_s.rend());
    debug(a_s);
    debug(f_s);

    // ans <= m ?
    auto test = [&](i64 m) {
        i64 cost = 0;
        rep(i, n)
        {
            cost += max((i64)0, a_s[i] - m / f_s[i]);
            if (cost > k)
            {
                return false;
            }
        }
        return true;
    };

    i64 ng = -1, ok = 1'000'000'000'000'000'000;
    while (ok - ng > 1)
    {
        auto mid = (ok + ng) / 2;
        if (test(mid))
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 6324
#include<stdio.h>
int main(void)
{
    char str[100];
    int n, k;
    scanf("%d%d", &n, &k);
    getchar();
    gets(str);
    str[k - 1] = 'a' + str[k - 1] - 'A';
    printf("%s\n", str);
    return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int[] x = new int[5];
		for(int i = 0;i < x.length;i++){
			x[i] = saori.saori_hayami();
			if(x[i] == 0){
				System.out.println(i+1);
			}
		}
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 32304
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    int temp;
    while(a%b!=0){
        temp=a%b;
        a=b;
        b=temp;
    }return b;
}
int main(){
    int N;cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }int g=A[0];
    for(int j=1;j<N;j++){
        g=gcd(g,A[j]);
    }cout<<g<<endl;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    int pos = N;
    vector<int> ans;
    while (pos > 0) {
        int step = min(M, pos);
        while (S[pos-step] == '1') {
            step--;
            if (step == 0) {
                cout << -1 << endl;
                return 0;
            }
        }
        ans.push_back(step);
        pos -= step;
    }
    for (int i = (int)ans.size()-1; i >= 0; i--) {
        cout << ans[i];
        cout << ((i == 0) ? "\n" : " ");
    }
    return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,b,c=1,d=0,e,f,g,h,m,n,ans=0;
  string s,t;
  cin>>n;
  string ss[n],tt[n];
  pair<string,int> p[n];
  rep(i,0,n) p[i].second=0;
  rep(i,0,n) cin>>ss[i];
  sort(ss,ss+n);
  t=ss[0];
  
  rep(i,1,n){
    if(t==ss[i]) c++;
    else{
      p[d].first=t;
      p[d].second=c;
      ans=max(ans,c);
      c=1;
      d++;
      t=ss[i];
    }
  }
  if(c>0){
    p[d].first=t;
    p[d].second=c;
    ans=max(ans,c);
    c=0;
    d++;
  }
  rep(i,0,d){
    if(p[i].second==ans) co(p[i].first);
  }
    
  return 0;
}

Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define N 100101
int main() 
{
    boost;
    string s;
    cin>>s;
    int a=s.find('9');
    if(a!=-1)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import math
N=int(input())
a=[]
c=0
"""
def isPrime( x ):
    if x <= 1:
        return False

    for i in range(2,x-1):
        if x % i == 0:
            return False

    return True
"""

def isPrime(x):
    if x == 2:
        return True

    if x < 2 or x%2==0:
        return False

    i = 3
    while i <= math.sqrt(x):
        if x%i==0:
          return False
        i = i + 2

    return True
    
for i in range(N):
    n=int(input())
    a.append(n)
    
for i in range(N):
    if(isPrime(a[i])==True):
        c=c+1

print(c)



Measured memory_bytes: 6020
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
string A[55], B[55];

int main() {
  int N, M;
  cin >> N >> M;
  int count = 0;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) cin >> B[i];

  for (int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < N - M + 1; j++) {
      count = 0;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (A[i + k].at(j + l) == B[k].at(l)) count++;
        }
      }
      if (count == M * M) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


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

#define ll long long
//#define int long long
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

#define dump(x)  cerr << #x << " = " << (x) << endl; 
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


typedef pair<int, int> P;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

signed main(){

	ll N, Y;

	cin >> N >> Y;

	for (int man = 0; man <= Y / 10000; man++)
		for (int gosen = 0; gosen <= Y / 5000; gosen++){
			int sen = N - man - gosen;
			if (sen >= 0 && (man * 10000 + gosen * 5000 + sen * 1000 == Y)){
				cout << man << " " << gosen << " " << sen << endl;
				return 0;
			}
		}

	cout << -1 << " " << -1 << " " << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

int GCD(int x, int y) {
	return x ? GCD(y % x, x) : y;
}

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using uint1024_t = mp::uint1024_t;
using namespace std;


int main() {
	int n, X;
	scanf("%d %d", &n, &X);
	int ans;
	rep(i, n) {
		int x;
		cin >> x;
		x = abs(x - X);
		if (i == 0) {
			ans = x;
		}
		ans = GCD(x, ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long sum, m,n;
    scanf("%lld%lld",&m,&n);
    if(n==1)
    {
        if(m==1)
            printf("1\n");
        else
            printf("%lld",m-2);
    }
    else if(m==1)
    {
        printf("%lld",n-2);
    }
    else
    {
        sum=(n-2)*(m-2);
        printf("%lld\n",sum);
    }
    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

long long int modpow(int b, int p){
    long long int num = 1, power = b;
    for(int i=0; i<=30; i++){
        if((p>>i) & 1) num *= power;

        num %= MOD;
        power *= power;
        power %= MOD;
    }
    return num;
}

int main(){
    int n, k;
    cin >> n >> k;

    vector<long long int> gcd(k+1);
    for(int i=k; i>=1; i--){
        //cout << i << " : ";
        gcd[i] = modpow(k/i, n);
        for(int d=2; d<=k/i; d++){
            //cout << d << " ";
            gcd[i] -= gcd[i*d];
            gcd[i] = (gcd[i] % MOD + MOD) % MOD;
        }
        //cout << endl;
        gcd[i] = (gcd[i] % MOD + MOD) % MOD;
    }

    long long int ans = 0;
    for(long long int j=1; j<=k; j++){
        ans += (gcd[j] * j) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4064
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int r0, w0, c, r;
	while (cin>>r0>>w0>>c>>r, r0|w0|c|r) {
		int ans = 0;
		while (r0 + ans*r < c*w0)
			ans++;
		cout << ans << endl;
	}
}

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

const int MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    int a,b;
    vector<pair<int,int>> p;
    for (int i=0;i<n-1;i++) {
        cin >> a >> b;
        p.push_back(make_pair(a-1,b-1));
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }
    int m=0;
    for (int i=0;i<n;i++) {
        int gsize=g[i].size();
        m=max(m,gsize);
    }
    vector<int> v(n);
    map<pair<int,int>,int> ans;
    queue<int> q;
    q.push(0);
    v[0]=m;
    while (!q.empty()) {
        int now=q.front();
        q.pop();
        int k=1;
        for (int j=0;j<g[now].size();j++) {
            int next=g[now][j];
            if (!(v[next]>=1)) {
                int l=v[now]+k;
                k++;
                v[next]= (l%m==0) ? m : l%m;
                ans[make_pair(now,next)]=v[next];
                ans[make_pair(next,now)]=v[next];
                q.push(next);
            }
        }
    }
    cout << m << endl;
    for (int i=0;i<n-1;i++) {
        cout << ans[p[i]] << endl;
    }
}

Measured memory_bytes: 19700
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll n;
	ll ans=0LL;
	cin >>n;
	ll last = 0;
	ll last2 = INFLL;
	/*
	if(n >=3){
		clog << n - 1 << endl;
		
		ans += n - 1;
	}
	*/
	for (ll i = 1; i * i <= n;i++){
		if((n-i)%i==0LL and n-i !=0LL){
		    last=(n - i) / i;
		    if(n/last==n%last){
			ans += (n - i) / i;
			clog << (n - i) / i << endl;
		    }			
		}
		
	} 
	cout << ans << endl;
}
/*
8
2499686339916
2499687339915
1 x
2 
3 .. 2...2 
4
7 .. 1.1
8
*/


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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    int cnt = a[n/2] - a[n/2-1];
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define f first
#define s second
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vi vector<int>
#define vll vector<ll>
#define endl '\n'
#define SIZE 1000002
#define w(t) int t;cin>>t;while(t--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define value_at_idx find_by_order
#define idx order_of_key
#define MOD 1000000007
#define inf INT_MAX
#define Maxheap(T) priority_queue<T>
#define Minheap(T) priority_queue<T,vector<T>,greater<T>>
#define mem(name,value) memset(name,value,sizeof(name))
#define pi 3.14159265358979323846 
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
const int p = 31;
string S,T;

void input()
{
    cin>>S>>T;
}
void solve()
{
    T.pop_back();
    if(T==S)
        cout<<"Yes";
    else 
        cout<<"No";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    input();
    solve();
    
    
    return 0;
        
    
    
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;
typedef long long lint;

bool solve(vector<int> A) {
    const int N = A.size();
    sort(A.begin(), A.end());
    if (A.back() - A.front() > 1) {
        return false;
    }
    if (A.back() == A.front()) {
        return A.front() <= N/2 || A.front() == N-1;
    }
    int unique = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == A.front()) ++unique;
        else break;
    }
    int all = A.back();
    return all > unique && 2 * all - unique <= N;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    if (solve(A)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    int n,w;
    cin>>n>>w;
    int a[105][2];
    f(i,n)cin>>a[i][0]>>a[i][1];
    int dp[105][100005];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 or j==0)dp[i][j]=0;
            else if(a[i-1][0]>j)dp[i][j]=dp[i-1][j];
            else
            {
                dp[i][j]=max(dp[i-1][j],a[i-1][1]+dp[i-1][j-a[i-1][0]]);
            }
        }
    }
    cout<<dp[n][w]<<endl;
    
    
}


Measured memory_bytes: 81024
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <complex>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;
static const double PI=3.141592653589793;

using Point=complex<double>;
using Plane=vector<Point>;

namespace std {
    bool operator<(const Point &a, const Point &b) {
        return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
    }
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

struct Circle {
    Point p;
    double r;
    Circle() {}
    Circle(const Point &p, const double r): p(p), r(r) {}
};

size_t num_ctangent(const Circle &c1, const Circle &c2) {
    double d=abs(c1.p-c2.p);
    double r=min(c1.r, c2.r), R=max(c1.r, c2.r);
    if (R+r < d) {
        return 4;
    } else if (abs(R+r-d) < EPS) {
        return 3;
    } else if (abs(R-r-d) < EPS) {
        return 1;
    } else if (R-r > d) {
        return 0;
    } else {
        return 2;
    }
}

bool testcase_ends() {
    double x, y, r;
    if (scanf("%lf %lf %lf", &x, &y, &r) == EOF) return 1;

    Circle A(Point(x, y), r);
    scanf("%lf %lf %lf", &x, &y, &r);
    Circle B(Point(x, y), r);

    size_t n=num_ctangent(A, B);
    if (n == 0) {
        printf("%d\n", A.r>B.r? 2:-2);
    } else {
        printf("%d\n", n!=4);
    }

    return 0;
}

int main() {
    int n;
    scanf("%d", &n);

    for (int i=0; i<n; ++i)
        if (testcase_ends())
            return 1;

    return 0;
}

Measured memory_bytes: 2716
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  ll Z, W;
  cin >> Z >> W;
  vector<ll> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];
  if(N == 1)
    cout << abs(A[0] - W) << endl;
  else
    cout << max(abs(A[N-1] - W), abs(A[N-2] - A[N-1])) << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i!=n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int l,r;
    cin >> l >> r;
    int ans=inf;
    r = min(r,l+2019);
    for(int i=l;i<r;++i)
    {
        for(int j=i+1;j<r+1;++j)
        {
            ans=min((i*j)%2019,ans);
        }
    }
    cout << ans << endl;
}


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


int main()
{
    int a;
    string s;
    cin >> a;
    cin >> s;
    if (a >= 3200){
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<string>
using namespace std;
#define ll long long
//vector<int>num;
ll a[200010];//出现次数 
ll b[200010];//相同个数 
ll c[200010]; //差距数组 
queue<ll>q;
int main(){
	for(int i=0;i<=200009;i++)c[i]=2;
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		int x;cin>>x;a[x]++;q.push(x);
		//cout<<"放入的数为"<<q.back()<<endl;
		if(a[x]==2){
			b[x]=1;
		}
		else if(a[x]>2){
			//cout<<"目前"<<x<<"出现了"<<a[x]<<"次，差距c为"<<c[x]<<endl;
			b[x]=c[x]+b[x];
			c[x]++;
		}
		//cout<<"对于"<<x<<"来说，相同的对数有"<<b[x]<<endl; 
	}
	ll ans=0;
	for(int i=1;i<=200009;i++){
		ans+=b[i];
	}
	while(!q.empty()){
		int idx=q.front();
		if(b[idx]==0)cout<<ans<<endl;
		else if(b[idx]==2)cout<<ans-1<<endl;
		else{
		cout<<ans-c[idx]+1<<endl;}
		q.pop();
	}
	return 0;
}

Measured memory_bytes: 7936
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

int main() {
	long N; cin >> N;
	string res = "Yes";
	long H[100009]; for (int i = 1; i <= N; i++) cin >> H[i];
	H[0] = INT_MIN;

	for (int i = 1; i <= N; i++) {
		if (H[i - 1] <= H[i] - 1) H[i]--;
	}

	for (int i = 1; i <= N - 1; i++) {
		if (H[i] > H[i + 1]) res = "No";
	}
	cout << res << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
int long long A, B;
int K;
int m[205];
int main()
{
    scanf("%lld%lld%d",&A,&B,&K);
    int t;
    if(A>B)
        {t=A;A=B;B=t;}
    if((B-A+2)/2<=K)
    {
        int sum = A;
        for(int i=0; i<(B-A+1); i++)
            printf("%d\n",sum++);
    }
    else
    {
        int c=2*K;
        m[0] = A;
        m[c-1] = B;
        for(int i=1; i<=(K-1); i++)
        {
            m[i] = m[i-1]+1;
        }
        for(int i=(c-2); i>=(c-K); i--)
        {
            m[i] = m[i+1]-1;
        }
        for(int i=0; i<c; i++)
        {
             printf("%d\n",m[i]);
        }
    }
    return 0;
}


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

int main(void){
	int a,b;
	int a_tax,b_tax;
	int a_max,b_max;

	scanf("%d %d\n",&a,&b);

	a_tax=a*12.5;
	a_max=a_tax+12;
	if(a%2==1){
		a_tax++;
	}
	b_tax=b*10;
	b_max=b_tax+9;
	if(b_max<a_tax||a_max<b_tax){
		printf("-1");
	}else{
		printf("%d",a_tax<b_tax?b_tax:a_tax);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
int n,k,a[MAXN*2],pat[2][4]={{1,-1,0,2},{-2,+1,0,-1}};
bool used[MAXN*2];
int main()
{
	cin>>n>>k;
	if(n==2){
		if(k==2)puts("Yes\n1\n2\n3");
		else puts("No");
		return 0;
	}
	if(k==1 || k==2*n-1)puts("No");
	else{
		int o=0;
		if(k==n*2-2)o=1;
		for(int i=0;i<4;++i)
			a[n-1+i]=k+pat[o][i],used[k+pat[o][i]]=true;
		int p=1;
		for(int i=1;i<=n*2-1;++i)
			if(!a[i]){
				while(used[p])++p;
				a[i]=p;
				used[p]=true;
			}
		puts("Yes");
		for(int i=1;i<=n*2-1;++i)
			printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cmath>

int main()
{
    long N;
    std::cin >> N;
    long partial=1+8*N;
    double edge=sqrt(partial);
    edge=edge-1;
    edge=edge/2.0;
    long result=std::ceil(edge);
    std::cout << result << std::endl;
    return 0;
}

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

int main()
{
	int N;
	double A[1000];
	double ans = 0.0;

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
	{
		scanf("%lf", &A[i]);
		ans += 1 / A[i];
	}

	ans = 1 / ans;

	printf("%f", ans);


}


Measured memory_bytes: 128