akhauriyash/Code-Regression huggingface dataset:
// #include <atcoder/all>
// using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int k;
    cin >> k;
    rep(i, k) cout << "ACL";
    cout << '\n';
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);

    int foodint[5];
    string food[5];
    rep(i,5){
        cin >> foodint[i];
        food[i] = to_string(foodint[i]);
    }

    int mi = 10;
    int ans = 0;

    rep(i,5){

        if(food[i][food[i].size()-1]-'0'!=0){
            mi = min(mi, food[i][food[i].size()-1]-'0');
        }

        if(food[i][food[i].size()-1]-'0'==0){
            ans += foodint[i];
        } else {
            ans += (foodint[i]/10+1)*10;
        }

        //cout << mi << endl;
    }

    cout << ans-(10-mi) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int, char**)
{
	long long N, K;
	cin >> N >> K;
	vector<long long> A(N);
	long long counter = 0;
	for (long long i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	vector<long long> tmp(N, 0);
	for (long long i = 0; i < N; ++i)
	{
		for (long long j = i + 1; j < N; ++j)
		{
			if (A[i] > A[j])
			{
				++tmp[i];
			}
		}
	}
	map<long long, long long> dict;
	for (long long i = 0; i < N; ++i)
	{
		if (dict.find(A[i]) != dict.end())	continue;
		dict[A[i]] = 0;
		for (long long j = 0; j < N; ++j)
		{
			if (A[i] > A[j])
			{
				++dict[A[i]];
			}
		}
	}
	long long MOD = 1000000007;
	long long sumK = ((K - 1) * K / 2) % MOD;
	K %= MOD;
	for (long long i = 0; i < N; ++i)
	{
		counter += ((dict[A[i]] * sumK) % MOD) + ((tmp[i] * K) % MOD);
	}
	counter %= MOD;
	cout << counter << endl;
	return 0;
}


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

using namespace std;

vector<int> g[100005];
bool used[100005];
void dfs(int u) {
  used[u] = 1;
	for(auto to : g[u]) {
    	if(!used[to])
    		dfs(to);
    }
}

int main() {
	int n, m;
  cin>>n>>m;
  while(m--) {
  	int u, v;
    cin>>u>>v;
    --u,--v;
  g[u].push_back(v);
    g[v].push_back(u);
    
  }
	int res =0;
  for(int i =0 ; i < n; ++i) {
  	if(!used[i]) {
    		dfs(i);
      ++res;
    	}
  
  }
	cout<<res-1;
}

Measured memory_bytes: 9532
#include <iostream>
using namespace std;
int main(void){
  int a,b,k;
  cin >> a >> b >> k;

  if(k >= (b-a)/2+1){
    for(int i=a;i<=b;i++){
      cout << i << endl;
    }
  }

  else{
    for(int i=0;i<k;i++){
    cout << a+i << endl;
    }
    for(int i=k-1;i>=0;i--){
      cout << b-i << endl;
    }
  }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define vi vector<int>
#define fi first
#define se second 
#define mp make_pair
typedef unsigned long long ull;
//typedef pair<int,int> P;
#define LL long long 
#define pi acos(-1)
typedef long long ll;
const int mod=1e9+7;
//const int maxn = 1005;
#define REP(i,n) for(int i=1;i<=n;i++)
#define show(x) cout<<#x<<" = "<<(x)<<endl;
const int maxn = 505;
int a[maxn],n;
int main(){
	for(int i=0;i<5;i++) cin>>a[i];
	cin>>n;
	int fl=1;
	if(a[4]-a[0]>n) fl=0;
	puts(fl?"Yay!":":(");
	return 0;
}


Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	static int[] h;
	static int[] dp;
	
	static int solve(int start, int end)
	{
		//base case
		if(end-start<=0)
			return 0;
		if(end-start==1)
		    return Math.abs(h[end]-h[start]);	
		
		if(dp[start]==-1)
		{
		    int temp = Math.min(solve(start + 1, end) + Math.abs(h[start] - h[start + 1]), solve(start+2, end) + Math.abs(h[start] - h[start + 2]));
		    dp[start] = temp;
		    return temp;
		}
		else
    		return dp[start];
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		
		int n = scn.nextInt();
		h = new int[n];
		dp = new int[n];
		Arrays.fill(dp, -1); 
		
		for(int i=0; i<n; i++)
			h[i] = scn.nextInt();
		
		System.out.println(solve(0, n-1));
		
		
		
	}
}

Measured memory_bytes: 71948
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    int k, x;
    cin >> k >> x;

    if(k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3588
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
//_____
#define pb push_back
#define mkp make_pair
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
//_______

vector <int> G[100005];
int group[100005];
int color = 1;

void dfs(int u)
{
   group[u] = color;

   rep(i, G[u].size())
      if( group[ G[u][i] ] == 0 )dfs( G[u][i] );
}

signed main()
{
   FAST();
   int N, M;
   cin >> N >> M;

   rep(i, M){
      int a,b;
      cin >> a >> b;
      G[a].pb(b);
      G[b].pb(a);
   }

   rep(i, N){
      if(group[i] == 0 )dfs(i);
      ++color;
   }

   int Q;
   cin >> Q;
   while(Q--){
      int a,b;
      cin >> a >> b;
      outl( group[a] == group[b] ? "yes" : "no" );
   }
}




Measured memory_bytes: 12188
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;


float FindConc(int water, int sugar){
    return 100*sugar / ((float)water + (float)sugar);
}

bool isSolved(int water, int sugar, int E){
  if(water * E >= sugar * 100) return true;
  else return false;
}

bool isLighter(int water, int sugar, int F){
  if(water + sugar <= F) return true;
  else return false;
}

int main(void){
  int A, B, C, D, E, F;
  float conc = 0, maxconc = 0;
  int sum_water = 0, sum_sugar = 0;
  int max_water = 0, max_sugar = 0;
  cin >> A >> B >> C;
  cin >> D >> E >> F;
  //条件を満たす範囲でconcの最大値を求める。
  //全探索で行けるはずなので，a, b, c, dの全探索で行こう。
  for(int a = 0; a <= 30; a++){
    for(int b = 0; b <= 30; b++){
      for(int c = 0; c <= ceil((double)F/C); c++){
        for(int d = 0; d <= ceil((double)F/D); d++){
          sum_water = a*100*A + b*100*B;
          sum_sugar = c*C + d*D;
          if(isSolved(sum_water, sum_sugar, E) && isLighter(sum_water, sum_sugar, F)){
            conc = FindConc(sum_water, sum_sugar);
            if(maxconc < conc){
              maxconc = conc;
              max_water = sum_water;
              max_sugar = sum_sugar;
            }
          }
        }
      }
    }
  }
  if(maxconc == 0) max_water = 100*A;
  cout << max_water + max_sugar << " " << max_sugar << endl;
  return 0;
}


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

int main() {
  int N, C, K;
  scanf("%d%d%d", &N, &C, &K);

  vector<int> T(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }

  sort(T.begin(), T.end());

  int ans = 0;
  int i = 0;
  while (i < N) {
    int passenger = 1;
    for (int j = i + 1; j < N; j++) {
      if (passenger == C) {
        break;
      }
      if (T.at(j) - T.at(i) <= K) {
        passenger++;
      } else {
        break;
      }
    }
    ans++;
    i += passenger;
  }

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

Measured memory_bytes: 768
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll a, b, n;
	cin >> a >> b >> n;

	ll ans = 0;
	if(n >= b - 1){
		ans = a * (b - 1) / b;
	}else{
		ans = a * n / b;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pii             pair<int , int >
#define in(a)           scanf("%d", &a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define piil            pair<ll , ll >
#define inl(a)          scanf("%lld", &a)
#define inl2(a, b)      scanf("%lld%lld", &a, &b)
#define inl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define ins(s)          scanf("%s",s)
#define prst(s)         printf("%s\n",s)
#define pn              printf("\n")
#define pr(a)           printf("%d\n", a)
#define prl(a)          printf("%lld\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)         printf("%lld ", a)
#define prl2(a, b)      printf("%lld %lld\n", a, b)
#define prl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define pcs(a)          printf("Case %d: ", a)
#define pf              printf
#define sc              scanf
#define m_p             make_pair
#define vi              vector<int >
#define vil             vector<ll >
#define pb              push_back
#define mem(a, b)       memset((a), (b), sizeof(a))
#define lg2(n)         (31-__builtin_clz(n))
#define N 2000010
#define inf 9999999
#define ll long long
#define ull unsigned long long
#define MIN INT_MIN
#define MAX INT_MAX
#define __  std::ios_base::sync_with_stdio (false); cin.tie(0); cout.tie(0);
#define Check(n, pos) (n & (1<<pos))
#define Set(n, pos) (n | (1<<pos))
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
using namespace std;
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
ll histogram(ll arr[],ll n) {  stack<int>s;  int area=0,i=0;  while(i<n) { if(s.empty() || arr[s.top()]<=arr[i]) s.push(i++); else { int tp=s.top(); s.pop(); int xx=arr[tp]*(s.empty() ? i : i - s.top() - 1);area=max(area,xx);}}while(!s.empty()){ int tp=s.top(); s.pop(); int xx=arr[tp]*(s.empty() ? i : i - s.top() - 1); area=max(area,xx); } return area;}
//___________________________________________________________________________________________________________________
ll dp[N],arr[N];
char str[N];
int main()
{
   ll n,m,k,a,b;
   ll sum=0;
   string s;
  cin>>n;
 ll mx=0,mn=1e10;
 for(int i=0;i<n;i++)
 {
     cin>>a;
     mx=max(a,mx);
     mn=min(mn,a);
 }
 cout<<(mx-mn)<<endl;
 
   
    return 0;
}




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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
const int MX = 5e3 +5;
int dp[MX][MX];

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

    int n; cin >> n;
    string s; cin >> s;

    int ans = 0;
    for (int i = n-1; i >= 0; i--) {
        for (int j = n-1; j >= 0; j--) {
            if (s[i] == s[j]) {
                chmax(dp[i][j], dp[i+1][j+1] + 1);
            }
        }
    }

    rep(i,n) rep(j,n) {
        if (i >= j) continue;
        int now = min(dp[i][j], j-i);
        ans = max(ans, now);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 98048
import java.util.ArrayList;
import java.util.BitSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		final int INF = 1000000;
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			int m = in.nextInt();
			int l = in.nextInt();
			int k = in.nextInt();
			int a = in.nextInt();
			int h = in.nextInt();
			if(m==0) break;
			BitSet hos = new BitSet(n);
			for(int i=0; i<l; i++){
				hos.set(in.nextInt());
			}
			int[][] road = new int[n][n];
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					if(i==j) continue;
					road[i][j] = INF;
				}
			}
			for(int i=0; i<k; i++){
				int x = in.nextInt();
				int y = in.nextInt();
				int t = in.nextInt();
				road[x][y] = road[y][x] = t;
			}
			for(int p=0; p<n; p++){
				for(int i=0; i<n; i++){
					for(int j=0; j<n; j++){
						if(road[i][j]>road[i][p]+road[p][j])
							road[i][j] = road[i][p] + road[p][j];
					}
				}
			}
			ArrayList<Node> node = new ArrayList<Node>();
			node.add(new Node(h));
			node.add(new Node(a));
			for(int i=hos.nextSetBit(0); i!=-1; i=hos.nextSetBit(i+1)){
				node.add(new Node(i));
			}
			for(int i=0; i<l+1; i++){
				Node v1 = node.get(i);
				for(int j=i+1; j<l+2; j++){
					Node v2 = node.get(j);
					if(road[v1.id][v2.id] > m) continue;
					v1.createEdge(v2);
					v2.createEdge(v1);
				}
			}
			Queue<Pos> pos = new PriorityQueue<Pos>();
			int time = INF;
			BitSet used = new BitSet(n);
			pos.add(new Pos(node.get(0), 0));
			while(!pos.isEmpty()){
				Pos p = pos.poll();
				if(used.get(p.id)) continue;
				if(p.id == a){
					time = p.time;
					break;
				}
				used.set(p.id);
				for(Node v: p.v.edge){
					pos.add(new Pos(v, p.time + road[p.id][v.id]));
				}
			}
			if(time<INF && time > m){
				time += (time-m);
			}
			System.out.println(time==INF?"Help!":time);
		}
	}
}

