akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))

dp = [[[0]*2 for _ in range(2)] for _ in range(N)]

dp[0][0][0] = 1000
dp[0][1][0] = 1000%A[0]
dp[0][1][1] = 1000//A[0]

for i, a in enumerate(A):
  if i == 0:
    dp[0][0][0] = 1000
    dp[0][1][0] = 1000%a
    dp[0][1][1] = 1000//a
  else:
    if dp[i-1][0][0] < dp[i-1][1][0] + dp[i-1][1][1]*a:
      dp[i][0][0] = dp[i-1][1][0] + dp[i-1][1][1]*a
    else:
      dp[i][0][0] = dp[i-1][0][0]
    if dp[i-1][1][1] < dp[i][0][0]//a or dp[i-1][1][1] == dp[i][0][0]//a and dp[i-1][1][0] < dp[i][0][0]%a:
      dp[i][1][0] = dp[i][0][0]%a
      dp[i][1][1] = dp[i][0][0]//a
    else:
      dp[i][1][0] = dp[i-1][1][0]
      dp[i][1][1] = dp[i-1][1][1]
if dp[N-1][0][0] < dp[N-1][1][0] + dp[N-1][1][1]*A[N-1]:
  print(dp[N-1][1][0] + dp[N-1][1][1]*A[N-1])
else:
  print(dp[N-1][0][0])

Measured memory_bytes: 9320
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
using namespace std;

