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

using ll = long long;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (ll i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (ll i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

template<typename T> using pop_max = std::priority_queue<T>;
template<typename T> using pop_min = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T> void LOG(const T& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T> void LOG(const vector<vector<T>>& a) { for (const auto& x : a) LOG(x); }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; }
ll gcd(ll a, ll b) { while (b != 0) { ll t = b; b = a % b; a = t; } return a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll gcd(const vector<ll>& v) { return accumulate(v.begin(), v.end(), 1LL, static_cast<ll(*)(ll, ll)>(gcd)); }
ll lcm(const vector<ll>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<ll(*)(ll, ll)>(lcm)); }
ll pow(ll x, ll y, ll z) { ll a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
ll inv(ll x, ll m) { return pow(x, m - 2, m); }

template<typename T> bool chmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<typename T> bool chmin(T& x, const T& y) { return x > y ? x = y, true : false; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_cpp;

const ll INF = inf<ll>;
using P = pair<ll, ll>;
const ll M = 1000000007;
signed main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> f(500000);
    f[0]=1;
    REP(i,f.size()-1)f[i+1]=f[i]*(i+1)%M;
    auto C=[&](ll n,ll r){return f[n]*inv(f[r],M)%M*inv(f[n-r],M)%M;};
    auto H=[&](ll n,ll r){return C(n+r-1,r);};
    ll a=H(n,n);
    if(k>=n-1){
        cout<<a<<endl;
    }else{
        for(ll i=n-2;i>=k;i--){
            //cout<<C(n,n-1-i)<<" "<<H(n-1-i,1+i)<<endl;
            a-=C(n,n-1-i)*H(n-1-i,1+i)%M;
            a=(a+M)%M;
        }
        cout<<a<<endl;
    }
	return 0;
}


Measured memory_bytes: 4224
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[200000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  vector<int> values;
  rep(i, N) values.pb(A[i] - (1+i));
  sort(all(values));
  long long sum = 0;
  rep(i, N-1) {
    sum += 1LL*(values[i+1]-values[i])*(int)min(i+1, N-(i+1));
  }
  cout << sum << "\n";
  return 0;
}


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

using namespace std;

int main(){
 int h,w;
  cin >> h >> w;
  
  vector<string> s(h);
  
  vector<bool> row(h,false),col(w,false);
  
  
  
  for(int i=0;i<h;i++){
    cin >> s[i];
    for(int j=0;j<w;j++){ 
      if(s[i][j]=='#'){ 
        row[i]=true;
        col[j]=true;
      }
      }
  }
  
  for(int i=0;i<h;i++){
   if(row[i]) { 
     for(int j=0;j<w;j++){
       if(col[j]){
     cout << s[i][j];
    }
     }   
    cout << "" << endl;
  }
  }
}

Measured memory_bytes: 256
N = int(input())
h = []
for i in range(N):
    h.append(list(map(int, input().split(" "))))

cost = h[-1]

for day in range(N-2, -1, -1):
    today_cost = [0 for i in range(3)]
    today_cost[0] = h[day][0] + max(cost[1], cost[2])
    today_cost[1] = h[day][1] + max(cost[0], cost[2])
    today_cost[2] = h[day][2] + max(cost[0], cost[1])
    cost = today_cost

print(max(cost))


Measured memory_bytes: 30580
s = gets.chomp.to_i

def fn(n)
  if n % 2 == 0
    n / 2
  else
    3 * n + 1
  end
end

h = [[s, 1]].to_h
k = { 1 => s }

i = 1
while true
  i = i + 1

  ai = fn(k[i - 1])
  if h[ai].nil?
    k[i] = ai
    h[ai] = i
  else
    print(i)
    break
  end
end


Measured memory_bytes: 1788
from sys import stdin

S = stdin.readline().rstrip()
K = int(stdin.readline().rstrip())
ans_odd = 0
ans_even = 0
changed_odd = [False] * len(S)
changed_even = [False] * len(S)

if len(S) == 1:
    print(K // 2)
    exit()

cnt = 1
ans = 0
begin = 0
end = 0

start = 0
for i in range(1, len(S)):
    if S[i - 1] != S[i]:
        if start == 0:
            begin += cnt
        else:
            if cnt >= 2:
                ans += cnt // 2
        cnt = 1
        start = i
    else:
        cnt += 1
    if i == len(S) - 1:
        if start == 0:
            print((cnt * K) // 2)
            exit()
        end += cnt
        break

if S[0] != S[-1]:
    print(ans * K + (begin // 2) * K + (end // 2) * K)
else:
    print(ans * K + begin // 2 + end // 2 + ((begin + end) // 2) * (K - 1))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define abs(x) ((x) < 0 ? (-(x)) : (x))
#define rep(i, a, m) for ((i) = (a); (i) < (m); ++(i))
#define REP(i, n) for ((i) = 0; (i) < (int)(n); (i)++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define sz(x) ((int)x.size())
#define PI 3.14159265

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
int a, b, c, i, j, k;
long long ans = 0LL;
long double eps = 1.0E-14;
long long MOD = 1000000007;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(30);
    const long double pi=acos(-1.000000);

    int t, T;
    int h, m;
    int a, b;
    cin >> a >> b >> h >> m;
    if (a == 0 || b == 0)
    {
        cout << abs(a - b) << endl;
        return 0;
    }
    long double ah = h * 30 + m * 0.5000;
    long double am = m * 6;
    long double d = (ah - am);
    if (d == 180 + eps)
    {
        cout << a + b << endl;
        return 0;
    }
    long double angle = pi*d;
    angle /= 180.0;
    long double aa = (a * a ) + (b * b) - (2 * b * a * cos(angle));
    cout << sqrt(aa) << endl;
    return 0;
}

Measured memory_bytes: 4180
# -*- coding: utf-8 -*-
n,x=map(int,input().split())
lst=map(int,input().split())
_lst=[0]
for l in lst:
    _lst.append(_lst[-1]+l)
#print(_lst)
num=0
for l in _lst:
    if l<=x:
        num+=1
    else:
        break
print(num)

Measured memory_bytes: 3060
import  math
A,B,H,M = list(map(int,input().split()))
short_nid_degree = H * 30 + (0.5 * M)
long_nid_degree = M * 360 /60
diff_nid_degree =  abs(short_nid_degree - long_nid_degree)
if diff_nid_degree > 180:
    diff_nid_degree=360 - diff_nid_degree
c_2  = A**2 + B**2 - (2 * B * A * math.cos(math.radians(diff_nid_degree)))
c= math.sqrt(c_2)
print(f"{c:.20f}")

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

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s)
        cout << a - 1 << " " << b << endl;
    else
        cout << a << " " << b - 1 << endl;

}

Measured memory_bytes: 256
#13:12
n,q = map(int,input().split())
import heapq
import sys
input = sys.stdin.readline
event = []
for _ in range(n):
  s,t,x = map(int,input().split())
  heapq.heappush(event,(s-x,t-x,x))
t = 0
now = []
for _ in range(q):
  d = int(input())
  if event:
    while event[0][0] <= d:
      tmp = heapq.heappop(event)
      heapq.heappush(now,(tmp[2],tmp[1]))
      if not event:
        break
  if now:
    while now[0][1] <= d:
      heapq.heappop(now)
      if not now:
        print(-1)
        break
    else:
      print(now[0][0])
  else:
    print(-1)

Measured memory_bytes: 50880
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define mod 1000000007
using namespace std;

int n;
vector<double> a;
vector<vector<double> > dp;

double fun(int i,int c){
	if(c==(n+1)/2)
		return 0;
	if(i==n)
		return 1;

	if(dp[i][c]!=-1)
		return dp[i][c];

	double ans = 0;
	ans += fun(i+1,c)*a[i];
	ans += fun(i+1,c+1)*(1-a[i]);
	return dp[i][c] = ans;
}

int main(){
	// ios_base::sync_with_stdio(false); 
	// cin.tie(NULL);cout.tie(NULL);

	cin>>n;
	a.resize(n);
	dp.assign(n,vector<double>(n+1,0));
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	dp[0][0] = a[0];
	// if(n==1)
	// 	return printf("%.9lf",fun(0,0)),0;
	dp[0][1] = (1-a[0]);
	for(int i=1;i<n;++i){
		for(int j=0;j<=i;++j){
			dp[i][j] = dp[i-1][j]*a[i];
			if(j>0)
				dp[i][j]+=dp[i-1][j-1]*(1-a[i]);
		}
		dp[i][i+1] = dp[i-1][i]*(1-a[i]);
	}
	// for(int i=0;i<n;++i)
	// {
	// 	for(int j=0;j<n;++j)
	// 		cout<<dp[i][j]<<" ";
	// 	cout<<'\n';
	// }
	double sum = 0;
	for(int i=0;i<(n+1)/2;++i)
		sum+=dp[n-1][i];
	printf("%.9lf",sum);
	// cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
	return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
 
using namespace std;
 
#define lli long long
typedef long double ldb;
#define deci(n) fixed << setprecision(n)
 
lli M=1e9+7;
lli MOD=1e9+7;
 
#define MAXN 2000006 
 
// Template function //
lli powermod(lli x, lli y)  
{  
    lli res = 1;  
    x = x % MOD;
    if (x == 0) return 0;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % MOD;  
        y = y>>1;   
        x = (x*x) % MOD;  
    }  
    return res;  
}
lli modinv(lli x)
{
    return powermod(x,MOD-2);
}
// Template functions end //
 
// Custom funtions //
lli findset(lli p[], lli x){
	if(x!=p[x]){
		p[x]=findset(p,p[x]);
	}
	return p[x];
}
 
void unionset(lli p[],lli r[],lli a,lli b){
	lli x=findset(p,a);
	lli y=findset(p,b);
	if(x!=y){
		if(r[x]<r[y]) swap(x,y);
		p[y]=x;
		if(r[x]==r[y]){
			r[x]++;
		}
	}
}

void dfs(vector<lli> v[], lli s[], lli x)
{
    lli S=1;
    for(lli i=0;i<v[x].size();i++)
    {
        dfs(v,s,v[x][i]);
        S+=s[v[x][i]];
    }
    s[x]=S;
}

lli f[100005];



void preprocess()
{
    f[0]=1;
    for(lli i=1;i<100005;i++)
    {
        f[i] = (f[i-1]*i)%MOD;
        if(i%2==0)
        f[i]/=2;
    }
}

lli tree[MAXN];


void buildTree(vector<lli> a, lli n)
{
    for(lli i=0;i<n;i++)
        tree[n+i] = a[i];
    for(lli i=n-1;i>0;i--)
    {
        tree[i] = tree[i<<1] + tree[i<<1|1];
    }
}

void updateTree(lli n, lli p, lli value)
{
    tree[p+n] = value;
    p+=n;
    for(lli i=p; i>1;i >>= 1)
        tree[i>>1] = tree[i] + tree[i^1];
}

lli queryTree(lli n, lli l, lli r)
{
    lli res = 0;
    for(l+=n,r+=n;l<r;l>>=1, r>>=1)
    {
        if(l&1)
            res += tree[l++];
        if(r&1)
            res += tree[--r];
    }
    return res;
}

bool sortbysec(const pair<pair<lli,lli>,lli> &a, 
              const pair<pair<lli,lli>,lli> &b) 
{ 
    if(a.first.second == b.first.second)
    return a.first.first>b.first.first;
    return (a.first.second < b.first.second); 
} 

void dfs(int x, int vi[], vector<int> v[], long double pr, long double &ans)
{
    vi[x] = 1;
    double d = 0;
    for(int i=0;i<v[x].size();i++) 
    {
        if(vi[v[x][i]]==0)
        d++;
    }
    if(d==0)
    return;
    ans+=pr;
    pr = pr/d;
    for(int i=0;i<v[x].size();i++) 
    {
        if(vi[v[x][i]]==0)
        {
            dfs(v[x][i],vi,v,pr,ans);
        }
    }
}

void solve()
{ 
    int n;
    cin>>n;
    lli x;
    lli sum = 0;
    lli ans = 0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        ans = (ans+(x*sum)%M)%M;
        sum = (sum+x)%M;
    }
    cout<<ans<<endl;
}
// Custom functions end //
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli q=1;
    //cin>>q;
    for(lli tc=1;tc<=q;tc++)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define Max(x, y)(max(decltype(x)(0), max((x), (y))))
#define Min(x, y)(max(decltype(x)(0), min((x), (y))))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define all(x) (x).begin(),(x).end()
#define _end '\n'
#define Out(x) cout<<(x)<<_end
template<typename T> inline bool _max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool _min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

    int c[3][3];
    int a1Max, a2Max, a3Max;
    int b1Min, b2Min, b3Min;
    int a1, a2, a3;
    int b1, b2, b3;
    bool is;

    int i, j, k;

    rep(i, 3) rep(j, 3) cin >> c[i][j];

    b1Min = min(c[0][0], min(c[1][0], c[2][0]));
    b2Min = min(c[0][1], min(c[1][1], c[2][1]));
    b3Min = min(c[0][2], min(c[1][2], c[2][2]));

    a1Max = min(c[0][0], min(c[0][1], c[0][2]));
    a2Max = min(c[1][0], min(c[1][1], c[1][2]));
    a3Max = min(c[2][0], min(c[2][1], c[2][2]));

    repin(i, a1Max) {
        a1 = i;

        repin(j, a2Max) {
            a2 = j;

            repin(k, a3Max) {
                a3 = k;

                is = true;

                b1 = c[0][0] - a1;
                b2 = c[0][1] - a1;
                b3 = c[0][2] - a1;

                if (c[1][0] - b1 != a2 || c[1][1] - b2 != a2 || c[1][2] - b3 != a2) is = false;
                if (c[2][0] - b1 != a3 || c[2][1] - b2 != a3 || c[2][2] - b3 != a3) is = false;

                if (is) {
                    Out("Yes");

                    return 0;
                }
            }
        }
    }

    Out("No");

    return 0;
}


Measured memory_bytes: 256
n=gets.to_i
a=n.times.map{gets.to_i}
max = a.sort[-1]
t = a.select{|x|x==max}.size

if t > 1
  puts [max]*n
else
  tt = a.sort[-2]
  idx = a.index(max)
  puts [max]*idx + [tt] + [max]*(n-1-idx)
end


Measured memory_bytes: 12776
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
int n,x;
int m[2000];

int main(){
  cin >> n >> x;
  int wa = 0;
  REP(i,n){
    cin >> m[i];
    wa += m[i];
  }
  sort(m,m+n);
  int a = m[0];
  cout << (x-wa)/a + n << endl;
  return 0;
}


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

ll A[200010];

int main(){
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++){
		ll a;
		cin >> a;
		A[i - 1] = a - i;
	}

	ll res = 0;
	sort(A, A + N);
	ll mid;
	if (N%2 == 1){
		mid = A[N/2];
		for (int i = 0; i < N; i++){
			res += abs(A[i] - mid);
		}
	} else {
		if ((A[N/2] + A[N/2 - 1])%2 == 0){
			mid = (A[N/2] + A[N/2 - 1])/2;
			for (int i = 0; i < N; i++){
				res += abs(A[i] - mid);
			}
		} else {
			mid = (A[N/2] + A[N/2 - 1])/2;
			for (int i = 0; i < N; i++){
				res += abs(A[i] - mid);
			}
			ll tmp = 0;
			if (A[N/2] + A[N/2 - 1] >= 0){
				mid = (A[N/2] + A[N/2 - 1] + 1)/2;
			} else {
				mid = (A[N/2] + A[N/2 - 1] - 1)/2;
			}
			for (int i = 0; i < N; i++){
				tmp += abs(A[i] - mid);
			}
			res = min(res, tmp);
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d,c=0;
    cin>>d;
    for(int i=1;i<=3;i++)
    {
        if(d%10==7)
            {
          c++;
          break;
          }
       else
           d=d/10;
    }
    if(c>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
int main(){
	int N,a[3000],out;
	std::cin>>N;
	for(int i=0;i<N;i++)std::cin>>a[i];
	for(int i=0;i<N;i++){
		out+=a[i]-1;
	}
	std::cout<<out<<std::endl;
}

Measured memory_bytes: 256
loop do
  h,w = gets.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  count_w = 0
  h.times {
    if count_w == 0 || count_w == h - 1
      puts "#" * w
    else
      puts "#" + "."*(w-2) + "#"
    end
    count_w += 1
  }
puts
end



Measured memory_bytes: 6964
#include<bits/stdc++.h>
using namespace std;
int n,ans=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%10==0)
		{
			continue;
		}
		int tmp=0;
		int fir=i%10;
		int a=i,last;
		while(1)
		{
			if(a<10)
			{
				last=a;
				break;
			}
			a/=10;
		}
		tmp+=(fir==last);
		int pow=1;
		bool flag=false;
		while(!flag)
		{
			for(int i=0;i<pow;i++)
			{
				int num=fir*pow*10+i*10+last;
				if(num>n)
				{
					flag=true;
					break;
				}
				++tmp;
			}
			pow*=10;
		}
		ans+=tmp;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    int w  = 0;
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == 'R') {
            while (w < i) {
                if (s[w] == 'W') {
                    ans++;
                    s[w] = 'R';
                    s[i] = 'W';
                    break;
                }
                w++;
            }
        }
    }
    cout << ans << endl;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    string s;
    cin >> s;

    map<char, int> a;
    rep(i, 0, s.size()) { ++a[s[i]]; }

    if (a.size() == 2 && (a.begin())->second == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

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

  string s; cin >> s;
  string a = "";
  rep(i, s.size()) {
    if(s[i] == 'B') {
      if(a.size() == 0) continue;
      a.pop_back();
    } else {
      a.push_back(s[i]);
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
s = list(input())

c = -1
f = -1

for i in range(len(s)):
    if s[i] == "C" and c == -1:
        c = i
    if s[i] == "F":
        f = i
        
if c < f and c != -1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp48
{
    class Program
    {
        static void Main(string[] args)
        {
            long a = long.Parse(Console.ReadLine());
            long b = 1;
            for(long i = 1; i <= a; i++)
            {
                b *= i;
                b = b % 1000000007;
            }
            Console.WriteLine(b);
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll n; cin >> n;
  map<ll, ll> mp;
  rep(i, n) {
    ll a; cin >> a;
    ++mp[a];
  }
  ll sum = 0;
  for(auto x : mp) sum += x.first*x.second;
  int q; cin >> q;
  vector<ll> ans;
  rep(i, q) {
    ll b, c; cin >> b >> c;
    ll x = mp[b];
    sum += (c-b)*x;
    mp[b] -= x;
    mp[c] += x;

    ans.push_back(sum);
  }
  for(auto x : ans) cout << x << endl;
}

Measured memory_bytes: 9880
package main

import (
	"fmt"
)

func main() {

	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)

	for i := 0; ; i++ {
		if i%2 == 0 {
			C -= B
			if C <= 0 {
				fmt.Println("Yes")
				break
			}
		} else {
			A -= D
			if A <= 0 {
				fmt.Println("No")
				break
			}
		}
	}
}


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

const int N = 2e5 + 10, mod = 1e9 + 7;

int n, p[N];
vector<string> res;

int get(int a) {
    return p[a] = (a == p[a] ? a : get(p[a]));
}

void join(int a, int b) {
    a = get(a), b = get(b);
    p[b] = a;
}

void init() {
    for(int i = 0; i < n; i++) p[i] = i;
}
string s;
void solve(int i, char c, int vis, bool bo) {
    if(vis == (1 << n) - 1) {
        res.push_back(s);
        return;
    }
    if(i == n) solve(0, c + 1, vis, 0);
    else if((vis >> i) & 1) solve(i + 1, c, vis, bo);
    else {
        if(!bo) {
            s[i] = c;
            solve(i + 1, c, vis ^ (1 << i), 1);
        }
        else {
            s[i] = c;
            solve(i + 1, c, vis ^ (1 << i), bo);
            solve(i + 1, c, vis, bo);
        }
    }
}

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
   // scanf("%d", &tc);
    while(tc--) {
        cin >> n;
        for(int i = 0; i < n; i++) p[i] = i;
        s.resize(n);
        solve(0, 'a', 0, 0);
        sort(res.begin(), res.end());
        for(auto x : res) printf("%s\n", x.c_str());
    }    
    return 0;
}

Measured memory_bytes: 7796
#include <stdio.h>
#include <math.h>
int main (void){
        int A,B,ans=0;
        scanf("%d %d",&A,&B);
        for (int i = A; i <= B; i++) {
                if (i/10000==i%10&&(i/1000)%10==(i/10)%10) {
                        ans++;
                }
        }
        printf("%d\n",ans );
        return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    long long int t,n,i,j,k,l,sum,sum1,cnt,cnt1,flag,flag1,m,x,y,a,b,c,d,mid;
      string s;
      cin>>s;
      if(s=="ABC")
      {
          cout<<"ARC"<<endl;
      }
      else if(s=="ARC")
      {
          cout<<"ABC"<<endl;
      }

     return 0;

}





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

#define all(x) (x).begin(), (x).end()
#define szof(x) int32_t((x).size())
#define str(x) to_string(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const ll MOD998 = 998244353;
const int INF = 1e9;
const ll LLINF = 1e18;

mt19937_64 rng((uint) chrono::steady_clock::now().time_since_epoch().count());

template <class T>
T rnd(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rng);
}

void run() {
	int n, W;
	cin >> n >> W;
	vector<pair<int, int>> a(n);
	for (auto &x : a) {
		cin >> x.first >> x.second;
	}
	vector<ll> dp(W + 1);
	for (int i = 0; i < n; i++) {
		vector<ll> new_dp = dp;
		for (int w = 0; w <= W; w++) {
			new_dp[w] = dp[w];
			if (w >= a[i].first) {
				new_dp[w] = max(new_dp[w], dp[w - a[i].first] + a[i].second);
			}
		}
		dp.swap(new_dp);
	}
	cout << *max_element(all(dp)) << "\n";
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout.precision(10); cout << fixed;
	int tests = 1;
	// cin >> tests;
	while (tests--) {
		run();
	}
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
	return 0;
}


Measured memory_bytes: 1888
#include<bits/stdc++.h>
using namespace std;
int N,n,add;
vector<pair<int,int> >ans;
void add_edge(int x,int y){
	ans.push_back(make_pair(x,y));
}
void print(){
	for(auto p:ans){
		cout<<p.first<<" "<<p.second<<endl;
	}
}
void solve0(){
	for(int i=1;i<n-1;i++)add_edge(i,i+1);
	add_edge(n-1,1+add);add_edge(1,n);
	for(int i=1;i<n-1;i++)add_edge(i+add,i+add+1);
	for(int i=0;i<N-1;i++){
		add_edge(n+i,n+i+1);
	}
	add_edge(n+N-1,add+n);
	for(int i=0;i<N-1;i++){
		add_edge(add+n+i,add+n+i+1);
	}
}
void solve1(){
	N--;solve0();N++;
	add_edge(N+n-1,n);
	add_edge(N+n-1+add,N-1);
}
void solve2(){
	for(int i=1;i<n-1;i++)add_edge(i,i+1);
	add_edge(n-1,1+add);
	for(int i=1;i<n-1;i++)add_edge(i+add,i+add+1);
	for(int i=n;i<n+N-1;i++)add_edge(i,i+1);
	for(int i=n+add;i<n+add+N-1;i++)add_edge(i,i+1);
	add_edge(1+add,n);
	add_edge(1+add,n+N-1+add); 
}
void solve3(){
	N--;solve2();N++;
	add_edge(N,add+add);
	add_edge(add,n);
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>N;n=1;add=N;
	if(N==3){
		puts("Yes");
		puts("1 2");
		puts("2 3");
		puts("3 4");
		puts("4 5");
		puts("5 6");
		return 0;
	}
	while(n<N)n*=2;
	if(n==N){
		puts("No");
		return 0;
	}
	cout<<"Yes"<<endl;
	n/=2;N-=n-1;
	if(N%4==0){
		solve0();
	}else if(N%4==1){
		solve1();
	}else if(N%4==2){
		solve2();
	}else if(N%4==3){
		solve3();
	}
	print();
	return 0;
}

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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int h[100005];
int PD[100005];
int n, k;

int pd(int i){
	if(i == 0){
		return 0;
	}
	int &ans = PD[i];
	if(ans != -1){
		return ans;
	}
	ans = INF;
	for(int d = 1; d <= k; d++){
		if(i-d < 0) break;
		ans = min(ans, abs(h[i]-h[i-d]) + pd(i-d));
	}
	return ans;
}

int main(){
	scanf("%d %d", &n, &k);
	FOR(i, 0, n){
		scanf("%d", h+i);
	}
	memset(PD, -1, sizeof PD);
	printf("%d\n", pd(n-1));
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>

using namespace std;


int main(){
    
    int H, W;

    while(true){
        cin >> H >> W;
        if(H!=0 && W!=0){
            for(int i=0; i<H; i++){
                if(i==0 || i==H-1){
                    for(int j=0; j<W; j++){
                        cout << "#";
                    }
                }else{
                    for(int j=0; j<W; j++){
                        if(j==0 || j==W-1){
                            cout << "#";
                        }else{
                            cout << ".";
                        }
                    }
                }
                cout << endl;
            }
            cout << endl;
        }else{
            break;
        }
    }

    return 0;
}




Measured memory_bytes: 3092
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))

    ans=INF
    for x in range(-100,101):
        score=0
        for a in A:
            score+=(a-x)**2
        ans=min(ans,score)
    print(ans)
resolve()

Measured memory_bytes: 38768
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d);
}

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


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	ll k,s,ans=0;
	cin>>k>>s;
	for(ll i=0;i<=k;i++)
	{
    for(ll j=0;j<=k;j++)
    {
      if( 0 <= s-i-j && s-i-j <= k ){
        ans++;
      }
    }
  }
		cout<<ans;
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

int N;
int A[100];

int check[100];

int trend;

int main(void) {

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

	A[0] = 100;

	int i = 1;
	while (A[i] == A[1]) { i++; }

	if (A[i] > A[1]) { trend = 1; check[1] = -1; }
	else { trend = -1; check[1] = 1; }

	for (int i = 1; i < N; i++) {

		if (trend == 1) { // up
			if (A[i] > A[i + 1]) { check[i] = +1; trend = -1; }

		}
		else {
			if (A[i] < A[i + 1]) { check[i] = -1; trend = 1; }
		}
	}

	if (trend == 1) { check[N] = 1; }
	//else { check[N] = -1; }

	/*for (int i = 1; i <= N; i++) {
		cout << "check[" << i << "]= " << check[i] << endl;
	}*/

	long long int gold = 1000;
	long long int kabu = 0;

	for (int i = 1; i <= N; i++) {
		if (check[i] == -1) {
			kabu += gold / A[i]; gold -= A[i] * (gold / A[i]);
		}
		else if(check[i]==1){
			gold += A[i] * kabu;
			kabu = 0;
		}
	}

	cout << gold << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<queue>
#include<map>

using namespace std;
int d[1001][1001];
int INF = 1e9;

int main(){
  queue<pair<int,pair<int, int> > > q;
  int H,W;
  cin >> H >> W;
  
  for (int i=0;i<H;i++){
  	for (int j=0;j<W;j++){
      d[i][j] = INF;
    }
  }
  string s;
  for(int i=0;i<H;i++){
    cin >> s;
    for(int j=0;j<W;j++){
      if(s[j] == '#'){
        d[i][j] = 0;
        q.push(make_pair(0,make_pair(i,j)));
      }
    }
  }
  while(!q.empty()){
    pair<int,pair<int, int> > a = q.front();
    q.pop();
    int dv = a.first;
    int x = a.second.first;
    int y = a.second.second;
    int dx = 1;
    int dy = 0;
    for (int j=0;j<4;j++){
      int t = dx;
      dx = dy;
      dy = -t;
      int xx = x + dx;
      int yy = y + dy;
      if (xx == -1 | xx == H){
        continue;
      }
      if (yy == -1 | yy == W){
        continue;
      }
      if (d[xx][yy] == INF){
        d[xx][yy] = dv + 1;
        q.push(make_pair(dv+1,make_pair(xx,yy)));
      }
    }
  }
  int ans = 0;
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if (ans < d[i][j]){
        ans = d[i][j];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 16272
#include <iostream>
#include <set>
typedef long long ll;
using namespace std;
ll ans;
ll n;
ll a[200005];
int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a[t] = i;
  }

  set<ll> s;
  s.insert(-1), s.insert(n);

  for(int i = 1; i <= n; i++) {
    ll j = a[i];
    auto it = s.lower_bound(j);
    ll r = *it;
    it--;
    ll l = *it;
    ans += ll(i) * (r - j) * (j - l);
    s.insert(j);
  }

  cout << ans << endl;
}
 
  


Measured memory_bytes: 11136
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


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

    int n;
    cin >> n;
    
    int a[n-1];
    
    int count[n];
    
    for(int i=0; i<n; i++) count[i] = 0;

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


Measured memory_bytes: 5132
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	int n;
	while(cin >> n,n){
		//dice = {u,l,r,d};
		int center = 1, dice[4] = {5,4,3,2}, res = 1;
		while(n--){
			string siji;
			cin >> siji;
			int vircen = center,virdice[4] = {0};
			memcpy(virdice,dice,sizeof(dice));
			if(siji == "North"){
				center = dice[3];
				dice[0] = vircen;
				dice[3] = 7 - vircen;
			}
			if(siji == "South"){
				center = dice[0];
				dice[0] = 7 - vircen;
				dice[3] = vircen;
			}
			if(siji == "East"){
				center = dice[1];
				dice[1] = 7 - vircen;
				dice[2] = vircen;
			}
			if(siji == "West"){
				center = dice[2];
				dice[1] = vircen;
				dice[2] = 7 - vircen;
			}
			if(siji == "Left"){
				dice[0] = virdice[2];
				dice[1] = virdice[0];
				dice[2] = virdice[3];
				dice[3] = virdice[1];
			}
			if(siji == "Right"){
				dice[0] = virdice[1];
				dice[1] = virdice[3];
				dice[2] = virdice[0];
				dice[3] = virdice[2];
			}
			//cout << center << endl;
			//for(int i=0;i<4;i++){
			//cout << dice[i];
			//}
			//cout << "\n";
			res += center;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 0
# 2つの入力を空白で分割し、数値化
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

yakusu_list = make_divisors(N)
#print(yakusu_list)
mid = yakusu_list[len(yakusu_list) // 2]

mid2 = N // mid

print((mid - 1) + (mid2 - 1))



Measured memory_bytes: 3268
from copy import *
s = str(input())
n = len(s)
ans = 0
S = s
for i in range(n):#偶数で0  01010
    if i % 2 == 0:
        if s[i] == "1":
            ans += 1

    else:
        if s[i] == "0":
            ans += 1

aans = 0
for i in range(n):#奇数で0  10101
    if i % 2 == 0:#偶数
        if S[i] == "0":
            aans += 1

    else:
        if S[i] == "1":
            aans += 1

print(min(ans,aans))




Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,N;
  cin >> H >> N;
  vector<int> A(N),B(N);
  for (int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }
  int INF = 100010000;
  vector<int> dp(21000,INF);
  dp[0] = 0;
  int res = INF;
  //dp[i]: 体力をi減らすのに必要な最小の魔力
  for (int i = 0; i < 21000; i++){
    if (i < H){
      for (int j = 0; j < N; j++){
        dp[i + A[j]] = min(dp[i + A[j]], dp[i] + B[j]);
      }
    } else {
      res = min(res,dp[i]);
    }
  }
  cout << res;
}

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

int main() {
  string S;
  cin >> S;
  string ans = "No";
  for(int i = 0; i < 3; i++){
      if(S.at(i) != S.at(0)) ans = "Yes";
  }
  cout << ans << endl;
}


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

long long memo[605][605];
long long g[605];
long long MOD = 1000000007LL;
int connected[605];
int mnc[605][605];
int mxc[605][605];
int smc[605][605];
int n,k;

long long dp(int s, int e){
    if (memo[s][e]!=-1) return memo[s][e];
    if (e%2==s%2) return memo[s][e] = 0;
    if (mxc[s][e]>e){
        return memo[s][e] = 0;
    }
    if (mnc[s][e]<s){
        return memo[s][e] = 0;
    }
    long long total = g[e-s+1-smc[s][e]];
    for (int x = s+2; x<e; x++){
        total -= (dp(s,x-1) * g[e-x+1-smc[x][e]]) %MOD;
        total += MOD;
        total %=MOD;
    }


    total%=MOD;
    //printf("memo[%d][%d] = %lld\n",s,e,total);
    return memo[s][e] = total;
}

int main(){
    memset(memo,-1,sizeof(memo));
    memset(connected,-1,sizeof(connected));
    long long t = 1;
    g[0] = 1;
    for (int x = 2; x<605; x+=2){
        g[x] = t;
        t*=(x+1);
        t%=MOD;
    }
    scanf("%d%d",&n,&k);
    for (int x = 0; x<k; x++){
        int a,b;
        scanf("%d%d",&a,&b);
        connected[a] = b;
        connected[b] = a;
    }
    for (int x = 1; x<=2*n; x++){
        int mn = 99999;
        int mx = -1;
        int sm = 0;
        for (int y = x; y<=2*n; y++){
            if (connected[y]!=-1){
                mn = min(mn,connected[y]);
                mx = max(mx,connected[y]);
                sm++;
            }

            mnc[x][y] = mn;
            mxc[x][y] = mx;
            smc[x][y] = sm;
        }
    }
    long long finalans = 0;
    for (int x = 1; x<=2*n; x++){
        for (int y = x+1; y<=2*n; y++){
            finalans += dp(x,y)*g[2*n-(y-x+1) - (2*k-smc[x][y])];
            //printf("*= %d\n",2*n-(y-x+1) - (2*k-smc[x][y]));
            finalans %= MOD;
        }
    }
    printf("%lld",finalans);

}


Measured memory_bytes: 7424
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		long a = long.Parse(Console.ReadLine());
		if(a == 1) Console.WriteLine("Hello World");
    if(a == 2)
    {
      long b = long.Parse(Console.ReadLine());
      long c = long.Parse(Console.ReadLine());
      Console.WriteLine(b+c);
    }
	}
}

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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;

    s += '1';
    int ans = 0;
    for (int i = 0; i + 1 < s.length(); ++i) {
        if (s[i] != s[i + 1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;

void solve()
{   
    string s;
    cin >> s;

    sort(all(s));

    cout << (s[0] == s[2] ? "No" : "Yes") << '\n';
} 

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

    // int t; cin >> t; while (t--)
    solve();

    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int w, v;
    vector<vector<long long>> dp(n+1, vector<long long>(k+1));
    for (int j = 0; j <= k; ++j) dp[0][j] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> w >> v;
        for (int j = 0; j <= k; ++j) {
            if (j < w) {
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w] + v);
            }
        } 
    }
    cout << dp[n][k] << endl;
    return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{	
	double x, h;

	cin >> x >> h;

	while (x > 0 || h > 0) {
		cout << fixed << setprecision(6)
			<< x * x + 2 * x * sqrt(x * x / 4 + h * h) << endl;

		cin >> x >> h;
	}

	return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, A, B, C, D = 0;
  cin >> N >> A >> B;
  C = N / (A + B);
  for (ll i = 0; i < C; i++) {D += A;}
  if (N % (A + B) < A) {D += N % (A + B);}
  else {D += A;}
  cout << D << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

struct LazySegmentTree {
private:
	int n;
	vector<ll> node, lazy;

public:
	LazySegmentTree(vector<ll> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, 0);

		for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2];
	}

	void eval(int k, int l, int r) {
		if (lazy[k] != 0) {
			node[k] += lazy[k];
			if (r - l > 1) {
				lazy[2 * k + 1] += lazy[k] / 2;
				lazy[2 * k + 2] += lazy[k] / 2;
			}
			lazy[k] = 0;
		}
	}

	void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] += (r - l) * x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, 2 * k + 1, l, (l + r) / 2);
			add(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = node[2 * k + 1] + node[2 * k + 2];
		}
	}

	ll getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return 0;
		if (a <= l && r <= b) return node[k];
		ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
		return vl + vr;
	}
};

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

	int N, K;
	cin >> N >> K;
	VI A(N);	
	
	REP(i, N)cin >> A[i];

	REP(i, K) {
		VI cnt(N + 1, 0);
		bool F = 1;
		REP(j, N) {
			int a = A[j];
			int L = max(0LL, j - a);
			int R = min(N - 1, j + a) + 1;
			cnt[L]++;
			cnt[R]--;
			//cout << L << " " << R << endl;
		}
		REP(j, N) {
			cnt[j + 1] += cnt[j];
			if (cnt[j] != N)F = false;
		}
		//cout << endl;
		A = cnt;
		if (F)break;
	}
	//	cout << kk << endl;

	REP(i, N) {
		cout << A[i];
		if (i == N - 1)cout << endl;
		else cout << " ";
	}

	return 0;
}



