akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a-b>c)
        printf("0");
    else
        printf("%d",c-(a-b));


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int ans = 1, n, a[123456], b[123456], cnt;
signed main() {
	cin >> n; for0(i, n) { cin >> a[i]; }
	sort(a, a + n); b[0] = a[0];
	for1(i, n - 1)b[i] = b[i - 1] + a[i];
	for (int i = n - 2; i >= 0; i--) {
		if (b[i] * 2 < a[i + 1]) {
			cout << n - i - 1 << endl; return 0;
		}
	}
	cout << n << endl;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		long people = Long.valueOf(in.readLine());
		long[] capacity = new long[5];
		for(int i = 0; i < 5; i++) {
			capacity[i] = Long.valueOf(in.readLine());
		}
		long compare = Long.MAX_VALUE;
		for(int i = 0; i < 5; i++) {
			if(capacity[i] < compare) {
				compare = capacity[i];
			}
		}
		BigDecimal bi = new BigDecimal(people);
		bi = bi.divide(new BigDecimal(compare), 0, BigDecimal.ROUND_CEILING);
		bi = bi.add(new BigDecimal(4));
		System.out.println(bi.longValue());
	}
}


Measured memory_bytes: 22228
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <list>

class Edge{
public:
    int from, to;
    long long cost;
    Edge(): from(0), to(0), cost(0){};
    Edge(int u, int v, long long w): from(u), to(v), cost(w){};
    ~Edge(){};
};

void Dijkstra(std::vector<Edge> &edge, int N, int start, std::vector<long long> &distance)
{
    typedef std::pair<long long, int> P;
    const long long infty = 1e+18;

    // initialize
    distance.clear();
    for(int i=0; i<N; i++) distance.push_back(infty);
    distance[start] = 0;
    std::priority_queue<P, std::vector<P>, std::greater<P> > q;
    q.push(P(0, start));

    std::vector<std::list<P> > edge_list(N);
    for(auto &&itr = edge.begin(); itr != edge.end(); itr++){
        edge_list[itr->from].push_back(P(itr->cost, itr->to));
    }

    while(!q.empty()){
        int d = q.top().first;
        int u = q.top().second;
        q.pop();
        if(distance[u] < d) continue;

        for(auto &&itr = edge_list[u].begin(); itr != edge_list[u].end(); itr++){
            int v = itr->second;
            long long w = itr->first;
            if(distance[u] + w < distance[v]){
                distance[v] = distance[u] + w;
                q.push(P(distance[v], v));
            }
        }
    }
}

void to_undirected(std::vector<Edge> &edge)
{
    int M = edge.size();
    for(int i=0; i<M; i++){
        edge.push_back(Edge(edge[i].to, edge[i].from, edge[i].cost));
    }
}

int main()
{
    int N;
    std::cin >> N;
    std::vector<Edge> edge(N);
    for(int i=0; i<N-1; i++){
        scanf(" %d %d %lld", &(edge[i].from), &(edge[i].to), &(edge[i].cost));
        edge[i].from--; edge[i].to--;
    }
    int Q, K;
    std::cin >> Q >> K; K--;
    std::vector<int> x(Q), y(Q);
    for(int i=0; i<Q; i++){
        scanf(" %d %d", &x[i], &y[i]);
        x[i]--; y[i]--;
    }

    std::vector<long long> distance;
    to_undirected(edge);
    Dijkstra(edge, N, K, distance);
    for(int i=0; i<Q; i++){
        printf("%lld\n", distance[x[i]] + distance[y[i]]);
    }
}

Measured memory_bytes: 19428
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {     
    long long int n;
    cin >> n;
    if (n == 1) {
        cout << "Yes" << endl << 2 << endl << "1 1" << endl << "1 1" << endl;
        return 0;
    }
    long long int b = 1, e = n;
    while (b < e) {
        long long int m = (b + e) / 2;
        long long int t = (m - 1) * m / 2;
        if (t > n) {
            e = m - 1;
        } else if (t < n) {
            b = m + 1;
        } else {
            b = m, e = m;
            break;
        }
    }
    if ((b - 1) * b / 2 != n) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    long long int k = (b - 1) * b / 2;
    cout << b << endl;
    vector<vector<int>> res(b, vector<int>(0));
    int x = 0, y = 1;
    for (int i = 1; i <= n; i++) {
        res[x].push_back(i);
        res[y].push_back(i);
        y++;
        if (y == b) {
            x++, y = x + 1;
        }
    }
    for (int i = 0; i < b; i++) {
        cout << res[i].size() << " ";
        for (auto num : res[i]) {
            cout << num << " ";
        }
        cout << endl;
    }
}




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


int MOD=1000000007;


