akhauriyash/Code-Regression huggingface dataset:
NUM_C = 17;

### subroutines

def n_grp(i)
  (i % 5 == 1) ? 5 : 2;
end

def t_grp(i)
  17 * (i % 2) + 3 * (i % 3) + 19
end

def find_seats(seats, n)
  st = 0
  while st < NUM_C
    while st < NUM_C && ! seats[st].nil?
      st += 1
    end

    k = 0;
    while st + k < NUM_C && seats[st + k].nil?
      k += 1
      return st if k >= n
    end
    st += k
  end
  nil
end

### main

seats = (0...NUM_C).map{nil}

t = 0
queue = []
waits = []

while (t < 500 || ! queue.empty?)
  # check if customers finish eating
  for i in (0...NUM_C)
    if ! seats[i].nil? && seats[i][1] == t
      seats[i] = nil
    end
  end

  # check if new group arrives
  if t < 500 && t % 5 == 0
    i = t / 5
    queue.push [i, n_grp(i), t_grp(i)]
  end

  # check if seats are available
  while ! queue.empty?
    gid, gn, gtime = queue[0]
    sid = find_seats(seats, gn)
    break if sid.nil?

    ginfo = [gid, t + gtime]
    for i in (0...gn)
      seats[sid + i] = ginfo
    end

    waits[gid] = t - 5 * gid

    queue.shift
  end

  # print current status
  #p [t, [seats]]

  # next time
  t += 1
end

#p waits

while (line = gets)
  gid = line.strip.to_i

  puts waits[gid]
end

Measured memory_bytes: 6116
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s.at(0)==s.at(1)&&s.at(1)!=s.at(2)&&s.at(2)==s.at(3))cout<<"Yes"<<endl;
    else if(s.at(0)==s.at(2)&&s.at(2)!=s.at(1)&&s.at(1)==s.at(3))cout<<"Yes"<<endl;
    else if(s.at(0)==s.at(3)&&s.at(3)!=s.at(1)&&s.at(1)==s.at(2))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

const ll N=25,mod=1e9+7;

ll n,a[N][N],mem[N][1<<(22)];

ll dp(int pos,int mask)
{
    if (pos==n)
    {
        return 1;
    }
    if (mem[pos][mask]!=-1)return mem[pos][mask];
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        if (mask&(1<<i)&&a[pos][i])
        {
            ans+=dp(pos+1,mask-(1<<i));
            ans%=mod;
        }
    }
    ans%=mod;
    return mem[pos][mask]=ans;
}

int main()
{
    memset(mem,-1,sizeof mem);
    cin >> n;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
            cin >> a[i][j];
        }
    }
    cout << dp(0,(1<<n)-1) << endl;
    return 0;
}


Measured memory_bytes: 819456
//
//  main.cpp
//  DPm2

#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
//const ll INF=1e18;
//const int mod = 998244353;
const int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
//istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int a[110];
int dp[110][100010];
bool flag[110][100010];