int main(){
    int a,b;
    while((cin >> a >> b)){
        int cnt = 0;
        int n = a+b;
        if(n!=0)for(cnt=0;n>0;cnt++)n/=10;
        else cnt = 1;
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
s = str(input())
n = len(s)

R_stock = 0
L_stock = 0

ans = [0] * n

for i in range(n-1):
    if s[i] == "R" and s[i+1] == "R":
        ans[i] = 0
        R_stock += 1
    elif s[i] == "R" and s[i+1] == "L":
        ans[i] += 1
        ans[i+1] += 1
        if R_stock % 2 == 0:
            ans[i] += int(R_stock / 2)
            ans[i+1] += int(R_stock / 2)
        else:
            ans[i] += R_stock // 2 
            ans[i+1] += R_stock // 2 + 1
        R_stock = 0
    elif s[i] == "L" and s[i+1] == "L":
        ans[i+1] = 0
        L_stock += 1
    else:
        if L_stock % 2 == 0:
            ans[i - L_stock - 1] += int(L_stock / 2)
            ans[i - L_stock] += int(L_stock / 2)
        else:
            ans[i - L_stock - 1] += L_stock // 2 + 1
            ans[i - L_stock] += L_stock // 2
        L_stock = 0

if L_stock % 2 == 0:
    ans[n - L_stock - 2] += int(L_stock / 2)
    ans[n - L_stock - 1] += int(L_stock / 2)
else:
    ans[n - L_stock - 2] += L_stock // 2 + 1
    ans[n - L_stock - 1] += L_stock // 2

print(" ".join(map(str, ans)))

Measured memory_bytes: 10612
n = int(input())
s = input()

p = [0] * n
p[0] = s[1:].count('E')
for i in range(1, n):
    p[i] = p[i-1]
    if s[i-1] == 'W':
        p[i] += 1
    if s[i] == 'E':
        p[i] -= 1
print(min(p))


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
ll P = 998244353;

template<typename T>
class tRMQ {
  vector<T> data;
  T unit;

public:
  static const long long INF = 100000000000;
  int n;
  function<T(const T &, const T &)> f;

  tRMQ(int _, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < _) {
      n <<= 1;
    }
    data.resize(n * 4);
    for (int i = 0; i < n * 4; i++)
      data[i] = unit;
  }

  void update(int index, T val) {
    int i = index + n - 1;
    data[i] = val;
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // [a, b)
  T query(int a, int b, int k, int l, int r) {
    if (a < 0 || r <= a || b <= l)
      return unit;
    if (a <= l && r <= b)
      return data[k];
    else
      return f(query(a, b, k * 2 + 1, l, (l + r) / 2),
               query(a, b, k * 2 + 2, (r + l) / 2, r));
  }

  T query(int a, int b) { return query(a, b, 0, 0, n); }
};

tRMQ<ll> minrmq(int n) {
  return tRMQ<ll>(n, 10000000000000000LL, [](ll r, ll l) { return min(l, r); });
}

tRMQ<ll> maxrmq(int n) {
  return tRMQ<ll>(n, -10000000000000000LL,
                  [](ll r, ll l) { return max(l, r); });
}

tRMQ<ll> sumrmq(int n) {
  return tRMQ<ll>(n, 0, [](ll l, ll r) { return l + r; });
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll fac[101010] = {0};
  fac[0] = 1;
  for (int i = 1; i < 101010; i++) fac[i] = (fac[i - 1] * i) % P;
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = fac[n];
  ll r = 0, g = 0, b = 0;
  ll rg = 0, gb = 0, br = 0;

  for (int i = 0; i < 3 * n; i++) {
    if (s[i] == 'R') {
      if (gb) {
        ans *= gb;
        ans %= P;
        gb--;
      } else if (g) {
        rg += 1;
        ans *= g;
        ans %= P;
        g--;
      } else if (b) {
        br += 1;
        ans *= b;
        ans %= P;
        b--;
      } else {
        r++;
      }
    } else if (s[i] == 'G') {
      if (br) {
        ans *= br;
        ans %= P;
        br--;
      } else if (r) {
        rg += 1;
        ans *= r;
        ans %= P;
        r--;
      } else if (b) {
        gb += 1;
        ans *= b;
        ans %= P;
        b--;
      } else {
        g++;
      }
    } else {
      if (rg) {
        ans *= rg;
        ans %= P;
        rg--;
      } else if (r) {
        br += 1;
        ans *= r;
        ans %= P;
        r--;
      } else if (g) {
        gb += 1;
        ans *= g;
        ans %= P;
        g--;
      } else {
        b++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define ppll pair<ll, pll>
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro%mod);
}
vector<int> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    ll sum=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            sum+=arr[i]*arr[j];
        }
    }
    cout<<sum;
    return 0;
}


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

using namespace std;

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

const ll mod = 1000000007;

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

  int m;
  cin >> m;
  vector<ll> d(m), c(m);
  for (int i = 0; i < m; i++) cin >> d[i] >> c[i];

  ll ans = -1;
  for (int i = 0; i < m; i++) ans += c[i];

  ll s = 0;
  for (int i = 0; i < m; i++) s += d[i] * c[i];
  ans += (s - 1) / 9;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<iomanip>

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

#define P pair<int, int>

typedef long long ll;

using namespace std;

#include <string>
#include <cctype>
typedef string::const_iterator State;
class ParseError {};


int main() {
	int N, ans= 1;
	cin >> N;
	while (ans <= N)
	{
		ans *= 2;
	}
	cout << ans / 2 << endl;

	return 0;
}



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

int main()
{
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)

            cout << ((j < a) ^ (i < b));
        cout << '\n';
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  string s;;
  cin>>s;
  string ch="hi";
  int n=s.size();
  if(n%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  else{
    rep(i,n){
      if(s[i]!=ch[i%2]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  


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




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

int A,B,C,D;

int main()
{
	cin >> A >> B >> C >> D;

	int x = max(A,C);
	int y = min(B,D);
	int ans = max(0,y - x);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// AOJ 2333: My friends are small
// 2017.11.19 bal4u@uu

#include <stdio.h>

#define M 1000000007 
int w[202], s[202];
int f[10001];
int dp[10001];

char buf[20], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int N, W, i, j, v, min, max, ans;

	fgets(p=buf, 20, stdin), N = getint(), p++, W = getint();
	fgets(p=buf, 10, stdin), min = max = v = getint(), f[v] = 1;
	i = N-1; while (i--) {
		fgets(p=buf, 10, stdin);
		v = getint(), f[v]++;
		if (v < min) min = v;
		else if (v > max) max = v;
	}
	for (j = 0, i = min; i <= max; i++) while (f[i]) w[j++] = i, f[i]--;
	s[0] = w[0]; for (i = 1; i < N; i++) s[i] = s[i-1] + w[i]; 

	if (s[N-1] <= W) { puts("1"); return 0; }
	dp[0] = 1, ans = 0;
	for (i = N-1; i >= 0; i--) {
		for (j = W-s[i]+1; j <= W-s[i]+w[i]; j++) {
			if (j >= 0) ans = (ans + dp[j]) % M;
		}
		for (j = W-w[i]; j >= 0; j--) dp[j+w[i]] = (dp[j+w[i]] + dp[j]) % M;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
int a,b,A=9999,B=9999;
for(int i=0;i<3;i++)cin>>a,A=min(A,a);
for(int i=0;i<2;i++)cin>>b,B=min(B,b);
cout<<A+B-50<<endl;
}

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

int main() {
 int N,K,a = 1;
  cin >> N >> K;
 for(int i=0;N>i;i++){
  if(a < K){
   a *= 2;
  }
  else{
  a += K;
  }
 }
 cout << a << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<b;i++)

ll mod = 998244353;
class SegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    vector<bool> flag_lazy;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, 0);
        flag_lazy.resize(2 * n - 1, false);
    }

    void update(int i, int l, int r) {
        if (!flag_lazy[i]) return;
        node[i] += lazy[i];
        node[i] %= mod;
        if (r - l > 1) {
            lazy[2 * i + 1] += lazy[i] / 2;
            lazy[2 * i + 2] += lazy[i] / 2;
            flag_lazy[2 * i + 1] = true;
            flag_lazy[2 * i + 2] = true;
        }
        flag_lazy[i] = false;
        lazy[i] = 0;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return;
        
        if (a <= l && r <= b) {
            lazy[k] += ((r - l) * (x));
            flag_lazy[k] = true;
            update(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]) % mod;
        }
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return 0;        
        if (a <= l && r <= b) return node[k] % mod;

        ll sum_l = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll sum_r = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (sum_l + sum_r) % mod;
    }

    void disp() {
        for (int i : node) {
            cout << i << " ";
        }
        cout << "\n";
    }

};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int L[K], R[K];
    for (int i = 0; i < K; i++) {
        cin >> L[i] >> R[i];
    }

    SegmentTree st(500050);
    st.add(1, 2, 1);
    
    for (int i = 1; i < N; i++) {
        ll x = st.query(i, i + 1);
        for (int j = 0; j < K; j++) {
            int l = i + L[j];
            int r = i + R[j] + 1;
            
            //st.add(min(l, N + 1), min(r, N + 1), x);
            st.add(l, r, x);
        }
        //cout << x << "\n";
    }

    cout << st.query(N, N + 1) << "\n";

    return 0;
}

Measured memory_bytes: 19832
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  vector<int> l(n); rep(i, n) cin >> l[i];
  sort(l);
  ll ans = 0;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int a = l[i], b = l[j];

      int k = max(a - b, b - a);

      // debug2(a, b);

      auto ub = upper_bound(l.begin(), l.end(), k);
      if (ub == l.end()) continue;
      int posl = distance(l.begin(), ub);

      // debug2(k, posl);

      auto lb = lower_bound(l.begin(), l.end(), a + b);
      int posr = distance(l.begin(), lb) - 1;

      // debug2(l[posl], l[posr]);

      // debug2("add", max(min(posr, n) - max(j + 1, posl), 0));
      ans += max(min(posr, n) - max(j + 1, posl) + 1, 0);
    }
  }

  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin  >> n;

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

    ll ans = 0;
    rep(i, n) {
        ll b;
        cin >> b;
        if(b <= a[i]) {
            ans += b;
        }
        else {
            ans += a[i];
            b -= a[i];
            if(b <= a[i+1]) {
                ans += b;
                a[i+1] -= b;
            }
            else {
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1024
def main():
    N,M = map(int, input().split())
    inf = 10**9
    p = 2**N
    dp = [inf] * p
    dp[0] = 0
    
    for i in range(M):
        a,b = map(int, input().split())
        c = sum([2**(int(j)-1) for j in list(input().split())])
        for k in range(p):
            if dp[k|c] > dp[k] + a:
                dp[k|c] = dp[k] + a
    if dp[-1] == inf:
        print(-1)
    else:
        print(dp[-1])

if __name__ == "__main__":
    main()



Measured memory_bytes: 3188
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int read() {
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9') {
        if(ch=='-')	f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9') {
        x=10*x+ch-'0';
        ch=getchar();
    }
    return x*f;
}
const int Size=100001;
int x,y;
int main() {
    x=read();
    y=read();
    if(x%y) {
    	printf("%d",x);
	} else {
		puts("-1");
	}
    return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int h,w;cin>>h>>w;
    vector<string> s(h+2);
    int dx[]={-1,0,1,-1,1,-1,0,1};
    int dy[]={-1,-1,-1,0,0,1,1,1};
    REP(i,w){
        s[0]+="?";
        s[h+1]+="?";
    }
    cerr<<"Initializing complete"<<endl;
    FOR(i,1,h+1){
        string temp;cin>>temp;
        s[i]=(string)"?"+temp+"?";
    }
    cerr<<"Inputing complete"<<endl;
    FOR(i,1,h+1){
        FOR(j,1,w+1){
            cerr<<"Viewing:"<<i<<","<<j<<endl;
            if(s[i][j]=='#'){
                continue;
            }
            int res=0;
            REP(k,8){
                cerr<<"Searching:"<<i+dx[k]<<","<<j+dy[k]<<endl;
                if(s[i+dx[k]][j+dy[k]]=='#'){
                    res++;
                }
            }
            s[i][j]='0'+res;
        }
    }
    FOR(i,1,h+1){
        FOR(j,1,w+1){
            cout<<s[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
  
class Main{
  public static void main(String [] args){
    Scanner scan = new Scanner(System.in);
    int a = Integer.parseInt(scan.next());
    int b = Integer.parseInt(scan.next());
    if (a > b){
      System.out.println("a > b");
    }
    if (a == b){
      System.out.println("a == b");
    }
    if (a < b){
      System.out.println("a < b");
    }
  }
}

Measured memory_bytes: 17120
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<u32>();
    println!("{}", (n - 2) * 180);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
typedef vector<vp> vvp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
  string s;
  ll k,count=0;
  cin>>s>>k;
  rep(i,0,s.size()){
    if(s[i]=='1'){count++;}
    else{break;}
  }
  if(k<=count){cout<<1<<endl;}
  else{cout<<s[count]<<endl;}
}




Measured memory_bytes: 256
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int64_t X;
  cin >> X;

  int64_t n500 = X / 500;
  X %= 500;
  int64_t n5 = X / 5;
  X %= 5;
  
  cout << (n500 * 1000 + n5 * 5) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(500000)
N = int(input())
h = [int(i) for i in input().split()]

memo = [float("inf")] * N
memo[0], memo[1] = 0, abs(h[1] - h[0])


def frog(ith):
    if memo[ith] != float("inf"):
        return memo[ith]
    memo[ith] = min(
        frog(ith - 1) + abs(h[ith] - h[ith - 1]),
        frog(ith - 2) + abs(h[ith] - h[ith - 2]),
    )
    return memo[ith]


print(frog(N - 1))


Measured memory_bytes: 94100
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        double xa, ya, ra, xb, yb, rb, s;
        while ((line = in.readLine()) != null) {
            int n = Integer.parseInt(line);
            while (n != 0) {
                n--;
                line = in.readLine();
                String[] strs = line.split("\\s+");
                xa = Double.parseDouble(strs[0]);
                ya = Double.parseDouble(strs[1]);
                ra = Double.parseDouble(strs[2]);
                xb = Double.parseDouble(strs[3]);
                yb = Double.parseDouble(strs[4]);
                rb = Double.parseDouble(strs[5]);
                s = Math.sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
                if (s + rb < ra) {
                    System.out.println("2");
                } else if (s + ra < rb) {
                    System.out.println("-2");  
                } else if (s <= ra + rb) {
                    System.out.println("1");
                } else if (s > ra + rb) {
                    System.out.println("0");
                }
            }
        } 
    }
}


Measured memory_bytes: 24248
def vector_multiplication(A, B):
    res = [[0 for _ in range(len(B[0]))] for _ in range(len(A))]
    for i in range(len(A)):
        for j in range(len(B[0])):
            for k in range(len(B)):
                res[i][j] += A[i][k] * B[k][j]
    return res


n, m = list(map(int, input().split()))
A = [[int(x) for x in input().split()] for _ in range(n)]
B = [[int(x) for x in input().split()] for _ in range(m)]
ans = vector_multiplication(A, B)
for i in ans:
    for j in i:
        print(j)


Measured memory_bytes: 6044
/*Bismillahir Rahmanir Rahim*/
#include<bits/stdc++.h>
using namespace std;
#define     ll        long long
#define     N         1e9+9
#define     PI        acos(-1.0)
#define     pb        push_back
#define     mp        make_pair
#define     ff        first
#define     ss        second
#define     gt        getchar()
#define     MOD       1000000007
#define     All(v1)   v1.begin(),v1.end()
#define     DBG(a)    cout<< #a <<" --> "<<(a)<<endl
ll arr[2000007],brr[200007],crr[200007];
char att[1000],m;
string g,h,v,x,ii,yy,vv;
int main()
{
    ll a,b,c,d,e=0,f,i,j=0,k=0,l,t;
    cin>>g;
    yy=g;
    reverse(yy.begin(),yy.end());
    if(yy==g)
        k=1;
    a=g.size();
    l=(a-1)/2;
    t=(a+3)/2;
    //cout<<l<<endl;
    //cout<<t<<endl;
    for(i=0;i<l;i++)
    {
        h+=g[i];
    }
    //DBG(h);
    x=h;
    reverse(x.begin(),x.end());
    if(x==h)
        j=1;
    for(i=t-1;i<g.size();i++)
    {
        v+=g[i];
    }
    //DBG(v);
    ii=v;
    reverse(ii.begin(),ii.end());
    if(ii==v)
        e=1;
    if(k==1 && e==1 && j==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}








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

int main(){
	for(int i ; ; i++){
		int x, y;
		cin >> x >> y;
		if(x==0 && y==0){
			break;
		}else{
			if(x>=y){
				int z;
				z = x;
				x = y;
				y = z;
			}
			cout << x << " " << y << endl;
		}
	}
	return 0;
}

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



int main() {
    int N; cin >> N;
    int ans = 0;
    for(int i = 1; i<= N; i++){
        if(i%2 == 0) continue;
        int cnt = 0;
        for(int j = 1; j<=i; j++){
            if(i%j == 0) cnt++;
        }
        if (cnt == 8)ans++;
    }

  cout << ans << endl;

  return 0;
}








Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,d,z1,z2;
double z3,z4,z5,z6;
void outn(){cout<<"NO\n";exit(0);}
void outy(){cout<<"YES\n";exit(0);}
int main(){
    z4=0.5;
    cin>>n>>a>>b>>c>>d;
    z3=(z3+c+d)/2,z4=z3-c,z5=z4*(n-1);z1=abs(a-b);
    if(z1>(n-1)*z3+z5)outn();
    z2=(int)(z1/z3);z6=z1-z3*z2;
    if(n%2)
        if(z2%2){z6=z3-z6;if(z6<=z5)outy();else outn();}
        else if(z6<=z5)outy();else outn();
    else
        if(z2%2)if(z6<=z5)outy();else outn();
        else{z6=z3-z6;if(z6<=z5)outy();else outn();}
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> p(N);
  for (int i=0; i<N; i++) {
    cin >> p.at(i);
  }
  
  sort(p.begin(), p.end());
  int sum=0;
  
  for (int i=0; i<N-1; i++){
    sum += p.at(i);
  }
  sum += p.at(N-1) / 2;
  
  cout << sum << endl;
        
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //M - Candies
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int maxn = 110;
const int maxm = 1e5 + 7;
const int mod = 1e9 + 7;

typedef long long int ll;

// ll dp[maxn][maxm];
ll dp[maxm],v[maxn],k;
ll pre[maxm];

int n,m;
inline ll go(int a,int b)
{
	if(a < 0) a = 0;

	if(a == 0) return pre[b]%mod;
	return (pre[b] - pre[a-1])%mod;
}

//dp[i][j] == na poss 'i' usando 'j' candies

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
		
	cin>>n>>k;
	for(int i=1;i<=n;++i) cin>>v[i];

	dp[0] = 1;
	
	for(int i=1;i<=n;++i)
	{
		
		pre[0] = dp[0];
		dp[0] = 0;

		for(int j=1;j<=k;++j)
			pre[j] = (dp[j] + pre[j-1])%mod;

		for(int j = 0; j <= k;++j)
			dp[j] = go(j-v[i],j);
	}

	
			
	// for(int j=0;j<=v[n];++j)
	// 	ans = (ans + dp[n][j])%mod;
	
	// cout<<ans<<"\n";
	if(dp[k] < 0) dp[k] += mod;
	
	cout<<dp[k]<<"\n";	
}

Measured memory_bytes: 5168
code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" namespace "atcoder":
    cdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()

from libc.stdio cimport scanf, printf
cdef int i
cdef int N, Q
cdef int t, u, v
scanf("%d%d", &N, &Q)
cdef dsu *d = new dsu(N)
for i in range(Q):
    scanf("%d%d%d", &t, &u, &v)
    if t == 0:
        d.merge(u, v)
    else:
        printf("%d\n", d.same(u, v))
"""
import os
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 10864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    if(a < b || d < b) {
        cout << "No" << endl;
        return;
    }

    if(c >= b-1) {
        cout << "Yes" << endl;
        return;
    }

    ll g = __gcd(b, d);
    if(b-c-1>=g) {
        cout << "No" << endl;
        return;
    }

    ll k = (c-a)/g+1;
    dump(a, b, c, d);
    dump(g, k, k*g+a);
    FOR(i, k-5, k+5) {
        if(c < i*g+a && i*g+a < b) {
            cout << "No" << endl;
            return;
        } 
    }
    cout << "Yes" << endl;
}

int main(void) {
    ll t;
    cin >> t;
    while(t--) solve();

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int X,Y,Z;
   cin >> X >> Y >> Z;
   swap(X,Y);
   swap(X,Z);
   cout << X << " " << Y << " " << Z << endl;
   return 0;
}


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

#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(var,start,end) for(int var=start; var<end; var++)
#define repr(var,start,end) for(int var=start; var>=end; var--)
#define repi(var,start,end) for(int var=start; var<=end; var++)
#define debg(var) cerr<<#var<<" : "<<var<<" "
#define pb push_back
#define mp make_pair

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

void solve() {
    int n;
    cin>>n;
    int k;
    int a[n];
    rep(i,0,n)
        cin>>a[i];
    k = a[0];
    rep(i,1,n)
        k^=a[i];
    rep(i,0,n) {
        cout<<(k^a[i])<<" ";
    }
}


int main() {
    fastio
    int t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4356
#include<iostream>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
const int MAXD = 30;
const int MAXN = 10;
int n, m, hit, d;
bool ladder[MAXD][MAXN-1];
bool tmp[MAXD][MAXN-1];
bool amida(void){
    int x = m-1;
    REP(i,d){
        if     (x==0){
            if(tmp[i][x])   x=x+1;
        }
        else if(x==n-1){
            if(tmp[i][x-1]) x=x-1;
        }
        else{
            if(tmp[i][x])        x=x+1;
            else if(tmp[i][x-1]) x=x-1;
        }
    }
    return (x==(hit-1));
}
void solve(void)
{   //with nothing
    REP(i,d) REP(j,n-1) tmp[i][j]=ladder[i][j];
    if(amida()){
        cout << 0 << endl;
        return;
    }
    //with one bar
    REP(i,d){ REP(j,n-1){
        if(ladder[i][j]) continue;
        if(j+1<n-1 && ladder[i][j+1]) continue;
        if(j-1>=0  && ladder[i][j-1]) continue;
        REP(k,d) REP(l,n-1) tmp[k][l]=ladder[k][l];
        tmp[i][j] = true; 
        if(amida()){
            cout << (i+1) << " " << (j+1) << endl;
            return;
        }
    }}
    //cannnot
    cout << 1 << endl;
}
int main(void)
{
    while(true){
        cin>>n;
        if(!n) break;
        cin>>m>>hit>>d;
        REP(i,d){
            string s;
            cin>>s;
            REP(j,n-1) ladder[i][j]=(s[j]=='1')?true:false;
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 3148
#include <stdio.h>

int main(){
 int N,M;
  scanf("%d %d", &N, &M);
  
  int shukudaiNeedDay = N;
  for(int i=0; i<M; i++){
    int A;
   	scanf("%d", &A);
    shukudaiNeedDay -= A;
  }
  if(shukudaiNeedDay<0){
    printf("-1");
  }else{
  	printf("%d", shukudaiNeedDay);
  }
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#ifdef TEST
#include <mytest.h>
#else
#define open(...) 0
#define print(...) 42
#endif
using namespace std;
namespace io {
  const int SZ = (1 << 22) + 1;
  char buf[SZ], *ptr = NULL, *bnd = NULL;
  #define GC() ((ptr == bnd) ? (ptr = buf, bnd = buf + fread(buf, 1, SZ, stdin), (ptr == bnd) ? EOF : (*(ptr++))) : (*(ptr++)))
  #define STATE(c) { if (c == '-') sgn = -1; else if (c == EOF) return false; }
  inline bool skip(const char& c) { return c < '0' || c > '9'; }
  template <class V>
  inline bool Read(V &v) {
    register char c, sgn = 1;
    while (skip(c = GC())) STATE(c);
    for (v = c - '0'; !skip(c = GC()); v = v * 10 + c - '0');
    return (v *= sgn), true;
  }
  char oBuf[SZ], *oCur = oBuf, *oBnd = oBuf + SZ, oStk[21], top = 0;
  inline void flush() { if (oCur - oBuf) fwrite(oBuf, 1, oCur - oBuf, stdout), oCur = oBuf; }
  inline void pc(char c) { *(oCur++) = c; if (oCur == oBnd) flush(); }
  template <class V>
  inline void Print(V v) {
    if (!v) return pc('0');
    if (v < 0) v = -v, pc('-');
    while (v) oStk[top++] = v % 10, v /= 10;
    while (top) pc(oStk[--top] + '0');
  }
  template <class V>
  inline void Println(const V& v) { Print(v), pc('\n'); }
  struct flusher { ~flusher() { flush(); } } __flusher__;
}
using io::Read;
using io::Println;
const int N = 1e3 + 5;
int a[N][N];
bool vis[N];
int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  // cin >> n;
  Read(n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < n; j++) {
      // cin >> a[i][j];
      Read(a[i][j]);
    }
    a[i][0] = 1;
  }

  int ans = 0, flg = 1, cnt = 0;
  while (flg) {
    flg = 0;
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; i++) {
      if (a[i][0] == n || vis[i]) continue;
      int t = a[i][a[i][0]];
      if (i == a[t][a[t][0]] && !vis[t]) {
        flg = 1;
        vis[i] = vis[t] = 1, cnt++;
        a[t][0]++, a[i][0]++;
      }
    }
    if (flg) ans++;
  }
  if (cnt != n * (n - 1) / 2) ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 10112
import math
import copy
from collections import Counter
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 

n=input()
s=input()

mod=7+10**9


def func():

    dic = Counter(s)
    ans = 1
    for x in dic:
        ans = ans*(dic[x]+1)%mod
    return ans-1
    
print(func())


Measured memory_bytes: 3748
n = int(input())
arr = list(map(int,input().split()))
arr = sorted(arr)

mid = arr[-1]/2
min_ = float('inf')
tmp = 0
for x in arr[:-1]:
    if abs(mid-x) < min_:
        tmp = x
        min_ = abs(mid-x)

print('{0} {1}'.format(arr[-1],tmp))

Measured memory_bytes: 14428
#include <stdio.h>

int main(){
  int n,x;
  if(scanf("%d",&n)==1 && scanf("%d",&x)==1){}
  int i,add;
  int point=0;
  int count=1;
  for(i=0;i<n;i++){
    if(scanf("%d",&add)==1){}
    point+=add;
    if(point <= x)count++;
  }
  printf("%d",count);
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

char str[1001];
char *p;
int values;

int formula() {
	char ch = *p++;
	switch (ch) {
		int l;
	case 'T':
		return 1;
	case 'F':
		return 0;
	case '-':
		return !formula();
	case '(':
		l = formula();
		switch (*p++) {
			int r;
		case '*':
			r = formula();
			p++;
			return l & r;
		case '+':
			r = formula();
			p++;
			return l | r;
		case '-':
			p++;
			r = formula();
			p++;
			return l == r | !l;
		}
	default:
		return values >> ch - 'a' & 1;
	}
}

int equation(void) {
	int l, r;

	p = str;
	l = formula();
	p++;
	r = formula();

	return l == r;
}

int main(void) {
	while (scanf("%s", str), str[0] != '#') {
		for (values = 0; values < 2048; values++)
			if (!equation())
				break;
		if (values == 2048)
			puts("YES");
		else
			puts("NO");
	}

	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    s.push_back('.');
    string t = "AKIHABARA";
    for(int i = 0; i < 9; i++){
        if(s[i] != t[i]) s.insert(i, "A");
    }
    s.pop_back();
    if(s == t) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

using namespace std;

int main(){
  for(int N;cin>>N,N;){
    int x[200],y[200];
    int l,r,t,b;
    x[0]=y[0]=l=r=t=b=0;
    for(int i=1;i<N;i++){
      int n,d;
      cin>>n>>d;
      int dx[]={-1,0,1,0};
      int dy[]={0,-1,0,1};
      x[i]=x[n]+dx[d];
      y[i]=y[n]+dy[d];
      l=min(l,x[i]);
      r=max(r,x[i]);
      t=max(t,y[i]);
      b=min(b,y[i]);
    }
    cout<<r-l+1<<' '<<t-b+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
//

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  string s;
  string d[4] = {"maerd", "remaerd", "esare", "resare"};
  int d_len[4] = {5, 7, 5, 6};
  cin >> s;
  reverse(s.begin(), s.end());

  while(s.length() != 0){
    //cout << s << endl;
    bool flg = false;
    for(int i = 0; i < 4; i++){
      if(s.find(d[i]) == 0){
        s = s.substr(d_len[i]);
        flg = true;
        break;
      }
    }
    if(flg) continue;
    else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main (){
    int a,b;
    cin>> a;
    cin>> b;
    if((a+b)%2!=0){
        cout<< "IMPOSSIBLE"<< endl;
    }
    else //if two numbers are equal it should be divisible by 2
        cout<<(a+b)/2<<endl;


return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int i, n;
  scanf("%d", &n);
  vector<int> v(n);
  for (i=0; i<n; i++) {
    scanf("%d", &v[i]);
  }
  while(1){
    if (v.size()==1) break;
    sort(v.begin(), v.end());
    for (i=1; i<v.size(); i++) {
      if (v[i]%v[0]==0) {
        v.erase(v.begin()+i);
      } else {
        v[i] = v[i]%v[0];
      }
    }
  }
  printf("%d\n", v[0]);
}

Measured memory_bytes: 640
x, y, a, b, c = map(int, input().split())
red = [int(x) for x in input().split()]
green = [int(x) for x in input().split()]
red.sort(reverse=True)
green.sort(reverse=True)
candidates = [int(x) for x in input().split()] + red[:x] + green[:y]
candidates.sort(reverse=True)
print(sum(candidates[:x+y]))

Measured memory_bytes: 23644
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9) + 7)

int main()
{
  int k;
  cin >> k;
  string s;
  cin >> s;
  bool flag = false;
  if(k >= s.size())
  {
    flag = true;
    k = s.size();
  }
  for(int i = 0;i < k;i++)
  {
    cout << s.at(i);
  }
  if(!flag)
  {
    cout << "..." << endl;
  }
  
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, q, l, r;
string s;
int psum[N];
int main() {
    cin >> n >> q;
    cin >> s;
    int sum = 0;
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'C' && s[i - 1] == 'A')
            ++sum;
        psum[i + 1] = sum;
    }
    for (int i = 0; i < q; ++i) {
        cin >> l >> r;
        cout << psum[r] - psum[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 4172
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <map>
using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;
	vector<int> alphabet(27);
	vector<int> alphabet2(27);
	string output = "Yes";
	for (int i = 0; i < S.length(); i++)
	{
		if (alphabet[S[i] - 'a'] == 0)
		{
			alphabet[S[i] - 'a'] = T[i];
		}
		else
		{
			if (alphabet[S[i] - 'a'] != T[i])
			{
				output = "No";
			}
		}
		if (alphabet2[T[i] - 'a'] == 0)
		{
			alphabet2[T[i] - 'a'] = S[i];
		}
		else
		{
			if (alphabet2[T[i] - 'a'] != S[i])
			{
				output = "No";
			}
		}
	}
	cout << output << endl;
	return 0;
}


Measured memory_bytes: 1020
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;


int main(){
	string s;
	cin >> s;
	if(s=="111")printf("3");
	else if(s=="000")printf("0");
	else if(s=="001" or s=="010" or s=="100")printf("1");
	else printf("2");

  return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
void kouri(int, int, int);
int  sum_max = 0;
int c[90][90] = { 0 };
int a, b;
int nx[] = { 1,0,-1,0 };
int ny[] = { 0,-1,0,1 };
int main() {
	while (1) {
		sum_max = 0;
		cin >> a;
		cin >> b;
		if (a == 0 && b == 0)break;
		for (int i = 1; i <= a; i++) {
			for (int j = 1; j <= b; j++) {
				cin >> c[i][j];
			}
		}
		for (int i = 1; i <= a; i++) {
			for (int j = 1; j <= b; j++) {
				if (c[i][j] == 1) {
					kouri(i, j, 0);
				}
			}
		}
		memset(c, 0, sizeof(c));
		cout << sum_max << endl;
	}
	return 0;
}
void kouri(int x, int y, int sum) {
	c[x][y] = 0;
	sum++;
	if (c[x][y + 1] == 1)kouri(x, y + 1, sum);
	if (c[x][y - 1] == 1)kouri(x, y - 1, sum);
	if (c[x + 1][y] == 1)kouri(x + 1, y, sum);
	if (c[x - 1][y] == 1)kouri(x - 1, y, sum);
	c[x][y] = 1;
	if (sum > sum_max)sum_max = sum;
}

Measured memory_bytes: 3092
gets
rate = $stdin.read.split.map(&:to_i)
maxv = rate[-1] - rate[0]
minv = rate[0]
1.upto(rate.length-1) do |i|
	d = rate[i].to_i - minv
	maxv = d if d>maxv
	minv = rate[i] if rate[i]<minv
end
puts maxv


Measured memory_bytes: 19980
#include <algorithm>
#include <climits>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <stack>
#include <string>
#include <vector>

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

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

int main(){
  string s;

  cin >> s;

  bool f1 = false, ans = false;

  REP(i, 0, s.size()){
    if(f1 == false && s[i] == 'C'){
      f1 = true;
    } else if(f1 == true && s[i] == 'F'){
      ans = true;
    }
  }

  if(ans == true){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

using namespace std;

int a[8] = {0,1,2,3,4,5,6,7};
unsigned char result[76543211];

int conv_n(vector<int> a) {
    int retval = 0;
    for(int i = 0;i < a.size();i++) {
        retval = retval * 10 + a[i];
    }
    return retval;
}

void solve() {
    for(int i = 0;i < 76543211;i++) {
        result[i] = 100;
    }
    queue<pair<vector<int>,int> > bfs;
    vector<int> temp;
    for(int i = 0;i < 8;i++) {
        temp.push_back(a[i]);
    }
    bfs.push(make_pair(temp,0));
    while(!bfs.empty()) {
        temp = (bfs.front()).first;
        int depth = (bfs.front()).second;
        bfs.pop();
        int zero;
        for(int i = 0;i < 8;i++) {
            if(temp[i] == 0)
                zero = i;
        }
        if(result[conv_n(temp)] <= depth) continue;
        result[conv_n(temp)] = depth;
        if(zero % 4 != 0) {
            swap(temp[zero],temp[zero-1]);
            bfs.push(make_pair(temp,depth+1));
            swap(temp[zero],temp[zero-1]);
        }
        if(zero % 4 != 3) {
            swap(temp[zero],temp[zero+1]);
            bfs.push(make_pair(temp,depth+1));
            swap(temp[zero],temp[zero+1]);
        }
        if(zero < 4) {
            swap(temp[zero],temp[zero+4]);
            bfs.push(make_pair(temp,depth+1));
            swap(temp[zero],temp[zero+4]);
        }
        if(zero >= 4) {
            swap(temp[zero],temp[zero-4]);
            bfs.push(make_pair(temp,depth+1));
            swap(temp[zero],temp[zero-4]);
        }
    }
}

int main(void) {
    solve();
    while(1) {
        if(!(cin >> a[0]))
            break;
        for(int i = 1;i < 8;i++)
            cin >> a[i];
        vector<int> temp;
        for(int i = 0;i < 8;i++) {
            temp.push_back(a[i]);
        }
        cout << (int)result[conv_n(temp)] << endl;
    }
}


Measured memory_bytes: 78016
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	while (s != "#") {
		int sy, sx, gy, gx;
		cin >> sy >> sx >> gy >> gx;
		sy--;
		sx--;
		gy--;
		gx--;
		vector<string>field;
		s += '/';
		string t;
		for (auto i : s) {
			if (i == '/') {
				field.push_back(t);
				t.clear();
				continue;
			}
			if (i == 'b') {
				t.push_back('b');
				continue;
			}
			for (int j = '0'; j < i; j++) {
				t.push_back('.');
			}
		}
		swap(field[sy][sx], field[gy][gx]);
		H = field.size();
		W = field[0].size();
		string ret;
		for (int i = 0; i < H; i++) {
			int num = 0;
			for (int j = 0; j < W; j++) {
				if (field[i][j] == 'b') {
					if (num) {
						ret+=to_string(num);
					}
					ret += 'b';
					num = 0;
				}
				else {
					num++;
				}
			}
			if (num) {
				ret += to_string(num);
			}
			ret += '/';
		}
		ret.pop_back();
		cout << ret << endl;
		cin >> s;
	}
	return 0;
}


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

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

void solve(long long N, long long K, std::vector<long long> H) {
  // solver code

  LL sum = 0;

  sort(H.begin(), H.end(), greater<LL>());

  for (int i = 0; i < N; i++) {
    if (K-- > 0) continue;
    sum += H[i];
  }

  cout << sum << endl;
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define str string
#define optimizator ios_base::sync_with_stdio(0);
using namespace std;
int main(){
	optimizator;
	int a,b;
	cin>>a>>b;
	if(a%b==0){
		cout<<a/b;
	}
	else{
		cout<<a/b+1;
	}
}

Measured memory_bytes: 256