class Node{
	int id;
	ArrayList<Node> edge = new ArrayList<Node>();
	public Node(int id){
		this.id = id;
	}
	
	public void createEdge(Node nd){
		edge.add(nd);
	}
}

class Pos implements Comparable<Pos>{
	Node v;
	int id;
	int time;
	public Pos(Node v, int time){
		this.v = v;
		this.time = time;
		id = v.id;
	}
	
	@Override
	public int compareTo(Pos o) {
		return time-o.time;
	}
}

Measured memory_bytes: 63032
#include <stdio.h>
#define N 100000
int  main(){
  int n,S[N],q,T[N],i;
  int left,right,mid,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)scanf("%d",&T[i]);
  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(T[i]==S[mid]){
	cnt++;
	break;
      }
      else if(T[i]<S[mid])right=mid;
      else left=mid+1;
    }
  }
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 2312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    cout << (s < t ? "Yes":"No") << endl;
}


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

const int mod = 1e9 + 7;

string s;
int n;
int dp[100005][5][5];

int serc(int cur, int carry, int flag) {
  if (cur == n) {
    return (carry == 0);
  }

  if (dp[cur][carry][flag] != -1) {
    return dp[cur][carry][flag];
  }

  int ret = 0;
  for (int a = 0; a < 2; a++) {
    for (int b = 0; b < 2; b++) {
      for (int nex_carry = 0; nex_carry < 2; nex_carry++) {
        int nex_sum = a + b + nex_carry;
        int nex_xor = a ^ b;
        if (nex_sum / 2 != carry) continue;
        if (nex_sum % 2 != nex_xor) continue;
        if (nex_xor && flag && !(s[cur] - '0')) continue;
        nex_sum %= 2;
        int nex_flag = flag && (nex_sum == (s[cur] - '0'));
        ret = (ret + serc(cur + 1, nex_carry, nex_flag)) % mod;
      }
    }
  }

  return dp[cur][carry][flag] = ret;
}

