akhauriyash/Code-Regression huggingface dataset:
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::collections::VecDeque;

fn main() {
    let (N, M) = get!(usize, usize);
    let (u, v): (Vec<_>, Vec<_>) = get!(usize, usize; M).into_iter().unzip();
    let (S, T) = get!(usize, usize);

    // 何歩目かを含めた状態グラフを作成し、BFSにより解を求める
    let mut G = vec!(vec!(); 3 * N + 1);
    for (x, y) in u.into_iter().zip(v.into_iter()) {
        G[x].push((y + N, 0));
        G[x + N].push((y + 2 * N, 0));
        G[x + 2 * N].push((y, 1));
    }
    let mut q = VecDeque::new();
    let mut dp = vec!(-1; 3 * N + 1);
    q.push_back(S);
    dp[S] = 0;
    while !q.is_empty() {
        let i = q.pop_front().unwrap();
        for (x, w) in G[i].clone() {
            if dp[x] == -1 {
                q.push_back(x);
                dp[x] = dp[i] + w;
            }
        }
    }
    let ans = dp[T];

    println!("{}", ans);
}


Measured memory_bytes: 35036
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }


int main()
{
    int n,x,ma=0;
    cin>>n;
    int a[100000]={0};
    rep(i,n){
        cin>>x;
        a[x]++,a[x+1]++,a[x+2]++;
    }
    rep(i,100000)ma=max(a[i],ma);
    cout<<ma<<endl;

    return 0;
}


Measured memory_bytes: 640
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	N, X := getInt(), getInt()
	x := make([]int, N)
	for i := 0; i < N; i++ {
		x[i] = getInt()
	}
	x = append(x, X)
	sort.Ints(x)
	d := x[1] - x[0]
	for i := 0; i < N; i++ {
		d = GCD(d, x[i+1]-x[i])
	}
	// out(x)
	out(d)
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    int N,x=0,ans=0;
    string S;
    cin>>N>>S;

    for(int i=0;i<N;i++){
        if(S[i]=='I'){
            x++;
        }else{
            x--;
        }
        ans=max(ans,x);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b){
        cout << c << endl;
    }else if(a==c){
        cout << b << endl;
    }else if(b==c){
        cout << a << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
///The greatest enemy of knowledge is not ignorance, it is illusion of knowledge

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


#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue

#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define fbo find_by_order
#define ook order_of_key
#define MP make_pair
#define UB upper_bound
#define LB lower_bound

#define F first
#define S second
#define mem(a,x) memset(a,x,sizeof(a))
#define inf 1e18
#define PI (acos(-1.0))
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r,n) (int)(log2(n)/log2(r))
#define pf printf
#define sf scanf
#define _ccase printf("Case %lld: ",++cs)
#define _case cout<<"Case "<<++cs<<": "
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }

#define asche cerr<<"Ekhane asche\n";
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define all(v) v.begin(),v.end()
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define toint(a) atoi(a.c_str())
#define fast ios_base::sync_with_stdio(false)
#define valid(tx,ty) (tx>=0&&tx<n&&ty>=0&&ty<m)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define stree ll l=(n<<1),r=l+1,mid=b+(e-b)/2
#define fout(x) fixed<<setprecision(x)

#define SQ(x) ((x)*(x))
#define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define AMR std::ios::sync_with_stdio(false);cin.tie(NULL);
int dp[100009][4], arr[100009][4] ,n;
int call(int pos, int nise)
{
    if(pos>n) return 0;
    int &ret=dp[pos][nise];
    if(ret!=-1) return ret;
    ret=0;
    for(int i=1; i<=3; i++){
        if(nise!=i)ret=max(ret, arr[pos][i]+call(pos+1, i));
    }
    return ret;


}


int main(){
AMR;
cin>>n;
for(int i=1; i<=n; i++)
    for(int j=1; j<=3; j++)
        cin>>arr[i][j];

memset(dp, -1, sizeof dp);

ll ans=call(1,0);
cout<<ans<<endl;
}






















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

int main()
{
	string s, p[2]; int r = 0;
	cin >> s;

	int n; cin >> n; while (n--){
		int o; cin >> o;
		if (o == 1) r = !r;
		else{
			int f; string c; cin >> f >> c;
			p[(r + f) % 2] += c;
		}
	}

	reverse(p[1].begin(), p[1].end());
	s = p[1] + s + p[0];
	if (r) reverse(s.begin(), s.end());
	cout << s << endl;

	return 0;
}



Measured memory_bytes: 1348
#include<stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d\n", &a, &b);
	if(a<b)
	{
		printf("a < b\n");
	}
	else
	{
		if(a>b)
		{
			printf("a > b\n");
		}
		else{
			printf("a == b\n");
		}
	}
	
	return 0;
}


