akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N, K;
	cin >> N >> K;

	double log_K = log2(K);

	double ans = 0;
	for (ll n = 1; n <= N; ++n)
	{
		ll num_req = ceil(log_K - log2(n));
		//cout << n << " " << num_req << endl;
		if (num_req <= 0)
		{
			ans += 1.0;
		}
		else
		{
			ans += pow(0.5, num_req);
		}
	}

	ans /= N;
	cout << std::setprecision(20) << ans << endl;

	//system("pause");
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto r = 100_000;
  foreach (_; n.iota)
    r = next(r);
  writeln(r);
}

int next(int r)
{
  r = r + r / 20;
  if (r % 1000 > 0)
    return (r / 1000 + 1) * 1000;
  else
    return r / 1000 * 1000;
}

Measured memory_bytes: 2420
#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;

struct Spell {
  int health = 0;
  int cost = 0;
};

class Solver {
 public:
  explicit Solver(int h, vector<Spell> spells) : h_(h), spells_(move(spells)) {
    dp_.resize(h + 1, -1);
  }

  int Solve() { return SolveAux(h_); }

 private:
  int SolveAux(int h) {
    if (h <= 0) return 0;

    int& ans = dp_[h];
    if (ans != -1) return ans;

    ans = 0x3f3f3f3f;
    for (const Spell& spell : spells_) {
      ans = min(ans, SolveAux(h - spell.health) + spell.cost);
    }

    return ans;
  }

  int h_;
  vector<int> dp_;
  vector<Spell> spells_;
};

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

  vector<Spell> spells(n);
  for (Spell& spell : spells) cin >> spell.health >> spell.cost;

  Solver s(h, move(spells));
  cout << s.Solve() << endl;

  return 0;
}


Measured memory_bytes: 640
HW = list(map(int,input().split()))
if all(x%2==1 for x in HW) and HW[0]>1 and HW[1]>1:
    print(int((HW[0]*HW[1]+1)/2))
elif HW[0] == 1 or HW[1] == 1:
    print(1)
