akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;


int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	int ans = 1;
	N -= K;
	if (N%(K-1) == 0) {
		ans += N / (K - 1);
	}
	else {
		ans += N / (K - 1);
		ans++;
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 

using namespace std;

int a, p;

int main()
{
	scanf("%d%d", &a, &p);
	p = p + a * 3;
	int count = p / 2;
	printf("%d\n", count);
	
	return 0;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t r;
  std::cin >> r;
  std::cout << 3 * r * r << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    ll ans = 0;
    REP(i, 3) if (s[i] == t[i]) ans++;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: [u32;5]
    }
    let mut a: Vec<(u32,u32)> = a.into_iter().map(|x| {
        let m = if x % 10 == 0 {0} else {10 - x % 10};
        (x,m)
    }).collect();
    a.sort_by_key(|x| x.1);
    let s: u32 = a.iter().map(|x| x.0 + x.1).sum();
    println!("{}", s - a.iter().last().unwrap().1);
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[][] cost = new int[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					cost[i][j] = in.nextInt();
				}
			}

			Set<Integer> s = new HashSet<>();
			Set<Integer> t = new HashSet<>();

			s.add(0);
			for (int i = 1; i < n; i++) {
				t.add(i);
			}
			boolean[] isVisited = new boolean[n];
			isVisited[0] = true;

			long ans = 0;
			while (!t.isEmpty()) {
				int min = INF;
				int to = -1;
				for (int i : s) {
					for (int j = 0; j < cost[i].length; j++) {
						if (cost[i][j] != -1 && cost[i][j] < min && !isVisited[j]) {
							min = cost[i][j];
							to = j;
						}
					}
				}
				if (to != -1) {
					t.remove(to);
					s.add(to);
					ans += min;
					isVisited[to] = true;
				}
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}
}



Measured memory_bytes: 29664
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int h, w;
  cin >> h >> w;
  int c[h + 1][w + 1], r[h + 1][w + 1];
  FOR(i, 1, h + 1) {
    FOR(j, 1, w + 1) {
      cin >> c[i][j];
    }
  }

  rep(i, h + 1) {
    rep(j, w + 1) {
      r[i][j] = 0;
    }
  }

  int ans = 0;
  FOR(i, 1, h + 1) {
    FOR(j, 1, w + 1) {
      if (c[i][j] == 1) r[i][j] = 0;
      else {
        r[i][j] = min({r[i - 1][j - 1], r[i - 1][j], r[i][j - 1]}) + 1;
        ans = max(ans, r[i][j]);
      }
    }
  }

  cout << ans * ans << endl;



  
  return 0;
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll N; cin >> N;
    ll res = 0;
    for(int i =1; i <= N; i += 2) {
        ll count = 0;
        rep(j, 1, i+1) if (i%j==0) count++;
        if (count == 8) res++;
    }
    cout << res << endl;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