Measured memory_bytes: 2052
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N,M; cin >> N>>M;
	vector<vector<int>> x(N);
	vector<pair<int, int>> y(M);
	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		x[a].push_back(b);
		x[b].push_back(a);
		y[i] = { a,b };

	}
	int ans = 0;
	for (int i = 0; i < M; i++) {
		vector<bool> k(N,0);
		queue<int> z;
		z.push(0);
		while (z.size() != 0) {
			int l = z.front();
			k[l] = 1;
			z.pop();
			for (int j = 0; j < x[l].size(); j++) {
				if (l == y[i].first&&x[l][j] == y[i].second)continue;
				if (l == y[i].second&&x[l][j] == y[i].first)continue;
				if (k[x[l][j]] == true)continue;
				z.push(x[l][j]);
			}
		}
		for (int j = 0; j < N; j++) {
			if (k[j] == false) {
				ans++; break;
			}
		}
	}
	cout << ans << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;


template<typename T, const T&(*f)(const T&, const T&) = std::min<T> >
struct rmq {
	vector<T> t;
	size_t d;
	
	rmq(size_t sz = 0, const T &val = T()): t(sz*2,val), d(sz) {}
	rmq(const vector<T> &vals){
		d = size(vals);
		t.resize(d*2);
		copy(begin(vals), end(vals), begin(t)+d);
		for(int i=d-1;i>0;--i) t[i] = f(t[i*2], t[i*2+1]);
	}
	
	void set_value(size_t i, const T& val){
		for(t[i+=d]=val; i>1; i>>=1) t[i>>1] = f(t[i], t[i^1]);
	}
	
	void update(size_t i, const T& val){
		set_value(i, f(t[i+d],val));
	}
	
	T operator()(size_t l, size_t r){
		T res = t[l+=d];
		for(++l,r+=d; l<r; l>>=1,r>>=1){
			if(l&1) res = f(res, t[l]), ++l;
			if(r&1) --r, res = f(res, t[r]);
		}
		return res;
	}
	
	T operator()(){ return t[1]; }
};

