akhauriyash/Code-Regression huggingface dataset:
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (ll)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll n,k,r,S,p,ans;
string s; 
map<char,int> score;
map<char,int> id;
int help(vector<int>& slices) {
	 int ans=0;
	 int preWin=0;
	 rep(i,0,sz(slices)){
	 	if(!preWin){
	 		preWin = 1;
	 		ans+=score[s[slices[i]]];
		 }else{
		 	if(s[slices[i]]!=s[slices[i-1]]){
		 		ans+=score[s[slices[i]]];
			 }else{
			 	preWin = 0;
			 }
		 }
	 }
	 return ans;
} 
void solve(){
	ll n;
	cin>>n;
	ll need = 1;
	rep(i,0,n){
		ll t;
		cin>>t;
		if(t==need)need++;
	}
	if(need==1){
		cout<<-1<<endl;
	}else{
		cout<<n-(need-1);
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();
    
    string in; cin >> in;
    deque<char> s;
    each(c, in)s.push_back(c);
    int q; cin >> q;
    int rev = 0;
    while (q--) {
        int t; cin >> t;
        if (t == 1)rev ^= 1;
        else {
            int f; char c; cin >> f >> c;
            --f;
            if (rev == 0 && f == 0)s.push_front(c);
            else if (rev == 0 && f == 1)s.push_back(c);
            else if (rev == 1 && f == 0)s.push_back(c);
            else if (rev == 1 && f == 1)s.push_front(c);
        }
    }

    if (rev == 1)reverse(all(s));
    each(c, s)cout << c;
    cout << "\n";
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
using P = pair <int, int>;
 
 
int main() {
    ll n,x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans =0;
    for(int i = 1;i<n;++i){
        if(a[i]+a[i-1]<=x){
            continue;
        }
        else if(a[i]+a[i-1]>x&&a[i-1]>x){
            ans += a[i];
            a[i]=0;
            ans+=a[i-1]-x;
        }
        else if (a[i]+a[i-1]>x&&a[i-1]<=x){
            ans+=a[i]+a[i-1]-x;
            a[i]=x-a[i-1];    
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main()
{
 

  int a;
  cin>>a;
  cout<<a+ a*a + a*a*a;

}


Measured memory_bytes: 3644
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}


int main(){
    ll a=1,mod=1000000007;
    rep(i,in()){
        a=(a*(i+1))%mod;
    }
    cout<<a<<endl;
}


Measured memory_bytes: 384
n = int(input())
h = list(map(int, input().split()))

count = 0
max_count = 0
for i in range(n-1):
  if h[i]>=h[i+1]:
    count += 1
  else: count = 0
  
  if count > max_count: max_count = count
print(max_count)

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define sf scanf
#define pb push_back
#define pf printf
typedef long long ll;
typedef double db;
const int maxn = 200050;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db eps = 1e-9;

char str[maxn];
int n, overall = 1<<30, bb, s[26], f[maxn];
bool used[26], vis[maxn];
set<int> tr[26];
set<int>:: iterator it;
char Current[maxn], Ans[maxn];

int dp(int x)
{
	if(f[x]) return f[x];
	f[x] = inf;
	fo(j,0,25) 
	{
		it = tr[j].upper_bound(x);
		if(it == tr[j].end()) return f[x]=2;
	}
	fo(j,0,25)
	{
		it = tr[j].upper_bound(x);
		f[x] = min(f[x], dp((*it))+1);	
	}
	return f[x];
}

int main()
{
	scanf("%s",str+1); n = strlen(str+1);
	fo(i,1,n) used[str[i]-'a'] = true, tr[str[i]-'a'].insert(i);
	fo(i,1,n) if(!s[str[i]-'a']) s[str[i]-'a'] = i;
	fo(i,0,25) if(!used[i]) return 0*printf("%c",(char)('a'+i));
	fo(i,0,25) dp(s[i]);
	fo(i,0,25)
	{
		int now = s[i], mx, cur = 0;
		while(1)
		{
			mx = 0; ++ cur;
			vis[now] = true;
			Current[cur] = str[now];
			bool shit = false;
			fo(j,0,25)
			{
				it = tr[j].upper_bound(now);
				if(it != tr[j].end()) mx = max(mx,(*it));
				else {shit = true; bb = j; ++ cur; Current[cur] = (char)(j+'a'); break;}
			}
			if(shit) break;
			fo(j,0,mx-1)
			{
				it = tr[j].upper_bound(now);
				if(f[(*it)] == f[mx]) {mx = (*it); break;}
			}
			now = mx;
		}
		if(cur < overall)
		{
			overall = cur;
			fo(j,1,cur) Ans[j] = Current[j];
		}
		else if(overall == cur)
		{
			fo(j,1,cur) 
				if(Ans[j] == Current[j]) continue;
				else if(Ans[j] < Current[j]) goto loop1;
				else goto loop2;
			loop1:
			continue;
			;
			loop2:
			fo(j,1,cur) Ans[j] = Current[j];
			;
		}
	}
	fo(j,1,overall) printf("%c",Ans[j]);
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define range 200010
#pragma GCC optimize ("Ofast")
#define endl '\n'

int B[100];
signed main(){

//	freopen("test.txt","r",stdin);
	ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int temp = 0;
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1]){
			temp++;
		}
	}
	//cout<<temp<<endl;
	if(k>=(temp+1)/2){
		cout<<n-1<<endl;
		return 0;
	}
	cout<<n+2*k-temp-1<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;
	
	ll n;
	cin >> n;
	vector<vector<ll>> d(n, vector<ll>(2, 0));
	ll sum = 0;
	rep(i, n)
	{
		cin >> d[i][0] >> d[i][1];
		if (d[i][0] == d[i][1])
		{
			sum++;
		}
		else
			sum = 0;
		if (sum == 3)
		{
			cout << "Yes" << endl;
			ret;
		}
	}
	cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 3660
main :: IO ()
main = do
  s <- getLine :: IO String
  print $ f (reverse s)

f :: String -> Int
f (x:xs) 
  | odd $ length xs = f xs 
  | otherwise = let half = length xs `div` 2 
                   in if take half xs == drop half xs 
                        then
                        half * 2 
                        else
                        f xs                              
  

Measured memory_bytes: 508
#include<stdio.h>

 int main(void){

   int a,b;

   scanf("%d %d",&a,&b);

   if(a<b){

  printf("a < b\n");

 }

 if(a>b){

  printf("a > b\n");

 }

 if(a==b){

  printf("a == b\n"); 

 }

 return 0;

}

Measured memory_bytes: 580
import sys

d = raw_input()

for i in range(len(d)):
    if d[i:i+5] == "apple":
        d = d[:i] + "peach" + d[i+5:]
    elif d[i:i+5] == "peach":
	d = d[:i] + "apple" + d[i+5:]
print d

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll pows(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>a>>b>>c;
sum=a+b+c;
if(sum<22)
{
  cout<<"win";
}
else
{
  cout<<"bust";
}
}


Measured memory_bytes: 256
N, K, *XY = map(int, open(0).read().split())

X, Y = zip(*sorted(zip(*[iter(XY)] * 2)))

cand = []
for k in range(K, N + 1):
    for i in range(N - k + 1):
        dx = X[i + k - 1] - X[i]
        YY = sorted(Y[i:i + k])
        cand += [dx * (YY[j + K - 1] - YY[j]) for j in range(k - K + 1)]

print(min(cand))

Measured memory_bytes: 3828
#include<stdio.h>
#include<iostream>

using namespace std;

struct{
  int x;
  int y;
} typedef Point;

int main(){

  while(1){
    int N,M,dis,cnt=0;
    char dir;
    cin >> N;
    if(N==0) break;
    Point point[N],rp;
  
    rp.x = 10;
    rp.y = 10;
  
    for(int i=0;i<N;i++){
      cin >> point[i].x >> point[i].y;
    }

    cin >> M;
    for(int i=0;i<M;i++){
      cin >> dir >> dis;
      for(int l=0;l<dis;l++){
	if(dir == 'N') rp.y++;
	else if(dir == 'S') rp.y--;
	else if(dir == 'E') rp.x++;
	else if(dir == 'W') rp.x--;

	for(int j=0;j<N;j++){
	  if(point[j].x==rp.x && point[j].y == rp.y){
	    cnt++;
	    point[j].x=10000;
	    point[j].y=10000;
	  }
	}
      }
    }
    printf("%s\n",(cnt==N) ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 1116
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> ii;
const int MAXN = 1e5 + 8;
 
 
priority_queue<ii, vector<ii>, greater<ii>> pq[MAXN];
int val[MAXN];
int fa[MAXN], _rank[MAXN];
inline void init(int n){
    for(int i = 0; i <= n; i++){
        fa[i] = i;
        _rank[i] = 0;
    }
}
inline int _find(int u){
    return fa[u] = fa[u] == u ? u : _find(fa[u]);
}
inline void _merge(int u, int v){
    int x = _find(u), y = _find(v);
    if(x == y) return;
    if(_rank[x] < _rank[y]){
        fa[x] = y;
    }
    else{
        fa[y] = x;
        if(_rank[x] == _rank[y]) _rank[x]++;
    }
}
 
vector<ii> vec;
int main()
{
    #ifdef LOCAL
    freopen("d.txt", "r", stdin);
    //freopen("d.out", "w", stdout);
    int T = 1;
    while(T--){
    #endif // LOCAL
    ios::sync_with_stdio(false); cin.tie(0);
 
    int n, m, i, u, v, findu, findv;
    LL ans = 0;
    cin >> n >> m;
    init(n);
    for(i = 0; i < n; i++){
        cin >> val[i];
    }
    for(i = 0; i < m; i++){
        cin >> u >> v;
        findu = _find(u), findv = _find(v);
        if(findu != findv){
            _merge(findu, findv);
        }
    }
    for(i = 0; i < n; i++){
        pq[_find(i)].push(ii(val[i], i));
    }
    for(i = 0; i < n; i++){
        if(!pq[i].empty()){
            vec.push_back(pq[i].top());
            val[pq[i].top().second] = 2e9;
            ans += pq[i].top().first;
        }
    }
    //cout << vec.size() << endl;
    if(vec.size() == 1){
        cout << 0 << endl;
    }
    else if(n < (vec.size()-1) * 2) cout << "Impossible" << endl;
    else{
        sort(val, val + n);
        n = (vec.size()-1) * 2 - vec.size();
 
        for(i = 0; i < n; i++){
            ans += val[i];
        }
        cout << ans << endl;
    }
    #ifdef LOCAL
    cout << endl;
    }
    #endif // LOCAL
    return 0;
}

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

int main() {
    ll n,x;
    std::cin >> n>>x;
    vector<ll> a(n);
    vector<vector<ll>> b(n,vector<ll>(n+2,(ll)1e15));
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= n; j++) {
            b[i][j] = min(b[i][j-1], a[(i+j-1)%n]);
        }
    }
    ll ans = 0;
    
    for (int i = 0; i < n; i++) {
        ll res = 1e16;
        for (int k = 0; k <= n; k++) {
            res = b[i][n];
        }
        ans += res;
    }
    ans += x*n;
    
    for (int m = 0; m < n; m++) {
        ll res2 = 0;
        for (int i = 0; i < n; i++) {
            res2 += b[i][m+1];
        }
        res2 += x*m;
        ans = min(res2,ans);
    }
    
    std::cout << ans << std::endl;
}


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

int main() {
  double n, xa, ya, ra, xb, yb, rb;
  double x, y, xx, rr, rr2;
  cin >> n;
  while(n--) {
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    x = xb - xa; y = yb - ya;
    xx = x*x + y*y;
    rr = rb - ra; rr = rr*rr;
    rr2 = rb + ra; rr2 = rr2*rr2;
    if(xx<rr) {
      if(rb<ra) {
        cout << "2" << endl;
      }else {
        cout << "-2" << endl;
      }
    }else if(xx<=rr2 && rr<=xx) {
      cout << "1" << endl;
    }else {
      cout << "0" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1220
n, m = map(int, input().split())
dp = [0] * (n + 1)
safe = [True] * (n + 1)
mod = 10 ** 9 + 7
for _ in range(m):
    a = int(input())
    safe[a] = False
dp[0] = 1
if safe[1] is True:
    dp[1] = 1 
for i in range(2, n+1):
    if safe[i-1] is True:
        dp[i] += dp[i-1]
    if safe[i-2] is True:
        dp[i] += dp[i-2]
    dp[i] %= mod
print(dp[n])


Measured memory_bytes: 7780
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
//#include<>
using namespace std;

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

int main()
{
  int n,m;
  bool b[15];
  int p[15];
  cin>>n>>m;
  int i,j,k,one_cnt=0,zero_cnt=0;
  rep(i,n){
    char ch;
    cin>>ch;
    if(ch=='1'){
      b[i]=true;
      one_cnt++;
    }
    else{
      b[i]=false;
      zero_cnt++;
    }
  }
  rep(i,m)cin>>p[i];
  
  bool ansline[2][15];
  int cnt[2]={};
  k=0;
  rep(i,m){
    j=0;
    while(j++<p[i]){
      ansline[0][k]=i%2;
      ansline[1][k++]=(i+1)%2;
      cnt[i%2]++;
    }
  }
  
  //  rep(i,n)cout<<ansline[0][i]<<" ";


  //swapしていく
  bool b2[15];
  rep(i,n)b2[i]=b[i];
  int swapcnt=100,swapcnt2=100;
  i=0;j=0;k=0;
  //0..1..0..な順の奴
  if(one_cnt==cnt[1] &&zero_cnt==cnt[0]){
    swapcnt=0;
    while(i<n){
      for(j=i;j<n;j++)if(b[j]==ansline[0][i])break;
      if(j!=i){
	swap(b[i],b[j]);
	swapcnt+=j-i;
      }
      i++;
    }
  }
  i=0;j=0;k=0;
  if(one_cnt==cnt[0] &&zero_cnt==cnt[1]){
    swapcnt2=0;
    while(i<n){
      for(j=i;j<n;j++)if(b2[j]==ansline[1][i])break;
      if(j!=i){
	swap(b2[i],b2[j]);
	swapcnt2+=j-i;
      }
      i++;
    }
  }
  cout<<min(swapcnt,swapcnt2)<<endl;;
  return 0;
}

Measured memory_bytes: 1160
X = int(input())
five = [0] * 200
five_inv = [0] * 200
for i in range(200):
  five[i] = i ** 5
  five_inv[i] = -five[i]

def check(x):
  A = 0
  B = 0
  for i in range(200):
    if X + five[i] in five:
      B = i
      A = five.index(five[i] + X)
      break
    elif X - five[i] in five:
      B = -i
      A = five.index(-five[i] + X)
      break
    elif X - five[i] in five_inv:
      B = -i
      A = -five_inv.index(-five[i] + X)
      break
  return "{} {}".format(A,B)

print(check(X))

Measured memory_bytes: 9224
#include <iostream>
#include<string>

using namespace std;

int main()
{
    string s , t;
    cin>>s>>t;
    int counto=0;
    int i ;
    for(i=0; i<s.size();i++){
        if(s[i]!= t[i]){counto+=1;}

    }
    cout<<counto;


    return 0;
}


Measured memory_bytes: 3880
def li():
    return [int(x) for x in input().split()]

N = int(input())
A = li()
d = 10**9 + 7
B = [A[i] % d for i in range(len(A))]

s = 0
s2 = 0
for i in range(len(B)):
    s += B[i]
    s = s
    s2 += B[i] ** 2
    s2 = s2

ans = ((s**2 - s2) // 2) % d

print(ans)

Measured memory_bytes: 101864
#include<bits/stdc++.h>
using namespace std;
 
class Dijkstra {
public:
    struct edge { long long v, dist; };
 
    struct state {
        long long v, cost;
        bool operator>(const state s) const { return cost > s.cost; }
    };
 
    const long long INF = (1LL << 60);
    long long N;
    vector< vector<edge> > E;
 
    Dijkstra(long long n): N(n), E(n) {}
 
    //有効グラフの時はこっち。u→vに距離dで結ぶ
    void add_directed_edge(long long u, long long v, long long d) {
        E[u].push_back((edge) { v, d });
    }
 
    //無向グラフの時はこっち。uとvを双方向に距離dで結ぶ
    void add_undirected_edge(long long u, long long v, long long d) {
        E[u].push_back((edge) { v, d });
        E[v].push_back((edge) { u, d });
    }
 
    //Sを始点として、他の頂点への最短経路を探す
    vector<long long> shortest_path(long long S) {
        vector<long long> dp(E.size(), INF);
        priority_queue<state, vector<state>, greater<state> > q;
        q.push((state) { S, 0 });
        while(!q.empty()) {
            long long v = q.top().v, cost = q.top().cost;
            q.pop();
            if(dp[v] <= cost) continue;
            dp[v] = cost;
            for(int i=0;i < E[v].size() ; i++) {
            long long nv = E[v][i].v, ncost = cost + E[v][i].dist;
            if(dp[nv] > ncost) q.push((state) { nv, ncost });
            }
        }
        return dp;
    }
};
 
 
int main(){
    long long n;
    cin>>n;
    long long a,b,c;
    Dijkstra d(n);
    for(int i=0;i<n-1;i++){
        cin>>a>>b>>c;
        a--,b--;
        d.add_undirected_edge(a,b,c);
    }
    long long q,k;
    cin>>q>>k;
    k--;
    vector<long long> ans=d.shortest_path(k);
    for(int i=0;i<q;i++){
        long long x,y;
        cin>>x>>y;
        x--,y--;

        
        cout<<ans[y]+ans[x]<<endl;
    }
    
}

Measured memory_bytes: 11120
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Main m = new Main();
    m.exec();
  }

  private void exec() {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();

    int countA = 1;
    int countB = 0;
    int groupA = a;
    int groupB = 0;
    
    if (b == groupA) {
      countA++;
    } else {
      groupB = b;
      countB = 1;
    }
    if (c == groupA) {
      countA++;
    } else {
      groupB = c;
      countB++;
    }
    if (countA == 1) {
      System.out.println(groupA);
    } else {
      System.out.println(groupB);
    }
  }
}

Measured memory_bytes: 22612
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin(), x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	ll N;
	cin >> N;

	ll ans = 0;
	ll boarder = 10;
	while (N >= boarder) {
		ans += boarder - boarder/10;
		boarder = boarder * 100;
	}

	if (N >= boarder/10) {
		ans += N - boarder/10 + 1;
	}

	cout << ans << endl;
	return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll h,n; cin >> h >> n;
    vl at(n),mp(n);
    rep(i,n)cin >> at[i] >> mp[i];
    vvl dp(h+10,vl(n+1,INF));
    dp[0][0] = 0;
    rep(i,h+1){
        rep(j,n){
            chmin(dp[min(h,i+at[j])][j],dp[i][j]+mp[j]);
            chmin(dp[i][j+1],dp[i][j]);
        }
    }
    out(dp[h][n]);
}


Measured memory_bytes: 78848
#include<stdio.h>

int main(){
	long long int N, A, B;
	long long int X[2];
	unsigned long long int fatigue = 0;
	scanf("%lld %lld %lld", &N, &A, &B);
	scanf("%lld", &X[0]);
	for(int i = 1; i < N; i++){
		scanf("%lld", &X[1]);
		if((X[1] - X[0]) * A <= B){
			fatigue += (X[1] - X[0]) * A;
		}else{
			fatigue += B;
		}
		X[0] = X[1];
	}
	printf("%llu", fatigue);
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
// import java.io.BufferedReader;
// import java.io.IOException;
// import java.io.InputStreamReader;
// import java.util.ArrayList;
// import java.util.Arrays;
// import java.util.Collections;
// import java.util.List;
// import java.util.HashSet;
// import java.util.Set;
// import java.util.Map;
// import java.util.HashMap;

import java.math.*;

public class Main {
    private static Scanner sc;
    private static final long mod = 1000000007;

    public static void main(final String[] args) {
        final Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private static String getUpperAlpha(int i) {
        return String.valueOf((char) (i + 64));
    }

    /* i=1 return a */
    private static String getLowerAlpha(int i) {
        return String.valueOf((char) (i + 96));
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null)
                br.close();
        }

        public String next() throws IOException {
            if (i < s.length)
                return s[i++];
            String st = br.readLine();
            while (st == "")
                st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long[] nextLongArray(int n) throws NumberFormatException, IOException {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

        public int[] nextIntArray(int n) throws NumberFormatException, IOException {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }
    }

    private void solve() {
        try {
            int a = sc.nextInt();

            System.out.println((1000 - a % 1000) % 1000);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}


Measured memory_bytes: 32624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

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

	int l, r, d;
	cin >> l >> r >> d;

	int ans = 0;
	for(int i = l; i <= r; i++){
		if(i % d == 0) ans++;
	}

	cout << ans << endl;

}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdlib>

using namespace std;

long long sumFirstPositive = 0;
long long sumFirstNegative = 0;

// long long calcSum(int i, long long na[]) {
//     long long sum = 0;
//     for (int j = 0; j <= i; j++) {
//         sum += na[j];
//     }
//     return sum;
// }

long long check(int n, int s, long long a[]) {
    long long cnt = 0;
    long long na[n];

    for (int i = 0; i < n; i++) {
        na[i] = a[i];
        // sum += na[i];

        if (s == 0) {
            sumFirstPositive += na[i];
            // 偶数番目のsumが負の場合
            if (i % 2 == 0 && sumFirstPositive <= 0) {
                // 変更する差分
                long long dx = 1 - sumFirstPositive;
                na[i] += dx;
                cnt += abs(dx);
                sumFirstPositive += dx;

                // cout << "dx: " << dx << endl;
                // cout << "cnt: " << cnt << endl;

            } else if (i % 2 != 0 && sumFirstPositive >= 0) {
                // 変更する差分
                long long dx = -1 - sumFirstPositive;
                na[i] += dx;
                cnt += abs(dx);
                sumFirstPositive += dx;

                // cout << "dx: " << dx << endl;
                // cout << "cnt: " << cnt << endl;

            }
        }

        if (s == 1) {
            sumFirstNegative += na[i];
            // 奇数番目のsumが負の場合
            if (i % 2 != 0 && sumFirstNegative <= 0) {
                // 変更する差分
                long long dx = 1 - sumFirstNegative;
                na[i] += dx;
                cnt += abs(dx);
                sumFirstNegative += dx;

                // cout << "dx: " << dx << endl;
                // cout << "cnt: " << cnt << endl;

            } else if (i % 2 == 0 && sumFirstNegative >= 0) {
                // 変更する差分
                long long dx = -1 - sumFirstNegative;
                na[i] += dx;
                cnt += abs(dx);
                sumFirstNegative += dx;

                // cout << "dx: " << dx << endl;
                // cout << "cnt: " << cnt << endl;
            }
        }
    }

    return cnt;
}

int main()
{
    int n; cin >> n;
    long long a[100001];

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

    cout <<min(check(n, 0, a), check(n, 1, a)) << endl;

    return 0;
}

Measured memory_bytes: 1152
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	n, d := scanInt(sc), scanInt(sc)
	ds := make([][]int, n)
	for i := range loop0(n) {
		ds[i] = make([]int, d)
		for j := range loop0(d) {
			ds[i][j] = scanInt(sc)
		}
	}
	num := 0
	t := squreNums(16000)
	for i := range loop0(n) {
		for j := i + 1; j < n; j++ {
			sum := 0
			for k := 0; k < d; k++ {
				df := ds[i][k] - ds[j][k]
				sum += df * df
			}
			if t[sum] {
				num++
			}
		}
	}
	return num
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

func squreNums(max int) []bool {
	t := make([]bool, max+1)
	for i := 1; i*i <= max; i++ {
		t[i*i] = true
	}
	return t
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1828
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

int main(){
    int n,m;cin>>n>>m;
    int d;cin>>d;
    int ans=0;
    for(int i=n;i<=m;i++){
        if(i%d==0)ans++;
    }
cout<<ans<<endl;
 }


Measured memory_bytes: 3632
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,a,b = readInts()
    ab = abs(a-b)
    if ab % 2 == 0:
        print(ab//2)
    else:
        print(min(a + (ab-1)//2, n - b + 1 + (ab-1)//2))

if __name__ == '__main__':
  main()


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

using namespace std;

int main()
{
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    if (abs(x-a)>abs(x-b))
    {
        printf("B");
    }
    else
    {
        printf("A");
    }


}


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

int main(){
    int n;
    cin >>n;
    char s[n];
    char t[n];
    char ans[2*n];

    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    for(int i=0;i<n;i++){
        cin >> t[i];
    }
    for(int i=0;i<n;i++){
        ans[i*2]=s[i];
        ans[i*2+1]=t[i];
    }
    for(int i=0;i<2*n;i++){
        cout << ans[i];
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x) for(int i=0; i<(int) (x); i++)
#define PI 3.14159265359
using namespace std;

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(1)
	{
		c -= b;
		if(c<=0)
		{
			cout << "Yes";
			break;
		}
		a -= d;
		if(a<=0)
		{
			cout << "No";
			break;
		}
	}


	//////////////////////////////////
	//--------end--------
	//
	return 0;
}

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

int main(){
    int N, a, ans=0;
    cin >> N;
    for(int i=0 ; i<N ; i++){
        cin >> a;
        bool flag=true;
        if(a!=2 && a%2==0 || a==1){
            flag=false;
        }else if(a>2){
            for(int j=3 ; j*j<=a ; j+=2){
                if(a%j==0){
                    flag=false;
                    break;
                }
            }
        }
        if(flag){
            ans+=1;
        }
    }
    cout << ans << endl;
    return 0;
}



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

typedef long long ll;

int main(){
	ll n, w; cin >> n >> w;
	ll weight[n+1], v[n+1], sum = 0LL;
	for(int i=1; i<=n; i++) {cin >> weight[i] >> v[i]; sum += weight[i];}
	ll dp[n+1][w+1];
	for(int i=0; i<=n; i++){
		for(int j=0; j<=w; j++)
			dp[i][j] = 0;
	}
	dp[0][0] = 0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=w; j++){
			if(j - weight[i] >= 0)
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight[i]]+v[i]);
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	/*for(int i=0; i<=n; i++){
		for(int j=0; j<=w; j++) cout << dp[i][j] << " "; 
		cout << endl;
	}*/
	cout << dp[n][w] << endl;
}




Measured memory_bytes: 79104
n,k = map(int,input().split())
a = list(map(int,input().split()))
dp1 = [0 for _ in range(n)]
dp2 = [0 for _ in range(n)]
mod = 10**9+7
for i in range(n):
    for j in range(n):
        if a[j]>a[i]:
            dp1[i]+=1
            if i>j:
                dp2[i]+=1
ans = 0
for i in range(n):
    ans += ((k-1)*dp1[i]+dp2[i]*2)*k//2
    ans %= mod
print(ans)

Measured memory_bytes: 42092
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, N;
    cin >> H >> N;

    vector<ll> A(N), B(N);
    vector<ll> dp(1e5, INF);

    dp[0] = 0;
    rep(i, N) {
        cin >> A[i] >> B[i];
    }

    rep(i, H) {
        rep(j, N) {
            chmin(dp[i + A[j]], dp[i] + B[j]);
        }
    }

    ll ans = INF;
    repd(i, H, 1e5) {
        chmin(ans, dp[i]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	string S;
	cin >> S;

	int tx, ty;
	cin >> tx >> ty;

	vector<int> X, Y;
	int tmp = 0;
	bool flag = true;
	rep(i, S.size()) {
		if (S[i] == 'F') {
			tmp++;
		} else {
			if (flag) {
				X.push_back(tmp);
			} else {
				Y.push_back(tmp);
			}
			tmp = 0;
			flag = !flag;
		}
	}
	if (flag) {
		X.push_back(tmp);
	} else {
		Y.push_back(tmp);
	}

	unordered_set<int> st;
	st.insert(0);
	if (X.size() != 0) {
		REP(i, 1, X.size() - 1) {
			unordered_set<int> st2;
			itrep(it, st) {
				st2.insert(*it + X[i]);
				st2.insert(*it - X[i]);
			}
			st = st2;
		}
	}

	if (st.count(tx - (X.size() != 0 ? X[0] : 0)) == 0) {
		cout << "No" << endl;
		return 0;
	}

	st.clear();
	st.insert(0);
	if (Y.size() != 0) {
		REP(i, 0, Y.size() - 1) {
			unordered_set<int> st2;
			itrep(it, st) {
				st2.insert(*it + Y[i]);
				st2.insert(*it - Y[i]);
			}
			st = st2;
		}
	}

	if (st.count(ty) == 0) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl sn(n);
	rep(i,k){
		ll d;
		cin>>d;
		rep(j,d){
			ll in;
			cin>>in;
			in--;
			sn[in]++;
		}
	}
	ll ans=0;
	rep(i,n)if(sn[i]==0)ans++;
	puta(ans);
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        long[] a = Read.longs();
        if (Math.Abs(a[0] - a[1]) > 1) { Console.WriteLine(0); return; }
        if (a[0] == a[1]) { Console.WriteLine((2 * (kaijo(a[0])) * kaijo(a[1]))% 1000000007); }
        else { Console.WriteLine(kaijo(a[0])*kaijo(a[1])% 1000000007); }
        Console.ReadLine();  }
    public static long kaijo(long a)
    {
        long n = 1;
        for (int i = 1; i <= a; i++)
        {
            n *= i;
            n =n% 1000000007;
        }
        return n;
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13396
import java.util.*;
 
public class Main {

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

        double k = (double)2*x/(a*b);
        double l = (double)2*(a*a*b-x)/(a*a);

        if (0 <= k && k <= a) {
            System.out.println((double)90-Math.toDegrees(Math.atan(k/b)));
        } else if (0 <= l && l <= b) {
            System.out.println(Math.toDegrees(Math.atan(l/a)));
        } else {
            System.out.println("***");
        }
    }
}


Measured memory_bytes: 21844