else:
    print(int((HW[0]*HW[1])/2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18 ;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll n;
ll t[1005];
ll a[1005];
ll x[1005];
ll mul(ll a,ll b)
{
    if(a > inf/b)return inf + 5;
    return a*b;
}
int main()
{
  finp;
  cin>>n;
  cin>>t[1]>>a[1];
  x[1]=1;

  afor(i,2,n)
  {
    cin>>t[i]>>a[i];

    ll low = 1; ll high = 1e18;

    while(low < high)
    {
        if(low+1 == high)
        {
            if(mul(t[i],low)<mul(t[i-1],x[i-1]) || mul(a[i],low)<mul(a[i-1],x[i-1]))low=high;
            break;
        }
        ll mid = (low + high)/2;
        if(mul(t[i],mid)<mul(t[i-1],x[i-1]) || mul(a[i],mid)<mul(a[i-1],x[i-1]))low=mid+1;
        else high =mid;

    }

    x[i] = low;


  }

  cout<<(t[n]*x[n] + a[n]*x[n]);
return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <ctype.h>

void FuncOpenLock(char str[96], int key);

int main(void)
{
  char buf[81];
  int key;
  int i;

  while (fgets(buf, 81, stdin) != NULL) {
    char temp[81];
    
    key = 27;
    for (i = 0; i < 26; i++) {
      strcpy(temp, buf);
      FuncOpenLock(temp, i);

      if (strstr(temp, "the")  != NULL ||
	  strstr(temp, "this") != NULL ||
	  strstr(temp, "that") != NULL) {
	key = i;
      }
      
      if (key != 27) {
	printf("%s", temp);
	break;
      }
    }
  }

  return 0;
}

void FuncOpenLock(char *str, const int key)
{
  int i;
  
  for ( i = 0; str[i] != '\n'; i++ ) {
    if ( isalpha(str[i]) ) {
      str[i] = ((str[i] - 'a' + key) % 26) + 'a';
    }
  }
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int mod=1e9+7;
const int INF = LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,x;
    cin>>n>>m>>x;
    vector<int>c(n);
    int a[n][m];
    for(int i=0;i<n;i++)
    {  cin>>c[i];
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    int ans=INT_MAX;
    for(int i=0;i<(1<<n);i++)
    {
       vector<int>v(m,0);
       int cost=0;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
              for(int k=0;k<m;k++)
              {
                 v[k]+=a[j][k];
              }
              cost+=c[j];
            }
        }
        int f=0;
        for(int i=0;i<m;i++)
        {
            if(v[i]<x){f=1;break;}
        }
        if(f==0)
        {
            ans=min(ans,cost);
        }
    }
    if(ans==INT_MAX)
        cout<<-1<<endl;
    else
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    string s;
    cin>>s;
    int l=0,r=s.length()-1,ans=0;
    while(l<r){
        if(s[l]==s[r]){
            l++;
            r--;
        }else if(s[l]=='x'&&s[r]!='x'){
            ans++;
            l++;
        }else if(s[l]!='x'&&s[r]=='x'){
            ans++;
            r--;
        }else if(s[l]!=s[r]){
            ans=-1;
            break;
        }
    }
    out(ans);
}

Measured memory_bytes: 3812
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll a;
    ll b;
    ll c;
    ll k;
    ll ans=0;
    cin >> a >> b  >> c >> k;
    if(k <= a){
        ans = k;
    }else if( k <= a+b ){
        ans = a;
    }else{
        ans = a-(k-(a+b));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G1[500005];
vector<ll> G2[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
 
ll mod = 1000000007;
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

 
//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,ans,a,b,c,e,g,h,w,i,j,k,q;
ll x[500005],y[500005],z[500005];
ll haibun[405][405];
ll dp[405][405];
char s[500005];
bool dame;

int main(){
    cin >> n >> c;
    for(i=0;i<n;i++){
        cin >> x[i];
    }
    for(i=0;i<n;i++){
        cin >> y[i];
    }
    for(i=1;i<=400;i++){
        for(j=0;j<=400;j++){
            haibun[i][j] = rui(i,j);
        }
    }
    for(j=0;j<=400;j++){
        for(i=1;i<=400;i++){
            haibun[i][j] += haibun[i-1][j];
            haibun[i][j] %= mod;
        }
    }
    dp[0][0] = 1;
    for(i=1;i<=n;i++){
        for(j=0;j<=c;j++){
            //dp[i][j]の値を決定する
            for(k=0;k<=c;k++){
                if(j - k < 0)continue;
                ll sum1,sum2;
                sum1 = haibun[x[i-1]-1][k];
                sum2 = haibun[y[i-1]][k];
                num = sum2 - sum1 + mod;
                num %= mod;
                dp[i][j] += (dp[i-1][j-k] * num) % mod;
                dp[i][j] %= mod;
            }
            //pe(dp[i][j]);
        }
        //el;
    }
    p(dp[n][c]);
    return 0;
}












Measured memory_bytes: 31872
import sys

N, W = [int(i) for i in sys.stdin.readline().rstrip("\n").split()]
goods_v = []
goods_w = []
for _ in range(N):
    elem = [int(i) for i in sys.stdin.readline().rstrip("\n").split()]
    goods_v.append(elem[0])
    goods_w.append(elem[1])
    
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if w >= goods_w[i]:
            dp[i+1][w] = max(dp[i][w], dp[i][w-goods_w[i]] + goods_v[i])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[N][W])


Measured memory_bytes: 25508
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
    int N;
    cin >> N;
    int h[N];
    int dp[N];
    fill(dp, dp + N, INT_MAX);
    dp[0] = 0;
    for (int &content : h) {
        cin >> content;
    }
    for (int i = 0; i < N; i++) {
        for (const int k: {1, 2}) {
            if (i + k < N) {
                dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
            }
        }
    }
    cout << dp[N-1] << endl;

}

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

struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
};
struct node *head;


void pre(struct node *u){
  if(u->key == -200000001){
    return;
  }
  printf(" %d", u->key);
  pre(u->l);
  pre(u->r);
}

void in(struct node *u){
  if(u->key == -200000001){
    return;
  }
  in(u->l);
  printf(" %d", u->key);
  in(u->r);
}

void insert(int u){
  struct node *z;
  z = (struct node *)malloc(sizeof(struct node));
  z->key = u;
  z->l = (struct node *)malloc(sizeof(struct node));
  z->r = (struct node *)malloc(sizeof(struct node));
  z->l->key = -200000001;
  z->r->key = -200000001;
  struct node *y;
  struct node *x;
  x = head;
  y = head->p;

  while(x->key != -200000001){
    y = x;
    if(u < x->key){
      x = x->l;
    }else{
      x = x->r;
    }
  }
    
  z->p = y;
  if(y->key == -200000001){
    head = z;
  }else if(z->key < y->key){
    y->l = z;
  }else{
    y->r = z;
  }
}

int findr(int k, struct node *z){
  if(z->key == -200000001){
    return 0;
  }else if(z->key == k){
    return 1;
  }
  if(k < z->key){
    return findr(k, z->l);
  }else{
    return findr(k, z->r);
  }
}

int find(int k){
  int l = findr(k, head);
  return l;
}

void print(void){
  in(head);
  printf("\n");
  pre(head);
  printf("\n");
}

void delete(int k){
  struct node *z = head;
  int a;
  while(z->key != -200000001){
    if(k == z->key){
      if(z->l->key == -200000001 && z->r->key == -200000001){
	z->key = -200000001;
	free(z->l);
	free(z->r);
	return;
      }else if(z->l->key == -200000001){
	if(a){
	  z->p->l = z->r;
	  z->r->p = z->p;
	  free(z);
	  return;
	}else{
	  z->p->r = z->r;
	  z->r->p = z->p;
	  free(z);
	  return;
	}
      }else if(z->r->key == -200000001){
	if(a){
	  z->p->l = z->l;
	  z->l->p = z->p;
	  free(z);
	  return;
	}else{
	  z->p->r = z->l;
	  z->l->p = z->p;
	  free(z);
	  return;
	}
      }else{
	struct node *y;
	struct node *x;
	x = z->r;
	y = z;
	while(x->key != -200000001){
	  y = x;
	  x = x->l;
	}
	z->key = y->key;
	k = y->key;
	z = y->p;
      }
    }
  
    if(k < z->key){
      z = z->l;
      a = 1;
    }else{
      z = z->r;
      a = 0;
    }
  }
}

int main(void){
  int i, n, x;
  head = (struct node *)malloc(sizeof(struct node));
  head->key = -200000001;
  head->l = (struct node *)malloc(sizeof(struct node));
  head->r = (struct node *)malloc(sizeof(struct node));
  head->p = (struct node *)malloc(sizeof(struct node));
  head->p->key = -200000001;
  head->l->key = -200000001;
  head->r->key = -200000001;
  char s[16];
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", s);
    if(!strcmp(s, "insert")){
      scanf("%d", &x);
      insert(x);
    }else if(!strcmp(s, "print")){
      print();
    }else if(!strcmp(s, "find")){
      scanf("%d", &x);
      if(find(x)){
	printf("yes\n");
      }else{
	printf("no\n");
      }
    }else if(!strcmp(s, "delete")){
      scanf("%d", &x);
      delete(x);
    }
  }
  return 0;
}


