akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll lcm(ll x, ll y)
{
    return (x*y)/__gcd(x,y);
}
int sum(string s)
{
    int x=0,sz=s.size();
    loop(i,0,sz)x+=(s[i]-'0');
    return x;
}
/*
struct node
{
int data;
node *link;
};
typedef node* nodeptr;
void head_insert(nodeptr& head,int x)
{
    nodeptr tmp;
    tmp=new node;
    tmp->data=x;
    tmp->link=head;
    head=tmp;
}
nodeptr search(nodeptr head,int x)
{
    nodeptr cur=head;
    if(cur ==  nullptr)return cur;
    while(cur->data!=x&&cur->link!=nullptr)
    {
        cur=cur->link;
    }
    if(cur->data==x)return cur;
    else return nullptr;
}
void show(nodeptr head)
{
    nodeptr cur=head;
    if(cur==nullptr)return;
   // cout<<head->data<<" ";
    while(cur->link!=nullptr){
        cout<<cur->data<<" ";
        cur=cur->link;
    }
    cout<<endl;
}
*/

int main()
{
    mego
   int n,id,m,x=0;
   unordered_map<int,int>f;
   loop(i,1,101)
   loop(j,1,101)
   loop(k,1,101)
   {
       x=(i*i);
       x+=(j*j);
       x+=(k*k);
       x+=(i*j);
       x+=(i*k);
       x+=(j*k);
      f[x]++;

   }
   cin>>n;
   loop(i,1,n)
   cout<<f[i]<<endl;
   cout<<f[n];
    return 0;
}