int main() {
  cin >> s;
  n = s.length();
  memset(dp, -1, sizeof(dp));
  cout << serc(0, 0, 1) << '\n';

  return 0;
}

Measured memory_bytes: 21120
let (+@) a b = (a + b) mod 998244353
let () =
  Scanf.scanf "%s" @@ fun s ->
  let n = String.length s in
  let thres_b = Array.init (2*n+1) (fun i ->
    if i = 0 then 0
    else if i <= n then int_of_char s.[i-1] - int_of_char '0'
    else 0) in
  for i = 1 to 2*n do thres_b.(i) <- thres_b.(i) + thres_b.(i-1) done;
  let thres_r = Array.init (2*n+1) (fun i -> 2 * (min i n) - thres_b.(i)) in

  let r, b = thres_r.(n), thres_b.(n) in
  let dp = Array.init (r+1) (fun _ -> Array.make (b+1) 0) in
  dp.(0).(0) <- 1;
  for w = 1 to 2*n do
    for r = max 0 (w - thres_b.(w)) to min w thres_r.(w) do
      let b = w - r in
      if r > 0 then dp.(r).(b) <- dp.(r).(b) +@ dp.(r-1).(b);
      if b > 0 then dp.(r).(b) <- dp.(r).(b) +@ dp.(r).(b-1);
    done;
  done;

  Printf.printf "%d\n" dp.(r).(b)

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

