akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
const int MOD=1000000007;
int dp[2][1<<19],flp[1<<19][19],must[20][19];
inline void upd(int &a,int b)
{
    a+=b;
    if (a>=MOD)
        a-=MOD;
}
int main()
{
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for (int i=0;i<(1<<(n-1));++i)
    {
        int lst=n-1;
        for (int j=n-2;j>=0;--j)
        {
            if ((i>>j)&1)
                lst=j;
            else
                flp[i][j]=lst==n-1?i^(1<<j):i^(1<<j)^(1<<lst);
        }
    }
    for (int i=0;i<k;++i)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        must[a-1][b-1]=c+1;
    }
    dp[0][0]=1;
    int p=0;
    for (int i=0;i<m;++i)
    {
        for (int j=0;j<n-1;++j)
        {
            for (int k=0;k<(1<<(n-1));++k)
                dp[p^1][k]=0;
            for (int k=0;k<(1<<(n-1));++k)
            {
                if (!dp[p][k])
                    continue;
                if (must[i][j]!=2&&!((k>>j)&1))
                    upd(dp[p^1][k],dp[p][k]);
                if (must[i][j]!=1)
                {
                    if ((k>>j)&1)
                        upd(dp[p^1][k],dp[p][k]);
                    else
                        upd(dp[p^1][flp[k][j]],dp[p][k]);
                }
            }
            p^=1;
        }
    }
    int ans=0;
    for (int i=0;i<(1<<(n-1));++i)
        upd(ans,dp[p][i]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 43264
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int a = 0, b = 0;
	cin >> s;
	for(int i = 0; i < s.size(); i++)
		if(s[i] == '0')
			a ++;
		else
			b ++;
	a = min(a, b);
	cout << a * 2;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<ctime>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

const ll INF = 998244353;
const int MAXN = 2333;
const double EPS = 1e-9;
ll n, ans;
pair<int, int> a[MAXN];
ll f[MAXN];


struct point {
	double x, y;
	point (double x = 0, double y = 0) : x(x), y(y) {}
}p[MAXN];
inline bool operator < (const point & a, const point & b) {
	return a.x == b.x ? a.y < b.y : a.x < b.x;
}
inline point operator + (const point & a, const point & b) {
	return point(a.x + b.x, a.y + b.y);
}
inline point operator - (const point & a, const point & b) {
	return point(a.x - b.x, a.y - b.y);
}
inline point operator * (const point & a, const double & b) {
	return point(a.x * b, a.y * b);
}
inline point operator / (const point & a, const double & b) {
	return point(a.x / b, a.y / b);
}
inline double det(const point &a, const point &b) { 
	return a.x * b.y - b.x * a.y;
}
inline double dot(const point &a, const point &b) {
	return a.x * b.x + a.y * b.y;
}

struct line {
	point s, t;
	line (point s = point(), point t = point()) : s(s), t(t) {}
};

inline bool check(line x, line y) {
	point i = x.s - x.t;
	point j = y.s - y.t;
	if (abs(det (i, j)) < EPS) return 1 ; else return 0 ; 
}


int main() {
	read(n);
	f[0] = 1;
	rep(i, 1, n) f[i] = f[i - 1] * 2 % INF;
	rep(i, 1, n) {
		double x, y;
		read(x);
		read(y);
		p[i] = point(x, y);
	}
	ans = f[n] - n - 1;
	rep(i, 1, n) {
		rep(j, 1, i - 1) {
			ll s = 0;
			rep(k, 1, j - 1) {
				if (check(line(p[i], p[j]), line(p[j], p[k]))) ++s;
			}
			ans -= f[s];
			ans %= INF;
		}
	}
	ans += INF;
	ans %= INF;
	cout << ans << "\n";
	return 0;
} 


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // read inputs
        Scanner in = new Scanner(System.in);
        final int N = in.nextInt(), K = in.nextInt();
        String cs = in.next();
        // System.out.printf("N = %d, K = %d\n", N, K);
        // System.out.printf("cs = %s\n", cs);

        // count number of blocks of 0
        int numBlock0 = 0;
        ArrayList<Integer> ls = new ArrayList<>(), rs = new ArrayList<>();
        ls.add(-1); // dummy
        rs.add(-1); // dummy
        for (int i = 0; i < N; i++) {
            // skip '1's
            for (; i < N && cs.charAt(i) == '1'; i++) {
                ;
            }
            if (i == N) {
                break;
            }
            // cs[i] == '0' at this point
            ls.add(i);
            // skip '0's
            for (; i < N && cs.charAt(i) == '0'; i++) {
                ;
            }
            rs.add(i - 1);
            numBlock0++;
            // i == N or cs[i] == '1' at this point
        }
        ls.add(N); // dummy
        rs.add(N); // dummy
        // System.out.printf("numBlock0 = %d\n", numBlock0);
        // System.out.printf("ls = %s\n", ls);
        // System.out.printf("rs = %s\n", rs);

        // solve
        if (numBlock0 <= K) {
            System.out.printf("%d\n", N);
        } else {
            int ans = 0;
            for (int i = 1; i + K < ls.size(); i++) {
                final int l = rs.get(i - 1) + 1, r = ls.get(i + K) - 1;
                // System.out.printf("i = %d, l = %d, r = %d, num = %d\n", i, l, r, r - l + 1);
                ans = Math.max(ans, r - l + 1);
            }
            System.out.printf("%d\n", ans);
        }
    }
}