Measured memory_bytes: 7952
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>

using namespace std;

int n, cnt;
int a[1000];
bool vis[1000];

int main() {
  scanf("%d", &n);
  a[++cnt] = 1;
  vis[1] = true;
  for(int i = 1; i <= n; i++) {
    if(!vis[i]) {
      for(int j = i * i; j <= n; j *= i) {
        a[++cnt] = j; vis[j] = true;
      }
    }
  }
  sort(a + 1, a + cnt + 1);
  printf("%d\n", a[cnt]);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int arr[3][3], flag[3][3] = {0};
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			scanf("%d", &arr[i][j]);
		}
	}
	int n;
	scanf("%d", &n);
	int brr[n];
	for(int i = 0; i < n; i++){
		scanf("%d", &brr[i]);
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(arr[j][k] == brr[i]){
					flag[j][k] = 1;
				}
			}
		}
	}
	int check = 0;
	for(int i = 0; i < 3; i++){
		if(flag[i][0] && flag[i][1] && flag[i][2]){
			check = 1;
		}
	}
	for(int i = 0; i < 3; i++){
		if(flag[0][i] && flag[1][i] && flag[2][i]){
			check = 1;
		}
	}
	if(flag[0][0] && flag[1][1] && flag[2][2]){
		check = 1;
	}
	if(flag[0][2] && flag[1][1] && flag[2][0]){
		check = 1;
	}
	(check) ? puts("Yes") : puts("No");
	return 0;
}


Measured memory_bytes: 1604
sieve = [True] * 110000
primes = []
for i in range(2, 110000):
    if sieve[i] == True:
        primes.append(i)
        for j in range(2*i, 110000, i):
            sieve[j] = False

while True:
    n, p = map(int, input().split())
    if n == -1 and p == -1: break
    cnt = 0
    for i in primes:
        if n < i: 
            break
        else: 
            cnt += 1
    psum = sorted([primes[i]+primes[j] for j in range(cnt, cnt+p) for i in range(j, cnt+p)])
    print(psum[p-1])

Measured memory_bytes: 8296