int main(){
    int N,ans; cin>>N; ans=0;
    string S; cin>>S;
    for(int i=0; i<N-2; i++){
        if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
import math
from functools import reduce
from operator import mul
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, sys.stdin.readline().split(' ')))
def In(): return int(sys.stdin.readline())
def InS(): return sys.stdin.readline()

S = InS()[:-1:]
T = InS()[:-1:]

if S == T[:-1:]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9508
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;
	char s[50+2];
	while(scanf("%d\n%50[A-Z]\n", &n, s)==2)
	{
		int ans=0;

		for(int i=0;i<n-2;i++)
		{
			if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e3+5 ;

int n ,x ,day[N] ;
long long cur[N] ;
deque<int> dq[N] ;
int vis[N][N] ,vid ;
long long dfs(int i,int tar){
    if(vis[i][tar] == vid){
        cout << -1 ;
        exit(0);
    }
    vis[i][tar] = vid ;

    for(int k=day[i];k<dq[i].size();++k){
        int j = dq[i][k] ;
        if(j==tar) break;

        if(dq[j][day[j]] == i){
            ++day[i] ;
            ++day[j] ;
            int mx = max(cur[i],cur[j]);
            cur[i] = cur[j] = mx+1 ;
            continue ;
        }
        cur[i] = max(cur[i],dfs(j,i)) ;
        ++day[i] ;
        ++day[j] ;
        int mx = max(cur[i],cur[j]);
        cur[i] = cur[j] = mx+1 ;
    }
    return cur[i];
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        for(int j=1;j<n;++j){
            scanf("%d",&x);
            dq[i].push_back(x);
        }
    }
    long long ans = 0 ;
    for(int i=1;i<=n;++i){
        ++vid ;
        ans = max(ans ,dfs(i,i)) ;
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 8576
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

struct que {
    int v, d, col;

    que() {
        v = d = col = 0;
    }
} req[MAXN];

vector<int> adj[MAXN];

int col[MAXN];

int lim[MAXN];

int u[MAXN];

int n, m, q;

int timer;

void solve() {
    scanf("%d %d", &n, &m);

    for (int i = 1; i <= n; ++i) {
        lim[i] = -1;
        col[i] = 0;
        u[i] = 0;
    }

    for (int i = 1, u, v; i <= m; ++i) {
        scanf("%d %d", &u, &v);
        adj[u].pb(v);
        adj[v].pb(u);
    }

    scanf("%d", &q);

    for (int i = 1; i <= q; ++i) {
        scanf("%d %d %d", &req[i].v, &req[i].d, &req[i].col);
    }

    queue<pair<int, int>> Q;

    for (int i = q; i > 0; --i) {
        Q.push(mp(req[i].v, req[i].d));
        ++timer;

        while (!Q.empty()) {
            int v = Q.front().fi;
            int d = Q.front().se;

            Q.pop();

            u[v] = timer;

            if (d <= lim[v]) {
                continue;
            }

            if (!col[v]) {
                col[v] = req[i].col;
            }

            lim[v] = d;

            for (int to : adj[v]) {
                if (u[to] != timer) {
                    Q.push(mp(to, d - 1));
                }
            }
        }
    }

    for (int i = 1; i <= n; ++i) {
        printf("%d\n", col[i]);
    }
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

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

const int N = 20;
const int INF = (int)5e3;

int f(int a, int b) {
    return (a-1)*N + b;
}

char s[N+5][N+5];
int dat[N*N+5][N*N+5];

int main() {
    for (int i=0; i<N*N+3; i++) {
        for (int j=0; j<N*N+3; j++) {
            dat[i][j] = (i == j ? 0 : INF);
        }
    }

    int h,w; scanf("%d %d", &h, &w);
    for (int i=1; i<=h; i++) scanf("%s", s[i]+1);

    for (int i=0; i<=h+1; i++) s[i][0] = s[i][w+1] = '#';
    for (int i=0; i<=w+1; i++) s[0][i] = s[h+1][i] = '#';

    for (int i=1; i<=h; i++) {
        for (int j=1; j<=w; j++) {
            if (s[i][j] == '.') {
                if (s[i][j+1] == '.') dat[f(i,j)][f(i,j+1)] = 1;
                if (s[i][j-1] == '.') dat[f(i,j)][f(i,j-1)] = 1;
                if (s[i+1][j] == '.') dat[f(i,j)][f(i+1,j)] = 1;
                if (s[i-1][j] == '.') dat[f(i,j)][f(i-1,j)] = 1;
            }
        }
    }

    for (int k=1; k<=N*N; k++) {
        for (int i=1; i<=N*N; i++) {
            for (int j=1; j<=N*N; j++) {
                dat[i][j] = min(dat[i][j], dat[i][k] + dat[k][j]);
            }
        }
    }

    int res = 0;
    for (int i=1; i<=N*N; i++) {
        for (int j=1; j<=N*N; j++) {
            if (dat[i][j] != INF) res = max(res, dat[i][j]);
        }
    }

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


Measured memory_bytes: 896
def f():
    n, a, b, c, d = map(int, input().split())
    s = input().strip()
    a -= 1
    b -= 1

    if '##' in s[a:c]:
        return False
    if '##' in s[b:d]:
        return False
    if c > d:
        if '...' not in s[b-1:d+1]:
            return False
    return True

print(['No', 'Yes'][f()])


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define range(i,a,b) for(int i = (a);i <= (b);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
#define vi vector<int>
#define vl vector<long long>
#define vd vector<double>
#define vp vector<pair<int,int> >
#define ll long long
#define pi pair<int,int>
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define xx first
#define yy second
#define PQ priority_queue
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prp(p) cerr << "(" << (p).first << " ," << (p).second << ")";
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
using namespace std;

const int MAX = 1 << 20,MAXLG = 20;
int sparse[2][MAX][MAXLG],lg[MAX];

int A[1 << 20],n;
int couple[MAX];

void build(int sparse[MAX][MAXLG],int t){
	lg[0] = -1;
	loop(i,MAX-1) lg[i + 1] = lg[i] + ((i + 1) == LSOne(i+1));
	loop(i,n) sparse[i][0] = (i%2 == t) ? A[i] : INT_MAX;
	loop(k,MAXLG-1) loop(i,n){
		int j = i + (1 << k);
		if(j >= n) j = i;
		sparse[i][k + 1] = min(sparse[i][k],sparse[j][k]);
	}
}

int RMQ(int a,int b,int sparse[MAX][MAXLG]){
	int l = lg[b - a + 1];
	return min(sparse[a][l],sparse[b - (1 << l) + 1][l]);
}


int get_cutpoint(int l,int r){
	if(l+1==r) return l+1;
	if(A[l + 1] < RMQ(l+3,r,sparse[1 - l%2])) return l+1;
	int s = 0,e = (r - l + 1)/2 - 1;
	int parity = 1 - l%2;
	while(s < e) {
		int m = s + (e - s + 1)/2;
		int pos = l + m*2 + 1;
		if(RMQ(l,r,sparse[parity]) == RMQ(pos,r,sparse[parity])) s = m;
		else e = m - 1;
	}
	return l + s*2 + 1;
}

int get_pivot(int l,int r){
	int s = 0,e = (r - l + 1)/2 - 1;
	while(s < e){
		int m = s + (e - s + 1)/2;
		if(RMQ(l,r,sparse[l%2]) == RMQ(l + 2*m,r,sparse[l%2])) s = m;
		else e = m-1;
	}
	return l + 2*s;
}

struct cmp{
public:
	bool operator () (const pi & a,const pi & b){
		return RMQ(a.xx,a.yy,sparse[a.xx&1]) > RMQ(b.xx,b.yy,sparse[b.xx&1]);
	}
};

deque<int> dq;
PQ<pi,vector<pi>,cmp> pq;

void solve(int s,int e){
//	cerr << s << " " << e << endl;
	int l = e - s + 1;
	assert(l%2 == 0);
	if(l == 0) return ;
	if(l == 2) {
		dq.push_back(A[s]);
		dq.push_back(A[e]);
	}
	else{
		int pivot = get_pivot (s,e);
		int cutpoint = get_cutpoint(pivot,e);
	//	cerr << s << " " << e << " -> " << pivot << " " << cutpoint << endl;
		dq.push_back(A[pivot]);
		dq.push_back(A[cutpoint]);
		if(s != pivot) pq.push(mp(s,pivot-1));
		if(pivot+1 != cutpoint) pq.push(mp(pivot+1,cutpoint-1));
		if(cutpoint != e) pq.push(mp(cutpoint+1,e));
	}
}

int main(){

	scanf("%d",&n);
	loop(i,n) scanf("%d",A + i);
	build(sparse[1],1);
	build(sparse[0],0);

	pq.push(mp(0,n-1));
	while(!pq.empty()) {
		auto p = pq.top(); pq.pop();
		solve(p.xx,p.yy);
	}
	//print(dq,int);
	loop(i,n) printf("%d%c",dq[i]," \n"[i==n-1]);
	return 0;
}


Measured memory_bytes: 41592
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    double t, x;
    cin >> t >> x;
    cout << setprecision(15) << fixed << t / x;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSearch(Node,int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert (int);
void inorder (Node);
void preorder(Node);

//void transplant(Node,Node);

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
       inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
       scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }
  }

  
  
  return 0;
}


Node treeMinimum(Node x){
  
  while(x->left != NIL){
    x = x->left;
  }

  return x;

}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){

  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right); //case1

  y = x->parent;

  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y; //case2

}

void treeDelete(Node z){
  Node a; // node to be deleted
  Node b; // child of y

  if(z->left == NIL || z->right == NIL) a = z;
  else a = treeSuccessor(z);

  if(a->left != NIL) b = a->left;
  else b = a->right;

  if( b != NIL ) b->parent = a->parent;
  if(a->parent == NIL) root = b;
  else if(a==a->parent->left) a->parent->left = b;
  else a->parent->right = b;

  if( a != z) z->key = a->key;

}


void insert(int k){
  Node y = NIL; // x parent
  Node x = root; 
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x; //parent set
    if( z->key < x->key) x = x->left;//左の子へ移動
    else x = x->right;//右の子へ移動
  }
  z->parent = y;

  //Tが空の場合
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z; //z を y の左の子にする
  else y->right = z; // z を yの右の子にする 

}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }

}
void preorder(Node u){
  if(u != NIL) {
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }

}





