akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

int N, M, L;
struct edge{int to, cost, peo;};
vector<edge> E[110];
int dist[110][110];//場所, 使った予算
void dijkstra(){
  rep(i, 110)rep(j, 110) dist[i][j] = INF;
  dist[0][0] = 0;
  typedef pair<int, pair<int, int>> P;
  priority_queue<P, vector<P>, greater<P>> pque;
  pque.push({0, {0, 0}});
  while(!pque.empty()){
    P p = pque.top();
    pque.pop();
    if(dist[p.s.f][p.s.s] < p.f) continue;
    for(edge e: E[p.s.f]){
      if(dist[e.to][p.s.s] > p.f + e.peo){
        dist[e.to][p.s.s] = p.f + e.peo;
        pque.push({dist[e.to][p.s.s], {e.to, p.s.s}});
      }
      if(p.s.s+e.cost > L) continue;
      if(dist[e.to][p.s.s+e.cost] > p.f){
        dist[e.to][p.s.s+e.cost] = p.f;
        pque.push({dist[e.to][p.s.s+e.cost], {e.to, p.s.s+e.cost}});
      }
    }
  }
  int ans = INF;
  rep(i, L+1) ans = min(ans, dist[N-1][i]);
  cout << ans << endl;
}

void solve(){
  while(true){
    cin >> N >> M >> L;
    if(N == 0 && M == 0 && L == 0) return;
    rep(i, M){
      int a, b, d, e;
      cin >> a >> b >> d >> e;
      a--, b--;
      E[a].pb({b, d, e});
      E[b].pb({a, d, e});
    }
    dijkstra();
    rep(i, N) E[i].resize(0);
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}



Measured memory_bytes: 3460
N, T = list(map(int, input().split()))
minc = 1001;
for i in range(N):
  c, t = list(map(int, input().split()))
  if(t <= T and c < minc):
    minc = c
if(minc == 1001):
  print("TLE")
else:
  print(minc)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

  int i;
  int judge_number;
  int result_point;

  while(1){
    
    int points[101]={0};
    int max_point=0;
    int min_point=0;
    int max_index=0;
    int min_index=0;
    int sum=0;

    scanf("%d",&judge_number);
    
    if(judge_number==0){
      break;
    }

    for(i=0;i<judge_number;i++){
      scanf("%d",&points[i]);

      if(i==0){
	max_point=points[i];
	min_point=points[i];
      }

      else if(max_point<points[i]){
	max_point=points[i];
	max_index=i;
      }

      else if(min_point>points[i]){
	min_point=points[i];
	min_index=i;
      }

    }

    for(i=0;i<judge_number;i++){
      if(i!=max_index && i!=min_index){
	sum+=points[i];
      }
    }

    result_point=sum/(judge_number-2);

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

  }

  return 0;

}
    

Measured memory_bytes: 600
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
         int N = sc.nextInt();
         int[] L = new int[N];
         int i = 0;
         int j = 0;
         int k = 0;
         int ans = 0;
    
         for(int h = 0 ; h < N ; h++){
                L[h] = sc.nextInt();
         }
         
         Arrays.sort(L);
         
         for(int fir = 0 ; fir < N ; fir++){
                i = L[fir];
                for(int sec = 0 ; sec < N ; sec++){
                    j = L[sec];
                    for(int sir = 0 ; sir < N ; sir++){
                        k = L[sir];
                        if(k > j && j > i){
                            if(k > j - i){
                                if(k < j + i){
                                    ans++;
                                }
                            }
                        }    
                }
                }
         }         
         System.out.println(ans);
    }
}

Measured memory_bytes: 27232
from sys import stdin
import itertools
#print('permutations(range(4))   : ', list(itertools.permutations(range(4) ) ) )

foods = [int(input()) for i in range(5)]
orders = list(itertools.permutations(range(5)))
mintime = 1111111111
ordertime = 0
nowtime = 0
for i in orders:
    ordertime = 0
    l = list(i)
    #print(l)
    ordertime += foods[l[0]]
    for j in range(1, 5):
        #print(ordertime)
        if ordertime%10 == 0:
            ordertime+= foods[l[j]]
        else:
            while ordertime%10 !=0:
                ordertime += 1
            ordertime+=foods[l[j]]
    if mintime > ordertime:
        mintime = ordertime

print(mintime)


Measured memory_bytes: 3064
#include <cstdio>
#include <utility>
#include <cstring>
#include <algorithm>

using namespace std;

#define ll long long
#define pii pair <int, int>
#define f first
#define s second
#define rep(i, l, r) for (int i = l; i <= r; ++ i)
const int MAXN = 200000;
const ll mod = 1000000007;

