akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int K, X;
	cin >> K >> X;

	if (X <= 500 * K) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

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

ll dp[100010][13];
 
int main() {
    string s;
    cin >> s;
    ll m = s.size();

    dp[0][0] = 1;
    rep(i, m) {
        rep(j, 13) {
            if(s[i] == '?') {
                rep(k, 10) {
                    dp[i+1][(10*j + k)%13] += dp[i][j];
                    dp[i+1][(10*j + k)%13] %= mod;
                }
            }
            else {
                ll k = s[i] - '0';
                dp[i+1][(10*j + k)%13] += dp[i][j];
                dp[i+1][(10*j + k)%13] %= mod;
            }
        }
    }
    
    out(dp[m][5]);
    re0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

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

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    bool zero = false;
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] == 0) zero = true;
    }
    if(zero) {
        cout << 0 << endl;
        return;
    }
    ll lim = 1;
    for(ll i = 1; i <= 18; i++) lim *= 10;
    ll ans = 1;
    bool invalid = false;
    for(ll i = 0; i < n; i++) {
        if(a[i] <= lim / ans) ans *= a[i];
        else {
            invalid = true;
            break;
        }
    }
    if(!invalid) cout << ans << endl;
    else cout << -1 << endl;
    return;
}

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

Measured memory_bytes: 3980
N=int(input())
A=[]
for i in range(N):
    a=int(input())
    a-=1
    A.append(a)
ans=0
reached=[0]*N
i=0
while(True):
    i=A[i]
    ans+=1
    if i==1:
        print(ans)
        quit()
    if reached[i]:
        print(-1)
        quit()
    reached[i]=1


Measured memory_bytes: 7852
const main = function(input){
  var N = parseInt(input.trim());
  var near = N - N%7;
  var ans = false;
  
  for(var i= 0;i<near/7+1;i++){
	var rest = N - 7 * i;
    if(rest % 4 ===0){
      ans = true;
      break;
    }
  }
  if(ans) console.log("Yes");
  else console.log("No");
}


main(require("fs").readFileSync("/dev/stdin","utf-8"));

Measured memory_bytes: 11468
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll inf  = 1e18;
const int MAX = 510000;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}
// const ll MOD=1000000007ll;


ll fact[MAX], fact_inv[MAX];