ll f(ll n,ll k){
    if(k==0) {
        dp[n][k]=1;
        return 1; // お菓子が０個なら分け合う方法は１通り
    }
    if(n==1&&k==a[1]){
        dp[n][k]=1;
        return 1; // 一人の時、全部もらえるならOK
    }
    if(n==1&&k>a[1]){
        dp[n][k]=0;
        return 0; // 一人の時、お菓子が多すぎたらNG
    }
    if(n<1) return 0;
    if(flag[n][k]==true){
        return dp[n][k]%mod;
    }
    int sum=0;
    if(k-1-a[n]>=0){
        sum=((f(n,k-1)+f(n-1,k))%mod-f(n-1,k-1-a[n])+mod)%mod;
    }else{
        sum=(f(n,k-1)+f(n-1,k))%mod;
    }
    flag[n][k]=true;
    return dp[n][k]=sum;
}
int main(int argc, const char * argv[]) {
    ll n,k;
    cin>>n>>k;

    rep(i,n){
        cin>>a[i+1];
    }
    cout<<f(n,k)<<endl;
    return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int main(){
  int N, M, sum = 0;
  cin >> N;
  vector<int> T(N);
  REP(i, N){
    cin >> T[i];
    sum += T[i];
  }
  cin >> M;
  vector<int> P(M), X(M);
  REP(i, M){
    cin >> P[i] >> X[i];
  }
  REP(i, M){
    cout << sum - T[P[i]-1] + X[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
#define cu cout<<
#define en endl
#define sp " "
#define RE(i,n) for(int i=0,_n=(n);i<_n;++i)
#define RI(i,n) for(int i=1,_n=(n);i<=_n;++i)
#include<cstdio>
#include<cstring>
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                pe[j] = false;
        }
    }
}*/
/*bool isprime(ll n)
{
    if(n<2) return 0;
    if(n==2) return 1;
    else
    {
        for(int i=2; i*i<=n; i++)
            if(n%i==0) return 0;
    }
    return 1;
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}

int main()
{
    fast ;
    string s,ss;
    cin >> s>>ss;
    int c = 0;
    for(int i=0; i<s.sz; i++)
    {
        if(s[i]!=ss[i])
            c++;
    }
    cout <<c<<endl;
}



Measured memory_bytes: 3808
import Data.STRef
import Control.Monad
import Control.Monad.ST
  
main :: IO()
main = getLine >> getContents >>= print.(\(x:y:xs) -> solve (y - x) (min x y) xs).map read.lines
  
solve :: Int -> Int -> [Int] -> Int
solve a b xs = runST $ do
                a' <- newSTRef a
                b' <- newSTRef b
                forM_ xs $ \z -> do
                    x <- readSTRef a'
                    y <- readSTRef b'
                    if (z - y > x) then writeSTRef a' (z - y) else return ()
                    if (z < y)     then writeSTRef b' z       else return ()
                readSTRef a'

Measured memory_bytes: 5564
#include<iostream>
using namespace std;
int main()
{
	int n,h[1024][1024]={0},count=0;
	char s[1024];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	h[0][0]++;
	for(int i=0;i<n;i++){
			switch(s[i]){
				case 'J':
				h[i+1][0]+=(h[i][0]+h[i][3]+h[i][5]+h[i][6])%10007;
                h[i+1][3]+=(h[i][0]+h[i][1]+h[i][3]+h[i][4]+h[i][5]+h[i][6])%10007;
                h[i+1][5]+=(h[i][0]+h[i][2]+h[i][3]+h[i][4]+h[i][5]+h[i][6])%10007;
                h[i+1][6]+=(h[i][0]+h[i][1]+h[i][2]+h[i][3]+h[i][4]+h[i][5]+h[i][6])%10007;
				break;

				case 'O':
				h[i+1][1]+=(h[i][1]+h[i][3]+h[i][4]+h[i][6])%10007;
                h[i+1][3]+=(h[i][0]+h[i][1]+h[i][3]+h[i][4]+h[i][5]+h[i][6])%10007;
                h[i+1][4]+=(h[i][1]+h[i][2]+h[i][3]+h[i][4]+h[i][5]+h[i][6])%10007;
                h[i+1][6]+=(h[i][0]+h[i][1]+h[i][2]+h[i][3]+h[i][4]+h[i][5]+h[i][6])%10007;
				break;
				case 'I':
				h[i+1][2]+=(h[i][2]+h[i][4]+h[i][5]+h[i][6])%10007;
                h[i+1][4]+=(h[i][1]+h[i][2]+h[i][3]+h[i][4]+h[i][5]+h[i][6])%10007;
                h[i+1][5]+=(h[i][0]+h[i][2]+h[i][3]+h[i][4]+h[i][5]+h[i][6])%10007;
                h[i+1][6]+=(h[i][0]+h[i][1]+h[i][2]+h[i][3]+h[i][4]+h[i][5]+h[i][6])%10007;
				break;
		}
	}
	for(int i=0;i<7;i++){
		count+=h[n][i];
	}
	count=count%10007;
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 5264
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(std::string S){
    int count = 0;
    REP(i, S.size())
        if (S[i] == 'o') count++;
    cout << 700 + 100 * count << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

ans = 0

for i in range(1, n+1):
    m = i
    cnt = 0
    for j in range(1, 101):
        if m >= k:
            break
        else:
            m = m * 2
            cnt += 1
    ans += (1 / n) * (0.5**cnt)

print(ans)

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

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

using namespace std;
using lint=long long;

class linear_sieve{
	vector<int> lpf,p;
public:
	linear_sieve(int n):lpf(n+1){
		for(int i=2;i<=n;i++){
			if(lpf[i]==0){
				lpf[i]=i;
				p.emplace_back(i);
			}
			for(int j=0;j<p.size()&&p[j]<=lpf[i]&&i*p[j]<=n;j++) lpf[i*p[j]]=p[j];
		}
	}

	const vector<int>& primes()const{ return p; }

	bool is_prime(int a)const{
		assert(a<=(int)lpf.size()-1);
		return a>0 && lpf[a]==a;
	}

	map<int,int> prime_factorize(int a)const{
		assert(a<=(int)lpf.size()-1);
		map<int,int> pf;
		for(;a>1;a/=lpf[a]) ++pf[lpf[a]];
		return pf;
	}

	int number_of_divisors(int a)const{
		assert(a<=(int)lpf.size()-1);
		int res=1,cnt=0,pre=-1;
		for(;a>1;a/=lpf[a]){
			if(pre==-1 || pre==lpf[a]){
				cnt++;
			}
			else{
				res*=cnt+1;
				cnt=1;
			}
			pre=lpf[a];
		}
		return res*(cnt+1);
	}
};

int main(){
	int n; scanf("%d",&n);

	linear_sieve LS(n);

	lint ans=0;
	for(lint k=1;k<=n;k++) ans+=k*LS.number_of_divisors(k);
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 46520
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using std::swap;

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

/*
int main() {
    vector<char> s;
    string S;
    std::cin >> S;
    for(int i=0; i<4; i++){
        s.push_back(S[i]);
    }
    std::sort(s.begin(), s.end());
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[3]){
        std::cout << "Yes" << std::endl;
        return 0;
    }
    else{
        std::cout << "No" << std::endl;
        return 0;
    }
}
*/
/*
int main(){
    int N;
    std::cin >> N;
    int a[N];
    int count =0;
    for(int i=0; i<N; i++){
        std::cin >> a[i];
    }
    for(int i=1; i<N-1; i++){
        if((a[i]-a[i-1])*(a[i]-a[i+1])<0){
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}
*/

/*
int main(){
    int a,N;
    std::cin >> N;
    vector<int> q;
    for(int i=0; i<N; i++){
        std::cin >> a;
        q.push_back(a);
    }
    std::sort(q.begin(), q.end());
    std::cout << q[N/2]-q[N/2-1]<< std::endl;
    return 0;
}
 */


int main(){
    int N, K;
    unsigned int q=pow(10,9)+7;
    long long int red, blue;
    std::cin >> N >> K;
    unsigned int **C = new unsigned int*[N+1];
    for (int i = 0; i < N+1; i++) {
        C[i] = new unsigned int[N+1];
    }

    for(int i=0; i<N+1; i++){
        for(int j=0; j<N+1; j++){
            C[i][j]=0;
        }
    }
    C[0][0]=1;
    for(int i=1; i<N+1; i++){
        C[i][0]=1;
        for(int j=1; j<i+1; j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%q;
        }
    }

    for(int i=1; i<=K; i++){
        if(i>(N+1)/2){
            std::cout<< 0 << std::endl;
        }
        else{
            red=C[N-K+1][i];
            blue=C[K-1][i-1];
            std::cout << (red*blue) % q << std::endl;
        }
    }

    for (int i = 0; i < N+1; i++) {
        delete[] C[i];
    }
    delete[] C;



    return 0;
}

Measured memory_bytes: 15872
// fahadmd16(IIEST Shibpur)
#include<bits/stdc++.h>
using namespace std;

#define ll                                      long long
#define pb                                      push_back
#define pf                                      push_front
#define eb                                      emplace_back
#define mp                                      make_pair
#define ff                                      first
#define ss                                      second
#define db                                      double
#define pll                                     pair<ll, ll>
#define ALL(a)                                  (a).begin(),(a).end()
#define endl                                    "\n"

#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define ford(i, n) for (ll i = n - 1; i >= 0; i--)
#define ford1(i, n) for (ll i = n - 1; i >= 1; i--)
#define forab(i, a, b) for(ll i = a; i < b; i++)
#define forabd(i, a, b) for(ll i = a; i >= b; i--)
#define eps 1e-10

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)


