akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define NUM 10

int main(){
  int a,b;
  char s[NUM],t[NUM],u[NUM];

  scanf("%s",s);
  scanf("%s",t);
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%s",u);

  if(strcmp(s,u) == 0){
    a--;
  }
  else if(strcmp(t,u) == 0){
    b--;
  }

  printf("%d %d\n",a,b);

  return 0;
}


Measured memory_bytes: 128
import sys
n = int(input())
a = [int(i) for i in input().split()]
if 0 in a:
    print(0)
    sys.exit(0)
ans = 1
for i in a:
    ans = ans * i
    if ans > 10 ** 18:
        print(-1)
        sys.exit(0)
print(ans)




Measured memory_bytes: 21640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=(a);i<ll(b);i++)
#define rep(i,b) loop(i,0,b)
 
typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, Capacity cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct Dinic {
    int n, s, t;
    vector<int> level, prog, que;
    vector<vector<Capacity>> cap, flow;
    vector<vector<int>> g;
    Capacity inf;
    Dinic(const Graph &graph)
        : n(graph.size()),
          cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
          g(n, vector<int>()), inf(numeric_limits<Capacity>::max()/8){
        for(int i = 0; i < n; i++) for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);
    }
    void addEdge(int u, int v, Capacity c){
        cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
        g[u].push_back(v); g[v].push_back(u);
    }
    inline Capacity residue(int u, int v){ return cap[u][v] - flow[u][v]; }
    Capacity solve(int s_, int t_){
        this->t = t_, this->s = s_;
        que.resize(n+1);
        Capacity res = 0;
        while(levelize()){ prog.assign(n, 0); res += augment(s, inf); }
        return res;
    }
    bool levelize(){
        int l = 0, r = 0;
        level.assign(n, -1); level[s] = 0; que[r++] = s;
        while(l != r){
            int v = que[l++]; if(v == t) break;
            for(const int &d : g[v]){
                if(level[d] == -1 && residue(v,d) != 0){
                    level[d] = level[v] + 1; que[r++] = d;
                }
            }
        }
        return level[t] != -1;
    }
    Capacity augment(int v, Capacity lim){
        Capacity res = 0;
        if(v == t) return lim;
        for(int &i = prog[v]; i < (int)g[v].size(); i++){
            const int &d = g[v][i];
            if(residue(v,d) == 0 || level[v] >= level[d]) continue;
            const Capacity aug = augment(d, min(lim, residue(v,d)));
            flow[v][d] += aug; flow[d][v] -= aug;
            res += aug; lim -= aug;
            if(lim == 0) break;
        }
        return res;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    Dinic ek(g);
    cout << ek.solve(0,N-1) << endl;
}

Measured memory_bytes: 3296
A,B,C = map(int,input().split())
K = int(input())
a,b,c = A,B,C
n = 0
while a >= b:
    b *= 2
    n += 1
    if n > K:
        print("No")
        exit()

while b >= c:
    c *= 2
    n += 1
    if n > K:
        print("No")
        exit()
print("Yes")




Measured memory_bytes: 9164
N, K, Q = map(int, input().split())

getp = [0 for _ in range(N)]
for _ in range(Q):
  A = int(input())
  getp[A-1] += 1

for i in range(N):
  if K - Q + getp[i] > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9932
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e6+5;
const int mod=998244353;
int n,m,inv[N],jc[N],jcn[N],foo,bar;
int C(int n,int m){
	if(n<0||m<0||n<m)return 0;
	return 1ll*jc[n]*jcn[m]%mod*jcn[n-m]%mod;
}
int cal(int n,int m){
	return C(n+m-1,n);
}
int main(){
	scanf("%d%d",&n,&m);inv[1]=jc[0]=jcn[0]=1;
	for(int i=2;i<N;++i)inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	for(int i=1;i<N;++i)jc[i]=1ll*jc[i-1]*i%mod,jcn[i]=1ll*jcn[i-1]*inv[i]%mod;
	for(int i=0;i<=m&&i<=n;++i)if(~(m+m+m-i)&1)foo=(foo+1ll*C(n,i)*cal(m+m+m-i>>1,n))%mod;
	for(int i=0;i<m;++i)bar=(bar+cal(i,n-1))%mod;
	printf("%lld\n",(foo+1ll*(mod-n)*bar)%mod);return 0;
}


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

using namespace std;