//繰り返し二乗法
ll power(ll a, ll b){
    ll res = 1;
    while(b > 0){
        if(b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

ll comb(ll n, ll r){
    return (fact[n] * fact_inv[r]) % MOD * fact_inv[n-r] % MOD;
}

int main(){
    ll n, m, k, ans = 0;
    cin >> n >> m >> k;
    int N = 200001;
    fact[0] = 1;
    //階乗計算(O(n))
    REP(i, N) fact[i+1] = fact[i] * (i+1) % MOD;
    fact_inv[N] = power(fact[N], MOD - 2);
    //逆元計算(O(logp + n))
    FORR(i, 0, N) fact_inv[i] = fact_inv[i+1] * (i+1) % MOD;
    //あとはconb(n,r)に値を突っ込めば良い

    for(ll d = 1; d < n; d++){
        ans += d * comb(n*m-2, k-2) % MOD * (( n - d ) * m * m) % MOD;
        ans %= MOD;
    }
    for(ll d = 1; d < m; d++){
        ans += d * ( comb(n*m-2,k-2) % MOD) * ((( m - d ) * n * n ) % MOD);
        ans %= MOD;
    }
    p(ans);
    
}

Measured memory_bytes: 5888
#include <iostream>

using namespace std;

int num;

int main(){

    cin >> num;

    for (int i = 1; i < 10; i++ ){
        if (num == i * 111){
            cout << i * 111;
            break;
        }
        if (num  < i * 111){
            cout << i *  111;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque

s = deque(input())
q = int(input())
 
r = 0
for i in range(q):
  tfc = input().split()
  if tfc[0] == '1':
    r += 1
  else:
    if tfc[1] == '1':
      if r % 2 == 0:
        s.appendleft(tfc[2])
        #s.insert(0, tfc[2])
      else:
        s.append(tfc[2])
    if tfc[1] == '2':
     if r % 2 == 1:
        s.appendleft(tfc[2])
     else:
        s.append(tfc[2])          
if r % 2 == 0:
  for i in s:
      print(i, end='')
else:
  for i in (reversed(s)):
    print(i, end='') 

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

#define ll long long

using namespace std;

int w,h;

int f[100][100]={};

int solve(int i,int j,int num){
    if(i<0 || j < 0 || i >= h || j >= w )
        return 0;
    if(f[i][j]!=1)
        return 0;
    
    f[i][j]=num;
    solve(i-1,j-1,num);
    solve(i-1,j,num);
    solve(i-1,j+1,num);
    solve(i,j-1,num);
    solve(i,j+1,num);
    solve(i+1,j-1,num);
    solve(i+1,j,num);
    solve(i+1,j+1,num);
    return 0;
}


int main(){

    while(1){
        scanf("%d %d",&w,&h);
        if(w == 0 && h==0)break;

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                scanf("%d",&f[i][j]);
            }
        }
        int ans = 1;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(f[i][j]==1){
                    ans++;
                    solve(i,j,ans);
                }
            }
        }
        cout << ans-1 << endl;
    }

}


Measured memory_bytes: 3212
#include <stdio.h>

int main(void){

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  for (long i = 0; i < n; i++) {
    if (a[i] == 0) {
      printf("0\n");
      return 0;
    }
  }
  long ans = a[0];
  long limit;
  for (long i = 1; i < n; i++) {
    limit = 1000000000000000000/ans;
    if (a[i] > limit) {
      printf("-1\n");
      return 0;
    }
    ans *= a[i];
  }
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 2488
#include <iostream>
#include <bitset>
#include <array>
#include <vector>
#include <limits>

using namespace std;

int main(void) {
    int N, C;
    cin >> N >> C;
    vector<bitset<30>> table(100000);
    for(int i = 0; i < N; i++){
        int s, t, c;
        cin >> s >> t >> c;
        for(; s <= t; s++){
            table[s][c] = true;
        }
    }
    int ans = 0;
    for(auto const& b : table) ans = max(ans, (int)b.count());

    cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string ans="YES";
  int c=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='o'){c++;}
  }
  if(15-s.size()+c<8){ans="NO";}
  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;

int bd[10][10];


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

    string s;
    cin >> s;
    while(s != "#"){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;b--;c--;d--;

        memset(bd, -1, sizeof(bd));
        int y = 0, x = 0;
        for(auto &c : s){
            if(c == '/'){
                x = 0;
                y++;
            }else if(c == 'b'){
                bd[y][x] = 1;
                x++;
            }else{
                REP(i, c-'0'){
                    bd[y][x] = 0;
                    x++;
                }
            }
        }
        assert(bd[a][b] == 1);
        bd[a][b] = 0;
        bd[c][d] = 1;
        string ans = "";
        REP(i, y+1){
            int tmp = 0;
            REP(j, x){
                if(bd[i][j] == 1){
                    if(tmp != 0) ans += to_string(tmp);
                    ans += "b";
                    tmp = 0;
                }
                else tmp++;
            }
            if(tmp != 0) ans += to_string(tmp);
            if(i != y) ans += "/";
        }
        cout << ans << endl;

        cin >> s;
    }
    return 0;
}


Measured memory_bytes: 3224
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int x, n, p;
set<int> st;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> x >> n;
    for (int i = 0; i < n; i++) {
        cin >> p;
        st.insert(p);
    }
    int ans = 0;
    for (int i = 1; i <= 101; i++) {
        if (st.count(i)) continue;
        if (abs(i - x) < abs(ans - x)) {
            ans = i;
        }
    }
    cout << ans << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3656
import sys

def main():
    n = int(sys.stdin.readline())
    r = [int(sys.stdin.readline()) for x in range(n)]
    m = r[0]
    result = -(10**9)
    for i in range(1, n):
        m = min(m, r[i -1])
        d = r[i] - m
        if d > result:
            result = d
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13600
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0; i<n; ++i)
        cin >> h[i];
    sort(h.begin(), h.end());

    int ans = INT_MAX;
    for(int i=0; i<=n-k; ++i)
        ans = min(ans, h[i+k-1] - h[i]);
    cout << ans << endl;

    return 0;
}


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