#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define tracen( x , n ){ cout<<(#x)<<":";for(int i=0;i<n;i++)cout<<(#x)<<"["<<i<<"]:"<< x[i] << "    "; cout<<endl;}
#define tracenm( x , n , m ){ cout<<(#x)<<endl;for(int i=0;i<n;i++){ cout<<"Row #"<<i<<":"; for(int j=0;j<m;j++) cout<<x[i][j]<<"     "; cout << endl;}}
#define trace(v){ cout<<#v<<": ";for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;}
using namespace std;



const ll sz = 8000;
const ll mod = 1e9 + 7;
const db PI = acos(-1);



typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;



ll power(ll n, ll k, ll m) {
	ll ans = 1;
	while (k) {
		if (k & 1)ans = (ans * n) % m;
		k /= 2;
		n = (n * n) % m;
	}
	return ans;
}

void solver() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll move = 1;
	while (a > 0 && c > 0) {
		if (move & 1) {
			ll h2 = c - b;
			c = h2;
		}
		else {
			ll h1 = a - d;
			a = h1;
		}
		move++;
	}
	// ll h1 = c - b;
	// ll h2 = a - d;
	// trace2(a, c);

	if (c <= 0)cout << "Yes\n";
	else if (a <= 0)cout << "No\n";
	// else cout << "Yes\n";
}


int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	IOS;
	ll T = 1; //cin >> T;
	forn1(i, T + 1) {
		clock_t z = clock();
		solver();
		debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	}
	return 0;
}


Measured memory_bytes: 3772
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	int N, D;
	cin >> N >> D;
	int x = D * 2 + 1;
	int ans = (N + x - 1) / x;
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

S=input().rstrip()
T=input().rstrip()

ls=len(S)
lt=len(T)

cand=[]

