akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const ll MOD=1e9+7; 
const int MAXN=1e5+5;
int a[MAXN];
bool vis[MAXN];

ll A(int x,int y){
	ll ans=1;
	for(int i=x;i>=(x-y+1);i--){
		ans=(ans*i)%MOD;
	}
	return ans;
} 

ll C(int x,int y){
	ll ans=1;
	for(int i=x,j=1;j<=y;i--,j++){
		ans=(ans*x/y)%MOD;
	}
	return ans;
}

int main()
{
	int dog,monkey;
	cin>>dog>>monkey;
	if(dog>monkey){
		int t=dog;
		dog=monkey;
		monkey=t;
	}
	//dog一定<=monkey
	if(monkey-dog>1){
		cout<<"0"<<endl;
		return 0;
	} 
	//数量相同 
	if(monkey-dog==0){
		ll ans=( A(dog,dog)*A(monkey,monkey) )%MOD;
		cout<<(2*ans)%MOD<<endl;
	}
	//monkey多一个 
	else {
		ll ans=((A(dog,dog)%MOD)*A(monkey,monkey))%MOD;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))

score = sum(P[:K])
mmax = score
idx = 0
for i in range(1, N-K+1):
  score = score - P[i-1] + P[i+K-1]
  if score > mmax:
    mmax = score
    idx = i
  else:
    continue

print((K+mmax)/2)

Measured memory_bytes: 99064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const MAXN = 2e5;
std::vector<int> G[MAXN];
int H[MAXN];

int main() {
  int N, M; std::cin >> N >> M;
  for(int i = 0; i < N; ++i) std::cin >> H[i];
  for(int i = 0; i < M; ++i) {
    int A, B; std::cin >> A >> B; --A; --B;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    bool good = true;
    for(auto c: G[i]) if(H[i] <= H[c]) good = false;
    if(good) ++ans;
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 11464
#include <iostream>
#include <cstdlib>

using namespace std;

void printarray(int n, int q, int a[]){
  for (int i=0; i<n; i++){
    if (i==q){
      cout << '[' << a[i] << ']';
    }
    else{
      cout << a[i];
    }

    if (i!=n-1){
      cout << ' ';
    }
  }
  cout << endl;
}

void swap(int a[], int i, int j){
  int tmp;
  tmp = a[i];
  a[i] = a[j];
  a[j] = tmp;
}

int partition(int a[], int p, int r){
  int x;
  x = a[r];
  int i;
  i = p-1;
  for (int j=p; j<r; j++){
    if (a[j] <= x){
      i = i+1;
      swap(a,i,j);
    }
  }
  swap(a,i+1,r);
  return i+1;
}

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

  int ans;
  ans = partition(a,0,n-1);

  printarray(n,ans,a);

  return 0;
}



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

using namespace std;

int data[110];

void BinaryInsertSort(int i)
{
	int left, mid, right;
	int insert = data[i];
	
	left = 0;
	right = i;
	while (left < right){
		mid = (left + right) / 2;
		if (data[mid] < insert){
			left = mid + 1;
		}
		else {
			right = mid;
		}
	}
	for (int j = left; j <= i; j++){
		swap(insert, data[j]);
	}
}

int main()
{
	int n;
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> data[i];
	}
	for (int i = 0; i < n; i++){
		BinaryInsertSort(i);
		for (int j = 0; j < n - 1; j++){
			cout << data[j] << ' ';
		}
		cout << data[n - 1] << endl;
	}
	
	return (0);
}

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

void printArray(int* array, int length) {
	for (int i = 0; i < length; i++) {
		cout << array[i];
		if (i != length - 1)  cout << " ";
		else cout << endl;
	}
}

void bubbleSort(int* array, int length) {
	int swap = 0;
	for (int i = 0; i < length; i++) {
		for (int j = 0; j < length - 1; j++) {
			if (array[j] > array[j + 1]) {
				int temp = array[j];
				array[j] = array[j + 1];
				array[j + 1] = temp;
				swap++;
			}
		}
	}
	printArray(array, length);
	cout << swap << endl;
}

int main()
{
	int loop;
	int array[100] = {};

	cin >> loop;
	for (int i = 0; i < loop; i++) cin >> array[i];

	bubbleSort(array, loop);

	return 0;
}