Measured memory_bytes: 57944
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,i,j,a[1010][1010],t=-1,k[1010]={};
  bool d[1010],pos=true;
  cin >> n;
  for (i=1;i<=n;i++) for (j=0;j<n-1;j++) cin >> a[i][j];
  while (pos){
    t++;
    pos=false;
    for (i=1;i<=n;i++) d[i]=false;
    for (i=1;i<=n;i++) if (k[i]!=n-1){
      j=a[i][k[i]];
      if (!d[i] && !d[j] && a[j][k[j]]==i){
        pos=true;
        k[i]++;
        k[j]++;
        d[i]=true;
        d[j]=true;
      }
    }
  }
  for (i=1;i<=n;i++) if (k[i]!=n-1) break;
  if (i==n+1) cout << t << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 4224
def main():
    N, M, K = tuple(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])
    for i in range(M):
        b.append(b[i] + B[i])

    ans, j = 0, M
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i + j)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47336
#include<bits/stdc++.h>
using namespace std;
int h,w,a,b,s[1002][1002];
int main()
{
	cin>>h>>w>>a>>b;
	if(h<b*2||w<a*2)
	{
		cout<<-1;return 0;
	}
	for(int i=1;i<=b;i++)
	for(int j=1;j<=a;j++)s[i][j]=1;
	for(int i=b+1;i<=h;i++)
	{
		for(int j=a+1;j<=w;j++)s[i][j]=1;
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)putchar('0'+s[i][j]);puts("");
	}
}