for i in range(ls-lt+1):
	#print(S[i:i+lt])
	for j in range(lt):
		#print(S[i+j], T[j])
		if S[i+j]!=T[j] and S[i+j]!='?':
			break
	else:
		candidate=S[:i]+T+S[i+lt:]
		cand.append(candidate.replace('?','a'))

if cand:
	print(min(cand))
else:
	print('UNRESTORABLE')

Measured memory_bytes: 3064
n, m, x = [int(i) for i in input().split()]

books = [[int(i) for i in input().split()] for j in range(n)]

def check(lst):
    return all([i >= x for i in lst])

ans = float("inf")
for k in range(1<<n):
    lst = [sum([(books[i][sub+1] if (k & 1<<i != 0) else 0) for i in range(n)]) for sub in range(m)]
    if check(lst):
        ans = min(ans, sum([(books[i][0] if (k & 1<<i != 0) else 0) for i in range(n)]))

print(-1 if ans == float("inf") else ans)

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,i;
	long long a,b;
	string s;
	t = 1;
	while(t--) {
	 a = 0;
	 cin >> n;
	 map<string, int> mp;
	 for(i = 0; i < n; i++) {
	  cin >> s;
	  sort(s.begin( ), s.end( ));
	  mp[s]++;
	 }
	 map<string, int>::iterator itr;
	 for(itr = mp.begin(); itr != mp.end(); itr++) {
	  if(itr->second > 1) {
	   b = itr->second;
	   b = (b * (b - 1)) / 2;
	   a = a + b;
	  }
     }
	 cout << a << endl;
	}
	return 0;
}



Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
#define fi first
#define se second
typedef pair<long long, long long> pii;
bool cmp(pii a, pii b) {
  if (a.se == b.se) {
    return a.fi < b.fi;
  }
  return a.se < b.se;
}
int main() {
  int n;
  cin >> n;
  pii ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i].fi >> ar[i].se;
  }
  sort(ar, ar+n, cmp);
  long long tim = 0;
  for (int i = 0; i < n; i++) {
    tim += ar[i].fi;
    if (tim > ar[i].se) {
      cout << "No" << el;
      return 0;
    }
  } 
  cout << "Yes" << el;
  return 0;
}

Measured memory_bytes: 3328
<?php
$n = trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));
$q1 = 0; //偶数の数
$q2 = 0; //偶数かつ3または5の倍数の数
for ($i = 0; $i < $n; $i++) {
    if ($a[$i]%2==0 ) {
        $q1++;
        if ($a[$i]%3==0 or $a[$i]%5==0) {
            $q2++;
        }
    }
}
if ($q1==$q2) {
    echo "APPROVED" ."\n";
}else {
    echo "DENIED" ."\n";
}
?>

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
  string S;
  cin >> S;
  vector<string> DW = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
  int count = 0;
  for (;count<7;++count)
  {
    if(S==DW[count])
       break;
  }
  count +=1;
  cout << count;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct union_find{
	static const int DEFAULT = 200200;
	vector<int> parent;
	int N;
	union_find(int N = DEFAULT) : N(N) {
		clear();
	}
	void clear(){
		parent.assign(N, -1);
	}
	int find(int u){
		return (parent[u] < 0) ? u : parent[u] = find(parent[u]);
	}
	bool is_connected(int u, int v){
		return find(u) == find(v);
	}
	bool join(int u, int v){
		u = find(u);
		v = find(v);
		if (u != v){
			if (parent[u] > parent[v])
				swap(u, v);
			parent[u] += parent[v];
			parent[v] = u;
		}
		return u != v;
	}
	int size(int u){
		return -parent[find(u)];
	}
};
const int maxn = 200200;
vector<int> to[maxn];
long long cost[maxn], sz[maxn];
void dfs(int u, int p){
	sz[u] = 1;
	for(int v : to[u]){
		if(v == p) continue;
		dfs(v, u);
		sz[u] += sz[v];
		cost[u] += cost[v] + sz[v];
	}
}
int n;
void fix(int u, int p){
	if(p != -1){
		cost[u] = cost[p] + n - 2 * sz[u];
	}
	for(int v : to[u]){
		if(v == p) continue;
		fix(v, u);
	}
}
int main(){
	cin >> n;
	vector<pair<long long, int> > vals;
	map<long long, int> rev;
	union_find uf(n);
	long long sum = 0;
	for(int i = 0; i < n; i++){
		long long x; cin >> x;
		rev[x] = i;
		vals.push_back({x, i});
		sum += x;
	}
	if(sum&1){
		cout << -1 << endl;
		return 0;
	}
	vector<pair<int,int> > edges;
	sort(vals.rbegin(), vals.rend());
	for(int i = 0; i < n - 1; i++){
		long long cost; int u;
		tie(cost, u) = vals[i];
		int sz = uf.size(u);
		long long ncost = cost - n + 2 * sz;
		auto it = rev.find(ncost); 
		if(it == rev.end()){
			cout << -1 << endl;
			return 0;
		}
		int x = u, y = it->second;
		if(x == y){
			cout << -1 << endl;
			return 0;
		}
		if(x > y) swap(x, y);
		if(!uf.join(x, y)){
			cout << -1 << endl;
			return 0;
		}
		edges.push_back({x, y});
		to[x].push_back(y);
		to[y].push_back(x);
	}
	dfs(0, -1);
	fix(0, -1);
	vector<pair<long long, int> > nvals;
	for(int i = 0; i < n; i++) nvals.push_back({cost[i], i});
	sort(nvals.rbegin(), nvals.rend());
	if(nvals != vals){
		cout << -1 << endl;
		return 0;
	}
	sort(edges.begin(), edges.end());
	for(auto e : edges) cout << e.first + 1 << " " << e.second + 1 << endl;
	return 0;
}


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