int main() {
    int A, B, C, D, E, F;
    scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);
    int ans_w, ans_s, w;
    double x = -1;
    for (int i = 0; i <= 30; i++) {
        for (int j = 0; j <= 30 - i; j++) {
            for (int k = 0; k <= 100; k++) {
                for (int l = 0; l <= 100 - k; l++) {
                     w = 100 * (A * i + B * j) + C * k + D * l;
                    if (w > F) continue;
                    if ( (C * k + D * l) > (A * i + B * j) * E) continue;
                    if (x < (double)100 * (C * k + D * l) / w) {
                        ans_w = w;
                        ans_s = (C * k + D * l);
                        x = (double)100 * (C * k + D * l) / w;
                    }
                }
            }
        }
    }
    printf("%d %d\n", ans_w, ans_s);
    return 0;
}

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

using namespace std;

int N;
int t[20][20];
int path[20];
int dp[(1<<16)];

int dfs(int bit){
  if(dp[bit] >= 0) return dp[bit];
  if(bit == (1<<N) - 1) return (dp[bit] = 0);

  int m = 1234567890;
  for(int i=0;i<N;++i){
	if((bit >> i) & 1) continue;
	int c = path[i];
	int temp[20];
	for(int j=0;j<N;++j){
	  temp[j] = path[j];
	  path[j] = min(path[j], t[j][i+1]);
	}
 
	m = min(dfs(bit | (1 << i)) + c, m);
	for(int j=0;j<20;++j)
	  path[j] = temp[j];
  }

  return (dp[bit] = m);
}

int main(){
  while(true){
	cin >> N; if(!N) break;
	for(int i=0;i<N;++i)
	  for(int j=0;j<=N;++j)
		cin >> t[i][j];

	fill(dp, dp+(1<<16), -1);
	for(int i=0;i<N;++i)
	  path[i] = t[i][0];
	cout << dfs(0) << endl;
  }

  return 0;
}

Measured memory_bytes: 1416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll md = 100000007;
#define fr first
#define sc second
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
vl p, fac(2, 1), ifac(2, 1);

ll ad(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod) % mod;
}

ll ml(ll a, ll b, ll mod = md) {
    return ( (a%mod) * (b%mod) ) % mod;
}

ll pw(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = (n >> 1);
        x = (x*x)%mod;
    }
    return res;
}

int mu(ll n) {
	int c = 1, pn = p.size();
	for(int i = 0; i < pn && p[i] * p[i] <= n; i++) {
		if(n%p[i] == 0) c = -c, n /= p[i];
		if(n%p[i] == 0) return 0;
	}
	if(n > 1) return -c;
	return c;
}

void sieveMU(ll n, vl &mu) {
    vl factor(n+1, 0);
    for(int i = 2; i * i <= n; i++) {
        if(!factor[i]) {
            for(int j = i * i; j <= n; j += i) factor[j] = i;
        }
    }
    mu[1] = 1;
    for(int i = 2; i <= n; i++) {
        if(!factor[i]) {
            mu[i] = -1;
            continue;
        }
        if((i/factor[i])%factor[i] == 0) {
            mu[i] = 0;
        } else {
            mu[i] = (-1)*mu[i/factor[i]];
        }
    }
}

void cachefact(ll lim, ll mod = md) {
    for(int i = 2; i <= lim; i++) {
        ifac.push_back((ifac[mod%i] * (mod - mod/i) % mod)%mod);
    }
    for(ll i = 2; i <= lim; i++) {
        fac.push_back((fac[i-1] * i)%mod);
        ifac[i] = (ifac[i-1] * ifac[i])%mod;
    }
}

ll C(ll n, ll r) {
    if(n < r || r < 0) return 0;
    return ml(fac[n], ml(ifac[r], ifac[n-r]));
}

ll P(int n, int r) {
    if(n < r || r < 0) return 0;
    return ml(fac[n], ifac[n-r]);
}

void sieve(ll n) {
    vector<bool> prime(n+1, true);
    for(int i = 2; i*i <= n; i++) {
        if(prime[i]) {
            for(int j = i*i; j <= n; j += i) {
                prime[j] = false;
            }
        }
    }
    p.push_back(2);
    for(int i = 3; i <= n; i += 2) {
        if(prime[i]) p.push_back(i);
    }
}

