akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int deg[N]={},dp[N]={},n,m,x,y;
vector<int> ft[N];
queue<int> ver;
int main(){
	int i,j,ans=0;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		ft[x].push_back(y);
		deg[y]++;
	}
	for(i=0;i<n;i++)
	{
		if(deg[i]==0)
		{
			ver.push(i);
		}
	}
	while(ver.size())
	{
		x=ver.front();
		ver.pop();
		for(i=0;i<ft[x].size();i++)
		{
			dp[ft[x][i]]=max(dp[ft[x][i]],dp[x]+1);
			deg[ft[x][i]]--;
			if(deg[ft[x][i]]==0)
			{
				ver.push(ft[x][i]);
			}
		}
	}
	for(i=0;i<n;i++)
	{
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;
}

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

const int N=85;
int n,a[N],mx[N],dp[N];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    dp[0]=1000;
    for(int i=1;i<=n;i++)
    {
        int mn=1e9;
        for(int j=i;j>=1;j--)
        {
            int cur=dp[j-1];
            mn=min(mn,a[j]);
            dp[i]=max(dp[i],(cur/mn)*a[i]+cur%mn);
        }
    }
    cout<<*max_element(dp,dp+n+1);
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
   long a;
   int i,n,g;

   scanf("%d",&n);
   for (i=0;i<n;i++) {
      scanf("%ld\n",&a);
      if (a%2==0) g++;
   }
   if (n==g) puts("second");
   else      puts("first");
   return 0;
}


Measured memory_bytes: 128
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

string s, t;
int n;
bool flag ;


bool match(int j){

    rep(i, 0, n){
    if(j>n)j=0;

        if(s[i]==t[j]){j++;continue;}
        else return false;

    }
return true;

}

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);



cin >>  s>> t;

n = s.size()-1;



    rep(j, 0, n){

    if(match(j)){
        cout << "Yes"<<endl;
        return 0;
    }

    }



cout << "No" ;





return 0;}
///.... Maria Otonashi


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
d={}
ans=0
for i in range(n):
    for j in range(-1,2):
        try:
            d[a[i]+j]+=1
            ans=max(ans,d[a[i]+j])
        except:
            d[a[i]+j]=1
            ans=max(ans,d[a[i]+j])
print(ans)


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