Measured memory_bytes: 20536
#include<bits/stdc++.h>
#define int long long int
#define db double
#define ull unsigned long long
#define vii vector <int>
#define pii pair <int, int>
#define fi first
#define se second
#define rep(i,a,n)		for(int i=a;i<n;i++)
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof a)
#define mkp make_pair
#define pb push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;
double pi=3.1415926535;
double eps=0.000001;
int mod=1000000007; 
void print(vector <int> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}
int ncr(int n, int r)
{
    r=min(r,n-r);
    int A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  //initializing A starting from n-r+1 to n
    iota(B,B+r,1);      //initializing B starting from 1 to r

    int g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    int ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]);
    return ans;
}
int32_t main(){
/////////////////////////////////////////////////////////////////////
//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
//	cout.tie(NULL);
//	cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//	std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//    std::cout.precision(10);

	
	int k, n;
	cin>>k>>n;
	
	int a[n+1];
	for (int i=1;i<=n;i++) cin>>a[i];
	
	
	
	int ans=a[n]-a[1];
	for (int i=1;i<n;i++){
		ans=min(ans, (k-(a[i+1]-a[i])));
	}
	cout<<ans<<endl;
	return 0;
	}

Measured memory_bytes: 1792
N, M = [int(i) for i in input().split()]
S = [list(map(int,input().split())) for _ in range(M)]