Measured memory_bytes: 3088
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    long long N, K; cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        int a; cin >> a; a--;
        A[i] = a;
    }

    vector<bool> visit(N); visit[0] = true;
    int next = A[0];
    int start = 0;
    int before_count = 0;
    while (true) {
        if (!visit[next]) {
            before_count++;
            visit[next] = true;
            next = A[next];
        }
        else {
            before_count++;
            start = next;
            break;
        }
    }

    vector<int> route; route.push_back(start);
    int loop_count = 0;
    next = A[start];
    while (true) {
        if (next != start) {
            loop_count++;
            route.push_back(next);
            next = A[next];
        }
        else {
            loop_count++;;
            break;
        }
    }

    before_count -= loop_count;

    int ans;
    if (K <= before_count) {
        next = 0;
        for (int i = 0; i < K; i++) next = A[next];
        ans = next + 1;
    }
    else {
        ans = route[(K - before_count) % loop_count] + 1;
    }

    // for (auto e : route) {
    //     cout << e << " ";
    // }
    // cout << endl;

    // cout << before_count << " " << loop_count << endl;

    cout << ans << endl;
}


int main() {
    solve();
    return 0;
}

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

using namespace std;

int main()
{
  	int N;
  	cin >> N;
  	vector<int> values(N);
  	for(int i = 0; i < N; ++i) cin >> values[i];
  	sort(values.begin(), values.end());
  	cout << values.back() - values.front() << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
namespace aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            double x = 0,y = 0;
            double deg = 90;
            double[] input;
            while(((input = (from q in Console.ReadLine().Split(',') select double.Parse(q)).ToArray())[0] + input[1]) != 0){
				x += (input[0] * Math.Cos(deg * (Math.PI / 180)));
				y += (input[0] * Math.Sin(deg * (Math.PI / 180)));
				deg = (deg - input[1]) % 360;
            }
			Console.WriteLine("{0}{1}{2}", (int)x, System.Environment.NewLine, (int)y);
        }
    }
}

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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;