int main(){
	int N,D;
  int ans=0,co=0;
  cin >> N >> D;
  int X[N+10][D+10]={};
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin >> X[i][j];
    }
  }
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      co=0;
      for(int k=0; k<D; k++){
        co+=pow(X[i][k]-X[j][k],2);
      }for(int k=1; k<1000; k++){
        if(co==k*k){ 
          ans+=1;
        break;
        }
      }    
      }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
ans' [] = [0]
ans' (0:xs) = ans' xs
ans' x@(1:xs) =
  let n = length $ takeWhile (== 1) x
      r = dropWhile (== 1) x
  in
    n:(ans' r)

ans i = 1 + (maximum $ ans' i)

main = do
  _ <- getLine
  l <- getLine
  let i = map read $ words l :: [Int]
      o = ans i
  print o



Measured memory_bytes: 4124
#include "iostream"
#include "vector"
#include "string"
#include <iomanip>
#include <algorithm>
#define rep(i,n) for (int i= 0; i < (n); ++i)
using ll = long long;
using namespace std;
const double PI = 3.14159265358979323846;

int vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

int main() {
	double N;
	cin >> N;
	
	double cN = ceil(N / 1000) * 1000;

	cout << cN - N << endl;

	return 0;

}

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll  long long int
vector<ll> v;
multiset<ll> ms;
multiset<ll>::iterator it;
ll a[MAXX], b[MAXX];
int main()
{
	FAST;
	ll n, t, m, o = 1, z, p, ans = 0;
	cin >> n >> m;
	for(ll i = 0; i < n; i++){
		cin >> t;
		for(ll i = 0; i < t; i++){
			cin >> a[i];
			b[a[i]] ++;
		}
	}
	for(ll i = 1; i <= m; i++){
		if(b[i] == n){
			ans ++;
		}
	}
	cout << ans;
	

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a,b,c;
		int count = 0;
		
		a = in.nextInt();
		b = in.nextInt();
		c = in.nextInt();
		
		for(int i=a; i<=b; i++){
			if(c%i == 0){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 17240
const fs = require('fs');
const input = fs.readFileSync('/dev/stdin', 'utf-8');
const N: number = parseInt(input);

// k + l 回移動後  (1+k, 1+l)
const sqrtN: number = Math.floor(Math.sqrt(N));

let min: number = N;
for (let i = 1; i <= sqrtN; ++i) {
  if (N % i !== 0) {
    continue;
  }
  let count = (i - 1) + (N / i -1);
  if (min > count) min = count;
}
    
console.log(min);

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
  
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define cin_desync()                      \
	do {                                  \
		ios_base::sync_with_stdio(false); \
		cin.tie(0);                       \
	} while (0)                           \

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	if ((B - A) % 2) {
		cout << "Borys" << endl;
	} else {
		cout << "Alice" << endl;
	}
}


Measured memory_bytes: 764
N, K = map(int, input().split())
A=N
total=0
count=1
flag=0
if N>=K:
   total=(N-K+1)/N
   
   N=K-1
if N<K:
    while(flag==0):
        if(K/2<1):
            flag=1
        if K%2==1:
            K = K//2+1
        elif K%2==0:
            K = K // 2
        if N>=K:

            total += (N-K+1)*1/(A*2**count)
            N=N-(N-K+1)

        count += 1
    print(total)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        double debt = 100000.0;
        int nWeeks = new Scanner(System.in).nextInt();
        for(int i = 0; i < nWeeks; i++) {
            debt = Math.ceil(debt * 0.00105) * 1000.0;
        }
        System.out.println((int)debt);

    }
} 

Measured memory_bytes: 17164
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int ans = 0;
    for (int i = 0; i < n-2; i++){
        for (int j = i+1; j < n; j++){
            int k = i+2;
            while (k < n && a[i] + a[j] > a[k]) k++;
            k--;
            ans += max(0,k-j);
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int H,W;
int cost[10][10];
int count[10];

int main(){
  cin >> H >> W;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin >> cost[i][j];
    }
    count[i] = 0;
  }
  int c;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> c;
      if(c>=0) count[c]++;
    }
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        cost[j][k] = min(cost[j][k],cost[j][i]+cost[i][k]);
      }
    }
  }
  int ans = 0;
  for(int i=0;i<10;i++){
    ans += count[i] * cost[i][1];
  }
  cout << ans << endl;
  return 0;
}


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

void print_vec(vector<ll> vec) {
  cout << "{ ";
  for (int i = 0; i < vec.size(); i++) {
    cout << vec.at(i) << " ";
  }
  cout << "}" << endl;
}