int main() {
	cin.sync_with_stdio(false);

	int K, S;
	cin >> K >> S;
	int count=0;
	for (int x = 0;x <= K; x++) {
		for (int y = 0;y <= K; y++) {
			int z = S - x - y;
			if (0 <= z&&z <= K) {
				count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    S = input()
    logging.info("Hello!")

    if N % 2 == 1:
        print("No")
    else:
        half_S_1 = S[0:N // 2]
        logging.info(half_S_1)
        half_S_2 = S[N // 2:N]
        logging.info(half_S_2)

        if half_S_1 == half_S_2:
            print("Yes")
        else:
            print("No")
            
if __name__ == "__main__":
    main()

Measured memory_bytes: 4212
#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;
}
template <typename T>
T gcd(const T x, const T y) {
  if (x == 0) {
    return y;
  } else if (y == 0) {
    return x;
  } else if (x < y) {
    return gcd(x, y % x);
  } else if (y < x) {
    return gcd(y, x % y);
  } else {
    return x;
  }
}

template <typename T>
T lcm(const T x, const T y) {
  if (x == 0 || y == 0) {
    return 0;
  } else {
    return x / gcd(x, y) * y;
  }
}
int main() {
  int64_t n, m;
  std::cin >> n >> m;

  std::vector<int64_t> a(n);
  std::cin >> a;
  std::sort(a.begin(), a.end());

  std::set<int64_t> s;

  for (int64_t i = 0; i < n; i++) {
    a[i] /= 2;
    s.insert(a[i]);
  }

  if (s.size() == 1) {
    if (m < a[0]) {
      std::cout << 0 << std::endl;
    } else {
      m -= a[0];
      std::cout << 1 + m / (2 * a[0]) << std::endl;
    }
  } else {
    std::vector<int64_t> b(a.cbegin(), a.cend());
    auto g = gcd(b[0], b[1]);
    auto l = lcm(b[0], b[1]);
    for (int64_t i = 2; i < b.size(); i++) {
      l = lcm(l, b[i]);
      g = gcd(g, b[i]);
      if (m < l) {
        std::cout << 0 << std::endl;
        return 0;
      }
    }

    for (const auto j : b) {
      if ((j / g) % 2 == 0) {
        std::cout << 0 << std::endl;
        return 0;
      }
    }

    if (m < l) {
      std::cout << 0 << std::endl;
    } else {
      m -= l;
      std::cout << 1 + m / (2 * l) << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1792
//R, G, B のみからなる、長さ N の文字列 S があります。
//以下の 2 つの条件をともに満たす組 (i, j, k) (1 ≤ j < k ≤ N)の数を求めてください。

//S_i ≠S_j かつ S_i≠S_k かつ S_j≠S_k である
//j−i≠k-j である

//解説通り書きました
//通り数を計算するときはこのやり方を使おう
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int N,r = 0,g = 0,b = 0;
  ll p;
  string S; cin >> N >> S;
  vector<int> a(N);
  rep(i,N){
    if(S[i] == 'R') a[i] = 0;
    if(S[i] == 'G') a[i] = 1;
    if(S[i] == 'B') a[i] = 2;
  }
  vector<int> cnt(3);
  rep(i,N) cnt[a[i]]++;
  ll ans = 1;
  rep(i,3) ans *= cnt[i];
  for(int j = 0; j < N; ++j){
    for(int i = 0; i < j; ++i){
      int k = j + (j - i);
      if(k < N){
        if(S[i] == S[j]) continue;
        if(S[i] == S[k]) continue;
        if(S[j] == S[k]) continue;
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll gcd(ll a, ll b){
    if(a<b && a>0){
      ll x;
      x = a;
      a = b;
      b = x;
    }
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}
template <typename T>
T lcm(T x, T y) {
    return x / gcd(max(x,y), min(x,y)) * y;
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> a(n);
    ll l = 1;
    for(auto &x : a) {
        cin >> x;
        l=lcm(l,x/2);
    }
    ll ret = 0;
    //cout << l << endl;
    for(auto &x:a){
        if(l%x==0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/l+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<queue>
#include<cstdlib>
using namespace std ;

#define MAXN 100007

int n ;
int a[ MAXN ] ;

int pos[ MAXN ] ;

class Tree {
    public :
    int tr[ 6 * MAXN ] ;
    void init ( int where , int IL , int IR ) {
        tr[ where ] = 0 ;
        if ( IL == IR ) { return ; }
        int mid = ( IL + IR ) / 2 ;
        init ( 2 * where , IL , mid ) ;
        init ( 2 * where + 1 , mid + 1 , IR ) ;
    }
    void update ( int where , int IL , int IR , int pos , int val ) {
        if ( IR < pos || pos < IL ) { return ; }
        if ( IL == IR ) {
            tr[ where ] = val ;
            return ;
        }
        int mid = ( IL + IR ) / 2 ;
        if ( pos <= mid ) {
            update ( 2 * where , IL , mid , pos , val ) ;
        }
        else {
            update ( 2 * where + 1 , mid + 1 , IR , pos , val ) ;
        }
        tr[ where ] = tr[ 2 * where ] + tr[ 2 * where + 1 ] ;
    }
    int getl ( int where , int IL , int IR , int pos ) {
        if ( pos < IL ) { return 0 ; }
        if ( IR <= pos && tr[ where ] == 0 ) { return 0 ; }
        if ( IL == IR ) { return IL ; }
        int mid = ( IL + IR ) / 2 ;
        int ret = getl ( 2 * where + 1 , mid + 1 , IR , pos ) ;
        if ( ret > 0 ) { return ret ; }
        return getl ( 2 * where , IL , mid , pos ) ;
    }
    int getr ( int where , int IL , int IR , int pos ) {
        if ( IR < pos ) { return n + 1 ; }
        if ( pos <= IL && tr[ where ] == 0 ) { return n + 1 ; }
        if ( IL == IR ) { return IL ; }
        int mid = ( IL + IR ) / 2 ;
        int ret = getr ( 2 * where , IL , mid , pos ) ;
        if ( ret < n + 1 ) { return ret ; }
        return getr ( 2 * where + 1 , mid + 1 , IR , pos ) ;
    }
};

Tree w ;

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

void solve ( ) {
    w.init ( 1 , 1 , n ) ;
    long long ans = 0 ;
    for ( int i = n ; i >= 1 ; -- i ) {
        int prv1 , nxt1 ;
        prv1 = w.getl ( 1 , 1 , n , pos[ i ] ) ;
        nxt1 = w.getr ( 1 , 1 , n , pos[ i ] ) ;
        int prv2 , nxt2 ;
        if ( prv1 == 0 ) { prv2 = 0 ; }
        else { prv2 = w.getl ( 1 , 1 , n , prv1 - 1 ) ; }

        if ( nxt1 == n + 1 ) { nxt2 = n + 1 ; }
        else { nxt2 = w.getr ( 1 , 1 , n , nxt1 + 1 ) ; }

        ans += 1LL * i * ( pos[ i ] - prv1 ) * ( nxt2 - nxt1 ) ;
        ans += 1LL * i * ( prv1 - prv2 ) * ( nxt1 - pos[ i ] ) ;

        w.update ( 1 , 1 , n , pos[ i ] , 1 ) ;
    }
    printf ( "%lld\n" , ans ) ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define pb			push_back
#define vi  		vector<int>
#define all(a)		(a).begin(),(a).end()
#define F 			first
#define S 			second
#define endl		"\n"
#define fast 		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int 		long long int
#define mod			1000000007

static int t[3][4001];
int32_t main(){

	int n;cin>>n;
	int m;cin>>m;
	int arr[m];
	int ans=n;
	for(int i=0;i<m;i++){
		cin>>arr[i];
		ans=ans-arr[i];
	}
	if(ans<0)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	string s;
	cin >> s;
	for(int i=0;i<(int)s.size()-1;i++){
		if(s[i]=='A'&&s[i+1]=='C'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

ss=input()
ans=0

if ss[-1]=="1":
    ans=-1
s=ss[:-1]
#print(s)
gans=[]

c=1
for i in range(len(s)):
    if i==0 and s[i]=="0":
        ans=-1
        break
    if s[i] != s[len(s)-i-1]:
        ans=-1
        break
    
    if s[i]=="1":
        gans.append([c, i+2])
        c=i+2
    else:
        gans.append([i+2,c])


if ans==-1:
    print(ans)
else:
    for i in gans:
        print(*i)

Measured memory_bytes: 21356
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int h = sc.nextInt();
			int w = sc.nextInt();
			if(h==0 && w==0) break;
			int[][] map = new int[h][w];
			
			int wid;
			int max = 0;
			char[] a = new char[w];
			for(int i=0;i<h;i++){
				a = sc.next().toCharArray();
				for(int j=0;j<w;j++){
					wid = 501;
					if(a[j]=='.'){
						if(j==0) map[i][j]=1;
						else map[i][j] = map[i][j-1]+1;
						for(int k=i;k>=0;k--){
							if(map[k][j]==0) break;
							wid = Math.min(wid, map[k][j]);
							max = Math.max(max, wid*(i+1-k));
						}
					}
				}
			}
			System.out.println(max);
		}	
	}	
}

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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  int p = 0;
  int i = 0;

  while (s.substr(i).length() > 0) {
    if (s[i] == '(') {
      if (p < 0) {
        s.insert(0, -p, '(');
        i -= p;
        p = 0;
      }
      p++;
    } else p--;
    i++;
  }
  if (p < 0) s = s.insert(0, -p, '(');
  if (p > 0) s = s.append(p, ')');
  cout << s << endl;
}


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

long h,w;
string ans="Yes";
vector<string> s(60);

bool check(long i,long j) {
  if(s[i][j]=='.') return false;
  if(i!=0) if(s[i-1][j]=='#') return false;
  if(i!=h-1) if(s[i+1][j]=='#') return false;
  if(j!=0) if(s[i][j-1]=='#') return false;
  if(j!=w-1) if(s[i][j+1]=='#') return false;
  return true;
}

int main() {
  cin >> h >> w;
  for(long i=0;i<h;i++) cin >> s[i];
  for(long i=0;i<h;i++) {
    for(long j=0;j<w;j++) {
      if(check(i,j)) ans="No";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
require 'pp'

n = gets.chomp!.to_i
a_n = gets.chomp!.split(" ").map(&:to_i)

sum = a_n.inject(&:+)

left = [a_n[0]]
right = [sum - a_n[0]]
sum
0.upto(n-2) do |i|
    left[i+1] = left[i] + a_n[i+1]
    right[i+1] = sum - left[i+1]
end

ans = 10 ** 20
left.length.times do |i|
    t = (left[i] - right[i]).abs
    if t < ans
        ans = t
    end
end

puts ans


Measured memory_bytes: 19656
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,c,d,e,i,h,k,l=0;
vector<long long>v;
cin>>a>>b;
for(i=1;i<=a;i++)
{
cin>>c;
v.push_back(c);
}
for(i=0;i<a-1;i++)
{
  if(v[i+1]-v[i]<b)
l+=v[i+1]-v[i];
else l+=b;
}
l+=b;
cout<<l<<endl;
}

Measured memory_bytes: 2420
#include<cstdio>
#include<iostream>
using namespace std;
int n;
long long l[87];

int main(){
    scanf("%d", &n);
    l[0] = 2LL, l[1] = 1LL;
    for(int i = 2;i < n+1;i++) l[i] = l[i-2] + l[i-1];
    cout << l[n];
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	double n, k;
	cin >> n >> k;

	double ans = 0;
	for (double i = 1; i <= n; i++) {
		double score = 1.0 / n;
		double now = i;
		double cnt = 0;
		while (now < k) {
			now *= 2.0;
			score /= 2.0;
		}
		ans += score;
	}

	printf("%.12lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,sn,tn,dic;
  bool rf=false;
  string x;
  
  cin >> x;
  n=x.size();
  
  i=0;
  dic=0;
  while (i<n){
    if (!rf) sn=0;
    tn=0;
    rf=false;
    while (i<n && x[i]=='S'){
      i++;
      sn++;
    }
    while (i<n && x[i]=='T'){
      i++;
      tn++;
    }
    dic+=min(sn,tn);
    if (sn>tn){
      sn-=tn;
      rf=true;
    }
  }
  
  cout << n-dic*2 << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#define llong long long
#define pb(a) push_back(a)
#define strVecSORT(strVec) sort(strVec.begin(), strVec.end());
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main(){
  int N,K,i,answer;
  cin>>N>>K;
  answer=1;
  for(i=0;i<N;i++){
    if(answer*2<answer+K){
      answer=answer*2;
    }else{
      answer=answer+K;
    }
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    int max = 0;
    map<string, int> m;

    rep(i, n){
        string s; cin >> s;
        m[s]++;
        chmax(max, m[s]);
    }
    
    for(auto p : m)
        if(p.se == max)
            cout << p.fi << endl;
            
return 0;
}

Measured memory_bytes: 19220
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <functional>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>

#include <cassert>
using namespace std;

int main(void){

	int N;
	cin >> N;
	vector<int> X(N),Xs(N);
	for(int i=0;i<N;++i){
		cin >> X[i];
	}
	Xs=X;
	sort(Xs.begin(),Xs.end());

	int c1 = Xs[N/2-1];
	int c2 = Xs[N/2];

	for(int i=0;i<N;++i){
		if(X[i]>c1){cout << c1 << endl;}
		else{cout << c2 << endl;}
	}

	return 0;
}

Measured memory_bytes: 3712
package main

import "fmt"

func main() {
  var(
  n int
  s string
  )
  fmt.Scan(&n)
  ss := make(map[string]bool)
  for i := 0; i < n; i++ {
    fmt.Scan(&s)
    ss[s] = true
  }

  fmt.Println(len(ss))
}

Measured memory_bytes: 18888
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

map<string,vector<int> > idx;


main(){
	string name;
	int page;
	
	while(cin>>name>>page){
		idx[name].push_back(page);
	}
	
	for(map<string,vector<int> >::iterator p=idx.begin();p!=idx.end();++p){
		
		cout<<p->first<<endl;
		sort(p->second.begin(),p->second.end());
		int sf=0;
		for(vector<int>::iterator vp=p->second.begin();vp!=p->second.end();vp++){
			if(sf==1)cout<<" ";
			sf=1;
			cout<<*vp;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i, n) cin >> h[i];

    sort(all(h));

    int ans = INF;
    REP(i, n-k+1){
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);

int main()
{
    vector<vector<uint64_t>> arr(0);
    vector<uint64_t> temp_vec(2);
    vector<uint64_t> num_vec(0);
    // string result;
    // vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    // uint32_t sum = 0;
    uint64_t num1, num2;
    uint64_t num, result;
    // uint64_t result;
    double length, mass;

    // uint32_t res_i = 0;
    // string str_temp, str_temp2;
    uint64_t temp, temp2;
    uint64_t i, j, k, l, count, n, o, size;
    // uint32_t count = 0;
    // string str;
    // uint8_t k_flag;
    
    cin >> k >> n;
    for (i=0; i<n; i++) {
        cin >> temp;
        num_vec.push_back(temp);
    }

    for (i=0; i<n; i++) {
        temp = num_vec.at(i) + k;
        num_vec.push_back(temp);
    }

    result = num_vec.at(n - 1) - num_vec.at(0);
    for (i=1; i<n; i++) {
        temp = num_vec.at(n - 1 + i) - num_vec.at(i);
        if (temp < result) {
            result = temp;
        }
    }

    cout << result << endl;
    // cout << fixed << setprecision(10) << mass << endl;

    // for (i=0; i<num; i++) {
    //     cin >> temp_vec.at(0) >> temp_vec.at(1);
    //     arr.push_back(temp_vec);
    // }

    // for (i=0; i<num; i++) {
    //     temp = arr.at(i).at(0);
    //     result[temp] = arr.at(i).at(1);
    // }

    return 0;
}

uint64_t silver_fox(vector<vector<int64_t>>& monster_arr, uint64_t range, uint64_t attack, uint64_t count)
{
    int64_t life, pos, num;
    int64_t i, short_i;

    while (monster_arr.size() != 0) {
        pos = monster_arr[0][0];
        life = monster_arr[0][1];
        count++;
        short_i = 0;

        for (i = 0; i < monster_arr.size(); i++) {
            short_i++;
            if (monster_arr[i][0] < pos + range) {
                monster_arr[i][1] -= attack;
            } else {
                break;
            }
        }

        for (i = short_i - 1; i >= 0; i--) {
            if (monster_arr[i][1] <= 0) {
                monster_arr.erase(monster_arr.begin() + i);
            }
        }
    }

    return count;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


Measured memory_bytes: 6384
#include <stdio.h>


int main()
{
    int a[100005]={0};

    int n;
    scanf("%d",&n);

    int x;

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

       a[x-1]++;
       a[x]++;
       a[x+1]++;
    }

    int boro=0;

    for(int i=0;i<100005;i++)
    {
        if(a[i]>boro)
        {
            boro=a[i];
        }
    }

    printf("%d",boro);

    return 0;
}


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

int main(){
  int n, a, b, c, i;
  int e=0;
  cin >> n;
  
  for(;i<n;i++){
    cin >> a >> b;
    c=b-a+1;
    e+=c;
  }
  cout << e << endl;
}


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

constexpr long long int mod = 998244353;
int main(){
    int N,S; cin >> N >> S;
    vector<int> A(3010);
    for(int i=0;i<N;++i){
        cin >> A[i];
    }
    vector<vector<long long int>> dp(3030,vector<long long>(3030));
    dp[0][0] = 1;
    for(int i=0;i<N;++i){
        for(int j=0;j<S+1;++j){
            dp[i+1][j] += 2 * dp[i][j];
            dp[i+1][j] %= mod;
            if(j + A[i] <= S){
                dp[i+1][j+A[i]] += dp[i][j];
                dp[i+1][j+A[i]] %= mod;
            }
        }
    }
    cout << dp[N][S] << endl;
}

Measured memory_bytes: 75040
K=int(input())
a=set([1,2,3,4,5,6,7,8,9])
prev=set([1,2,3,4,5,6,7,8,9])

while len(a)<K:
  temp=set()
  for now in prev:
    c=now%10
    if c==0:
      temp.add(now*10)
      temp.add(now*10+1)
    elif c==9:
      temp.add(now*10+9)
      temp.add(now*10+8)
    else:
      temp.add(now*10+c-1)
      temp.add(now*10+c)
      temp.add(now*10+c+1)
  prev=temp
  a=a|temp
print(sorted(list(a))[K-1])

Measured memory_bytes: 31204
import math

a, b, h, m = map(int, input().split())

hdeg = math.radians(360 / 12 / 60)
mdeg = math.radians(360 / 60)

hdeg *= 60 * h + m
mdeg *= m

deg = abs(hdeg - mdeg)

# 余弦定理
ans = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(deg))
print(ans)

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

int main() {
  int A, B;
  char w[100];
  scanf("%s", w);

  vector<int> app(26, 0);

  for (int i = 0; w[i] != '\0'; i++) {
      app[w[i] - 'a']++;
  }

  for (int i = 0; i < 26; i++) {
      if(app[i]%2!=0) {
          printf("No"); 
          return 0;
      }
  }
  puts("Yes"); 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 



int32_t main()
{
	IOS
	string s;cin>>s;
	int n=s.length();
	s='$'+s;
	vvi dp(n+1,vi(13));
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		if(s[i]!='?')
		{
		     for(int j=0;j<13;j++)
		     {
				 dp[i][(j*10+s[i]-'0')%13]+=dp[i-1][j];
				 dp[i][(j*10+s[i]-'0')%13]%=MOD;
			 }
		}
		else
		{
			for(int j=0;j<13;j++)
			{
				for(int k=0;k<10;k++)
				{
					dp[i][(j*10+k)%13]+=dp[i-1][j];
					dp[i][(j*10+k)%13]%=MOD;
				}
			}
		}
	}
	cout<<dp[n][5]<<endl;
			 
		

}


Measured memory_bytes: 13676
#include <iostream>
#include <string>
#include <list>
#include <sstream>
using namespace std;

string toStr(int n) {
    stringstream ss;
    ss << n;
    return ss.str();
}

int main() {
    int m, n;
    while (cin >> m >> n, m) {
        list<int> player;
        for (int i=1; i<=m; ++i) {
            player.push_back(i);
        }
        list<int>::iterator it = player.begin();
        string s, expected;
        for (int i=1; i<=n; ++i) {
            cin >> s;
            if (i % 15 == 0) {
                expected = "FizzBuzz";
            } else if (i % 5 == 0) {
                expected = "Buzz";
            } else if (i % 3 == 0) {
                expected = "Fizz";
            } else {
                expected = toStr(i);
            }
            if (s == expected) {
                ++ it;
            } else if (1 < (int)player.size()) {
                it = player.erase(it);
            }
            if (it == player.end()) {
                it = player.begin();
            }
        }
        for (it = player.begin(); it != player.end(); ++it) {
            cout << (it == player.begin() ? "" : " ") << *it;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1260
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n,m;cin>>n>>m;
  vector<string>a(n);
  vector<string>b(m);
  rep(i,n)cin>>a[i];
  rep(i,m)cin>>b[i];
  rep(i,n-m+1){
    rep(j,n-m+1){
      bool ans=true;
      rep(p,m){
        rep(q,m){
          if(a[p+i][q+j]!=b[p][q])ans=false;
        }
      }
      if(ans){
        //cout<<i<<" "<<j<<endl;
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}
             

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const string str[] = {"Wednesday","Thursday","Friday",
		      "Saturday","Sunday","Monday","Tuesday"};
const int m[] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
int main(){
  int mon,day;
  while(cin >> mon >> day, mon + day){

    for(int i = 0 ; i < mon ; i++){
      day += m[i];
    }
    cout << str[day%7] << endl;
}
  return 0;
}

Measured memory_bytes: 1192
def main():
    N = int(input())
    li = list(map(int, input().split()))
    li2 = [i for i in li if not (i % 2)]
    ans = "APPROVED"
    for j in li2:
        if (j % 3) and (j % 5):
            print("DENIED")
            quit()
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
x,y = map(int, input().split())
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]

if (x in g1 and y in g1) or (x in g2 and y in g2) or (x == 2 and y == 2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
struct MInt {
    static int64_t mod;
    int64_t v;
    MInt() {}
    MInt(int64_t x) : v(x) {}
    MInt operator+(const MInt &y) { return (v + y.v) % mod; }
    MInt operator-(const MInt &y) { return (v - y.v + mod) % mod; }
    MInt operator*(const MInt &y) { return (v * y.v) % mod; }
    void operator+=(const MInt &y) { *this = *this + y; }
    void operator-=(const MInt &y) { *this = *this - y; }
    void operator*=(const MInt &y) { *this = *this * y; }
    friend istream &operator>>(istream &ist, MInt &m) { return ist >> m.v; }
    friend ostream &operator<<(ostream &ost, MInt &m) { return ost << m.v; }
    operator int64_t() { return v; }
};
int64_t MInt::mod = MOD;
// 恐らくDP(ナップザック問題的な)
vector<int> a;
MInt dp[301][50001][2][2];
MInt powmod(int64_t a, int64_t p) {
    int64_t value = 1;
    for (int64_t mul = a; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
        if (p & 1) value = (value * mul) % MOD;
    }
    return MInt(value);
}
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, S = 0;
    cin >> N;
    a = vector<int>(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        S += a[i];
    }
    int sup = S / 2 + (S & 1);
    for (int i = 0; i <= sup; i++) {
        for(int j = 0; j <= N; j++) {
            dp[j][i][0][0] = dp[j][i][0][1] = dp[j][i][1][0] = dp[j][i][1][1] = 0;
        }
    }
    dp[0][0][0][0] = 1;
    for(int i = 0; i < N; i++) {
        for(int b = 0; b <= sup; b++) {
            for(int g = 0; g < 2; g++) {
                for(int r = 0; r < 2; r++) {
                    dp[i + 1][b][g][1] += dp[i][b][g][r];
                    dp[i + 1][b][1][r] += dp[i][b][g][r];
                    dp[i + 1][min(sup, b + a[i])][g][r] += dp[i][b][g][r];
                }
            }
        }
    }
    MInt M_Pinv = dp[N][sup][1][1];
    M_Pinv *= 3;
    MInt M_all = powmod(3, N) - (powmod(2, N) * MInt(3)) + MInt(3);
    MInt M_P = M_all - M_Pinv;
    cout << M_P << endl;
    return 0;
}

Measured memory_bytes: 470272
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,t,b,w=1,s;
   int h[1005],a[1005];
   cin>>n>>t>>b;
   for(int i=1;i<=n;i++)
   {
   	  cin>>h[i];
   	  a[i]=abs(1000*t-6*h[i]-b*1000);
   }
   s=a[1];
    for(int i=2;i<=n;i++)
   {
   	  if(a[i]<s){
   	  	s=a[i];w=i;
   	  }
   }
   cout<<w;
	return 0;
}


Measured memory_bytes: 256
N, *ABC = map(int, input().split())
s = [input() for _ in range(N)]

yes_flag = True
ans_list = []

if sum(ABC) == 0:
    yes_flag = False

for i in range(N):
    if not yes_flag:
        break
    u = ord(s[i][0]) - 65
    v = ord(s[i][1]) - 65
    if ABC[u] + ABC[v] == 0:
        yes_flag = False
    elif ABC[u] + ABC[v] == 1:
        if ABC[u] == 1:
            ans_list += [s[i][1]]
            ABC[u] -= 1
            ABC[v] += 1
        else:
            ans_list += [s[i][0]]
            ABC[v] -= 1
            ABC[u] += 1
    elif ABC[u] + ABC[v] == 2:
        # 両方1の場合だけケアが必要
        if ABC[u] * ABC[v] == 1:
            if i == N-1:
                if ABC[u] > 0:
                    ans_list += [s[i][1]]
                else:
                    ans_list += [s[i][0]]
            else:
                if s[i][1] in s[i+1]:
                    ans_list += [s[i][1]]
                    ABC[u] -= 1
                    ABC[v] += 1
                else:
                    ans_list += [s[i][0]]
                    ABC[v] -= 1
                    ABC[u] += 1
        else:
            if ABC[u] > 1:
                ans_list += [s[i][1]]
                ABC[u] -= 1
                ABC[v] += 1
            else:
                ans_list += [s[i][0]]
                ABC[v] -= 1
                ABC[u] += 1
    else:
        if ABC[u] > 1:
            ans_list += [s[i][1]]
            ABC[u] -= 1
            ABC[v] += 1
        else:
            ans_list += [s[i][0]]
            ABC[v] -= 1
            ABC[u] += 1

if yes_flag:
    print("Yes")
    print(*ans_list)
else:
    print("No")


Measured memory_bytes: 17772
#include<stdio.h>

int main(){
    int D;
    scanf("%d" , &D);
    if (D==22){
        printf("Christmas Eve Eve Eve\n");
    }else if(D==23){
        printf("Christmas Eve Eve\n");
    }else if(D==24){
        printf("Christmas Eve\n");
    }else if(D==25){
        printf("Christmas\n");
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<(ll)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
const ll INF = 1e9;
int main(){
    fast_io
    
    int n;
    cin>>n;
    int d[n];
    rep(i,n) cin>>d[i];

    int left=n/2-1;
    int right=left+1;
    sort(d, d+n);
    cout<<d[right]-d[left]<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n;
  cin >> n;
  string s ,t;
  cin >> s >> t;
  for(int i = 0;i<n;i++)cout << s[i] << t[i];
  cout<< "\n";
  return 0;
}



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

using namespace std;

set<int> s;
int main()
{
  s.insert(2);
  s.insert(4);
  s.insert(3);
  s.insert(9);

  int N;
  cin >> N;
  if (N == 3)
  {
    cout << "2 5 63" << endl;
    return 0;
  }
  else if (N == 4)
  {
    cout << "2 5 20 63" << endl;
  }
  else
  {
    if (N <= 15002 && N % 3 != 0)
    {
      for (int i = 0; i < N - 4; i++)
      {
        s.insert(2 * (i + 3));
      }
    }
    else if (N >= 15003 && N % 3 != 0)
    {
      for (int i = 0; i < 4998; i++)
      {
        s.insert(3 + 6 * (i + 2));
      }
      for (int i = 0; i < N - 4998 - 4; i++)
      {
        s.insert(2 * (i + 3));
      }
    }
    else if (N % 3 == 0 && N % 2 == 0)
    {
      if (N <= 5002)
      {
        for (int i = 0; i < N - 4; i++)
        {
          s.insert(15 + (i * 6));
        }
      }
      else if (5004 <= N && N <= 10002)
      {
        for (int i = 0; i < 5000; i++)
        {
          s.insert(2 * (i + 3));
        }
        for (int i = 0; i < N - 5000 - 4; i++)
        {
          s.insert(15 + (i * 6));
        }
      }
      //10006から
      else if (10004 <= N && N <= 15002)
      {
        for (int i = 0; i < 10000; i++)
        {
          s.insert(2 * (i + 3));
        }
        for (int i = 0; i < N - 10000 - 4; i++)
        {
          s.insert(15 + (i * 6));
        }
      }
      //15006から
      else if (15004 <= N)
      {
        for (int i = 0; i < 14998; i++)
        {
          s.insert(2 * (i + 3));
        }
        for (int i = 0; i < N - 15000 - 2; i++)
        {
          s.insert(15 + (i * 6));
        }
      }
    }
    else if (N % 3 == 0 && N % 2 == 1)
    {
      //5001まで
      if (N <= 5001)
      {
        s.insert(6);
        for (int i = 0; i < N - 5; i++)
        {
          s.insert(15 + (i * 6));
        }
      }
      //5007
      else if (5003 <= N && N <= 10003)
      {
        for (int i = 0; i < 5001; i++)
        {
          s.insert(2 * (i + 3));
        }
        for (int i = 0; i < N - 5005; i++)
        {
          s.insert(15 + (i * 6));
        }
      }
      //10005
      else if (10005 <= N && N <= 15001)
      {
        for (int i = 0; i < 9999; i++)
        {
          s.insert(2 * (i + 3));
        }
        for (int i = 0; i < N - 10003; i++)
        {
          s.insert(15 + (i * 6));
        }
      }
      //15003
      else if (15003 <= N)
      {
        for (int i = 0; i < 14997; i++)
        {
          s.insert(2 * (i + 3));
        }
        for (int i = 0; i < N - 15001; i++)
        {
          s.insert(15 + (i * 6));
        }
      }
    }
    for (auto x : s)
    {
      cout << x << ' ';
    }
  }
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
    char rcd[3];
    int i,t=0;
    cin >> rcd;
    for(i=0;i<3;i++)
        if(rcd[i]=='R')
            t++;

    if(t == 3)
        cout <<t;
    else if(t == 2)
        {
            if(rcd[1]=='S')
                cout << 1;
            else
                cout << 2;
        }
    else if(t == 1)
        cout << t;
    else
        cout << 0;
    return 0;
}


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

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

  double sum = 0.0;
  for (int i = 1; i <= n; i++) {
    int tmp   = i;
    int index = 0;
    while (k > tmp) {
      tmp *= 2;
      index++;
    }
    double t = pow(0.5, index);
    sum += (1 / n) * t;
  }
  cout << fixed << setprecision(12) << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <fstream>
#include <numeric>


using namespace std;

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

const int INF = 1 << 29;        // 十分大きい値にする

// 入力
string S, T;

// DP テーブル
int dp[1010][1010];
int n;
int ans[150];

int main() {

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> S >> T;
        memset(dp, 0, sizeof(dp));    // 初期化
        for (int i = 0; i < S.size(); ++i) {
            for (int j = 0; j < T.size(); ++j) {
                if (S[i] == T[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
            }
        }

        ans[i] = dp[S.size()][T.size()];

    }

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

}


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

using namespace std;

int main()
{
	string str, cmd, p;
	int q, a, b;

	cin >> str >> q;

	for (int i = 0; i < q; i++){
		cin >> cmd;
		if (cmd == "print"){
			cin >> a >> b;
			cout << str.substr(a, b - a + 1) << endl;
		}
		else if (cmd == "reverse"){
			cin >> a >> b;
			p = str.substr(a, b - a + 1);
			reverse(p.begin(), p.end());
			str.replace(a, p.length(), p);
		}
		else if (cmd == "replace"){
			cin >> a >> b >> p;
			str.replace(a, p.length(), p);
		}
	}

	return 0;
}

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


int main() {
  ll X;
  cin >> X;
  ll A = 1000, B = 1000;
  while (true) {
    ll sum = pow(A, 5) - pow(B, 5);
    if (sum == X) {
      break;
    } else if (sum > X) {
      A--;
    } else {
      B--;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int  a[3];
  for (int i = 0; i < 3; i++) cin >> a[i];
  int k; cin >> k;
  sort(a, a + 3);
  long long res = 1;
  cout << a[0] + a[1] + (a[2] << k) << "\n";
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

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

result = 0
t = -1
for a, b in ab:
    a, b = a - 1, b - 1
    if a <= t < b:
        continue
    result += 1
    t = b - 1
print(result)


Measured memory_bytes: 29856
#include <stdio.h>
#include <ctype.h>
int main(void){
    char a[10],b[10],c[10];
    scanf("%s %s %s",a,b,c);
    printf("%c%c%c",toupper(a[0]),toupper(b[0]),toupper(c[0]));
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (s[i] == '?') {
            s[i] = 'D';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 3752
a = int(input())
b = list(map(int, input().split()))
c = {}
d = {}
for i in range(a):
    if i % 2 == 0:
        if b[i] not in c:
            c[b[i]] = 1
        else:
            c[b[i]] += 1
    else:
        if b[i] not in d:
            d[b[i]] = 1
        else:
            d[b[i]] += 1
e = sum(c.values()) + sum(d.values())
c = sorted(c.items(), key=lambda x: x[1], reverse=True)
d = sorted(d.items(), key=lambda x: x[1], reverse=True)
if c[0][0] == d[0][0]:
    if len(c) == len(d) == 1:
        print(c[0][1])
    elif len(c) == 1:
        print(e - c[0][1] - d[1][1])
    elif len(d) == 1:
        print(e - c[1][1] - d[0][1])
    else:
        if c[0][1] - c[1][1] > d[0][1] - d[1][1]:
            print(e - c[0][1] - d[1][1])
        else:
            print(e - c[1][1] - d[0][1])
else:
    if len(c) == len(d) == 1:
        print(0)
    else:
        print(e - c[0][1] - d[0][1])


Measured memory_bytes: 19292
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>

typedef long long ll;
const ll INF = 1e18;

ll gcd(ll a, ll b)
{
  while (b != 0) {
    a = a % b;
    std::swap(a, b);
  }
  return a;
}

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

  std::vector< ll > vx(N+1, 0);
  std::cin >> vx[N];
  for (ll i = 0; i < N; i++) {
    std::cin >> vx[i];
  }

  std::sort(vx.begin(), vx.end());
  std::vector< ll >::iterator it;

  ll ans = vx[1] - vx[0];
  for (ll i = 0; i < N; i++) {
    ans = gcd(ans, vx[i+1] - vx[i]);
  }

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


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int dp[3001][3001];
string s, t; int n, m;
P par[3001][3001];
int main() {
	cin >> s >> t; n = s.length(), m = t.length();
	rep(i, n) {
		rep(j, m) {
			int val = dp[i][j];
			if (val >= dp[i + 1][j]) {
				dp[i + 1][j] = val;
				par[i + 1][j] = { i,j };
			}
			if (val >= dp[i][j+1]) {
				dp[i][j+1] = val;
				par[i][j+1] = { i,j };
			}
			if (s[i] == t[j]) {
				val++;
				if (val >= dp[i + 1][j + 1]) {
					dp[i + 1][j + 1] = val;
					par[i + 1][j + 1] = { i,j };
				}
			}
		}
	}
	int ma = 0; P cur; string ans;
	rep(i, n+1) {
		rep(j, m+1) {
			if (ma < dp[i][j]) {
				ma = dp[i][j]; cur = { i,j };
			}
		}
	}
	while (true) {
		if (cur.first<n&&cur.second<m&&s[cur.first]==t[cur.second])ans.push_back(s[cur.first]);
		if (cur == P{0, 0})break;
		cur = par[cur.first][cur.second];
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	//stop
	return 0;
}


Measured memory_bytes: 105856
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

string S; cin >> S;

cout << distance(S.begin(), unique(ALL(S))) - 1 << "\n";
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 592