ll fac[MAXN + 5], inv[MAXN + 5];
inline ll times(const ll &a, const ll &b) {
	return a * b % mod;
}
inline ll C(const int &m, const int &n) {
	ll ret = fac[n + m];
	ret = times(ret, inv[n]);
	ret = times(ret, inv[m]);
	return ret;
}
inline ll calc(const int &x, const int &y, const int &xx, const int &yy) {
	return C(xx - x, yy - y);
}
inline ll fastpow(ll a, ll b) {
	ll ret = 1;
	for (; b; b >>= 1) {
		if (b & 1) {
			ret = times(ret, a);
		}
		a = times(a, a);
	}
	return ret;
}
ll dp[3005];
pii p[3005];
int main() {
	fac[0] = 1;
	inv[0] = 1;
	rep (i, 1, MAXN) {
		fac[i] = times(fac[i - 1], 1ll * i);
		inv[i] = fastpow(fac[i], mod - 2);
	}
	int R, C, n;
	scanf("%d%d%d", &R, &C, &n);
	rep (i, 1, n) {
		scanf("%d%d", &p[i].f, &p[i].s);
	}
	p[n + 1].f = R;
	p[n + 1].s = C;
	sort(p + 1, p + n + 2);
	rep (i, 1, n + 1) {
		dp[i] = calc(1, 1, p[i].f, p[i].s);
	}
	rep (i, 1, n) {
		rep (j, i + 1, n + 1) {
			if (p[j].f < p[i].f || p[j].s < p[i].s) {
				continue;
			}
			dp[j] -= times(dp[i], calc(p[i].f, p[i].s, p[j].f, p[j].s));
			if (dp[j] < 0) {
				dp[j] = (dp[j] + mod) % mod;
			}
			if (dp[j] > mod) {
				dp[j] %= mod;
			}
		}
	}
	printf("%lld\n", dp[n + 1]);
	return 0;
}

Measured memory_bytes: 3328
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($A,$B) = array_map('intval',explode(" ",trim(fgets(STDIN))));
list($A,$B) = explode(" ",trim(fgets(STDIN)));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$B = str_replace(".","",$B);
printf("%d\n",intdiv($A*$B,100));


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

int query(int x) {
   cout << x << endl;
   string s;
   cin >> s;
   if (s == "Male") {
      return 0;
   } else if (s == "Female") {
      return 1;
   } else {
      exit(0);
   }
}

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

   int left = 0, right = n;
   int mid = (left+right)/2;
   int l = query(left), m = query(mid);

   rep (i, 0, 18) {
      // 矛盾の判定
      bool ok = false;
      if ((mid-left)&1) {
         if (l != m) ok = true;
      } else {
         if (l == m) ok = true;
      }

      if (ok) { // 矛盾無し
         left = mid;
         l = m;
      } else { // 矛盾有り
         right = mid;
      }
      mid = (left + right) / 2;
      m = query(mid);
   }

   return 0;
}

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

int main()
{
    int n,i;
    cin>>n;
    vector<int> a(n+1);
    for(i=1;i<=n;i++) cin>>a[i];
    vector<int> dp(n+1);
    dp[0]=dp[1]=0;dp[2]=abs(a[2]-a[1]);
    for(i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var basis = Console.ReadLine().Split();
            int n = int.Parse(basis[0]);
            long d = long.Parse(basis[1]);

            int result = 0;

            for(int i = 0; i < n; i++)
            {
                long[] XY = Console.ReadLine().Split()
                    .Select(long.Parse)
                    .ToArray();

                var x = XY[0];
                var y = XY[1];

                if (x * x + y * y <= d * d)
                    result += 1;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 46624
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		// 計算
		long result = lcm(a, b);
		
		
		// 出力
		System.out.println(result);
	}
	static long gcd(long x, long y){
	    if(y == 0) return x;
	    return gcd(y , x%y);
	}
	static long lcm(long x, long y){
	    return x*y/gcd(x, y);
	}
}




Measured memory_bytes: 21844
#include<algorithm>
#include<cstdio>
#include<map>
#include<iostream>
using namespace std;
int sum;
int a[100005];
int n,m;
map<int,int> cnt,vis;
long long ans;
int main() {
	cin>>n>>m;
	cnt[0]=1;
	for(int i=1;i<=n;i++) {
		cin>>a[i],sum=(sum+a[i]%m)%m;
		if(cnt[sum]>=1) ans+=cnt[sum];
		cnt[sum]++;
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 3584
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var Hs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool[] batList = new bool[NM[0]];
            for (int i = 0; i < NM[1]; i++)
            {
                var AB = Console.ReadLine().Split().Select(x => int.Parse(x) -1).ToArray();
                if (Hs[AB[0]] < Hs[AB[1]])
                {
                    batList[AB[0]] = true;
                }
                else if ((Hs[AB[1]] < Hs[AB[0]]))
                {
                    batList[AB[1]] = true;
                }
                else
                {
                    batList[AB[0]] = true;
                    batList[AB[1]] = true;
                }
            }

            Console.WriteLine(batList.Count(x => x == false));
        }
        
    }
}