int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	
	vector<ll> x(n), y(n);
	for(int i=0;i<n;++i) cin>>x[i]>>y[i];
	
	ll ans = -9e18;
	
	for(int it=0;it<4;++it){
		
		vector<int> p(n); iota(ALL(p),0);
		sort(ALL(p), [&](int i, int j){return pair(y[i],x[i]) < pair(y[j],x[j]);});
		
		vector<ll> xs;
		for(int i=0;i<n;++i) xs.push_back(x[i]);
		sort(ALL(xs));
		
		rmq<ll,min> q(n,9e18);
		
		for(int i : p){
			//cout<<"?"<<i<<": "<<x[i]<<' '<<y[i]<<endl;
			int k = lower_bound(ALL(xs), x[i]) - begin(xs);
			ll s = q(0,k+1);
			ans = max(ans, x[i]+y[i] - s);
			q.update(k,x[i]+y[i]);
		}
		
		
		for(int i=0;i<n;++i){
			ll tx = x[i], ty = y[i];
			
			x[i] = ty;
			y[i] = -tx;
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 13988
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

std::string ReplaceString
(
      std::string String1   // 置き換え対象
    , std::string String2   // 検索対象
    , std::string String3   // 置き換える内容
)
{
    std::string::size_type  Pos( String1.find( String2 ) );
 
    while( Pos != std::string::npos )
    {
        String1.replace( Pos, String2.length(), String3 );
        Pos = String1.find( String2, Pos + String3.length() );
    }
 
    return String1;
}

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

    vector<string> v;
    int lim = S.size() - T.size() + 1;

    rep(i,lim){
        string tmp = "";
        rep(j,T.size()){
            if(S[i+j] == T[j] || S[i+j] == '?'){
                if(j == T.size()-1){
                    for(int k = 0;k < i;k++){
                        tmp.push_back(S[k]);
                    }
                    tmp += T;
                    for(int k = i+T.size();k < S.size();k++){
                        tmp.push_back(S[k]);
                    }
                    tmp = ReplaceString(tmp,"?","a");
                    v.push_back(tmp);
                }
                continue;
            }
            else break;
        }
    }

    sort(all(v));
    if(v.size() != 0){
        cout << v[0] << endl;
    }
    else{
        cout << "UNRESTORABLE" << endl;
    }

}


Measured memory_bytes: 256
s=str(input())
def judge(s):
  l=len(s)
  if l%2==1:
    for i in range((l-1)//2):
      if s[i]==s[-i-1]:
        pass
      else:
        return 0
    return 1
  else:
    for i in range(l//2):
      if s[i]==s[-i-1]:
        pass
      else:
        return 0
    return 1
L=len(s)
if judge(s)==1 and judge(s[0:(L-1)//2])==1 and judge(s[(L+3)//2-1:])==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  
  char A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  a = (int)(A - '0');
  b = (int)(B - '0');
  c = (int)(C - '0');
  d = (int)(D - '0');
  
  int result;
  char op1, op2, op3;

  // 3ビットのビット列をすべて列挙する
  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> s(tmp);
    result = a;
    if (s.test(0)) {
      result += b;
      op1 = '+';
    }
    else {
      result -= b;
      op1 = '-';
    }
    if (s.test(1)) {
      result += c;
      op2 = '+';
    }
    else {
      result -= c;
      op2 = '-';
    }
    if (s.test(2)) {
      result += d;
      op3 = '+';
    }
    else {
      result -= d;
      op3 = '-';
    }
    if (result == 7) {
      cout << a << op1 << b << op2 << c << op3 << d << "=7" <<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n)cin >> p[i];
    SORT(p);
    if(p[n/2] == p[n/2-1])cout << 0 << endl;
    else cout << p[n/2] - p[n/2-1] << endl;



    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc132.contest.atcoder.jp/tasks/abc132_b

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

int main(){
  int N,M,k,su;
  cin>>N>>M;
  
  vector<vector<int>> data(N, vector<int>(M,0));
  
  for(int i=0;i<N;i++){
    cin>>k;
    for(int j=0;j<k;j++){
      cin>>su;
      data[i][su-1]=1;
    }
  }
  
  
  int sz=0;//合計
  int flg=0;
  for(int i=0;i<M;i++){
    flg=0;
    for(int j=0;j<N;j++){
      if (data[j][i]==0){
        flg=1;
        break;
      }
    }
    if (flg==0)
      sz++;
    
  }
  
  cout<<sz<<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<57;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

string s,t;

int main(){
	cin>>s>>t;
	int S=s.size(),T=t.size();
	string res="LESS";
	if(s==t) res="EQUAL";
	if(S>T||S==T&&s>t) res="GREATER";
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

bool isPrime[1000010];
void set_prime() {
	for (int i = 1; i <= 1000000; i++) {
		isPrime[i] = true;
	}
	isPrime[0] = false; isPrime[1] = false;
	for (int i = 2; i * i <= 1000000; i++) {
		int j = 2;
		while (i * j <= 1000000) {
			isPrime[i * j] = false;
			j++;
		}
	}
}

int main()
{
	int X;
	cin >> X;
	set_prime();
	while (true) {
		if (isPrime[X]) {
			cout << X << endl;
			return 0;
		}
		X++;
	}
}


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

n = int(input())
A = list(map(int,input().split()))

ans = -float("inf")
if n % 2 == 0:
    D = [[0,0] for i in range(n//2)]
    D[0][0] = A[0]
    D[0][1] = A[1]
    for i in range(1, n//2):
        D[i][0] = D[i-1][0] + A[i*2]
        D[i][1] = max(D[i-1][0],D[i-1][1]) + A[i*2+1]
    print(max(D[-1]))

else:

    

    D = [[0,0] for i in range(n//2)]
    D[0][0] = A[0]
    D[0][1] = A[1]
    for i in range(1, n//2):
        D[i][0] = D[i-1][0] + A[i*2]
        D[i][1] = max(D[i-1][0],D[i-1][1]) + A[i*2+1]


    S = [0] * n
    S[0] = A[0]
    S[1] = A[1]
    for i in range(2, n):
        S[i] = A[i] + S[i-2]

    # print(S)
    

    for i in range(0, n, 2):
        le = max(D[i//2-1]) if i>0 else 0
        ri = S[-1] - S[i]
        # print(i,le,ri, le+ri)
        ans = max(ans, le+ri)

    A = A[::-1]

    D = [[0,0] for i in range(n//2)]
    D[0][0] = A[0]
    D[0][1] = A[1]
    for i in range(1, n//2):
        D[i][0] = D[i-1][0] + A[i*2]
        D[i][1] = max(D[i-1][0],D[i-1][1]) + A[i*2+1]
    # print(D[-1])

    S = [0] * n
    S[0] = A[0]
    S[1] = A[1]
    for i in range(2, n):
        S[i] = A[i] + S[i-2]
    

    for i in range(0, n, 2):
        le = max(D[i//2-1]) if i>0 else 0
        ri = S[-1] - S[i]
        # print(i,le,ri, le+ri)
        ans = max(ans, le+ri)

    print(ans)

Measured memory_bytes: 111932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int gcd = (int) gcd(n,m);
		long lcm = n / gcd(n,m) * m;
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		for(int i=0;i<gcd;i++) {
			if (s[n/gcd*i] != t[m/gcd*i]) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(lcm);
	}
	public static long gcd(long a,long b) {
		while(b!=0) {
			long r = a%b;
			a = b;
			b = r;
		}
		return a;
	}
}


Measured memory_bytes: 28696
<?php
fscanf(STDIN, "%d %d %d %d", $R, $G, $B, $N);
$ans = 0;
for ($r = 0; $r <= intdiv($N, $R); $r++) {
    $x = $N - $R * $r;
    for ($g = 0; $g <= intdiv($x, $G); $g++) {
        if (($x - $G * $g) % $B === 0) {
            $ans++;
        }
    }
}
echo $ans;


Measured memory_bytes: 4728
#include <stdio.h>
 
int main(void)
{
    int n, m, l, i, j, k;
    int a[100][100] = { 0 }, b[100][100] = { 0 };
    long int c;
 
    scanf("%d %d %d", &n, &m, &l);
 
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
            scanf("%d", &a[i][j]);
 
    for (i = 0; i < m; i++)
        for (j = 0; j < l; j++)
            scanf("%d", &b[i][j]);
 
    for (i = 0; i < n; i++)
        for (j = 0; j < l; j++) {
            c = 0;
            for (k = 0; k < m; k++) 
                c += a[i][k] * b[k][j];
 
            printf("%ld%s", c, j == l - 1 ? "\n" : " ");
        }
 
 
    return 0;
}

Measured memory_bytes: 684
#include<bits/stdc++.h>
using namespace std ;
 
#define int long long


#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()

#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846//20 decimals
#define MOD 1000000007

 
int32_t main(){

   
     IOS
     int a,b,c,k,ans=0;
     cin>>a>>b>>c>>k;
     if(a>k)
        {
            ans=k;
            k=0;
        }
    else
    {
        ans=a;
        k=k-a;
    }
    k=k-b;
    if(k>0)ans=ans-k;
    cout<<ans;
    

return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 120
#define eps 1e-8
using namespace std;

int dlcmp(double x) {return x<-eps?-1:x>eps;}

double p[N],speed[N],rest[N][N],sum[N][N];
double time[N];
int n,m;
double l;

void calc(double p,double s[])
{
	int i,j;

	memset(rest,0,sizeof(rest));
	rest[0][0]=1;
	for (i=1;i<=m;i++)
		for (j=0;j<=i;j++)
		{
			rest[i][j]+=rest[i-1][j]*(1-p);
			if (j-1>=0)
				rest[i][j]+=rest[i-1][j-1]*p;
		}


	for (i=m;i>=0;i--)
		s[i]=s[i+1]+rest[m][i];
}

int main()
{
	int i,j,k;
	double ans,curT;

	while (scanf("%d%d%lf",&n,&m,&l)!=EOF)
	{
		memset(sum,0,sizeof(sum));
		for (i=1;i<=n;i++)
		{
			scanf("%lf%lf%lf",&p[i],&time[i],&speed[i]);
			p[i]/=100;

			calc(p[i],sum[i]);
		}

		/*
		for (i=1;i<=n;i++,printf("\n"))
			for (j=0;j<=m;j++)
				printf("%.3f ",sum[i][j]);
		*/

		for (i=1;i<=n;i++)
		{
			ans=0;
			for (j=0;j<=m;j++)
			{
				curT=l/speed[i]+time[i]*j;
				double tmp=sum[i][j]-sum[i][j+1];
				int flag=1;

				for (k=1;k<=n;k++)
					if (k!=i)
					{
						double r=curT-l/speed[k];

						int idx=r/time[k];
						idx=max(0,idx);
						while (dlcmp(idx*time[k]-r)<=0&&idx<=m)	idx++;

						if (idx>m)
						{
							flag=0;
							break;
						}

						tmp*=sum[k][idx];
					}

				if (flag)
					ans+=tmp;
			}

			printf("%.8f\n",ans);
		}
	}

	return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	int stx, sty, edx, edy;
	cin >> sty >> stx >> edy >> edx;
	--sty; --stx; --edy; --edx;
	vector<string> maps(H);
	REP(i, H) cin >> maps[i];
	
	vector<vector<int>> d[4], done[4]; // 直前の移動方向
	REP(i, 4) {
		d[i] = vector<vector<int>>(H, vector<int>(W, INF));
		done[i] = vector<vector<int>>(H, vector<int>(W, 0));
	}
	
	struct Data {
		int y, x, pdir, res;
	};
	
	int dx[] = {1,0,-1,0}, dy[] = {0,-1,0,1};
	
	deque<Data> deq;
	REP(dir, 4) {
		d[dir][sty][stx] = 0;
		deq.push_back(Data{sty, stx, dir, 0});
	}
	
	auto ok = [&](int y, int x) {
		return y >= 0 && y < H && x >= 0 && x < W && maps[y][x] == '.';
	};
	
	while (!deq.empty()) {
		Data cur = deq.front(); deq.pop_front();
		if (!chmax(done[cur.pdir][cur.y][cur.x], 1)) continue;
		
		REP(dir, 4) {
			int ny = cur.y + dy[dir], nx = cur.x + dx[dir];
			if (!ok(ny, nx)) continue;
			
			if (dir != cur.pdir || cur.res == 0) {
				// コストが発生
				if (chmin(d[dir][ny][nx], d[cur.pdir][cur.y][cur.x] + 1)) {
					deq.push_back(Data{ny, nx, dir, K - 1});
				}
			}
			else {
				if (chmin(d[dir][ny][nx], d[cur.pdir][cur.y][cur.x])) {
					deq.push_front(Data{ny, nx, dir, cur.res - 1});
				}
			}
		}
	}
	
	int ans = INF;
	REP(dir, 4) chmin(ans, d[dir][edy][edx]);
	if (ans == INF) puts("-1");
	else cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 40120
import java.io.*;
class Main {
  public static void main (String[] args) throws Exception {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s;
    while(null != (s = in.readLine()))
      calc(Double.parseDouble(s));
  }
  private static void calc(double a){
    double sum = 0;
    for(int i=0;i<10;i++){
      sum+=a;
      a=((i&1)==0)?a*2.0:a/3.0;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 16920
#include <iostream>

#define maxn 1005
using namespace std;

int a[maxn],sum;

int main()
{
	for(int i=1;i<=3;i++)
		cin>>a[i];
	a[4]=a[1];
	for(int i=1;i<=3;i++)
		if(a[i]==a[i+1]) sum++;
	if(sum==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var count int
	for i := 1; i <= n; i++ {
		var p int
		fmt.Scan(&p)
		if p != i {
			count++
		}
		if count > 2 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 512
/*input

*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  int a, b;
  cin >> a >> b;
  int ans = 1;
  int cnt = 0;
  while(ans < b) {
    ans --;
    ans += a;
    cnt ++;
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int x;
   string s;
   cin>>x>>s;
   for(int i=0;i<s.size();i++){
    s[i]+=x;
    if(s[i]>'Z'){
    s[i]%='Z';
    s[i]+='A'-1;
   }}
   cout<<s;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N, kazu, K;
int A[18], B[18], onaji[18], MAB[18];
unsigned char dp[36][1 << 18];
int keisan(int b, bool n, int k) {
	if (dp[k][b] != 255) return dp[k][b];
	if (b == (1 << N) - 1) return 0;

	int saishou = 254;
	int num2 = 0;
	int used = 0;
	auto a = n ? B : A;

	rep(i, N) {
		if (!(b >> i & 1)) {
			if (MAB[i] < k) return dp[k][b] = 254;
			if (!(used >> onaji[i] & 1) && a[i] >= k) {
				chmin(saishou, keisan(b ^ (1 << i), !n, a[i]) + num2);
				used ^= 1 << onaji[i];
			}
			num2++;
		}
	}
	return dp[k][b] = saishou;
}

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


	scanf("%d", &N);
	rep(i, N) {
		if (i & 1) scanf("%d", B + i);
		else scanf("%d", A + i);
	}
	rep(i, N) {
		if (i & 1) scanf("%d", A + i);
		else scanf("%d", B + i);
	}
	rep(i, N) MAB[i] = max(A[i], B[i]);

	rep(i, N) {
		int atta = -1;
		rep(j, i) {
			if (A[i] == A[j] && B[i] == B[j]) {
				atta = j;
				break;
			}
		}
		if (atta != -1) onaji[i] = onaji[atta];
		else onaji[i] = kazu++;
	}

	pair<int, int> kari[36];
	rep(i, N) kari[i] = mp(A[i], i);
	rep(i, N) kari[i + N] = mp(B[i], i + N);
	sort(kari, kari + N * 2);
	int mae = kari[0].first;
	rep(i, N * 2) {
		if (mae != kari[i].first) K++;
		mae = kari[i].first;
		if (kari[i].second < N) A[kari[i].second] = K;
		else B[kari[i].second - N] = K;
	}
	memset(dp[0], 255, (K + 1) * (1 << 18));

	int kotae = keisan(0, 0, 0);
	if (kotae == 254) printf("-1\n");
	else printf("%d\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 8320
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int ans = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if ((i + 1) % 2 == 1 && a[i] % 2 == 1) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 35860
#include <stdio.h>

char str[100000];
char before;

int main() {
  int i;
  int cnt = 0;

  scanf("%s", str);
  before = str[0];
  
  for (i = 0; str[i] != '\0'; i++) {
    if (str[i] != before) cnt++;
    before = str[i];
  }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)


int main(){
	while(true){
		int n,x,r; r=0;
		cin >> n >> x;			if(!n) return 0;
		FOR(i,1,n+1) FOR(j,i+1,n+1) FOR(k,j+1,n+1) if(i+j+k==x) r++;
		cout<<r<<endl;
	}
}

Measured memory_bytes: 1160
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>      // sqrt
#include <cstdlib>    // exit
#include <algorithm>  // min,max
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define R 1000000007
#define DBG 1
typedef pair<int,int> pii;

#define M 16001
#define K 8000
int dp[80][80][M];

int main() {
  int h,w;
  int a[80][80];
  int b[80][80];
  cin >> h >> w;
  forr(i,0,h-1)
  forr(j,0,w-1)
    cin >> a[i][j];
  forr(i,0,h-1)
  forr(j,0,w-1) {
    cin >> b[i][j];
    forr(k,0,M-1) dp[i][j][k] = 0;
  }
  dp[0][0][a[0][0]-b[0][0]+K] = 1;
  dp[0][0][-a[0][0]+b[0][0]+K] = 1;
  forr(i,0,h-1)
  forr(j,0,w-1)
  forr(u,0,M-1) {
    if (!(i>0 && dp[i-1][j][u] || j>0 && dp[i][j-1][u]))
      continue;
    int x = u + a[i][j] - b[i][j];
    int y = u - a[i][j] + b[i][j];
    if (0<=x && x<M) dp[i][j][x] = 1;
    if (0<=y && y<M) dp[i][j][y] = 1;
  }
  int mn = 999999;
  forr(u,0,M-1)
    if (dp[h-1][w-1][u] && abs(u-K)<mn) mn = abs(u-K);
  cout << mn << endl;
}


Measured memory_bytes: 400384
#include<bits/stdc++.h>
#define int int64_t
using namespace std;

int M = 1e9+7;

vector<vector<int>> multiply(vector<vector<int>> &a , vector<vector<int>> &b , int n) {
    vector<vector<int>> res(n , vector<int>(n));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                res[i][j] = (res[i][j] + (a[i][k] * b[k][j])%M)%M;
            }
        }
    }
    return res;
}

vector<vector<int>> power(vector<vector<int>> &a , int n , int k) {
    vector<vector<int>> res(n , vector<int>(n , 0));
    for(int i = 0; i < n; i++) res[i][i] = 1;
    while(k) {
        if(k & 1) res = multiply(res , a , n);
        k /= 2;
        a = multiply(a , a , n);
    }
    return res;
} 

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

    int n , k;
    cin >> n >> k;
    vector<vector<int>> a(n , vector<int>(n));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) cin >> a[i][j];
    }
    vector<vector<int>> res(n , vector<int>(n));
    res = power(a , n , k);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) ans = (ans + res[i][j])%M;
    }
    cout << ans << '\n';

    return 0;
}



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

int main(){
	int m1,d1,m2,d2; cin>>m1>>d1>>m2>>d2;
	if(m1+1==m2&&d2==1) cout<<1<<endl;
	else cout<<0<<endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

int main()
{
	int h,w,n;
	cin >> h >> w >> n;
	pair<int,int> s;
	cin >> s.first >> s.second;
	s.first--;s.second--;
	string strS, strT;
	cin >> strS >> strT;

	vector<int> l( n + 1, -1 );
	vector<int> r( n + 1, w );
	vector<int> u( n + 1, -1 );
	vector<int> d( n + 1, h );

	BREP(i, n)
	{
		l[i] = l[i+1];
		r[i] = r[i+1];
		u[i] = u[i+1];
		d[i] = d[i+1];
		if( strT[i] == 'L' && r[i] < w )
		{ r[i]++; }
		else if( strT[i] == 'R' && l[i] > -1  )
		{ l[i]--; }
		else if( strT[i] == 'U' && d[i] < h  )
		{ d[i]++; }
		else if( strT[i] == 'D' && u[i] > -1 )
		{ u[i]--; }
		
		if( strS[i] == 'L' )
		{ l[i]++; }
		else if( strS[i] == 'R' )
		{ r[i]--; }
		else if( strS[i] == 'U' )
		{ u[i]++; }
		else if( strS[i] == 'D' )
		{ d[i]--; }
	}
	
	bool ans = true;
	if( s.first <= u[0] || d[0] <= s.first ||
	s.second <= l[0] || r[0] <= s.second )
	{
		ans = false;
	}
	else
	{
		REP( i, n )
		{
			if( l[i] >= r[i] - 1 || 
			    u[i] >= d[i] - 1)
			{
				ans = false;
				break;
			}
		}
	}
	cout << ( ans ? "YES" : "NO" ) << endl;

	return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 2e5 + 9;
int jump[N][61], parent[N];

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif

	/*
	 * N K -> 1e18 2^59 + ...
	 * A1 A2, ....
	 */
	int n;
	ll rem;
	cin >> n >> rem;
	for (int i = 1; i <= n; ++i) {
		cin >> parent[i];
		jump[i][0] = parent[i];
	}
	for (int k = 1; k < 60; ++k) {
		for (int i = 1; i <= n; ++i) {
//			int cur = i; // 2^(k-1)
			// 1 -> 2 -> 3 -> 4
			// 1 (2 steps) -> 3
			int par = jump[i][k-1]; // 2^(k-1)
			jump[i][k] = jump[par][k - 1];
		}
	}


// 2^k, 2^(k-1)
	int cur = 1;
	for (int k = 60; k >= 0; --k) {
		if((1ll << k) <= rem) { // 4 < 7
			// 3
			// 2
			// 1
			rem -= (1ll << k);
			int temp = jump[cur][k];
			cur = temp;
		}
	}
	cout << cur;
	return 0;
}


Measured memory_bytes: 52092
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
  vector<int>x(5);
  int k;
  for( int i=0;i<5;i++ )
    cin >> x[i];
  cin >> k;
  for( int i=0;i<5;i++ )
    for( int j=i+1;j<5;j++)
      if( x[j]-x[i]>k )
	{
	  cout << ":(" << endl;
	  return 0;
	}
  cout << "Yay!" << endl;  
  return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
long long solve(long long x,long long k,long long d){

    long long ans;
    if(x<d){
        if(k%2==1){
            ans=abs(x-d);
        }
        else{
            ans=x;
        }
    }
    else if(x==d){
        if(k%2==1){
            ans=0;
        }
        else{
            ans=x;
        }
    }
    else{
        if((long double)x/d>k){
            ans=abs(x-d*k);
        }
        else{
            long long res=x%d;
            long long l=x/d;
            if((k-l)%2==0){
                ans=res;
            }
            else{
                ans=abs(res-d);
            }
        }
    }


    return ans;
}
int main(){
    long long x,k,d;
    cin>>x>>k>>d;
    //x=1;
    //d=5;
    //k=20;
    x=abs(x);
    
    cout<<solve(x,k,d)<<endl;



    return 0;

}
/*


*/


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

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

    //I don't care about anybody, and fuck ratings! I'll go to google!
    string s; cin>>s;
    int n = s.size();
    bool ok = 1;
    for(int i = 0; i<n; i++){
        if((i%2==1 && s[i]=='R') || (i%2==0 && s[i]=='L')) ok = 0; 
    }
    cout<<(ok?"Yes\n":"No\n");
    return 0; 
}


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

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

  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  long long ans = A.at(0);
  for (int i = 0; i < N; i++) {
    ans = __gcd(ans, A.at(i));
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n, S;

int hp (ll x) {
	static char ss[] = "87";
	static char s[20];
	sprintf(s, "%lld", x);
	return ((string)s < (string)ss) == (x < 87);
}

bool ask (bool p, ll x) {
	static char y;
	printf("%c %lld\n", p ? '!' : '?', x);
	fflush(stdout);
	scanf("%s", &y);
//	return hp(x);
	return y == 'Y';
}

int main () {
	int res = 0, j = 1, now = ask(0, 1000000000000ll) ^ 1;
	bool oo;
	for (int i = 9, j = 1, _i = 10; 1; i = i * 10 + 9, ++j, _i *= 10) {
		if (now == 0) oo = ask(0, i);
		else oo = !ask(0, _i);
		if (oo) { S = j; break; }
		if (i == 1e9) { S = 9; break; }
	}
	if (!S) return ask(1, 0), 0;
	if (S == 10) return ask(1, 1e9), 0;
	for (int i = j = 1; i < S; ++i, res *= 10) {
		int l = 1, r = 9, mid;
		while (l <= r) {
			mid = (l + r) >> 1;
			if (!ask(0, res + mid)) r = mid - 1;
			else l = mid + 1;
		}
		res += (l - 1);
	}
	for (int i = S == 1; i <= 9; ++i) {
		if (ask(0, 10ll * (i + res))) return ask(1, i + res), 0;
	}
	ask(1, res);
	return 0;
}
/*
Y
Y
Y
N
N
N
Y
N
Y
N
*/

Measured memory_bytes: 596
n=int(input())
x=list(map(int,input().split()))

l=[x[i] for i in range(n)]

l.sort()

small=l[n//2-1]
large=l[n//2]

for i in range(n):
    if x[i]>=large:
        print(small)
    else:
        print(large)


Measured memory_bytes: 26772
N = int(input())
s = input()
words = [s]
for _ in range(N-1):
    t = input()
    if not t in words:
        words.append(t)
    else:
        print("No")
        exit()
    if s[-1] != t[0]:
        print("No")
        exit()
    s = t
print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>

typedef long long ll;

using namespace std;

int main()
{
	const string keyence = "keyence";
	string input;

	cin >> input;

	ll skip_start = -1, skip_end = -1;

	int i = 0;
	int k = 0;

	while (true)
	{
		if (keyence[k] == input[i])
		{
			if (k < keyence.size() && i < input.size())
			{
				++i;
				++k;
			}
			else
			{
				if (i < input.size())
				{
					if (skip_start == -1)
					{
						cout << "YES" << endl;
						return 0;
					}
				}
				else if (k < keyence.size())
				{
					cout << "NO" << endl;
					return 0;
				}
				else
				{
					cout << "YES" << endl;
					return 0;
				}
			}
		}
		else
		{
			if (skip_start == -1)
			{
				skip_start = i;
			}
			k = skip_start;

			while (keyence[k] != input[i])
			{
				if (i < input.size())
				{
					++i;
				}
				else
				{
					cout << "NO" << endl;
					return 0;
				}
			}
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<map>
#include<cmath>
using namespace std;

int main() {
    int k;
    cin>>k;
    int r[k], c[k];
    for(int i=0;i<k;++i){
        cin>>r[i]>>c[i];
    }
    queue<vector<int> > que;
    vector<int> tmp;
    for(int i=0;i<8;++i){
        tmp.clear();
        tmp.push_back(i);
        que.push(tmp);
    }
    
    vector<int> state;
    bool tmpans;
    bool ans;
    while(!que.empty()){
        state = que.front();que.pop();
        if(state.size()==8){
            tmpans = true;
            for(int i=0;i<k;++i){
                if(state[r[i]]!=c[i])tmpans = false;
            }
            if(!tmpans) continue;
            ans = true;
            for(int i=0;i<8;++i){
                for(int j=i+1;j<8;++j){
                    if(abs(state[j]-state[i])==abs(j-i)) ans = false;
                }
            }
            if(ans){
                break;
            }
        }
        map<int, int> map;
        for(int i=0;i<state.size();++i){
            map[state[i]]++;
        }
        for(int i=0;i<8;++i){
            if(map[i]==0){
                state.push_back(i);
                que.push(state);
                state.pop_back();
            }
        }
    }
    for(int i=0;i<8;++i){
        for(int j=0;j<8;++j){
            if(j==state[i]) cout<<'Q';
            else cout<<'.';
        }
        cout<<endl;
    }
}



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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;


inline li calc(li n, li h, li nn) {
	auto bunbo = 4 * h * nn - n * h - n * nn;
	if (bunbo == 0)return -1;
	auto bunshi = h * nn * n;
	if (bunshi % bunbo != 0) {
		return -1;
	}
	return bunshi / bunbo;
}

int main(void)
{
	li n;
	cin >> n;
	for (li h = 1; h <= 3500; h++) {
		for (li nn = 1; nn <= 3500; nn++) {
			li w = calc(n, h, nn);
			if (w > 0) {
				cout << h << " " << nn << " " << w << endl;
				return 0;
			}
		}
	}
	puts("not found");
	cout << calc(2, 1, 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    int A,B,c=0;;cin >> A >> B;
    char S[17];
    cin >> S;
    rep(i,A+B+1){
        if(S[i]!='-' && i!= A){
            c++;
        }
        if(S[i]=='-' && i==A){
            c++;
        }
    }
    cout << (c==A+B+1 ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;


int main(){
  string s;
  cin>>s;
  if(s[0]=='S') cout<<"Cloudy"<<endl;
  else if(s[0]=='R') cout<<"Sunny"<<endl;
  else cout<<"Rainy"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdint>

namespace {
    const int STRING_NUM = 5;
    const char char_vec[STRING_NUM] = {'M','A','R','C','H'};
}

int main() {
    int n;
    std::cin >> n;
    std::vector<uint64_t> str_count(STRING_NUM, 0);
    for (auto i = 0; i < n; ++i) {
        std::string tmp;
        std::cin >> tmp;
        for(auto j = 0; j < STRING_NUM; ++j) {
            if (tmp[0] == char_vec[j]) {
                ++(str_count[j]);
                break;
            }
        }
    }
    uint64_t result = 0;
    for (auto i = 0; i < STRING_NUM - 2; ++i) {
        for (auto j = i + 1; j < STRING_NUM - 1; ++j) {
            for (auto k = j + 1; k < STRING_NUM; ++k) {
                result += str_count[i] * str_count[j] * str_count[k];
            }
        }
    }
    std::cout << result << std::endl;
    return 0;
}



Measured memory_bytes: 256
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern
let (n, m) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n m -> (n, m)
let h = read_line () |> split_string |> List.map int_of_string |> Array.of_list
let ab = Array.init m @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun a b -> (a - 1, b - 1)

let m = Array.make n 0

let () =
  Array.iter (fun (a, b) -> m.(a) <- max m.(a) h.(b); m.(b) <- max h.(a) m.(b)) ab;
  Printf.printf "%d\n" @@ Array.fold_left (+) 0 @@ Array.mapi (fun i v -> if v > m.(i) then 1 else 0) h

Measured memory_bytes: 21284
import java.util.Scanner;
import java.util.Collections;
import java.util.LinkedList;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        LinkedList<Integer> nums = new LinkedList<>();

        // input
        final int NUM = scan.nextInt();
        for(int i = 0; i < NUM; i++){
            if(i % 2 == 0){
                nums.addLast(scan.nextInt());
            } else {
                nums.addFirst(scan.nextInt());
            }
        }

        // answer
        if(NUM % 2 == 0){
            nums.forEach(a -> System.out.print(a + " "));
        } else {
            Collections.reverse(nums);
            nums.forEach(a -> System.out.print(a + " "));
        }
        

    }
}

Measured memory_bytes: 101324