Measured memory_bytes: 5120
n=int(input())
S=[0,0,0,0]
for i in range(n):
    s=input()
    if s=='AC':
        S[0]+=1
    if s=='WA':
        S[1]+=1
    if s=='TLE':
        S[2]+=1
    if s=='RE':
        S[3]+=1

print('AC x ' + str(S[0]))
print('WA x ' + str(S[1]))
print('TLE x ' + str(S[2]))
print('RE x ' + str(S[3]))

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=11;
char s[MAXN];
int a[10010];
int t[4];
int ans=0;
int main()
{
	int n=read();
	for(int i=1;i<=n;++i)
	{
		scanf("%s",s);
		int len=strlen(s);
		for(int j=0;j<len-1;++j)
			if(s[j]=='A' && s[j+1]=='B')
				++ans;
		if(s[0]=='B')
			a[i]=2;
		if(s[len-1]=='A')
			a[i]=1;
		if(s[0]=='B' && s[len-1]=='A')
			a[i]=3;
		++t[a[i]];
	}
	if(t[3] && t[1])
	{
		--t[1];
		++ans;
	}
	ans+=max(0,t[3]-1);
	if(t[3] && t[2])
	{
		--t[2];
		++ans;
	}
	ans+=min(t[1],t[2]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2])
    {
        cout << "Yes" << endl;
    }
    else if (s[1] == s[2] && s[2] == s[3])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;