void trace(int A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << A[i];
	}

	cout << endl;
}

void insertionSort(int A[], int N) {
	int v, j;
	for (int i = 1; i < N; i++) {

		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		
		trace(A, N);

	}
}


int main(void) {
	int N;
	int A[100];

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	trace(A, N);
	insertionSort(A, N);

	return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>
#include <math.h>
#include <string.h>
int main() {
	char s[11] = {};
	int min = 1000, num;
	scanf("%s", s);
	for (int i = 0; i < strlen(s); i++) {
		s[i] -= '0';
	}
	for (int i = 0; i < strlen(s) - 2; i++) {
		num = s[i] * 100 + s[i + 1] * 10 + s[i + 2];
		if (min > abs(num - 753)) {
			min = abs(num - 753);
		}
	}
	printf("%d", min);
	return 0;
}

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

#define APPLE "apple"
#define PEACH "peach"

int main(void)
{
	char str[1001];
	char temp[1001];
	int i = 0;
	
	fgets(str, 1000, stdin);
	
	while (str[i + 5] != '\0'){
		if (strncmp(&str[i], PEACH, 5) == 0){
			strcpy(temp, &str[i + 5]);
			str[i] = '\0';
			strcat(str, APPLE);
			strcat(str, temp);
		}
		else if (strncmp(&str[i], APPLE, 5) == 0){
			strcpy(temp, &str[i + 5]);
			str[i] = '\0';
			strcat (str, PEACH);
			strcat (str, temp);
		}
		i++;
	}
	
	printf("%s", str);
	
	return 0;
}

Measured memory_bytes: 536
solve :: String -> (Int, Int) -> (Int, Int)
solve [] lr = lr
solve (s:ss) (l, r) = solve ss (nextl, nextr)
    where d = if s == '(' then 1 else -1
          nextl = if d /= 1 && r == 0 then l + 1 else l
          nextr = max 0 (r + d)

main :: IO ()
main = do
  getLine
  s <- getLine
  let (l, r) = solve s (0, 0)
  putStrLn $ replicate l '(' ++ s ++ replicate r ')'

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

int main() {
  int n;
  while(cin >> n&&n!=0){
  int ans=0;
  n=1000-n;
  vector<int> c={500,100,50,10,5,1};
  r(i,6){
    int t=n/c[i];
    n-=t*c[i];
    ans+=t;
  }
  cout<<ans<<endl;
  }
}



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

#define reps(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)
const int INF = 0x3f3f3f3f;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  int cnt = 0;
  rep(i, h) cin >> s[i];
  rep(i, h) rep(j, w) cnt += (s[i][j] == '#');

  auto in = [&](int i, int j) -> bool {
    return 0 <= i && i < h && 0 <= j && j < w;
  };

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

  queue<pair<int, int>> que;
  vector<vector<int>> dist(h, vector<int>(w, INF));
  que.emplace(0, 0);
  dist[0][0] = 0;
  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    int y = p.first, x = p.second;
    rep(i, 4) {
      int ny = y + dy[i], nx = x + dx[i];
      if (!in(ny, nx) || s[ny][nx] == '#') continue;
      if (dist[y][x] + 1 < dist[ny][nx]) {
        dist[ny][nx] = dist[y][x] + 1;
        que.emplace(ny, nx);
      }
    }
  }
  if (dist[h - 1][w - 1] == INF) {
    cout << -1 << endl;
  } else {
    cout << h * w - dist[h - 1][w - 1] - cnt - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  map<ll,queue<ll> > que;
  ll ans=1,c=0;
  rep(i,n) {
    if(a[i]) {
      if(que[a[i]-1].empty()) {
        pr(0);
        return;
      }
      ll x=que[a[i]-1].size();que[a[i]-1].pop();
      ans*=x;
      ans%=MAX;
    } else c++;
    que[a[i]].push(i);
  }
  ll cnt=0;
  tr(it,que) cnt+=it->S.size();
  if(cnt>c||c>=4) {
    pr(0);
    return;
  }
  if(c==1) ans*=3;
  else ans*=6;
  ans%=MAX;
  pr(ans);
}

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