Measured memory_bytes: 49412
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
const int INF=1000000;
int main()	{
  int n;
  cin>>n;
  int t,a;
  cin>>t>>a;
  vector<int>avg(n);
  int dif=INF;
  rep(i,n){
    int h;
    cin>>h;
    avg[i]=1000*t-6*h;
    dif=min(dif,abs(avg[i]-1000*a));
  }
  rep(i,n){
    if(dif==abs(avg[i]-1000*a)){
      cout<<i+1<<endl;
      return 0;
    }
  }
  
}
      

Measured memory_bytes: 3572
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
char s[100007];
int get[128];
int main()
{
    get['b'] = 0 , get['p'] = 1 , get['d'] = 2 , get['q'] = 3;
    scanf("%s",s+1); 
    for(int l = strlen(s+1), i = 1; i <= (l>>1) + 1; ++i)
    {
        if(get[s[i]]^((get[s[l-i+1]]+2)%4)) return printf("No\n"),0;
    }
    return printf("Yes\n"),0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;


signed main() {
    int n, k;
    cin >> n >> k;

    if ((n - 1) * (n - 2) / 2 < k) {
        cout << -1 << endl;
        return 0;
    }

    vector<i_i> edges;

    // score:(n-1)(n-2)/2のグラフ
    for (int i = 1; i < n; i++) {
        edges.emplace_back(0, i);
    }

    // (n-1)(n-2)/2 - kだけスコアを減らす
    int a = 1, b = 2;
    for (int i = 0; i < (n - 1) * (n - 2) / 2 - k; i++) {
        edges.emplace_back(a, b);
        if (b == n - 1) {
            a++;
            b = a+1;
        } else b++;
    }

    cout << edges.size() << endl;
    for (auto &it: edges) {
        cout << it.first + 1 << " " << it.second + 1 << endl;
    }
}

// グラフ

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int num,a[100],i,k,l,j;

  cin>>num;
  for(i=0;i<num;i++){
    cin>>a[i];
  }


 for(k=0; k<num; k++){
   
   if(k<num-1){
   cout << a[k]<<" ";
   }else{
     cout <<a[k];
   }
 }
      cout <<endl;
    
  
  for(i=1;i<num;i++){
    for(j=i-1;j>=0;j--){
      if(a[j]>a[j+1]) swap(a[j],a[j+1]);
	     
	else
	  break;

	
    }
 for(k=0; k<num; k++){

   if(k<num-1){
     cout << a[k]<<" ";

   }else
   cout << a[k];


 }

 // if(i!=num-1){
 cout << endl;
 // }
 // cout <<A<<endl;
 
  }
  






      return 0;
}




Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
const bool DBG = 1;

#define TRACE(x)    x
#define WATCH(x)    TRACE(cout << #x" = " << x << endl)
#define WATCHR(a,b) TRACE(for(auto it=a; it!=b;) cout<<*(it++)<<" ";cout<<endl)
#define WATCHC(V)   TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define sort_by(x, y) sort(all(x), [&](const auto& a, const auto& b) { return y; })

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

void solve() {
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);

    ll N; cin >> N;
    ll ans = N;
    F0R(i,N-1) {
        ans += (i+1)*(N-i);
        ll u,v; cin >> u >> v;
        if(u>v) swap(u,v);
        ans -= u*(N-v+1);
    }
    cout << ans << endl;

	return 0;
}


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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(b <= a)cout << "delicious" << endl;
    else if(b - a <= x)cout << "safe" << endl;
    else cout << "dangerous" << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    A,B = map(int,input().split())
    for i in range(10000):
        if (int(i*0.08) == A) and (int(i*0.1) == B):
            break
    if i == 9999:
        print(-1)
    else:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38776
#include<cstdio>

using namespace std;

const int Weit=2;
int weit;
int date;
bool flag;