ll PIE(ll n, ll k, ll f, ll mod = md) {
	if(f < 0 || k < 0 || n < 0) return 0;
	ll ans = 0, l = min(n, k/(f+1));
	for(int i = 0; i <= l; i++) {
		ans = ad(ans, (i&1 ? -1 : 1) * ml(C(n, i), C(n - 1 + k - (f+1) * i, k - (f+1) * i)));
	}
	return ans;
}

void mat_mul(vvl &M, vvl &S, int N) {
	vvl res(N, vl (N, 0));
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			for(int k = 0; k < N; k++) {
				res[i][j] += M[i][k]*S[k][j];
			}
		}
	}
	M = res;
}

void mat_exp(vvl &F, int N, ll n) {
	vvl res(N, vl (N,0));
	for(int i = 0; i < N; i++) res[i][i] = 1;
	while(n) {
		if(n & 1) mat_mul(res, F, N);
		mat_mul(F, F, N);
		n >>= 1;
	}
	F = res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, x, t;
    cin >> n >> x >> t;
    cout << t * ((n+x-1)/x) << "\n";
    return 0;
}

Measured memory_bytes: 3616
def main():
  list_s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
  
  k = int(input())
  
  print(list_s[k-1])
  
main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep2(i,st,ed) for(int i = st; i < ed; ++i)
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
const ll mod = 1e9 + 7;
const ll N = 2e5 + 200;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;


