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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define fi first
#define se second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr ll MOD = 1000000007;

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

ll dp[2005][2005];
ll sum[2005][2005];

int main(int argc, char* argv[]) {
  ll n, m;
  cin >> n >> m;
  vec<ll> s(n), t(m);
  scan(s), scan(t);

  rep(i, 0, n) rep(j, 0, m) {
    if (s[i] == t[j]) dp[i][j] = sum[i][j] + 1;

    sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + dp[i][j];
    sum[i + 1][j + 1] = mod(sum[i + 1][j + 1], MOD);
  }

  cout << sum[n][m] + 1 << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }

Measured memory_bytes: 62848
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll a; cin >> a;
    cout << a + a*a + a*a*a << endl;

}

Measured memory_bytes: 3588
#include<stdio.h>

int main(){
  int H1=0;
  int M1=0;
  int H2=0;
  int M2=0;
  int K=0;
  
  int T=0;
  
  scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);
  
  T=(60*H2+M2-K)-(60*H1+M1);
  
  printf("%d",T);
  
  return 0;
}

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

int main(){
    long N=0,K=0,x=0,y=0,ans=0;
    cin >> N >> K;
    x=N%K;
    y=-(x-K);
    if(x>=y){ans=y;}
    else{ans=x;}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#D 400

def devide(n):
    if memo[n]!=-1:
        return memo[n]
    tmp = 0
    if 3<=n:
        tmp += 1
    for i in range(3,n+1):
        if n-i>=3:
            tmp += devide(n-i)
    memo[n] = tmp
    return tmp
    
s = int(input())
memo = [-1 for i in range(s+1)]
print(devide(s)%(10**9+7))



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

i64 dp[101][100001];

void solve() {
  int N, W;
  cin >> N >> W;
  rep(i, 101) rep(j, 100001) dp[i][j] = 2e9;
  dp[0][0] = 0;
  rep(i, N) {
    int w, v;
    cin >> w >> v;
    rep(j, 100001) {
      if (dp[i][j] == 2e9) continue;
      amin(dp[i + 1][j], dp[i][j]);
      amin(dp[i + 1][j + v], dp[i][j] + w);
    }
  }
  int ans = -1e9;
  repc(j, 100000) if (dp[N][j] <= W) {
    amax(ans, j);
  }
  cout << ans << endl;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT32_MAX;
ll i;

int main(){
    ll K,N;
    cin>>K>>N;
    V A(N);
    rep(i,N)cin>>A.at(i);
    ll ans=A.at(0)+(K-A.at(N-1));
    for(ll j=1;j<N;j++)ans=max(ans,A.at(j)-A.at(j-1));
    cout<<K-ans<<endl;
}


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

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b)
{
    for (int i = 0; i < M; i++)
    {
        long long mid = -1;
        if (a.at(i) == 1 || b.at(i) == 1)
        {
            if (a.at(i) != 1)
            {
                mid = b.at(i);
            }
            else
            {
                mid = a.at(i);
            }
        }
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    vector<bool> A(N + 2, false);
    vector<bool> B(N + 2, false);
    for (int i = 0; i < M; i++)
    {
        int a = 0, b = 0;
        cin >> a >> b;
        if (a == 1)
        {
            A[b] = true;
        }
        if (b == N)
        {
            B[a] = true;
        }
    }
    for (int i = 1; i <= N; i++)
    {
        if (A[i] && B[i])
        {
            cout << YES << endl;
            return 0;
        }
    }

    cout << NO << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定
 
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL
 
int main(void) {
    long n, sum = 0;
    cin >> n;
    rep(i, n) {
        if ((i + 1) % 3 != 0 && (i + 1) % 5 != 0) sum += i + 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <set>

const int P=998244353;
inline int mul(const int &a,const int &b){return 1ll*a*b%P;}
inline int add(int a,const int &b){a+=b;return(a>=P)?a-P:a;}
inline int sub(int a,const int &b){a-=b;return (a<0)?a+P:a;}
int qsm(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=mul(ans,a);
		a=mul(a,a);
		b>>=1;
	}
	return ans;
}
int Pow[100001],f[131072],lim,n,head[100001],nxt[100001],b[100001],k,m,v[100001],g[131072];
void push(int s,int t){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
}
std::set<int>set;
void FWT(int *a){
	for(int i=1;i<lim;i<<=1)
		for(int j=0;j<lim;j+=(i<<1))
			for(int k=0;k<i;k++){
				const int Ny=a[i+j+k];
				a[i+j+k]=sub(a[j+k],Ny);
				a[j+k]=add(a[j+k],Ny);
			}
}
int main(){
	scanf("%d",&n);
	lim=1;
	while(lim<=n)lim<<=1;
	for(int i=0;i<lim;i++)g[i]=1;
	Pow[0]=1;
	for(int i=1;i<=n;i++)Pow[i]=mul(Pow[i-1],(1000000000000000000ll)%P);
//	for(int i=1;i<=n;i++)printf("%d ",Pow[i]);putchar('\n');
	for(int fd=0;fd<3;fd++){
		for(int j=1;j<=n;j++)head[j]=v[j]=0;
		k=0;
		scanf("%d",&m);
		for(int j=1,u,v;j<=m;j++){
			scanf("%d%d",&u,&v);
			if(u>v)push(v,u);
			else push(u,v);
		}
		for(int i=n;i;i--){
			set.clear();
			for(int j=head[i];j;j=nxt[j])
				set.insert(v[b[j]]);
			for(v[i]=0;set.count(v[i]);v[i]++);
		}
		for(int j=0;j<lim;j++)f[j]=0;
		for(int j=1;j<=n;j++)f[v[j]]=add(f[v[j]],Pow[j]); 
		FWT(f);
		for(int j=0;j<lim;j++)g[j]=mul(g[j],f[j]);
	}
	int inv=qsm(lim,P-2),ans=0;
	for(int i=0;i<lim;i++)ans=add(ans,g[i]);
	printf("%d\n",mul(ans,inv));
}

Measured memory_bytes: 3200
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace


using namespace std;

lli solve(string const &s, string const &t) {
  vector<vector<lli>> next(26, vector<lli>(s.size()+1, -1));
  REP(i, s.size()) { next[s[i]-'a'][i] = i; }
  REP(c, 26) RREP(j, s.size()) {
    if (next[c][j] < 0) { next[c][j] = next[c][j+1]; }
  }
  vector<lli> dp(t.size(), 0);
  dp[0] = next[t[0]-'a'][0];
  if (dp[0] < 0) { return -1; }
  FOR(i, 1, t.size()-1) {
    int c = t[i] - 'a';
    lli last = dp[i-1] % s.size();
    if (next[c][last+1] >= 0) {
      dp[i] = dp[i-1] + next[c][last+1] - last;
    } else if (next[c][0] >= 0) {
      dp[i] = dp[i-1] + s.size() - last + next[c][0];
    } else {
      return -1;
    }
  }
  return dp[t.size()-1] + 1;
}

int main() {
  // cout << fixed << setprecision(10);

  string S, T;
  cin >> S >> T;
  cout << solve(S, T) << endl;
  return 0;
}


Measured memory_bytes: 21888
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


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

  string s1, s2;
  cin >> s1;
  cin >> s2;

  vector<bool> s;

  for (int i = 0; i < n; ++i) {
    if (s1[i] == s1[i + 1]) {
      s.push_back(true);
      i++;
    } else {
      s.push_back(false);
    }
  }

  ll ans = 1;


  bool befs = s[0];
  if (s[0] == true) {
    ans *= 3 * 2;
  } else {
    ans *= 3;
  }


  for (int i = 1; i < s.size(); i++) {
    if (s[i]) {
      if (befs == s[i]) {
        ans *= 3;
      } else {
        ans *= 2;
      }

    } else {
      if (befs == s[i]) {
        ans *= 2;
      } else {
        ans *= 1;
      }

    }
    ans %= mod;



    befs = s[i];
  }


  cout << ans << endl;

}




















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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n;
int sum=0;
vector<int> s;

int main(){
  scanf("%d",&n);
  REP(i,n){
    int a;
    scanf("%d",&a);
    s.push_back(a);
    sum+=a;
  }
  sort(s.begin(),s.end());
  if(sum%10!=0){
    printf("%d\n",sum);
    return 0;
  }
  REP(i,n){
    if(s[i]%10!=0){
      printf("%d\n",sum-s[i]);
      return 0;
    }
  }
  printf("0\n");
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

#define ll long long int
#define ull unsigned long long int

#define INF 100000000000L

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> num;
    ll score;

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        num.resize(N);
        for(int i = 0; i < N; i++) {
            par[i] = i;
            num[i] = 1;
        }
        score = N*(N-1)/2;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        ll num_x = num[rx];
        ll num_y = num[ry];
        score -= num_x * num_y;
        num[rx] = num_x+num_y; 
        num[ry] = num_x+num_y;
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll N,M;
vector<int> A,B;

int main(){
    cin >> N >> M;
    UnionFind U(N);
    A.resize(M);
    B.resize(M);
    vector<ll> ans(M);
    for(int i = 0;i < M;i++){
        cin >> A[i] >> B[i];
    }
    for(int i=M-1;i >= 0; i--){
        ans[i] = U.score;
        U.unite(A[i]-1,B[i]-1);
    }
    for(int i= 0;i < M ;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll mini = LONG_LONG_MAX;
    ll x, y;
    cin >> x >> y;
    rep(i, 1LL << 2) {
        ll val = x;
        ll count = 0;
        if(i & 1LL) {
            val *= -1;
            count++;
        }
        count += abs(abs(y) - abs(val));
            val += abs(abs(y) - abs(val));
        if(i & 2LL) {
            // count += abs(y) - val;
            // val += abs(y) - val;
            val *= -1;
            count++;
        } else {
            // count += abs(abs(y) - abs(val));
            // val += abs(abs(y) - abs(val));
        }
        if(val == y && count >= 0) mini = min(count, mini);
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
lsa = list(map(int,input().split()))
ls = []

for i in range(n - 1):
    if lsa[i] < lsa[i + 1]:
        ls.append("up")
    elif lsa[i] == lsa[i + 1]:
        ls.append("keep")
    else:
        ls.append("down")

lssb = []
for i in range(n - 1):
    if i == 0:
        if ls[0] == "up":
            lssb.append(1)
        else:
            lssb.append(0)
    else:
        if ls[i - 1] == "up":
            if ls[i] == "down":
                lssb.append(2)
            else:
                lssb.append(0)
        elif ls[i - 1] == "keep":
            if ls[i] == "up":
                lssb.append(1)
            elif ls[i] == "down":
                lssb.append(2)
            else:
                lssb.append(0)
        else:
            if ls[i] == "up":
                lssb.append(1)
            else:
                lssb.append(0)
lssb.append(2)

money = 1000
kabu = 0

for i in range(n):
    if lssb[i] == 1:
        kabu += money // lsa[i]
        money = money % lsa[i]
    elif lssb[i] == 2:
        money += kabu * lsa[i]
        kabu = 0

print(money)


Measured memory_bytes: 9124
n=int(input())
a=[int(k) for k in input().split()][ :n]
c=0
a.sort();
for i in range(len(a)):
    for j in range(i+1,len(a)):
        for m in range(j + 1, len(a) ):
            if (a[i]+a[j]>a[m] and a[i]+a[m]>a[j] and a[m]+a[j]>a[i]) and (a[i]<a[j] and a[j]<a[m]) :
                c+=1

print(c)

Measured memory_bytes: 9120
#include <iostream>
using namespace std;
int main()
{
  int N, H, W;
  cin >> N >> H >> W;
  int A[N], B[N];
  for (int i = 0; i < N; i++)
    cin >> A[i] >> B[i];
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (H <= A[i] && W <= B[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
B - RGB Boxes
https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b

"""
import sys


def solve(R, G, B, N):
    ans = 0
    for r in range(N//R+1):
        for g in range(N//G+1):
            t = N - r*R - g*G
            if t < 0:
                break
            if t % B == 0:
                ans += 1
    return ans


def main(args):
    R, G, B, N = map(int, input().split())
    ans = solve(R, G, B, N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
S = input()
T = input() #s>t
ans = 1000
d = len(S) - len(T)
for i in range(d+1):
    s = S[i:i + len(T)]
    t = T
    a = 0
    #print(s,t)
    for j in range(len(T)):
        if not(s[j] == t[j]):
            a+=1
    if  a <ans:
        ans = a
print(ans)

Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,H;
  cin >> N >> H;
  int ans = 0;
  vector<int> a(N);
  vector<int> b(N);
  for(int i = 0;i < N;i++)cin >> a[i] >> b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int maxa = a[N-1];
  for(int i = 1;i <= N;i++){
    if(b[N-i] <= maxa)break;
    ans++;
    H -= b[N-i];
    if(H <= 0)break;
  }
  H = max(H,0);
  ans += (H + maxa -1)/maxa;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    if(A + B < C + D)
        cout << "Right" << endl;
    else if(A + B == C + D)
        cout << "Balanced" << endl;
    else
        cout << "Left" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2e5 + 123;
int n, a[N], m;
vi adj[N];

struct Node {
	int l = 0, r = 0, mx = 0;
	void merge(const Node & x, const Node & y) {
		l = x.l, r = y.r;
		mx = max(x.mx, y.mx);
	}
};

Node t[(1 << 19) + 1];

void build(int v, int l, int r) {
	t[v].l = l, t[v].r = r;
	if (l == r) {
		return;
	}
	int m = l + r >> 1;
	build(v << 1, l, m);
	build(v << 1 | 1, m + 1, r);
	t[v].merge(t[v << 1], t[v << 1 | 1]);
}

void upd(int v, int pos, int x) {
	if (t[v].l == t[v].r) {
		t[v].mx = x;
		return;
	}
	int m = t[v].l + t[v].r >> 1;
	if (pos <= m) {
		upd(v << 1, pos, x);
	}	else {
		upd(v << 1 | 1, pos, x);
	}
	t[v].merge(t[v << 1], t[v << 1 | 1]);
}

int getmax(int v, int l, int r) {
	if (t[v].l > r || t[v].r < l) {
		return 0;
	}
	if (t[v].l >= l && t[v].r <= r) {
		return t[v].mx;
	}
	return max(getmax(v << 1, l, r), getmax(v << 1 | 1, l, r));
}

struct Seq {
	vi vec, val[N];
	Seq() {
		build(1, 1, 200000);
	}
	int get(int x) {
		return getmax(1, 1, x);
	}
	void add(int x) {
		vec.pb(x);
		int tmp = get(x - 1) + 1;
		upd(1, x, tmp);
		val[x].pb(tmp);
	}
	void pop() {
		int x = vec.back();
		val[x].ppb();
		vec.ppb();
		int tmp = 0;
		if (!val[x].empty()) {
			tmp = val[x].back();
		}
		upd(1, x, tmp);
	}
};

Seq s;
int ans[N];

void dfs(int v, int p) {
	s.add(a[v]);
	ans[v] = s.get(m);
	for (int to : adj[v]) {
		if (to == p) {
			continue;
		}
		dfs(to, v);
	}
	s.pop();
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	vi comp;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		comp.pb(a[i]);
	}
	sort(all(comp));
	comp.erase(unique(all(comp)), comp.end());
	m = comp.size();
	for (int i = 1; i <= n; i++) {
		a[i] = lower_bound(all(comp), a[i]) - comp.begin() + 1;
	}
	for (int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	dfs(1, 1);
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << '\n';
	}
}


Measured memory_bytes: 41644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

struct item
{
	//weight, value
	ll w = 0, v = 0;
	item(ll a = 0, ll b = 0)
	{
		w = a;
		v = b;
	}
};

const ll INF = 1e15;
ll n, cap;
vector<item> items(10000);
bool cached[100][100000];
ll memo[100][100000];

ll knap(int i, int curcap)
{
	if (curcap < 0)
		return -INF;
	if (i == n)
		return 0LL;
	if (cached[i][curcap])
		return memo[i][curcap];

	ll res2 = knap(i + 1, curcap);
	ll res1 = knap(i + 1, curcap - items[i].w) + items[i].v;
	ll res = max(res1, res2);
	cached[i][curcap] = true;
	memo[i][curcap] = res;
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> cap;
	for (int i = 0; i < n; i++)
	{
		ll w, v;
		cin >> w >> v;
		items[i] = item(w, v);
	}
	cout << knap(0, cap);
}


Measured memory_bytes: 84856
import java.util.*;
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
        Scanner obj=new Scanner(System.in);
        int N,i,min,j,temp,tot=0;
        int p[],k;
        N=obj.nextInt();
        k=obj.nextInt();
        p=new int[N];
        if(N>=k)
        {
        for(i=0;i<N;i++)
            p[i]=obj.nextInt();
        for(i=0;i<N;i++)
        {
            min=i;
            for(j=i+1;j<N;j++)
            {
                if(p[j]<p[min])
                    min=j;
            }
            temp=p[i];
            p[i]=p[min];
            p[min]=temp;
        }
        for(i=0;i<k;i++)
            tot+=p[i];
        System.out.println(tot);
    }
    }
}


Measured memory_bytes: 30144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {

            List<long> a = new List<long>(2000000 + 1);
            a.Add(0);// dummy
           
            while(true)
            {
                string[] szarr = Console.ReadLine().Split(' ');
                string cmd = szarr[0];
                if(cmd == "insert")
                {
                    long key = long.Parse(szarr[1]);
                    Insert(a, key);
                }else if(cmd == "extract")
                {
                    Console.WriteLine(HeapExtractMax(a));
                }
                else
                {
                    // end
                    break;
                }
            }
        }
        static long HeapExtractMax(List<long> a)
        {
            if( a.Count < 1)
            {
                return 0;
            }
            long max = a[1];
            a[1] = a[a.Count - 1];
            a.RemoveAt(a.Count - 1);
            MaxHeapify(a, 1);
            return max;
        }
        static void Insert(List<long> a, long key)
        {
            a.Add(long.MinValue);
            HeapIncreaseKey(a, a.Count-1, key);
        }
        static void HeapIncreaseKey(List<long> a, int i, long key)
        {
            if( key < a[i])
            {
                // error
                return;
            }

            a[i] = key;
            while(i > 1 && a[Parent(i)] < a[i])
            {
                long tmp = a[i];
                a[i] = a[Parent(i)];
                a[Parent(i)] = tmp;
                i = Parent(i);
            }
        }
        static int Parent(int i) { return i / 2; }
        static int Left(int i) { return 2 * i; }
        static int Right(int i) { return 2 * i + 1; }
        static void MaxHeapify(List<long> a, int i)
        {
            int l = i * 2;
            int r = i * 2 + 1;
            int largest = 0;
            if( l < a.Count && a[l] > a[i])
            {
                largest = l;
            }else
            {
                largest = i;
            }
            if( r < a.Count && a[r] > a[largest])
            {
                largest = r;
            }

            if( largest != i)
            {
                long tmp = a[i];
                a[i] = a[largest];
                a[largest] = tmp;
                MaxHeapify(a, largest);
            }
        }
        static void BuildMaxHeap(List<long> a)
        {
            for(int i=a.Count / 2; i >= 1; --i)
            {
                MaxHeapify(a, i);
            }
        }
    }

}



Measured memory_bytes: 37532
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <math.h>
#include <stdio.h>
#define pai 3.1415926535
using namespace std;

int a;
int b;
int c;

double s;
double l;
double h;

int main() {

	cin >> a >> b >> c;

	double C = pai * c / 180;

	s = a * b * sin(C) * 0.5;
	l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C));
	h = 2 * s / a;

	printf("%.5f\n", s);
	printf("%.5f\n", l);
	printf("%.5f\n", h);

	return 0;
}


Measured memory_bytes: 3376
// Author : Abhisar Singhal
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>   
#include <map>
#include <string>  
#include <climits> 
#include <set>
#include <string>    
#include <sstream>
#include <utility>   
#include <ctime>
#include <cassert>
#include <fstream>
#include <iomanip>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<long long> VLL;
typedef vector<bool> VB;

#define SZ(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MAX(a,b) ((a >= b) ? (a) : (b))
#define MIN(a,b) ((a >= b) ? (b) : (a))
#define ABS(a) (((a) > 0) ? (a) : (-a))
#define MP make_pair
#define X first
#define Y second
#define PB push_back
#define FOUND(A, x) (A.find(x) != A.end())
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12

#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define clrbit(s, b) (s &= ~(1<<b))

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < n; i++)
#define REV(i, a, n) for(int i = a; i > n; i--)
#define FORALL(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 1, 0, 0, -1, -1, -1}, dy[] = {1, 0, -1, 1, -1, 1, 0, -1};
inline void inp( int &n ) {
	n=0; int ch = getcx(); int sign = 1;
	while(ch < '0' || ch > '9') { if(ch == '-') sign=-1; ch = getcx(); }
	while(ch >= '0' && ch <= '9') { n = (n << 3) + (n << 1) + ch - '0', ch = getcx(); }
	n = n * sign;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
    int n;
	cin >> n;
	VI A(n);
	REP (i, n) cin >> A[i];
	int sum = 0;
	REP (i, n) sum += A[i];
	int ans = sum;
	REP (i, n) {
		if (sum % 10 == 0) {
			if ((sum - A[i]) % 10) {
				if (ans == sum) ans -= A[i];
				else ans = max(ans, sum - A[i]);
			}
		}
	}
	if ((ans % 10) == 0) ans = 0;
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#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()
#define inf = 9876543210
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b; cin>>a>>b;
    print((a-1)*(b-1));
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int a, b, c; cin >> a >> b >> c;
	cout << (a + b + c >= 22 ? "bust" : "win") << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

ans = 0
for i in range(N):
    temp = input().split(" ")
    x = float(temp[0])
    u = temp[1]
    if u == 'BTC':
        x = x * 380000
    ans += x

print(ans)



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    string str;
    cin >> str;
    for(ll i=0;i<3;i++){
            if(str[i]==str[i+1]){
                cout << "Bad" << endl;
                return 0;
            }
    }
    cout << "Good" << endl;
    return 0;
}


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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for(int i = s; i < (e); ++i)
#define FASTIO                                                                                     \
	ios_base::sync_with_stdio(false);                                                              \
	cin.tie(NULL);
#define FILEIO                                                                                     \
	freopen("./input.txt", "r", stdin);                                                            \
	freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                                                  \
	for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;  \
		debug("%s : %lld ms\n ",                                                                   \
			  d,                                                                                   \
			  chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() -   \
														  blockTime.first)                         \
				  .count()),                                                                       \
			 blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T& x) {
	return x > 0 ? x : -x;
}
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }
ll ceil2(ll a, ll b) { return (a + b - 1) / b; }

int main() {
	FASTIO
#ifdef LOCAL
	FILEIO
#endif
	ll n, d;
	cin >> n >> d;
	d = d * d;
	ll cnt = 0, x, y;
	forn(i, 0, n) {
		cin >> x >> y;
		if(x * x + y * y <= d) { ++cnt; }
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}

void solve(long long A, long long B, long long C, long long D){
	ll x,y,g,l;
	g = extgcd(C, D, x, y);
	l = C*D/g;
	ll am,b;
	am = (A-1)/C+(A-1)/D-(A-1)/l;
	b = B/C+B/D-B/l;
	cout << B-(A-1)-(b-am) << endl;
}

int main(){	
	long long B;
	long long A;
	long long D;
	long long C;
	scanf("%lld",&A);
	scanf("%lld",&B);
	scanf("%lld",&C);
	scanf("%lld",&D);
	solve(A, B, C, D);
	return 0;
}



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

int main(){
    int64_t A,B,K;
    cin>>A>>B>>K;
    if(A>K){
        A=A-K;
    }else if(A+B<=K){
        A=0;
        B=0;
    }else{
        B-=K-A;
        A=0;
    }
    cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  while(1)
    {
  int H,W;

  scanf("%d %d",&H,&W);

  if(H==0 && W==0)
    {
      break;
    }

  for(int y=0;y<H;y++)
    {
      for(int x=0;x<W;x++)
	{
	  if(y==0 || y==H-1)
	    {
	      if(x==W-1)
		{
		  printf("#\n");
		}
	      else
		{
		  printf("#");
		}
	    }
	  else
	    {
	  if(x==0)
	    {
	      printf("#");
	    }
	      else if(x == W - 1)
	    {
	      printf("#\n");
	    }
	  else
	    {
	      printf(".");
	    }
	    }
	}
    }
  printf("\n");
    }
  
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<double> p(n,0.0);
  rep(i,0,n) cin >> p[i];
  vector<vector<double>> dp(n, vector<double>(n+2,0.0));
  dp[0][0] = 1.0 - p[0];
  dp[0][1] = p[0];
  rep(i,0,n-1) rep(j,0,n+1) {
    dp[i+1][j] += dp[i][j] * (1.0 - p[i+1]);
    dp[i+1][j+1] += dp[i][j] * p[i+1];
  }
  double ans = 0.0;
  rep(i,n/2+1,n+1) ans += dp[n-1][i];
  printf("%.10lf\n", ans);
  return 0;
}


Measured memory_bytes: 73724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int, int>;
const int INF (1<<30);

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  map<int, int> mp;


  int now = 0;
  ll l = 0LL, loopNum = N;
  vector<int> order(N, 0);
  rep(i, N) {
    auto it = mp.find(now);
    if (it != mp.end()) {
      l = it->second;
      loopNum = (i) - it->second;
      break;
    }

    mp[now] = i;
    order[i] = now;
    now = A[now]-1;
  }


  if (K <= l) {
    cout << (order[K]+1) << endl;
  }
  else {
    int mod = (K-l) % loopNum;
    cout << (order[l + mod]+1) << endl;
  }

  return 0;
}


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

int main(void) {
  int A, B, kuti;
  int answer=1;
  scanf("%d %d", &A, &B);
  if (B==1) { //タップが不要な場合
    printf("0\n");
  } else {
    kuti = A;
    while (kuti<B) {
      kuti = kuti + A - 1;
      answer++;
    }
    printf("%d\n", answer);
  }
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
	char s[11];
	char t[11];
	char u[11];
	int a,b;
	scanf("%s %s\n%d %d\n%s",s,t,&a,&b,u);
	if(strcmp(u,s)==0){
	printf("%d %d\n",a-1,b);
    }
	else if(strcmp(u,t)==0){
	printf("%d %d\n",a,b-1 );
    } 
	return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<cstdlib>
#include<vector>
#include <cmath>
#include <time.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int i;
  int ans=n;

  for(i=0;i<n;i++){
    if(s[i]==s[i+1]){
      ans--;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main()
{
    string s, f[2][26], z;
    cin >> s;

    for (int i = 0; i < 26; i++)
    {
        if (s[s.size()-1] == (char)('a'+i))
        {
            f[0][i] = (char)('a'+i);
            f[0][i] += "a";
        }
        else
            f[0][i] = (char)('a'+i);
    }

    for (int i = s.size()-2; i >= 0; i--)
    {
        z = f[0][0];

        for (int j = 1; j < 26; j++)
            if (f[0][j].size() < z.size())
                z = f[0][j];
            else if (f[0][j].size() == z.size() && f[0][j] < z)
                z = f[0][j];

        for (int j = 0; j < 26; j++)
            if (s[i] == (char)(j+'a'))
            {
                f[1][j] = (char)(j+'a');
                f[1][j] += z;
            }
            else
                f[1][j] = f[0][j];

        for (int j = 0; j < 26; j++)
            f[0][j] = f[1][j];
    }

    z = f[0][0];

    for (int j = 1; j < 26; j++)
        if (f[0][j].size() < z.size())
            z = f[0][j];
        else if (f[0][j].size() == z.size() && f[0][j] < z)
            z = f[0][j];

    cout << z;
}


Measured memory_bytes: 644
from collections import deque

N = int(input())
tree = [[] for _ in range(N)]

for i in range(N-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append((b, c))
    tree[b].append((a, c))

Q, K = map(int, input().split())
K -= 1

depth = [0 for _ in range(N)]

def bfs(v, p = -1, d = 0):
    q = deque()
    q.append([v, p, d])
    while len(q)>0:
        cur = q.popleft()
        depth[cur[0]] = cur[2]
        for i, j in tree[cur[0]]:
            if i == cur[1]:
                continue
            q.append([i, cur[0], cur[2] + j])

bfs(K)

for i in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print (depth[x] + depth[y])

Measured memory_bytes: 49280
#include<bits/stdc++.h>
using namespace std;
string s;
int l,ans,d;
int main(){
	cin>>l>>s;
	for(int i=0;i<l;i++){
		if(s[i]=='I')d++;
		else d--;
		ans=max(ans,d);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  int n, a, black;
  cin >> n >> a;
  
  if(n <= 100 && n >= 1)
  {
    if(a >= 0 && a <= n*n)
    {
      black = n*n-a;
    }
  }
  
  cout << black << endl;

  return 0;
}

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

int64_t nibun(vector<int>&l,int j,int num){
  int hidari=j;
  int migi=l.size();
  int64_t tmp=hidari;
  while(migi-hidari>1){
    int mid=(hidari+migi)/2;
    if(l.at(mid)>=num){
      migi=mid;
    }
    else{
      hidari=mid;
    }
    tmp=hidari;
  }
  return tmp;
}

int main(){
  int n;cin>>n;
  vector<int>l(n);
  int64_t ans=0;
  int64_t tmp;
  for(int i=0;i<n;i++){
    cin>>l.at(i);
  }
  sort(l.begin(),l.end());
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      tmp=nibun(l,j,l.at(i)+l.at(j));
      ans+=tmp-j;
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

    vector<int> res(n, 0);
    for (int i = 0; i < n; i++) {
        vector<int> d(n, n);
        d[i] = 0;

        queue<int> que;
        que.push(i);
        while (!que.empty()) {
            int q = que.front();
            que.pop();

            if (q - 1 >= 0 && d[q - 1] > d[q] + 1) {
                d[q - 1] = d[q] + 1;
                que.push(q - 1);
            }
            if (q + 1 <= n - 1 && d[q + 1] > d[q] + 1) {
                d[q + 1] = d[q] + 1;
                que.push(q + 1);
            }
            if (q == x - 1 && d[y - 1] > d[q] + 1) {
                d[y - 1] = d[q] + 1;
                que.push(y - 1);
            }
            if (q == y - 1 && d[x - 1] > d[q] + 1) {
                d[x - 1] = d[q] + 1;
                que.push(x - 1);
            }
        }

        for (int j = 0; j < n; j++) {
            res[d[j]]++;
        }
    }

    for (int i = 1; i < n; i++) {
        cout << res[i] / 2 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define All(a) a.begin(), a.end()
typedef pair<long long, long long> P;
int main(){
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K <= A){
        cout << K << endl;
    }
    else if(A < K &&  K <=A + B){
        cout << A << endl;
    }
    else{
        cout << A - (K - A - B) << endl;
    }
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>

#define rep(i, n) for (int i = 0; i < n; i++) 
#define rrep(i, n) for(int i = n-1; i>=0; i--)
#define range(i, n, m) for (int i = n; i < m; i++) 
#define rrange(i, n, m) for (int i = n - 1; i => m; i--) 

typedef long long int ll;
typedef unsigned long long int ull;


using namespace std;

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

vector<ll> ans;


void add3(ll num, ll N, bool flg3, bool flg5, bool flg7);
void add5(ll num, ll N, bool flg3, bool flg5, bool flg7);
void add7(ll num, ll N, bool flg3, bool flg5, bool flg7);

void add3(ll num, ll N, bool flg3, bool flg5, bool flg7) {
	num = num * 10 + 3;
	if (num > N) return;

	if (flg3 && flg5 && flg7) {
		ans.push_back(num);
	}

	add3(num, N, true, flg5, flg7);
	add5(num, N, flg3, true, flg7);
	add7(num, N, flg3, flg5, true);
}

void add5(ll num, ll N, bool flg3, bool flg5, bool flg7) {
	num = num * 10 + 5;
	if (num > N) return;

	if (flg3 && flg5 && flg7) {
		ans.push_back(num);
	}

	add3(num, N, true, flg5, flg7);
	add5(num, N, flg3, true, flg7);
	add7(num, N, flg3, flg5, true);
}

void add7(ll num, ll N, bool flg3, bool flg5, bool flg7) {
	num = num * 10 + 7;
	if (num > N) return;

	if (flg3 && flg5 && flg7) {
		ans.push_back(num);
	}

	add3(num, N, true, flg5, flg7);
	add5(num, N, flg3, true, flg7);
	add7(num, N, flg3, flg5, true);
}

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

	ll N;
	cin >> N;

	add3(0, N, true, false, false);
	add5(0, N, false, true, false);
	add7(0, N, false, false, true);

	cout << dec << ans.size();


	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	cout << 0 << endl;
	string s;
	cin >> s;
	if (s == "Vacant") return 0;
	vector<string> v(n);
	v[0] = s;
	int l = 0;
	int r = n;
	int p = (l+r)/2;
	cout << p << endl;
	while (cin >> s, s != "Vacant") {
		v[p] = s;
		int x = p - l - 1;
		int y = r - p - 1;
		if ((v[l] == s && x % 2 == 0) || (v[l] != s && x % 2 == 1)) {
			r = p;
			p = (l+r)/2;
		} else {
			l = p;
			p = (l+r)/2;
		}
		cout << p << endl;
	}
}

Measured memory_bytes: 6428