int main() {
    ll K,N; cin >> K >> N;
    vector<ll> A(N);
    vector<ll> dist(N);
    ll m = K;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for(int i = 0; i < N-1; i++) {
        dist.at(i) = abs(A.at(i)-A.at(i+1));
    }
    dist.at(N-1) = K - A.at(N-1) + A.at(0);
    //print_vec(A);
    //print_vec(dist);

    ll max_dist = -1;
    ll sum_dist = 0;

    for(int i = 0; i < N; i++) {
        sum_dist += dist.at(i);
        if(max_dist < dist.at(i)) max_dist = dist.at(i);
    }

    cout << sum_dist - max_dist << endl;

    return 0;
}

Measured memory_bytes: 3456
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int cnt[101010];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n;
  cin >> n;
  for(int x=1;x<=100;x++){
    for(int y=1;y<=100;y++){
      for(int z=1;z<=100;z++){
        int v = x*x + y*y + z*z + x*y + y*z + z*x;
        if(v<=n){
          cnt[v]++;
        }
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<cnt[i]<<endl;
  }


return 0;
}
///....


Measured memory_bytes: 3644
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 10000000;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int,PP> PPP;
struct edge { int to; int to2; int cost; };
int l[15];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> l[i];
	sort(l, l + n);
	int sum = 0;
	rep(i, n - 1)sum += l[i];
	if (l[n - 1] < sum)cout << "Yes" << endl;
	else puts("No");
}

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

int main()
{
  int h, w, n, one_time_size, min_count;
  cin >> h >> w >> n;
  if (h > w) one_time_size = h;
  else one_time_size = w;
  min_count = n / one_time_size;
  if (n % one_time_size > 0) min_count++;
  cout << min_count << endl;
}

Measured memory_bytes: 256
import numpy as np
s = list(input())
x, y = map(int, input().split())

X = [0]
Y = [0]

X_append = X.append
Y_append = Y.append

flag = True
tmp = 0
for i in s:
    if i == 'F':
        tmp += 1
    else:
        if flag:
            X_append(tmp)
        else:
            Y_append(tmp)
        tmp = 0
        flag = not flag

if flag:
    X_append(tmp)
else:
    Y_append(tmp)

x -= X[1]
X[1] = 0

x = abs(x)
total_X = sum(X)

lst_X = np.zeros(total_X + 1, dtype = np.int32)
lst_X[0] = 1
for i in X:
    if i == 0:
        continue
    lst_X[i:] = np.maximum(lst_X[i:], lst_X[:-i])