int main()
{
	while(scanf("%d",&date)!=EOF)
	{
		flag=true;
		for(int i=0;i<10;i++)
		{
			if(i==0)weit=Weit;
			else weit*=2;
			if(date%weit!=0)
			{
				date-=date%weit;
				if(flag==true) flag=false;
				else printf(" ");
				printf("%d",weit/2);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
s = list(input())

count = 0
buf = ''
prev = ''

for i in s:
    buf += i
    if len(prev) == 1 and len(buf) == 1:
        if prev != buf:
            prev = buf
            buf = ''
            count += 1
    else:
        prev = buf
        buf = ''
        count += 1

print(count)


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

vector<int> a, c;

int f(int i, int n) {
  if(a[n] == 2) return i;
  if(c[n] == 1) return -1;
  c[n] = 1;
  return f(i + 1, a[n] - 1);
}

int main() {
  int N; cin >> N;
  a.resize(N);
  c.assign(N, 0);
  rep(i, 0, N) cin >> a[i];
  cout << f(1, 0) << endl;
  return 0;
}


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

int main(){
    int n,ans;
    cin >> n;
    vector<int> a(n);
    ans = 0;
    long long left,right;
    left = 0;
    right = 0;
    for(int i=0; i<n; ++i){
        cin >> a[i];
        right += a[i];
    }
    int k;
    k = 0;
    while (left < right && k<n){
        left += a[k];
        right -= a[k];
        k++;
    }
    // cout <<left-right<< ", "<<(right+a[k-1])-(left-a[k-1])<<"\n";
    ans = min(abs(left-right),abs((right+a[k-1])-(left-a[k-1])));
    if(n==2){
        ans = abs(a[1] - a[0]);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

void solve() {
}

int main() {
#ifdef WIN32
	freopen("input.txt", "r", stdin);
#endif
//	int tc;
//	cin >> tc;
	ll a, b, k, diff;
	cin >> a >> b >> k;
	
	diff = min(k, a);
	a -= diff;
	k -= diff;
	b -= k;
	
	cout << a << " "<< max(0LL,b) << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
 
list_a=[]
for i in a:
  if i%2==0:
    list_a.append(i)

if all([list_a[i]%3==0 or list_a[i]%5==0 for i in range(len(list_a))]):
  print('APPROVED')
else:
  print('DENIED')


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

#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << #x << ':' << x << endl;
#define  rep(i,n)          for(long long i = 0; i <  n ; i++)
#define  reps(i,n)         for(long long i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  REMOVE(v,a)       v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a

using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
const ll MOD = 1e9+7;
bool cmp(int X, int Y) {return X > Y;}

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}

ll ncr(ll n , ll r){
	if(r > n - r) {r = n - r;}
	if(r==1){return n;}
	if(r==0){return 1;}
	
	if(r == n){return 1;}
	
	return ((n*ncr(n-1,r-1))/r)%MOD;
	}


int main(){ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll x = a*c;
ll y = a*d;
ll z = b*c;
ll t = b*d;
ll ans = max({x,y,z,t});
cout<<ans;

}		
		
				


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
const int Maxn = 3e3 + 5, Mod = 1e9 + 7;
typedef long long ll;
typedef int arr[Maxn];
ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, m;
arr a;
ll ans;
ll f[Maxn][Maxn];
ll qp(rg ll x, int y)
{
	rg ll res = 1;
	while (y)
	{
		if (y & 1)
			res = res * x % Mod;
		x = x * x % Mod;
		y >>= 1;
	}
	return res;
}
int main()
{
	rg ll inv2 = qp(2, Mod - 2);
	rg int x, y;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		a[i] = read();
	for (int i = 1; i <= n; i++)
		for (rg int j = 1; j <= n; j++)
			f[i][j] = a[i] > a[j];
	for (rg int i = 1; i <= m; i++)
	{
		x = read();
		y = read();
		f[x][y] = f[y][x] = (f[x][y] + f[y][x]) * inv2 % Mod;
		for (rg int j = 1; j <= n; j++)
			if (j != x && j != y)
			{
				f[j][y] = f[j][x] = (f[j][x] + f[j][y]) * inv2 % Mod;
				f[y][j] = f[x][j] = (f[x][j] + f[y][j]) * inv2 % Mod;
			}
	}
	for (rg int i = 1; i < n; i++)
		for (rg int j = i + 1; j <= n; j++)
			ans = Add(ans, f[i][j]);
	cout << ans * qp(2, m) % Mod << '\n';
	return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,s=1;cin>>n>>k;
    for(int i=0;i<n;i++)
        if(s*2<=s+k)
        s*=2;
    else s+=k;
    cout<<s;
    return 0;
   }

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

int main()  {
  int N;
  int A[200];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  
  int cnt = 0;
  while (true) {
    bool is_odd = false;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 != 0) is_odd = true;
    }
    
    if (is_odd) break;
    
    for (int i = 0; i < N; i++) { 
      A[i] /= 2;
    }
    cnt++;
  }
  cout << cnt << endl;
}
        


Measured memory_bytes: 256
#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 K;
  cin >> K;
  
  vector<ll> a;
  for (int i = 1; i <= 9; i++) a.push_back(i);

  while (1) {
      if (K <= a.size()) {
          cout << a.at(K-1) << endl;
          return 0;
      }
      K = K - a.size(); // 桁ごとに計算しているので、下の桁の分削っておく
      vector<ll> old = a;
      a = {};
      // swap(old, a);
      for (ll x : old) {  // 桁ごとに計算する
          for (int i = -1; i <= 1; ++i) {
              int d = x%10 + i;
              if (d < 0 || d > 9) continue;
              ll nx = x*10 + d;
              a.push_back(nx);
          }
      }
  }
  
  return 0;
  
  
}

Measured memory_bytes: 1784
#include<stdio.h>

int main()
{
  int aa[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
  int seihou[200][2],an[100][2],i,n,m=0,ten,muki;
  int minx=0,maxx=0,miny=0,maxy=0;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    seihou[0][0]=0;
    seihou[0][1]=0;
    for(i=1;i<n;i++){
      scanf("%d%d",&ten,&muki);
      seihou[i][0]=seihou[ten][0]+aa[muki][0];
      seihou[i][1]=seihou[ten][1]+aa[muki][1];
    }
    for(i=0;i<n;i++){
      if(minx>seihou[i][0])minx=seihou[i][0];
      else if(maxx<seihou[i][0])maxx=seihou[i][0];
      else if(miny>seihou[i][1])miny=seihou[i][1];
      else if(maxy<seihou[i][1])maxy=seihou[i][1];
    }
    an[m][0]=maxx-minx+1;
    an[m][1]=maxy-miny+1;
    m++;
    maxx=0;minx=0,miny=0,maxy=0;
  }
  for(i=0;i<m;i++){
    printf("%d %d\n",an[i][0],an[i][1]);
  }
  return 0;
}

Measured memory_bytes: 600
using System;

namespace ARC096C
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int A = int.Parse(target[0]);
            int B = int.Parse(target[1]);
            int C = int.Parse(target[2]);
            int X = int.Parse(target[3]);
            int Y = int.Parse(target[4]);
            int count = 0;
            if(X > Y){
              if(A+B < 2*C) count += Y*(A+B);
                else count += Y*2*C;
              if(A < 2*C) count += (X-Y)*A;
                else count += (X-Y)*2*C;
            } else {
              if(A+B < 2*C) count += X*(A+B);
                else count += X*2*C;
              if(B < 2*C) count += (Y-X)*B;
                else count += (Y-X)*2*C;
            }
            Console.WriteLine(count);
        }
    }
}


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