Measured memory_bytes: 72960
s = input()
t = input()

def main():
    m = float("inf")
    for i in range(len(s) - len(t) + 1):
        rr = 0
        r = ""
        for j in range(len(t)):
            r += s[i + j]
        for x in range(len(t)):
            if r[x] != t[x]:
                rr += 1
        
        m = min(m, rr)
    print(m)
    return 

main()       



Measured memory_bytes: 9124
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

N,X = inputIL()
M = inputILs(N)

m = min(M)
s = sum(M)

print(N + (X-s)//m)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }

    ll ans = 0LL;
    map<ll, ll> cnt;
    for(int i=0;i<n;++i) {
        ans += cnt[i - a[i]];
        ++cnt[a[i] + i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 27448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int H, W;
const ll MOD = 1e9+7;
vector<vector<char> > field;
vector<vector<ll> > memo;

signed main(){
	scanf("%d %d", &H, &W);
	field.resize(H, vector<char> (W));
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++) cin >> field[i][j];
	}
	memo.resize(H, vector<ll> (W, 0));
  memo[0][0] = 1;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(i + 1 < H && field[i + 1][j] == '.'){
				(memo[i + 1][j] += memo[i][j]) %= MOD;
			}
			if(j + 1 < W && field[i][j + 1] == '.'){
				(memo[i][j + 1] += memo[i][j]) %= MOD;
			}
		}
	}
	cout << memo[H - 1][W- 1] << endl;
}


Measured memory_bytes: 12264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

ll g(ll n) {
  return n*(n+1)/2;
}

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for(int i=1;i<=n;i++) {
    ans += i * g(n/i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i <= (n); i++)
#define repb(i, a, n) for (int i = (a); i >= (n); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
}

void co_elem(vector<int> &A) {
    rep(i, 0, A.size() - 1) {
        if (i < A.size() - 1) {
            cosp(A[i]);
        } else {
            co(A[i]);
        }
    }
}

void bubbleSort(vector<int> &A, int N, int &changed) {
    int flag = 1;
    int i = 0;
    while (flag) {
        flag = 0;
        repb(j, N - 1, i + 1) {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                flag = 1;
                changed++;
            }
        }
        i++;
    }
}

int main() {
    int N, changed = 0;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N - 1) {
        cin >> A[i];
    }
    bubbleSort(A, N, changed);
    co_elem(A);
    co(changed);
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define F first
#define S second

int main(void){
    int h,w,d; scanf("%d %d %d", &h, &w, &d);
    vector <pair<int,int>> data(1000000);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a; scanf("%d", &a);
            data[a] = {i,j};
        }
    }
    vector <int> c(900001);
    
    for(int i =1; i<=d; i++){
        int t = i;
    while(t<90001 ){
        c[t+d] = c[t] + abs(data[t].F-data[t+d].F) + abs(data[t].S-data[t+d].S);
        t+=d;
        }
    }
    int q; cin>>q;
    for(int i=0;i<q;i++){
        int a,b; cin>>a>>b;
        cout<<c[b]-c[a]<<endl;
    }
}


Measured memory_bytes: 12416
import java.awt.Point;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int t = sc.nextInt();
            int n = sc.nextInt();
            if ((t | n) == 0)
                break;
            int[][] map = new int[121][121];
            boolean[][] visited = new boolean[121][121];
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                int y = sc.nextInt();
                map[y + 60][x + 60] = -1;
            }
            Queue<Point> q = new LinkedList<Point>();
            int sx = sc.nextInt() + 60;
            int ans = 0;
            int sy = sc.nextInt() + 60;
            q.add(new Point(sx, sy));
            visited[sy][sx] = true;
            while (!q.isEmpty()) {
                Point p = q.poll();
                int x = p.x;
                int y = p.y;
                if (map[y][x] > t)
                    continue;
                ans++;
                int dx[] = { 1, 1, 0, -1, -1, 0 };
                int dy[] = { 0, 1, 1, 0, -1, -1 };
                for (int i = 0; i < 6; i++) {
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if (nx >= 0 && ny >= 0 && ny < 121 && nx < 121
                            && map[ny][nx] != -1) {
                        if (visited[ny][nx]) {
                            continue;
                        }
                        visited[ny][nx] = true;
                        map[ny][nx] = map[y][x] + 1;
                        q.add(new Point(nx, ny));
                    }
                }
            }
            System.out.println(ans);
//            for (int i = 0; i <= 60; i++) {
//                System.out.println(Arrays.toString(map[i]));
//            }
        }
    }
}