if x > total_X or (total_X - x) % 2 == 1 or lst_X[(total_X - x) // 2] == 0:
    print ('No')
    exit()

y = abs(y)
total_Y = sum(Y)

lst_Y = np.zeros(total_Y + 1)
lst_Y[0] = 1
for i in Y:
    if i == 0:
        continue
    lst_Y[i:] = np.maximum(lst_Y[i:], lst_Y[:-i])

if x > total_X or y > total_Y:
    print ('No')
    exit()

if  (total_Y - y) % 2 == 0 and int(lst_Y[(total_Y - y) // 2]) == 1:
    print ('Yes')
else:
    print ('No')

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

int main() {
  string S(4, '0');
  cin >> S;
  int digit = S.size() - 1;
  for (int b = 0; b < (1 << digit); b++) {
    int res = S.at(0) - '0';
    string formula = to_string(res);
    for (int i = 0; i < digit; i++) {
      if (b & (1 << i)) {
        formula += '+';
        res += S.at(i + 1) - '0';
      } else {
        formula += '-';
        res -= S.at(i + 1) - '0';
      }
      formula += S.at(i + 1);
    }
    if (res == 7) {
      cout << formula + "=7" << endl;
      break;
    }
  }
}

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

int main() {
    ll n;
    cin>>n;
    vector<int> b(100000);
    rep(i,n){
        int a;
        cin>>a;
        b[a]++;
    }
    int ans = 0;
    rep(i,b.size()-1){
        int tmp = b[i]+b[i+1]+b[i+2];
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}


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

class Solve {
private:
	using ai4 = std::array<int, 4>;
public:
	bool is_last_query{};
	Solve()
	{
		int n, w, d;
		scanf("%d%d%d", &n, &w, &d);
		if (n == 0 && w == 0 && d == 0)
		{
			is_last_query = true;
			return;
		}
		std::vector<ai4> cakes(2 * n + 1);
		cakes.back() = {w * d, w, d, 1};
		for (int i{}; i < n; i++)
		{
			int p, s;
			scanf("%d%d", &p, &s);
			int cakes_i{}, num{};
			while (true)
			{
				num += cakes[cakes_i][3];
				if (p == num) break;
				cakes_i++;
			}
			auto& cake{cakes[cakes_i]};
			cake[3]--;
			s %= cake[1] + cake[2];
			ai4 next[2];
			if (s < cake[1])
			{
				next[0] = {s * cake[2], s, cake[2], 1};
				next[1] = {(cake[1] - s) * cake[2], cake[1] - s, cake[2], 1};
			}
			else
			{
				s -= cake[1];
				next[0] = {cake[1] * s, cake[1], s, 1};
				next[1] = {cake[1] * (cake[2] - s), cake[1], cake[2] - s, 1};
			}
			if (next[0][0] > next[1][0]) std::swap(next[0], next[1]);
			cakes[2 * i + 1] = next[0];
			cakes[2 * i + 2] = next[1];
		}
		std::vector<int> ans;
		for (int i{}; i <= 2 * n; i++)
			if (cakes[i][3])
				ans.push_back(cakes[i][0]);
		std::sort(ans.begin(), ans.end());
		for (int i{}; i < n + 1; i++)
			printf("%d%c", ans[i], i == n?'\n':' ');
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


Measured memory_bytes: 3148
n = int(input())

D = []

for i in range(n):
    x, y = map(int, input().split())
    D.append(set([x, y]))

for i in range(1, n - 1):
    if len(D[i - 1]) == 1 and len(D[i]) == 1 and len(D[i + 1]) == 1:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 62352
using System;
using System.Collections.Generic;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = 0;
            for (int i = 0; i < 4; i++)
            {
                if (s[i].ToString() == "+")
                {
                    ans++;
                }
                else
                {
                    ans--;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
object Main extends App {
	override def main(args: Array[String]) = {
		val sc = new java.util.Scanner(System.in)
		val a,b,c = sc.nextInt()
		
		val list = List(a,b,c)
		val res = solve(list)
		println(res(0) + " "+res(1)+" "+res(2))
		
	}
	
	def solve(list : List[Int]):List[Int] = {
		 list.sortWith(_ < _)
	}
	
}

Measured memory_bytes: 45132
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/all>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
	cin>>N>>Q;
	dsu uf(N);
	rep(i, Q){
		int t, u, v;
		scanf("%d%d%d", &t, &u, &v);
		if(t == 0){
			uf.merge(u, v);
		}else{
			printf("%d\n", uf.same(u, v));
		}
	}
}

Measured memory_bytes: 3896
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>

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

using namespace std;

typedef long long ll;

int main(){
  int K;
  string s;
  cin >> s >> K;

  set<string> se;
  REP(i,K) REP(j,s.size()-i){
    se.insert(s.substr(j,i+1));
  }
  int k=0;
  for(auto it = se.begin();it!=se.end();it++){
    k++;
    if(k==K){
      cout << *it << endl;
      break;
    }
  }
return 0;

}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    vector<P> D;
    rep(i,N){
        ll d; cin>>d;
        D.emplace_back(d,i); // d,ノード
    }
    vector<P> A[N];
    bool nodeused[N]={};
    bool henused[M]={};
    rep(i,M){
        ll u,v; cin>>u>>v; --u,--v;
        A[u].emplace_back(v,i); // 接続先,辺番号
        A[v].emplace_back(u,i);
    }

    SORT(D);

    vector<ll> nodeiro(N,0); //色 0 ,1 ,2
    vector<ll> wans(M,0); // 辺の重み
    rep(i,N){
        ll ct=1;
        while(i+ct!=N and D[i].first==D[i+ct].first){
            ++ct;
        }
        // つなげていいところ
        rep(j,ct){
            nodeused[D[i+j].second]=true;
        }
        // つなげていいところを各ノードで探す
        // 色は決まってたら放置、片方決まってないなら反対に、両方なら適当に決める.
        // 見つからんかったらdame

        rep(j,ct){
            ll now=D[i+j].second;
            ll cost=D[i+j].first;
            bool ok=false;
            for(auto pe: A[now]){
                ll tuginode=pe.first;
                ll nowhen=pe.second;
                if(!nodeused[tuginode]) continue;
                ok=true;
                wans[nowhen]=cost;
                if(nodeiro[now]==0){
                    if(nodeiro[tuginode]==1) nodeiro[now]=2;
                    else if(nodeiro[tuginode]==2) nodeiro[now]=1;
                    else if(nodeiro[tuginode]==0) {nodeiro[now]=1; nodeiro[tuginode]=2;}
                }
            }
            if(!ok) dame;
        }
        i+=ct-1;
    }

    rep(i,N){
        cout<< ( nodeiro[i]==1 ? 'W' : 'B' );
    }
    cout<<"\n";
    rep(i,M){
        cout<< wans[i] <<"\n";
    }

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 18416
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

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

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
vector<int> E[200001];
bool shipment[15][15];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;
char F[51][51];
int H, W;

void dfs(int x, int y) {
    F[x][y] = '0';
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            int to_x = x + i; int to_y = y + j;
            if (to_x >= 0 && to_x < H && to_y >= 0 && to_y < W && F[to_x][to_y] == '1') dfs(to_x, to_y);
        }
    }
    return;
}

int main() {
    vector<int> ans;
    int output_count = 0;

    while (true) {
        cin >> H >> W; swap(H, W);
        if (H == 0 && W == 0) {
            break;
        }
        output_count++;
        for (int i = 0; i < H; i++) {
            for (int k = 0; k < W; k++) cin >> F[i][k];
        }
            int count = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (F[i][j] == '1') {
                        dfs(i, j);
                        count++;
                    }
                }
            }
            ans.push_back(count);
        
    }

    for (int i = 0; i < output_count; i++) cout << ans.at(i) << endl;
}



Measured memory_bytes: 7904
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define int long long
using namespace std;
int h, w, k, cx, cy, u, d, l, r;
char map[876][876]; bool bm[876][876];
queue<pair<pair<int, int>, int>>q;
signed main() {
	cin >> h >> w >> k;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> map[i][j];
			if (map[i][j] == 'S') { cx = i; cy = j; }
		}
	}
	u = h; d = h; l = w; r = w;
	q.push(make_pair(make_pair(cx, cy), 0));
	while (q.size()) {
		int x = q.front().first.first, y = q.front().first.second, p = q.front().second;
		if (!bm[x][y]) {
			bm[x][y] = 1;
			u = min(u, (x - 1 + k - 1) / k);
			d = min(d, (h - x + k - 1) / k);
			l = min(l, (y - 1 + k - 1) / k);
			r = min(r, (w - y + k - 1) / k);
			if (p < k) {
				if (map[x - 1][y] == '.' && !bm[x - 1][y])q.push(make_pair(make_pair(x - 1, y), p + 1));
				if (map[x + 1][y] == '.' && !bm[x + 1][y])q.push(make_pair(make_pair(x + 1, y), p + 1));
				if (map[x][y - 1] == '.' && !bm[x][y - 1])q.push(make_pair(make_pair(x, y - 1), p + 1));
				if (map[x][y + 1] == '.' && !bm[x][y + 1])q.push(make_pair(make_pair(x, y + 1), p + 1));
			}
		}
		q.pop();
	}
	cout << min(min(u, d), min(l, r))+1 << endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
#include<map>
using namespace std;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int ii = 0; ii < n; ii++){
    cout << a[ii];
    if(ii == n-1) cout << endl;
    else cout << " ";
  }

  for(int i = 1; i < n; i++){
    int temp = a[i];
    int j = i-1;
    while(j >= 0 && a[j] > temp){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = temp;
    for(int ii = 0; ii < n; ii++){
      cout << a[ii];
      if(ii == n-1) cout << endl;
      else cout << " ";
    }
  }

  return 0;
}



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int n;
ll k;
vector<int>t;
int roup;
int en;
bool hte;
vector<bool> ch;
vector<int>cou;
void tel(int p,int c,ll k){
    if(ch.at(p)==true){
        roup=p;
        en=c;
        hte=true;
        return;
    }
    else if(c==k){
        roup=p;
        en=c;
        return;
    }
    cou.at(p)=c;
    //cout<<p<<cou.at(p);
    //cout<<endl;
    ch.at(p)=true;
    tel(t.at(p),c+1,k);
}
int roup2;
void tel2(int p,int c,ll k){
    if(c==k){
        roup2=p;
        return;
    }
    tel2(t.at(p),c+1,k);
}
int main(){
    cin>>n>>k;
    t.resize(n);
    cou.resize(n);
    ch.resize(n);
    rep(i,0,n){
        ch.at(i)=false;
    }
    hte=false;
    rep(i,0,n){
        int a;
        cin>>a;
        a--;
        t.at(i)=a;
    }
    tel(0,0,k);
    if(!hte){
        cout<<roup+1<<endl;
        return 0;
    }
    ll hmr=(ll)(k-cou.at(roup))/(en-cou.at(roup));
    //cout<<hmr<<' '<<cou.at(roup)<<' '<<en<<endl;;
    ll amari=k-cou.at(roup)-hmr*(en-cou.at(roup));
    //cout<<amari<<endl;
    tel2(roup,0,amari);
    cout<<roup2+1<<endl;
return 0;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        while(A[i] %2 == 0){
            ans++;
            A[i] /= 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << (double)W*H/2 << " ";
  if (W == 2*x && H == 2*y)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
K, A, B = map(int, input().split())
if K <= A:
    ans = K+1
elif A+1 < B:
    K -= A - 1  # A-1回叩く
    ans = A
    ans += (K // 2) * (B - A)
    if K % 2 == 1:
        ans += 1

else:
    ans = K+1
print(ans)


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

#define int long long
#define nl '\n'
#define tez ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

signed main()
{
	tez
	string s;
	
	cin >> s;
	int ma=0;
	int c=0;
	for(int i=0;s[i];i++)
	{
	    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
	    for(int j=i;s[j];j++)
	    {
	        if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T')     c++;
	        else break;
	    }}
	    else continue;
	    ma=max(ma,c);
	    c=0;
	}
	cout<<ma;
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;

ll f(ll t,ll p, ll x){
    if(x==0) return 0;
    if(t==1) return 1; 

    if(x<=t/2) return f((t-3)/2, (p-1)/2, x-1);
    else return p/2 + 1 + f((t-3)/2, (p-1)/2, x-t/2-1);
}

int main(){FIN

    ll n,x;cin>>n>>x;
    ll s=1, p=1;
    REP(i,n){
        s= s*2+3;
        p = p*2+1;
    }
    cout<<f(s,p,x)<<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 reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define abs(a) llabs(a)
#define int long long
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   int n, a;
   cin >> n;
   a = n;
   while (1)
   {
      int x = a * 1.08;
      if (x < n)
      {
         cout << ":(" << '\n';
         return 0;
      }
      else if (x == n)
      {
         cout << a << '\n';
         return 0;
      }
      a--;
   }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	int n, c = 0;
	cin >> n;
	vector<int> p(n), q(n);
	rep(i, n) cin >> p.at(i);
	reps(i, 1, n + 1) q.at(i - 1) = i;
	rep(i, n) p.at(i) -= q.at(i);
	rep(i, n) {
		if (p.at(i) == 0) c++;
	}
	if (c == n - 2 || c == n) cout << "YES";
	else cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <climits>
#include <map>
using namespace std;

long long A[2000020];
long long sumx[2000020];
long long sumy[2000020];
int n;

int main() {
    cin >> n;
    for ( long long i = 0; i < n; i++ ) {
        cin >> A[i];
    }
    
    sumx[0] = A[0];
    sumy[n-1] = A[n-1];
    for ( long long i = 1, j = n - 2; i < n; i++, j-- ) {
        sumx[i] = A[i] + sumx[i-1];
        sumy[j] = A[j] + sumy[j+1];
        //cout << sumx[i] << " " << sumy[i] << endl;
    }
    
    unsigned long long mn = (1<<31);
    for ( int i = 0; i < n - 1; i++ ) {
        long long x = sumx[i];
        long long y = sumy[i + 1];
        long long sum = x - y;
        if ( sum < 0 ) sum = -sum;
        //cout << x << " " << y << endl;
        if (sum < mn) mn = sum;
    }

    cout << mn << endl;
    
    return 0;
}

Measured memory_bytes: 9984
#include <stdio.h>
#define N 100

int main(void) {
    int i, j, n, v; 
    int a[N];

    scanf("%d", &n);

    for(i=0; i<n; i++) {
        scanf("%d", &v);
        if( 0<=v && v<= 1000 ){
            a[i] = v;
        }
        else i--;
    }

    for(i=0; i<n; i++) {
        v = a[i];
        j = i-1;

        while( j>=0 && a[j] > v ) {
            a[j+1] = a[j];
            j--;
            a[j+1] = v;
        }

        for(j=0; j<n; j++){
            if( j<n-1 ) printf("%d ", a[j]);
            else printf("%d\n", a[j]);
        }

    }

    return 0;
}


Measured memory_bytes: 2100
def greedyTakahashi(a, b, k):

    a -= k

    if a < 0:
        return (0, b+a) if b+a > 0 else (0, 0)
    else :
        return (a, b)

def main():
    a, b, k = map(int, input().split())
    print(*greedyTakahashi(a, b, k))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9160
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int gcd(int x, int y){
    if(x<y){
        int temp=x;
        x=y,y=temp;
    }
    int r=x%y;
    while(r!=0){
        x=y;
        y=r;
        r=x%y;
    }
    return y;
}
int main(void){
    int n,dis;
    cin >> n >> dis;
    int x,ans;

    for(int i=0; i<n; i++){
        cin >> x;
        if(ans==0)ans=x-dis>=0?x-dis:dis-x;
        ans=gcd(ans,x-dis>=0?x-dis:dis-x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k; cin >> n >> k;
	if (k == 1) {
		cout << 0 << endl;
		return 0;
	}

	cout << (n - k) << endl;

	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int * n_input = new int[n];
    for(int i = 0; i < n; i++) cin >> n_input[i];

    for(int i = n-1; i >= 0; i--) {
        cout << n_input[i];
        if(i != 0) cout << " ";
        else cout << endl;
    }

    delete[] n_input;
    return 0;
}

Measured memory_bytes: 1196
n, k = gets.split(' ').map(&:to_i)
r, s, p = gets.split(' ').map(&:to_i)
t = gets.chomp
points = { 's' => r, 'p' => s, 'r' => p }

total = 0
arr = t.split('')
j = Hash.new(true)

arr.each.with_index do |e, i|
  if (i - k) >= 0 
    # k回目の手が同じ場合は、負ける可能性あり
    if e == arr[i - k]
      # 前回が故意で負けている場合は、問題なし
      if j[i - k]
        j[i] = false
        next
      end
    end
  end
  total += points[e]
end

puts total




Measured memory_bytes: 9980
//https://www.codechef.com/problems/CHEFSUBA
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)>(y)?(y):(x)
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1<<28;
const int maxn=100010;
const int maxm=110;
const int maxk=100010;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n;
int num[maxn*3];
ll maxleft[maxn],minright[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    int a,b;
    while(~scanf("%d",&n))
    {
        cls(maxleft,0);
        cls(minright,0);
        for(int i=0;i<n*3;i++)
            scanf("%d",&num[i]);
        priority_queue<int, vector<int>, greater<int> > Q1;
        priority_queue<int> Q2;
        for(int i=0;i<n;i++)
        {
            maxleft[0]+=num[i];
            Q1.push(num[i]);
            minright[n+1]+=num[n*3-1-i];
            Q2.push(num[n*3-1-i]);
        }
        for(int i=1;i<=n;i++)
        {
            Q1.push(num[n+i-1]);
            maxleft[i]=maxleft[i-1]+num[n+i-1]-Q1.top();
            Q1.pop();

            Q2.push(num[n*2-i]);
            minright[n+1-i]=minright[n+1-i+1]+num[n*2-i]-Q2.top();
            Q2.pop();
        }
        ll ans;
        for(int i=0;i<=n;i++)
        {
            if(i==0)
                ans=maxleft[i]-minright[i+1];
            else
                ans=max(ans,maxleft[i]-minright[i+1]);
        }
        printf("%lld\n",ans);
    }
    return 0;
}


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





int main()
{
   int a, b;     
   cin >> a >> b;
   
   if (a == b)
      cout << "a == b" << endl;
   else if(a > b)
      cout << "a > b" << endl;
   else if(a < b)
      cout << "a < b" << endl;
   
   return 0;
}


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

int main(){
    int x,y;
    cin >> x >> y;
    if(x % y == 0){
        cout << -1 << endl;
        return 0;
    } else {
        for(int i = 2;i*x <= pow(10,18);i++){
            if((i*x) % y != 0){
                cout << i*x << endl;
                return 0;
            }
        }
        cout << -1 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a,b,c; cin>>a>>b>>c;
  int pi; pi = 100*a+10*b+c;
  if(pi%4==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
    bool ans=true;
    string s;
    cin>>s;
    rep(i,3){
        if(s.at(i)==s.at(i+1))ans=false;
    }
    if(ans)cout<<"Good"<<endl;
    else cout<<"Bad"<<endl;
}
   



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
#define is(x) cout << #x << " = " << x << endl;
using namespace std;
const int N=500000;
int nxt(){int x;cin >> x;return x;}
int32_t main(){
    base
    int a=nxt(),b=nxt(),c=nxt(),k=nxt();
    int cnt=0;
    if(k-a>=0){
        k-=a,cnt+=a;
        if(k-b>=0){
            k-=b;
            if(k-c>=0)cnt-=c;
            else cnt-=k;
        }
    }
    else cnt=k;
    cout<<cnt;
    exit
}


Measured memory_bytes: 3620
package main

import (
  "fmt"
)

func main() {

  var s string
  fmt.Scan(&s)
  
  a := s[0:1]
  b := s[1:2]
  c := s[2:3]
  d := s[3:4]
  
  if a == b || b == c || c == d {
       fmt.Println("Bad") 
  } else {
      fmt.Println("Good")
  }
}

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

int S(int n) {
	int s = 0;
  	while (n > 0) {
    	s += n % 10;
      	n /= 10;
    }
  	return s;
}

int main() {
  	int N;
  	cin >> N;
 	bool res = N % S(N) == 0;
  	cout << (res ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int k,x,i,j,a[10000];
    scanf("%d%d",&k,&x);
    for(i=k-1,j=0;i>0;i--,j++)
    {
        a[j]=x-i;
    }
    a[j]=x;
    j++;
    for(i=1;i<(k+1);j++,i++)
    {
        a[j]=x+i;
    }
    for(j=0;j<=(2*(k-1));j++)
    {
        printf("%d ",a[j]);
    }
    return 0;
}


Measured memory_bytes: 128
N,X,M=map(int,input().split())
L=[]
L.append(X)
J=[0 for i in range(M+1)]
key=0
start=0
end=0
for i in range(1,M+2):
    X=(X**2)%M
    L.append(X)
    if J[X]>=1:
        key=X
        end=i
        break;
    J[X]+=1
for i in range(1,end):
    if L[end-i]==key:
        start=end-i
A=L[0:start]
B=L[start:end]
C=(N-start)//(end-start)
D=(N-start)%(end-start)
E=L[start:start+D]
if N<end:
    print(sum(L[0:N]))
else:
    print(sum(A)+sum(B)*C+sum(E))

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

int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;
  char c = op.at(0);
  if (c=='+') {
    cout << A+B << endl;
  }
  else {
    cout << A-B << endl;
  }
}

Measured memory_bytes: 256
ary = Array.new
while line = $stdin.gets
ary << line.chomp.split.map{|item|item.to_i}
end
n = ary[0][0].to_i
ary.delete_at(0)
ary.sort!{|a,b| a[1] <=> b[1]}
timesum = 0
flag = 0
ary.each{|item|
    timesum += item[0]
    if timesum > item[1] then
        flag = 1
        break
    end
}
if flag == 0 then
    print "Yes"
else
    print "No"
end

Measured memory_bytes: 18552
#include<stdio.h>
 int main()
 {
     int N;
      scanf("%d",&N);
      if(N%2!=0)
      printf("No");
      else
      {
     char s[N+5];
    
     scanf("%s",s);
     int flag=0;
     for(int i=0;i<N/2;i++)
     {
         if(s[i]!=s[i+N/2])
         {
             flag=1;
             break;
         }
     }
     if(flag==1)
     printf("No");
     else
     printf("Yes");
      }
     return 0;
 }


Measured memory_bytes: 128
mod=10**9+7
N=input()
n=len(N)
DP=[[0]*2 for _ in range(n)]
DP[0][1]=1
DP[0][0]=2
for i in range(1,n):
  if N[i]=="1":
    DP[i][0]=2*DP[i-1][0]%mod
    DP[i][1]=(3*DP[i-1][1]+DP[i-1][0])%mod
  else:
    DP[i][0]=DP[i-1][0]%mod
    DP[i][1]=3*DP[i-1][1]%mod
print((DP[n-1][0]+DP[n-1][1])%mod)

Measured memory_bytes: 19652
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, x, t = input_a

tmp = (n / x.to_f).ceil
puts tmp * t


Measured memory_bytes: 14356
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int N=sc.nextInt(),m=0,res=0;
        HashMap<Integer,Integer> c=new HashMap<>();
        for(int i=0;i<N;i++){
            int t=sc.nextInt();
            if(!c.containsKey(t)){
                c.put(t,1);
            }
            else{
                c.put(t,c.get(t)+1);
            }
            m=Math.max(c.get(t),m);
        }
        for(int i:c.keySet()){
            if(c.get(i)<i){
                res+=c.get(i);
            }
            else{
                res+=Math.min(c.get(i),c.get(i)-i);
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 63480
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	s := scanInts(n)
	t := scanInts(m)

	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, m+1)
	}
	for i := 0; i < m+1; i++ {
		dp[0][i] = 1
	}

	for i := 0; i < n; i++ {
		add := 0
		dp[i+1][0] = 1
		for j := 0; j < m; j++ {
			dp[i+1][j+1] = dp[i][j+1]
			if s[i] == t[j] {
				add+=dp[i][j]
				add %= MOD
			}

			dp[i+1][j+1] += add
			dp[i+1][j+1] %= MOD
		}
		// debug(dp[i+1])
	}

	fmt.Fprintln(wr, dp[n][m])
}

// MOD constant
const MOD = 1000000007


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

ans1 = max(a)
ans2 = 0

dif = ans1
for i in a:
  if dif > abs(i-ans1/2) and i != ans1:
    dif = abs(i-ans1/2)
    ans2 = i
    
print(ans1, ans2)

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

using namespace std;

using ll = long long;

ll n;
const ll mod = 1e9 + 7;

inline ll bigMod(ll n, ll p) {
  if(p == 0) return 1 % mod;
  ll temp = bigMod(n, p / 2);
  temp = ((temp % mod) * (temp % mod)) % mod;
  if(p & 1) temp = ((temp % mod) * (n % mod)) % mod;
  return temp % mod;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  ll ans = 0;
  ans += (bigMod(10, n) % mod + bigMod(8, n) % mod) % mod;
  ans -= ((2 % mod) * (bigMod(9, n) % mod)) % mod;
  if(ans < 0) ans = (ans + mod) % mod;
  cout << ans % mod;
  return 0;
}

Measured memory_bytes: 3612