akhauriyash/Code-Regression huggingface dataset:
# knk_kei  0 in a の条件は不要 
n = int(input())
a = [int(i) for i in input().split()]
if len([i for i in a if i < 0]) % 2 == 0:
    print(sum([abs(i) for i in a]))
else:
    print(sum([abs(i) for i in a]) - 2*min([abs(i) for i in a]))

Measured memory_bytes: 14284
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n,k;
int a[100001];

void input(){
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> a[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    cout << (n-2)/(k-1)+1 << endl;
    return 0;
}

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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
ll aI, aO, aT, aJ, aL, aS, aZ;

int main() {
	cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ;
	ll ans = aO + (aI / 2) * 2 + (aJ / 2) * 2 + (aL / 2) * 2;
	if (aJ && aI && aL) {
		ans = max(ans, aO + ((aI - 1) / 2) * 2 + ((aJ - 1) / 2) * 2 + ((aL - 1) / 2) * 2 + 3);
	}
	cout << ans << "\n";
	return 0;
}




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

int main() {
    int n;
    cin >> n;
    string s;
    cin >>s;
    
    int count = 0;
    rep(i,n) {
        if(s.at(i) == 'R'){
        count++;
        }
     }
    
    int rbx = 0;
    for(int i = 0;i<count;i++) {
     if(s.at(i) == 'R'){
      rbx++;
     }
    }
    
    if(count-rbx<count){
     cout << count-rbx;
    } else {
     cout << count;
    }
}

Measured memory_bytes: 3748
from collections import deque
n, m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
ai = 1
q1 = deque()
q1.append(a[0]//2)
for i in range(1,m):
    ql = q1.popleft()
    if ai < n and a[ai] > ql:
        q1.appendleft(ql)
        q1.append(a[ai]//2)
        ai += 1
    else:
        q1.append(ql//2)

ans = sum(q1)
for i in range(ai,n):
    ans += a[i]

print(ans)


Measured memory_bytes: 14636
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  ll a,b,n;
  cin >> a >> b >> n;
  
  if(n<b){
    ll ans = (a*n/b) - a*(n/b);
    cout << ans << endl;
  }else{
    ll ans = 0;
    rep(i,a){
      ll x = ll(i+1)*b - 1LL;
      if(x>n) break;
      ll val = (a*x/b) - a*(x/b);
      ans = max(ans,val);
    }
    cout << ans << endl;
  }
}

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

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

    ll a, b;
    cin >> a >> b;
    
    ll m = max(a, b);
    ll s = min(a, b);
    
    for(int i=s; i<=m; i++){
        if(abs(m-i) == abs(s-i)){
            cout << i << endl;
            return 0;
        }
    }
    
    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 256
/*  AtCoder Grand Contest 017. Problem A, by Abreto<m@abreto.net>. */
#include <stdio.h>

int N, P;
int A[64];
long long int dp[64][2];

int main(void)
{
    int i = 0;
    int t = 0, Ai = 0;

    scanf("%d%d", &N, &P);
    scanf("%d", &Ai);
    if(Ai & 1)
    {
        dp[1][0] = 1; dp[1][1] = 1;
    } else {
        dp[1][0] = 2; dp[1][1] = 0;
    }
    for(i = 2;i <= N;++i)
    {
        scanf("%d", &Ai);
        if(1 == (Ai%2))
        {
            dp[i][0] = dp[i-1][1] + dp[i-1][0];
            dp[i][1] = dp[i-1][0] + dp[i-1][1];
        } else {
            dp[i][0] = dp[i-1][0]*2;
            dp[i][1] = dp[i-1][1]*2;
        }
    }
    printf("%lld\n", dp[N][P]);

    return 0;
}


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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

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

   bool f = true;
   for (int i = 0; i < s.size(); i++) {
      if (i < a) {
         if (s[i] >= '0' && s[i] <= '9') {

         } else {
            f = false;
         }
      } else if (i == a) {
         if (s[i] != '-') {
            f = false;
         }
      } else {
         if (s[i] >= '0' && s[i] <= '9') {

         } else {
            f = false;
         }
      }
   }

   if (f) {
      puts("Yes");
   } else {
      puts("No");
   }

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  long long N, ans = 0, num, input, min;
  cin >> N;
  num = N;
  for(int i = 0; i < 5; i++){
    cin >> input;
    if(i == 0 || min > input) min = input;
  }
  ans = (N + min - 1) / min + 4;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    import math
    a, b, h, m = map(int, input().split())


    if 0 <= h/6  + m/360 - m/30 <1:
        c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos((h/6 + m/360 - m/30)*math.pi))
    elif 1 <= h/6  + m/360 - m/30 <2:
        c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos((-h/6  - m/360+ m/30)*math.pi))
    elif -1 <= h/6 + m/360 - m/30 <0:
        c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos((-h/6 - m/360 + m/30)*math.pi))
    elif -2 <= h/6  + m/360 - m/30 <-1:
        c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos((h/6 + m/360 - m/30)*math.pi))
    print(c)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9556