Measured memory_bytes: 14000
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

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

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
	string s;
	cin >> s;
	
	ll total = 0;
	ll b = 1 << (s.size() - 1);

	REPC(i, b) {
		string num;
		REPC(j, s.size()) {
			num += s[j];

			if (s.size() - 1 == j || i & (1 << (s.size() - 2 - j))) {
				total += stoll(num);
				num = "";
			}
		}
	}

	cout << total << endl;
  return 0;
}

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

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

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

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

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

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include<string.h>
using namespace std;
int main()
{
    char ch[2][3];
    for(int i = 0 ; i < 2; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            scanf("%c",&ch[i][j]);
        }
        getchar();
    }
    for(int i = 0 ; i < 2; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            if(ch[1-i][2-j]!=ch[i][j])
            {
                printf("NO");
                return 0;
            }
        }
    }
    printf("YES");
    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <string>

using namespace std;

int search(string s1, string s2) {
    int i;
    int times = 0;

    for (i=0;i<(s1.size()-s2.size()+1);i++) {
        if (s1.substr(i, s2.size()) == s2) {
            times++;
        }
    }

    return times;
}

int main() {
    while (1) {
        char input[10001];
        string tmp;

        if (scanf("%s", input) == EOF) return 0;
        tmp = input;

        printf("%d\n", search(tmp, "JOI"));
        printf("%d\n", search(tmp, "IOI"));
    }
}

Measured memory_bytes: 1080
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>

using namespace std;

