akhauriyash/Code-Regression huggingface dataset:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])

for j in range(M):
    b.append(b[j] + B[j])

ans = 0
j = M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(i + j, ans)

print(ans)

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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;

int a[N];
typedef pair<int,int> pa;
int dv[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
char path[100][100];
int n,m;
int vis[100][100];
void bfs(int x,int y)
{
    queue<pa>q;
    q.push({x,y});
    vis[x][y]=1;
    while(q.size()){
        pa k=q.front();q.pop();
        for(int i=0;i<4;i++) {
             int xx=k.first+dv[i][0];
             int yy=k.second+dv[i][1];
             if(path[xx][yy]=='.' && xx>=1 && xx<=n && yy>=1 && yy<=m && !vis[xx][yy]){
                  q.push({xx,yy});
                  vis[xx][yy]=vis[k.first][k.second]+1;
             }
        }
    }

}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    int ans=0;
    for(int i=1;i<=n;i++) {
        cin>>path[i]+1;
        for(int j=1;j<=m;j++) {
            if(path[i][j]=='.')
                ans++;
        }
    }
    bfs(1,1);
    if(!vis[n][m])  cout<<-1<<endl;
    else {
        cout<<ans-vis[n][m]<<endl;
    }
    return 0;
}


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

int main() {
    long long a, b, k;
    cin >> a >> b >> k;

    if (k < a) cout << a - k << ' ' << b << endl;
    else if (k < a + b) cout << 0 << ' ' << b - k + a << endl;
    else cout << 0 << ' ' << 0 << endl;

}

Measured memory_bytes: 3616
#Thanks, snuke!

N,M = map(int,input().split())
key = []
for i in range(M) :
    a,b = map(int,input().split())
    s = 0
    cx = list(map(int,input().split()))
    for j in range(b) :
        s = s | (1 << (cx[j]-1))
    key.append([s,a])

dp = [10**12 for i in range(1 << N)]
dp[0] = 0
for s in range(1 << N) :
    for i in range(M) :
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)

ans = dp[-1] if dp[-1] != 10**12 else -1

print(ans)


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void solve() {
	ll n, r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r << endl;
	}
	else {
		cout << r + 100 * (10 - n) << endl;
	}
}

