akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
#define fi first
#define se second
#define pb push_back
int n,a[N],b[N];
int vis[N];
const LL mod=998244353;
LL pm(LL a,LL b){
    LL ans=1;
    while(b){
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i];
    
    sort(b+1,b+1+n);
    if(a[1]!=0){
        return cout<<0,0;
    }
    if(n==1)return cout<<1,0;
    if(b[2]==0)
        return cout<<0,0;
    int len=unique(b+1,b+1+n)-b-1;
    int now=1;
    for(int i=2;i<=len;i++){
        if(b[i]>now){
            return cout<<0,0;
        }
        now++;
    }
    for(int i=1;i<=n;i++)vis[a[i]]++;
    LL ans=1;
    for(int i=0;i<n;i++){
        if(i)ans=ans*pm(vis[i-1],vis[i])%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long LL;
int main()
{
	int Q;
	scanf("%d",&Q);
	while(Q--)
	{
		LL a,b;
		scanf("%lld %lld",&a,&b);
		LL c=sqrt(a*b);
		if(c*c==a*b)
			c--;
		LL ans=c*2-1;
		if(c*(c+1)>=a*b)
			ans--;
		LL i=2;
		while(c*(c+i)<a*b)
			i++; 
		if(a==b && c*(c+2)<a*b)
			ans++;
		printf("%lld\n",ans);
	}
	return 0;
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int main() {
  int x;
  scanf("%d", &x);
  int sum = 0;
  for (int i = 1; i <= x; i++) {
    if (std::to_string(i).length() % 2 != 0) sum++;
  }
  printf("%d", sum);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll K;
int main(){
	cin>>K;
	const int N=8;
	int X=300;
	ll a[N]={},vs[N];
	rep(i,N) a[i]=1;
	vs[0]=1;
	rep(i,N-1){
		a[i+1]+=X*a[i];
		rep(j,N-2-i) a[i+2+j]+=a[i+1+j];
		vs[i+1]=a[N-1];
	}
//	rep(i,N) show(vs[i]);
	int num[N]={};
	for(int i=N-1;i>=0;i--){
		ll q=K/vs[i];
		num[i]=q;
		K%=vs[i];
	}
	string ans;
	string FES="FESTIVA";
	rep(i,N){
		if(i==0) ans+=FES;
		else ans+=string(X,FES[i-1])+FES.substr(i);
		ans+=string(num[i],'L');
	}
	cout<<ans<<endl;
}


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

int main(){
  int N;
  cin >> N;
  string s[N];
  bool frag=false;
  for(int i=0;i<N;i++)cin >> s[i];
  for(int i=0;i<N;i++){
    if(s[i]=="Y") frag=true;
  }
  if(frag){
  cout << "Four" << endl;
  }else{
  cout << "Three" << endl;
  }
}

Measured memory_bytes: 3604
n = int(input())
list_red = [list(map(int, input().split())) for i in range(n)]
list_blue = [list(map(int, input().split())) for i in range(n)]
list_red.sort(key = lambda x:x[1], reverse = True)
list_blue = sorted(list_blue)
ans = 0

for c, d in list_blue:
    for a ,b in list_red:
        if a < c and b < d:
            list_red.remove([a, b])
            ans += 1
            break
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++) cin >> vec[i];
  bool flag = true;
  for(int i=0; i<n; i++) {
    if(vec[i]%2 == 0) {
      if(vec[i]%3 != 0 && vec[i]%5 != 0) flag = false;
    }
  }
  if(flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Maxn=305,p=998244353;
int n,a[Maxn];
long long sum[Maxn],dp[Maxn*Maxn],dp2[Maxn*Maxn];
long long fast_pow(long long x,long long y)
{
	long long ans=1,now=x;
	while(y)
	{
		if(y&1) ans=(ans*now)%p;
		now=(now*now)%p;
		y>>=1;
	}
	return ans;
}
long long ans;
int main()
{
//	freopen("D.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	dp[0]=fast_pow(2,n);
	dp2[0]=1;
	for(int i=1;i<=n;i++)
		for(int j=sum[i];j>=a[i];j--)
			dp[j]=(dp[j]+499122177*dp[j-a[i]]%p)%p,
			dp2[j]=(dp2[j]+dp2[j-a[i]])%p;
	if(!(sum[n]%2)) ans+=dp[sum[n]/2]-dp2[sum[n]/2];
	for(int i=sum[n]/2+1;i<=sum[n];i++)
		ans=(ans+dp[i])%p;
	ans*=3;
	printf("%lld",((fast_pow(3,n)-ans)%p+p)%p);
	return 0;
}

Measured memory_bytes: 1664
// Contest: AtCoder Beginner Contest 155 (https://atcoder.jp/contests/abc155)
// Problem: E: Payment (https://atcoder.jp/contests/abc155/tasks/abc155_e)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    string n; cin >> n;
    int c0 = 0, c1 = INF;
    reverse(all(n));
    rep(i, sz(n)) {
        int d = n[i] - '0';
        int nc0 = min(d + c0, d + 1 + c1);
        int nc1 = min(10 - d + c0, 10 - (d + 1) + c1);
        c0 = nc0, c1 = nc1;
    }

    cout << min(c0, c1 + 1) << '\n';
    return 0;
}

Measured memory_bytes: 1948
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pr pair<int, int>
#define v1d vector<int>
#define mp make_pair
#define pb push_back
#define v1p vector<pr>
#define vb vector<bool>
#define v2d vector<vector<int>>
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define S(v) sort(v.begin(), v.end())
#define RS(v) sort(v.rbegin(), v.rend())
#define eb emplace_back
#define endl "\n"
#define MOD 1000000007
#define pqx priority_queue <int>
#define pqn priority_queue <int, v1d, greater<int> >
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};



int32_t main() {
  fio
  string s, t; cin >> s >> t;
  for(int i=0; i<(int)s.size(); ++i) {
    if(s[i] != t[i]) {
      cout << "No"; return 0; 
    }
    
  }
  cout << "Yes"; return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

template<typename T>
struct LCA{
	int n, root, l;
	vector<vector<int>> to;
	vector<vector<T>> co;
	vector<int> depth;
	vector<T> cost;
	vector<vector<int>> par;
	LCA(int n) : n(n), to(n), co(n), depth(n), cost(n){
		l = 0;
		while((1 << l) < n)++l;
		par = vector<vector<int>>(n + 1, vector<int>(l, n));
	}

	void addEdge(int a, int b, T c = 0){
		to[a].push_back(b);
		to[b].push_back(a);
		co[a].push_back(c);
		co[b].push_back(c);
	}

	void dfs(int v, int p = -1, int d = 0, T c = 0){
		if(p != -1)par[v][0] = p;
		depth[v] = d;
		cost[v] = c;
		for(int i = 0; i < to[v].size(); ++i){
			int nv = to[v][i];
			if(nv == p)continue;
			dfs(nv, v, d + 1, c + co[v][i]);
		}
	}

	void init(int r = 0){
		root = r;
		dfs(root);
		for(int i = 0; i < l - 1; ++i){
			for(int v = 0; v < n; ++v){
				par[v][i + 1] = par[par[v][i]][i];
			}
		}
	}

	int operator()(int a, int b){
		if(depth[a] > depth[b])swap(a, b);
		int diff = depth[b] - depth[a];
		for(int i = l - 1; i >= 0; --i){
			int len = 1 << i;
			if(diff >= len){
				diff -= len;
				b = par[b][i];
			}
		}

		if(a == b)return a;
		for(int i = l - 1; i >= 0; --i){
			int na = par[a][i];
			int nb = par[b][i];
			if(na != nb){
				a = na;
				b = nb;
			}
		}
		return par[a][0];
	}

	int length(int a, int b){
		int c = (a, b);
		return depth[a] + depth[b] - depth[c] * 2;
	}

	T dist(int a, int b){
		int c = (a, b);
		return cost[a] + cost[b] - cost[c] * 2;
	}
};

struct Edge{
	int to, cost, color;
	Edge(int to, int color, int cost) : to(to), color(color), cost(cost){}
};

vector<vector<Edge>> edge;

struct Query{
	int id, x, y, op;
	Query(int id, int x, int y, int op) : id(id), x(x), y(y), op(op){}
};

vector<ll> ans;
vector<vector<Query>> qs;
vector<int> cnt;
vector<ll> sum;
void dfs2(int v, int p = -1){
	for(auto q : qs[v]){
		ll tmp = -sum[q.x];
		ans[q.id] -= q.op * sum[q.x];
		ans[q.id] += q.op * cnt[q.x] * (ll)q.y;
	}
	for(auto e : edge[v]){
		if(e.to == p)continue;
		++cnt[e.color];
		sum[e.color] += e.cost;
		dfs2(e.to, v);
		--cnt[e.color];
		sum[e.color] -= e.cost;
	}
}

int main(){
  int n, q;
  cin >> n >> q;
  LCA<ll> g(n);
  edge.resize(n);
  for(int i = 0; i < n - 1; ++i){
  	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  	--a;
  	--b;
  	edge[a].push_back(Edge(b, c, d));
  	edge[b].push_back(Edge(a, c, d));
  	g.addEdge(a, b, d);
  }

  g.init();
  ans.resize(q);
  qs.resize(n);  
  for(int i = 0; i < q; ++i){
  	int x, y, u, v;
  	cin >> x >> y >> u >> v;
  	--u;
  	--v;
  	int a = g(u, v); 
  	ans[i] = g.cost[u] + g.cost[v] - 2 * g.cost[a];
  	qs[u].push_back(Query(i, x, y, 1));
  	qs[v].push_back(Query(i, x, y, 1));
  	qs[a].push_back(Query(i, x, y, -2));
  }

  cnt.assign(n, 0);
  sum.assign(n, 0);
  dfs2(0);

  for(int i = 0; i < q; ++i){
  	cout << ans[i] << endl;
  }
  return 0;
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int n, ans = 1;
    cin >> n;
    REP(i, 1, n + 1)
    {
        ans *= i;
        ans %= inf;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
long long dp[3500][3500];
string s,t;
int count(int si,int ti){
	if(si == 0 || ti == 0)
	{
		dp[si][ti] = 0;
		return 0;
	}
	if(dp[si][ti]!=-1)
		return dp[si][ti];
	if(s[si-1] == t[ti-1])
		dp[si][ti] = count(si-1,ti-1) + 1;
	else{
		dp[si][ti] = max(count(si-1,ti),count(si,ti-1));
	}
	return dp[si][ti];
}

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


	cin >> s >> t;
	for(int i = 0;i < 3500; ++i){
		for(int j = 0; j < 3500; ++j){
			dp[i][j] = -1;
		}
	}
	string ans;
	int l = count(s.size(),t.size());

	int si = s.size() , ti = t.size();

	while(l > 0){
		if(dp[si-1][ti] == dp[si][ti]){
			--si;
		}else if(dp[si][ti-1] == dp[si][ti]){
			--ti;
		}else {
			ans.push_back(s[si-1]);
			--l;
			--si;
			--ti;
		}
	}
	reverse(ans.begin(),ans.end());
	cout << ans;

	return 0;
}

Measured memory_bytes: 96384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	IOS;
	 
    int n; cin>>n;
    ll a[n]; ll x = 0;
    forn(i,n)
    {
        cin>>a[i];
        x ^= a[i];
    }
    forn(i,n)
    {
        cout<<(x^a[i])<<' ';
    }
	
	return 0;
}


Measured memory_bytes: 5176
#include<stdio.h>
int main(){
	int i, j, k, n, m = 3, row, num;
	int data[200][3];
	int sum[200] = {};
	
	//?????¬???????????°?????\???
	scanf("%d", &n);
	
	//???????????????????????°?????\???
	for( i = 0; i < n; i++){
		for( k = 0; k < m; k++){
			scanf("%d", &data[i][k]);
		}
	}
	
	//????????°?????????
	for( k = 0; k < m; k++){
		for( j = 0; j < n; j++){
			row = j;
			num = data[row][k];
			for( i = j + 1; i < n; i++){
				if( data[i][k] == num){
					data[i][k] = 0;
					data[j][k] = 0;
				}
			}
		}
	}
	
	//????¨?????¨????
	for( i = 0; i < n; i++){
		for( k = 0; k < m; k++){
			sum[i] = sum[i] + data[i][k];
		}
	}
	
	//??????
	for( i = 0; i < n; i++){
		printf("%d\n", sum[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  string tmp[2];
  string s,t;
  cin>>s>>t;
    
  vector<vector<ll>> dp(s.length()+1,vector<ll>(t.length()+1,0));
  
  for(int i=1;i<=s.length();i++){
    for(int j=1;j<=t.length();j++){
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      if(s[i-1]==t[j-1]) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
      else  dp[i][j]=max(dp[i][j],dp[i-1][j-1]);
    }
  }
  string ans="";
  int x=s.length(),y=t.length();
  while(x>0&&y>0){
    if(dp[x][y]==dp[x-1][y]) x--;
    else if(dp[x][y]==dp[x][y-1]) y--;
    else{
      x--; y--;
      ans.push_back(s[x]);
    }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
	long long n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	for(int k=1;k<=n;k++)
	ans+=__gcd(i,__gcd(j,k));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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





int main() {
    int n, sum = 0;
    cin >> n;
    REP(i, n){
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,k,count=0;
	cin>>n>>k;
	char c[n+2];
	int i;
	c[0]='R';
	c[n+1]='L';
	for(i=0;i<n;i++)cin>>c[i+1];
	for(i=1;i<n+1;i++){
		if(c[i]=='R'&&c[i+1]=='L')count++;
		if(c[i]=='L'&&c[i-1]=='R')count++;
	}
	cout<<min(n-count+2*k,n-1);
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.function.BiFunction;

public class Main {
  Scanner sc = new Scanner(System.in);

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

  long div(long a, long b) {
    return a / b + (a % b == 0 ? 0 : 1);
  }

  void run() {
    int n = ni();
    long T = 1;
    long A = 1;
    long t_ = 1;
    long a_ = 1;
    for (int i = 0; i < n; ++i) {
      long t = ni();
      long a = ni();
      long v = Math.max(div(T, t), div(A, a));
      T = t * v;
      A = a * v;
//      debug(t, a, v, T, A);
    }
    System.out.println(A + T);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }

  class BIT<T> {
    int n;
    ArrayList<T> bit;
    BiFunction<T, T, T> bif;

    BIT(int n, BiFunction<T, T, T> bif, T defaultValue) {
      this.n = n;
      bit = new ArrayList<>(n + 1);
      for (int i = 0; i < n + 1; ++i) {
        bit.add(defaultValue);
      }
      this.bif = bif;
    }

    void update(int i, T v) {
      for (int x = i; x <= n; x += x & -x) {
        bit.set(x, bif.apply(bit.get(x), v));
      }
    }

    T reduce(int i, T defaultValue) {
      T ret = defaultValue;
      for (int x = i; x > 0; x -= x & -x) {
        ret = bif.apply(ret, bit.get(x));
      }
      return ret;
    }
  }

}

Measured memory_bytes: 12704
#include <stdio.h>
 
int main(void)
{
  
  char buf[10];
  int x;
  
  char ans[10];
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  
  char ac[10] = "AC";
  char wa[10] = "WA";
  char tle[10] = "TLE";
  char re[10] = "RE";
  
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d", &x);
  
  for(int i = 0; i < x; i++){
	fgets(buf, sizeof(buf), stdin);
  	sscanf(buf, "%s", ans);
    
    if(ans[0] == 'A'){
      a++;
    } else if (ans[0] == 'W'){
      b++;
    } else if (ans[0] == 'T'){
      c++;
    } else if (ans[0] == 'R'){
      d++;
    }
    
  }
  
  	printf("AC x %d\n", a);
    printf("WA x %d\n", b);
    printf("TLE x %d\n", c);
    printf("RE x %d\n", d);
}

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

      int n = sc.nextInt();
      int x = sc.nextInt();
      int data[] = new int[n];
      int data2[] = new int[n];

      for (int i  = 0;i<n ;i++ ) {
        data[i] = sc.nextInt();
      }

      for (int i  = 0;i<n ;i++ ) {
        data2[i] = Math.abs(data[i]-x);
      }

      System.out.println(gcd(data2,n));

  }

    static int gcd(int[] data2,int n){
      Arrays.sort(data2);
      int ans = data2[0];
      for (int i = 0;i<n ;i++ ) {
        if (ans<data2[i]) {
          int temp = ans;
          ans = data2[i];
          data2[i] = temp;
        }
        while(data2[i]>0){
          int r = ans%data2[i];
          ans = data2[i];
          data2[i] = r;
        }
       }
       return ans;
      }

    }


Measured memory_bytes: 47984
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> h;
  ll add = 1;
  while (1) {
    if (h == 0) break;
    h /= 2;
    ans += add;
    add *= 2;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

x_1,y_1,x_2,y_2=map(int,input().split())
x_3=x_2-(y_2-y_1)
y_3=x_2-x_1+y_2
x_4=x_3-(x_2-x_1)
y_4=y_3-(y_2-y_1)
print('{} {} {} {}'.format(x_3,y_3,x_4,y_4))


        


Measured memory_bytes: 2940
N,K=map(int,input().split())
d=[]
A=[]
for i in range(K):
    u=int(input())
    d.append(u)
    a=list(map(int,input().split()))
    A.append(a)
    
Q=[0]*N
for i in range(K):
    for j in range(d[i]):
        Q[A[i][j]-1]+=1
print(Q.count(0))

Measured memory_bytes: 9200
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for(int i=0; i<s.length(); i+=2){
			System.out.print(s.charAt(i));
		}
		System.out.println("");
	}
}

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

void umex(char* tostr,int toome) {
	int i;
	for(i=0;tostr[i];i++) {
		if(tostr[i]=='X')tostr[i]=toome+'0';
	}
}

int checkstr(const char* taisyou) {
	if(strlen(taisyou)==1)return 1;
	if(taisyou[0]=='0')return 0;
	return 1;
}

void stradd(char* out,const char* in1,const char* in2) {
	int offset;
	int i;
	int now;
	int kuriagari=0;
	int maxlen;
	int nowmax;
	char buf[128];
	offset=strlen(in2)-strlen(in1);
	maxlen=strlen(in2);
	now=127;
	for(i=strlen(in1)-1;i>=0 || i+offset>=0;i--) {
		buf[now]=kuriagari;
		if(i>=0)buf[now]+=in1[i]-'0';
		if(i+offset>=0 && i+offset<maxlen)buf[now]+=in2[i+offset]-'0';
		kuriagari=buf[now]/10;
		buf[now]=buf[now]%10;
		now--;
	}
	if(kuriagari) {
		buf[now]=kuriagari;
		now--;
	}
	nowmax=127-now;
	now++;
	for(i=0;i<nowmax;i++) {
		out[i]=buf[i+now]+'0';
	}
	out[i]=0;
}

int main(void) {
	char tougou[127];
	char one[127];
	char two[127];
	char ans[127];
	char one_2[127];
	char two_2[127];
	char ans_2[127];
	char addbuf[128];
	int i;
	char* plus;
	char* equal;
	while(~scanf("%s",tougou)) {
		plus=strchr(tougou,'+');
		equal=strchr(tougou,'=');
		*plus=0;
		*equal=0;
		strcpy(one,tougou);
		strcpy(two,plus+1);
		strcpy(ans,equal+1);
		for(i=0;i<=9;i++) {
			strcpy(one_2,one);
			strcpy(two_2,two);
			strcpy(ans_2,ans);
			umex(one_2,i);
			umex(two_2,i);
			umex(ans_2,i);
			if(!checkstr(one_2))continue;
			if(!checkstr(two_2))continue;
			if(!checkstr(ans_2))continue;
			stradd(addbuf,one_2,two_2);
			if(strcmp(addbuf,ans_2)==0)break;
		}
		if(i>9)puts("NA"); else printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<functional>
#include<vector>
#include<string>
#include<queue>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

struct state {
    int node;
    ll cost, value;
    state(int node, ll cost, ll value):node(node), cost(cost), value(value) {}
};

struct edge {
    int to;
    ll cost, dist;
    edge(int to, ll cost, ll dist):to(to), cost(cost), dist(dist) {}
};

const ll INF = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, S;
    cin >> N >> M >> S;
    int u, v;
    ll a, b;
    vector<vector<edge>> graph(N);
    rep(i, 0, M) {
        cin >> u >> v >> a >> b;
        --u, --v;
        graph[u].emplace_back(v, a, b);
        graph[v].emplace_back(u, a, b);
    }
    vector<ll> C(N), D(N);
    rep(i, 0, N) {
        cin >> C[i] >> D[i];
    }
    vector<vector<ll>> dist(N, vector<ll>(2525, INF));
    chmin(S, 2500LL);
    dist[0][S] = 0;
    priority_queue<state, vector<state>, function<bool(state, state)>> que([](const state& s1, const state& s2) {
        return s1.value > s2.value;
    });
    que.push(state(0, S, 0));
    while (!que.empty()) {
        state now = que.top();
        que.pop();
        if (dist[now.node][now.cost] < now.value) {
            continue;
        }
        for (auto& e : graph[now.node]) {
            if (e.cost > now.cost) {
                continue;
            }
            if (chmin(dist[e.to][now.cost - e.cost], now.value + e.dist)) {
                que.push(state(e.to, now.cost - e.cost, now.value + e.dist));
            }
        }
        if (chmin(dist[now.node][min(now.cost + C[now.node], 2500LL)], now.value + D[now.node])) {
            que.push(state(now.node, min(now.cost + C[now.node], 2500LL), now.value + D[now.node]));
        }
    }
    rep(u, 1, N) {
        ll ans = INF;
        rep(cost, 0, 2525) {
            chmin(ans, dist[u][cost]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 7296
import Foundation

let a = readLine()!.components(separatedBy: " ").map{ Int($0)! }
var R = a[0]
var G = a[1]
var B = a[2]
let K = Int(readLine()!)!

for i in 1...K {
    if B > G && G > R {
        print("Yes")
        break
    } else if G <= R {
        G *= 2
        if B > G && G > R {
            print("Yes")
            break
        }
    } else if B <= G {
        B *= 2
        if B > G && G > R {
            print("Yes")
            break
        }
    }
    if i == K {
        print("No")
    }
    
}

Measured memory_bytes: 14088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    clock_t start = clock();
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    ll d; cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) cin >> s[i][j];
    }
    
    vector<ll> w(0);
    for (ll i = 0; i < 26; i++) {
        w.push_back(i);
        for (ll j = 0; j < c[i]; j++) w.push_back(i);
    }
    ll m = w.size();
    
    vector<ll> t(d);
    random_device rand;
    for (ll i = 0; i < d; i++) t[i] = w[rand() % m];
    
    auto calc = [&] () {
        ll ret = 0;
        vector<ll> v(26, -1);
        for (ll i = 0; i < d; i++) {
            v[t[i]] = i;
            ret += s[i][t[i]];
            for (ll j = 0; j < 26; j++) ret -= c[j] * (i - v[j]);
            //cout << ret << endl;
        }
        return ret;
    };
    ll score = calc();
    
    vector<set<ll>> v(26);
    for (ll i = 0; i < 26; i++) v[i].insert(-1);
    for (ll i = 0; i < d; i++) v[t[i]].insert(i);
    for (ll i = 0; i < 26; i++) v[i].insert(d);
    
    auto modified_score = [&] (ll day, ll into) {
        ll ret = score;
        ret += s[day][into] - s[day][t[day]];
        auto itr1 = v[t[day]].find(day);
        ll p = *(--itr1), q = *(++itr1), r = *(++itr1);
        ret += ((q - p) * (q - p - 1) + (r - q) * (r - q - 1)) * c[t[day]] / 2;
        ret -= (r - p) * (r - p - 1) * c[t[day]] / 2;
        auto itr2 = v[into].upper_bound(day);
        p = *(--itr2); q = day; r = *(++itr2);
        ret -= ((q - p) * (q - p - 1) + (r - q) * (r - q - 1)) * c[into] / 2;
        ret += (r - p) * (r - p - 1) * c[into] / 2;
        return ret;
    };
    
    while (clock() - start <= 1.95 * CLOCKS_PER_SEC) {
        ll day = rand() % d, into = w[rand() % m];
        ll x = modified_score(day, into);
        if (x >= score) {
            score = x;
            v[t[day]].erase(day);
            v[into].insert(day);
            t[day] = into;
        }
    }
    
    for (ll i = 0; i < d; i++) cout << t[i] + 1 << endl;
    xout << score << endl;
}

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

int main(void){
	ll d = 1e9+7;
	int N;
	cin >> N;
	ll a=1, b=2, c=1;
	rep(i,N) {
		a *= 10;
		b *= 9;
		c *= 8;
		a %= d;
		b %= d;
		c %= d;
	};

	ll ans = a - b +c;
	ans = (ans+d)%d;
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define For(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){

  int n,ans=0;
  cin >> n;
  int p[n];
  For(i, n) cin >> p[i];

  for(int i=1; i<n-1; i++){
    if(p[i]>p[i-1]&&p[i]<=p[i+1]) ans++;
    if(p[i]<=p[i-1]&&p[i]>p[i+1]) ans++;
  }

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


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#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, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
   int N, Y; cin >> N >> Y;
   for(int x = 0; x <= N; x++)
   {
       for(int y = 0; x+y <= N; y++)
       {
           int z = N - x - y;
           if(10000*x + 5000*y + 1000*z == Y)
           {
               cout << x << " " << y << " " << z << endl;
               return;
           }
       }
   }
   cout << -1 << " " << -1 << " " << -1 << endl;
}

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

    solve();

    return 0;
}

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

int main() {
	int N, M, C;
	int count = 0;
	int score = 0;

	cin >> N >> M >> C;

	int A, B[M];
	for (int i = 0; i < M; i++) {
		B[M] = 0;
	}

	for (int i = 0; i < M; i++)
		cin >> B[i];

	for (int code_id = 0; code_id < N; code_id++) {
		score = 0;
		for (int feature_id = 0; feature_id < M; feature_id++) {
			cin >> A;
			score += A * B[feature_id];
		}
		if (score + C > 0)
			count++;
	}

	cout << count << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s, t, r;
    cin >> s >> t;
    r = s + t;
    int n = stoi(r);
    bool p = true;
    FOR(i,0,350){
        if(SQ(i) == n){
            cout << "Yes" << endl;
            p = false;
            break;
        }
    }
    if(p){
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import Control.Monad

main :: IO ()
main = do
  ls <- replicateM 8 getLine
  let ls' = spin90 ls
      ls'' = spin90 ls'
      ls''' = spin90 ls''
  print 90
  mapM_ putStrLn ls'
  print 180
  mapM_ putStrLn ls''
  print 270
  mapM_ putStrLn ls'''

spin90 :: [String] -> [String]
spin90 ("":_) = []
spin90 [(a:as),(b:bs),(c:cs),(d:ds),(e:es),(f:fs),(g:gs),(h:hs)]
  = [h,g,f,e,d,c,b,a]:(spin90 [as,bs,cs,ds,es,fs,gs,hs]) 

Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int p[N],q[N],r[N];
int x,y,a,b,c;
int main(){
	cin>>x>>y>>a>>b>>c;
	for(int i=0;i<a;i++) cin>>p[i];
	for(int i=0;i<b;i++) cin>>q[i];
	for(int i=0;i<c;i++) cin>>r[i];
	sort(p,p+a);
	sort(q,q+b);
	sort(r,r+c);
	p[a]=q[b]=1e9;
	long long ans=0;
	for(int i=0;i<x;i++) ans+=p[a-i-1];
	for(int i=0;i<y;i++) ans+=q[b-i-1];
	for(int i=0,j=a-x,k=b-y;i<x+y;i++){
		int s=r[c-i-1];
		if(s<=p[j]&&s<=q[k]) break;
		ans+=s;
		if(p[j]<q[k]) ans-=p[j++];
		else ans-=q[k++];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
#include<numeric>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int ans;

int main(){
    string t;
    cin >> t;
    Int n = t.size();
    string comp = "";
    Int all_cnt[2] = {0,0};
    Int always = 0;
    for(char c:t){
        all_cnt[c - '0']++;
        if(!comp.empty() && comp.back() == '1' && c == '1'){
            comp.pop_back();
            always++;
        }
        else comp.push_back(c);
    }
    
    ans += (all_cnt[1] / 2) * (all_cnt[1] / 2 + 1);
    if(all_cnt[1] % 2)ans += all_cnt[1] / 2 + 1;
    ans += always * all_cnt[0];
    Int zero = 0;
    Int one = 0;
    for(char c: comp){
        if(c == '0')zero++;
        else{
            one++;
            Int from = one + zero;
            Int to = one;to;
            ans += all_cnt[0];
            ans -= (from / 2) - (to/2);
        }
    }
    cout << ans << endl;
        
    return 0;
}

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


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

Measured memory_bytes: 80256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		//int a = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] NMK = Console.ReadLine().Split(' ');
		int N = int.Parse(NMK[0]);
		int M = int.Parse(NMK[1]);

		string[] items = Console.ReadLine().Split(' ');
		List<int> point = new List<int>();
		int sum = 0;
		for(int i=0; i<items.Length; i++)
		{
			int a = int.Parse(items[i]);
			point.Add(a);
			sum += a;
		}

		point.Sort();


		for(int i=N-1; i>N-1-M; i--)
		{
			decimal b = (decimal)point[i];
			decimal c = (decimal)sum / (4*M);
			//Console.WriteLine(b + " " + c);
			if(b < c)
			{
				Console.WriteLine("No");
				return;
			}
		}

		// 文字列の入力
		//string s = Console.ReadLine();
		//出力
		//Console.WriteLine((a+b+c) + " " + s);
		Console.WriteLine("Yes");
	}
}


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

int main() {
  int n,k;
  cin >>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  long long kotae=0;
  for(int i=0;i<k;i++){
    kotae+=a[i];
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <cstdlib>
#define rep(i,N) for(ll i=0;i<N;i++)
typedef long long int ll;
using namespace std;
using vl=vector<ll>;

ll gcd_(ll a,ll b){
    if(a<b)    
        swap(a,b);
    if(b==0)
        return a;
    return gcd_(b,a%b);
}
 
ll gcd(vl l){
    ll ans=l[0];
    for(size_t i=0;i<l.size();i++)
        ans=gcd_(ans,l[i]);
    return ans;
}

int main(){
    ll N,X;
    cin>>N>>X;
    vl x(N);
    rep(i,N){
        cin>>x[i];
        x[i]=abs(X-x[i]);
    }
    
    cout<<gcd(x)<<endl;

    return 0;
}

Measured memory_bytes: 1792
// 2020-08-31 14:48:41
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
bool ok(vector<int>& ds, int x) {
  bitset<20000> b;
  b[10000] = 1;
  for (int d : ds) {
    b = (b >> d) | (b << d);
  }
  return b[10000 + x];
}
void answer() {
  string s;
  cin >> s;
  int tx, ty;
  cin >> tx >> ty;
  int si = 0;
  for (; si < s.size(); si++) {
    if (s[si] == 'F')
      tx--;
    else
      break;
  }
  if (tx < 0) tx = -tx;
  if (ty < 0) ty = -ty;
  vector<vector<int> > ds(2);
  {
    int c = 0, d = 0;
    REP(i, si, s.size()) {
      if (s[i] == 'F') {
        c++;
      } else {
        if (c > 0) ds[d].push_back(c);
        c = 0;
        d = 1 - d;
      }
    }
    if (c > 0) ds[d].push_back(c);
  }
  if (ok(ds[0], tx) && ok(ds[1], ty)) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
using PP = pair<int, long long>;

int N, Q, K;
vector<PP> G[100000];
long long dist[100000];


long long calc(int l, int r) {
  return dist[l] + dist[r];
}

void dfs(int i, int prev) {
  for(PP p : G[i]) {
    int to = p.first;
    if(to == prev) continue;
    dist[to] = dist[i] + p.second;
    dfs(to, i);
  }
}

void solve() {
  fill(dist, dist + N, 1ll << 62);
  dist[K] = 0;
  dfs(K, -1);
}

int main() {
  cin >> N;
  for(int i = 0; i < N - 1; ++i) {
    int a,b,c;
    cin >> a >> b >> c;
    --a; --b;
    G[a].push_back(PP(b, c));
    G[b].push_back(PP(a, c));
  }
  
  cin >> Q >> K;
  --K;
  solve();
  for(int i = 0; i < Q; ++i) {
    int l, r;
    cin >> l >> r;
    --l; --r;
    cout << calc(l, r) << endl;  
  }
  return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	a %= MOD;
	b %= MOD;
	return (a * b) % MOD;
}

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}	
	int one = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (a[j] < a[i]) {
				one++;
			}
		}
	}
	vector<int> hv;
	for (int i = 0; i < n; i++) {
		int cur = 0;
		for (int j = 0; j < n; j++) {
			if (a[j] > a[i]) {
				cur++;
			}
		}
		hv.push_back(cur);
	}
	int hs = 0;
	for (auto t : hv) {
		hs += t;
	}
	// cerr << hs << endl;
	int ans = add(one * k, mul(k * (k - 1) / 2, hs));
	cout << ans << endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
x = gets.chomp.split(' ').map(&:to_i)

sorted_x = x.sort
median_right_i = n / 2
median_left_i = median_right_i - 1
median_left = sorted_x[median_left_i]
median_right = sorted_x[median_right_i]

# if median_left == median_right
#   n.times { puts median_left }
#   return
# end

x.each do |xi|
  puts xi <= median_left ? median_right : median_left
end


Measured memory_bytes: 25316
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,e) for(int i=0;i<(e);++i)

int main() {
  int d, w;
  while(cin >> d >> w){
    if(d==0) return 0;
    int grid[d][w] = {};
    rep(i,d)rep(j,w) cin>>grid[i][j];
    int ans=0;

    rep(i, d-2)rep(j, w-2){
      for(int dd=2; i+dd<d; dd++){
        for(int ww=2; j+ww<w; ww++){
          int wmin = 1e9;
          int cur = 0;
          int good = true;
          REP(ii, i, i+dd+1){
            wmin = min(wmin, grid[ii][j]);
            wmin = min(wmin, grid[ii][j+ww]);
          }
          REP(jj, j, j+ww+1){
            wmin = min(wmin, grid[i][jj]);
            wmin = min(wmin, grid[i+dd][jj]);
          }
          REP(ii, i+1, i+dd)REP(jj, j+1, j+ww){
            if(grid[ii][jj]>=wmin){
              good = false;
              break;
            }
            else cur += wmin - grid[ii][jj];
          }
          if(good) ans = max(ans, cur);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    // int size = to_string(n).size();
    int ans = 0;

    for (auto i = 1; i <= n; i++)
    {
        if(to_string(i).size() % 2 == 1){
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	ll n;
	cin >> n;
	ll ans = (n / 11) * 2;
	if(n % 11 != 0){
		if(n % 11 > 6) ans += 2;
		else ans += 1;
	}

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

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

typedef long long ll;
typedef unsigned long long ull;

#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll res = 1e18;
    for (int i = 0; i <= (int)1e5; i++) {
        res = min(res, 1LL*(i*2*c)+(max(0, x-i) * a)+(max(0, y-i) * b));
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;

long double a[100];
int main()
{
	while (cin >> a[0])
	{
		auto sum = a[0];
		FOR(i, 1, 10)
		{
			if (i % 2 == 0) a[i] = a[i-1] / 3;
			else a[i] = a[i - 1] * 2;
			sum += a[i];
		}
		cout <<D10<< sum << endl;
	}
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <map>
#include <utility>
using namespace std;

template<class T>
T gcd(T a, T b)
{
    while (a > 0)
    {
        T t = a;
        a = b%a;
        b = t;
    }
    return b;
}

int main()
{
    int N;
    cin>>N;
    vector<long long> A(N), B(N);
    for (int i=0; i<N; i++)
        cin>>A[i]>>B[i];

    map<pair<long long, long long>, long long> M;
    for (int i=0; i<N; i++)
    {
        long long a = A[i];
        long long b = B[i];
        if (a!=0 || b!=0)
        {
            long long g = gcd(abs(a), abs(b));
            a /= g;
            b /= g;
            if (a<0 || a==0 && b<0)
            {
                a *= -1;
                b *= -1;
            }
        }
        M[make_pair(a, b)]++;
    }

    //for (auto m: M)
    //    cout<<m.first.first<<" "<<m.first.second<<" "<<m.second<<endl;

    long long MOD = 1000000007;
    vector<long long> P2(N+1);
    P2[0] = 1;
    for (int i=1; i<=N; i++)
        P2[i] = P2[i-1]*2%MOD;

    long long ans = 1;
    for (auto m: M)
    {
        long long a = m.first.first;
        long long b = m.first.second;
        long long c = m.second;

        if (a!=0 || b!=0)
        {
            long long ai = b;
            long long bi = -a;
            if (ai<0 || ai==0 && bi<0)
            {
                ai *= -1;
                bi *= -1;
            }
            if (M.count(make_pair(ai, bi))==0)
            {
                ans *= P2[c];
                ans %= MOD;
            }
            else if (ai>a || ai==a && bi>b)
            {
                long long ci = M[make_pair(ai, bi)];
                ans *= (P2[c]+P2[ci]-1)%MOD;
                ans %= MOD;
            }
        }
    }
    cout<<(ans+M[make_pair(0LL, 0LL)]-1+MOD)%MOD<<endl;
}


Measured memory_bytes: 19804
#include <stdio.h>

int main()
{
    char s[3];
    int cnt = 0;
    scanf("%s", s);
    if (s[0] == 'o') ++cnt;
    if (s[1] == 'o') ++cnt;
    if (s[2] == 'o') ++cnt;

    printf("%d", 700 + (100 * cnt));
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))

if n == k:
    ans = 1 
elif (n-1)%(k-1)==0:
    ans = (n-1)//(k-1)
else:
    ans = math.ceil(n/(k-1))
print(ans)


Measured memory_bytes: 20472
#include<iostream>
#include<queue>
#include<string>
#define P pair<string,int>
using namespace std;

queue<P> d;

int n,q,t,nowtime;
string s;

int main(){
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>s>>t;
		d.push(P(s,t));
	}
	while(d.empty()!=1){
		if(d.front().second<=q){
			nowtime+=d.front().second;
			cout<<d.front().first<<" "<<nowtime<<endl;
			d.pop();
		}
		else{
			nowtime+=q;
			d.push(P(d.front().first,d.front().second-q));
			d.pop();
		}
		
	}
	return 0;
}

Measured memory_bytes: 6160