bool ok(string s) {
  if (s[0] != 'A') return false;
  if (count(s.begin() + 2, s.end() - 1, 'C') != 1) return false;
  for (char c : s) {
    if (c != 'A' && c != 'C' && isupper(c)) return false;
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  cout << (ok(s) ? "AC" : "WA") << endl;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> board(n);

	for(int i=0; i<n; i++){
		cin >> board.at(i);
	}

	int count=0;
	bool flag = true;
	while(flag){
		for(int i=0; i<n; i++){
			if(board.at(i)%2 == 1){flag = false;}
			else{board.at(i) = board.at(i)/2;}
		}
		count++;
	}
	cout << count-1 << endl;
	return 0;
}


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

vector<ll> v[4];
vector<ll> w;
ll N, W;

ll rec(int i, int j) {
    ll res = 0;
    if (i == w.size()) {
        res = 0;
    }
    else if (j < w[i]) {
        res = rec(i+1, j);
    }
    else {
        res = rec(i+1, j);
        ll sum = 0;
        for (int k=0; k<v[i].size(); ++k) {
            sum += v[i][k];
            if (j >= w[i]*(k+1)) {
                res = max(res, rec(i+1, j-w[i]*(k+1))+sum);
            }
        }
    }
    return res;
}

int main() {
    cin >> N >> W;
    rep(i, N) {
        int wi, vi;
        cin >> wi >> vi;
        if (w.size() == 0) {
            w.push_back(wi);
            v[w.size()-1].push_back(vi);
        }
        else {
            bool f=true;
            rep(j, w.size()) {
                if (w[j] == wi) {
                    v[j].push_back(vi);
                    f=false;
                }
            }
            if (f) {
                w.push_back(wi);
                v[w.size()-1].push_back(vi);
            }
        }
    }
    rep(i, w.size()) {
        sort(v[i].begin(), v[i].end(), greater<ll>());
    }
    cout << rec(0, W) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a,b;
cin >>n>>a>>b;
string s;
cin >>s;
int genzai=0;
int genzai_f=0;
for(int i=0;i<n;i++){
string output;
if(s[i]=='a'){
if(genzai<a+b){
output = "Yes";
genzai++;
}
else{
output ="No";
}
}else if(s[i]=='b'){
if(genzai<a+b&&genzai_f<b){
output = "Yes";
genzai++;
genzai_f++;
}else{
output ="No";
}
}else{
  
output ="No";
}

cout << output <<endl;

}
}

Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N;
	cin >> N;
	vi L(N);
	for(int i=0; i<N; i++){
		cin >> L[i];
	}

	sort(L.begin(),L.end(),std::greater<int>());
	int count=0;

	for(int i=0; i<N-2; i++){
		for(int j=i+1; j<N-1; j++){
			for(int k=j+1; k<N; k++){
				if(L[i]<L[j]+L[k]) count++;
			}
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

vector<vector<int> > graph(1001);
vector<bool> isused(1001, false);


vector<int> findLoop(int now)
{
	for(int i = 0; i < graph[now].size(); i++){
		int next = graph[now][i];
		if(isused[next]){
			vector<int> ans;
			ans.push_back(next);
			ans.push_back(now);
			return ans;
		}
		isused[next] = true;
		vector<int> res = findLoop(next);
		isused[next] = false;
		if(res.size() > 0){
			if(res[0] != res[res.size() - 1]){
				res.push_back(now);
			}
			return res;
		}
	}
	return vector<int>();
}

vector<int> solve(vector<int> loop)
{

	int now = 0;
	vector<int> ans;
	map<int, int> m;
	for(int i = 0; i < loop.size(); i++){
		m[loop[i]] = i;
	}
	while(now < loop.size()){
		vector<int> v;
		for(int i = 0; i < graph[loop[now]].size(); i++){
			if(m.find(graph[loop[now]][i]) != m.end()) v.push_back(m[graph[loop[now]][i]]);
		}
		if(v.size() == 1){
			ans.push_back(loop[now]);
			now++;
		} else {
			sort(v.begin(), v.end());
			if(v[0] < now){
				vector<int> tmp;
				for(int j = v[0]; j <= min(now, v[1]); j++){
					tmp.push_back(loop[j]);
				}
				return solve(tmp);
			} else {
				ans.push_back(loop[now]);
				now = v[v.size() - 1];
			}
		}
	}
	return ans;
}

int main()
{
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
	}
	for(int i = 0; i < n; i++){
		isused[i] = true;
		vector<int> loop = findLoop(i);
		isused[i] = false;
		if(loop.size() == 0) continue;
		loop.pop_back();
		reverse(loop.begin(), loop.end());
		vector<int> ans = solve(loop);
		cout << ans.size() << endl;
		for(int j = 0; j < ans.size(); j++){
			cout << ans[j] + 1 << endl;
		}
		return 0;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int c = a * b;
  if(c % 2 == 0){
    cout << "Even\n";
    return 0;
  }
  cout << "Odd\n";
}
  

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
x, y = map(int, input().split(" "))
group_a = [1, 3, 5, 7, 8, 10, 12]
group_b = [4, 6, 9, 11]
group_c = [2]
x_group = ""
y_group = ""

if x in group_a:
    x_group = "a"
elif x in group_b:
    x_group = "b"
else:
    x_group = "c"

if y in group_a:
    y_group = "a"
elif y in group_b:
    y_group = "b"
else:
    y_group = "c"

if x_group == y_group:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<stdio.h>
int main(){

  int i,n,R,max,minR;
  scanf("%d", &n );

  max = -1000000000;
  minR = 1000000000;

  for ( i = 0 ; i < n ; i++ ){

    scanf("%d", &R );

    if ( i > 0 && R - minR > max ) max = R - minR;

    if ( R < minR ) minR = R;
    
  }

  printf("%d\n", max );

  return 0;

}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <stack>
using namespace std;
int main(){
  map<double,double> m;
  double a,b,ave=0,sum=0;
  while(scanf("%lf,%lf",&a,&b)!=EOF){
    m[a]=b;
  }
  map<double,double>::iterator it = m.begin();
  while(it!=m.end()){
    ave+=(*it).second,sum+=((*it).first*(*it).second);
    it++;
  }
  ave/=m.size();
  ave+=0.5;
  cout<<sum<<endl<<(int)ave<<endl;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int n;
int rec[200005];

int main()
{
	cin >> n;
	for (int i=1; i<=n; i++) cin >> rec[i];
	int ans=n,l=1;
	for (int i=1; i<=n; i++)
	{
		while (l<=n&&rec[l]!=i) l++;
		if (l<=n) ans--;
		else break;
	}
	cout << (ans==n?-1:ans) << endl;
	return 0;
}

Measured memory_bytes: 1152
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{	
		
		 Scanner cthanh = new Scanner(System.in);
        int x = cthanh.nextInt();
        System.out.println( x * x * x );
		
	}
}
		
    
    
   

Measured memory_bytes: 26080
import java.io.*;
class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] two_number = br.readLine().split(" ");
    int a = Integer.parseInt(two_number[0]);
    int b = Integer.parseInt(two_number[1]);
    if(a<b){
      System.out.println("a < b");
    }else if(a>b){
      System.out.println("a > b");
    }else{
      System.out.println("a == b");
    }
  }
}



Measured memory_bytes: 24452
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int N;
    vector<long long int> xs, ys, hs;
    long long int x0, y0, h0;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        long long int x, y, h;
        cin >> x >> y >> h;
        xs.push_back(x);
        ys.push_back(y);
        hs.push_back(h);
        if (h > 0)
        {
            x0 = x;
            y0 = y;
            h0 = h;
        }
    }
    for (int Cx = 0; Cx <= 100; Cx++)
    {
        for (int Cy = 0; Cy <= 100; Cy++)
        {
            long long int H = h0 + abs(x0 - Cx) + abs(y0 - Cy);
            for (int i = 0; i < N; ++i)
            {
                long long int h = max(0ll, H - abs(xs[i] - Cx) - abs(ys[i] - Cy));
                if (h != hs[i])
                {
                    goto next;
                }
            }
            cout << Cx << " " << Cy << " " << H << endl;
            return 0;
        next:;
        }
    }
    return 0;
}


Measured memory_bytes: 256