bag =[]
for i in range(1000):
    ans = str(i)    
    if len(ans) == N:
        for j in range(M):
            if ans[S[j][0]-1] != str(S[j][1]):
                break
        else:# インナーループがbreakで終了しなかった
            bag.append(i)
            
if len(bag) != 0:
    print(min(bag))
else:
    print(-1)

Measured memory_bytes: 3064
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
s = ns()

lb = 0
lw = 0
rb = s.count('#')
rw = s.count('.')

ans = float('inf')

for i, si in enumerate(s):
    if si == '#':
        rb -= 1
    else:
        rw -= 1
        
    ans = min(ans, rw + lb)
    
    if si == '#':
        lb += 1
    else:
        lw += 1
        
print(ans)

Measured memory_bytes: 3500
import java.util.*;

public class Main{
	
	public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        int N = sc.nextInt();
        String all = sc.next();

        String past, crr;
        int def = 0;
        int cost = 0;
        int min_cost = 0;

        crr = String.valueOf(all.charAt(0));
        for(int i=1; i<N; i++){
            past = crr;
            crr = String.valueOf(all.charAt(i));

            if(past.equals("W")) cost++;
            
            if(crr.equals("E")){
                cost--;
                def++;
            }

            if(cost < min_cost) min_cost = cost;

        }