int main() {
	IOS;
	//io_set();
	ll tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
S = input()

allowed = set(list('ATCG'))

ans = 0
curstreak = 0
flag = False

for char in S:
    if char in allowed:

        if flag:
            curstreak += 1
        else:
            flag = True
            curstreak = 1
        
        ans = max(ans, curstreak)

    else:
        if flag:
            flag = False
            curstreak = 0

print(ans)


Measured memory_bytes: 3060
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    la = rli()
    if sum(la) >= 22:
        print("bust")
    else:
        print("win")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int dp[100][10000],array1[105],n;
int solve(int i,int sum){
    if(i==n){
        if(sum%10==0){
            return 0;
        }
        return sum;
    }
    if(dp[i][sum]!=-1){
        return dp[i][sum];
    }
    return dp[i][sum]=max(solve(i+1,sum+array1[i]),solve(i+1,sum));
}
int main()
{
memset(dp,-1,sizeof(dp));
scanf("%d",&n);
int i;
for(i=0;i<n;++i){
    scanf("%d",&array1[i]);
}
printf("%d",solve(0,0));



    return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

int type(int i, string &s1, string &s2) {
  if (s1[i] == s2[i]) {
    return 1;
  }
  return 2;
}

void solve() {
  const int mod = 1000000007;
  int N;
  cin >> N;
  string s1, s2;
  cin >> s1 >> s2;
  int t = type(0, s1, s2);
  ll ans = 0;
  if (t == 1) {
    ans = 3;
  } else {
    ans = 6;
  }
  int prett = t;
  while(t < N) {
    int tt = type(t, s1, s2);
    if (prett == 1 && tt == 1) {
      ans *= 2;
      ans %= mod;
    }
    if (prett == 1 && tt == 2) {
      ans *= 2;
      ans %= mod;
    }
    if (prett == 2 && tt == 2) {
      ans *= 3;
      ans %= mod;
    }
    prett = tt;
    t += tt;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

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

int main(void)
{
    int n;
    cin >> n;
    v_int b(n);
    rep(i,n-1) {
        cin >> b[i];
    }
    
    v_int a(n);
    a[n-2] = a[n-1] = b[n-2];
    rrep2(i,n-2,0) {
        int c = min(b[i],a[i+1]);
        a[i+1] = c;
        a[i] = b[i];
    }
    ll sum = 0;
    rep(i,n) { 
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
} /*atcoder*/



Measured memory_bytes: 3600
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5, P = 998244353;
int n, mx, cnt[N];

int power(int a, int b) {
	int ans = 1;
	for ( ; b; a = 1LL * a * a % P, b >>= 1)
		ans = b & 1? 1LL * ans * a % P: ans;
	return ans;
}

int main() {
	cin >> n >> mx;
	int ans = !mx;
	for (int i = 1; i < n; i++) {
		int x;
		cin >> x;
		cnt[x]++;
		mx = max(mx, x);
	}
	ans *= !cnt[0];
	for (int i = 1; i < mx; i++)
		ans = 1LL * ans * power(cnt[i], cnt[i + 1]) % P;
	cout << ans;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
	int n;
	int d1;
	int d2;
	int zoro_count = 0;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%d", &d1);
		scanf("%d", &d2);
		if(zoro_count < 3){
			if(d1 == d2){
				zoro_count++;
			} else {
				zoro_count = 0;
			}
		}
	}
	if(zoro_count == 3){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
#define N 300006
int T,n;
ll a[N],s[N];
char ch[N];
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
        scanf("%s",ch+1);if(ch[n]=='1'){puts("1");continue;}
        for(int j=0;j<=62;j++)s[j]=0;bool flag=true;
        for(int i=n;i;i--)
        {
            if(ch[i]=='0')
            {
                ll x=a[i];
                for(int j=62;~j;j--)if(x&(1ll<<j))
                {
                    if(!s[j]){s[j]=x;break;}
                    else x^=s[j];
                }
            }
            else
            {
                ll x=a[i];bool tf=false;
                for(int j=62;~j;j--)if(x&(1ll<<j))
                {
                    if(!s[j]){s[j]=x;tf=true;break;}
                    else x^=s[j];
                }
                if(tf){flag=false;break;}
            }
        }
        if(!flag)puts("1");
        else puts("0");
    }
}


Measured memory_bytes: 3744
def solve():
  ans = 0
  N, M = map(int, input().split())
  A = [list(map(int, input().split())) for _ in range(N)]
  A.sort()
  for i in range(N):
    if M>=A[i][1]:
      ans += A[i][0]*A[i][1]
      M -= A[i][1]
    else:
      ans += A[i][0]*M
      break
  return ans
print(solve())

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

int n;
vector<int> v;

void solve(){
    int cnt=0;
    for(int i=0; i<n; i++){
        if(i+1 == v[i]){
            if(i==n-1){
                int t=v[i]; v[i]=v[i-1]; v[i-1]=t;
            }else{
                int t=v[i]; v[i]=v[i+1]; v[i+1]=t;
            }
            cnt++;
        }
    }
    cout << cnt << endl;
}

int main(){
    cin >> n;
    v.resize(n);
    for(auto &x: v) cin >> x;
    solve();
}

Measured memory_bytes: 768
#include<stdio.h>

int gcd(int a, int b) {
  int v0 = a, v1 = b, v2 = a % b;
  while (v2 != 0) {
    v0 = v1;
    v1 = v2;
    v2 = v0 % v1;
  };
  return v1;
}

int lcm(int a, int b) {
  return a * b / gcd(a, b);
}


int main(void){
    char str[11];
    int a[100];
    int value;
    float v1;

    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    
    value = a[0];
    for (int i = 1; i < n; i++) {
      value = lcm(value, a[i]);
    }
    // printf("%d", value);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum = sum + value / a[i];
    } 
    v1 = (float)((float)value / (float)sum);
    printf("%e", v1);    
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var result = 0;

            for (var i = 1; i <= n; i++)
            {
                if (i % 2 == 1 && inputLongArray[i-1] % 2== 1)
                {
                    result += 1;
                }
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 19132
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

bool isprime[1300001];
vector<int> primes;

int main(){
    memset(isprime,true,sizeof(isprime));

    for(int i=2;i<=1300000;++i){
        if(isprime[i]){
            primes.push_back(i);
            for(int j=2;i*j<=1300000;j++){
                isprime[i*j] = false;
            }
        }
    }

    int n;
    while(cin >> n && n){
        if(find(primes.begin(), primes.end(), n) != primes.end()){
            cout << 0 << endl;
        }else{
            vector<int>::iterator it = upper_bound(primes.begin(), primes.end(), n);
            cout << *it - *(it-1) << endl;
        }
    }
}

Measured memory_bytes: 0
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
// #define int unsigned long long int
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int mul1 = 1003, mul2 = 5, mul3 = 8;
const int MOD3 = 179424673, MOD2 = 982451653, MOD1 = 1190494759;
const ll MOD = 1000000007;
const ld EPS = 1e-9;

v64 facts;


ll pow(ll a, ll n)
{
    if (n == 0) return 1;
    if (n % 2 == 0)
    {
        ll tmp = pow(a, n/2);
        return (tmp * tmp) % MOD;
    }
    else
    {
        ll tmp = pow(a, n/2);
        return (a * (tmp * tmp % MOD)) % MOD;
    }
    
}

ll inv(ll a)
{
    return pow(a, MOD - 2);
}

ll NCR(int n, int r)
{
    // cout << facts[n] << " " << facts[r] << " " << facts[n-r] << endl;
    ll tmp = (facts[n] * inv(facts[r])) % MOD;
    return (tmp * inv(facts[n-r])) % MOD;
}

int main()
{
    int S;
    cin >> S;
    ll sum = 0;

    // cout << (inv(24) * 24) % MOD << endl;

    ll prod = 1;

    forn(i, 2001)
    {
        if (i == 0) {facts.pb(1); continue;}
        prod = (prod * i) % MOD;
        // if (i < 20) cout << prod << endl;
        facts.pb(prod);
    }

    ll comb = 0;

    forn(i, S)
    {
        int l = S - 3 * (i + 1);
        if (l >= 0)
        {
            // cout << NCR(l+i, i) << endl;
            comb += NCR(l+i, i);
            comb %= MOD;
        }
        else break;
    }

    cout << comb << endl;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

ll gcd(ll a, ll b){
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main(void){
    ll A, B; cin >> A >> B;
    
    cout << A / gcd(A, B) * B << endl;
}


Measured memory_bytes: 256
# code-festival-2017-qualaB - fLIP
def main():
    n, m, k = list(map(int, input().rstrip().split()))
    for i in range(n + 1):
        for j in range(m + 1):
            if i * (m - j) + j * (n - i) == k:
                print("Yes")
                return
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
using namespace std;

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
using namespace std;


int main(void){
	int N,M;

	cin >> N >> M;

  if (M == 1)
	cout << 0 << endl;
  else
	cout << N - M << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MAXN = 212345;
int n, m, k;
ll ft[MAXN];
ll get(int x) {
    ll ans = 0;
    for (; x; x-=x&-x) {
        ans = max(ans, ft[x]);
    }
    return ans;
}

void update(int x, ll v) {
    for (; x<=n; x+=x&-x) {
        ft[x] = max(v, ft[x]);
    }
}

int h[MAXN], v[MAXN];
int main() {
    scanf("%d", &n);
    for (int i = 1; i<=n; ++i) {
        scanf("%d", h+i);
    }
    for (int i = 1; i<=n; ++i) {
        scanf("%d", v+i);
    }
    ll ans = 0, sum;
    for (int i = 1; i<=n; ++i) {
        sum = get(h[i])+v[i];
        update(h[i], sum);
    }
    printf("%lld\n", get(n));
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <string.h>
#define N 100002
typedef struct A{
  char name[100];
  int time;
}Point;
Point hi[N];
int head=0,tail=0,n;
void in(Point x);
Point de();
int min(int a,int b){
  if(a<b)
    return a;
  else return b;
}
int main(){
  int s=0,c;
  int i,p,t;
  Point k;
  scanf ("%d %d",&p,&t);
  for (i=1;i<=p;i++){
    scanf ("%s",hi[i].name);
    scanf ("%d",&hi[i].time);
  }
  head=1;
  tail=p+1;
  
  while(head!=tail){
    k=de();
    c=min(t,k.time);
    k.time-=c;
    s+=c;

    if (k.time > 0)
      in(k);
    else{
      printf("%s %d\n",k.name,s);
    }
  }

  return 0;
}
void in (Point x){
  hi[tail]=x;
  tail=(tail+1) % N;
}
Point de () {
  Point x =hi[head];
  head =(head+1) % N;
  return x;
}
  



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

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define li long long
#define ld long double
#define x first
#define y second
#define pt pair<int, int>
#define pll pair<li, li>
#define forn(i, t) for(int i = 0; i < (t); i++)
#define fore(i, f, t) for(int i = (f); i < (t); i++)
#define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
#define all(x) (x).begin(), (x).end()
#define ins insert

using namespace std;


const int INF = 1e9;
const int MOD = 1e9 + 7;
const li INF64 = 1e18;
const ld EPS = 1e-7;

mt19937 myrand(time(NULL));

const int N = 100 * 1000 + 13;

int n;
char a[N];


bool read(){
	if(scanf("%d\n", &n) != 1)
		return 0;
	scanf("%s\n", a);
	return 1;
}


bool check(string s){
	forn(i, n){
		if (s[i] == 'W' && a[i] == 'x' && s[(i - 1 + n) % n] != s[(i + 1) % n])
			return 0;
		if (s[i] == 'W' && a[i] == 'o' && s[(i - 1 + n) % n] == s[(i + 1) % n])
			return 0;
		if (s[i] == 'S' && a[i] == 'o' && s[(i - 1 + n) % n] != s[(i + 1) % n])
			return 0;
		if (s[i] == 'S' && a[i] == 'x' && s[(i - 1 + n) % n] == s[(i + 1) % n])
			return 0;
	}
	return 1;
}


void solve(){
	/*char s[N];
	forn(i, n + 1){
		forn(j, i)
			s[j] = 'S';
		forn(j, n - i)
			s[j + i] = 'W';
		do{
			if (check(s))
				cout << s << "\n";
		} while(next_permutation(s, s + n));
	}*/
	char s[N];
	forn(i, 2)
		forn(j, 2){
			s[0] = (i ? 'S' : 'W');
			s[1] = (j ? 'S' : 'W');
			fore(k, 1, n - 1){
				if (s[k] == 'W' && a[k] == 'x')
					s[k + 1] = (s[k - 1] == 'S' ? 'S' : 'W');
				if (s[k] == 'W' && a[k] == 'o')
					s[k + 1] = (s[k - 1] == 'S' ? 'W' : 'S');
				if (s[k] == 'S' && a[k] == 'x')
					s[k + 1] = (s[k - 1] == 'S' ? 'W' : 'S');
				if (s[k] == 'S' && a[k] == 'o')
					s[k + 1] = (s[k - 1] == 'S' ? 'S' : 'W');
			}
			if (check(s)){
				cout << s << "\n";
				return;
			}
		}
	printf("-1\n");
}


int main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
	#endif
	while(read())
		solve();
	return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(S.charAt(S.length()-1) == 's')
			System.out.println(S + "es");
		else
			System.out.println(S + "s");
	}

}


Measured memory_bytes: 38412
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

string s;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> s;
    int i;
    rep(i, s.length()) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3652
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = line[0];
            int B = line[1];
            int max = Math.Max(A + B, A - B);
            Console.WriteLine(Math.Max(max, A * B));
        }
    }
}

Measured memory_bytes: 11092
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  collections import deque

def main():
    k,s = map(int,input().split())
    ans = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if 0 <= s - i - j <= k:
                ans += 1
    print(ans)
if __name__ == '__main__':
    main()

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T &b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T &b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;


int main()
{
    LL t1,t2,a1,a2,b1,b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if(a1 < b1) {
        swap(a1,b1);
        swap(a2,b2);
    }



    if(t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2){
        cout << "infinity" << endl;
    }
    else if(t1 * a1 - t1 * b1 > t2 * b2 - t2 * a2){
        cout << 0 << endl;
    }
    else{
        LL a = t1 * a1 - t1 * b1;
        LL b = t2 * b2 - t2 * a2;
        if(a % (b - a)){
            cout << 2 * (a/(b-a)) + 1 << endl;
        }else{
            cout << 2* (a/(b-a)) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    dice = [int(p) for p in input().split()]
    S = [ 0 for i in range(N+1)]

    for i in range(1, N+1):
        S[i] = S[i-1] + (dice[i-1]+1)/2.0

    max_E = 0
    for i in range(N-K+1):
       E = S[i+K] - S[i]
       if max_E < E:
           max_E = E

    print(max_E)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 25188
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String args[]) {
		FastScanner in = new FastScanner();
		char s1[]=in.next().toCharArray();
		char s2[]=in.next().toCharArray();
		int n1=s1.length;
		int n2=s2.length;
		int ans=Integer.MAX_VALUE;
		for(int i=0;i<=n1-n2;i++) {
			int ctr=0;
			for(int j=0;j<n2;j++) {
				if(s1[i+j]!=s2[j]) {
					ctr++;
				}
			}
			ans=Math.min(ans, ctr);
		}
		System.out.println(ans);
	}

	///////////////////////////
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 32804
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include <cstring>
#include <sstream>
using namespace std;

int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx;
	int dy = ty - sy;
	string ans;
	int steps = 2 * (2 * dy + 2 * dx) + 8;
	for(int i = 0; i < steps; i++){
		if(i < dy) ans.push_back('U');
		else if(i < dx + dy) ans.push_back('R');
		else if(i < 2*dy + dx) ans.push_back('D');
		else if(i < 2*dy + 2*dx + 1) ans.push_back('L');
		else if(i < 3*dy + 2*dx + 2) ans.push_back('U');
		else if(i < 3*dy + 3*dx + 3) ans.push_back('R');
		else if(i == 3*dy + 3*dx + 3) ans.push_back('D');
		else if(i == 3*dy + 3*dx + 4) ans.push_back('R');
		else if(i < 4*dy + 3*dx + 6) ans.push_back('D');
		else if(i < 4*dy + 4*dx + 7) ans.push_back('L');
		else ans.push_back('U');
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()

int main() {
  ll n,d;
  cin >> n >> d;
  vector<ll> x(n);
  vector<ll> y(n);
  for(int i=0;i<n;i++){
  	cin >> x[i] >> y[i];
  }
  ll count=0;
  for(int i=0;i<n;i++){
  	if(x[i]*x[i]+y[i]*y[i] <= d*d){
    	count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 6436
#define _GLIBCXX_DEBUG //提出時に消す
#include <bits/stdc++.h>
//#include <atcoder/scc>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007ll

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15)
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) cout << "ACL";
  cout << endl;
  
}



Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  char dp[200][200];
  int h,w;
  cin>>h>>w;
  rep(i,h+2)rep(j,w+2)dp[i][j]='#';
  rep(i,h)rep(j,w)cin>>dp[i+1][j+1];
  rep(i,h+2)
  {
    rep(j,w+2){
      cout<<dp[i][j];
    }
    cout<<endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common

typedef int  i32;
typedef long long i64,ll;
typedef long double ld;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,r) for(int i=(int)l;i<(int)(r);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#define NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T pmod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}
#define nextInt(n) scanf("%d",&n)
#define defInt(n) int n;nextInt(n)
#define nextLong(n) scanf("%lld",&n)
#define defLong(n) ll n;nextLong(n)
#define nextDouble(n) scanf("%lf",&n)


class Main{
public:
	void run(){
	//	ifstream cin("in");
	//	ofstream cout( "out" );
		int N;cin >>N;
		vector<vector<int> > ps(N,vector<int>(3));
		REP(i,N)REP(j,3) cin >> ps[i][j];
		
		vector<int> res(N);
		REP(j,3){
			map<int,int> pmap;
			REP(i,N)pmap[ps[i][j]]++;
			
			REP(i,N)if(pmap[ps[i][j]]==1)res[i]+=ps[i][j];
		}
		REP(i,N){
			cout << res[i]<<endl;
		}
	}
};
int main(){
	cout <<fixed<<setprecision(3);	
	ios::sync_with_stdio(false);
	Main().run();
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#define mes(a, b) memset(a, b, sizeof a)
#define pb push_back
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 2e6+10;
const double eps = 1e-1;
ll n;
ll l, r;
ll max(ll x, ll y){
    return x > y?x:y;
}
struct Node{
    ll x, id;
    bool operator < (const Node &p)const{
        return x > p.x;
    }
}a[maxn];
ll dp[2100][2100];
int main(){
    scanf("%lld", &n);
    for(int i = 1; i <= n; i++){
        scanf("%lld", &a[i].x);
        a[i].id = i;
    }
    sort(a+1, a+n+1);
    ll tmp = 0, ans = 0;
    Node b;
    for(int i = 1; i <= n; i++){
        b = a[i];
        for(ll l = 1, r = n-i+1; r <= n; l++,r++){
            dp[i][l] = max(dp[i][l], dp[i-1][l-1] + abs(b.id-l) * b.x);
            dp[i][l-1] = max(dp[i][l-1], dp[i-1][l-1] + abs(b.id-r) * b.x);
        }
    }
    for(int i = 1; i <= n; i++)
        ans = max(ans, dp[n][i]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 26252
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n,a,b,s=0,v=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++) {
		v=i%10;
		v+=i/10%10;
		v+=i/100%10;
		v+=i/1000%10;
		v+=i/10000;
		if(v>=a && v<=b){
			s+=i;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int b[100];
int A[100][100];
int ans[100];

int main()
{
	int n, m;

	cin >> n >> m;
	rep(i, n) rep(j, m) cin >> A[i][j];
	rep(i, m) cin >> b[i];

	rep(i, n) {
		rep(j, m) ans[i] += A[i][j] * b[j];
	}

	rep(i, n) cout << ans[i] << endl;

	return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

inline ll mod(ll a, ll m=MOD){return (a%m+m)%m;}
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline ll inv(ll n, ll m=MOD){
    ll a = n, b = m, x = 1, y = 0;
    while(b){
        ll t = a/b;
        a -= t*b;
        swap(a, b);
        x -= t*y;
        swap(x, y);
    }
    return mod(a, m); 
}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __{ __(){ /* cin.tie(0); ios::sync_with_stdio(0); */ cout<<fixed<<setprecision(15); } };

int main(){

    ll n, m;
    scanf("%lld%lld", &n, &m);  

    vector<ll> a(n);
    rep(i, n) scanf("%lld", &a[i]);

    ll l = 1;
    int lsb = a[0] & -a[0];
    rep(i, n){
        l = lcm(l, a[i]/2);
        if((a[i] & -a[i]) != lsb or l > m){
            ppp(0);
            return 0;
        }
    }
    ppp((m/l-1)/2+1);

    return 0;
}


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

using ll = long long;
ll modinv(ll a, ll m) {
	assert(m > 0);
	if (m == 1) return 0;
	a %= m;
	if (a < 0) a += m;
	assert(a != 0);
	if (a == 1) return 1;
	return m - modinv(m, a) * m / a;
}

template <int MOD_> struct modnum {
private:
	int v;
public:
	static const int MOD = MOD_;

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum operator ~ () const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

using num = modnum<998244353>;


#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<num, num> pii;
typedef vector<int> vi;
typedef vector<num> vn;

void FST(vn& a, bool inv) {
	for (int n = sz(a), step = 1; step < n; step *= 2) {
		for (int i = 0; i < n; i += 2 * step) rep(j,i,i+step) {
			num &u = a[j], &v = a[j + step]; tie(u, v) =
				pii(u + v, u - v);                   // XOR
		}
	}
	if (inv) trav(x, a) x /= sz(a); // XOR only
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	int N = (1 << n);
	vector<num> a(N), b(N);
	num asum = 0;
	for(int i = 0; i < N; i++){
		int r;
		cin >> r;
		a[i] = r;
		b[i] = -1;
		asum += a[i];
	}
	for(int i = 0; i < N; i++){
		a[i] /= asum;
	}
	a[0] -= 1;
	b[0] += N;
	FST(a, 0); FST(b, 0);
	for(int i = 1; i < N; i++) b[i] /= a[i];
	FST(b, 1);
	for(int i = 0; i < N; i++){
		cout << (int) (b[i] - b[0]) << '\n';
	}
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_lim=(n); i<i##_lim; ++i)
#define FOR(i, a, b) for (int i=(a), i##_lim=(b); i<i##_lim; ++i)
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;

int main()
{
    int N, M;
    cin >> N >> M;
    int L[M], R[M];
    REP(i, M) cin >> L[i] >> R[i];

    int lower = 1;
    int upper = N;

    REP(i, M)
    {
        lower = max(lower, L[i]);
        upper = min(upper, R[i]);
    }

    cout << max(upper-lower+1, 0) << endl;
    return 0;
}

Measured memory_bytes: 1024
function Main(input) {
    ans = 0
    lines = input.split("\n")
    S = lines[0]
    s = S[0]
    ans = 'Good'
    for(i =1; i < S.length; i++) {
        if (s == S[i]) {
          ans = 'Bad'
          break;
        }
        s = S[i]
    }
    console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 1e6;

int ans[N];
int c[N];
vector<pair<int, int> > qs[N];
int lst[N];

int fenw[N];

void add(int pos, int x)
{
    while (pos < N)
    {
        fenw[pos] += x;
        pos = pos | (pos + 1);
    }
}

int get(int x)
{
    int res = 0;
    while (x >= 0)
    {
        res += fenw[x];
        x = (x & (x + 1)) - 1;
    }
    return res;
}

int get(int l, int r)
{
    if (l == 0) return get(r);
    return get(r) - get(l - 1);
}

signed main()
{
    ll n, d;
    int ans = 0;
    cin >> n >> d;
    d *= d;
    for (int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        x = x * x + y * y;
        ans += x <= d;
    }
    cout << ans;
}


Measured memory_bytes: 27036
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, Q; 
  string s;
  cin >> N >> s >> Q;

  while(Q--){
    int k;
    cin >> k;
    k--;

    int ans = 0;
    int D = 0, M = 0, DM = 0;
    REP(i, N){
      if(s[i] == 'D') D++;
      if(s[i] == 'M') M++, DM += D;
      if(s[i] == 'C') ans += DM;
      if(i-k >= 0){
        if(s[i-k] == 'D') D--, DM -= M;
        if(s[i-k] == 'M') M--;
      }
    }
    cout << ans << "\n";
  }


  return 0;
}

Measured memory_bytes: 1948
import java.util.Scanner;

public class Main{
  static final long MOD = 1_000_000_007;
  static int n, m;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();
    m = sc.nextInt();

    if(Math.abs(n - m) >= 2){
      System.out.println(0);
      return;
    }

    long[] fac = new long[Math.max(n, m) + 1];
    fac[0] = 1;
    for(int i = 1; i <= Math.max(n, m); i++){
      fac[i] = (fac[i - 1] * i) % MOD;
    }

    long ans = (fac[n] * fac[m]) % MOD;
    if(n == m){
      ans = (2L * ans) % MOD;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> a(n),ans(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    ans[a[i]-1] = i+1;
  }

  for(int p : ans){
    cout << p << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define MOD 1000000007
#define MAX 200005
#define MAX_NUM 300001
int arr[MAX];
long long int cnt[MAX];
int main()
{
    int N,i,j;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&arr[i]);
        arr[i]--;
        cnt[arr[i]]++;
    }
    long long int total=0;
    for(i=0;i<N;i++)
    {
        total=total+cnt[i]*(cnt[i]-1);
    }
    total=total/2;
    //printf("total=%lld\n",total);
    for(i=0;i<N;i++)
    {
        printf("%lld\n",total-cnt[arr[i]]+1);
    }
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define _for(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FOR(...)   _for (__VA_ARGS__)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;

inline constexpr auto distance (size_t x, size_t y) noexcept
{
  return x < y ? y - x : x - y;
}

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

  size_t n, x, y;
  cin >> n >> x >> y;
  -- x; -- y;
  vector <size_t> ans (n);
  rep (i, n) rep (j, i)
  {
    auto d = min (distance (i, j), distance (j, x) + 1 + distance (y, i));
    ++ ans[d];
  }
  FOR (i, 1, n)
  {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
mod = 7 + 10 ** 9
#A:1, C:2, G:3, T:4
#132, 123, 312, 1x32, 13x2は不可

N = int(input())
memo = {}

def agc(ppp, pp, p, i, memo):
    if i == N: return 1
    try:
        return memo[(ppp, pp, p, i)]
    except KeyError:
        Ans = 0
        if ppp == 1:
            if pp == 3:
                Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 3, i+1, memo) + agc(pp, p, 4, i+1, memo)
            elif pp == 1:
                if p == 2:
                    Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 2, i+1, memo) + agc(pp, p, 4, i+1, memo)
                elif p == 3:
                    Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 3, i+1, memo) + agc(pp, p, 4, i+1, memo)
                else: Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 2, i+1, memo) + agc(pp, p, 3, i+1, memo) + agc(pp, p, 4, i+1, memo)
            elif p == 3:
                Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 3, i+1, memo) + agc(pp, p, 4, i+1, memo)
            else: Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 2, i+1, memo) + agc(pp, p, 3, i+1, memo) + agc(pp, p, 4, i+1, memo)
        else:
            if pp == 1:
                if p == 2:
                    Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 2, i+1, memo) + agc(pp, p, 4, i+1, memo)
                elif p == 3:
                    Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 3, i+1, memo) + agc(pp, p, 4, i+1, memo)
                else: Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 2, i+1, memo) + agc(pp, p, 3, i+1, memo) + agc(pp, p, 4, i+1, memo)
            elif pp == 3:
                if p == 1: Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 3, i+1, memo) + agc(pp, p, 4, i+1, memo)
                else: Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 2, i+1, memo) + agc(pp, p, 3, i+1, memo) + agc(pp, p, 4, i+1, memo)
            else: Ans = agc(pp, p, 1, i+1, memo) + agc(pp, p, 2, i+1, memo) + agc(pp, p, 3, i+1, memo) + agc(pp, p, 4, i+1, memo)
        Ans %= mod
        memo[(ppp, pp, p, i)] = Ans
        return Ans

print(agc(0, 0, 0, 0, memo))

Measured memory_bytes: 4364
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 100100;

int k;
char s[N];

int main() {

	scanf("%s %d", s, &k);

	int n = strlen(s);
	long long res = 0;

	vector <int> c;

	for (int i = 0; i < n;) {
		int j = i;
		while (j < n && s[i] == s[j]) {
			j++;
		}
		c.push_back(j - i);
		i = j;
	}

	if (k == 1 || s[0] != s[n - 1]) {
		for (int i = 0; i < c.size(); i++) {
			res += 1LL * k * (c[i] / 2);
		}
	} else if (c.size() == 1) {
		res += (1LL * k * n) / 2;
	} else {
		for (int i = 0; i < c.size(); i++) {
			res += c[i] / 2;
		}
		for (int i = 1; i + 1 < c.size(); i++) {
			res += 1LL * (k - 1) * (c[i] / 2);
		}
		res += 1LL * (k - 1) * ((c[0] + c[c.size() - 1]) / 2);
	}

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

	return 0;

}

Measured memory_bytes: 256