Measured memory_bytes: 27788
using System;

namespace AtCoderPractice
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] line = Console.ReadLine().Split(' ');
            int n = int.Parse(line[0]);

            // n以下の
            // 5桁の数 … 10000~99999 90000個
            // 3桁の数 … 100~999 900個
            // 1桁の数 … 1~9 9個
            int result = 0;

            if (n < 100)
            {
                result = n >= 9 ? 9 : n;
            }
            else if (n < 10000)
            {
                result = 9 + (n >= 999 ? 900 : n - 100 + 1);
            }
            else
            {
                result = 9 + 900 + (n >= 99999 ? 90000 : n - 10000 + 1);
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
import collections

N = int(input())
S = []
for i in range(N):
	S.append(input())


s = collections.Counter(S)

s = s.most_common()

pri_l = [s[0][0]]
for i in range(1,len(s)):
	if s[0][1] == s[i][1]:
		pri_l.append(s[i][0])

	else:
		break

pri_l = sorted(pri_l)
#print("======")
for i in range(len(pri_l)):
	print(pri_l[i])



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

int main()
{
    int a, b;
    cin >> a >> b;
    int c = a + b;
    if (c % 2 == 1)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << c / 2 << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll m;
vector<vector<ll>> matmul(vector<vector<ll>> a,vector<vector<ll>> b){
    ll n=a.size();
    vector<vector<ll>> ret;
    vector<ll> e;
    rep(i,0,n)e.push_back(0);
    rep(i,0,n)ret.push_back(e);
    rep(i,0,n){
        rep(j,0,n){
            ll sum=0;
            rep(k,0,n){
                sum+=(a[i][k]*b[k][j])%m;
                sum%=m;
            }
            ret[i][j]=sum;
        }
    }
    return ret;
}
vector<vector<ll>> matbeki(vector<vector<ll>> a,ll n){
    vector<vector<ll>> ret;
    ll m=a.size();
    vector<ll> e;
    rep(i,0,m)e.push_back(0);
    rep(i,0,m)ret.push_back(e);
    rep(i,0,m){
        rep(j,0,m){
            if(i==j)ret[i][j]=1;
            else ret[i][j]=0;
        }
    }
    
    while(n>0){
        if(n%2){
            ret=matmul(ret,a);
            
        }
        a=matmul(a,a);
        n/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll l,a,b;cin>>l>>a>>b>>m;
    ll now=1;
    for(;;){
        if(now>a)break;
        now*=10;
    }
    ll usi=0;
    ll ans=0;
    ll r=a;
    for(;;){
        ll u=(now-a)/b;
        if((now-a)%b!=0)u++;
        u=min(u,l);
        vector<vector<ll>> v={{now%m,1,0},{0,1,1},{0,0,1}};
        vector<vector<ll>> w=matbeki(v,u-usi);
        ll rr=r%m;
        ll bb=b%m;
        ll y=(ans*w[0][0])%m;
        ll e=(w[0][1]*rr)%m;
        ll ee=(w[0][2]*bb)%m;
        y+=e+ee;
        y%=m;
        ans=y;
        usi=u;
        r=b*u+a;
        now*=10;
        //cout<<ans<<" "<<u<<" "<<now<<" "<<r<<endl;
        if(u==l)break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int q = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        int ans = (int)1e9;
        for(int x : a){
            int cnt = 0;
            PriorityQueue<Integer> que = new PriorityQueue<>();
            PriorityQueue<Integer> ya = new PriorityQueue<>();
            for(int i=0; i<n; i++){
                que.add(a[i]);
                if(a[i] < x){
                    que.clear();
                }
                if(k <= que.size()){
                    cnt++;
                    ya.add(que.poll());
                }
            }
            
            if(q <= cnt){
                int y = 0;
                for(int i=0; i<q; i++){
                    y = ya.poll();
                }
                ans = Math.min(ans, y-x);
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 65632
#include <bits/stdc++.h>
 
typedef long long ll;
typedef unsigned long long ull;
 
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout<<i<<endl;
#define AS(i) cout<<i<<" ";
 
const int INF = 1001001001;
 
using namespace std;
 
 
int main() {

    int n;
    cin >> n;

    int h[n];
    rep(i, n) {
        cin >> h[i];
    }

    vector<int> dp(n, 0);

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++) {
        dp[i] = min( dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1] ));
    }

    AA(dp[n - 1]);
}

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <utility>
#include <cmath>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  
  ll n,m; cin >> n >> m;
  ll a[n],b[n];
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  
  vector<pair<ll,ll>> shop(n);
  rep(p,n){
    shop[p] = make_pair(a[p], b[p]);
  }
  
  sort(shop.begin(), shop.end());
  
  ll sum = 0;
  ll honsuu = 0;
  
  rep(j,n){
    honsuu += shop[j].second;
    sum += shop[j].first*shop[j].second;
    if(honsuu >= m){
      cout << sum - (honsuu-m)*shop[j].first;
      exit(0);
    }
  }
 return 0;
}

Measured memory_bytes: 3456
#pragma GCC optimize(2)
#pragma commet(linker,"STACK:102400000,102400000")
#include<bits/stdc++.h>
using namespace std;
const int man = 1e5+10;
int x[man];
int l[man],r[man];
int pos[man];
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i<= n;i++){
        scanf("%d",&x[i]);
        pos[x[i]] = i;
        l[i] = i-1;
        r[i] = i+1;
    }
    long long ans = 0;
    for(int i = 1;i <= n;i++){
        int lpos1 = l[pos[i]];
        int lpos2 = l[lpos1];
        int rpos1 = r[pos[i]];
        int rpos2 = r[rpos1];
        if(lpos1)ans += 1ll*(lpos1 - lpos2)*(rpos1 - pos[i])*i;
        if(rpos1!=n+1)ans += 1ll*(rpos2 - rpos1)*(pos[i] - lpos1)*i;
        l[rpos1] = lpos1;
        r[lpos1] = rpos1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
// atcoder/panasonic2020/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

int di[] = {0, 1, -1, 0, 1, -1, 1, -1};
int dj[] = {1, 0, 0, -1, 1, -1, -1, 1};
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  vec<int> a({1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51});
  int k;
  while (cin >> k) {
    cout << a[k - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;

    int ans = 0;
    for(int i=1; i<=N; i+=2){
        int n = 0;
        for(int j=1; j<=i; j++){
            if(i % j == 0)n++;
        }
        if(n==8) ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
from collections import deque

N,M = [int(v) for v in input().split()]
ad_list = [[] for _ in range (N+1)]
ad_num = [0 for _ in range(N)]
topo = []

for _ in range(N-1+M):
    l,r = [int(v) for v in input().split()]
    ad_list[l].append(r)
    ad_num[r-1] += 1

for i in range(1,N+1):
    if ad_num[i-1] == 0:
        topo.append(i)
queue = deque(topo[:])
topo = [[0,topo[0]]]
while queue:
    n1 = queue.popleft()
    for n2 in ad_list[n1]:
        ad_num[n2-1] -= 1
        if ad_num[n2-1] == 0:
            topo.append([n1,n2])
            queue.append(n2)
topo.sort(key=lambda x:x[1])
for i,v in topo:
    print(i)
#  visited = [False for _ in range(N)]

#  ans = 0
#  path_len = 0
#  def dfs(node,cnt=1):
    #  global ans
    #  if visited[node-1]: return 0
    #  visited[node-1] = True
    #  ans = max(ans,cnt)
    #  for n in ad_list[node]:
        #  dfs(n,cnt+1)

#  for n in range(1,N+1):
    #  dfs(n)
#  print(ans)


Measured memory_bytes: 31044
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
int main()
{
  string s;
  cin>>s;
  if(s=="ABC")
    cout<<"ARC"<<endl;
  else
    cout<<"ABC"<<endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define ET cout << "\n"
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef bbq
#define debug(...) {\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}
#define DB(a,s,e) {for(int _i=s;_i<e;++_i) cerr << a[_i] << " ";cerr << "\n";}
template<typename T>void _do(T &&x){cerr<<x<<endl;}
template<typename T,typename ...S> void _do(T &&x,S &&...t){cerr<<x<<", ";_do(t...);}
template<typename a,typename b> ostream& operator << (ostream &s,const pair<a,b> &p){return s<<"("<<p.X<<","<<p.Y<<")";}
#else
#define debug(...)
#define DB(a,s,e)
#endif

ll f(ll a,ll b)
{
    if(a>b) swap(a,b);
    if(b%a==0)
        return 2*b-a;
    return b/a*2*a+f(b%a,a);
}

int main()
{
    IOS();
    ll n,x;
    cin >> n >> x;
    cout << n+f(x,n-x) << "\n";
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 60

// レベル i の時の全体の長さ
ll length[MAX_N];

// n, x の時の P の数を返す
ll dfs(ll n, ll x) {
    if(x == 0) { return 0; }
    if(n == 0) { return (x == 1) ? 1 : 0; }
    if(n == 1) { return (x == 5) ? 3 : x - 1; }
    // x を 2 つに分ける
    if(x - 1 <= length[n-1]) {
        return dfs(n-1, x-1);
    }
    if(x == length[n]) {
        return 1 + dfs(n-1, length[n-1]) * 2;
    }
    ll x1 = length[n-1];
    ll x2 = x - length[n-1] - 2;
    ll ret1 = dfs(n-1, x1);
    ll ret2 = dfs(n-1, x2);
    ll ret = 1 + ret1 + ret2;
    return ret;
}

signed main()
{
    ll N, X;
    cin >> N >> X;

    // length の作成
    length[0] = 1;
    for(int i = 1; i < MAX_N; ++i) {
        length[i] = 3 + length[i-1] * 2;
    }

    ll ans = dfs(N, X);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
    int N;
    cin>>N;
    
    int gain = 0;
    
    vector<int>value(N);
    vector<int>cost(N);
    
    for(int i = 0; i < N; i++){
        cin>>value.at(i);
    }
    
    for(int i = 0; i < N; i++){
        cin>>cost.at(i);
    }
    
    for(int i = 0; i < N; i++){
        if(value.at(i) > cost.at(i)){
            gain += value.at(i) - cost.at(i);
        }
     }
    
    cout<<gain<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,count=1,z;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(i=0;i<n;i++)
  {
    if(a[i]==count)
    {
      count++;
    }
  }
  if(count==1)
  {
    cout<<"-1"<<endl;
  }
  else
  {
    z=n-count+1;
  	cout<<z<<endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll S;
    cin >> S;

    ll x1 = 0, y1 = 0;

    const ll m = 1e9;

    if(S <= m) {
        cout << x1 << " " << y1 << " " << 1 << " " << 0 << " " << 0 << " " << S << endl;
        re0;
    }

    ll x2 = m, y2 = 1;

    if(S == 1e18) {
        ll x3 = 0, y3 = m;
        cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
        re0;
    }
    
    ll y3 = S/m + 1;
    ll z = S%m;
    ll x3 = m - z;
    
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    re0;
}

Measured memory_bytes: 256
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(), a.end());//bという配列を小さい方からソート
  int flag=0;
for(int i=0;i<n-1;i++){
  if(a.at(i) == a.at(i+1)) flag=1;
     }
     if(flag==1)cout<<"NO"<<endl;
     else cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
N = int(input())
l = list(map(int, input().split()))
dp = [0]+[float('inf')]*(N-1)
for i in range(N):
    if i < N-1:
        dp[i+1] = min(dp[i+1], dp[i]+abs(l[i+1]-l[i]))
    if i < N-2:
        dp[i+2] = min(dp[i+2], dp[i]+abs(l[i+2]-l[i]))
print(dp[-1])

Measured memory_bytes: 13800
#include<iostream>
#include<cstdlib>
#include<string>
#include<cstdio>
using namespace std;

struct Node{
    int key;
    Node *parent,*left,*right;
};

Node *root,*NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x!=NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y==NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}



Measured memory_bytes: 26632
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <time.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,string> pip;
typedef vector<pip> vip;
const int inf=2*1e9+1;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b;

int main(){
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}

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

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec.at(i);
    }
    int eat = 0;
    int sum = 0;
    for(int i = 0; i < n; i++){
        eat = (d - 1) / vec.at(i) + 1;
        sum = sum + eat;
    }
    cout << sum + x << endl;
}

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

int main () {
    int x;
    cin >> x;
    cout << x / 500 * 1000 + x % 500 / 5 * 5 << endl;
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n,k;
    cin>>n>>k;
    
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    
    int sum=0;
    int i=0;
    while(k--)
    {
        sum=sum+a[i++];
    }
    cout<<sum;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    ll n;cin>>n;
    vector<ll> h(n);
    rep(i,n) cin >>h[i];
    vector<ll> dp(n);
    //初期化　（最小化問題なのでINFに初期化)
    rep(i,n)dp[i]=LINF;

    //初期条件
    dp[0]=0;
    for(ll i = 1;i<n;i++){
        chmin(dp[i], dp[i-1] + abs( h[i] - h[i-1] ) ); //1つ前の足場とのコスト
        if(i > 1) chmin(dp[i], dp[i-2] + abs( h[i] - h[i-2] ) ); //2つ前の足場とのコスト
    }
    //答え
    cout << dp[n-1]<<endl;

    return 0;
}



Measured memory_bytes: 1792
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
pair < int, int > pos[N];

ll f[N], inv[N];

int mult (int a, int b) {
	return (a * (ll)b) % mod;
}

int C (int n, int k) {
	if (n < k) return 0;
	if (k < 0) return 0;

	return mult(mult(f[n], inv[k]), inv[n-k]);
}

int main () {
	SpeedForce;
	cin >> n;
	++n;
	For (i, 1, n) {
		cin >> a[i];
		if(!pos[a[i]].F) pos[a[i]].F = i;
		else pos[a[i]].S = i;
	}
	int ptr = 1;
	while(!pos[ptr].second) ++ptr;
	inv[1] = 1;
	For (i, 2, n)
		inv[i] = mult(mod-mod/i, inv[mod%i]);
	f[0] = inv[0] = 1;
	For (i, 1, n) {
		inv[i] = mult(inv[i-1], inv[i]);
		f[i] = mult(f[i-1], i);
	}

	cout << n-1 << '\n';
	For (k, 2, n) {
		int ans = C(n, k);

		ans -= C(n - 1 - pos[ptr].second + pos[ptr].first, k-1);
		if(ans < 0) ans += mod;
		
		cout << ans << '\n';
	}

	return Accepted;
}

// B...a

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

int main() {
	int A, B;
	cin >> A >> B;
	for (int i = 1; i <= 1000; ++i) {
		if (i * 8 / 100 == A && i * 10 / 100 == B) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
    int n, m;
    long ai;
    cin >> n >> m;
    vector<long> a(n);
    for (int i = 0; i < n; i++){
        cin >> ai;
        a[i] = ai;
    }
    vector<pair<long, int>> disdiff;
    
    long cut = 0;
    for(int i = 0; i< n; i++){
        long price = a[i];
        long diff;
        bool comp = true;
        for (int j = 0; j < m; j++){
            long pp = price;
            price /= 2;
            diff = pp-price;
            if (diff < cut || diff == 0){
                comp = false;
                break;
            }
            auto r = make_pair(diff, i);
            disdiff.push_back(r);
        }
        if(comp)
            cut = diff;
    }

    sort(disdiff.begin(), disdiff.end(), greater<pair<long, int>>());

    for(int j = 0; j < m; j++){
        if (j >= disdiff.size())
            break;
        int i = disdiff[j].second;
        a[i] /= 2;
    }

    long total = 0;
    for(int i = 0; i< n; i++){
        total += a[i];
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 68448
n = int(input())
a = list(map(int, input().split()))

total = sum(a)
s = 0
ans = 10**9 * 2 * 10**5
for i in range(0, n-1):
    s += a[i]
    ans = min(ans, abs(s - (total-s)))
    
print(ans)


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

int main(){
    using namespace std;
    using tuplis = array<int, 3>;
    const int sq = 1400;
    
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for(int& i : c){
        cin >> i;
        i--;
    }
    vector<tuplis> query(q);
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--;
        query[i] = {l, r, i};
    }
    sort(query.begin(), query.end(), [&](const tuplis& a, const tuplis& b){ if(a[0] / sq == b[0] / sq) return a[1] < b[1]; return a[0] < b[0]; });
    vector<int> ans(q);
    vector<int> cnt(n);
    int types = 0, L = 0, R = 0;
    for(auto [l, r, i] : query){
        while(L < l){
            cnt[c[L]]--;
            types -= !cnt[c[L]];
            L++;
        }
        while(L > l){
            L--;
            types += !cnt[c[L]];
            cnt[c[L]]++;
        }
        while(R > r){
            R--;
            cnt[c[R]]--;
            types -= !cnt[c[R]];
        }
        while(R < r){
            types += !cnt[c[R]];
            cnt[c[R]]++;
            R++;
        }
        ans[i] = types;
    }
    for(int i : ans) cout << i << ' ';
}

Measured memory_bytes: 15468
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl

signed main(void){
    int N;
    int A[214514];
    int B[214514]={};
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }
    REP(i,214514){
        B[i]=INF;
    }
    B[0]=A[0];
    REP(i,N-1){
        B[i+1]=B[i]+A[i+1];
    }
    
    
    int Ans=INF;
    int i=0,k=2;
    //REP(i,N){cout << B[i] << " ";}cout << endl;
    int P[4];
    REP(j,N){
        if(j==0)continue;
        //0~j-1から選ぶ,j~N-1から選ぶ
        int sum1,sum2;
        while(1){
            sum1=abs(B[j]-2*B[i]),sum2=abs(B[j]-2*B[i+1]);
            if(sum1>sum2){
                i++;
            }else{
                break;
            }
        }
        
        while(1){
            sum1=abs(B[N-1]-B[k]-B[k]+B[j]),sum2=abs(B[N-1]-B[k+1]-B[k+1]+B[j]);
            if(sum1>sum2){
                k++;
            }else{
                break;
            }
        }
        
        P[0]=B[i];
        P[1]=B[j]-B[i];
        P[2]=B[k]-B[j];
        P[3]=B[N-1]-B[k];
        sort(P,P+4);
        Ans=min(Ans,P[3]-P[0]);
        //cout << i << " " << j << " " << k << " "<<P[3]-P[0] << endl;
    }
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        String S = sc.next();

        byte[] bytes = S.getBytes();
        for(int i = 0; i < N; i++){
            if(bytes[i] != '('){
                continue;
            }
            for(int j = i + 1; j < N; j++){
                if(bytes[j] == ')'){
                    bytes[i] = bytes[j] = 0;
                    break;
                }
            }
        }

        int lcnt = 0;
        int rcnt = 0;
        for(int i = 0; i < N; i++){
            if(bytes[i] == '('){
                lcnt += 1;
            }

            if(bytes[i] == ')'){
                rcnt += 1;
            }
        }

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < rcnt; i++){
            sb.append("(");
        }
        sb.append(S);
        for(int i = 0; i < lcnt; i++){
            sb.append(")");
        }

        System.out.println(sb.toString());
    }
}

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

int main()
{
  int n, p;
  while( cin >> n >> p, n && p ) {
    int stone[50] = {0};
    int cnt = 0;
    int P = p;
    
    while( 1 ) {
      if( p == 0 ) {
	p = stone[cnt];
	stone[cnt] = 0;
      } else {
	stone[cnt] ++;
	p --;
      }
      if( stone[cnt] == P ) break;
      cnt++;
      if( cnt == n ) cnt = 0;
    }

    cout << cnt << endl;
  }
}

Measured memory_bytes: 3012
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    A, B, T = LI()
    ans = (T // A) * B
    return ans

print(main())

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


int main(){
    ll N;
    cin >> N;
    vector<pair<ll , ll>> a(N + 1);
    for(ll i = 1; i <= N; i++){
        ll tmp;
        cin >> tmp;
        a[i] = make_pair(i, tmp);
    }
    ll cnt = 0, i = 1;
    while(a[i].second != 2){
        if(cnt > 1e8){
            cout << -1 << endl;
            return 0;
        }
        i = a[i].second;
        cnt++;
    }
    cout << cnt + 1 << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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; }
 
int main(){
    string s; cin >> s;
    string ans="";
    rep(i,s.size()){
        if (s[i]!=',') ans+=s[i];
        else ans+=' ';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
    ll mod = 1000000007;
    ll N;
    cin >> N;
    string S;
    cin >> S;
    vector<ll> alfa(26, 0);
    for (ll i = 0; i < N; ++i)
    {
        alfa.at(S.at(i) - 'a') += 1;
    }
    ll ans = 1;
    for (ll i = 0; i < 26; ++i)
    {
        ans = ans * (alfa.at(i) + 1) % mod;
    }
    ans -= 1;
    if (ans < 0)
    {
        ans += mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3716
program main
  integer(8) :: n, i, a, b, nmax, mcd, adum, bdum
  read(*,*) a, b
  nmax = min(a,b)
  mcd = 1
  adum = a
  bdum = b
  do i = 2, nmax
    do while(mod(adum,i)==0.and.mod(bdum,i)==0)
      mcd = mcd * i
      adum = adum/i
      bdum = bdum/i
    end do
  end do
  write(*,*) a*b/mcd
end program main

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long

//gcd(a,b)が1前提のしか作ってない
ll ex_Euclid(ll a,ll b){
	ll q,r,x0,x1,x2,y0,y1,y2;
	x0=1;y0=0;
	x1=0;y1=1;
	while(b>0){
		r=a%b;
		q=a/b;
		x2=x0-x1*q;
		y2=y0-y1*q;
		a=b;b=r;
		x0=x1;x1=x2;
		y0=y1;y1=y2;
	}
	return y0;
}

ll comb(ll N,ll k,ll mod){
	ll i,j;
	vector<ll> fact(N+1);
	fact[0]=1;
	for(i=1;i<=N;i++){
		fact[i]=(fact[i-1]*i)%mod;
	}
	vector<ll> invfact(N+1);
	invfact[N]=ex_Euclid(mod,fact[N])%mod;
	for(i=1;i<=N;i++){
		invfact[N-i]=invfact[N-i+1]*(N-i+1)%mod;
	}
	return fact[N]*invfact[N-k]%mod*invfact[k]%mod;
}


int main(){
	ll MOD=1000000007;
	ll X,Y;
	cin >> X >> Y;
	if(X<Y)swap(X,Y);
	if((X+Y)%3==0 && X<=2*Y){
		cout << comb((X+Y)/3,(2*Y-X)/3,MOD)<<endl;
	}else{
		cout << 0;
	}
    return 0;
}



Measured memory_bytes: 10624
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>

using namespace std;
#define prev prev55

long long n, s, cnt;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        long long a, b;
        cin >> a >> b;
        s += a * b;
        cnt += b;
    }
    cout << cnt + (s - 1) / 9 - 1;
}


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

int main() {
  int n;
  long long int total=0,ans=0;
  vector<long long int> a(200001,0);
  vector<long long int> b(200001,0);
  cin>>n;
  rep(i,0,n){
    int tmp;
    cin>>tmp;
    a[tmp]++;
    b[i]=tmp;
  }
  
  rep(i,1,n+1){
    total+=(a[i]*(a[i]-1))/2;
  }
  //cout<<total<<endl;
  
  rep(i,0,n){
    ans=total;
    ans-=(a[b[i]]*(a[b[i]]-1))/2;
    ans+=((a[b[i]]-1)*(a[b[i]]-2))/2;
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){
	unsigned long long int N,A,B;
	cin>>N>>A>>B;
	if(A>B||A!=B&&N==1){
		cout<<0<<endl;
	}
	else{
		if(A==B)cout<<1<<endl;
		else cout<<(N-2)*(B-A)+1<<endl;
	}
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e20;
const int INF = 1e9;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool flag = false;
  REP(i, s.size()-1){
    if(s[i] == s[i+1]) flag=true;
  }
  puts(flag ? "Bad" : "Good");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#define N 100005
using namespace std;
struct edge{
	int k,next;
}e[N<<3];
int n,home[N],H[N],cnt=-1,IN[N],H1[N];
vector<int> s;
void add(int *home,int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
void dfs(int *home,int k,int F){
	int sum=0;
	for(int i=home[k];~i;i=e[i].next){
		sum^=1;
		dfs(home,e[i].k,k);
	}
	IN[k]=sum^1;
	if(!sum){
		s.push_back(k);
	}
}
int col[N];
void dfs(int k){
	for(int i=home[k];~i;i=e[i].next)if(!col[e[i].k]){
		col[e[i].k]=col[k]^3;
		dfs(e[i].k);
	}
}
int main(){
	memset(home,-1,sizeof(home));
	memset(H,-1,sizeof(H));
	memset(H1,-1,sizeof(H1));
	scanf("%d",&n);
	int r1,r2;
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		if(x>0) IN[x]^=1;
		else r1=i;
		add(H,x,i);
	}
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		if(x>0) IN[x]^=1;
		else r2=i;
		add(H1,x,i);
	}
	for(int i=1;i<=n;i++) if(IN[i]) return puts("IMPOSSIBLE"),0;
	dfs(H,r1,0);
	while(s.size()>1){
		int S=s.size();
		add(home,s[S-1],s[S-2]);
		add(home,s[S-2],s[S-1]);
		s.pop_back();s.pop_back();
	}
	s.clear();
	dfs(H1,r2,0);
	while(s.size()>1){
		int S=s.size();
		add(home,s[S-1],s[S-2]);
		add(home,s[S-2],s[S-1]);
		s.pop_back();s.pop_back();
	}
	for(int i=1;i<=n;i++) if(!col[i]&&IN[i]) col[i]=1,dfs(i);
	puts("POSSIBLE");
	for(int i=1;i<=n;i++){
		if(!col[i]) printf("0 ");
		else if(col[i]==1) printf("-1 ");
		else printf("1 ");
	}
	return 0;
}

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

using namespace std;
using ll = long long;

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

  int n, m;
  cin >> n >> m;
  // connect[i] := i番目のスイッチに繋がっている電球
  vector<vector<int>> connect(n);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      connect[s].push_back(i);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++)
    cin >> p[i];

  int ans = 0;
  for (int b = 0; b < (1 << n); b++) {
    vector<int> cnt(m, 0);
    for (int i = 0; i < n; i++) {
      if (!(~b & (1 << i)))
        continue;
      for (auto e : connect[i]) {
        cnt[e]++;
        cnt[e] %= 2;
      }
    }
    bool f = true;
    for (int i = 0; i < m; i++) {
      if (p[i] != cnt[i])
        f = false;
    }
    if (f)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    cout << min({p+q, q+r, r+p}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    ll n,k,s;
    cin>>n>>k>>s;
    if(s==1e9){
        rep(i,k) cout<<1000000000<<" ";
        rep(i,n-k) cout<<1<<" ";
    }
    else{
        rep(i,k) cout<<s<<" ";
        rep(i,n-k) cout<<s+1<<" ";
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

string s;

int32_t main(){
	cin>>s;
	int n = s.length();
	int ans = 1;
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1]){
			ans++;
		}
	}
	cout<<ans-1;
}


Measured memory_bytes: 512
#!python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    S = input()

    s = 0
    for c in S[1:]:
        if c == 'E':
            s += 1

    ANS = s
    for i in range(1, N):
        if S[i] == 'E':
            s -= 1
        if S[i - 1] == 'W':
            s += 1
        ANS = min(ANS, s)

    print(ANS)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int read();

int N, x[200005], st[200005], a[200005];
int work() {
    int m = N / 2 + 1, res = a[m], l = m, r = m;
    a[0] = a[1], a[N + 1] = a[N];
    for (; l >= 1 && a[l] != a[l - 1] && a[r] != a[r + 1]; --l, ++r) res ^= 1;
    return res;
}

int main() {
 //   freopen("triangle.in", "r", stdin);
   // freopen("triangle.out", "w", stdout);
    N = read() * 2 - 1;
    for (int i = 1; i <= N; ++i) st[i] = x[i] = read();
    sort(st + 1, st + 1 + N);
    int l = 1, r = N, res = r;
    while (l <= r) {
        int mid = l + r >> 1;
        for (int i = 1; i <= N; ++i) a[i] = x[i] > st[mid];
        if (!work())
            r = mid - 1, res = mid;
        else
            l = mid + 1;
    }
    printf("%d\n", st[res]);
    return 0;
}
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    return x * f;
}

Measured memory_bytes: 2560
#define REP(i, s, e) for(register int i = s; i <= e ;i++)

#include <iostream>
#include <cstdio>

using namespace std;
const int maxn = 105;

int m, n, k;
int a[maxn];

int main() {
	cin >> n >> k;
	REP(i, 1, n) scanf("%d", a+i);
	REP(i, 1, n) m += min(abs(a[i]), abs(a[i] - k));
	cout << m * 2;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	vector<int> c(m),a(m),b(m);
	vector<vector<int> > dist(n,vector<int>(n,INF));
	REP(i,m){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;b[i]--;
		dist[b[i]][a[i]] = dist[a[i]][b[i]] = c[i];
	}
	REP(i,n)REP(j,n)if(i == j)dist[i][j] = 0;
	REP(i,n){
		REP(j,n){
			REP(k,n){
				dist[j][k] = min(dist[j][i] + dist[i][k],dist[j][k]);
			}}}
	
	int ans = m;
	REP(i,m){
		bool shortest = false;
		REP(j,n){
			if(dist[j][a[i]] + c[i] == dist[j][b[i]])shortest = true;
		}
	if(shortest)ans--;
	}
	cout << ans << endl;
  return 0;
}


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

int main() {
	int a , b , c , d, e ;
    cin >> a;
    b = a%100 ;
    c = a-b ;
    d = b-b%10 ;
    
    cout << c/100+d/10+a%10 << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int cur = 1;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == cur)
            cur++;
        else a[i] = -1;
    }
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] != -1)
            count++;
    }
    if (count == 0)
        cout << "-1";
    else
        cout << n - count;
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 1792