        System.out.println(def + min_cost);
        
	}

}

Measured memory_bytes: 43268
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll comb2(ll n) { return n * (n - 1) / 2; }

void solve(long long N, long long M, std::vector<long long> A) {
  vl acc(N + 1);
  rep(n, 0, N) { acc[n + 1] = acc[n] + A[n]; }

  map<ll, ll> cnts;
  rep(n, 0, N + 1) { cnts[acc[n] % M]++; }

  ll ans = 0;

  itrep(cnt, cnts) {
    ll num = cnt->sc;
    ans += comb2(num);
  }
  print(ans);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, M, std::move(A));
  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll x,n;
	cin>>x>>n;
	bool f[110]={};
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		f[a]=1;
	}
	ll num=1e9,ans;
	for(int i=101;i>=0;i--){
		if(f[i])continue;
		if(abs(x-i)<=num){
			num=abs(x-i);
			ans=i;
		}
		//cout<<num<<' '<<ans<<endl;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    int count = 0;
    string d;
    REP(i, N){
        cin >> d;
        if(d=="A")++count;
        else{
            if(--count==-1){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    if(count==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 3160
a=int(input())
b=int(input())
c=int(input())
x=int(input())

count=0
for i in range(a+1):
	for j in range(b+1):
		for k in range(c+1):
			sum = 500*i+100*j+50*k
			if(x%50==0 and sum == x):
				count+=1

print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define MN 100
int a[MN+5];
int main()
{
	int n,k,i,ans=0;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;++i)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<=n;++i)if(a[i]<=k)k-=a[i],++ans;
	if(ans==n&&k)--ans;
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b,c,d,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------

bool check(ll syu){
    int res=1;
    priority_queue<P> que;
    rrep(i,1,n){
        if(res==0)break;
        if(a[i]>a[i-1])continue;
        while(1){
            if(que.empty())break;
            P X=que.top();
            if(X.fi<a[i])break;
            que.pop();
        }
        ll want_ind=a[i]-1;
        int ok=0;
        while(1){
            if(que.empty())break;
            P X=que.top();
            if(want_ind==X.fi&&X.se==syu-1){
                want_ind--;
                que.pop();
            }
            else{
                if(want_ind==X.fi){
                    que.pop();
                    que.push({X.fi,X.se+1});
                    ok=1;
                }
                break;
            }
        }
        if(want_ind<0){
            res=0;
        }
        if(!ok){
            if(want_ind<0){
                res=0;
            }
            else{
                if(syu==1)res=0;
                que.push({want_ind,1});
            }
        }
    }
    if(res==1)return true;
    else return false;
}
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n)cin>>a[i];
    ll le=1,ri=LINF,mid;
    while(ri-le>1){
        mid=(le+ri)/2;
        if(check(mid))ri=mid;
        else le=mid;
    }
    rrep(i,max(le-5,1LL),ri+5){
        if(check(i)){
            Cout(i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
def isPrime(n):
    # 素数判定
    if n == 2:
        return True
    if n < 2 or n % 2 == 0:
        return False
    m = 3
    while m * m <= n:
        if n % m == 0:
            return False
        m += 2
    return True


def main():
    X = int(input())
    while True:
        if isPrime(X):
            print(X)
            break
        X += 1
    return


main()


Measured memory_bytes: 2940
#include<iostream>
#include<fstream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <random>
#include <set>
using namespace std;
typedef long long ll;


int main(){
	ll n,s,m=998244353,ans=0;
	cin >> n >> s;
	vector<ll> a(n),dp(3001,0),t,cls(3001,0);
	for(auto &&x:a)cin >> x;
	for(auto &&x:a){
		t = cls;
		for(int i=0;i<3001;i++){
			( t[i] += dp[i] ) %= m;
			if(i+x<=3000)( t[i+x] += dp[i] ) %= m;
		}
		t[0]++;
		t[x]++;
		dp = t;
		( ans += dp[s] ) %= m;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    map <int, int> d;
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int x; cin >> x; ++d[x];
    }   
    vector <int> a;
    for (auto e : d) a.push_back(e.second);
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int ans = 0;
    while (a.size() > k) {
        ans += a.back();
        a.pop_back();
    }   
    cout << ans << '\n';
}   

Measured memory_bytes: 14964
// 177

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long int;
#define NUM 1000000007

int main(){
    int n;
    cin >> n;
    vector<ll> v(n), sum(n, 0);
    ll buf, ans=0, tmp;
    cin >> buf;
    v.at(0) = buf;
    sum.at(0) = buf;
    for(int i=1; i<n; i++){
        cin >> buf;
        v.at(i) = buf;
        sum.at(i) = (sum.at(i-1) + buf)%NUM;
    }
    for(int i=n-1; i>0; i--){
        tmp = (sum.at(i-1) * v.at(i))%NUM;
        ans = (ans + tmp)%NUM;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6428
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := readInt(), readInt(), readInt()
	k := readInt()

	for i := 0; i < k; i++ {
		if b <= a {
			b *= 2
		} else if c <= b {
			c *= 2
		} else {
			break
		}
	}
	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1776
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int H = Cin(), A = Cin();
    cout << (H + A - 1) / A << endl;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  string a,b;
  cin >> a >> b;
  string s=a+b;
  int num=atoi(s.c_str());
  string ans;
  if(sqrt(num)==(int)sqrt(num)) ans="Yes";
  else ans="No";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256