ll a[N];
vector<ll> v[N];
int main(){
	ll n,m;
	cin>>n>>m;
	rep(i,n){
		cin>>a[i+1];
	}
	while(m--){
		ll x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	ll sum = 0;
	rep2(i,1,n+1){
		ll len = v[i].size();
		int flag = 0;
		rep(j,len){
			if(a[v[i][j]] >= a[i]){
				flag = 1;
				break;
			}
		}
		if(!flag){
			sum++;
			// cout<<i<<endl;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 12600
from collections import deque
n, m = map(int, input().split())
a = [0]*m
for _ in range(n):
    A = deque(map(int, input().split()))
    k = A.popleft()
    if _ == 0:
        S = set(A)
    else:
        S = S & set(A)
print(len(S))



Measured memory_bytes: 3316
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<map>
#include<deque>
#include<stack>
#include<algorithm>
#define N 20
using namespace std;
const int INF=0x7fffffff;
const double Pi=acos(-1);
int K,D[N];
bool Check(int X)
{
	int i;
	while(X)
	{
		int T=X%10;
		for(i=1;i<=K;i++)if(T==D[i])return 0;
		X/=10;
	}
	return 1;
}
int main()
{
	int i,n;
	scanf("%d%d",&n,&K);
	for(i=1;i<=K;i++)scanf("%d",&D[i]);
	for(i=n;;i++)
	{
		if(Check(i))
		{
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n,m,X,Y=map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))

for z in range(X+1, Y+1):
    if all(map(lambda _x: _x < z, x)) and all(map(lambda _y: _y >= z, y)):
        print("No War")
        quit()

print("War")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); ++i)
 
int H, W, size;
char map[101][101];
void dfs(int i, int j) {
    char c = map[i][j];
    map[i][j] = '.';
    if(j+1<W && map[i][j+1]==c) dfs(i, j+1);
    if(j>0 && map[i][j-1]==c) dfs(i, j-1);
    if(i+1<H && map[i+1][j]==c) dfs(i+1, j);
    if(i>0 && map[i-1][j]==c) dfs(i-1, j);
}
int main() {
    while(cin >> H >> W && H!=0 && W!=0) {
        rep(i, H) {
            rep(j, W) {
                cin >> map[i][j];
            }
        }
        size = 0;
        rep(i, H) {
            rep(j, W) {
                if(map[i][j]!='.') {
                    ++size;
                    dfs(i, j);
                }
            }
        }
        cout << size << endl;
        }
    return 0;
}

Measured memory_bytes: 2104
import sys

def read():
	return tuple([int(d) for d in sys.stdin.readline().rstrip().split(" ")])

N, = read()

cur_T = 1
cur_A = 1

for i in range(N):
	T, A = read()

	current = cur_T + cur_A
	sum = T + A

	mult1 = (current + sum - 1) // sum
	mult2 = (cur_T + T - 1) // T
	mult3 = (cur_A + A - 1) // A

	mult = mult1
	if mult2 > mult: mult = mult2
	if mult3 > mult: mult = mult3

	cur_T = T * mult
	cur_A = A * mult

print(cur_T + cur_A)


Measured memory_bytes: 3064
s = input()
ls = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
c = 0
for i in ls:
  if i in s:
    c += 1
  else:
    print(i)
    break
    
if c >= 26:
  print("None")

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n; cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b; cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 3564
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

int N, M, a[300004], i;
long long int r;

template<typename ...> static inline int gc(void) { return getchar(); }
static inline void read(int &x){int k=gc();x=0;for(;;k=gc()){if(isdigit(k)){x=k-48;break;}}for(;;){k=gc();if(!isdigit(k))break;x=x*10+k-48;}}

int main(){
    read(N);
    M = N;
    M += (N << 1);
    for(; i ^ M; i += 3){
        read(a[i]);
        read(a[i + 1]);
        read(a[i + 2]);
    }
    sort(a, a + M, greater<int>());
    N <<= 1;
    ++N;
    for(i = 1; i ^ N; i += 2){
        r += a[i];
    }
    printf("%lld", r);
    return 0;
}


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

int nr[100010];
int n;

int cmmdc(int a, int b)
{
    while (a) {
        b %= a;
        a ^= b ^= a ^= b;
    }
    return b;
}

bool castiga()
{
    int x(0), y(0), py;
    bool unu(0);
    for (int i(0); i < n; i++) {
        if (nr[i] & 1)
            y++, py = i;
        else
            x++;
        if (nr[i] == 1)
            unu = 1;
    }

    if (unu) { /// gcd won't ever be != 1, so parity counts
        int stotal(0);
        for (int i(0); i < n; i++)
            stotal ^= nr[i] - 1;
        return (stotal & 1);
    }

    if (x == 0) /// have to make even, oponent makes it odd again
        return false;
    if (x % 2 == 1) /// makes it odd, upper case
        return true;
    if (x % 2 == 0 && y > 1) /// if i change one of the evens, the oponent changes another
        return false;
    /// i am here so y == 1

    nr[py]--;

    x = 0;
    for (int i(0); i < n; i++)
        x = cmmdc(x, nr[i]);
    for (int i(0); i < n; i++)
        nr[i] /= x;
    return !castiga();
}

int main()
{
    cin >> n;
    for (int i(0); i < n; i++)
        cin >> nr[i];

    cout << (castiga() ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 768
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

"""
・最適解をとって2つ入れ替えの議論
・s+wが小さい方が上にあるように詰めることが分かる
・wの和 -> vの和でdp
・自身の下に積むならば、wの和<=s_maxでなければいけない
"""

N = int(readline())
m = map(int,read().split())
WSV = sorted(zip(m,m,m),key=lambda x:x[0]+x[1])

dp = np.zeros(10**4*2+100,np.int64)

for w,s,v in WSV:
    prev = dp
    dp = np.zeros_like(prev)
    # 置く場合
    dp[w:w+s+1] = prev[:s+1]+v
    np.maximum(dp,prev,out=dp)

answer = dp.max()
print(answer)

Measured memory_bytes: 14668
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    map<char, int> mp;
    rep(i, n) mp[s[i]]++;
    ll ans = 1;
    int t=0;
    for(auto p : mp){
        ans*=p.second;
        t++;
    }
    if(t!=3) {
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++){
        rep(j, n){
            int a, b, c;
            a=j;
            b=j+i;
            c=j+2*i;
            if(c>=n) continue;
            if(s[a]!=s[b] && s[b]!=s[c] && s[a]!=s[c]) ans--;
        } 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3644
n = int(input())
li = list(map(int,input().split()))
w1=[]
a=0
b=0
for i in range(1, n):
    a=0
    b=0
    for j in range(0,i):
        a += li[j]
        b = sum(li) -a
    w1.append(abs(a-b))

print(min(w1))

Measured memory_bytes: 3064
unittest
{
	assert( [ "BACD" ].parse.expand.solve == "Yes" );
	assert( [ "ABCD" ].parse.expand.solve == "No" );
	assert( [ "CABD" ].parse.expand.solve == "No" );
	assert( [ "ACACA" ].parse.expand.solve == "Yes" );
	assert( [ "XX" ].parse.expand.solve == "No" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	for( auto i = 0L; i + 1 < s.length; i++ )
	{
		if( s[ i .. i + 2 ] == "AC" ) return "Yes";
	}
	return "No";
}


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

int	main() {
	int N;
	cin >>N;
	vector<vector<long>> A(N, vector<long> (3, 0));
	for (int i=0; i<N; i++) {
		cin >> A.at(i).at(1);
		cin >> A.at(i).at(2);
		A.at(i).at(0)=A.at(i).at(1)+A.at(i).at(2);
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	long S=0;
	for (int i=0; i<N; i++) {
		if (0==i%2)
			S +=A.at(i).at(1);
		else
			S -=A.at(i).at(2);
	}
	cout <<S <<endl;
	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    cin >> a;
    auto calcDist = [&](ll now, ll next) {
        if (now <= next) return next - now;
        else return (m - now) + next;
    };
    auto moveIdx = [&](ll now, ll add) {
        ll temp = now + add;
        if (temp > m) temp = (temp % m);
        return temp;
    };
    ll base = 0;
    for (int i = 0; i + 1 < n; i++) base += calcDist(a[i], a[i + 1]);
    ll count = 0, sumMinus = 0;
    vector<ll> plus(m + 1), minus(m + 1), resetPlus(m + 1);
    for (int i = 0; i + 1 < n; i++) {
        if (calcDist(a[i], a[i + 1]) == 1) continue;
        if (a[i] > a[i + 1] && a[i] + 2 <= m) {
            sumMinus += calcDist(a[i], m) - 1;
            count++;
        } else if (a[i + 1] == m) {
            sumMinus += calcDist(a[i], a[i + 1]) - 1;
            count++;
        }
        plus[moveIdx(a[i], 2)]++;
        minus[moveIdx(a[i + 1], 1)]++;
        resetPlus[moveIdx(a[i + 1], 1)] += calcDist(a[i], a[i + 1]) - 1;
    }
    ll ans = INFLL;
    for (int i = 1; i <= m; i++) {
        count -= minus[i];
        sumMinus -= resetPlus[i];
        count += plus[i];
        sumMinus += count;
        ans = min(ans, base - sumMinus);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int n = read();
	for (int i = 1; i < 10; i++) {
		if (111 * i >= n) {
			cout << i * 111 << endl;
			break;
		}
	}
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y) {
    rep(i, 101) {
        rep(j, 101) {
            if ((i + j) == X) {
                if ((i * 2 + j * 4) == Y) {
                    cout << YES << endl;
                    return;
                }
            }
        }
    }
    cout << NO << endl;
}

int main() {
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 3768
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] T = new long[N];
		for( int i=0; i<N; i++ ){
			T[i] = sc.nextLong();
		}
		Arrays.sort(T);
		long ans = T[N-1];
		for( int i=0; i<N; i++ ){
			for( int j=1; j<=T[i]; j++ ){
				if( (ans*j)%T[i]==0 ){
					ans = ans*j;
					break;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	ll n;
	cin >> n;
	ll ans = n - 1;
	for (ll i = 2; i * i <= n; i++) if (n % i == 0) {
		ckmin(ans, i + n / i - 2);
	}
	cout << ans << '\n';

}



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

int t, a;
bool chk[14], ans[14][14][2], vis[14][14][2];

bool solve(bool type, int l, int r)
{
    if (vis[l][r][type])
        return ans[l][r][type];
    ans[l][r][type] = false;
    vis[l][r][type] = true;
    int cnt = 0;
    for (int i = 1; i <= 13; i++)
        if (i != 7 && (chk[i] ^ type) && l <= i && i <= r)
            cnt++;
    if (cnt == 6)
        return ans[l][r][type] = true;
    bool ope = false;
    if (l != 1 && (chk[l - 1] ^ type))
    {
        if (cnt == 5)
            return ans[l][r][type] = true;
        ans[l][r][type] |= (!solve(type ^ 1, l - 1, r));
        ope = true;
    }
    if (r != 13 && (chk[r + 1] ^ type))
    {
        if (cnt == 5)
            return ans[l][r][type] = true;
        ans[l][r][type] |= (!solve(type ^ 1, l, r + 1));
        ope = true;
    }
    if (!ope)
        ans[l][r][type] |= (!solve(type ^ 1, l, r));
    return ans[l][r][type];
}

int main()
{
    scanf("%d", &t);
    while (t--)
    {
        for (int i = 0; i < 14; i++)
        {
            chk[i] = false;
            for (int j = 0; j < 14; j++)
                vis[i][j][0] = vis[i][j][1] = false;
        }
        for (int i = 0; i < 6; i++)
        {
            scanf("%d", &a);
            chk[a] = true;
        }
        printf("%s\n", (solve(false, 7, 7) ? "yes" : "no"));
    }
}



Measured memory_bytes: 3144
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    map<ll,int> M;
    for(ull a : A) M[a]++;
    ull count = 0;
    for(auto p : M){
        if(p.se >= p.fi) count += p.se - p.fi;
        else count += p.se;
    }
    cout << count << endl;
}

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

const long long MAX = 10000001;

// array to store prime factors
long long factor[MAX] = { 0 };

void generatePrimeFactors()
{
    factor[1] = 1;

    // Initializes all the positions with their value.
    for (long long i = 2; i < MAX; i++)
        factor[i] = i;

    // Initializes all multiples of 2 with 2
    for (long long i = 4; i < MAX; i += 2)
        factor[i] = 2;

    // A modified version of Sieve of Eratosthenes to
    // store the smallest prime factor that divides
    // every number.
    for (long long i = 3; i * i < MAX; i++) {
        // check if it has no prime factor.
        if (factor[i] == i) {
            // Initializes of j starting from i*i
            for (long long j = i * i; j < MAX; j += i) {
                // if it has no prime factor before, then
                // stores the smallest prime divisor
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}

// function to calculate number of factors
long long calculateNoOFactors(long long n)
{
    if (n == 1)
        return 1;

    long long ans = 1;

    // stores the smallest prime number
    // that divides n
    long long dup = factor[n];

    // stores the count of number of times
    // a prime number divides n.
    long long c = 1;

    // reduces to the next number after prime
    // factorization of n
    long long j = n / factor[n];

    // false when prime factorization is done
    while (j != 1) {
        // if the same prime number is dividing n,
        // then we increase the count
        if (factor[j] == dup)
            c += 1;

        /* if its a new prime factor that is factorizing n,
           then we again set c=1 and change dup to the new
           prime factor, and apply the formula explained
           above. */
        else {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }

        // prime factorizes a number
        j = j / factor[j];
    }

    // for the last prime factor
    ans = ans * (c + 1);

    return ans;
}

int main() {
  long long n; cin >> n;
  long long ans = 0;

  generatePrimeFactors();

  for(long long i = 1; i <= n; i++) {
    ans += i * calculateNoOFactors(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 81624
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        this.PointList = new Point[inpt[0]];
        this.MustContain = inpt[1];

        for (int i = 0; i < PointList.Length; i++) {
            long[] pos = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
            this.PointList[i] = new Point(i, pos[0], pos[1]);
        }

        long flags = this.PointList.Sum(a => a.GetKey());
        long ans = GetAns(flags, this.PointList.ToList());
        Console.WriteLine(ans);

    }

    private Dictionary<long, long> dic = new Dictionary<long, long>();

    private long GetAns(long flags, List<Point> target) {
        if(dic.ContainsKey(flags)) {
            return dic[flags];
        }

        if(target.Count<this.MustContain) {
            return -1;
        }

        long ans = (target.Max(a=>a.X)-target.Min(a=>a.X)) * (target.Max(a=>a.Y)-target.Min(a=>a.Y));

        List<Point> subTarget = new List<Point>();
        subTarget.Add(target.OrderBy(a => a.X).First());
        subTarget.Add(target.OrderByDescending(a => a.X).First());
        subTarget.Add(target.OrderBy(a => a.Y).First());
        subTarget.Add(target.OrderByDescending(a => a.Y).First());

        subTarget.ForEach(a=>{
            List<Point> newTarget = target.Where(b => b.ID != a.ID).ToList();
            long subFlag = flags - a.GetKey();
            long ret = GetAns(subFlag, newTarget);
            if(ret>=0) {
                ans = Math.Min(ans, ret);
            }
        });
        dic[flags] = ans;
        return ans;
    }

    private int MustContain;
    private Point[] PointList;

    private class Point {
        public int ID;
        public long X;
        public long Y;
        public Point(int id, long x, long y) {
            this.X = x;
            this.Y = y;
            this.ID = id;
        }
        public long GetKey() {
            return 1L << this.ID;
        }
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


4 3
-1000000000 -1000000000
1000000000 1000000000
-999999999 999999999
999999999 -999999999

";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;
int x, y, tot;
vi fo;
bool dp[4000][16001], dp2[4000][16001];	// i番目まででj-8000を作れるか

int main() {
	cin >> s >> x >> y;
	
	int cnt = 0;
	vi xf, yf;
	int tur = 0;
	rep(i,s.length()) {
		if (s[i]=='F') {
			cnt++;
		}
		else {
			if (!tur) xf.pb(cnt);
			else yf.pb(cnt);
			cnt = 0;
			tur = 1 - tur;
		}
	}
	if (!tur) xf.pb(cnt);
	else yf.pb(cnt);
	// iが偶数なら左右、奇数なら上下 一度も動かない場合は考慮しなくていい
	// 偶数の一番最初の1要素だけは右向き指定だった
	
	// evの要素を足し引きしてxに、odを足し引きしてyにできればいい
	// 最高で2000通りずつある どうする？ dp 間に合うか怪しい
	int N = xf.size(), M = yf.size();
	dp[1][8000+xf[0]] = true;
	for (int i = 1; i < N; ++i) {
		rep(j,16001) {
			if (dp[i][j]) {
				//cout << j-8000 << "がOKなので" << j-8000+xf[i] << "もいける" << ln;
				dp[i+1][j+xf[i]] = true;
				dp[i+1][j-xf[i]] = true;
			}
		}
	}
	
	dp2[0][8000] = true;
	for (int i = 0; i < M; ++i) {
		rep(j,16001) {
			if (dp2[i][j]) {
				//cout << j-8000 << "がOKなので" << j-8000+yf[i] << "もいける" << ln;
				dp2[i+1][j+yf[i]] = true;
				dp2[i+1][j-yf[i]] = true;
			}
		}
	}
	if (dp[N][x+8000] && dp2[M][y+8000]) cout << "Yes" << ln;
	else cout << "No" << ln;
	
	/*
	rep(i,N) cout << xf[i] << " ";
	cout << ln;
	rep(i,M) cout << yf[i] << " ";
	cout << ln;
	 */
}

Measured memory_bytes: 123776
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const int MOD=1e9+7;

int main(){

  int n, k, a, d;

  bool flag[101];
  cin >> n >> k;
  rep(i, n) flag[i] = false;

  rep(i, k){
    cin >> d;
    rep(j, d){
      cin >> a;
      flag[a - 1] = true;
    }
  }
  int ans = 0;
  rep(i, n) if(!flag[i]) ans++;
  cout << ans << endl;

  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if !ONLINE_JUDGE
#define debug
#endif

using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;
 
typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

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

#ifdef debug
#define dbg(...) { cerr<<"[ "; dump(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.ff<<","<<x.ss<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const unordered_map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
} 
 
template <typename Arg1>
void dump(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void dump(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    dump(names.substr(1+(int)name.size()), args...);
}
#else
    #define dbg(args...)
#endif
 
ll powmod(ll x, ll y) 
{ 
    ll res = 1;  
    x = x % MOD;
    while (y > 0) 
    { 
        if (y & 1) 
  	      res = (res*x) % MOD; 
        y = y>>1; // y = y/2 
        x = (x*x) % MOD;   
    } 
    return res; 
} 

int main()
{
	#if !ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	
 	int a,b,c;cin>>a>>b>>c;
 	cout<<min(c,a+b+1)+b;
}

Measured memory_bytes: 256