int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;
return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
vector<long long> divisor(long long val) {
  vector<long long> res;
  for (long long i = 1; i * i <= val; ++i) {
    if (val % i == 0) {
      res.emplace_back(i);
      if (i * i != val) res.emplace_back(val / i);
    }
  }
  sort(ALL(res));
  return res;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  vector<int> a(n); REP(i, n) cin >> a[i];
  int sum = 0;
  REP(i, n) sum += a[i];
  vector<long long> yakusu = divisor(sum);
  for (int i = yakusu.size() - 1; i >= 0; --i) {
    long long now = yakusu[i];
    vector<int> diff(n);
    long long wa = 0;
    REP(i, n) {
      diff[i] = (a[i] + now - 1) / now * now - a[i];
      wa += diff[i];
    }
    if (wa % now != 0) continue;
    sort(ALL(diff));
    long long cnt = 0;
    REP(i, n - wa / now) cnt += diff[i];
    if (cnt <= k) {
      cout << now << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	vector<int> A(9);
	for (int i = 0; i < 9; i++) cin >> A[i];

	int N;
	cin >> N;
	set<int> B;
	for (int i = 0; i < N; i++) {
		int b;
		cin >> b;
		B.emplace(b);
	}

	auto chk = [&B](auto& a) { return B.find(a) != B.end(); };

	bool ans = false;
	ans |= chk(A[2]) && chk(A[4]) && chk(A[6]);
	ans |= chk(A[0]) && chk(A[4]) && chk(A[8]);
	for (int i = 0; i < 3; i++) {
		ans |= chk(A[i * 3 + 0]) && chk(A[i * 3 + 1]) && chk(A[i * 3 + 2]);
		ans |= chk(A[0 * 3 + i]) && chk(A[1 * 3 + i]) && chk(A[2 * 3 + i]);
	}

	if (ans) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <queue>
#include <tuple>
#include <algorithm>

using namespace std;

int main() {

	int k, x;
	cin >> k >> x;

	if (500 * k >= x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    string s;
    cin >> s;
        
    bool ans = true;

    if(n%2 == 0) {
        string t = s.substr(0, n/2) + s.substr(0, n/2);
        if(s != t) { ans = false; }
    } else {
        ans = false;
    }

    if(ans) {
        cout <<"Yes"<< endl;
    } else {
        cout <<"No"<< endl;
    }
    return 0;
} /*atcoder*/



Measured memory_bytes: 3600
def is_include(n,D):
  for c in str(n):
    for d in D:
      if d == c:
        return True
  else:
    return False

n,k = map(int,input().split())
D = list(map(str,input().split()))
for i in range(n,n*10):  
  if is_include(i,D) == False:
    print(i)
    break              

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define re register
#define pb push_back
#define fi first
#define se second
#define mp make_pair
const int N=2e6+10;
const int mod=998244353;
const int mod2=19260811;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int f[N];
int main()
{
    int n,m,ans=0;
    read(n),read(m);
    for(re int i=1,x;i<=n;i++)
    {
        f[0]++;read(x);
        for(re int j=m;j>=x;j--)
        {
            f[j]+=f[j-x];
            f[j]%=mod;
        }
        ans+=f[m];
        ans%=mod;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
n=int(input())
c=[[0]*10 for _ in range(10)]
ans=0
for i in range(1,n+1):
    c[int(str(i)[0])][int(str(i)[-1])]+=1
for i in range(10):
    for j in range(10):
        ans+=c[i][j]*c[j][i]
print(ans)

Measured memory_bytes: 3060
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        Console.WriteLine(a == b + c | b == c + a | c == a + b ? "Yes" : "No");
    }
}

Measured memory_bytes: 13140
///
// File:  a.cpp
// Author: ymiyamoto
//
// Created on Sun Jan 14 20:53:31 2018
//
#include <bits/stdc++.h>
using namespace std;

#define rep(n, init, N) for (int32_t n = init; n < (int32_t)(N); n++)
#define rrep(n, N) for (int32_t n = (int32_t)(N)-1; n >= 0; n--)

static const double pi = 2 * asin(1);
static const double precision = 10e-9;

int32_t main()
{
  uint32_t N, A, B;
  cin >> N >> A >> B;

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

  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	A, B := sc.NextInt(), sc.NextInt()
	i := 0
	for A <= B {
		i++
		A *= 2
	}
	fmt.Println(i)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <sstream>
#include <cstdio>
using namespace std;
string tostr(int n){
	stringstream ss;
	ss<<n;
	string ret;
	ss>>ret;
	return ret;
}
int main(){
	int n;
	while(cin>>n,n){
		int lunch=0,dinner=0,midnight=0;
		int lc=0,dc=0,mc=0;
		for(int i=0,h,m,mm;i<n;++i){
			scanf("%d:%d %d",&h,&m,&mm);
			int time = (mm-m>0)?mm-m:mm+60-m;
			if(11*60<=h*60+m&&h*60+m<15*60){
				lc++;
				if(time<=8)lunch++;
			}else if(18*60<=h*60+m&&h*60+m<21*60){
				dc++;
				if(time<=8)dinner++;
			}else if((21*60<=h*60+m&&h*60+m<24*60)||(0*60<=h*60+m&&h*60+m<2*60)){
				mc++;
				if(time<=8)midnight++;
			}
		}
		cout<<"lunch "<<((lc!=0)?tostr(lunch*100/lc):"no guest")<<"\n";
		cout<<"dinner "<<((dc!=0)?tostr(dinner*100/dc):"no guest")<<"\n";
		cout<<"midnight "<<((mc!=0)?tostr(midnight*100/mc):"no guest")<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> X(N,K-Q);
  REP(i,Q) {
    int A;
    cin >> A;
    X[A-1]++;
  }
  REP(i,N) {
    if(X[i]>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
#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>
#include <assert.h>
#include <sys/time.h>
#include <fstream>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define REP(i,n)  FOR(i,0,n)
#define each(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define deb(x) cerr << #x << " = " << (x) << " , ";
#define debl cerr << " (L" << __LINE__ << ")"<< endl;
#define sz(s) (int)((s).size())


#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(x,y) make_pair((x),(y))

double pi=3.14159265358979323846;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& z){
	os << "[ ";
	REP(i,z.size())os << z[i] << ", " ;
	return ( os << "]" << endl);
}

template<typename T> std::ostream& operator<<(std::ostream& os, const set<T>& z){
	os << "set( ";
	EACH(p,z)os << (*p) << ", " ;
	return ( os << ")" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const map<T,U>& z){
	os << "{ ";
	EACH(p,z)os << (p->first) << ": " << (p->second) << ", " ;
	return ( os << "}" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const pair<T,U>& z){
	return ( os << "(" << z.first << ", " << z.second << ",)" );
}

double get_time(){
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec + tv.tv_usec*1e-6;
}

typedef unsigned int uint32_t;
struct RND{
	uint32_t x;
	uint32_t y;
	uint32_t z;
	uint32_t w;
	RND(){
		x=123456789;
		y=362436069;
		z=521288629;
		w=88675123;
	}
	void init(int seed){
		x=123456789;
		y=362436069;
		z=521288629;
		w=seed+100;
		REP(i,10)get();
	}
	uint32_t get(){
		uint32_t t;
		t=x^(x<<11);
		x=y;y=z;z=w;
		w=(w^(w>>19))^(t^(t>>8));
		return w;
	}
};
RND rnd;

void _main(istream &inp){
	int n;
	inp >> n;
	vl a(n);
	rep(i,n){
		inp >> a[i];
	}
	sort(a.begin(), a.end());
	ll u = a[n-1];
	ll best_score=1e18;
	ll v;
	rep(k, n){
		ll score = abs(u-2*a[k]);
		if(score<best_score){
			best_score = score;
			v = a[k];
		}
	}
	cout << u << " " << v << endl;

}

int main(){
	if(0){
		ifstream ifs("test.txt");
		_main(ifs);
	}
	else{
		_main(cin);
	}
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int N,M,C;
 int ans=0;
 long long int sum=0;

 cin>>N>>M>>C;

 vector<vector<int>>A(N,vector<int>(M,0));
 vector<int> B(M,0);

 for(int i=0; i<M; i++)cin>>B[i];

 for(int i=0; i<N; i++)
  for(int j=0; j<M; j++)cin>>A[i][j];
 
 for(int i=0; i<N; i++)
  for(int j=0; j<M; j++){
   sum+=(A[i][j]*B[j]);
   if(j==M-1){
    if(sum+C>0)ans++;
    sum=0;
   }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  int ans = -1;
  vector <int> s(m), c(m);
  REP(i, m) {
	cin >> s[i] >> c[i];
  }
  int mi, ma;
  if (n == 1) {
	  mi = 0;
	  ma = 9;
	} else if (n == 2) {
	  mi = 10;
	  ma = 99;
	} else {
	  mi = 100;
	  ma = 999;
	}
  for (int k = mi; k <= ma; k++) {
	  string num = to_string(k);
	  bool flg   = true;
	  REP(i, m) {
		if (num[s[i] - 1] != c[i] + '0') {
			flg = false;
			break;
		  }
	  }
	  if (flg) {
		  ans = k;
		  break;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
import bisect

N = int(input())
cnt_A = Counter(map(int, input().split()))
keys = sorted(cnt_A.keys())
max_keys = max(keys)
flags = {key: True for key in keys}

for key in keys:
    if flags[key] is False:
        continue

    factor = 2
    while key * factor <= max_keys:
        idx = bisect.bisect(keys, key * factor)
        if keys[max(0, idx - 1)] == key * factor:
            del cnt_A[key * factor]
            flags[key * factor] = False
        factor += 1

print(sum([val if val == 1 else 0 for val in cnt_A.values()]))



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

double h[1000];

int main(void) {
	int N;
	double T, A;
	cin >> N;
	cin >> T >> A;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	double x = 1000000;
	int ans;
	for (int i = 0; i < N; i++) {
		if (x > abs(A-(T-h[i]*0.006))) {
			x = abs(A - (T - h[i] * 0.006));
			ans = i + 1;
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;

int main(){

    int n, t;
    cin >> n >> t;

    vector<int> a(n + 1);

    rep(i,n){
        cin >> a[i + 1];
    }

    vector<int> minindex(n + 2);
    vector<int> maxindex(n + 2);

    minindex[1] = 1;

    //問題文中の制約ではn>=1だが
    //1円以上利益を上げられるとのことよりn>=2であることがわかる
    for(int i = 2; i <= n; i++){
        int tmpindex = minindex[i - 1];
        if(a[tmpindex] >= a[i]){
            minindex[i] = i;
        }else{
            minindex[i] = tmpindex;
        }
    }

    maxindex[n] = n;

    for(int i = n; i >= 1; i--){
        int tmpindex = maxindex[i + 1];
        if(a[tmpindex] <= a[i]){
            maxindex[i] = i;
        }else{
            maxindex[i] = tmpindex;
        }
    }

    int diff = 0;

    set<int> buyindex;
    set<int> sellindex;

    for(int i = 1; i <= n; i++){
        if(minindex[i] < maxindex[i]){
            if(diff < a[maxindex[i]] - a[minindex[i]]){
                diff = a[maxindex[i]] - a[minindex[i]];
                buyindex.clear();
                sellindex.clear();
                buyindex.insert(minindex[i]);
                sellindex.insert(maxindex[i]);
            }else if(diff == a[maxindex[i]] - a[minindex[i]]){

                buyindex.insert(minindex[i]);
                sellindex.insert(maxindex[i]);
            }
        }
    }

    cout << min(buyindex.size(), sellindex.size()) << endl;

    
    return 0;
}

Measured memory_bytes: 6144
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int n,m;
bool x[222222];
bool y[222222];
int main(void){
  scanf("%d%d",&n,&m);
  for(int i = 0; i < m; i++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--;b--;
    if(a > b) swap(a,b);
   
    if(a == 0) x[b] = true;
    if(b == n-1) y[a] = true;
  }

  for(int i = 0; i < n; i++){
    if(x[i] && y[i]){
      puts("POSSIBLE");
      return 0;
    }
  }
  puts("IMPOSSIBLE");
}


Measured memory_bytes: 640
(defun decrypt (o e)
  (labels ((inner-loop (now next acc)
	     (if now		 
		 (inner-loop next (cdr now) (cons (car now) acc))
		 (coerce (reverse acc) 'string))))
    (inner-loop (coerce o 'list) (coerce e 'list) nil)))

(let ((o (read-line))
      (e (read-line)))
  (format t "~A~%" (decrypt o e)))

Measured memory_bytes: 6116
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <stack>
using namespace std;

typedef long long ll;
const int qq = 1e5 + 10;
ll diff[qq];
ll num[qq];
ll n;

int main(){
	scanf("%lld", &n);
	ll sum = 0;
	for(int i = 0; i < n; ++i)	scanf("%lld", num + i), sum += num[i];
	for(int i = 0; i < n - 1; ++i)
		diff[i] = num[i + 1] - num[i];
	diff[n - 1] = num[0] - num[n - 1];
	ll k = (1 + n) * n / 2;
	if(sum % k != 0){
		printf("NO\n");
		return 0;
	}
	k = sum / k;
	for(int i = 0; i < n; ++i){
		if(k == diff[i])	continue;
		ll c = k - diff[i];
		if(c < 0 || c % n != 0){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
	cin>> n;
	vi h(n+1, 0);

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

	int dp[n+1];
	dp[0] = 0;
	dp[1] = dp[0] + abs(h[1] - h[0]);

	for(int i = 2; i <n; ++i){
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	}
	cout<< dp[n-1] << endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}


Measured memory_bytes: 4044
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
  ll N;cin>>N;
  if(N%2==0){
    ll c=N/10;
    ll res=c;
    //cout<<"c:"<<c<<endl;
    
    for(int i=1;i<42;i++){
      ll p=10*pow(5,i);
      if(0)if(N%(p)!=0){
	//cout<<p<<"!!!";
	break;
      }
      //cout<<"+:"<<N/p<<endl;
      res+=N/(p);
    }
    cout<<res;
  }
  else{
    cout<<0;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	int cnt = 0;
	while(true) {
		bool odd = false;
		rep(i, N) {
			if((A[i] & 1)==1) odd = true; 
		}

		if(!odd) {
			cnt++;
			rep(i, N) A[i] >>= 1;
			//cout << "cnt:" << cnt << endl;
		} else {
			break;
		}
	}

	cout << cnt << endl;

	return 0;
}



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

int main() {
	int n , W;
	cin >> n >> W;
	long long  v[n];
	long long w[n];
	for(int i = 0 ; i < n  ; i++){
		cin >> w[i] >> v[i];
	}
	long long dp[n+1][W+1];
	for(int i = 0 ; i < W+1 ; i++){
		dp[0][i] =  0;
	}
	for(int i = 1 ; i <= n ; i++){
		for(int j = 0 ; j < W+1 ; j++){
			if(j < w[i-1]){
				dp[i][j] = dp[i-1][j];
			}else{
				dp[i][j] = max(dp[i-1][j] , dp[i-1][j - w[i-1]] + v[i-1]);
			}
		}	
	}
	cout << dp[n][W];
	return 0;
}

Measured memory_bytes: 79104
n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
ans = [True for _ in range(n+1)]
for _ in range(m):
  a, b = map(int, input().split())
  if h[a] > h[b]:
    ans[b] = False
  elif h[a] < h[b]:
    ans[a] = False
  else:
    ans[a] = False
    ans[b] = False
print(len(list(filter(lambda x:x,ans[1:]))))

Measured memory_bytes: 19956
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int n;
  while(cin >> n) {
    int h[n];
    inputs(h, n);
    int mx = 0;
    int ans = 0;
    REP(i, n) {
      if (mx <= h[i])ans++;
      chmax(mx, h[i]);
    }
    cout << ans << endl;
  }
}


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

int main(){
    int N,K,i;
    long int sum=0;
    cin >> N >> K;
    int A[N];
  
    for(i=0;i<N;i++) cin >> A[i];
	
  	if(N <= K) cout << '0' << endl;
    else{
      sort(A, A + N);
      
      for(i=0;i<N-K;i++) sum = sum + A[i];
      cout << sum << endl; 
    }
}

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

int a,b,c,d;
ll dp[3005][3005];

int main(void){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	dp[a][b]=1;
	for(int i=a;i<=c;i++){
		for(int j=b;j<=d;j++){
			dp[i][j]+=(ll)dp[i-1][j]*j%MOD;
			dp[i][j]+=(ll)dp[i][j-1]*i%MOD;
			ll val=dp[i-1][j-1]*(i-1)*(j-1)%MOD;
			dp[i][j]+=(MOD-val);
			dp[i][j]%=MOD;
		}
	}
	printf("%lld\n",dp[c][d]);
	return 0;
}


Measured memory_bytes: 74152
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int n,a[maxn],b[maxn];
long long ans;

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n+1;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    for(int i=n;i>=1;i--){
        if(b[i]>=a[i+1]){
            b[i]-=a[i+1];
            ans+=a[i+1];
            a[i+1]=0;
        }
        else{
            ans+=b[i];
            a[i+1]-=b[i];
            b[i]=0;
        }
        if(b[i]>=a[i]){
            b[i]-=a[i];
            ans+=a[i];
            a[i]=0;
        }
        else{
            ans+=b[i];
            a[i]-=b[i];
            b[i]=0;
        }
    }
    cout<<ans<<endl;
}
/*
    Good Luck
        -Lci70121
*/


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

int main(){
    string n;
    bool flag = false;
    cin >> n;
    for(int i = 0; i < 3; i++){
        if(n[i] == '7'){
            flag = true;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

const int MAXN = 101;
int arr[MAXN];
int n, ans;

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

	cin >> n;

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

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

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, MOD = 1e9 + 7;

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

void debug() {
	debug();
}

string ans;

int main()
{
	fastInp;

	ll n;
	cin >> n;

	srand(rng());

	ans.resize(2 * n);
	vector<ll> ord;
	ord.resize(n + 1);
	for (int i = 0; i <= n; i++) ord[i] = -1;
	cout << "? ";
	for (int j = 0; j < n; j++) cout << j + 1 << " ";
	cout << endl;
	string q;
	cin >> q;

	ord[0] = q[0] == 'R';
	ll l = 0, r = n + 1;
	while (r - l > 1) {
		ll mid = (l + r) / 2;

		cout << "? ";
		for (int i = 0; i < n; i++) {
			cout << i + mid + 1 << " ";
		}
		cout << endl;
		string s;
		cin >> s;

		ord[mid] = (s[0] == 'R');
		if (q != s) {
			r = mid;
		}
		else {
			l = mid;
		}
	}


	for (int i = 1; i < ord.size(); i++) {
		if (ord[i] != ord[i - 1] && ord[i] != -1 && ord[i - 1] != -1) {
			if (ord[i] == 0) {
				ans[i - 1] = 'R';
				ans[i + n - 1] = 'B';
				for (int t = 0; t < n * 2; t++) {
					if (t < i - 1 || t > i + n - 1) {
						cout << "? ";
						for (int j = 0; j < n - 1; j++) {
							cout << j + i + 1 << " ";
						}
						cout << t + 1;
						cout << endl;
						string s;
						cin >> s;
						/*if (s == "-1") {
							debug();
						}*/
						if (s[0] == 'B') {
							ans[t] = 'B';
						}
						else {
							ans[t] = 'R';
						}
					}
				}
			}
			else {
				ans[i + n - 1] = 'R';
				ans[i - 1] = 'B';
				for (int t = 0; t < n * 2; t++) {
					if (t < i - 1 || t > i + n - 1) {
						cout << "? ";
						for (int j = 0; j < n - 1; j++) {
							cout << j + i + 1 << " ";
						}
						cout << t + 1;
						cout << endl;
						string s;
						cin >> s;
						/*if (s == "-1") {
							debug();
						}*/
						if (s[0] == 'B') {
							ans[t] = 'B';
						}
						else {
							ans[t] = 'R';
						}
					}
				}

			}

			vector<ll> pos[2];
			for (int i = 0; i < n * 2; i++) {
				if (ans[i] == 'R') {
					pos[0].push_back(i);
				}
				if (ans[i] == 'B') {
					pos[1].push_back(i);
				}
			}

			for (int i = 0; i < n * 2; i++) {
				if (ans[i] != 'R' && ans[i] != 'B') {
					ll cnt = n / 2;
					cout << "? ";
					for (int j = 0; j < cnt; j++) {
						cout << pos[0][j] + 1 << " ";
					}
					for (int j = 0; j < cnt; j++) {
						cout << pos[1][j] + 1 << " ";
					}
					cout << i + 1;
					cout << endl;
					string s;
					cin >> s;

					if (s[0] == 'R') {
						ans[i] = 'R';
					}
					else {
						ans[i] = 'B';
					}
				}
			}

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

	return 0;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,m;
  cin>>n>>m;
  m/=1000;
  int x,y,z;
  z=m%5;
  y=(m-z)/5;
  rep(i,(y+1)){
    // 1000 = z+(i*5),5000=y-i;
    rep(j,(y-i+2)/2){
      // 5000 = y-i -(j*2),10000=j
      if(z+(i*5)+y-i-(j*2)+j == n){
	cout<<j<<" "<<y-i-(j*2)<<" "<<z+(i*5)<<endl;
	return 0;
      }
    }
  }
    
  cout<<-1<<" "<<-1<<" "<<-1<<endl;   
      
  

  return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;



int main() {
    int n,m;
    cin>>n>>m;
    vector<int>L(m);vector<int>R(m);
    
    for(int i=0;i<m;i++){
        cin>>L.at(i)>>R.at(i);
    }
    
    int L_max=*max_element(L.begin(), L.end());
    int R_min=*min_element(R.begin(), R.end());
    
    if(R_min-L_max+1>=0){
        cout<<R_min-L_max+1<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
def p_d():
    N, W = map(int, input().split())
    dp = [[0] * (W + 1) for _ in range(N + 1)]

    for i in range(1, N + 1):
        w, v = map(int, input().split())
        for j in range(1, W + 1):
            if j - w >= 0:
                dp[i][j] = max(v + dp[i - 1][j - w], dp[i - 1][j])
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j])

    print(max(dp[N]))


if __name__ == '__main__':
    p_d()


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

int main(){
  int n,d[102],at=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d,d+n);
  for(int i=0;i<n-1;i++){
    if(d[i]<d[i+1]){
      at++;
    }
  }
  cout<<at+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> x(n);
  rep(i,n) cin >> x.at(i) ;
  int ans = 0;
  rep(i,n) ans += 2*min(x.at(i),k-x.at(i));
  cout << ans << endl;
  return 0;
}



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

int main(){

    int A,B;
    cin >> A >> B;

    int B_origin = B * 10;
    int A_origin = -1;

    for(int i = 0; i < 10; i++){
        if((int)((B_origin + i) * 0.08) == A){ // 0.08書けるからdouble型になっちゃう
            A_origin = B_origin + i;
            break;
        }
    }

    cout << A_origin << endl;

}

Measured memory_bytes: 256
result = []
while true
    n = gets.to_i
    break if n == 0
    arr = []
    n.times{|i|
        line = gets.chomp.split
        arr << [line[0], line[1].to_i * 3 + line[3].to_i, i]
    }
    arr2 = []
    arr.sort_by{|item| [-item[1], item[2]]}.each{|name, point, index|  arr2 << sprintf("%s,%d", name, point)}
    result << arr2
end

result.each_with_index{|arr, i|
    puts arr
    puts if i != result.length - 1
}


Measured memory_bytes: 6892
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <math.h>
#include <vector>
#include <cstdio>
using namespace std;
 
int main()
{
    int k, n;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int min = 2147483647;
    for (int i = 0; i < n - k + 1; ++i) {
        if (min > (a[i + k - 1] - a[i])){
            min = a[i + k - 1] - a[i];
        }
    }
    cout << min;
}

Measured memory_bytes: 640
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

def minute(p):
    p[5] += min(E,p[4])
    p[4] = max(0,p[4]-E)
    p[4] += min(D,p[3])
    p[3] = max(0,p[3]-D)
    p[3] += min(C,p[2])
    p[2] = max(0,p[2]-C)
    p[2] += min(B,p[1]) 
    p[1] = max(0,p[1]-B)
    p[1] += min(A,p[0])
    p[0] = max(0,p[0]-A)
    return p
    
p = [N,0,0,0,0,0]
for i in range(100):
    p = minute(p)
    if p[-1] == N:
        print(i+1)
        break
if p[-1] != N:
    r = p[-1]
    r_ = minute(p)[-1]
    x = r_-r
    from math import ceil
    print(100+ceil((N-r)/x))

Measured memory_bytes: 38512
import sys
input = sys.stdin.readline

MOD = 1000000007

def comb_mod(n, r, mod):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fac.append(fac[-1] * i % mod)
            inv.append(-inv[mod % i] * (mod // i) % mod)
            finv.append((finv[-1] * inv[-1]) % mod)

        return int(fac[n] * finv[r] * finv[n - r] % mod)

x, y = map(int, input().split())
m = int((x * 2 - y) / 3)
n = int(x - 2 * m)

if (x + y) % 3 != 0:
    print(0)
else:
    print(comb_mod(n + m, n, MOD))


Measured memory_bytes: 82476
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/

bool check() {
	LOAD(int, N);
	LOADVEC(int, a, N);
	int minA = INF;
	int maxA = -INF;
	for (int i = 0; i < N; ++i) {
		minA = std::min({ minA ,a[i] });
		maxA = std::max({ maxA ,a[i] });

	}
	if (maxA - minA >= 2) {
		return false;
	}
	int n = maxA;
	if (maxA == minA) {
		return n <= N / 2 || n == N - 1;
	}
	int x = 0;
	for (int i = 0; i < N; ++i) {
		if (a[i] == minA)++x;
	}
	if (x == N - 1)return false;
	if (x + 2 * (n - x) <= N && 2 * n - x <= N && n - x > 0)return true;
	return false;
}

void proc() {
	if (check()) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


#endif


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



int main() {
  ll n,k;
  cin >> n >> k ;
  string s;
  cin >> s;
  // vector<ll> a(n,0);
  // cin >> a;

  ll ans = 0;
  // for (int i = 0; i < n; i++) {
      
  // }


  s[k-1] = s[k-1] - 'A' + 'a';



  cout << s <<endl;


  // cout << (true? "Yes":"No");

  // cout << ans << endl;

}







Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
using namespace std;
#define ll long long
int main(){
	ll A,B;
    cin >> A >> B;
    ll ans=1;
    ll tmp=B;
    while(tmp<=A){
        tmp*=B;
        ans++;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
let _ =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let is_triangle (x, y, z) =
    if x >= y && x >= z then
      if x * x = y * y + z * z then "YES" else "NO"
    else
      if y >= x && y >= z then
        if y * y = x * x + z * z then "YES" else "NO"
      else
        if z * z = x * x + y * y then "YES" else "NO" in
  for i = 1 to n do
    let a, b, c = Scanf.scanf "%d %d %d\n" (fun x y z -> (x,y,z)) in
    print_endline @@ is_triangle (a, b, c)
  done

Measured memory_bytes: 2912
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n,k;cin>>n>>k;
	int a[200000]={0};
	for(int i=0;i<n;i++)
	{
		int m;cin>>m;
		a[m]++;
	}
	sort(&a[0],&a[200000]);
	int cnt=0;
	for(int i=200000-1;a[i]!=0;i--,cnt++);
	int s=0;
	for(int i=200000-1-cnt;i<=200000-1-k;i++)
	{
		s+=a[i];
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1024