akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
const int MAXN = 300005;
map<pair<int,int>,int>mp;
int fa1[MAXN],fa2[MAXN],*fa,n,*head,m1,m2,cnt;
int head1[MAXN],head2[MAXN];
struct Edge{
    int to,next;
}e[MAXN<<2];
inline void insert(int u,int v)
{
    e[++cnt].to=v,e[cnt].next=head[u],head[u]=cnt;
    e[++cnt].to=u,e[cnt].next=head[v],head[v]=cnt;
}
int *vis,vis1[MAXN],vis2[MAXN],q[MAXN];
inline void bfs(int s)
{
    int front=1,back=0,u,v;
    q[++back]=s,vis[s]=1;
    while(front<=back){
        u=q[front++];
        for(int i=head[u];i;i=e[i].next){
            v=e[i].to;
            if(!vis[v]){
                vis[v]=1;
                q[++back]=v;
                fa[v]=s;
            }
        }
    }
}
int main()
{
    head=head1;
    scanf("%d%d%d",&n,&m1,&m2);
    for(int i=1;i<=m1;++i){
        int u,v;
        scanf("%d%d",&u,&v);
        insert(u,v);
    }
    head=head2;
    for(int i=1;i<=m2;++i){
        int u,v;
        scanf("%d%d",&u,&v);
        insert(u,v);
    }
    head=head1;
    fa=fa1,vis=vis1;
    for(int i=1;i<=n;++i)fa[i]=i;
    for(int i=1;i<=n;++i)if(!vis[i])bfs(i);
    head=head2;
    fa=fa2,vis=vis2;
    for(int i=1;i<=n;++i)fa[i]=i;
    for(int i=1;i<=n;++i)if(!vis[i])bfs(i);
    for(int i=1;i<=n;++i)++mp[make_pair(fa1[i],fa2[i])];
    for(int i=1;i<=n;++i)
        printf("%d ",mp[make_pair(fa1[i],fa2[i])]);
    return 0;
}

Measured memory_bytes: 23936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP 100
#define Pair pair<int,int>

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


int main(){
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = MM;
    for(int i = -100; i <= 100; i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            sum += (i-a[j])*(i-a[j]);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, M;
  while (cin >> N >> M) {
    cout << (N == M ? "Yes" : "No") << endl;
  }
  return 0;
}


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

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

signed main()
{
    int n; cin >> n;
    vector<ll> L(n); rep(i,n) cin >> L[i];

    ll ans = 0;
    for (int i = 0; i < n-2; ++i){
        for (int j = i + 1; j < n-1; ++j){
            for (int k = j + 1; k < n; ++k){
                ll& a = L[i], b = L[j], c = L[k];
                if ((a!=b) && (b!=c) && (c!=a)){
                    ll mx = max(a,b); mx = max(mx,c);
                    if ((mx * 2L) < a+b+c)
                        ++ans;
                }
            }
        }
    }

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


Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<vector>
#include <string>
#include<math.h>
typedef long long int ll;
using namespace std;

int main() {
  string s; cin>>s;
  int n=s.size();
  ll ans=0;

  for (int bit=0; bit< 1<<(n-1); bit++) {
    ll ma = s[0] - '0';
    for (int i=0; i<n-1; i++){
      if (bit & (1 << i)) {
        ans+=ma;
        ma=s[i+1]-'0';
      } else {
        ma=ma*10+(s[i+1]-'0');
      }
    }
    ans+=ma;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
uses math;
var
	N,X,Y,loop,k,ans,z:Longint;
begin
	read(N,X,Y);
	loop:=Y-X+1;
	for k:=1 to N-1 do begin
		ans:=0;
		{inc(ans,max(0,X-k));
		inc(ans,max(0,N+1-Y-k));}
		z:=min(X-1,k-1);
		if k-z<=loop div 2 then begin
			inc(ans,(z-max(0,2*k-loop-1)div 2)*2);
			if(loop mod 2=0)and(loop div 2<k)and(k-loop div 2<X)then dec(ans);
		end;
		z:=min(N-Y,k-1);
		if k-z<=loop div 2 then begin
			inc(ans,(z-max(0,2*k-loop-1)div 2)*2);
			if(loop mod 2=0)and(loop div 2<k)and(k-loop div 2<N+1-Y)then dec(ans);
		end;
		if N+1+X-Y>k then inc(ans,N+1+X-Y-k);
		if k=1 then dec(ans)else begin
			if X-1>=k-1 then dec(ans);
			if N-Y>=k-1 then dec(ans);
		end;
		if k*2<loop then begin
			inc(ans,loop);
		end else if k*2=loop then begin
			inc(ans,loop div 2);
		end;
		writeln(ans);
	end;
end.

Measured memory_bytes: 128
using System;

namespace agc006_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            bool b = true;
            for (int i = n; i > 0 && b; i--)
            {
                if (t.Substring(0, i) == s.Substring(t.Length - i, i))
                {
                    Console.WriteLine((s + t).Length - i);
                    b = false;
                }
            }
            if (b)
            {
                Console.WriteLine((s + t).Length);
            }
        }
    }
}

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

int main()
{
  int n,m;
  cin >> n >> m;
  int a[n][m];
  for(int i=0;i<n;i++)
   for(int j=0;j<m;j++)
    {
      cin >> a[i][j]; a[i][j]--;
    }
    int cnt[m];
    int max1=1;
    int ans=400;
    int id;
  while(max1>0)
   {
     max1=-1;
    memset(cnt,0,sizeof cnt);
    for(int i=0;i<n;i++)
    {
      int j=0;

       while(j<m && a[i][j]==-1) j++;
       if(j<m)
       cnt[a[i][j]]++;
    }

    for(int k=0;k<m;k++)
     if(cnt[k]>max1)
      max1=cnt[k],id=k;
    //cout << max1<<"\n";
    if(max1>0)
     ans=min(ans,max1);
     //cout << ans<<"\n";
    for(int p=0;p<n;p++)
     for(int q=0;q<m;q++)
      if(a[p][q]==id)
        a[p][q]=-1;
  }
  cout << ans;
  return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class BDistance {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        ll n,d;
        cin>>n>>d;
        int cnt=0;
        d*=d;
        for (int i=1;i<=n;i++){
            ll x,y;
            cin>>x>>y;
            if (x*x+y*y<=d)
                cnt++;
        }
        cout<<cnt;
	}
};


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


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

int main(){
	int N,W;
	cin >> N >> W;
	
	vector<int> weight(110);
	vector<int> value(110);
	vector<vector<long long>> dp(110, vector<long long>(100010,0));
	for(int i=0; i<N; i++) cin >> weight[i] >> value[i];

	for(int i=0; i<N; ++i){
		for(int j=0; j<=W; ++j){
			if(j - weight[i] >= 0){
				dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]]+value[i]);
			}

			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
		}
	}

	cout << dp[N][W] << endl;
}

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