int main(){
	ll n,m;
	cin>>n>>m;

	if(n==1 && m==1){
		cout<<1<<endl;
	}else if(n==1 || m==1){
		cout<<n*m-2<<endl;
	}else{
		cout<<(n-2)*(m-2)<<endl;
	}

	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

typedef struct vector
{
    double x, y;
} vec;

main()
{
    vec p1, p2, p3;
    char c;
    while (cin >> p1.x >> c >> p1.y >> c >> p2.x >> c >> p2.y >> c >> p3.x >> c >> p3.y)
    {
        vec a, b;
        a.x = p2.x - p1.x;
        a.y = p2.y - p1.y;
        b.x = p3.x - p1.x;
        b.y = p3.y - p1.y;

        double outer = a.x * b.y - a.y * b.x;
        double th = acos((a.x * b.x + a.y * b.y) / (sqrt(a.x * a.x + a.y * a.y) * sqrt(b.x * b.x + b.y * b.y)));
        double x, y;
        if (outer > 0)
        {
            x = cos(-2 * th) * b.x - sin(-2 * th) * b.y;
            y = sin(-2 * th) * b.x + cos(-2 * th) * b.y;
        }
        else
        {
            x = cos(2 * th) * b.x - sin(2 * th) * b.y;
            y = sin(2 * th) * b.x + cos(2 * th) * b.y;
        }
        printf("%.8f %.8f\n", x + p1.x, y + p1.y);
    }
    return 0;
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std ;
int main () {
  int N ;
  cin >> N ;
  int a[N] ;
  for(int i = 0 ; i < N ; i++ ) cin >> a[i] ;
  int pre = a[0] ;
  int ans = 0 ;
  int tmp = 1 ;
  for(int i = 1 ; i < N ; i++ ){
    if(a[i]==pre){
      tmp++ ;
    } else { 
      ans += tmp/2 ;
      tmp = 1 ;
      pre = a[i] ;
    }
  }
  ans += tmp/2 ;
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

static inline s64 rs64() {
	s64 a;
	scanf("%" SCNd64, &a);
	return a;
}

static inline void wi(int a) {
	printf("%d", a);
}

static inline void wu64(u64 a) {
	printf("%" PRIu64, a);
}

int comp_int(const void* a, const void* b) {
	return (*((int*)a) - *((int*)b));
}

int main() {
	int n = ri();
	int a[n];
	int b[n];
	FOR(i,n) {
		a[i] = ri();
		b[i] = a[i] - i;
		// printf("a : %d, b : %d\n", a[i], b[i]);
	}
	qsort(b, n, sizeof(int), comp_int);
	int index;
	if (!n%2) index = n/2-1;
	else index = n/2;
	int minus = b[index];
	u64 res = 0;
	// printf("index : %d\nminus : %d\n", index, minus);
	FOR(i,n) {
		res += (u64)abs(a[i]-minus-i);
	}
	
	wu64(res);
	
	return 0;
}


Measured memory_bytes: 2556
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    hat=[0,0,0]
    colors=0
    ans=1

    for i in range(N):
        if A[i]==0:
            ans *= 3 - colors
            colors += 1
            continue
        factor=0
        flag=1
        for j in range(colors):
            if A[i] == hat[j]+1:
                factor += 1
                hat[j] += flag
                flag = 0
        ans = (ans * factor) % MOD

    print(ans)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14324
import heapq

N, M = map(int, input().split())

a = [-int(x) for x in input().split()]

heapq.heapify(a)

num = 0
hq = 1

while num < M and hq != 0:
    hq = -heapq.heappop(a)
    hq2 = hq // 2
    heapq.heappush(a, -hq2)
    num += 1

print(-sum(a))

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

char s[15], t[15];

int main () {
    scanf("%s%s",&s,&t);
    // // printf("%s %s",s,t);
    // int flag=1;
    // for(int i=0;i<2;i++) {
    //     for(int j=0,k=i;j<strlen(s);k++,j++) {
    //         // printf("%c %c ", s[j], t[k]);
    //         if(s[j]==t[k]) continue;
    //         else {
    //             flag=0;
    //             break;
    //         }
    //         // printf("\nflag: %d\n",flag);
    //     }
    //     if (flag==1) {
    //         printf("Yes");
    //         return 0;
    //     }
    //     else flag=1;
    // }
    // printf ("No");
    
    
    
    
    
    // int f1=0,f2=0;
    // if(s[0]==t[0]) {
    //     f1=1;
    //     for(int i=0;i<strlen(s);i++) {
    //         if(s[i]!=t[i]) f1=0;
    //     }
    // }
    // if(s[0]==t[1]) {
    //     f2=1;
    //     for(int i=0;i<strlen(s);i++) {
    //         if(s[i]!=t[i+1]) f2=0;
    //     }
    // }
    // // printf("f1:%d f2:%d",f1,f2);
    // if(f1==0&&f2==0) printf("No");
    // else printf("Yes");
    
    
    int f1=0;
    if(s[0]==t[0]) {
        f1=1;
        for(int i=0;i<strlen(s);i++) {
            if(s[i]!=t[i]) f1=0;
        }
    }
    // printf("f1:%d f2:%d",f1,f2);
    if(f1==0) printf("No");
    else printf("Yes");
    
    
    
    
}

Measured memory_bytes: 1728
x, y = map(int, input().split())
ans = 0

if x == 1 and y == 1:
    ans += 400000

if x == 3:
    ans += 100000
elif x == 2:
    ans += 200000
elif x == 1:
    ans += 300000

if y == 3:
    ans += 100000
elif y == 2:
    ans += 200000
elif y == 1:
    ans += 300000

print(ans)


Measured memory_bytes: 3316
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
lis.sort()
x=lis[0]
for i in range(n-1):
    x=gcd(x,lis[i+1])
if lis[-1]-k>=0 and (lis[-1]-k)%x==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")



Measured memory_bytes: 91324
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

long count(int n, int k, int s, long[int[]] memo) {
	if(([n,k,s] in memo) !is null) {
		return memo[[n,k,s]];
	}
	if(n <= 0 || s <= 0) {
		return 0;
	}
	if(k == 1) {
		if(n >= s) {
			return 1;
		} else {
			return 0;
		}
	}
	long ans;
	for(int i = 1; i <= n; ++i) {
		ans += count(i-1, k-1, s-i, memo);
	}
	memo[[n, k, s].idup] = ans;
	return ans;
}

void main(){
	while(true) {
		auto nks = readInts();
		auto n = nks[0];
		auto k = nks[1];
		auto s = nks[2];
		if((n|k|s) == 0) return;
		long[int[]] memo;
		writeln(count(n, k, s, memo));
	}
}

Measured memory_bytes: 3040
#include <stdio.h>
#define LL long long
int main(){
	LL x,y;
	int i;
	scanf("%lld",&x);
	y=100;
	for(i=1;i<=4000;i++){
		y=y+y*0.01;
		if(y>=x)break;
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, a, b) for(int i = (a); i < (b); i++)

int main() {
  int n;
  int count = 0;
  cin >> n;

  vector<int> d(n);
  rep(i, n) {
     cin >> d.at(i);
  }
  sort(d.begin(), d.end());

  rep2(i, d.at(n/2-1)+1, d.at(n/2)+1) {
     count++;
  }

  cout << count << endl;
}


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

int main() {
	int N;
	cin>>N;
	vector<ll> a(N);
	for(int i=0;i<N;i++){
		cin >> a.at(i);
	}
	sort(a.begin(),a.end());
	ll ans=a.at(0);
	bool p=true;
	while(p){
		ans=a.at(0);
		for(int i=1;i<N;i++){
			a.at(i)=a.at(i)%ans;
			if(a.at(i)==0){
				// cout<<"erased;"<<a.at(i)<<endl;
				a.erase(a.begin()+i);
				i--;
				N--;
				if(a.size()==1){
					p=false;
					break;
				}
			}
		}
		
		if(p)sort(a.begin(),a.end());
	}
	ans=a.at(0);
	cout<<ans<<endl;
}

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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

long g(int r, int c, long mod, long *seki, long *shou){
    long g1;
    g1 = seki[r+c+2] * shou[r+1];
    g1 %= mod;
    g1 *= shou[c+1];
    g1 %= mod;
    g1 -= 1;
    if(g1 < 0)
        g1 += mod;
    return g1;
}

int main()
{
    int r1, c1, r2, c2;
    long seki[2000005], shou[1000005];
    long mod = 1000000007;
    long ans;

    cin >> r1 >> c1 >> r2 >> c2;

    seki[0] = 0;
    seki[1] = 1;
    REP(i, 2000001){
        seki[i+2] = seki[i+1] * (long)(i+2);
        seki[i+2] %= mod;
    }
    shou[0] = 1;
    shou[1] = 1;
    REP(i, 1000001){
        shou[i+2] = shou[i+1] * modinv(i+2, mod);
        shou[i+2] %= mod;
    }
    ans = 0;
    ans = g(r2, c2, mod, seki, shou) + g(r1 - 1, c1 - 1, mod, seki, shou);
    ans %= mod;
    ans -= g(r1 - 1, c2, mod, seki, shou);
    if(ans < 0)
        ans += mod;
    ans -= g(r2, c1 - 1, mod, seki, shou);
    if(ans < 0)
        ans += mod;

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



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

int main() {
  int x,aa,ans;
  cin>>x;
  if(x<4)cout<<1<<endl;
  else{
  for(int i=2;i*i<x;i++){
    aa=i*i;
    for(;aa<=x;){
      ans=max(ans,aa);
      aa*=i;
    }
  }
  cout<<ans<<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
ll cn[100005];
int main() {
	// your code goes here
	
	ll i,j,k,n,m,t;
	cin>>n;
	ll sum = 0;
	for(int i=0;i<n;i++) {
	    cin>>j;
	    sum += j;
	    cn[j]+=1;
	}
	
	cin>>t;
	while(t--){
	    ll p,q;
	    cin>>p>>q;
	    ll c1 = cn[p];
	    sum = sum + c1*(q-p);
	    cn[p] = 0;
	    cn[q] += c1;
	    cout<<sum<<"\n";
	}
	
	return 0;
}


Measured memory_bytes: 4400
#include <stdio.h>
int main(void) {
	char s[5];
	scanf("%s",s);

	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3] || s[3] == s[4]) {
		printf("Bad");
	}
	else {
		printf("Good");
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int k = stdIn.nextInt();

		if(k <= a) {
			System.out.println(k);
		} else if(k <= a + b) {
			System.out.println(a);
		} else {
			int res = k - a - b;
			System.out.println(a - res);
		}

		System.out.println();

		stdIn.close();
	}
}


Measured memory_bytes: 35808
#include <bits/stdc++.h>
using namespace std;
int main() {
	//input
	int N;
	cin >> N;

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

	//calculation
	sort(S.begin(), S.end());
	S.erase(unique(S.begin(), S.end()), S.end());
 

	//output
	int output = S.size();
	cout << output << endl;


	return 0;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;
const ll LIMIT = 1e18;

void solve(long long N, std::vector<long long> A){
    ll answer = 1;
    if (find(all(A), 0) != A.end()) {
        cout << 0 << endl;
        return;
    }
    rep(i,0,N) {
        if (answer > LIMIT / A[i]) {
            cout << -1 << endl;
            return;
        }
        answer *= A[i];
    }
    if (LIMIT < answer) {
        cout << -1 << endl;
        return;
    } else {
        cout << answer << endl;
        return;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
int par[300003] ; int N;
bool vis[300003]; 
int main()
{
    scanf("%d",&N);
    for(int i=1;i<=N;i++) scanf("%d",&par[i]) ; 
    vis[1] = true; int now = 1, cnt=0;
    while(1)
    {
        now = par[now];
        if(vis[now]) return !printf("-1");
        vis[now] = true; 
      	cnt++;
        if(now == 2) return !printf("%d",cnt);
    }
}

Measured memory_bytes: 768
import collections
N = int(input())
A_list = list(map(int, input().split(" ")))
C_dic = collections.Counter(A_list)
ans_dic = {}
sum_cdic = 0
temp_sum = 0
for i in C_dic:
    temp = C_dic[i]
    temp = temp*(temp-1)//2
    temp_sum += temp
sum_cdic = temp_sum

for i in A_list:
    if i in ans_dic:
        print(ans_dic[i])
    else:
        temp_sum = sum_cdic
        temp_sum -= (C_dic[i]*(C_dic[i]-1)//2)
        temp_sum += ((C_dic[i]-1)*(C_dic[i]-2)//2)
        ans_dic[i] = temp_sum
        print(temp_sum)

Measured memory_bytes: 35396
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int N;
  int A[100];
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  int ans=0;
  FOR(i,0,N){
    int minj=i;
    FOR(j,i,N){
      if(A[j]<A[minj]){
        minj=j;
      }
    }
    if(i!=minj){
      swap(A[i],A[minj]);
      ans++;
    }
  }
  FOR(i,0,N){
    if(i!=0){
      cout<<" ";
    }
    cout<<A[i];
  }
  cout<<endl;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>

int main() {
	int x, a, b;
	scanf ("%d%d%d", &x, &a, &b);
	int xa = x - a;
	int xb = x - b;
	
	if (xa < 0) {
		xa *= -1;
		if (xb< 0) {
			xb *= -1;
			xa > xb ? printf ("B\n") : printf ("A\n");
		}
		else {
			xa > xb ? printf ("B\n") : printf ("A\n");
		}
	}
	else if (xb < 0) {
		xb *= -1;
		if (xa< 0) {
			xa *= -1;
			xa > xb ? printf ("B\n") : printf ("A\n");
		}
		else {
			xa > xb ? printf ("B\n") : printf ("A\n");
		}
	}
	else {
		xa > xb ? printf ("B\n") : printf ("A\n");
	}
	return 0;	
}

Measured memory_bytes: 1620
#include<stdio.h>
main()
{
    int k,x,i,c;
    while(scanf("%d %d",&k,&x)==2){
        c=x-k;
        for(i=c+1;i<x+k;i++){
            printf("%d",i);
            if(i==x+k-1)
                printf("\n");
            else
                printf(" ");
        }
    }
}


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

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int solve(int n){
	int odd = n;
	int cnt=0;
	bool can = true;
	while(can){
		odd /= 2;
		cnt++;
		if(odd%2 != 0) can = false;
	}

	return cnt;
}

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

	for(int i=0;i<n;i++){
		if(a[i]%2 == 0){
			ans += solve(a[i]);
		}
	}
	
	cout<< ans <<endl;

	return 0;
}

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

long long m, d;

long long solve();

int main() {
  cin >> m >> d;

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(long long i = 1; i <= m; ++i) {
    for(int j = 1; j <= d; ++j)
      if((j % 10) * (j / 10) == i && (j % 10) > 1 &&
         (j / 10) > 1)
        ++ans;
  }
  return ans;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cmath>
#include <algorithm>

int nextch(void)
{
    static char bufdatum[BUFSIZ];
    static char *buf = bufdatum, *endbuf = bufdatum;
    if (endbuf == buf)
    {
        endbuf = (buf = bufdatum) + fread(bufdatum, 1, BUFSIZ, stdin);
        if (endbuf == buf)
            return EOF;
    }
    return *buf++;
}

void legit(void) {}

template<typename Car, typename ...Cdr>
void legit(Car &var, Cdr &...Rest)
{
    int peek;
    while (!isdigit(peek = nextch())
#ifdef LEGIT_NEGI
        && peek != '-'
#endif  // LEGIT_NEGI
        )
        ;
#ifdef LEGIT_NEGI
    bool negi;
    if (peek == '-')
        negi = true;
    else
        negi = false;
#endif  // LEGIT_NEGI
    var = 0;
    do
        var = (((var << 2) + var) << 1) + (peek ^ '0');
    while (isdigit(peek = nextch()));
#ifdef LEGIT_NEGI
    if (negi)
        var = -var;
#endif  // LEGIT_NEGI
    legit(Rest...);
}

void solve(void);

int main(void)
{
#ifdef redirect
    freopen("check/data.in", "r", stdin);
    freopen("check/prog.out", "w", stdout);
    freopen("check/log.out", "w", stderr);
#endif  // redirect
#ifdef chrono
    auto begtm = clock();
#endif  // chrono
    solve();
#ifdef chrono
    auto endtm = clock();
    printf("%f\n", static_cast<float>(endtm - begtm) / CLOCKS_PER_SEC);
#endif  // chrono
    return 0;
}

const size_t MaxN = static_cast<size_t>(1e5 + 7);

int n, k;
int arr[MaxN];
size_t idx1;

void solve(void)
{
    legit(n, k);
    for (size_t i = 0; i < n; ++i)
    {
        legit(arr[i]);
        if (1 == arr[i])
            idx1 = i;
    }
    --k;
    size_t ans = 19260817;
    for (int left = idx1, right = n - 1 - idx1 - k; left >= 0; --left, ++right)
    {
        size_t now = 0;
        if ( left % k != 0)
            ++now;
        now += left / k;
        if (right > 0)
        {
            if (right % k != 0)
                ++now;
            now += right / k;
        }
        ans = std::min(ans, now + 1);
    }
    printf("%llu\n", ans);
}



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

#define task "C" // ABC134
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

// Limit

// Struct

// Variables
int n,a[200005],mx=-200003,mxi;
// Function

int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> n;
	rep(i,1,n)
	{
	    cin >> a[i];
	    if (mx<a[i])
        {
            mx=a[i];
            mxi=i;
        }
	}
	sort(a+1,a+1+n);
	rep(i,1,n) if (i!=mxi) cout << mx << '\n'; else cout << a[n-1] << '\n';
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>

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

using namespace std;

int main(){
  string sa, sb, sc;
  int n[3];
  string turn = "a";

  REP(i, 3){n[i] = 0;}

  cin >> sa >> sb >> sc;

  for(;;){
    if(turn == "a"){
      if(n[0] == sa.length()) break;

      turn = sa[n[0]];
      n[0]++;
    }else if(turn == "b"){
      if(n[1] == sb.length()) break;

      turn = sb[n[1]];
      n[1]++;
    }else{
      if(n[2] == sc.length()) break;

      turn = sc[n[2]];
      n[2]++;
    }
  }

  transform(turn.begin(), turn.end(), turn.begin(), ::toupper);

  cout << turn << endl;

  return 0;
}


Measured memory_bytes: 256
def detect_odd_and_even(a, b):
    res = a * b
    if (res % 2 == 0):
        return 'Even'
    else:
        return 'Odd'

if __name__ == '__main__':
    a, b = input().split()
    print(detect_odd_and_even(int(a), int(b)))

Measured memory_bytes: 2940
function main()
  
  x, k, d = parse.(Int, split(readline()))
  
  x = abs(x)
  
  move = min(k, div(x,d))
  k -= move
  x -= move*d
  
  if k % 2 == 0
    println(x)
  else
    println(abs(x-d))
  end
  
end

main()

Measured memory_bytes: 171944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long LL;
const int N = 2e5+5;

struct dat{
	LL a,b;
	void in(){scanf("%lld%lld",&a,&b);}
}a[N];

int n, m;
LL t, dp[40], b[N];

int main(){
	scanf("%d%lld",&n,&t);
	rep(i,1,n) a[i].in();
	sort(a+1,a+n+1,[](dat x,dat y){return x.a*(y.b+1)>y.a*(x.b+1);});
	
	for(m=1; m<=n && a[m].a; m++);
	m--, b[0] = 0;
	rep(i,m+1,n) b[i-m] = a[i].b;
	n -= m;
	sort(b+1,b+n+1);
	
	rep(j,0,39) dp[j] = t+1;
	dp[0] = 0;
	rep(i,1,m) rrep(j,39,1) dp[j] = min(dp[j], (dp[j-1]+1) * (a[i].a+1) + a[i].b );
	
	int ans = 0;
	rep(i,1,n) b[i] += (b[i-1] + 1ll);
	rep(j,0,39){
		LL x = t - dp[j];
		if(x<0) break;
		int y = upper_bound(b+1,b+n+1,x) - b - 1;
		ans = max(ans, j + y);
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  char a[n][n], b[m][m];
  for (int i = 0; i < n; i++)
    scanf("%s", a[i]);
  for (int i = 0; i < m; i++)
    scanf("%s", b[i]);

  int flag;
  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; j <= n - m; j++) {
      flag = 0;
      for (int k = i; k < i + m; k++) {
	for (int l = j; l < j + m; l++) {
	  if (a[k][l] != b[k - i][l - j]) {
	    flag = 1;
	    goto loop_end;
	  }
	}
      }
    loop_end: ;
      if (!flag) {
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
	short f=1;x=0;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	x*=f;
}
int main(){
	int a,b;
	string s;
	read(a),read(b);
	cin>>s;
	if(s[a]!='-'){ cout<<"No"<<endl;return 0; }
	int gs=0;
	for(int i=0;i<=a+b;i++)
		if(!isdigit(s[i]))gs++;
	if(gs>2)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


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

int n;
ll x,y;
ll max_y[63];
ll target_y[63];
int main(void){
	max_y[0]=1;
	for(int i=1;i<=62;i++){
		max_y[i]=max_y[i-1]*2LL;
	}
	while(1){
		scanf("%d%lld%lld",&n,&y,&x);
		if(n==0 && y==0LL && x==0LL)break;
		y=(1LL<<n)-y+1LL;
		target_y[n]=y;
		for(int i=n-1;i>=0;i--){
			if(target_y[i+1]>max_y[i]){
				target_y[i]=max_y[i]*2LL-target_y[i+1]+1LL;
			}else{
				target_y[i]=target_y[i+1];
			}
		}
		ll nowy=1;
		ll nowx=x;
		ll len=(1LL<<n);
		string res="";
		for(int i=0;i<n;i++){
			if(nowy==target_y[i+1]){
				if(nowx<=len/2LL){
					res+='R';
				}else{
					res+='L';
					nowx-=(len/2LL);
				}
			}else{
				if(nowx<=len/2LL){
					res+='L';
					nowx=len/2LL-nowx+1LL;
				}else{
					res+='R';
					nowx=len-nowx+1LL;
				}
				nowy=target_y[i+1];
			}
			len/=2LL;
		}
		cout << res << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3256
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int a = 0, b = 0, o = 0, ab = 0;
	while (in.hasNextLine()) {
	 String str = in.nextLine();
	 if (str.contains("AB")) {
		ab++;
	 } else if (str.contains("A")) {
		a++;
	 } else if (str.contains("B")) {
		b++;
	 } else {
		o++;
	 }
	}
	System.out.println(a);
	System.out.println(b);
	System.out.println(ab);
	System.out.println(o);
 }
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int mx = 1100;
char str[mx];
int vis1[100],vis2[100];
int main()
{
    int n;
    while(~scanf("%d",&n)){
        int ans=0;
        scanf("%s",str);
        for(int i=1;i<n;i++){
            memset(vis1,0,sizeof(vis1));
            memset(vis2,0,sizeof(vis2));
            for(int j=0;j<i;j++)
                vis1[str[j]-'a']=1;
            for(int j=i;j<n;j++)
                vis2[str[j]-'a']=1;
            int cont=0;
            for(int i=0;i<26;i++)
                if(vis1[i]==1&&vis2[i]==1)
                    cont++;
            ans=max(ans,cont);
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 128
import collections # deque, Counter
# import itertools   # accumulate, compress, permutations(nPr), combinations(nCr)
# import bisect      # bisect_left(insert位置), bisect_right(slice用)
# import math        # factorical（階乗) # hypot(距離)
# import heapq
# from fractions import gcd # Python3.5以前 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # Python3.6以降
# --------------------------------------------------------------

H,W   = map(int,input().split())
maze  = [[None for _ in range(W)] for _ in range(H)]

for i in range(H):
    maze[i] = list(input())

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

cnt = 0

for j in range(H):
    for k in range(W):
            if maze[j][k]=='#':
                continue
            else:
                sy = j
                sx = k

                seen = [[-1 for _ in range(W)] for _ in range(H)]
                seen[sy][sx] = 0

                que  = collections.deque()  # 発見済未訪問な頂点
                que.append([sy,sx])

                while(len(que)!=0):
                    p = que.popleft()
                    for i in range(4):
                        ny = p[0] + dy[i]
                        nx = p[1] + dx[i]
                        if (ny >= 0 and nx >=0 and ny < H and nx < W and seen[ny][nx] == -1 and maze[ny][nx] != '#'):
                            seen[ny][nx] = seen[p[0]][p[1]] + 1
                            que.append([ny,nx])

                cnt = max(cnt, max([x for row in seen for x in row]))

print(cnt)

Measured memory_bytes: 9256
from collections import defaultdict

S = input()

d = defaultdict(int)

d[0] += 1

mod = 0
R = 1
for i in range(len(S)):
    mod = (mod + R * int(S[len(S) - i - 1])) % 2019
    R = R * 10 % 2019
    d[mod] += 1
ans = 0
for i in d.values():
    if i > 1:
        ans += i * (i - 1) / 2

print(int(ans))


Measured memory_bytes: 9484
#include<iostream>

using namespace std;

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

	if (N % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < N / 2; i++) {
		if (S[i] != S[i + N / 2]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll X, N, ans, min = 114514;
  cin >> X >> N;
  bool ansX = 1, continuefr = 0;
  vector<ll> p(N);
  for(ll i = 0; i < N; i++) {
    cin >> p.at(i);
    if(p.at(i) == X) ansX = 0;
  }
  if(ansX) cout << X << endl;
  else {
    for(ll i = 0; i <= 101; i++) {
      continuefr = 0;
      for(ll j = 0; j < N; j++) {
        if(i == p.at(j)) {
          continuefr = 1;
          break;
        }
      }
      if(continuefr == 0) {
        if(abs(X - i) < min) {
          min = abs(X - i);
          ans = i;
        }
      }
    }
  cout << ans << endl;  
  }
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

int dp[55][55][30][30];
char s[55][25];
char base = 'a'-1;

//文字列[l,r)のa文字目がb以上である通り数
int f(int l, int r, int a, int b){
    if(dp[l][r][a][b] != -1)return dp[l][r][a][b];
    if(l >= r)return dp[l][r][a][b] = 1;
    int ret = 0;
    if(b == 27) return dp[l][r][a][b] = ret;
    if(a == 20) return dp[l][r][a][b] = r-l == 1;
    loop(i,l,r+1){
        if(i != l && s[i-1][a] != base+b && s[i-1][a] != '?')break;
        if(i != l && s[i-1][a] == '?' && b == 0)break;
        ret += f(l,i,a+1,0)*f(i,r,a,b+1)%MOD;
        ret %= MOD;
    }
    return dp[l][r][a][b] = ret;
}

signed main(void) {
    rep(i,55)rep(j,55)rep(k,30)rep(l,30)dp[i][j][k][l] = -1;
    int n;
    cin >> n;
    rep(i,n){
        cin >> s[i];
        for(int j = strlen(s[i]); j < 20; j++) s[i][j] = base;
    }
    cout << f(0,n,0,0) << endl;
}



Measured memory_bytes: 24420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=(int)1e5;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int s,t,d;
	cin>>d>>t>>s;

	cout<<(t*s>=d?"Yes":"No")<<"\n";

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

int X;

int main() {
    cin >> X;

    int target = sqrt(X);

    int ans = 1;

    for (int i = 2; i <= target; i++) {
        int tmp = i;
        while (true) {
            if (tmp > X) break;
            tmp *= i;
        }
        tmp /= i;
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)1e5 + 9;
bool vis[N];
int pos[N];

int main(){
  fastIO;
  int n;
  cin >> n;
  vector<pii> pa(n), pb(n);
  for(int i = 0 ; i < n; i ++ ){
    cin >> pa[i].fi;
    pa[i].se = i;
  }
  for(int i = 0 ; i < n ; i ++ ){
    cin >> pb[i].fi;
    pb[i].se = i;
  }
  sort(pa.begin(), pa.end());
  sort(pb.begin(), pb.end());
  for(int i = 0 ; i < n; i ++ ){
    pos[pa[i].se] = pb[i].se;
    if(pa[i].fi > pb[i].fi){
      cout << "No\n";
      return 0;
    }
  }
  for(int i = 0 ; i + 1 < n; i ++ ){
    if(pa[i + 1].fi <= pb[i].fi){
      cout << "Yes\n";
      return 0;
    }
  }
  int node = 0;
  while(!vis[node]){
    vis[node]=true;
    node = pos[node];
  }
  for(int i = 0 ; i < n; i ++ ){
    if(!vis[i]){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


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

int main()
{
	string s,t;
	cin>>s;
	cin>>t;
	
	char s_min='z',t_max='a',s_max='a';
	for(int i=0;i<s.size();i++){
		if (s[i]<=s_min) s_min=s[i];
		if (s[i]>=s_max) s_max=s[i];
	}
		
	for(int i=0;i<t.size();i++)
		if (t[i]>=t_max) t_max=t[i];
	if (s_min<t_max)
		cout<<"Yes"<<endl;
	else if (s_min==t_max && s_min<s_max)
		cout<<"No"<<endl;
	else if (s_min==t_max && s.size()<t.size())
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#                               #
    # author : samars_diary #
    # 17-09-2020 │ 16:08:30 #
#                               #

import sys, os.path, math

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    n,d=mii();c=0
    for _ in range(n):
        a,b=mii()
        if math.sqrt((a**2)+(b**2))<=d:
            c+=1
    print(c)
for _ in range(1):
    solve()

Measured memory_bytes: 73424
#include <cstdio>
using namespace std;

int main(){
	int n, r, p, c;
	const int SIZE = 50;
	int card[SIZE];
	int P[SIZE], C[SIZE];
	
	while(true){
		scanf("%d%d", &n, &r);
		if(n == 0 && r == 0) break;
		
		for(int i = n; i > 0; i--){
			card[n - i] = i;
		}
		
		for(int i = 0; i < r; i++){
			scanf("%d%d", &p, &c);
			for(int j = 0; j < p - 1; j++) P[j] = card[j];
			for(int j = 0; j < c; j++) C[j] = card[j + p - 1];
			
			for(int j = 0; j < c; j++) card[j] = C[j];
			for(int j = 0; j < p - 1; j++) card[j + c] = P[j];
		}
		
		printf("%d\n", card[0]);
	}
	
	return 0;
}

Measured memory_bytes: 1028
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int n, ans = 0;
	cin >> n;
	string s = to_string(n);
	for (int i = 3; i <= s.size(); i++) {
		rep(j, mod_pow(3, i, INF)) {
			int bit[15];
			rep(k, i) bit[k] = j / mod_pow(3, k, INF) % 3;
			bool b[3] = { false,false,false };
			rep(k, i) b[bit[k]] = true;
			if (b[0] && b[1] && b[2]) {
				int now = 0;
				rep(k, i) {
					if (bit[k] == 0) now = now * 10 + 3;
					if (bit[k] == 1) now = now * 10 + 5;
					if (bit[k] == 2) now = now * 10 + 7;
				}
				if (now <= n) ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main(void){
  string S,T;
  int ans=3;
  int i,j;
  cin >> S >> T;
  for(i=0;i<3;i++) if(S[i]!=T[i]) ans--;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
l1=list(map(int,input().split()))
l1.append(max(l1)+1)
l2=[-1]
l3=[]
for i in range(N):
  if l1[i]<l1[i+1]:
    l2.append(i)
for i in range(len(l2)-1):
  if l2[i+1]-l2[i] >= 2:
    l3.append(l2[i+1]-l2[i]-1)
print(max(l3) if l3 else 0)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<int> H(N+1);
    for(int i=1;i<=N;i++){
        cin >> H[i];
    }
    vector<int> step(N+1);
    step[N]=0;
    for(int i=N-1;i>0;i--){
        if(H[i]>=H[i+1]){
            step[i]=step[i+1]+1;
        }else{
            step[i]=0;
        }
    }
    int max_step=-1;
    for(int i=1;i<=N;i++){
        max_step = max(max_step,step[i]);
    }
    cout << max_step << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(x,to) for(x=0;x<(to);x++)

int main()
{
    string n;cin>>n;
    int x,i,xf=0;
    FOR(i,n.size()){
        xf+=n[i]-48;
    }
    x=stoi(n);
    x%xf==0 ? cout<<"Yes" : cout<<"No";
}


Measured memory_bytes: 256
#include <stdio.h>

void bombs(int x, int y);

_Bool tront[8][8];

int main(void) {
	int i, j, k;
	int n;
	char str[9];
	int x, y;
	scanf("%d", &n);
	
	for (i = 1; i <= n; i++) {
		getchar();
		getchar();
		
		for (j = 0; j < 8; j++) {
			scanf("%s", str);
			for (k = 0; k < 8; k++) {
				tront[j][k] = str[k] - '0';
			}
		}
		
		scanf("%d", &x);
		scanf("%d", &y);
		bombs(x-1, y-1);
		
		printf("Data %d:\n", i);
		for (j = 0; j < 8; j++) {
			for (k = 0; k < 8; k++) {
				printf("%d", tront[j][k]);
			}
			printf("\n");
		}
	}
	return 0;
}

void bombs(int x, int y) {
	int i;
	for (i = -3; i <= 3; i++) {
		if ( x+i >= 0 && x+i < 8 && tront[y][x+i]) {
			tront[y][x+i] = 0;
			bombs(x+i, y);
		}
		if ( y+i >= 0 && y+i < 8 && tront[y+i][x]) {
			tront[y+i][x] = 0;
			bombs(x, y+i);
		}
	}
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
int a[110000];
ll x[1000][1000];
int main(){
  int h,w,n,ans=0,st=0,st2=0;
  cin>>h>>w>>n;
  rep(i,0,n)cin>>a[i];
  for(int i=0;i<n;i++){
    while(a[i]>0){
      if(st==w){st2++;st=0;}
      if(st<w) {x[st2][st]=i+1;a[i]--;st++;}
    }
  }
  rep(i,0,h){
    if(i%2==0)rep(j,0,w)cout<<x[i][j]<<" ";
    else irep(j,w-1,0)cout<<x[i][j]<<" ";
    cout<<endl;
  }
}


Measured memory_bytes: 2816