int main(){
  int N,D,ans=1,cnt=0;
  cin >> N >> D;
  cnt+=2*D+1;
  while(1){
    if(cnt<N){
      ans++;
      cnt+=2*D+1;
    }
    else{
      cout << ans << endl;
      break;
    }
  }
}

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 int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}
const ll MOD = 1000000007;
int main()
{
    ll n, ans = 1;;
    cin >> n;
    for(int i = 1; i <= n; i++){
        ans = (i*ans)%MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string s,t;
  cin>>s>>t;
  vector<lint> ss[26];
  lint Ns=s.size();
  lint Nt=t.size();
  REP(i,Ns){
    ss[s[i]-'a'].push_back(i);
  }
  for(auto c:t){
    if(ss[c-'a'].empty()){
      cout<<-1<<endl;
      return 0;
    }
    ss[c-'a'].push_back(ss[c-'a'][0]+Ns);
  }
  lint D[Nt];
  D[0]=ss[t[0]-'a'][0];
  FOR(i,1,Nt){
    auto itr=lower_bound(ALL(ss[t[i]-'a']),(D[i-1]%Ns)+1);
    D[i]=*(itr)+Ns*(D[i-1]/Ns);
  }
  cout<<D[Nt-1]+1<<endl;
  return 0;
}


Measured memory_bytes: 3452
n = int(input())
ans = 0
def dfs(num ,depth, three,five,seven):
    global ans
    if depth == 0:
        if three and five and seven and num <= n:
            ans += 1
    else:
        dfs(10*num+3, depth-1, True, five, seven)
        dfs(10*num+5, depth-1, three, True, seven)
        dfs(10*num+7, depth-1, three, five, True)
for i in range(len(str(n))):
    dfs(0,i+1,False,False,False)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  int x,a,b,c,d;
  scanf("%d", &x);
  d= x%  10;
  c=(x% 100-    d)/ 10;
  b=(x%1000-x%100)/100;
  a= x/1000;
    
  if	 (  a+b+c+d == 7 ){ printf("%d+%d+%d+%d=7",a,b,c,d); }
  else if(  a+b+c-d == 7 ){ printf("%d+%d+%d-%d=7",a,b,c,d); }
  else if(  a+b-c+d == 7 ){ printf("%d+%d-%d+%d=7",a,b,c,d); }
  else if(  a+b-c-d == 7 ){ printf("%d+%d-%d-%d=7",a,b,c,d); }
  else if(  a-b+c+d == 7 ){ printf("%d-%d+%d+%d=7",a,b,c,d); }
  else if(  a-b+c-d == 7 ){ printf("%d-%d+%d-%d=7",a,b,c,d); }
  else if(  a-b-c+d == 7 ){ printf("%d-%d-%d+%d=7",a,b,c,d); }
  else if(  a-b-c-d == 7 ){ printf("%d-%d-%d-%d=7",a,b,c,d); }
  return 0;
}

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

const int MAXN = 105;
const int MAX_K = (int)1e5 + 5;
const int MOD = (int)1e9 + 7;

int a[MAXN];
int dp[MAXN][MAX_K];

int main(void) {
    int n, k;

    scanf(" %d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf(" %d", &a[i]);
    }

    for (int j = 0; j <= a[n]; j++) {
        dp[n][j] = 1;
    }
    for (int i = n - 1; i >= 0; i--) {
        int idx = 0;
        int sum = 0;
        for (int j = 0; j <= k; j++) {
            sum += dp[i + 1][j];
            sum %= MOD;
            while(j - a[i] > idx) {
                sum -= dp[i + 1][idx];
                sum = (sum % MOD + MOD) % MOD;
                idx++;
            }
            dp[i][j] = sum;
        }
    }
    printf("%d\n", dp[1][k]);

    return 0;
}