int main() {
	int n, d, a; cin >> n >> d >> a;
	vector<P> p(n);
	rep(i, n) cin >> p[i].first >> p[i].second;
	sort(p.begin(), p.end());
	d = d * 2;
	ll ans = 0;
	ll tot = 0;
	queue<pair<ll, ll>> que;
	rep(i, n) {
		ll x = p[i].first;
		ll h = p[i].second;
		while (que.size() && que.front().first < x) {
			tot -= que.front().second;
			que.pop();
		}
		h -= tot;
		if (h > 0) {
			ll num = (h + a - 1) / a;
			ans += num;
			ll damage = num * a;
			tot += damage;
			que.emplace(x + d, damage);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
using System;
class at{
static void Main(){
var line = Console.ReadLine().Split(' ');
int n = int.Parse(line[0]);
int say = int.Parse(line[1]);
bool lay = false;
int x = -1;
int y = -1;
int z = -1;
for(int i = 0;i <= n;i++)
{
	for(int j = 0;j <= n-i;j++)
	{
			int sum = i*10000 + 5000*j + (n-i-j)*1000;
			if(sum == say)
			{
				x = i;
				y = j;
				z = n-i-j;
		}
	}
}
Console.WriteLine(x + " " + y + " " + z);
}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n; cin>>n;
  vector<int>P(n), Q(n), A(n);
  for(int i = 0; i < n; i++)  cin>>P[i];
  for(int i = 0; i < n; i++) {
      cin>>Q[i];
      A[i] = i+1;
  }

  int x = 0, y = 0, cnt = 1;
  while(next_permutation(A.begin(), A.end())) {
    if(A == P)  x = cnt;
    if(A == Q)  y = cnt;
    ++cnt;
  }
  cout<<abs(x-y)<<"\n";
  return 0;
}
   


Measured memory_bytes: 256
import Data.List

solve :: Int -> Int -> Int
solve n m = m `div` (head $ dropWhile (< n) $ sort $ divisors m)

sieve :: [Int]
sieve = 2 : sieve_sub [2] [3..]

sieve_sub :: [Int] -> [Int] -> [Int]
sieve_sub (n:yet) cand =
  let
    (cnfmd, rem) = span (< n*n) cand
    newcand = filter (\i -> i `mod` n /= 0) rem
  in cnfmd ++ sieve_sub (yet ++ cnfmd) newcand

prfac :: Int -> [(Int,Int)]
prfac n = filter ((>= 1) . snd) $ unfoldr f (sieve, n)
  where
    f (_, 1) = Nothing
    f (p:ps, k) | p*p > k   = Just ((k, 1), ([], 1))
                | otherwise = Just ((p, pow), (ps, div k p_pow))
      where (pow, p_pow) = divmany k p
    divmany k p = sub 0 1 k
      where sub pow p_pow x | m == 0    = sub (pow+1) (p_pow*p) d
                            | otherwise = (pow, p_pow)
              where (d,m) = divMod x p

divisors :: Int -> [Int]
divisors n = sub (prfac n)
  where sub []            = [1]
        sub ((p,r) : prs) = [x*y | x <- [p^k | k <- [0..r]], y <- sub prs]

main = do
  cont <- getContents
  let n : m : _ = map read $ words cont
  putStrLn $ show $ solve n m


Measured memory_bytes: 2172
#include<cstdio>
const int maxn=100010;
int n,d;
int g;
int ab(int x) {
	return x>0?x:-x;
}
int gcd(int a,int b) {
	return !b?a:gcd(b,a%b);
}
int main() {
	scanf("%d%d",&n,&d);
	for(register int i=1,x;i<=n;++i)scanf("%d",&x),g=gcd(ab(x-d),g);
	printf("%d\n",g);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    map<P, int> m;

    int H, W, N;
    cin >> H >> W >> N;
    REP(i, N){
        int a, b;
        cin >> a >> b;
        FOR(j, a-1, a+2)FOR(k, b-1, b+2){
            if(m.find(mp(j,k)) == m.end()) m[mp(j, k)] = 1;
            else m[mp(j, k)]++;
        }
    }
    vector<llint> ans(10,0);
    for(auto x : m){
        P key = x.first;
        if(key.first <= 1 || key.first >= H) continue;
        if(key.second <= 1 || key.second >= W) continue;

        ans[m[key]]++;
    }

    ans[0] = (llint)(H-2)*(W-2);
    FOR(i, 1, 10) ans[0] -= ans[i];
    REP(i, 10) cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 56576
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

# 穴が開いている段
a = [int(input()) for _ in range(M)]

# 動的計画法
DP = [1] * (N + 1)

# 穴が開いている段への進み方は0通りにする
for idx in a:
    DP[idx] = 0

# 以下、漸化式のように解く
if N >= 2:
    for i in range(2, N+1):
        if DP[i] != 0:
            if DP[i - 1] != 0:
                if DP[i - 2] != 0:
                    DP[i] = DP[i - 1] + DP[i - 2]
                else:
                    DP[i] = DP[i - 1]
            else:
                if DP[i - 2] != 0:
                    DP[i] = DP[i - 2]
                else:
                    DP[i] = 0

print(DP[N]%MOD)


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

using namespace std;

int main()
{
	int dp[8];
	
	dp[0]=1;
	for(int i=1;i<=7;i++)
	{
		dp[i]=dp[i-1]*i;
	}
	
	int n;
	cin>>n;
	bool vis[n+1];
	memset(vis,false,sizeof(vis));
	int a=0,b=0;
	int p[n],q[n];
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>q[i];
	}
	
	for(int i=0;i<n;i++)
	{
		int count=0;
		for(int j=i+1;j<n;j++)
		{
			if(p[i]>p[j])
			{
				count++;
			}
		}
		a+=count*dp[n-i-1];
	
	}
	//cout<<a<<endl;
	memset(vis,false,sizeof(vis));
	
	for(int i=0;i<n;i++)
	{
		int count=0;
		for(int j=i+1;j<n;j++)
		{
			if(q[i]>q[j])
			{
				count++;
			}
		}
		
		b+=count*dp[n-i-1];
	}
	cout<<abs(a-b)<<endl;
	

}

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

int main()
{
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] != T[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3852
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.size();

    s += s;
    bool ans = false;
    for (int i=0; i<n; i++) {
        if (s.substr(i, n) == t) ans = true;
    }

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

}

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

int main(){
  constexpr int N= 5;
  vector<int> data(N);

  for(int i=0; i<N; i++){
    cin >> data.at(i);
    if(data.at(i)==0){
      cout << i+1 << endl;
      break;
    }
  }
}

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

string s[1002];
int a[1002];

bool check(string x, string y){
  for(int i = 0; i < x.size(); i++){
    if(x[i] != '*' && x[i] != y[i]){
      return false;
    }
  }
  return true;
}

int main(){
  int n, m;

  while(cin >> n >> m, n || m){
    for(int i = 0; i < n; i++){
      cin >> s[i] >> a[i];
    }

    int res = 0;

    for(int i = 0; i < m; i++){
      string t;
      cin >> t;

      for(int j = 0; j < n; j++){
	if(check(s[j], t)){
	  res += a[j];
	  break;
	}
      }
    }

    cout << res << endl;
  }
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define ll long long
#define MAX 4000005
#define P ((ll)1e9+7)
using namespace std;

ll qpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n&1) res = res*a%P;
        a = a*a%P;
        n >>= 1;
    }
    return res;
}

ll fac[MAX], inv[MAX];

void init(){
    fac[0] = 1;
    for(int i = 1; i < MAX; i++){
        fac[i] = fac[i-1]*i%P;
    }
    inv[MAX-1] = qpow(fac[MAX-1], P-2);
    for(int i = MAX-2; i >= 0; i--){
        inv[i] = inv[i+1]*(i+1)%P;
    }
}

ll C(ll n, ll m){
    if(!m) return 1;
    return fac[n]*inv[m]%P*inv[n-m]%P;
}

ll calc(ll x, ll l, ll r){
    return (C(r+1, x+1)-C(l, x+1)+P)%P;
}

int main()
{
    init();
    ll x1, y1, x2, y2, ans = 0;
    cin >> x1 >> y1 >> x2 >> y2;
    for(int i = x1; i <= x2; i++){
        ans = (ans+calc(i, i+y1, i+y2))%P;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 62720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int64_t dp[51][51][2501] = {};
int main(){
    int N, A;
    cin >> N >> A;

    vector<int> x(N);
    int sum = 0;
    for(auto& c : x){
        cin >> c;
        sum += c;
    }

    dp[0][0][0] = 1;
    for(int i = 1; i <= N; ++i){
        dp[i][0][0] = 1;
        dp[i][1][x[i-1]]++;
        for(int j = 1; j <= N; ++j){
            for(int k = 0; k <= sum; ++k){
                dp[i][j][k] += dp[i-1][j][k];
                if(k > x[i-1]){
                    dp[i][j][k] += dp[i-1][j-1][k - x[i-1]];
                }
            }
        }
    }

    int64_t ans = 0;
    for(int i = 1; i <= N; ++i){
        ans += dp[N][i][A*i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 50048
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int s[][] = new int[H + 2][W + 2];
    for (int i = 1; i < H + 1; i++) {
      String line = sc.next();
      for (int j = 1; j < W + 1; j++) {
        if (line.charAt(j - 1) == '.')
          s[i][j] = 0;
        else
          s[i][j] = 1;
      }
    }
    for (int i = 1; i < H + 1; i++) {
      for (int j = 1; j < W + 1; j++) {
        if (s[i][j] != 1) {
          continue;
        } else {
          if (s[i][j - 1] == 1 || s[i][j + 1] == 1 || s[i - 1][j] == 1 || s[i + 1][j] == 1) {
            continue;
          } else {
            System.out.println("No");
            return;
          }
        }
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 21972
/**
 * @author yuzining
**/
#ifdef local
#include "D:\vscode\acm\local.hpp"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
  return 0;
}
#endif

void Main() {
  int n; cin >> n;
  cout << (1000 - n % 1000) % 1000 << '\n';
}

Measured memory_bytes: 3652
#Golden Coins
cost_1 = int(input())

numbers_500 = int(cost_1 / 500)
cost_2 = cost_1 - (numbers_500 * 500)

numbers_5 = int(cost_2 / 5)
cost_3 = cost_2 - (numbers_5 *5)

#print(numbers_500, numbers_5)
#print(cost_1, cost_2, cost_3)
print(int(numbers_500*1000 + numbers_5*5))


Measured memory_bytes: 2940
input = gets.chomp.split(" ").map(&:to_i)
scores = Array.new(input[0],input[1]-input[2])

input[2].times do
  answer = gets.chomp.to_i - 1
  scores[answer] += 1
end
  
scores.each do |e|
  if e > 0
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pi acos(-1)
#define mod 1000000007
#define inf INT_MAX
#define scl(x) scanf("%lld",&x)
#define sc(x) scanf("%d",&x)
int main()
{

    //ios_base::sync_with_stdio(false);cin.tie(NULL);

    int i,j,k,n,t,ans=0,x,ct=0,ln,ok=0,m,y,sum=0,a;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        sc(a);
        if(i%2==1&&a%2==1)
            ans++;
    }
    cout<<ans<<endl;



}




Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;


int main()
{ 
    int n;
    cin>>n;
    int k;
    LL s;
    cin>>k;
    cin>>s;
    if(n==k){
        for(int i=0;i<n-1;i++){
            cout<<s<<' ';
        }
        cout<<s<<endl;
        return 0;
    }
    for(int i=0;i<k;i++){
        cout<<s<<' ';
    }
    LL y=s+1;
    if(s==1000000000){
        y=s-1;
    }
    for(int i=k;i<n-1;i++){
        cout<<y<<' ';
    }
    cout<<y<<endl;
    return 0;

}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	int a=0,b=0,c=0,n;
	cin >> n;
	for(int i=0;i<n;i++){
		int x; cin >> x;
		if(x%2 == 1) a++;
		else if(x%4 == 2) b++;
		else c++;
	}
	if(b == 0){
		puts(a<=c+1?"Yes":"No");
	}
	else{
		puts(a<=c?"Yes":"No");
	}
}

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

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

  int ans = 1e9;
  int D, G;
  cin >> D >> G;
  int p[D], c[D];
  FOR(i, 0, D) { cin >> p[i] >> c[i]; }

  FOR(bit, 0, (1 << D)) {
    int sum = 0;
    int count = 0;

    FOR(i, 0, D) {
      if (bit & (1 << i)) {
        sum += 100 * (i + 1) * p[i] + c[i];
        count += p[i];
      }
    }

    if (sum >= G) {
      ans = min(ans, count);
    } else {
      RFOR(i, D - 1, -1) {
        if (bit & (1 << i)) {
          continue;
        }

        FOR(j, 0, p[i]) {
          if (sum >= G) {
            break;
          }

          sum += 100 * (i + 1);
          count++;
        }
      }

      ans = min(ans, count);
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll ggcd(ll a, ll b)
{
	if(b==0)
	{
		return a;
	}
	return ggcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,i,j,k,s=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			for(k=1;k<=n;k++)
			{
				ll temp = ggcd(i,j);
				temp = ggcd(temp,k);
				s += temp;
			}
		}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

typedef set<string> ss;

int main()
{
	int N; cin >> N;
	ss U;
	rep(i, 0, N)
	{
		string s; cin >> s; U.insert(s);
	}

	int M; cin >> M;
	int f = 0;
	rep(i, 0, M)
	{
		string s; cin >> s;
		if (U.find(s) == U.end())
		{
			cout << "Unknown " + s << endl;
			continue;
		}

		if (f == 0)
			cout << "Opened by " + s << endl;
		else
			cout << "Closed by " + s << endl;

		f = (f + 1) % 2;
	}
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<int,int>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
  string s,t;
  cin>>s>>t;
  ll ans=10000;
  ll a,b,c;
  a=s.length();
  b=t.length();
  c=a-b;
  rep(i,c+1){
    ll ab=0;
    rep(j,b){
      if(s[j+i]!=t[j]){
        ab++;
      }
    }
    ans=min(ab,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b; string s;
  cin >> a >> b >> s;
  bool flag = true;
  rep(i,0,a) {
    if (s[i] == '-') {
      flag = false;
    }
  }
  if (s[a] != '-') {
    flag = false;
  }
  rep(i,a+1,a+b+1) {
    if (s[i] == '-') {
      flag = false;
    }
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int main(){
    string s; cin >> s;
    if(s[s.size()-1] == 's'){
        cout << s << "es" << endl;
    }else{
        cout << s << "s" << endl;
    }
}

Measured memory_bytes: 3620
fun main(args: Array<String>) {
    val INF = 1000000001
    val (N, M, L) = readInputLine().split(" ").map { it.toInt() }
    val d = Array(N) { IntArray(N) { INF } }

    for (i in 0 until N) {
        d[i][i] = 0
    }

    for (i in 1..M) {
        val (A, B, C) = readInputLine().split(" ").map { it.toInt() }
        if (C <= L) {
            d[A - 1][B - 1] = C
            d[B - 1][A - 1] = C
        }
    }

    for (k in 0 until N) {
        for (i in 0 until N) {
            for (j in 0 until N) {
                d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j])
            }
        }
    }
    
    val d2 = Array(N) { IntArray(N) { INF } }
    
    for (i in 0 until N) {
        for (j in 0 until N) {
            if (d[i][j] <= L) {
                d2[i][j] = 1
            }
        }
    }
    
    for (i in 0 until N) {
        d2[i][i] = 0
    }

    for (k in 0 until N) {
        for (i in 0 until N) {
            for (j in 0 until N) {
                d2[i][j] = Math.min(d2[i][j], d2[i][k] + d2[k][j])
            }
        }
    }

    val Q = readInputLine().toInt()
    
    for (i in 1..Q) {
        val (s, t) = readInputLine().split(" ").map { it.toInt() - 1 }
        
        if (d2[s][t] == INF) {
            println(-1)
        } else {
            println(d2[s][t] - 1)
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 72772
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  int x = 1;
  for (int i = 0; i < N; ++i) {
    if (A[i] == x) {
      ++x;
    }
  }
  
  if (x == 1) {
    cout << -1 << endl;
  } else {
    cout << N - x + 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        int H = sc.nextInt();
        int A = sc.nextInt();

        out.println((H + A - 1) / A);

        out.close();
    }


    public static PrintWriter out;

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}


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

void fnInput(int& rnPicSiz, vector<int>& rvnCoordx)
{
  int nCoordxSiz;
  cin >> rnPicSiz >> nCoordxSiz;
  rvnCoordx.resize(nCoordxSiz);

  for (int& rnCoordx : rvnCoordx)
    cin >> rnCoordx;

  sort(begin(rvnCoordx), end(rvnCoordx));
}

int fnMinMoveCnt(int nPicSiz, const vector<int>& cnrvnCoordx)
{
  vector<int> vnDist;

  for (int i = 0; i < cnrvnCoordx.size() - 1; i++)
    vnDist.push_back( cnrvnCoordx[i + 1] - cnrvnCoordx[i] );

  sort(begin(vnDist), end(vnDist));
  int nMinMoveCnt = 0;

  for (int i = 0; i < (int)vnDist.size() - (nPicSiz - 1); i++)
    nMinMoveCnt += vnDist[i];

  return nMinMoveCnt;
}
 
int main()
{
  int nPicSiz;
  vector<int> vnCoordx;

  fnInput(nPicSiz, vnCoordx);
  cout << fnMinMoveCnt(nPicSiz, vnCoordx) << endl;

  return 0;
}

Measured memory_bytes: 4208
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = numeric_limits<int>::infinity();

int main(void)
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i+=2){
        putchar(s[i]);
    }
    putchar('\n');

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

void swap(int *a,int *b)
{
	int c;
	c=*a;
	*a=*b;
	*b=c;
}

int main()
{
	int ball[3]={1,0,0};
	int i;
	char cup1,cup2;
	char ans;

	while(scanf("%c,%c",&cup1,&cup2)!=EOF)
	{
		cup1-='A';
		cup2-='A';
		swap(ball+(int)cup1,ball+(int)cup2);
	}
	for(i=0;i<3;i++)
	{
		if(ball[i]==1)
		{
			ans=(char)i+'A';
		}
	}
	printf("%c\n",ans);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int u[b],v[b],r[b];
    for(int i=0;i<b;i++)
    {
        cin >> u[i] >> v[i] >> r[i];
    }
    int dis[a][a];
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<a;j++)
        {
            dis[i][j]=INT_MAX;
        }
    }
    int g=0;
    for(int i=0;i<a;i++)
    {
        if(g==0)
        {
            dis[i][i]=0;
            //for(int j=1;j<=a;j++)
            {
                if(g==0)
                {
                    for(int k=1;k<a;k++)
                    {
                        for(int l=0;l<b;l++)
                        {
                            if(dis[i][u[l]]!=INT_MAX)
                            {
                                if(dis[i][v[l]]>dis[i][u[l]]+r[l])
                                {
                                    dis[i][v[l]]=dis[i][u[l]]+r[l];
                                }
                            }
                        }
                    }
                    for(int l=0;l<b;l++)
                    {
                        if(dis[i][u[l]]!=INT_MAX)
                        {
                            if(dis[i][v[l]]>dis[i][u[l]]+r[l])
                            {
                                g++;
                                break;
                            }
                        }
                    }
                }
                else
                    break;
            }
        }
        else
            break;
    }
    if(g>0)
        cout << "NEGATIVE CYCLE" << endl;
    else
    {
        for(int i=0;i<a;i++)
        {
            for(int j=0;j<a;j++)
            {
                if(j<a-1)
                {
                    if(dis[i][j]==INT_MAX)
                        cout << "INF" << " ";
                    else
                        cout << dis[i][j] << " ";
                }
                else
                {
                    if(dis[i][j]==INT_MAX)
                        cout << "INF" << endl;
                    else
                        cout << dis[i][j] << endl;
                }
            }
        }
    }
}



Measured memory_bytes: 3216
import java.io.*;
  
class Main{
	public static void main(String[] args) throws IOException{

		int x,y,i,j;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);

			if(x == 0 && y ==0){
				break;
			}

			for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					System.out.printf("#");
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
  	}
}

Measured memory_bytes: 48028
import java.util.Scanner;
public class Main{
    public static void main(String srgv[])
    {
	Scanner scan = new Scanner(System.in);

	int a = scan.nextInt();
	int b = scan.nextInt();

	if( a < b )
	    System.out.println("a < b");
	else if( a > b)
	    System.out.println("a > b");
	else
	    System.out.println("a == b");
    }
}

Measured memory_bytes: 26172
#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, c;
  cin >> a >> b >> c;
    if (a == b + c || b == c + a || c == a + b) {
      cout << "Yes" << endl;
    }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;
using LLONG = long long;

int main()
{
    LLONG N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    LLONG M = min({ A, B, C, D, E });
    cout << (N + M - 1) / M + 4 << endl;
}


Measured memory_bytes: 256
import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = collections.Counter(a)

to_del = max(0, len(c) - k)
cm = c.most_common()[::-1]
ans = sum(cm[i][1] for i in range(to_del))
print(ans)

Measured memory_bytes: 43052
#include <iostream>

int main() {
	int n;
	int r[200000];
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> r[i];
	}
	int s = r[1] - r[0];
	int rr = r[0];
	for (int i = 1; i < n; i++) {
		if (r[i] - rr > s) {
			s = r[i] - rr;
		}
		if (r[i] < rr) {
			rr = r[i];
		}
	}
	std::cout << s << std::endl;
	return 0;
}

Measured memory_bytes: 3828
'use strict';
const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const info = input.splice('\n');
const N = info[0].split(' ')[0];
const M = info[0].split(' ')[1];
const As = info.splice(1 , N);
const Bs = info.splice(1 , M);
let isMatch = "";

// 4重for文でぶん回していく
for(let ax = 0; ax < N - M + 1; ax++){
  for(let ay = 0; ay < N - M + 1; ay++){
    // マッチするかのフラグを用意
    isMatch = true;
   	// ループぬけ用のラベル
    // labelは繰り返しの手前につけないといけないらしい
    loopReset:
    // 小さい方の四角形の1つずつ吟味するfor文
    for(let bx = 0; bx < M; bx++){
	  for(let by = 0; by < M; by++){
        if(As[ax + bx][ay + by] == Bs[bx][by]){
        	continue;
        } else {
        	isMatch = false;
            break loopReset;
        }
      }
    }
    if(isMatch){
    	console.log("Yes");
      	return;
    }
  }
}
console.log("No");




Measured memory_bytes: 9420
n,k=map(int,input().split())
v=list(map(int,input().split()))
finans=0
for l in range(n+1):
  for r in range(n-l+1):
    if l+r>k:
      continue
    ans=[]
    for i in range(l):
      ans.append(v[i])
    for i in range(n-1,n-r-1,-1):
      ans.append(v[i])
    ans.sort()
    i=-1
    for i in range(min(len(ans),k-(r+l))):
      if ans[i]>0:
        i-=1
        break
    ans1=0
    for j in range(i+1,len(ans)):
      ans1+=ans[j]
    finans=max(finans,ans1)
print(finans)

Measured memory_bytes: 73872
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

int N;
vector<ll> a, imos;
vector<vector<ll>> dp;

// find cost [l,r)
ll solve(int l, int r)
{
	if(dp[l][r] != INFL)return dp[l][r];
	if(l + 1 == r)return dp[l][r] = 0;

	ll res = INFL;
	FOR(k, l + 1, r)
	{
		ll tmp = solve(l, k) + solve(k, r) + (imos[r - 1] - (l == 0 ? 0 : imos[l - 1]));
		res = min(res, tmp);
	}
	return dp[l][r] = res;
}

//メイン関数
int main()
{
	// input
	cin >> N;
	a.resize(N);
	dp.resize(N + 1, vector<ll>(N + 1, INFL));
	REP(i, N)cin >> a[i];
	imos = a;
	REP(i, N - 1)imos[i + 1] += imos[i];

	cout << solve(0, N) << endl;
	cin >> N;
	return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL n, m;
    cin >> n >> m;
    vector<LP> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i].F >> v[i].S;

    }
    sort(all(v));

    LL sum = 0;
    int i = 0;
    while(m > 0) {
        if(v[i].S <= m) {
            sum += v[i].S * v[i].F;

        } else {
            sum += m * v[i].F;

        }
        m -= v[i].S;
        ++i;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1792
import sys
from collections import deque

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N, K = MAP()
    S = input() + 'e'

    num = []
    count = []
    tmp0 = 0
    tmp1 = 0
    for i in range(N):
        if S[i] == '0':
            tmp0 += 1
            if S[i + 1] == '1' or S[i + 1] == 'e':
                num += [0]
                count += [tmp0]
                tmp0 = 0
        else:
            tmp1 += 1
            if S[i + 1] == '0' or S[i + 1] == 'e':
                num += [1]
                count += [tmp1]
                tmp1 = 0
    if num[0] == 0:
        num = [1] + num
        count = [0] + count
    if num[-1] == 0:
        num += [1]
        count += [0]
    k = 0
    sumv = sum(count[:2*K+1])
    maxv = sumv
    l = 0
    r = 2*K+1
    for j in range(1, len(num)//2 - K + 1):
        sumv += sum(count[r:r+2])
        sumv -= sum(count[l:l+2])
        r += 2
        l += 2
        maxv = max(maxv, sumv)
    print(maxv)

if __name__ == '__main__':
    main()


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

int main()
{
  int W,H,x,y;
  cin >> W >> H >> x >> y;

  double ans = (double)W * H / 2;
  int p =0;
  if(W == x*2 && H == y*2){
   p =1;
  }
  printf("%.10f %d\n",ans,p);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{    
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    int n = max(x,y);
    int min_p = a*x + b*y;
    int p = min_p;

    rep(i,n)
    {
        if(i<x) p -= a;
        if(i<y) p -= b;
        p += 2*c;
        min_p = min(min_p,p);
    }
    cout << min_p << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    h, n = map(int, input().split())

    num_list = list(map(int, input().split()))

    isWin = False

    for num in num_list:
        h -= num
        if h <= 0:
            isWin = True
            break

    print('Yes' if isWin else 'No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 53572
#include <iostream>
#include <string>

using namespace std;
int main() {
	string s;
	int sum=0;
	cin >> s;
	for (int i = 1; i < s.length(); i++)
	{
		if (s[i - 1] == s[i])
		{
			sum++;
			s[i] = s[i] == '0' ? '1' : '0';
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

long long gcd(long long a, long long b) {
    return b ? gcd(b, a % b) : a;
}

std::vector<long long> divisors(long long n) {
    std::vector<long long> divisors;
    long long i = 1;
    while (i * i <= n) {
        if (n % i == 0) {
            divisors.push_back(i);
            if (i * i != n) {
                divisors.push_back(n/i);
            }
        }
        i++;
    }

    sort(divisors.begin(), divisors.end());
    return divisors;
}


int n, m;
string s;

int main() {
    cin >> n;

    Vi v(n);
    REP(i, n) cin >> v[i];

    int div;
    if (n == 2) {
        div = gcd(v[0], v[1]);
    } else {
        div = gcd(gcd(v[0], v[1]), v[2]);
    }

    Vl divs = divisors(div);
    FOR(i, divs) std::cout << *i << '\n';

    return 0;
}



Measured memory_bytes: 3184
N = int(input())
A = input().split()
A = [int(a) for a in A if int(a) % 2 == 0]

tmp = 0

for a in A:
  if a % 3 == 0 or a % 5 == 0:
    tmp += 1

if tmp == len(A):
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
// #include <unordered_map>
#include <cmath>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m, n) for (int i = m; i < n; i++)
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
#define ST(x, y, z) sort(x + y, x + z);
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
#define re read()
#define case  \
    int T;    \
    cin >> T; \
    rep(_, 1, T)
// #define int ll
#define LL long long
#define int ll
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}

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;
}

const int N = 2e5 + 10;
bool st[N];
signed main()
{
    //STDIN
    int n;cin >> n;
    int ac = 0,tle = 0, wa = 0,ree = 0;
    rep(i,1,n)
    {
        string s;
        cin >> s;
        if (s == "AC")ac++;
        if (s == "WA")wa++;
        if(s=="TLE")tle++;
        if(s=="RE") ree++;
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", ree);
}

Measured memory_bytes: 3720
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, A = MAP()

print(-(-H//A))


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

int prim();
int Infty = 20000000;

int n,*d,*p,**G;
string *color;

int main(){
	cin>>n;
	d = new int[n]; p = new int[n];
	d = d-1; p = p-1;
	G = new int*[n]; for(int i=0;i<n;i++) G[i] = new int[n];
	G = G-1; for(int i=1;i<=n;i++) G[i] = G[i]-1;
	color = new string[n]; color = color-1;

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++) cin>>G[i][j];
	}

	cout<<prim()<<endl;

	delete [] (d+1); delete [] (p+1);
	for(int i=1;i<=n;i++) delete [] (G[i]+1); delete [] (G+1);
	delete [] (color+1);
}

int prim(){
	for(int i=1;i<=n;i++){
		color[i] = "WHITE"; d[i] = Infty;
	}
	d[1] = 0; p[1] = -1;

	while(1){
		int u , mincost = Infty;
		for(int i=1;i<=n;i++){
			if(color[i]!="BLACK"&&d[i]<mincost){
				mincost = d[i];
				u = i;
			}
		}

		if(mincost==Infty) break;

		color[u] = "BLACK";

		for(int v=1;v<=n;v++){
			if(color[v]!="BLACK" && G[u][v]!=-1){
				if(G[u][v]<d[v]){
					d[v] = G[u][v];
					p[v] = u;
					color[v] = "GRAY";
				}
			}
		}
	}

	int sum = 0;
	for(int i=1;i<=n;i++){
		sum += d[i];
	}
	return sum;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
const int max_n = 1e6;
ll a[2][200];
int main(){
  int k;
  cin >> n >> k;
  bool ok[10]={false};
  for(int i=0 ; i<k ; i++){
    int x;  cin >> x;
    ok[x] = true;
  }
  int ans = n;
  int now = 1;
  while(true){
    now = ans;
    while(now>0){
      if(ok[now%10]){
        break;
      }
      now /= 10;
    }
    if(now == 0) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
for _ in range(int(input())):
    s = input()
    l = set([s,s[::-1]])
    for i in range(1,len(s)):
        a,b,ra,rb = s[:i],s[i:],s[:i][::-1],s[i:][::-1]
        l |= set([a+rb,ra+b,ra+rb,b+a,b+ra,rb+a])
    print(len(l))

Measured memory_bytes: 7652