int main()
{
	int n;
	cin >> n;
	map<string, vector<int>> M;
	map<pair<string, int>, int> S;
	int p;
	string s;
	for (int i = 0; i < n; ++i)
	{
		cin >> s >> p;
		M[s].push_back(p);
		S[make_pair(s, p)] = i + 1;
	}
	for (auto o : M)
	{
		sort(o.second.begin(), o.second.end(), greater<int>());
		for (auto oo : o.second)
		{
			cout << S[make_pair(o.first, oo)] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	int A[110] = {}; 
	int cnt = 0; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			for(int k = j+1; k < N; k++){
				if(A[i] != A[j] && A[j] != A[k] && A[k] != A[i] && A[i] + A[j] > A[k] && A[i] + A[k] > A[j] && A[j] + A[k] > A[i]) cnt ++; 
			}
		}
	}
	cout << cnt << "\n"; 
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/
vector<int> ans;

struct Data {
  vector<int> e;
};
vector<Data> v;
vector<int> o;
void dfs(int i, int d, int c) {
  if (ans[i] == -1)
    ans[i] = c;
  if (d <= o[i])return;
  o[i] = d;

  if (d > 0)for (auto& j : v[i].e) {
    dfs(j, d - 1, c);
  }
}

void Calc() {

  var(int, n, m);
  v.resize(n);
  ans.resize(n, -1);
  o.resize(n);
  err(n, m);
  rep(i, m) {
    var(int, a, b);
    a--, b--;

    v[a].e.push_back(b);
    v[b].e.push_back(a);
  }

  int q = in;
  //assert(n <= 2000 && m <= 2000 && q <= 2000);
  struct Q {
    int v, d, c;
    void In() { in, v, d, c; }
  };
  vector<Q> qu(q);
  for (auto& i : qu) {
    i.In();
  }
  reverse(all(qu));

  for (auto& i : qu) {
    dfs(i.v - 1, i.d, i.c);
  }
  for (auto& i : ans) {
    cout << (i == -1 ? 0 : i) << endl;
  }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    set<string> S;
    rep(i, N) {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << '\n';
}

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


Measured memory_bytes: 19200
while True:
    H,W = map(int, input().split())
    i = 0
    j = 0

    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j)%2 == 0:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()



Measured memory_bytes: 7008
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,k=0;
	cin>>a>>b>>c>>d;
	if((a<b)&&(b<c)){
		cout<<"Yes";
	}
	else{
			do{
		k++;
		if(a>=c){
			c=c*2;
		}
		else{
			if(b<=a){
				b=b*2;
			}
			else{
				if(b>=c){
					c=c*2;
				}
			}
		}
		if((a<b)&&(b<c)){
			break;
		}
	}while(1<2);
	if(k<=d){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	}
}

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

int main() {
 int k,s;
  cin>>k>>s;
  int ans=0;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      int z=s-x-y;
      if(0<=z&&z<=k) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n; cin >> n;
  int m; cin >> m;
  set<int> red;
  vector<int> cur(n + 1, 1);
  red.insert(1);
  rep(i, m) {
    int x,y; cin >> x >> y;
    ++cur[y];
    --cur[x];
    if(red.find(x) != red.end()) {
      red.insert(y);
    }
    if(cur[x] < 1) {
      red.erase(x);
    }
  }

  cout << red.size() << endl;
}


Measured memory_bytes: 5376
N,M=map(int,input().split())
PY=[list(map(int,input().split()))+[i] for i in range(M)] #定義終了
 
PY.sort(key= lambda x:x[1])
num=[0]*N
w=[""]*M
 
for p,y,i in PY:
	num[p-1]+=1
	w[i]=str(p).zfill(6)+str(num[p-1]).zfill(6)

for i in range(M):
  	print(w[i])


Measured memory_bytes: 32608
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		assert(p >= 0);
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
int main() {
	ll H, W, T;
	scanf("%lld%lld%lld", &H, &W, &T);
	// (kT, kT) = (0, 0) mod (H, W)
	ll numH = __gcd(H, T);
	ll numW = __gcd(W, T);
	ll h = H / numH;
	ll w = W / numW;
	ll d = __gcd(h, w);
	Mint ans = modex(Mint(2), h) + modex(Mint(2), w) + modex(Mint(2), d) - 3;
	ans = modex(ans, numH * numW);
	printf("%d\n", ans.val);
}


Measured memory_bytes: 256
import math
import itertools
N = int(input())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
a = []
for i in range(1,N+1):
    a.append(i)
junn = list(itertools.permutations(a))
flag = 0
for i in range(math.factorial(N)):
    if p == list(junn[i]):
        pp = i
        if flag == 1:
            break
        flag = 1
    if q == list(junn[i]):
        qq = i
        if flag == 1:
            break
        flag = 1
print(abs(pp-qq))

Measured memory_bytes: 8052
#include<stdio.h>

int main(void){
  int d,t,s;
  double result;
  
  scanf("%d",&d);
  scanf("%d",&t);
  scanf("%d",&s);
  
  result=(double)d/s;
  if(result <= t){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 1736
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[202][202] , m  ;
int FW[12][12];
int main ( ){
scanf("%d %d",&n,&m);
for ( int i = 0 ; i <= 9 ; i++){
 for ( int j = 0 ; j <= 9 ; j++ ){
    scanf("%d",&(FW[i][j]));
 }
}
for ( int k = 0 ; k <= 9 ; k++ )
    for ( int i = 0 ; i <= 9 ; i++ )
      for(int j = 0 ; j <= 9 ; j++ )
      FW[i][j] = min ( FW[i][j] , FW[i][k] + FW[k][j]);
int ANS = 0, x ;
for ( int i = 0 ; i < n ; i++ ){
     for ( int j = 0 ; j < m ; j++ ){
        scanf("%d",&x);
        if ( x == -1 ) continue;
        ANS += FW[x][1] ;
     }
}
printf("%d",ANS);
return 0 ;
}


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

using namespace std;
using ll = long long;

int main() {
	
	string s, t;
	
	cin >> s >> t;
	int tmp1;
	string twice_s = s + s;
	array<vector<int>, 26> next;
	for(int i=0; i<26; i++) {
		tmp1 = -1;
		for(int j=twice_s.length() - 1; j>=0; j--) {
			if (twice_s[j] == 'a' + i) tmp1 = 1;
			next[i].push_back(tmp1);
			//printf("next[%d][%d] = %d\n", i, j, tmp1);
			if (tmp1 != -1) tmp1++;
		}
	}
	
	ll ans = 0;
	int c = 0, tmp2;
	for(int i=0; i<t.length(); i++) {
		tmp2 = next[t[i] - 'a'][twice_s.length() - 1 - c];
		if (tmp2 == -1) {
			cout << -1 << endl;
			return 0;
		}
		ans += tmp2;
		//printf("(%c) tmp2 = %d, c = %d\n", t[i], tmp2, c);
		c = (c + tmp2) % s.length();
	}
	
	cout << ans << "\n";
	
	return 0;
}


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

int main (){
int n;
cin>>n;
int v[50],c[50];
int ans = 0;
for(int i =0;i<n;i++){
cin >> v[i];
}
for(int i =0;i<n;i++){
cin >> c[i];
if (v[i]-c[i]>0) ans += v[i]-c[i];
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)x.size()
using namespace std;
typedef long long ll;

int main() {
	int n, a[100010];
	scanf("%d",&n);
	int c=0;
	multiset<int> st;
	for(int i=1; i<=n; i++) {
		scanf("%d",a+i);
		auto it=st.lower_bound(a[i]);
		if(it!=st.begin()) {
			it--;
			st.erase(st.find(*it));
		} else c++;
		st.insert(a[i]);
	}
	printf("%d",c);
	return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define MAXN 100002
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL {printf("-1\n"); return 0;}

int N, W;

LL dp[MAXN];
LL ans;
int B[MAXN];

int main(int argc, char **argv)
{
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d %d", &N, &W);
    B[0] = 1;
    for (int i = 0; i < N; i++) {
        int w,v;
        scanf("%d %d", &w, &v);
        for (int k = W; k-w >= 0; k--) {
            if (B[k-w]) {
                B[k] = 1;
                dp[k] = max(dp[k], dp[k-w] + v);
                ans = max(ans, dp[k]);
            }
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  ll q, h, s, d;
  cin >> q >> h >> s >> d;
  ll n;
  cin >> n;
  ll one = min(q * 4, min(h * 2, s));
  ll two = min(one * 2, d);
  if (2 * one < two)
  {
    cout << one * n << endl;
  }
  else
  {
    cout << two * (n / 2) + (one * (n % 2)) << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=998244353;
inline int addmod(int x)
{
	return x>=mod?x-mod:x;
}
inline int submod(int x)
{
	return x<0?x+mod:x;
}
int fpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=1ll*ans*x%mod;
		x=1ll*x*x%mod;
		y/=2;
	}
	return ans;
}
int n,a[1000005],f[1000005],g[1000005],tans[1000005],inv2;
void fwt(int *a)
{
	for(int k=1;k<(1<<n);k<<=1)
		for(int i=0,r=k*2;i<(1<<n);i+=r)
			for(int j=0;j<k;j++)
			{
				int x=a[i+j],y=a[i+j+k];
				a[i+j]=addmod(x+y);
				a[i+j+k]=submod(x-y);
			}
}
int main()
{
	inv2=fpow(2,mod-2);
	scanf("%d",&n);
	int sum=0;
	for(int i=0;i<(1<<n);i++)
	{
		scanf("%d",&a[i]);
		sum=addmod(sum+a[i]);
	}
	sum=fpow(sum,mod-2);
	for(int i=0;i<(1<<n);i++)
		a[i]=1ll*a[i]*sum%mod;
	fwt(a);
	int ct=0;
	for(int i=0;i<(1<<n);i++)
	{
		f[i]=fpow(submod(1-a[i]),mod-2);
		if(a[i]==1) ct++;
	}
	fwt(f);
	printf("0\n");
	for(int i=1;i<(1<<n);i++)
	{
		int ans=1ll*submod(f[0]-f[i])*fpow(ct,mod-2)%mod;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 4964
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,Q;cin>>N>>Q;
  
  vector<pair<int,int>> combination(N-1);
  vector<int> ans(N);
  for(int i=0;i<N-1;i++)cin>>combination.at(i).first>>combination.at(i).second;
  sort(combination.begin(),combination.end());
  
  int a,b;
  for(int i=0;i<Q;i++){
    cin>>a>>b;
    ans.at(a-1)+=b;
  }
  
  for(int i=0;i<N-1;i++)ans.at(combination.at(i).second-1)+=ans.at(combination.at(i).first-1);
  
  for(int i=0;i<N;i++)cout<<ans.at(i)<<" ";
  cout<<endl;
}

Measured memory_bytes: 4736
fn main() {
    let abcd = read_vec::<u64>();
    let a = abcd[0];
    let b = abcd[1];
    let c = abcd[2];
    let d = abcd[3];

    let n = b - a + 1;
    let lcm = c * d / gcd(c, d);
    let d = {
        let c_div = b / c - (a - 1) / c;
        let d_div = b / d - (a - 1) / d;
        let cd_div = b / lcm - (a - 1) / lcm;
        c_div + d_div - cd_div
    };

    println!("{}", n - d);
}

fn gcd(a: u64, b: u64) -> u64 {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

/**
 * The Code A Doctor Loved
 */
public class Main {

	static final HashMap<Character, String> c1 = new HashMap<Character, String>(32) {
		{
			put(' ', "101");
			put('\'', "000000");
			put(',', "000011");
			put('-', "10010001");
			put('.', "010001");
			put('?', "000001");
			put('A', "100101");
			put('B', "10011010");
			put('C', "0101");
			put('D', "0001");
			put('E', "110");
			put('F', "01001");
			put('G', "10011011");
			put('H', "010000");
			put('I', "0111");
			put('J', "10011000");
			put('K', "0110");
			put('L', "00100");
			put('M', "10011001");
			put('N', "10011110");
			put('O', "00101");
			put('P', "111");
			put('Q', "10011111");
			put('R', "1000");
			put('S', "00110");
			put('T', "00111");
			put('U', "10011100");
			put('V', "10011101");
			put('W', "000010");
			put('X', "10010010");
			put('Y', "10010011");
			put('Z', "10010000");
		}
	};

	static final HashMap<String, Character> c2 = new HashMap<String, Character>(32) {
		{
			put("00000", 'A');
			put("00001", 'B');
			put("00010", 'C');
			put("00011", 'D');
			put("00100", 'E');
			put("00101", 'F');
			put("00110", 'G');
			put("00111", 'H');
			put("01000", 'I');
			put("01001", 'J');
			put("01010", 'K');
			put("01011", 'L');
			put("01100", 'M');
			put("01101", 'N');
			put("01110", 'O');
			put("01111", 'P');
			put("10000", 'Q');
			put("10001", 'R');
			put("10010", 'S');
			put("10011", 'T');
			put("10100", 'U');
			put("10101", 'V');
			put("10110", 'W');
			put("10111", 'X');
			put("11000", 'Y');
			put("11001", 'Z');
			put("11010", ' ');
			put("11011", '.');
			put("11100", ',');
			put("11101", '-');
			put("11110", '\'');
			put("11111", '?');
		}
	};

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {
			//
			if (line.isEmpty()) {
				System.out.println("");
				continue;
			}
			StringBuilder sb1, sb2;
			sb1 = new StringBuilder();
			sb2 = new StringBuilder();
			for (char c : line.toCharArray()) {
				sb1.append(c1.get(c));
			}
			//
			sb1.append("00000");
			//
			String line2 = sb1.toString();
			for (int i = 0; i < line2.length() - 5; i += 5) {
				sb2.append(c2.get(line2.substring(i, i + 5)));
			}
			System.out.println(sb2.toString());
		}
	}
}

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

int main() {
 
  int n;
  cin>>n;
  string s;
  cin>>s;
  int k=n/2;
  int m=0;
  if(n%2==1){
    cout<<"No"<<endl;
  }
 else{
  for (int i = 0; i <k ; i++) {
    if(s.at(i)==s.at(i+k)){
      m=m+1;
    }
  }
    if(m==k){
      cout <<"Yes"<< endl;
}
  else{
    cout<<"No"<<endl;
  }
 }
}
  


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int main ()
{
    int N; cin >> N;
    vector < int > a(N);
    REP(i,N) cin >> a[i];

    map < int,int > cnt;
    REP(i,N) cnt[a[i]]++;

    if (cnt.size() > 2) {
        cout << "No" << endl;
        return 0;
    }

    vector < pair < int,int > > ord;
    for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
        ord.push_back(make_pair(itr->first, itr->second));
    }

    if (ord.size() == 1) {
        if (ord.front().first != N - 1) {
            bool flag = true;
            REP(i,N) {
                if (a[i] * 2 > N) {
                    flag = false;
                }
            }
            if (flag) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "Yes" << endl;
        }
        return 0;
    }

    if (ord.front().first + 1 != ord.back().first) {
        cout << "No" << endl;
        return 0;
    }

    int A = ord.back().first;
    int B = ord.front().first;

    if (A != B + 1) {
        cout << "No" << endl;
        return 0;
    }

    int y = ord.back().second;
    int x = ord.front().second;

    if (x < A && 2 * (A - x) <= y) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 5376
// https://atcoder.jp/contests/arc073/tasks/arc073_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w;
    cin >> n >> w;
    vector<vector<ll>> g(4), f(4);
    int idx = 0;
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        if (i == 0)
            idx = a;
        g[a - idx].push_back(b);
    }
    // 各重さで価値が大きい順にソート
    for (auto &x : g) {
        sort(ALLR(x));
    }
    REP(i, 4) {
        ll sum = 0;
        f[i].push_back(0);
        for (auto &x : g[i]) {
            sum += x;
            f[i].push_back(sum);
        }
    }
    int fin = w / idx + 1;
    ll maxv = 0;
    REP(i, min(fin, (int)f[0].size()))
    REP(j, min(fin, (int)f[1].size()))
    REP(k, min(fin, (int)f[2].size()))
    REP(l, min(fin, (int)f[3].size())) {
        ll weight = i * idx + j * (idx + 1) + k * (idx + 2) + l * (idx + 3);
        ll value = f[0][i] + f[1][j] + f[2][k] + f[3][l];
        if (weight > w)
            break;
        maxv = max(maxv, value);
    }
    cout << maxv << endl;

    return 0;
}


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

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a.at(i);
  }
  if (h <= sum) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n;
int a[200000][3];
int dp[200000][3];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int z = 0; z < 3; z++) {
				if (i > 0 && j == z) continue;
				dp[i + 1][z] = max(dp[i + 1][z], dp[i][j] + a[i][z]);
			}
		}
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(16);
    int n; cin >> n;
    vector<int> a(n+2);
    a[0] = 0;
    rep(i,n) cin >> a[i+1];
    a[n+1] = 0;
    vector<int> way(n+2); way[0] = 0;
    rep(i,n+1) way[i+1] = way[i] + abs(a[i+1] - a[i]);
    rep(i,n) cout << way[i] + (way[n+1]-way[i+2]) + abs(a[i+2]-a[i]) << endl;
    return 0;
}


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

ll mod = 1000000007;

ll modpower(ll a, ll r){ //a^r
    ll x = 1;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a){
    return modpower(a, mod-2);
}

int main(){
    int n;
    cin >> n;
    vector<ll> check(n+1, 0);
    ll l, r;
    for (int i = 1; i <= n+1; i++) {
        ll a;
        cin >> a;
        if (check[a] > 0){
            l = check[a];
            r = i;
            break;
        }
        else check[a] = i;
    }
    
    vector<ll> factorial(n+2, 1);
    for (int i = 1; i <= n+1 ; i++) {
        factorial[i] = (factorial[i-1] * i) % mod;
    }
    
    for (int k = 1; k <= n+1; k++) {
        ll a = (factorial[n+1] * modinv(factorial[k]) % mod) * modinv(factorial[n+1-k]) % mod;
        ll b = 0;
        if (n-r+l-k+1 >= 0) b = ((factorial[n-r+l] * modinv(factorial[k-1])) % mod) * modinv(factorial[n-r+l-k+1]) % mod;
        cout << (a-b+mod) % mod << "\n"; 
    }
    
}

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

int main(){
  int n;
  std::cin >> n;
  std::vector<T> abc(n);
  std::vector<std::vector<int> > cost(n,std::vector<int>(3,0));
  rep(i,n){
    int a,b,c;
    std::cin >> a>>b>>c;
    abc[i]=T(a,b,c);
  }

  cost[0][0]=get<0>(abc[0]);
  cost[0][1]=get<1>(abc[0]);
  cost[0][2]=get<2>(abc[0]);

  rep(i,n){
    if(i+1<n){
         cost[i+1][0] = max(cost[i+1][0], cost[i][1]+get<0>(abc[i+1]));
         cost[i+1][0] = max(cost[i+1][0], cost[i][2]+get<0>(abc[i+1]));

         cost[i+1][1] = max(cost[i+1][1], cost[i][0]+get<1>(abc[i+1]));
         cost[i+1][1] = max(cost[i+1][1], cost[i][2]+get<1>(abc[i+1]));

         cost[i+1][2] = max(cost[i+1][2], cost[i][0]+get<2>(abc[i+1]));
         cost[i+1][2] = max(cost[i+1][2], cost[i][1]+get<2>(abc[i+1]));
    }
  }
  std::cout << max(max(cost[n-1][0],cost[n-1][1]),cost[n-1][2]) << '\n';



}


Measured memory_bytes: 6912
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  string s, t; cin >> s >> t;
  vector<int> S(26, -1);
  vector<int> T(26, -1);
  for(int i = 0; i < s.size(); i++) {
    int si = s[i] - 'a';
    int ti = t[i] - 'a';
    if(S[si] == -1) {
      S[si] = ti;
    } else {
      if(S[si] != ti) {
        cout << "No" << endl;
        return 0;
      }
    }

    if(T[ti] == -1) {
      T[ti] = si;
    } else {
      if(T[ti] != si) {
        cout << "No" << endl;
        return 0;
      }
    }
  } 

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


Measured memory_bytes: 904
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

vector<pair<ll, ll>> pF;


void prime_fact(ll n){
// 素因数分解
for(ll i = 2; i * i <= n; i ++){
ll cnt = 0;
while(n % i == 0){
cnt ++;
n /= i;
}
pair<ll, ll> f = {i, cnt};
pF.push_back(f);
}
if(n != 1){
pF.push_back({n, 1});
}
}


int main(){
    int N;
    int M;
    cin >> N >> M;
    vector<int> yakusu;
    for(int i = 1; i * i <= M; i ++){
        if(M % i == 0){
            yakusu.push_back(i);
            yakusu.push_back(M / i);
        }
    }

    int ans = 0;
    rep(i, yakusu.size()){
        int tmp = M / yakusu[i];
        if(tmp >= N) {
            ans = max(yakusu[i], ans);
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef pair<int,int> P;
const int INF = 1<<30;

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


int main(){
    int sx,sy,gx,gy;cin >> sx >> sy >> gx >> gy;
    int n;cin >> n;
    set<P> st;
    for (int i = 0; i < n; i++) {
        int x,y;
        cin >> x >> y;
        st.insert({y,x});
    }
    int lx,ly;cin >> lx >> ly;
    deque<pair<pair<int,P>,P>> q;
    bool dp[202][202][6][2];
    memset(dp,false,sizeof(dp));
    q.push_back({{0,{0,0}},{sy,sx}});
    while(!q.empty()){
        int t = q.front().first.first;
        int d = q.front().first.second.second;
        int f = q.front().first.second.first;
        int u = q.front().second.second;
        int v = q.front().second.first;
        q.pop_front();
        if(v==gy&&u==gx){
            cout << d << endl;
            return 0;
        }
        if(dp[v+100][u+100][t][f]) continue;
        dp[v+100][u+100][t][f]=true;
        int s=abs(u)*abs(v)*t%6;
        for (int i = 0; i < 6; i++) {
            int nx = u + dx[(u+1000)%2][i];
            int ny = v + dy[(u+1000)%2][i];
            if(-lx<=nx&&nx<=lx&&-ly<=ny&&ny<=ly){
                if(st.find({ny,nx})==st.end()){
                    if(s==i) q.push_front({{(t+1)%6,{f,d}},{ny,nx}});
                    else q.push_back({{(t+1)%6,{f,d+1}},{ny,nx}});
                }
            }
        }
        if(!f) q.push_back({{(t+1)%6,{1,d+1}},{v,u}});
    }
    cout << "-1" << endl;
    return 0;
}




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

#define maxn
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int main() {
    //freopen("bestby.inp", "r", stdin);
    int a, b, x;
    //freopen("", "w", stdout);
    //ios::sync_with_stdio(0); cin.tie(0);
    scanf("%d%d%d", &x, &a,  &b);
    b -= a;
    if (b<=0) printf("delicious");
    else if (b<=x) printf("safe");
    else printf("dangerous");
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 1,0 },{ 0,1 }
};



signed main() {
	string nex[3];
	
	
	REP(i, 3) {
		char buf[10000];
		scanf("%s",buf);
		nex[i] = buf;
	}
	int next = 0;
	while (1) {
		if (nex[next].empty())
			break;
		char buf = nex[next][0];
		nex[next].erase(nex[next].begin());
		next = buf-'a';
	}
	printf("%c\n", next+'A');
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void InsertionSort(int A[], int N);

int main(void){
	
	int n;
	scanf("%d",&n);
	
	int a[n];
	
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	InsertionSort(a, n);
	
	return 0;

}

void InsertionSort(int A[], int N)
{

	int i,j,k,v;
	
	for(i=1;i<N;i++){
		
		for(k=0;k<N-1;k++){
			printf("%d ",A[k]);
		}
		printf("%d",A[k]);
		printf("\n");
		
		v = A[i];
		j = i-1;
		
		while (j >= 0 && A[j] > v){
		
			A[j+1] = A[j];
			j--;
		
		}
		
		A[j+1] = v;
	
	}
	
	for(k=0;k<N-1;k++){
		printf("%d ",A[k]);
	}
	printf("%d",A[k]);
	printf("\n");

}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
char ch[N],st[N];
int top=0;
int main()
{
    int n,m;scanf("%s",ch+1),n=strlen(ch+1);
    for(int i=1;i<=n;i++)
    {
        int f=1;
        if(ch[i]=='T')
            {if(top&&st[top]=='S')top--,f=0;}
        if(f)st[++top]=ch[i];
    }
    printf("%d\n",top);
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < 10; ++i) {
        if (i == 3) {
            cout << '8';
        }
        else {
            cout << s[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}


int main()
{
    run;
    string s,t;
    cin>>s>>t;
    ll f=0;
    if(t.length()!=1+s.length())
    {
        cout<<"No";
        return 0;

    }
    fr(i,0,s.length())
    {
        if(s[i]==t[i])
        {

        }else{
        f=1;}
    }
    if(f)
    {
        cout<<"No";
    }else{
    cout<<"Yes";}



}


Measured memory_bytes: 3652
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
const int N = 1e5+2;
signed main()
{
    fast;
    int n;
    cin>>n;
    int a[n+1];
    int odd[N]={};
    int even[N]={};
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i&1)
            odd[a[i]]++;
        else even[a[i]]++;
    }
    int val1,val2;
    int mx1=-1,mx2=-1;
    for(int i=1;i<=N-1;i++)
    {
        if(odd[i]>mx1)
        {
            mx1= odd[i];
            val1 = i;
        }
        if(even[i]>mx2)
        {
            mx2 = even[i];
            val2 = i;
        }
    }
    if(val1 == val2)
    {
        sort(even,even+N);
        sort(odd,odd+N);
        int ans1 = even[N-1]+odd[N-2];
        int ans2 = even[N-2]+odd[N-1];
        cout<<n-max(ans1,ans2);
    }
    else
        cout<<n-(mx1+mx2);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	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;
	return 0;
}

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

int N;
int A[16];

int main() {
    cin >> N;
    int x[16][16], y[16][16];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }

    int ans = 0;
    for (int bit = 0; bit < (1<<N); bit++) {
        bool f = true;
        for (int i = 0; i < N; i++) {
            if (bit & (1<<i)) {
                for (int j = 0; j < A[i]; j++) {
                    if (((bit >> (x[i][j] - 1)) & 1) != y[i][j]) {
                        f = false;
                        break;
                    }
                }
            }

            if (!f) break;
        }

        if (f) {
            bitset<16> bt(bit);
            ans = max(ans, (int)bt.count());
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// Problem : B - Common Raccoon vs Monster
// Contest : AtCoder - AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n,a,s;
    cin>>s>>n;
    int t = 0;
    for(int i=0;i<n;i++) cin>>a, t += a;
    if(t>=s) cout<<"Yes\n";
    else cout<<"No\n";
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String a = scan.next();

        Pattern p = Pattern.compile("[a-z]+");
        Matcher m = p.matcher(a);

        if (m.find()) {
            System.out.println("a");
        } else {
            System.out.println("A");
        }

    }
}

Measured memory_bytes: 35656
#include<cstdio>
int main() {
	int n, k, x, y;
	scanf("%d%d%d%d", &n, &k, &x, &y);
	if (n <= k) {
		printf("%d", n*x);
	}
	else {
		printf("%d", k*x + (n - k)*y);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n, h;
    cin >> n >> h;
    vector<ll> q;
    vector<ll> v;
    for (ll i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        v.push_back(a);
        q.push_back(b);
    }
    sort(ALL(v));
    sort(ALL(q));
    ll i = n - 1;

    ll max = v[n - 1];

    ll ans = 0;
    while (h > 0)
    {
        if (max >= q[i] || i < 0)
        {
            ll t;
            if(h%max==0){
                t = h / max;
            }
            else{
                t = h / max + 1;
            }
            h -= max * t;
            ans += t;
        }
        else
        {
            h -= q[i];
            i--;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2036
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {

	int R, B, W, G;
	cin >> R >> B >> W >> G;
	cout << R + B + W + G << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

const int mod = 1e9+7;

inline void add(int &x, int y)
{
	x += y;
	if (x >= mod)
		x -= mod;
}

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	string s;
	cin >> s;

	int n = s.length();

	vector<vector<int>> dp(13, vector<int>(n+1));
	dp[0][0] = 1;

	for (int i = 0; i < n; ++i)
	{
		vector<int> t(10);
		iota(t.begin(), t.end(), 0);
		if (s[i] != '?')
		{
			t.clear();
			t.push_back(s[i]-'0');
		}

		for (int k = 0; k < 13; ++k)
			for (auto j : t)
				add(dp[(k*10+j)%13][i+1], dp[k][i]);
	}

	cout << dp[5][n] << "\n";

	return 0;
}


Measured memory_bytes: 5968