Measured memory_bytes: 41088
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pii pair<int,int>
using namespace std;
void boost(){
 ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n,a[100005],b[100005],c[100005],ans;
main(){
boost();
cin>>n;
for(int k=1;k<=n;k++)
    cin>>a[k];
for(int k=1;k<=n;k++)
    b[k]=__gcd(a[k],b[k-1]);
for(int k=n;k>=1;k--)
    c[k]=__gcd(a[k],c[k+1]);
for(int k=1;k<=n;k++){
    ans=max(ans,__gcd(b[k-1],c[k+1]));
}
cout<<ans;
return 0;
}


Measured memory_bytes: 2560
# ABC089D - Practical Skill Test
def main():
    H, W, D, *X = map(int, open(0).read().split())
    memo = [None] * (H * W + 1)  # memo[i] := coordinate of i
    for i, a in enumerate(zip(*[iter(X[: H * W])] * W), 1):
        for j, x in enumerate(a, 1):
            memo[x] = (i, j)
    dist = [0] * (H * W + 1)  # dist[i] := distance to i from 1
    for r in range(D + 1, H * W + 1):
        rx, ry = memo[r]
        l = r - D
        lx, ly = memo[r - D]
        dist[r] = dist[l] + abs(rx - lx) + abs(ry - ly)
    ans = []
    for l, r in zip(*[iter(X[H * W + 1 :])] * 2):
        ans.append(dist[r] - dist[l])
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 36424
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;	

int main() {
    string a, b, c; cin >> a >> b;

    c = a + b;
    int d = stoi(c);
    int e = sqrt(d);
    if (e * e == d) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3716
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);

// ===

const INF: usize = 1000000000;

fn decode(x: usize, y: usize, r: usize, c: usize) -> usize {
    if y == 0 {
        x
    } else if x == r {
        r + y
    } else if y == c {
        r + c + r - x
    } else if x == 0 {
        r + c + r + c - y
    }  else {
        INF
    }
}

fn main() {
    let (r, c, n): (usize, usize, usize) = read();
    let points: Vec<(usize, usize, usize, usize)> = readn(n);

    let mut pairs = vec![];
    for i in 0..n {
        let fpos = decode(points[i].0, points[i].1, r, c);
        let tpos = decode(points[i].2, points[i].3, r, c);
        if fpos == INF || tpos == INF {
            continue
        }
        pairs.push((fpos, i));
        pairs.push((tpos, i));
    }

    pairs.sort();

    let mut stk = VecDeque::new();
    let mut isok = true;
    let mut seen = vec![false; n];
    for i in 0..pairs.len() {
        let (_, i) = pairs[i];
        if !seen[i] {
            stk.push_front(i);
            seen[i] = true;
        } else {
            if stk.len() == 0 {
                isok = false;
                break
            }
            let last = stk.pop_front().unwrap();
            if last != i {
                isok = false;
                break
            }
        }
    }
    if stk.len() != 0 {
        isok = false;
    }

    if isok {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 14396
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000; // 十分大きな値

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int len = s.size();
    for(int i=0;i < len;++i) if(s[i] == '+') ans++;else ans--;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long ll;
using namespace std;
ll inf = 1000000007;
ll c[55];
int main() {
	int n, m, x;
	cin >> n >> m >> x;
	ll ans = inf;
	vector<vector<int>>a(n);
	for (int i = 0; i < n; i++) {
		 cin >> c[i];
		 a[i].resize(m);
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	for (int bit = 0; bit < (1 << n); bit++) {
		bool ok = true;
		ll count = 0;
		vector<int>t(m, 0);
		for (int j = 0; j < n; j++) {
			if (bit & (1 << j)) {
				count += c[j];
				for (int k = 0; k < m; k++) {
					t[k] += a[j][k];
				}
			}
		}
		for (int j = 0; j < m; j++) {
			if (t[j] < x) {
				ok = false;
			}
		}
		if (ok) {
			ans = min(ans, count);
		}
	}
	if (ans == inf) {
		cout << "-1" << endl;
	}
	else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    double x;
    string u;
    double ans = 0;
    for(int i = 0; i < n; i++){
        cin >> x >> u;
        if(u == "JPY"){
            ans += x;
        }else{
            ans += 380000 * x;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
fgets(STDIN);
$m=explode(' ',trim(fgets(STDIN)));
$m=array_unique($m);
rsort($m);
$pt=0;
while(true){
for($pt=0;$pt<sizeof($m)-1;$pt++){
  $f = $m[$pt] % $m[$pt+1];
  if($f==0){
    $m[$pt] = $m[$pt+1];
  }else{
    $m[$pt] = $f;
  }
}
$m=array_unique($m);
if(sizeof($m)==1){
  echo $m[0];break;
}
rsort($m);
}

Measured memory_bytes: 20852
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=[],n=!0,o=!1,u=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw u}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}e.exports=function(e){var t=r(e.split("\n")[0].split(" ").map(function(e){return Number(e)}),2),n=t[0],o=2*t[1]+1,u=Math.ceil(n/o);console.log(u)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 11468
N = int(input())
flag = True
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*(n+h) <= 0:
            continue
        if N*h*n < (4*h*n-N*(n+h)):
            continue
        if flag and (N*n*h) % (4*h*n-N*(n+h)) == 0:
            print(str(h)+' '+str(N*n*h //(4*h*n-N*(n+h)))+' '+str(n))
            flag = False
        if not flag:
            break
    if not flag:
        break



Measured memory_bytes: 40668
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define test ll t; cin>>t; while(t--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
#define MAX 1000005
#define forci(p,q) for(int i=p;i<q;i++)
bool prime[MAX];
/*ull sieve()
{
	memset(prime,true,sizeof(prime));
	for(ull p=2;p*p<MAX;p++)
	{
		if(prime[p]==true){
			for(ull i=2*p;i<MAX;i+=p)
			{
				prime[i]=false;
			}
		}
	}
	prime[0]=0;
	prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int n;
	cin>>n;
	string s;
	map<string,int>x;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		x[s]++;
	}	
	cout<<x.size()<<endl;
	
	
	
	
	
	
	
}





Measured memory_bytes: 19216
n,m = map(int,input().split())
if n >= 3 and m >= 3:
    ans = (n-2) * (m-2)
elif n >= 3 and m==1:
    ans = n-2
elif m >= 3 and n==1:
    ans = m-2
elif n==1 and m==1:
    ans = 1
else:
    ans = 0
print(ans)


Measured memory_bytes: 38256
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
LL read(){
	LL f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 100000
char S[10];
int main(){
	scanf("%s",S);
	if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3])
		puts("Bad");
	else puts("Good");
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 200090;

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

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
    k = read(), n = read();
    for(int i = 1;i <= n;i++) {
    	a[i] = read();
	}
	
	for(int i = 1 ;i <= n;i++) {
		d[i]=a[i]-a[i-1];
	}
	for(int i=1 ;i <= n;i++){
		m=max(m,d[i]);
	}
	m=max(m,k-a[n]+a[1]);
		
	printf("%d\n",k-m);
	return 0;
}

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

int main(void) {
    int w, h, n, area[114][114] = {}, ans = 0;
    cin >> w >> h >> n;
    for (int i = 0; i < n; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            for (int i = 0; i < x; i++) {
                for (int j = 0; j < h; j++) {
                    area[i][j] = 1;
                }
            }
        }
        if (a == 2) {
            for (int i = x; i < w; i++) {
                for (int j = 0; j < h; j++) {
                    area[i][j] = 1;
                }
            }
        }
        if (a == 3) {
            for (int i = 0; i < w; i++) {
                for (int j = 0; j < y; j++) {
                    area[i][j] = 1;
                }
            }
        }
        if (a == 4) {
            for (int i = 0; i < w; i++) {
                for (int j = y; j < h; j++) {
                    area[i][j] = 1;
                }
            }
        }
    }
    for (int j = 0; j < h; j++) {
        for (int i = 0; i < w; i++) {
            if (!area[i][j]) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter

N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)

S = sum(V[:A])
cnt = A
mx = S / cnt
L = [cnt]

for v in V[A:]:
    if cnt == B:
        break
    cnt += 1
    S += v
    if mx < S / cnt:
        mx = S / cnt
        L = []
    if mx == S / cnt:
        L.append(cnt)

def ncr(n, r):
    ret = 1
    for i in range(r):
        ret *= (n - i)
    for i in range(1, r + 1):
        ret //= i
    return ret

print(mx)
ans = 0
cntV = Counter(V)
for c in L:
    cnt = Counter(V[:c])
    prd = 1
    for x, c in cnt.items():
        prd *= ncr(cntV[x], c)
    ans += prd
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include <cstdlib>
#include<list>
#include<string>
#include<stack>
using namespace std;
int main(){
	int a;
	stack <int> b;
	while (cin >> a) {
		if (a != 0) {
			b.push(a);
		}
		else {
			cout << b.top() << endl;
			b.pop();
		}
	}
    return 0;
}

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

#define FOR(i,a,b) for(int i = (a);i < (b);++i)
typedef long long ll;

int main(){
    int A,B; cin >> A >> B;
    if(B %A == 0) cout << A+B << endl;
    else cout << B - A << endl;
    return 0;
}

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

int main(){
  for(int i = 0; i < 2; ++i){
    vector<int> S(10);
    for(int j = 0; j < 10; ++j){
      cin >> S[j];
    }
    sort(S.rbegin(), S.rend());
    int s = 0;
    for(int j = 0; j < 3; ++j)
      s += S[j];
    cout << s << (i+1 < 2 ? " " : "\n");
  }
}



Measured memory_bytes: 3088
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,j,k,ans=0;
  char s[1010][1010];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%s",s[i]);
  for(i=0;i<n;i++)strcpy(s[i+n],s[i]);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      for(k=0;k<n;k++){
	if(s[i+j][k]-s[i+k][j])goto END;
      }
    }
    ans+=n;
  END:;
  }
  printf("%d\n",ans);
  return 0;
}


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

bool determined(vector<pair<int, int>> votes, int current){
  sort(votes.begin(), votes.end(), greater<pair<int, int> >());
  // for(int i = 0; i < votes.size(); i++){
  //   cout << votes[i].first << " " << votes[i].second + 'A' << endl;
  // }
  if(votes[0].first == votes[1].first) return false;
  if(votes[0].first - votes[1].first > n - (current + 1)){
    cout << (char)(votes[0].second + 'A') << " " << current + 1 << endl;
    return true;
  }else{
    return false;
  }
}

int main(void){
  while(cin >> n, n != 0){
    bool flg = false;
    vector<char> arr(n);
    if(n == 1){
      char c; cin >> c;
      cout << c << " " << 1 << endl;
      continue;
    }
    vector<pair<int, int>> votes(30);
    for(int i = 0; i < (int)votes.size(); i++){
      votes[i] = make_pair(0, i);
    }
    for(int i = 0; i < n; i++){
      char c; cin >> c;
      arr[i] = c;
    }
    for(int i = 0; i < n; i++){
      char c = arr[i];
      c -= 'A';
      votes[c].first++;
      if(flg = determined(votes, i)){
        break;
      }
    }
    if(flg == false)
      cout << "TIE" << endl;
  }
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if(a%2==1){
			sum++;
		}
	}
	if(sum%2==0){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ar = new int[n];
		boolean F = false;
		for (int i=0; i<n; i++) {
			ar[i] = sc.nextInt();
			if (ar[i]%2==1) {F = true;}
		}
		
		if (F == true) {out.println(0);}
		else {
			int min = Integer.MAX_VALUE;
			for (int i=0; i<n; i++) {
				int times = 0;
				while (ar[i]%2==0) {
					ar[i] /= 2;
					times++;
				}
				min = Math.min(min,times);
			}
			out.println(min);
		}
	}
}

Measured memory_bytes: 23892
from copy import deepcopy

N = int(input())
S = list(input())
newS = deepcopy(S)

i = 0
while 1:
    if i >= len(S):
        break
    if S[i] == "(":
        j = i
        while 1:
            if j >= len(S):
                break
            if S[j] == ")":
                S.pop(j)
                S.pop(i)
                i = -1
                break
            j += 1
    i += 1

y = S.count("(")
x = S.count(")")

print("(" * x + "".join(newS) + ")" * y)


Measured memory_bytes: 3444
N = int(input())


def is_prime(n):
    for i in range(1, n):
        if i != 1 and n % i == 0:
            return False
    return True


def prime_numbers():
    num = 5
    while True:
        is_num_prime = is_prime(num)
        if is_num_prime and num % 5 == 1:
            yield num
        num += 1


prime_gene = prime_numbers()
ans = [next(prime_gene) for _ in range(N)]
print(*ans)


Measured memory_bytes: 3060
n = [int(s) for s in input().split(' ')]
v = [int(s) for s in input().split(' ')]
c = [int(s) for s in input().split(' ')]

result=0
for i in range(n[0]):
  tmp = v[i]-c[i]
  if tmp>0:
    result+=tmp
    
print(result)
               

Measured memory_bytes: 3060
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	using namespace std;
	int n;
	cin>>n;
	if(n==0){
		cout<<0<<endl;
		return 0;
	}
	vector<int> v;
	while(n!=0){
		if(n%2==0){
			v.push_back(0);
			n=n/-2;
		}
		if(n%2!=0){
			v.push_back(1);
			n=(n-1)/-2;
		}
	}
	reverse(v.begin(),v.end());
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int b[N];
    int ans[N];
    for(int i=1;i<=N;i++){
        cin >> b[i];
    }
    
    int NN=N;
    int count=0;
    for(int i=0;i<N;i++){
        for(int j=NN;j>0;j--){
            if(b[j]==j){
                ans[i] = b[j];
                for(int k=j;k<=NN-1;k++){
                    b[k] = b[k+1];
                }
                NN--;      
                break;
            }
        }
    }
    reverse(ans,ans+N);
    int flag=0;
    for(int i=0;i<N;i++){
        if(ans[i]<=N&&ans[i]>=1){
        }else{
            flag++;
        }
    }
    if(flag>0){
        cout << -1 << endl;
    }else{
        for(int i=0;i<N;i++){
            cout << ans[i] << endl;
        }
    }
}

Measured memory_bytes: 256