int main()
{
	long long a,b,c,d,e,ans;
	while(~scanf("%lld %lld %lld",&a,&b,&c))
	{
		if(a%2==0||b%2==0||c%2==0) ans = 0;
		else
		{
			if(a <= c&&b <= c) ans = a*b;
			else if(a <= b&& c <= b) ans = a*c;
			else if(c <= a&& b <= a) ans = b*c;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
/* 解法思い付かず、解説放送の通りに実装 */

#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	string s;
	cin >> s;
	ll n = s.length();

	if(s[0] == '0' || s[n-1] == '1') {
		cout << -1 << endl;
		return 0;
	}

	rep(i, n/2) {
		if(s[i] != s[n-i-2]) {
			cout << -1 << endl;
			return 0;
		}
	}

	ll tmp = 0;
	repd(i, 1, n) {
		if(s[i] == '1') {
			repd(j, tmp, i) {
				cout << j + 1 << " " << i + 1 << endl;
			}
			tmp = i;
		}
	}

	cout << tmp + 1 << " " << n << endl;

	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
using ll = long long;
using pi = pair <ll, ll>;
vector <pi> e[N];
int ans[N];
void dfs(int u, int fa, int uc)
{
	int col = 0;
	for (auto i : e[u])
	{
		int v = i.first;
		if (v == fa)
			continue;
		++col;
		if (col == uc)
			++col;
		ans[i.second] = col;
		dfs(v, u, col);
	}
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		cin >> u >> v;
		e[u].emplace_back(make_pair(v, i));
		e[v].emplace_back(make_pair(u, i));
	}
	dfs(1, 0, 0);
	cout << *max_element(ans + 1, ans + n) << endl;
	for (int i = 1; i < n; ++i)
		cout << ans[i] << endl;
}


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

int main() {
   int n,m;
   cin >> n >> m;
   vector<int> v(50);
   rep(i,n){
   int k; cin >> k;
   rep(i,k){
      int a; cin >> a;
      v[a]++;
   }
   }
   int ans=0;
   rep(i,50){
      if(v[i]==n)
      ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		System.out.println(b/a < c ? b/a : c);

	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=101;
int a[N],b[N],n,ans=0;

int keisan(int x){
	int ansk=0;
	ansk+=a[1];
	FOR(i,2,x+1){
		ansk+=a[i];
	}
	FOR(i,x,n+1){
		ansk+=b[i];
	}
	return ansk;
}




int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	FOR(i,1,n+1)cin>>a[i];
	FOR(i,1,n+1)cin>>b[i];
	FOR(i,1,n)ans=max(ans,keisan(i));
	if(n==1)ans=a[1]+b[1];
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

ll n;


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
   
 cin >> n;
  
 vll a(n);
 map<ll,ll> mp;
  
  rep(i,0,n) {
    cin >> a[i];
    mp[a[i]]++;
  }
  
  ll res=0;
  for(auto p :mp){
    ll x=p.second;
    res+=x*(x-1)/2;
  }
  
  ll k=0;
  while(k<n){
    ll x=mp[a[k]];
    cout << res-(x-1) << endl;
   k++; 
  }
  
  
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll query(string &s)
{
	cout<<"? "<<s<<'\n';
	fflush(stdout);
	ll x; cin>>x;
	return x;
}

vector<ii> edges;

void out()
{
	cout<<"! ";
	for(int i=0;i<edges.size();i++)
	{
		cout<<"(";
		cout<<edges[i].fi<<","<<edges[i].se<<")";
		if(i+1<edges.size()) cout<<' ';
	}
	cout<<'\n';
	fflush(stdout);
}

struct DSU
{
	int S;
	
	struct node
	{
		int p; ll sum;
	};
	vector<node> dsu;
	
	DSU(int n)
	{
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	void reset(int n)
	{
		dsu.clear();
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	int rt(int u)
	{
		if(dsu[u].p == u) return u;
		dsu[u].p = rt(dsu[u].p);
		return dsu[u].p;
	}
	
	void merge(int u, int v)
	{
		u = rt(u); v = rt(v);
		if(u == v) return ;
		if(rand()&1) swap(u, v);
		dsu[v].p = u;
		dsu[u].sum += dsu[v].sum;
	}
	
	bool sameset(int u, int v)
	{
		if(rt(u) == rt(v)) return true;
		return false;
	}
	
	ll getstat(int u)
	{
		return dsu[rt(u)].sum;
	}
};

int main()
{
	vector<ii> possible;
	srand(13);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			possible.pb(mp(i,j));
		}
	}
	random_shuffle(possible.begin(),possible.end());
	DSU dsu(n);
	for(int i=0;i<possible.size();i++)
	{
		if(dsu.sameset(possible[i].fi,possible[i].se)) continue;
		string s(n,'0');
		s[possible[i].fi]=s[possible[i].se]='1';
		if(query(s)==1)
		{
			dsu.merge(possible[i].fi,possible[i].se);
			edges.pb(possible[i]);
		}
		if(int(edges.size())>=n-1)
		{
			out();
			return 0;
		}
	}
		
}


Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  int ans =0;
  for(int i = 1; i < 3; i++) ans += a[i] - a[i - 1];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

static int a[200'000];

int main() {
    int n;
    scanf("%u", &n);
  
  	auto xor_total = 0;
    for (auto i = 0; i < n; i += 2) {
        scanf("%u %u", &a[i], &a[i + 1]);
        xor_total ^= (a[i] ^ a[i + 1]);
    }
    for (auto i = 0; i < n; i += 2) {
        printf("%u %u ", xor_total ^ a[i], xor_total ^ a[i + 1]);
    }

    return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;

int main() {
    string N;
    cin >> N;
    reverse(ALL(N));
    if(N[0] == '2' || N[0] == '4' || N[0] == '5' || N[0] == '7' || N[0] == '9') {
        cout << "hon" << endl;
    } else if(N[0] == '0' || N[0] == '1' || N[0] == '6' || N[0] == '8') {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  if (n%1000 == 0){
    cout << 0 << endl;
  }else{
  cout << 1000-(n%1000) << endl;
  }
}


Measured memory_bytes: 3592
#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;

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

    int N, X, tmp;
    pqr<int> q;

    cin >> N >> X;
    rep (i, N) {
        cin >> tmp;
        q.push(tmp);
        X -= tmp;
    }

    tmp = q.top();
    print(N + X / tmp);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s1[4096], s2[4096];
    static short dp[4096][4096];
    int i, j;
    int l1, l2;
    int ans;
    
    while (scanf("%s%s", &s1, &s2) == 2){
        l1 = strlen(s1);
        l2 = strlen(s2);
        
        memset(dp, 0, sizeof(dp));
        ans = 0;
        
        for (i = 1; i <= l1; i++){
            for (j = 1; j <= l2; j++){
                if (s1[i - 1] == s2[j - 1]){
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                else {
                    dp[i][j] = 0;
                }
                ans = ans > dp[i][j] ? ans : dp[i][j];
            }
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}

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

using namespace std;

vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  int wcnt = 0;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '.') wcnt++;
    }
  }
  vector<vector<int>> grid(H, vector<int>(W, -1));
  queue<pair<int, int>> que;
  grid[0][0] = 0;
  que.push(make_pair(0, 0));
  while (!que.empty()) {
    auto xy = que.front();
    que.pop();
    int x = xy.first, y = xy.second;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
      if (S[ny][nx] == '#' || grid[ny][nx] != -1) continue;
      grid[ny][nx] = grid[y][x] + 1;
      que.push(make_pair(nx, ny));
    }
  }
  cout << (grid[H - 1][W - 1] == -1 ? -1 : wcnt - (grid[H - 1][W - 1] + 1))
       << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
namespace yspm{
	inline int read()
	{
		int res=0,f=1; char k;
		while(!isdigit(k=getchar())) if(k=='-') f=-1;
		while(isdigit(k)) res=res*10+k-'0',k=getchar();
		return res*f;
	}
	const int mod=1e9+7,N=4e3+100,M=2e5+10,s=2010;
	int inv[M],fac[M];
	int n,x[M],y[M],f[N][N];
	inline void prework()
	{
		inv[0]=inv[1]=1; fac[0]=1;
		for(int i=1;i<M;++i) fac[i]=fac[i-1]*i%mod;
		for(int i=2;i<M;++i) inv[i]=mod-mod/i*inv[mod%i]%mod;
		for(int i=1;i<M;++i) inv[i]*=inv[i-1],inv[i]%=mod;;
		return ;
	}
	inline int C(int n,int m){return fac[n]*inv[n-m]%mod*inv[m]%mod; }
	
	signed main()
	{
		prework(); n=read(); 
		for(int i=1;i<=n;++i) x[i]=read(),y[i]=read(),f[s-x[i]][s-y[i]]++;
		for(int i=1;i<=(s<<1);++i)
		{
			for(int j=1;j<=(s<<1);++j)
			{
				f[i][j]+=(f[i][j-1]+f[i-1][j])%mod; f[i][j]%=mod;
			}
		}
		int ans=0;
		for(int i=1;i<=n;++i)
		{
			ans+=f[s+x[i]][s+y[i]]; ans%=mod;
			ans-=C((x[i]<<1)+(y[i]<<1),(x[i]<<1));
			ans+=mod; ans%=mod;
		}printf("%lld\n",ans*inv[2]%mod);
		return 0;
	}
}
signed main(){return yspm::main();} 

Measured memory_bytes: 135808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

// abc136_d
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n = s.size();
    vector<int> ans(n, 0);
    int cnt = 0;
    rep(i, n){
        if(s[i]=='R') cnt++;
        else{
            ans[i]+=cnt/2;
            ans[i-1]+=(cnt+1)/2;
            cnt=0;
        }
    }
    cnt = 0;
    for(int i=n-1; i>=0; i--){
        if(s[i]=='L') cnt++;
        else{
            ans[i]+=cnt/2;
            ans[i+1]+=(cnt+1)/2;
            cnt=0;
        }
    }
    rep(i,n){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 1104
def fa(K,X):
    ch=""
    L=[X]
    for i in range(1,K):
        L.append(X-i)
        L.append(X+i)
    L.sort()
    C=str(L)
    ch=C[1:len(C)-1]
    return ch
K,X=map(int,input().split())
print(fa(K,X).replace(",",""))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int X, A, B;
  cin >> X >> A >> B;

  X -= A;
  X %= B;

  cout << X << endl;

  return 0;
}


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

using namespace std;

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

#define MINF -1000000000

typedef pair<int,int> pii;

const int M = 5005;

int dp[2][M];

int main(){
	
	int A,B;
	cin>>A>>B;
	
	int a[M]={0};
	int b[M]={0};
	reps(i,1,A+1)cin>>a[i];
	reps(i,1,B+1)cin>>b[i];
	
	rep(i,2)rep(j,M)dp[i][j]=0;
	
	int maxi = 0;
	
	reps(i,1,B+1){
		rep(j,M)dp[i%2][j]=0;
		reps(j,1,A+1){
			if(b[i]==a[j]){
				dp[i%2][j] = max(dp[i%2][j],dp[(i+1)%2][j-1]+1);
			}else{
				dp[i%2][j] = dp[i%2][j-1];
			}
			maxi = max(maxi, dp[i%2][j]);
		}
	}
	
	/*
	rep(i,7){
		rep(j,7){
			printf("%d ",dp[i][j]);
		}puts("");
	}*/
	
	printf("%d\n",maxi);
}

Measured memory_bytes: 1232
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	vector<int> c(3);
	cin >> s;
	rep(i,s.size()){
		c[0] += (s[i] == 'a');
		c[1] += (s[i] == 'b');
		c[2] += (s[i] == 'c');
	}
/*	if(s.size() > 2 && c[0] && c[1] && c[2]){
		cout << "NO\n";
	}
	*/
	while(c[0] && c[1] && c[2]){
		--c[0];
		--c[1];
		--c[2];
	}
	sort(all(c),greater<int>());
	int zero = 0,sum = 0;
	rep(i,3){
		zero += (c[i] == 0);
		sum += c[i];
	}
	if(zero == 3) cout << "YES\n";
	else if(zero == 1){
		if(sum <= 2) cout << "YES\n";
		else cout << "NO\n";
	}
	else{
		if(sum == 1) cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        String s = next();
        String t = next();

        if (s.equals(t.substring(0, t.length() - 1))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static char nextChar() throws IOException {
        return next().charAt(0);
    }

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

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

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

    static int[] readArray(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    static long[] readLongArray(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine().trim());
        }
        return st.nextToken();
    }

    static int Char2Int(Character c) {
        return Character.getNumericValue(c);
    }

    static double Char2Double(Character c) {
        return (double) Char2Int(c);
    }

    static int nCr(int n, int r) {
        return fact(n) / (fact(r) * fact(n - r));
    }

    // Returns factorial of n
    static int fact(int n) {
        int res = 1;
        for (int i = 2; i <= n; i++) {
            res = res * i;
        }
        return res;
    }

    static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        } else {
            a = a % b; // 残り部分
            return gcd(b, a); // 残り部分から最小の正方形を見つける
        }
    }
}

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

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

    if(x == y) cout << "Draw" << endl;
    else if(x>y && y != 1) cout << "Alice" << endl;
    else if(x>y && y == 1) cout << "Bob" << endl;
    else if(y>x && x != 1) cout << "Bob" << endl;
    else if(y>x && x == 1) cout << "Alice" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a[3],k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(a, a+3);
    for (int i = 0; i < k;i++) {
        a[2] *=2;
    }
    cout << a[0]+a[1]+a[2];
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    int64_t m = s.size();

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(2, vector(k + 1, vector(a.back() + 1, 0L)));
    int64_t h = 0;
    dp[h][0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        auto&& prev = dp[h];
        auto&& next = dp[!h];
        h = !h;

        for (auto j : irange(k, -1L, -1L)) {
            int64_t ss = 0;
            for (auto c : irange(a[i + 1], a.back() + 1)) {
                next[j][c] = ss + prev[j][a[i] + (c - a[i + 1])];
                if (next[j][c] >= M) {
                    next[j][c] -= M;
                }
                ss += prev[j][a[i] + (c - a[i + 1])];
                if (ss >= M) {
                    ss -= M;
                }
            }

            for (auto c : irange(a[i + 1], a.back() + 1)) {
                for (auto b : irange(a[i] + (c - a[i + 1]) + 1, c + 1)) {
                    auto w = j + b - (a[i] + (c - a[i + 1]));
                    if (w > k) {
                        break;
                    }
                    next[w][c] += prev[j][b];
                    if (next[w][c] >= M) {
                        next[w][c] -= M;
                    }
                }
            }
        }
    }

    int64_t ans = 0;
    for (auto i : irange(0L, k + 1)) {
        ans += dp[h][i][a.back()];
        if (ans >= M) {
            ans -= M;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 5276
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;
const int sz=200005;

int fact[sz],inv[sz],ifact[sz];

void make(){
    fact[0]=fact[1]=inv[1]=ifact[0]=ifact[1]=1;
    for(int i=2;i<sz;i++){
        fact[i]=fact[i-1]*i%mod;
        inv[i]=inv[mod%i]*(mod-mod/i)%mod;
        ifact[i]=ifact[i-1]*inv[i]%mod;
    }
}

int comb(int n,int k){
    if(n<k) return 0;
    return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
}

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

    make();

    int ans=1;
    for(int i=2;i*i<=M;i++){
        int cnt=0;
        while(M%i==0){
            M/=i;
            cnt++;
        }
        ans*=comb(N+cnt-1,cnt);
        ans%=mod;
    }
    if(M>1){
        ans*=N;
        ans%=mod;
    }
    cout<<ans<<endl;

}


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

int calc(int n){
    return 0;
}

void solve(){
    long long N;
    cin>>N;
    long long a;
    long long a_max,a_min;
    a_max=-1;
    a_min=1<<30;
    for(int i=0;i<N;i++){
        cin>>a;
        a_max=max(a_max,a);
        a_min=min(a_min,a);

    }
    long long ans=a_max-a_min;
    cout<<ans<<endl;

}
int main(){
    solve();
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s; cin >> s;
	if (s[0] != s[1] || s[1] != s[2]) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
} 
 


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

typedef long long ll;
typedef pair <int, int> pii;

#define NL cout<<"\n";
#define ALL(a) a.begin(), a.end()
#define DBG(a) cout<< #a <<" --> "<<(a)<<endl;
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const int N=3e5+5;
const int oo=1e9+7;

int32_t main()
{
    FastIO;
    int n,k;
    cin>>n>>k;
    int d= min(n,k);

    cout<< (k==1 ? 0 :n-k )<<"\n";
}


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

int aiueo(int kazu) {
	int tmp=0;
	while (kazu > 0) {
		tmp += kazu % 10;
		kazu /= 10;
	}
	return tmp;
}

int main() {
	int n;

	cin >> n;
	int nn = n, nnn=1;

	while (nn/10> 0) {
		nn /= 10;
		nnn*=10;
	}

	if (nnn == n) cout << aiueo(n / 2) + aiueo(n / 2) << endl;
	else cout << aiueo(n);

	return 0;
}


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

using namespace std;

typedef long long ll;

int main () {
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  ll ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i+1; j < n; ++j) {
      ans += v[i] * v[j];
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007
using namespace std;

int main(){

string s,t;
cin>>s>>t;
ll ans = 0;
for(ll i=0;i<3;i++){
if(s[i]==t[i]){
  ans++;
}
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	int n,i,j,m;
	cin>>n>>m;
	vector<string> ch;string str;
	for(i=0;i<n;i++){cin>>str;
	ch.push_back(str);}
	int dp[n][m];
	for(i=0;i<n;i++){
		for(j=0;j<ch[i].size();j++){
			if(ch[i][j]=='#')
			dp[i][j]=0;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<ch[i].size();j++){
			if(ch[i][j]=='.'){
				if(i==0&&j==0){
					dp[i][j]=1;
				}
				else if(i==0)
				dp[i][j]=dp[i][j-1]%mod;
				else if(j==0)
				dp[i][j]=dp[i-1][j]%mod;
				else
				dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
			}
		}
	}
	cout<<dp[n-1][m-1];
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 5248
import sys 
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,X,Y = map(int,readline().split())
ans = [0]*N
graph = [[] for _ in range(N)]
for i in range(N-1):
    graph[i].append(i+1)
    graph[i+1].append(i)
graph[X-1].append(Y-1)
graph[Y-1].append(X-1)

def bfs(x,q,dist):
    while q:
        v = q.popleft()
        for nx in graph[v]:
          if dist[nx] != 0:
            continue
          dist[nx] = dist[v] + 1
          q.append(nx)
          if nx > x:
            ans[dist[nx]] +=1

for i in range(N):
    dist = [0]*N
    q = deque([i])
    bfs(i,q,dist)
      
print('\n'.join(str(n) for n in ans[1:]))

Measured memory_bytes: 9880