Measured memory_bytes: 4908
#include <bits/stdc++.h>
using namespace std;
int main() {
	double n,m,s;
	while(cin>>n>>m>>s,n){
		int ans=0;
		n+=100;
		m+=100;
		for(int i=1;i<=s/2;i++){
			for(int j=1,x,y;i+j<=s;j++){
				if((x=i*n/100)+(y=j*n/100)==s)ans=max(ans,(x=i*m/100)+(y=j*m/100));
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1220
#include<stdio.h>
#define N 100
main(){
  int i,j,n,a[N],count=0,b;

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

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

  

Measured memory_bytes: 604
#include <cstdio>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
#define REP(i,x)for(int i=0;i<x;i++)

string res;
int H,W,dx,dy,min_len;
char s[200];
char MAP[11][22];
bool visit[20][20];
vector<string> ss;
void dfs(int x,int y,int k){
  if(visit[y][x]){
    ss.push_back(string(s));
    return;
  }
  s[k]=MAP[y][x];  visit[y][x]=1;
  dfs((x + dx + W) % W, (y + dy + H) % H, k + 1);
  s[k]=0;  visit[y][x]=0;
}
int main() {
  while(scanf("%d%d",&H,&W),H){
    REP(i,H)scanf("%s",MAP[i]);
    ss.clear();
    min_len=1; res="0";
    REP(y,H)REP(x,W){
      for(dx=-1;dx<=1;dx++){
        for(dy=-1;dy<=1;dy++){
          if(dx|dy)dfs(x,y,0);
        }
      }
    }
    string res = "0";
    sort(ss.begin(),ss.end());
    REP(i,ss.size()-1){
      int len = 0;
      REP(k,min(ss[i].size(),ss[i+1].size())){
        if(ss[i][k]==ss[i+1][k])len++;
        else break;
      }
      if(len < res.size())continue;
      if(res.size() == len){
        res = min(res, ss[i].substr(0,len));
      }else{
        res = ss[i].substr(0, len);
      }
    }
    puts(res.c_str());
  }
}

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

using namespace std ;

const int N = 2 * 100 * 1000 + 10 ;
pair <int , int> arr[N] ;
bool booly[N] ;
// main memory

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

    for(int i = 0 ; i <= m ; i++)
        booly[i] = false ;

    for(int i = 0 ; i < m ; i++){
        cin >> arr[i].first >> arr[i].second ;
        if(arr[i].second == n)
            booly[arr[i].first] = true ;
    }

    sort(arr , arr + m) ;

    // vorodi

    int i = 0 ;
    while(arr[i].first == 1)
    {
        if(booly[arr[i].second] == true){
            cout << "POSSIBLE" << endl ;
            return 0 ;
        }
        i++ ;
    }

    cout << "IMPOSSIBLE" << endl ;
	return 0 ;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

const int MAX_SIZE=2000001;

int main(){

	//int mtate[MAX_SIZE];
	//int myoko[MAX_SIZE];
	vector<int> mtate(MAX_SIZE,0);
	vector<int> myoko(MAX_SIZE,0);

	int n,m;
	vector<int> tate;
	vector<int> yoko;
	while(cin>>n>>m&&!(n==0&&m==0)){
		tate.clear();
		yoko.clear();
		tate.push_back(0);
		for(int i = 0; i < n; i++){
			int t;
			cin>>t;
			int p=tate.size()-1;
			tate.push_back(t+tate[p]);
		}
		yoko.push_back(0);
		for(int i = 0; i < m; i++){
			int t;
			cin>>t;
			int p=yoko.size()-1;
			yoko.push_back(t+yoko[p]);
		}
		// ツ閉敖づ個青板づーcnt
		//fill(mtate,mtate+MAX_SIZE,0);
		//fill(myoko,myoko+MAX_SIZE,0);
		//memset(mtate,0,sizeof(mtate));
		//memset(myoko,0,sizeof(myoko));
		for(int i = 0; i < MAX_SIZE; i++){
			mtate[i]=myoko[i]=0;
		}

		for(int i = 0; i < tate.size(); i++){
			for(int j = i + 1; j < tate.size(); j++){
				mtate[tate[j]-tate[i]]++;
			}
		}
		for(int i = 0; i < yoko.size(); i++){
			for(int j = i + 1; j < yoko.size(); j++){
				myoko[yoko[j]-yoko[i]]++;
			}
		}
		int cnt=0;
		for(int i = 0; i < MAX_SIZE; i++){
			cnt+=(mtate[i]*myoko[i]);
		}
		cout<<cnt<<endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=n-1; k>j; k--){
                if(a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i]){
                    vector<int> tru({a[i], a[j], a[k]});
                    sort(tru.begin(), tru.end());
                    if(tru[0] + tru[1] > tru[2]) ans++;
                }
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3612
import random,math

def MillerRabinPrimalityTest(n):
	if n == 2:
		return True;
	if n == 1 or n & 1 == 0:
		return False
	d = (n - 1) >> 1
	while d & 1 == 0:
		d >>= 1
	for k in range(int(math.log(n, 4))):
		a = random.randint(1, n - 1)
		t = d
		y = pow(a, t, n)
		while t != n - 1 and y != 1 and y != n - 1:
			y = (y * y) % n
			t <<= 1
		if y != n - 1 and t & 1 == 0:
			return False
	return True
def nextp(prevp):
	if(prevp<=3):
		return 2
	prevp-=1
	while(True):
		if(MillerRabinPrimalityTest(prevp)):
			break
		prevp-=1
	return prevp
def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])
	if temp!=1:
		arr.append([temp, 1])
	if arr==[]:
		arr.append([n, 1])
	return arr

N = int(input())
if(N==1):
	print(0)
else:
	ans = 0;
	facts = factorization(N)
	for fact in facts:
		used = 0
		left = fact[1]
		while True:
			used+=1
			ans+=1
			left-=used
			if left<=used:
				break
	print(ans);



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

using namespace std;
typedef long long ll;
const ll maxx=INT_MAX;


ll dp[100000];
ll n,k;
ll frog1(ll in[],ll i)
{

    ll INF=maxx;

    if(i==n){

        return 0 ;
    }
    if(dp[i]!=-1)
        return dp[i];
    if(i>n)return maxx;


    for(ll j=1;j<=k;j++){

        INF=min(INF,(frog1(in,i+j)+abs(in[i]-in[i+j])));

    }


    return dp[i]=INF;
}
int main()
{
  ll in[100000]={0},i;

  cin>>n>>k;
memset(dp,-1,sizeof(dp));
  for (i=1; i<=n; i++)
  {
    cin>>in[i];
  }
    cout<<frog1(in,1);

  return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    vector <int> a(n);
    rep(i,n) a[i] = i+1;
    int num=0;
    rep(i,n) {
        if(p[i] != a[i]){
            ++num;
        }
    }
    if(num == 2 || num == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3608
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }
    
}

fn main(){
    let tiles = read_as_string();
    let tiles = tiles.chars().collect::<Vec<char>>();

    
    let mut diff: usize = 0;
    for i in 0..tiles.len(){
        if i%2 == 0{
            if tiles[i] == '0'{
                diff += 1;
            }
        }else{
            if tiles[i] == '1'{
                diff += 1;
            }
        }
    }

    if diff > tiles.len()/2{
        println!("{}", tiles.len()-diff);        
    }else{
        println!("{}", diff);        
    }

    
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  bool has_odd = false;
  rep(i, N)
  {
    cin >> a[i];
    if(a[i] % 2 == 1)
      has_odd = true;
  }
  if(has_odd)
    cout << "first" << endl;
  else
    cout << "second" << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
using namespace std;


int main()
{
    int l,r,d,ans=0;cin>>l>>r>>d;
    for(int i=l;i<=r;i++){
        if(!(i%d)) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3464
(* Vicfred
 * https://atcoder.jp/contests/abc135/tasks/abc135_a
 * math
 * *)
Scanf.scanf "%d %d\n" (fun a b ->
    if (a + b) mod 2 != 0 then "IMPOSSIBLE"
    else string_of_int @@ (a + b) / 2
) |> Printf.printf "%s\n"



Measured memory_bytes: 3796
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

const ll MAX = 1e6+9;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0]  = fac[1]  = 1;
    finv[0] = finv[1] = 1;
    inv[1]  = 1;

    for(int i = 2; i < MAX; ++i){
        fac[i]  = fac[i - 1] * i % MOD;
        inv[i]  = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    ll a[n+1];
    map<ll, ll> mp;
    ll l, r;
    rep(i, n+1){
        cin >> a[i];
        if(mp.count(a[i]) > 0){
            l = mp[a[i]];
            r = i;
        }
        else {
            mp[a[i]] = i;
        }
    }

    COMinit();
    rep(i, n+1){
        cout << (COM(n+1, i+1)%MOD - COM(l+n-r, i) + MOD) % MOD << endl;
    }
}

Measured memory_bytes: 34116
#include <iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int main()
{
    int  a=0,b=0;
    while(cin >> a>> b){
        cout << a+b << endl;

    }
    //cout << b;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <vector>
using namespace std;
#define ll long long
int main()
{
	int n, m;
	cin >> n >> m;
	if (n == m) cout << "Yes";
	else cout << "No";
	system("pause>0");
	return 0;
}


Measured memory_bytes: 504
const main = input =>{
    const In = input.split(' ').map(n=>Number(n));
    const o1 = In[0] > In[1] ? 0 : In[1]/In[0];
    console.log(o1 >= In[2] ? In[2] : parseInt(o1));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
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;
int A[19], B[19];
int dp[1 << 18][18];
int keisan(int b, int k) {
	if (b && dp[b][k] != -1) return dp[b][k];
	if (b == (1 << N) - 1) return 0;

	int num = __builtin_popcount(b);
	auto k2 = (num + k & 1) ? A[k] : B[k];

	int saishou = 2e9;
	int num2 = 0;
	rep(i, N) {
		if (!(b >> i & 1)) {
			if ((num ^ i) & 1) {
				if (B[i] >= k2) {
					chmin(saishou, keisan(b ^ (1 << i), i) + num2);
				}
			}
			else {
				if (A[i] >= k2) {
					chmin(saishou, keisan(b ^ (1 << i), i) + num2);
				}
			}
			num2++;
		}
	}
	return dp[b][k] = saishou;
}

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


	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	rep(i, 1 << N) rep(j, 18) dp[i][j] = -1;

	int kotae = keisan(0, 18);
	if (kotae > 1e9 || kotae == -1) co(-1);
	else co(kotae);

	Would you please return 0;
}

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

using namespace std;

int N, E, T;
int A[100002];
long long dp[100002];
long long f[100002];
long long g[100002];

int main()
{
    scanf("%d%d%d", &N, &E, &T);
    for(int i=1; i<=N; i++)
        scanf("%d", A+i);
    A[N+1]=E;
    dp[0]=A[1];
    f[0]=dp[0]-3LL*A[1];
    g[0]=dp[0]-A[1];
    multiset<long long> s;
    s.insert(g[0]);
    int ptr=0;
    for(int i=1; i<=N; i++)
    {
        dp[i]=0x3f3f3f3f3f3f3f3fLL;
        while(ptr<i && T<2LL*(A[i]-A[ptr+1]))
        {
            s.erase(s.find(g[ptr]));
            ptr++;
        }
        if(ptr>0)
            dp[i]=min(dp[i], f[ptr-1]+2LL*A[i]);
        if(!s.empty())
            dp[i]=min(dp[i], *s.begin()+T);
        dp[i]+=A[i+1];
        f[i]=min(dp[i]-3LL*A[i+1], f[i-1]);
        g[i]=dp[i]-A[i+1];
        s.insert(g[i]);
    }
    printf("%lld\n", dp[N]);
    return 0;
}


Measured memory_bytes: 4992
# Snack
from collections import deque
import numpy as np
import math


# input
A, B = map(int, input().split())
A, B = max(A,B), min(A,B)

# solve
# -----------------
# 約数列挙
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = deque()
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return list(divisor_list)
# -----------------

div_A = make_divisor_list(A)
div_B = make_divisor_list(B)

rem = [b for b in div_B if b not in div_A]

if len(rem) != 0:
    for b in [b for b in div_B if b not in div_A]:
        if A * b % B == 0:
            res = A * b
            break
else:
    res = A

# output
print(res)

Measured memory_bytes: 12844
# D - Teleporter
def main():
    N, K, *A = map(int, open(0).read().split())
    A = [0] + A
    cur_pos = 1
    last_visit = [-1] * (N + 1)
    last_visit[1] = 0
    
    for i in range(1, K + 1):
        nxt_pos = A[cur_pos]
        if (j := last_visit[nxt_pos]) != -1:
            print(last_visit.index(j + (K - i) % (i - j)))
            return
        cur_pos = nxt_pos
        last_visit[cur_pos] = i
    
    print(cur_pos)


if __name__ == "__main__":
    main()


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

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

void solver() {
    int N = input();
    i64 ans = 0;
    range(i, 1, N + 1) {
        if (i % 3 && i % 5) ans += i;
    }
    
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;

  double ans;
  if(n % 2 ==0)
	  ans = 1.0/2;
  else
	  ans = (n/2+1.0) / n;

  cout << Decimal;
  cout << ans << endl;
  
  
}


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

int main() {
    int n, m;
    cin >> n >> m;
    ll x[n], y[n], z[n], num[8][n], ans = 0;
    rep (i, n) {
        cin >> x[i] >> y[i] >> z[i];
        num[0][i] =  x[i] + y[i] + z[i];
        num[1][i] =  x[i] + y[i] - z[i];
        num[2][i] =  x[i] - y[i] + z[i];
        num[3][i] =  x[i] - y[i] - z[i];
        num[4][i] = -x[i] + y[i] + z[i];
        num[5][i] = -x[i] + y[i] - z[i];
        num[6][i] = -x[i] - y[i] + z[i];
        num[7][i] = -x[i] - y[i] - z[i];
    }
    rep(i, 8) {
        ll tmp = 0;
        sort(num[i], num[i] + n);
        rep(j, m) tmp += num[i][n-j-1];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

#define N 101

int bubblesort(int *, int);

int main() {
  int i, n, c;
  int A[N];

  scanf("%d",&n);
  if(n<0 || n>101) exit(1);

  for(i=0;i<n;i++) scanf("%d", &A[i]);

  c=bubblesort(A, n);
  for(i=0;i<n-1;i++) printf("%d ", A[i]);
  printf("%d\n", A[i]);
  printf("%d\n", c);

  return 0;
}

int bubblesort(int *A, int n){
  int i, j, temp;
  int c=0, flag=1;
  while(flag){
    flag=0;
    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(A[j]<A[j-1]){
	  temp=A[j];
	  A[j]=A[j-1];
	  A[j-1]=temp;
	  flag=1;
	  c++;
	}
      }
    }
  }
  return c;
  
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
int64_t N,K;
  cin>>N>>K;
  if(K%2!=0){
  int64_t ans=N/K;
    ans=powl(ans,3);
    cout<<ans<<endl;
  }else{
  int64_t a=N/K;
    a=powl(a,3);
    int64_t b=(N+K/2)/K;
    b=powl(b,3);
    int64_t ans=a+b;
    cout<<ans<<endl;
  }
  
   return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N, T;
int A[100010];

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> T;
	rep(i, 0, N)
	{
		cin >> A[i];
	}

	int ma = INF;
	map<int, int> vmap;
	
	rep(i, 0, N)
	{
		chmin(ma, A[i]);
		vmap[A[i] - ma]++;
	}

	auto itr = vmap.end();
	itr--;

	cout << (*itr).second << endl;

	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
	private: int _num[98],_head;
	public: int SUF; template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'),putchar(SUF);return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; putchar(SUF); return *this;}
	fastout() {_head=0,SUF=' ';}
}fout;
// ----------------------------
#define int ll
// #define abs(x) (x>0?x:-x)
using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;
 
int a,b,c,d;
inline ll solve()
{
	--a,--b,--c,--d;
	int res=abs(a-c)+abs(b-d),t=1LL;
	for(rgi i=1;i<=33;++i) t*=3LL;
	for(rgi i=33;i>=0;--i)
	{
		for(rgi j=0;j<2;++j)
		{
			if(a/t==c/t&&(a/t)%3LL==1LL&&abs(b/t-d/t)!=1&&abs(b-d)>=t)
			{
				int mn=min(a,c),mx=max(a,c);
				// cout<<t<<endl;
				// cout<<mn<<" "<<mx<<endl;
				// cout<<mn-((mn-1)/t)*t<<" "<<((mx-1)/t+1)*t-mx+1<<endl;
				return res+min(mn-mn/t*t+1LL,(mx/t+1LL)*t-mx)*2LL;
			}
			swap(a,b),swap(c,d);
		}
		t/=3LL;
	}
	return res;
}
 
signed main()
{
	rgi q;
	cin>>q;
	while(q--)
	{
		cin>>a>>b>>c>>d;
		cout<<solve()<<endl;
	}
	return 0;
}
// ----------------------------
// by imzzy
 
/*
10
4 2 7 4
9 9 1 9
2 1 2 3
4 3 4 7
5 3 5 7
6 3 6 7
4 3 6 7
10 9 19 9
*/

Measured memory_bytes: 384
# 58
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

n = I()
a = LI()
ans = 0
i = 0
while i < n:
    while i+1 < n and a[i] == a[i+1]:
        i += 1
    if i+1 < n and a[i] < a[i+1]:
        while i+1 < n and a[i] <= a[i+1]:
            i += 1
    elif i+1 < n and a[i] > a[i+1]:
        while i+1 < n and a[i] >= a[i+1]:
            i += 1
    ans += 1
    i += 1
print(ans)


Measured memory_bytes: 20072
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/


void solve(){
    char c;
    cin >> c;
    if(c >= 'a' and c <= 'z')cout << "a";
    else cout << "A";
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3644
from collections import Counter
N = int(input())
A = sorted(map(int, input().split()), reverse=False)
m = max(A)+1
c = Counter(A)
s = list(set(A))
dp = [True] * m
for x in s:
    t = x * 2
    while t < m:
        dp[t] = False
        t += x
ans = 0
for a in A:
    if c[a] == 1 and dp[a]:
        ans += 1
print(ans)



Measured memory_bytes: 45164
#include <iostream>
#include <algorithm>
using namespace std;
int n,ans;
typedef pair<int,int> P;
bool f_sort(P a,P b){return a.first<b.first;};
bool s_sort(P a,P b){return a.second>b.second;};
int main(){
        cin >>n;
        P r[n];
        P b[n];
        for(int i=0; i<n; i++) {
                cin >> r[i].first;
                cin >> r[i].second;
        }
        for(int i=0; i<n; i++) {
                cin >> b[i].first;
                cin >> b[i].second;
        }
        sort(r,r+n,s_sort);//rのy座標を大きい順に並べる
        sort(b,b+n,f_sort);//bのx座標を小さい順に並べる
        for(int i=0; i<n; i++) {//bの左にある点から調べる
                for(int j=0; j<n; j++) {//rの下にある点から調べる
                        if((r[j].first<b[i].first)&&(r[j].second<b[i].second)&&r[j].first!=-1) {
                                ans++;
                                r[j].first=-1;
                                break;
                        }
                }
        }
        cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

//Educational DP Contest / DP まとめコンテスト
//C	Vacation
public class Main {

	static void chMin(int[][] dp, int i, int j, int v) {
		if (dp[i][j] > v) {
			dp[i][j] = v;
		}
	}

	static void chMax(int[][] dp, int i, int j, int v) {
		if (dp[i][j] < v) {
			dp[i][j] = v;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());

		final int DP_SIZE = 100000 + 10;

		int[][] abcArr = new int[N][3];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				abcArr[i][j] = Integer.parseInt(sc.next());
			}
		}
		sc.close();

		int[][] dp = new int[DP_SIZE][3];
		for (int i = 0; i < DP_SIZE; i++) {
			for (int j = 0; j < 3; j++) {
				dp[i][j] = 0;
			}
		}

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (j == k) {
						continue;
					}
					chMax(dp, i + 1, k, dp[i][j] + abcArr[i][k]);
				}
			}
		}

		int ans = 0;
		for (int j = 0; j < 3; j++) {
			ans = Math.max(ans, dp[N][j]);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 67904
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <set>

template <typename T>
struct PrimeFact {
    std::vector<T> spf;
    PrimeFact(T N) { init(N); }
    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    std::map<T, T> get(T n) { // nの素因数分解を求める
        std::map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};

int main() {
  uint32_t N = 0;
  std::cin >> N;

  PrimeFact pf(1'000'000);

  std::map<uint32_t, uint32_t> prime;
  for (size_t i = 0; i < N; i++)
  {
    uint32_t a = 0;
    std::cin >> a;

    for (auto &&p : pf.get(a)) prime[p.first]++;
  }
  
  bool pairwise = true;
  for(auto &&p: prime){
    if(p.second == N){
      std::cout << "not coprime" << std::endl;
      return 0;
    }
    if(p.second >= 2) pairwise = false;
  }

  std::cout << (pairwise ? "pairwise" : "setwise") << " coprime" << std::endl;

  return 0;
}

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

int main(void)
{
  long n,i,a[10001],max,min,sum;

  cin >> n;
  for(i=1; i<=n; i++){
    cin >> a[i];
  }
  sum=a[1];
  min=a[1];
  max=a[1];
  for(i=2; i<=n; i++){
    sum=sum+a[i];
    if(a[i]<min) min=a[i];
    if(a[i]>max) max=a[i];
  };
  cout << min << " " << max << " " << sum << endl;

  return 0;
}

Measured memory_bytes: 3168
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in x,k,d;
    cin>>x>>k>>d;
    if(x<0ll) x=-x;
    in cnt=x%d;
    if((x/d)>=k){
        cout<<x-k*d<<endl;
        return 0;
    }
    k -=x/d;
    if(k%2ll==0ll){
        cout<<cnt<<endl;
    }
    else{
        cout<<abs(cnt-d)<<endl;
    }
}/*
./problem.exe
*/

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,m,ans = 1;
	set<int> as,bs;
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		if(as.count(a)){
			cout << 0 << endl;
			return 0;
		}
		as.insert(a);
	}
	for(int i = 0;i < m;i++){
		int b;
		cin >> b;
		if(bs.count(b)){
			cout << 0 << endl;
			return 0;
		}
		bs.insert(b);
	}
	int r = 0,c = 0;
	for(int i = n * m;i >= 1;i--){
		if(!as.count(i) && !bs.count(i)){
			ans = (r * c - (n * m - i) % MOD + MOD) % MOD * ans % MOD;
		}else{
			int a = 1,b = 1;
			if(as.count(i)) r++;
			else a = r;
			if(bs.count(i)) c++;
			else b = c;
			ans = (a * b + MOD) % MOD * ans % MOD;
		}
	}
	cout << ans << endl;
}

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

int arr[200000];
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	int g = arr[0];
	for (int i = 1; i < n; i++) {
		g = gcd(arr[i], g);
	}
	for (int i = 0; i < n; i++) {
		if (arr[i] >= k) {
			int p = arr[i] - k;
			if (p%g == 0) {
				printf("POSSIBLE");
				return 0;
			}
		}
	}
	printf("IMPOSSIBLE");
}

Measured memory_bytes: 640
N, M = map(int, input().split())
inputDict = {}  # キーは年、値は県番号
ansDict = {}  # キーは年、値は認識番号
inputOrderList = []  # 与えられた順に年を入れる
cityCountDict = {}  # キーは県番号、値は今何個目の市か

for index in range(M):
    Pi, Yi = map(int, input().split())
    inputOrderList.append(Yi)
    inputDict[Yi] = Pi
    cityCountDict[Pi] = 1

for year, pref in sorted(inputDict.items()):
    num = cityCountDict[pref]
    ansDict[year] = "{0:06d}".format(pref) + "{0:06d}".format(num)
    cityCountDict[pref] += 1

for order in inputOrderList:
    print(ansDict[order])


Measured memory_bytes: 47304
import java.util.*;
 
class Main{
    public static void main(String agrs[]){
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
if(a<b && b<c){
        System.out.println("Yes");
}else{
        System.out.println("No");
}
    }
}

Measured memory_bytes: 26216
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	cout << (ll)((n + 5.5 - 1) / 5.5) << endl;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b)
        swap(a, b);
    string ans;
    rep(i, b) ans += a + '0';
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long int 
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pqmin priority_queue<ll,vector<ll>,greater<ll>>
#define pqmax priority_queue<ll>
using namespace std;
ll power(ll a,ll n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return (power((a*a),n/2));
	else
	  return (a*(power((a*a),n/2)));    
}
int main()
{
  IOS;
   ll n,i,mini=100000000000000;
   cin>>n;
   for(i=1;i*i<=n;i++)
   {
       if(n%i==0)
       {
           mini=min(mini,i+(n/i)-2);
       }
   }
   cout<<mini<<endl;
   return 0;
   
}

Measured memory_bytes: 256
///
// File:  1160.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 12 16:15:22 2017
//

#include <array>
#include <cstdint>
#include <iostream>

using namespace std;

void dfs(int32_t h, int32_t w, array<array<uint32_t, 50>, 50> &arr, int32_t i, int32_t j)
{
  arr[i][j] = 0;

  for (int32_t l = -1; l <= 1; l++) {
    for (int32_t k = -1; k <= 1; k++) {
      if (0 <= i + l && i + l < h && 0 <= j + k && j + k < w) {
        if (arr[i + l][k + j] == 1) {
          dfs(h, w, arr, i + l, k + j);
        }
      }
    }
  }
}

int32_t main()
{
  while (true) {
    uint32_t w, h;
    cin >> w >> h;
    if (w == 0) break;

    array<array<uint32_t, 50>, 50> arr;
    for (uint32_t i = 0; i < h; i++) {
      for (uint32_t j = 0; j < w; j++) {
        cin >> arr[i][j];
      }
    }

    uint32_t count = 0;
    for (uint32_t i = 0; i < h; i++) {
      for (uint32_t j = 0; j < w; j++) {
        if (arr[i][j] == 1) {
          count++;
          dfs(h, w, arr, i, j);
        }
      }
    }
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  ll H,W;
  cin >> H >> W;
  vector<vector<ll>> D(H,vector<ll>(W,numeric_limits<ll>::max()));
  vector<string> G(H);

  ll Ch,Cw,Dh,Dw;
  cin >> Ch >> Cw >> Dh >> Dw;
  Ch--;
  Cw--;
  Dh--;
  Dw--;
  for (size_t i = 0; i < H; i++)
  {
    cin >> G[i];
  }
  priority_queue<pair<ll,pair<ll,ll>> ,vector<pair<ll,pair<ll,ll>>>, greater<pair<ll,pair<ll,ll>>> > q;
  q.push({0,{Ch,Cw}});
  vector<pair<ll,ll>> directions ={
    {1,0},
    {-1,0},
    {0,1},
    {0,-1}
  };
  while(!q.empty()){
    auto p = q.top();
    q.pop();
    ll d = p.first;
    ll x = p.second.first;
    ll y = p.second.second;
    // cout << x << "," << y << ":" << d << endl;
    if (d>= D[x][y]){
      continue;
    }else{
      D[x][y] = d;
      for(int i = 0;i < 4;i++){
        ll new_x = x + directions[i].first;
        ll new_y = y + directions[i].second;
        if (0 <= new_x && new_x < H && 0 <= new_y && new_y < W){
          if (G[new_x][new_y] == '.'){
            q.push({d,{new_x,new_y}});
          }
        }
      }
      for(int i = -2;i <= 2;i++){
        for(int j = -2;j <= 2;j++){
          ll new_x = x + i;
          ll new_y = y + j;
          if (0 <= new_x && new_x < H && 0 <= new_y && new_y < W){
            if (G[new_x][new_y] == '.'){
              q.push({d+1,{new_x,new_y}});
            }
          }
        }
      }
    }
  }
  if (D[Dh][Dw] == numeric_limits<ll>::max()){
    cout << -1 << endl;
  }else{
    cout << D[Dh][Dw] << endl;
  }
 return 0;
}


Measured memory_bytes: 19176
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
double a,b;
int main(){
	cin>>a>>b;
	printf("%.10lf",a/b);
}

Measured memory_bytes: 256
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
using namespace std;

#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vector<int>>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define fir(i,a,b)      for(int i=a;i<b;i++)
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);
#define MAXZ            200005
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

bool cmp(int a,int b) {return a>b;}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

int a[200001],b[200001];

int32_t main()
{
    FIO
    string a,b; cin>>a>>b;
    int p=1;
    for(int i=0;i<min(a.length(),b.length());i++){
        if(a[i]!=b[i]) p=0;
    }
    (p && cout<<"Yes\n")|| cout<<"No\n";
    return 0;

}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
    long A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    long ans=100000000000000000;;
    for(int D=0;D<=max(X,Y);D++){
        ans=min(ans,C*2*D+A*max((long)0,X-D)+B*max((long)0,Y-D));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let d: usize = scan(tokens);
    println!("{}", (n + 2 * d) / (2 * d + 1));
}


Measured memory_bytes: 4352
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N,A,B,C;
int l[10];
signed main(){
    scanf("%lld %lld %lld %lld",&N,&A,&B,&C);
    rep(i,N)scanf("%lld",&l[i]);
    int ans=INF;
    rep(i,1<<2*N){
        int matsu[10];//0の時使わない、1の時A、2の時B、3の時C
        int a=0,b=0,c=0;
        int i_=i;
        int sans=-30;
        rep(j,N){
            matsu[j]=i_%4;
            if(matsu[j]==1){a+=l[j];sans+=10;}
            if(matsu[j]==2){b+=l[j];sans+=10;}
            if(matsu[j]==3){c+=l[j];sans+=10;}
            i_/=4;
        }
        if(a==0||b==0||c==0)continue;
        sans+=abs(a-A);
        sans+=abs(b-B);
        sans+=abs(c-C);
        ans=min(ans,sans);
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 1712
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a + b == 15) cout << '+' << endl;
    else if( a * b == 15) cout << '*' << endl;
    else cout << 'x' << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    string s;
    cin >> s;
    ull K;
    cin >> K;
    int one_continue_n = 0;
    int a;
    for(char c : s){
        if(c != '1'){
            a = c - '0';
            break;
        }else one_continue_n++;
    }
    if(one_continue_n >= K) cout << '1' << endl;
    else cout << a << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, x, i, a[100001], ans=0;

    cin >> N >> x;

    for(i=1; i<=N; i++){
        cin >> a[i];
    }

    if(a[1] > x){
        ans += (a[1]-x);
        a[1] = x;
    }

    for(i=2; i<=N; i++){
        if(a[i-1]+a[i] > x){
            ans += (a[i-1]+a[i]-x);
            a[i] = x-a[i-1];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
lis = list(map(int, input().split()))
lis_score = []


for i in range(n):

  if i >= k:
    lis_edge_right = lis[i]
    lis_edge_left = lis[i-k]
    
    if lis_edge_right > lis_edge_left:
      print("Yes")
    else:
      print("No")



Measured memory_bytes: 31540
N = int(input())
a = list(map(int,input().split()))
result = "APPROVED"
for i in range(N):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            result = "DENIED"
            break
print(result)


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
str s[4],st;
int memo[200005];
bool f(int num){
    if(memo[num]>-1)return (bool)memo[num];
    if(num==st.size())return memo[num]=1;
    else {
        bool ans=false;
        rep(i,num,num+7){
            if(i==(num+4)&&s[1][i-num]==st[i]){
                ans=max(f(num+5),ans);
            }else if(s[1][i-num]!=st[i]){
                break;
            }else if(i==(num+6)){
                ans=max(f(num+7),ans);
            }
        }
        //cout << ans << endl;
        if(ans)return ans;
        rep(i,0,6){
            if(i==4&&s[3][i]==st[num+i]){
                ans=max(ans,f(num+5));
          //  cout << ans ;
            }else if(s[3][i]!=st[i+num]){
            //    cout << i << endl;
                break;
            }else if(i==5){
                ans=max(ans,f(num+6));
            }
        }
        return memo[num]=ans;
    }
//    cout << ans << endl;
//    return ans;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    str ss[4]={"dream","dreamer","erase","eraser"};
    memset(memo,-1,sizeof(memo));
    rep(i,0,4)s[i]=ss[i];
    cin >> st;
    int mae=0;
    bool ff=f(0);
    if(ff){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 3792