#include <cstdio>
#include <algorithm>
using namespace std;
int n,a[15];
void dfs(int step,int pre){
	int i,j,now;
	if(step==n){
		for(j=0;j<n;j++)printf("%c",a[j]+'a');
		printf("\n");
		return ;
	}
	now=min(step,pre+1);
	for(i=0;i<=now;i++){
		a[step]=i,pre=max(pre,i);
		dfs(step+1,pre);
	}
}
int main(){
	scanf("%d",&n);
	dfs(0,-1);
	return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string N; cin >> N;
    ll sum = 0;
    for(auto s:N){
        sum += s - '0';
    }
    if(atoi(N.c_str())%sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
char map[105][105];
int main() {
	int a,b;
	scanf("%d%d",&a,&b);
	printf("100 100\n");
	--a;
	for(int i=1;i<=50;++i) {
		for(int j=1;j<=100;++j) {
			map[i][j]='#';
		}
	}
	while(a--) {
		for(int i=1;i<=49;++i) {
			for(int j=1;j<=100;++j) {
				bool check=true;
				for(int x=-1;x<=1;++x) {
					for(int y=-1;y<=1;++y) {
						if(1<=i+x&&i+x<=50&&1<=j+y&&j+y<=100&&map[i+x][j+y]=='.') {
							check=false;
						}
					}
				}
				if(check) {
					map[i][j]='.';
					goto continue0;
				}
			}
		}
		continue0:continue;
	}
	--b;
	for(int i=51;i<=100;++i) {
		for(int j=1;j<=100;++j) {
			map[i][j]='.';
		}
	}
	while(b--) {
		for(int i=52;i<=100;++i) {
			for(int j=1;j<=100;++j) {
				bool check=true;
				for(int x=-1;x<=1;++x) {
					for(int y=-1;y<=1;++y) {
						if(51<=i+x&&i+x<=100&&1<=j+y&&j+y<=100&&map[i+x][j+y]=='#') {
							check=false;
						}
					}
				}
				if(check) {
					map[i][j]='#';
					goto continue1;
				}
			}
		}
		continue1:continue;
	}
	for(int i=1;i<=100;++i) printf("%s\n",map[i]+1);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	boolean result = false;
	int count=0;
	int cc = -1;
	for(int i=2;i<S.length()-1;i++){
	    if(S.charAt(i) == 'C'){
		result=true;
		count++;
		cc = i;
	    }
	}
	if(S.charAt(0)!='A') result=false;

	if(count != 1){
	    result = false;
	}else if(cc != -1){
	    for(int i=1;i<S.length();i++){
		if(i!=cc){
		    if(Character.isUpperCase(S.charAt(i)))
			result = false;
		}
	    }
	}
	if(result) System.out.print("AC");
	else System.out.print("WA");
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}

void solve(void){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll e[n];
    ll w[n];
    rep(i,0,n) e[i] = w[i] = 0;

    ll tmp = 0;

    rep(i,0,n){
        if(s[i] == 'W'){
            tmp++;
        }
            w[i] = tmp;
    }

    tmp = 0;
    
    rrep(i,n-1,0){
        if(s[i] == 'E'){
            tmp++;
        }
            e[i] = tmp;
    }
    
    ll ans = e[1];
    rep(i,1,n-2){
        ans = min(ans,w[i-1]+e[i+1]);
    }
    ans = min(ans,w[n-2]);
    cout << ans << endl;
 
}

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

Measured memory_bytes: 5396
# Binary indexed tree
from sys import stdin
readline = stdin.readline


def bit_add(bit, i, x):
    i += 1
    n = len(bit)
    while i <= n:
        bit[i - 1] += x
        i += i & -i


def bit_sum(bit, i):
    result = 0
    i += 1
    while i > 0:
        result += bit[i - 1]
        i -= i & -i
    return result


def query(bit, start, stop):
    if start == 0:
        return bit_sum(bit, stop - 1)
    else:
        return bit_sum(bit, stop - 1) - bit_sum(bit, start - 1)


N, M = map(int, readline().split())
ab = [list(map(int, readline().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

bit = [0] * (N - 1)
result = 0
for a, b in ab:
    a, b = a - 1, b - 1
    if query(bit, a, b) != 0:
        continue
    result += 1
    bit_add(bit, b - 1, 1)
print(result)


Measured memory_bytes: 28696
import math
a, b, h, m = map(int, input().split())
p = math.pi
angle = abs(p*(h + m/60)/6 - p*m/30)
angle = min(angle, 2*math.pi - angle)
ans = (a**2 + b**2 - 2*a*b*math.cos(angle))**(1/2)
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define vi vector<int>
#define vvi vector<vi>

#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;






int main(){

        ll n,m;
        cin >> n >> m;

        ll ans = (m*1900 + (n-m)*100) * (1 << m);
      
        cout << ans << endl;

        return 0;

}












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

int main() {
    int n;
    cin >> n;
    map<string, int> m;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        m[s]++;
    }
    int a = 0;
    for(auto p : m)
        a = max(a, p.second);
    for(auto p : m)
        if(a == p.second)
            cout << p.first << '\n';
    cout << flush;
    return 0;
}


Measured memory_bytes: 25216
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define mst(a) memset(a, 0, sizeof(a))
#define _test printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
const ll ll_INF = 233333333333333;
const int maxn = 1e5+10;
int res[maxn];
int main(void) {
    ll s, c;
    while(~scanf("%lld%lld", &s, &c)) {
        ll res;
        if (s == c/2) {
            res = s;
        }
        else if (s < c/2) {
            res = s + (c-2*s)/4;
        }
        else if (s > c/2) {
            res = c/2;
        }
        printf("%lld\n", res);
    }
    return 0;
}

Measured memory_bytes: 256
#E
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N%2 == 0:
    n = int(N/2)
    xmin = (A[n-1]+A[n])
    xmax = (B[n-1]+B[n])
    count = int(xmax)-int(xmin+0.5)+1
else:
    n = int((N+1)/2)
    xmin = A[n-1]
    xmax = B[n-1]
    count = xmax-xmin+1

print(count)

Measured memory_bytes: 25468
N = int(input())
As = list(map(int, input().split()))
count_dict = {}


def calc_combo(n):
    return int(n * (n - 1) / 2)


for i in range(N):
    try:
        count_dict[As[i]] += 1
    except KeyError:
        count_dict[As[i]] = 1

combo = 0
for key in count_dict:
    combo += calc_combo(count_dict[key])

for i in range(N):
    num_delete = As[i]
    try:
        num_count = count_dict[num_delete]
        out = combo - calc_combo(num_count) + calc_combo(num_count - 1)
        print(out)
    except KeyError:
        print(combo)

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

pair<string, pair<int, int>> pr[105];
int n;

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        int p;
        cin >> s >> p;
        pr[i] = make_pair(s, make_pair(100-p,i+1));
    }
    sort(pr, pr+n);
    for(int i = 0; i < n; i++){
        printf("%d\n", pr[i].second.second);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    int a , b;
    cin >> a;
    for ( int i = 1 ; i <= a ; i++ ) {
        b += i;
    }
    cout << b;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b,c,x,y=map(int, input().split())
    if a+b<=2*c:
        ans=x*a+y*b
    else:
        ans=2*c*min(x,y)
        if x>y:
            x-=y
            ans+=min(2*c*x,a*x)
        elif x<y:
            y-=x
            ans+=min(2*c*y,b*y)
    print(ans)
resolve()

Measured memory_bytes: 38256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

#include <boost/multiprecision/cpp_int.hpp>
 using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair

cpp_int Kai(int n){
  cpp_int t = 1;
  FOR(i,2,n+1)t*=i;
  return t;
}

int main(){
  CIN(n,a,b);vector<ll> v(n);VECCIN(v);
  sort(ALL(v),greater<ll>());
  vector<ll> vec;
  REP(i,a)vec.pb(v[i]);
  ll bound = vec.back();

  int allcou=count(ALL(v),bound);

  cpp_int ncr=0;
  if(vec[0]==bound)
    FOR(cou,a,b+1)
      ncr += Kai(allcou)/(Kai(cou)*Kai(allcou-cou));
  else{
    int cou = count(ALL(vec),bound);
    ncr = Kai(allcou)/(Kai(cou)*Kai(allcou-cou));
  }

  double maxav = 1.0 * accumulate(ALL(vec),0LL) / a;
  printf("%.8f\n",maxav);
  COUT(ncr);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main()
{
    long long n,a,b;
    cin >> n >> a >> b;
    long long ans=0;
    long long num=n/(a+b);

    ans+=num*a;
    n%=(a+b);
    if(n>=a)ans+=a;
    else ans+=n;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n;
		n = scan.nextInt();
		String ss = scan.next();
		char[] c = ss.toCharArray();

		int ans = 0;
		for(int i = 0; i <= n-3; i ++) {
			if(c[i] == 'A' && c[i+1] == 'B' && c[i+2] == 'C') {
				ans++;
			}
		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
    int A,B,C;
    cin >> A >> B >>C;
    if(A+B+C == 17 && A*B*C == 175){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    
    
    
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
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 const INF = 1 << 30;


int main()
{
    ll n;
    cin >> n;
    ll res = 0;
    for(int a = 1; a < n; a++) {
        res += (n-1)/a;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main(void)
{
  int N;

  int i,j;

  cin >> N;
  int keta = 0;
  for(i = N;i > 0;i /= 10){
    keta++;
  }

  int output = 0;
  for(i = 1,j = 1;i < keta;i++){
    if(i%2){
      output += 9 * j;
      j *= 100;
    }
  }

  if(keta%2){
    cout << (output + (N - j + 1)) << endl;
  }
  else {
     cout << output << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    char S[3];
    cin>>S[0]>>S[1]>>S[2];
    if(S[0] == S[1] and S[1] == S[2])
    {
        cout<<"No"<<endl;
    }
    else{
            cout<<"Yes"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;


int main(void){
	int a,b;
	char s;
	cin >> a >> s >> b;

	if(s == '+'){
		cout << a + b << endl;
	} else {
		cout << a - b << 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++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  string s;
  cin >> s;
  bool flag = false;
  erep1(i,s.size()){
    for(int j = i;j<s.size();j++){
      //cout << s.substr(0,i) << " " << s.substr(j,s.size()-j) << endl;
      if(s.substr(0,i)+s.substr(j,s.size()-j) == "keyence") flag = true;
    }
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=200000+100;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
    #define N 200000

    int fac[N+100],invfac[N+100];

    int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
    int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
    int mul(int x,int y) {return 1ll*x*y%maxd;}
    ll qpow(ll x,int y)
    {
        ll ans=1;
        while (y)
        {
            if (y&1) ans=mul(ans,x);
            x=mul(x,x);y>>=1;
        }
        return ans;
    }
    int getinv(int x) {return qpow(x,maxd-2);}

    int C(int n,int m)
    {
        if ((n<m) || (n<0) || (m<0)) return 0;
        return mul(mul(fac[n],invfac[m]),invfac[n-m]);
    }

    int A(int n,int m)
    {
        if ((n<m) || (n<0) || (m<0)) return 0;
        return mul(fac[n],invfac[n-m]);
    } 

    void math_init()
    {
        fac[0]=invfac[0]=1;
        rep(i,1,N) fac[i]=mul(fac[i-1],i);
        invfac[N]=getinv(fac[N]);
        per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
    }
    #undef N
}
using namespace My_Math;

int f[N];

int main()
{
    int n=read(),m=read(),k=read();
    int ans=0;
    math_init();
    f[0]=1;f[1]=m;
    rep(i,2,n) f[i]=mul(f[i-1],m-1);
    rep(i,0,k)
    {
        //cout << f[n-i] << endl;
        ans=add(ans,mul(f[n-i],C(n-1,n-i-1)));
    }
    printf("%d",ans);
    return 0;
}

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

using namespace std;
 
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(x) (int) ((x).size()) 
#define forn(i, n) for (int i = 0; (i) < (n); ++i)
#define fornr(i, n) for (int i = (n) - 1; (i) >= 0; --i)
#define forab(i, a, b) for (int i = (a); (i) < (b); ++i)
#define forba(i, a, b) for (int i = (b) - 1; (i) >= (a); --i)
#define forit(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end() 

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) static_cast<void>(0)   
#endif

#ifdef _WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
typedef vector <int> vi;
typedef pair <int, int> pii;

#define FNAME ""

const int MAX_N = 1e5 + 5;

char s[MAX_N];

int main() {
#ifdef LOCAL    
	freopen(FNAME".in", "r", stdin);
	freopen(FNAME".out", "w", stdout); 
#endif    

	int k;
	scanf("%s%d", s, &k);
	int n = strlen(s);
	forn (i, n) {
	 	if (s[i] != 'a') {
	 	 	if (k >= ('z' - s[i] + 1))
	 	 		k -= ('z' - s[i] + 1), s[i] = 'a';
	 	}
	}
	k %= 26;
	forn (j, k)
		if (s[n - 1] == 'z')
			s[n - 1] = 'a';
		else
			s[n - 1]++;
	puts(s);
	return 0;
}

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

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e6 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 3e5 + 17;

int n, k;
int cnt[maxn];

bool read() {
    if (scanf("%d %d", &n, &k) != 2)
        return false;

    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++cnt[x];
    }

    return true;
}

void solve() {
    sort(cnt, cnt + maxn);
    reverse(cnt, cnt + maxn);
    printf("%d\n", accumulate(cnt + k, cnt + maxn, 0));
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 1408
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int size = 10000010;
        long[] num = new long[size];
        Arrays.fill(num, 2);
        num[1] = 1;
        int sizer = (int)(Math.sqrt(size));

        for (int i = 2; i <= sizer; i++) {
            int mn = i;
            int mmn = mn*mn;
            if(mmn < size) num[mmn]++;
            mmn += mn;
            while(mmn < size){
                num[mmn] += 2;
                mmn += mn;
            }
        }

        long ans = 0;

        for (int i = 1; i <= n; i++) {
            ans += i * num[i];
        }

        System.out.println(ans);

    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}




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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int INF=1e18;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    int ans=0;
    for(int i=2;i*i<=n;i++)
    {
        int k=0;
        while(n%i==0)
            k++,
            n/=i;
        for(int j=1;k>=j;j++)
            k-=j,
            ans++;
    }
    if(n>1)
        ans++;
    cout<<ans;
}


Measured memory_bytes: 3692
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int x,y,dx,dy,n,t,tl,i;
bool b;
int main()
{
//	freopen("traveling.in","r",stdin);
//	freopen("traveling.out","w",stdout);
 	cin>>n;
 	x=0;y=0;b=1;tl=0;
 	for (i=1;i<=n;i++)
 	{
 		cin>>t>>dx>>dy;
 		if (b)
 		{
 			if (t-tl<abs(x-dx)+abs(y-dy)||((t-tl-abs(x-dx)-abs(y-dy))%2==1))
 			b=0;
 			tl=t;x=dx;y=dy;
		 }
	 }
	 if (b) cout<<"Yes"<<endl;
	 else cout<<"No"<<endl;
	return 0;
}



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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=(x);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

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

#define WA printf("WA\n");
int main()
{
    ll n,k;
    string s;

    cin >> n >> s >> k;
    rep(i,n){
        if(s[i] == s[k-1])cout << s[i];
        else cout << '*';
    }
    cout << 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++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int N, H;
    cin >> N >> H;
    vint a(N), b(N);
    vector<bool> throwed(N);
    rep(i, N)
    {
        cin >> a[i] >> b[i];
    }
    sort(all(a),greater<int>());
    sort(all(b),greater<int>());
    int aidx = 0, bidx = 0, ans = 0;
    while (H > 0)
    {
        if (a[aidx] >= b[bidx]) //and !throwed[aidx] and !throwed[bidx])
        {
            H -= a[aidx];
        }
        else
        {
            H -= b[bidx];

            bidx++;
        }
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

const int MAXN = 3000 + 10;
long long a[MAXN];
long long dp[MAXN][MAXN];

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

    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < n; i++)
        dp[i][i] = a[i];

    for (int r = 0; r < n; r++) {
        for (int l = r-1; l >= 0; l--) {
            dp[r][l] = max(a[r] - dp[r-1][l], a[l] - dp[r][l+1]);
        }
    }

    cout << dp[n-1][0];
    return 0;
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define frst first
#define sec second
#define fast cin.tie(0) , ios_base :: sync_with_stdio(0)
#define db double
#define mod 1000000007
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}



ll dp[101][100001];
ll solve1(ll wt[] , ll p[] , ll n , ll w)
{
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= w; ++j)
		{
			if (i == 0 || j == 0) {
				dp[i][j] == 0;
				continue;
			}
			dp[i][j] = dp[i - 1][j];
			if (j >= wt[i - 1])
			{
				dp[i][j] = max(dp[i][j] , dp[i - 1][j - wt[i - 1]] + p[i - 1]);
			}
		}
	}
	////cout << dp[n][w] << endl;
	return dp[n][w];
}

void go() {
	ll n , w;
	cin >> n >> w;
	ll wt[n] , p[n];
	for (int i = 0; i < n; ++i)cin >> wt[i] >> p[i];
	//memset(dp , -1 , sizeof dp);
	cout << solve1(wt , p , n , w);
}


int main() {
	fast;
///	online_judge();
	//cout << 2332;
	go();
}

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

int main(){
  int n;
  cin >> n;
  int s = 0;
  
  for(int i = 0;i < n;i++) {
    int l,r;
    cin >> l >> r;
    s += r - l +1 ;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) sort(ALL(x), greater<T>())
#define REVERSE(x) reverse(ALL(x))
#define ACM(x, y) accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

// デバッグ用
#define PUT_LIST(x, y) std::copy(ALL(x), ostream_iterator<decltype(x)::value_type>(cout, y))

const int kMod = 1e9 + 7;

itn main() {
	ios::sync_with_stdio(false);

	int n, m;

	cin >> n >> m;

	vector<int> a(n);

	REP(i, n) {
		cin >> a[i];
	}

	RSORT(a);

	int sum = ACM(a, 0);

	if (a[m - 1] * m * 4 < sum) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main(void) {
	int N,K;
	cin >> N >> K;
	double res = 0;
	for (int i = 0; i < N; ++i) {
		int score = i+1;
		double prob = (double)1/N;
		while (score < K) {
			score *= 2;
			prob /= 2;
		}
		res += prob;
	}
	cout << setprecision(20) << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n, h, w;

    cin >> n;
    cin >> h;
    cin >> w;

    int ans;

    if(h == 1 && w == 1){
        ans = n * n;
    }else{
        ans = ((n - h) + 1) * ((n - w) + 1);
    }
    cout << ans << endl;

}

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

using namespace std;

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

	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		ans = max(ans, c[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

int main(){
	int n, num;
	int sum_a = 0;
	int *p;

	scanf("%d\n", &n);
	p = malloc(n * sizeof(int));
	for(int i=0; i<n; i++){
		p[i]=0;
	}
	num = n-1;
	while (0<num){
		int up_no = 0;
		char c = getchar();
		while((c!=' ') && (c!=10)){
			up_no *= 10;
			up_no += c - '0';
			c = getchar();
		}
		p[up_no-1]++;
		num--;
	}
	for(int i=0; i<n; i++){
		printf("%d\n", p[i]);
	}
	return (0);
}

Measured memory_bytes: 2516
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using std::min;
const int M=2e5+7,inf=0x3f3f3f3f;
char c[M];
int f[M],n,g[(1<<26)+7],s[M];
int main(){
	memset(g,0x3f,sizeof(g));
	g[0]=0;
	scanf("%s",c+1); n=strlen(c+1);
	for(int i=1;i<=n;i++) s[i]=s[i-1]^(1<<(c[i]-'a'));
	for(int k=1;k<=n;k++){
		f[k]=g[s[k]]+1;
		for(int i=0;i<26;i++) f[k]=min(f[k],g[s[k]^(1<<i)]+1);
		g[s[k]]=min(g[s[k]],f[k]);
	}printf("%d\n",f[n]);
	return 0;
}

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

int main(int argc, char const* argv[])
{
    int N;
    cin >> N;

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

    int M;
    cin >> M;

    vector<int> P(M), X(M);
    for (int i = 0; i < M; ++i) {
        cin >> P[i] >> X[i];
    }

    int S = accumulate(T.begin(), T.end(), 0);

    for (int i = 0; i < M; ++i) {
        cout << S - T[P[i] - 1] + X[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

typedef long long ll;

const ll INF = 1e18;
const int BIG = 1e9;
const int maxN = 100 * 1000 + 9;
const string FILENAME = "sample";

string s;

void read(){
	cin >> s;
}

void solv(){
	for(int i = 0; i + 1 < 4; i++){
		if(s[i] == s[i + 1]){
			cout << "Bad\n";
			return;
		}
	}

	cout << "Good\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
#ifdef h4h4
	freopen((FILENAME + ".inp").c_str(), "r", stdin);
	freopen((FILENAME + ".out").c_str(), "w", stdout);
#endif

	read();
	solv();

	return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; cin>>N;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin>>tmp;
        ans += --tmp;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
//#define min(a, b, c) min(a, min(b, c))
//#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	vector<pll> cans(n);
	for(int i=0;i<n;i++)
	cin>>cans[i].fi>>cans[i].se;
	sor(cans);
	ll sum=0;
	ll cost=0;
	for(int i=0;i<n;i++)
	{
	    if(sum+cans[i].se<=m)
	    {sum+=cans[i].se;cost+=cans[i].fi*cans[i].se;}
	    else
	    {
	        cost+=cans[i].fi*(m-sum);
	        sum=m;
	        break;
	    }
	    if(sum==m)
	    break;
	}
	cout<<cost;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Data
{
    public string Str { get; set; }
    public int Num { get; set; }
}

class Program
{       

    static void RoundRobin(Queue<Data> que, int q, List<Data> result)
    {
        int time = 0;
        while(que.Count > 0)
        {
            if(que.Peek().Num <= q)
            {
                time += que.Peek().Num;
                Data a = new Data();
                a.Str = que.Peek().Str;
                a.Num = time;
                result.Add(a);
                que.Dequeue();           
            }
            else if(que.Peek().Num > q)
            {
                time += q;
                Data a = new Data();
                a.Str = que.Peek().Str;
                a.Num = que.Peek().Num - q;
                que.Dequeue();
                que.Enqueue(a);
            }
        }        
    }

    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int n = int.Parse(s[0]);
        int q = int.Parse(s[1]);

        var que = new Queue<Data>();
        var result = new List<Data>();

        //データの格納
        for(int i = 0; i < n; i++)
        {
            string[] ss = Console.ReadLine().Split(' ');
            var data = new Data();
            data.Str = ss[0];
            data.Num = int.Parse(ss[1]);
            que.Enqueue(data);
        }

        //データの処理
        RoundRobin(que, q, result);
        　
        foreach(var p in result)
        {
            Console.WriteLine($"{p.Str} {p.Num}");
        }

    }
}


Measured memory_bytes: 27624
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int r,g;
    cin >> r >> g;

    cout << 2*g -r;

    return 0;
}

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

int a[200005];
int l[200005];
int r[200005];

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

    l[0] = a[0];
    for(int i = 1; i < n; ++i){
        l[i] = __gcd(l[i- 1], a[i]);
    }
    r[n - 1] = a[n - 1];
    for(int i = n - 2; i >= 0; --i){
        r[i] = __gcd(r[i + 1], a[i]);
    }

    int mx = 0;
    for(int i = 1; i < n - 1; ++i){
        mx = max(mx, __gcd(r[i + 1], l[i - 1]));
    }
    mx = max(mx, r[1]);
    mx = max(mx, l[n - 2]);

    cout << mx << "\n";
    return 0;
}


Measured memory_bytes: 1408
from collections import deque

S = deque(list(input()))
Q = int(input())

inv = 0
for i in range(Q):
  query = input().split()
  if query == ['1']:
    inv = (inv + 1)%2
  else:
    f, c = query[1], query[2]
    if f == '1':
      if inv:
        S.append(c)
      else:
        S.appendleft(c)
    else:
      if inv:
        S.appendleft(c)
      else:
        S.append(c)

S = list(S)
if inv:
  print(''.join(S[::-1]))
else:
  print(''.join(S))

Measured memory_bytes: 10084
from collections import deque
N, K = map(int, input().split())
S = input()
que = deque()
p = 0
q = 0
num = 0
i = 0
while i < N:
    if S[i] == '0':
        tmp = 0
        while i < N and S[i] == '0':
            tmp += 1
            i += 1
        que.append(p + tmp)
        q += que[-1]
        if len(que) > K:
            q -= que.popleft()
        num = max(num, q)
    else:
        tmp = 0
        while i < N and S[i] == '1':
            tmp += 1
            i += 1
        p = tmp
        num = max(num, q + tmp)
print(num)




Measured memory_bytes: 3564
using System;

namespace C
{
    class Kock
    {
        public void kock(double n, double p1x, double p1y, double p2x, double p2y)
        {
            if (n==0)
            {
                return;
            }
            double sx = (2 * p1x + 1 * p2x) / 3;
            double sy = (2 * p1y + 1 * p2y) / 3;
            double tx = (1 * p1x + 2 * p2x) / 3;
            double ty = (1 * p1y + 2 * p2y) / 3;
            double ux = (tx - sx) * Math.Cos(60 * (Math.PI / 180)) - (ty - sy) * Math.Sin(60 * (Math.PI / 180)) + sx;
            double uy = (tx - sx) * Math.Sin(60 * (Math.PI / 180)) + (ty - sy) * Math.Cos(60 * (Math.PI / 180)) + sy;
            //Console.WriteLine(String.Format("{0:f8} {1:f8}", p1x, p1y));
            kock(n - 1, p1x, p1y, sx, sy);
            Console.WriteLine(String.Format("{0:f8} {1:f8}", sx, sy));
            kock(n - 1, sx, sy, ux, uy);
            Console.WriteLine(String.Format("{0:f8} {1:f8}", ux, uy));
            kock(n - 1, ux, uy, tx, ty);
            Console.WriteLine(String.Format("{0:f8} {1:f8}", tx, ty));
            kock(n - 1, tx, ty, p2x, p2y);
            //Console.WriteLine(String.Format("{0:f8} {1:f8}", p2x, p2y));
            

        }
    }

    class C
    {
        static void Main(string[] args)
        {
            string n;
            Kock a = new Kock();
            n = Console.ReadLine();
            if (int.Parse(n)==0)
            {
                n = Console.ReadLine();
                Console.WriteLine(String.Format("{0:f8} {1:f8}", 0, 0));
                Console.WriteLine(String.Format("{0:f8} {1:f8}", 100, 0));
            }
            else
            {
                Console.WriteLine(String.Format("{0:f8} {1:f8}", 0, 0));
                a.kock(int.Parse(n), 0.0, 0.0, 100.0, 0.0);
                Console.WriteLine(String.Format("{0:f8} {1:f8}", 100, 0));
            }
        }
    }
}



Measured memory_bytes: 9308
import java.util.*;

public class Main {
    private static final long MODVAL = 1000000007L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        double t = (double)L / 3.0;
        double result = t * t * t;
        System.out.println(String.format("%.12f", result));
     }
}


Measured memory_bytes: 23252