akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,ans="No";cin>>s;
  bool Cfind=false;
  for(int i=0;i<s.size();i++){
    if(s[i]=='C')Cfind=true;
    if(Cfind&&s[i]=='F')ans="Yes";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] cell = new int[n];
		for(int i=0; i<n; i++) cell[i] = in.nextInt();
		int[] dp = new int[n];
		final int INF = Integer.MAX_VALUE;
		for(int i=0; i<n; i++) dp[i] = INF;
		Queue<Pos> qu = new PriorityQueue<Pos>();
		qu.add(new Pos(0, 0));
		int res = INF;
		while(!qu.isEmpty()){
			Pos p = qu.poll();
			if(p.p >= n-1){
				res = p.turn;
				break;
			}
			if(dp[p.p] <= p.turn) continue;
			dp[p.p] = p.turn;
			if(cell[p.p] != 0){
				qu.add(new Pos(p.p+cell[p.p], p.turn));
				continue;
			}
			for(int i=1; i<=6; i++){
				qu.add(new Pos(p.p+i, p.turn+1));
			}
		}
		System.out.println(res);
	}
}

class Pos implements Comparable<Pos>{
	int turn;
	int p;
	Pos(int p, int turn){
		this.p = p;
		this.turn = turn;
	}
	@Override
	public int compareTo(Pos o) {
		return turn-o.turn;
	}
}

Measured memory_bytes: 64820
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if(Math.abs(a-b)<1)
            System.out.println(bb(b,bb(a,2)));
        else if(Math.abs(a-b)<2)
            System.out.println(bb(b,bb(a,1)));
        else
            System.out.println(0);
    }
    private static long bb(long a, long b){
        for(long i=1;i<=a;i++){
            b *= i;
            b%=1000000007l;
        }
        return b;
    }
}


Measured memory_bytes: 21716
def main():
    N, M = map(int, input().split())
    A = list(map(int,input().split()))
    L = 1/(4*M)*sum(A)
    # print(L)
    sum_ = 0
    for a in A:
        # print(a)
        if a >= L:
            sum_ += 1
    if sum_ >= M:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9100
import java.io.PrintWriter;
import java.util.*;

public class Main {
    private static int n, m;
    private static char[] s, t;
    private static int[][] sp, tp;
    private static short[][] dp;

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
            s = in.next().toCharArray();
            t = in.next().toCharArray();
            n = s.length;
            m = t.length;
            sp = new int[2][n + 2];
            tp = new int[2][m + 2];
            dp = new short[n + 2][m + 2];
            sp[0][n] = sp[1][n] = n;
            tp[0][m] = tp[1][m] = m;

            // 不可能な遷移先
            sp[0][n + 1] = sp[1][n + 1] = n + 1;
            tp[0][m + 1] = tp[1][m + 1] = m + 1;
            // とり尽くした
            sp[0][n] = sp[1][n] = n + 1;
            tp[0][m] = tp[1][m] = m + 1;
            // 通常遷移
            for (int i = n - 1; i >= 0; i--) {
                for (int j = 0; j < 2; j++) sp[j][i] = sp[j][i + 1];
                sp[s[i] - '0'][i] = i + 1;
            }
            for (int i = m - 1; i >= 0; i--) {
                for (int j = 0; j < 2; j++) tp[j][i] = tp[j][i + 1];
                tp[t[i] - '0'][i] = i + 1;
            }


            int len = dp(0, 0);
            //Arrays.stream(dp).map(Arrays::toString).forEach(System.out::println);
            int i = 0, j = 0;
            StringBuilder ans = new StringBuilder();
            for (int k = 0; k < len; k++) {
                if (dp(sp[0][i], tp[0][j]) <= dp(sp[1][i], tp[1][j])) {
                    i = sp[0][i];
                    j = tp[0][j];
                    ans.append('0');
                } else {
                    i = sp[1][i];
                    j = tp[1][j];
                    ans.append('1');
                }
            }
            out.println(ans.toString());
        }
    }

    private static short dp(int i, int j) {
        if (i == n + 1 && j == m + 1) return 0;
        if (dp[i][j] > 0) return dp[i][j];
        short res = Short.MAX_VALUE;
        for (int k = 0; k < 2; k++) {
            int di = sp[k][i], dj = tp[k][j];
            short t = dp(di, dj);
            if (t < res) res = t;
        }
        res++;
        return dp[i][j] = res;
    }
}


Measured memory_bytes: 89160
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+9;
int idx[MAX]={0};
void init(){
	int i;
	for(i=0;i<MAX;i++)
		idx[i]=i;
}
int findroot(int i){
	while(i!=idx[i])
		i=idx[i];
	return i;
}
void munion(int u ,int v){
	u=findroot(u);
	v=findroot(v);
	if(u!=v)
		idx[v]=u;
}
int main(){
	int i ,j ,n ,m;
	cin>>n>>m;
	init();
	while(m--){
		int x ,y;
		cin>>x>>y;
		munion(x ,y);
	}
	int q;
	cin>>q;
	while(q--){
		int  u ,v;
		cin>>u>>v;
		u=findroot(u);
		v=findroot(v);
		if(u==v)
			cout<<"yes"<<"\n";
		else
			cout<<"no"<<"\n";
	}
}


Measured memory_bytes: 3484
import math
n = int(input())
res = [1]
last = -1
for i in range(1, n):
    for c in range(2, n):
        num = pow(i, c)
        if num == last:
            break
        if num <= n:
            res.append(num)
        else:
            break
        c+= 1
        last = num
print(max(res))

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

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

  vector<int> a(n);
  rep(i,n) cin >> a.at(i);

  int ans=0;
  int r=0;
  
  sort(a.begin(), a.end());
  
  rep(l,n){
    int left = a.at(l);
    while(r<n&&a.at(r)<=left+2){
      r++;
    }
    ans = max(ans, r-l);
  }

  cout << ans;
}

Measured memory_bytes: 3768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
const int N=1e5+5;
int n,nval,xval,val[N];

inline int nxi(){
	int x=0;
	char c;
	while(((c=getchar())>'9'||c<'0')&&c!='-');
	const bool f=(c=='-')&&(c=getchar());
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return f?-x:x;
}

bool solve(){
	if(xval==nval) return xval==n-1||xval<=n>>1;
	if(xval-nval>1) return 0;
	int clow=0;
	for(int i=1; i<=n; ++i){
		clow+=val[i]==nval;
	}
	if(clow>=xval) return 0;
	if(clow+((n-clow)>>1)<xval) return 0;
	return 1;
}

int main(){
	n=nxi();
	for(int i=1; i<=n; ++i){
		val[i]=nxi();
		nval=i==1?val[i]:std::min(nval,val[i]);
		xval=i==1?val[i]:std::max(xval,val[i]);
	}
	puts(solve()?"Yes":"No");
	return 0;
}


Measured memory_bytes: 640
#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(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll n;
    cin >> n;
    vector<ll> data(n);
    rep(i, n) cin >> data[i];

    sort(data.begin(), data.end());

    ll min, max, sum;
    min = data.front();
    max = data.back();
    sum = accumulate(data.begin(), data.end(), 0LL);

    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3252
x, y = map(int, input().split())
s = 0
if x == 3:
    s += 100000
if x == 2:
    s += 200000
if x == 1:
    s += 300000
if y == 3: 
    s += 100000
if y == 2:
    s += 200000
if y == 1:
    s += 300000
if x == 1 and y == 1:
    s += 400000
print(s)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Enum various numbers
//-------------------------------------------------
namespace Enum
{
    using fint = ::std::int_fast64_t;
    //素因数分解(素因数列挙)
    ::std::map<fint,int> factor(fint n)
    {
        ::std::map<fint,int> ret;
        for(fint i=2; i*i<=n; i++){
            while(n%i==0){
                ret[i]++;
                n/=i;
            }
        }
        if (n!=1) ret[n]++;
        return ret;
    }
    //約数列挙
    ::std::vector<fint> divisor(fint n)
    {
        ::std::vector<fint> ret;
        for(fint i=1; i*i<=n; i++){
            if (n%i==0){
                ret.push_back(i);
                if (i*i!=n) ret.push_back(n/i);
            }
        }
        return ret;
    }
    //商列挙(割る最小の数と商のペア)
    ::std::vector<::std::pair<fint,fint> > quotient(fint n)
    {
        ::std::vector<::std::pair<fint,fint> > ret;
        fint i=0;
        for(i=1; i*i<=n; i++){
            ret.emplace_back(i,n/i);
        }
        for(; i<=n; i++){
            fint d = n/i;
            ret.emplace_back(i,d);
            i+=(n-d*i)/d;
        }
        return ret;
    }
    //素数判定(おまけ)
    bool isprime(fint n)
    {
        for(fint i=2; i*i<=n; i++){
            if (n%i==0) return false;
        }
        return true;
    }
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin>>n;
    auto div = Enum::divisor(n-1);
    ll ans=div.size()-1;
    div = Enum::divisor(n);
    for(auto e:div){
        if (e==1) continue;
        ll m=n;
        while(m%e==0) m/=e;
        if (m%e==1) ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 384
import           Control.Monad
import           Data.List
import           Debug.Trace

main :: IO ()
main = do
  n <- readLn :: IO Int
  ss <- replicateM n $ head <$> getLine
  print $ solve ss

solve ss = let ss' = filter (\a -> head a `elem` "MARCH")
                 $ groupBy (==) $ sort ss
               xs = filter ((== 3) . length) $ f ss'
           in
             sum $ map product xs

f [] = []
f [x] = [[length x], []]
f (h:t) = let ts = f t
          in (map (length h :) ts) ++ ts


Measured memory_bytes: 49916
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

void dijk(vector<ll> v[], ll n, ll x,vector<ll> &dis)
{
    set<pair<ll,ll>> st;
    //vector<ll> dis(n,INF);
    
    st.insert(mp(0,x));
    dis[x] = 0;
    
    while(st.size() > 0)
    {
        ll temp = st.begin()->second;
        st.erase(st.begin());
        
        for(auto it = v[temp].begin();it!=v[temp].end();it++)
        {
            ll v1 = *it;
            ll wt = 1;
            
            if(dis[v1]>dis[temp] + wt)
            {
                dis[v1] = dis[temp] + wt;
                st.insert(mp(dis[v1],v1));
            }
        }
    }
    
}

int main()
{
   FAST/**/
   
   ll n,x,y;
   cin>>n>>x>>y;
   ll dis[n][n];
   x--,y--;
   vector<ll> v[n];
   rep(n-1)
   {
       v[i].pb(i+1);
       v[i+1].pb(i);
   }
   
   v[x].pb(y);
   v[y].pb(x);
   
   rep(n)
   {
       vector<ll> dis1(n,inf);
       dijk(v,n,i,dis1);
       repi(j,n)
            dis[i][j] = dis1[j];
   }
   
   map<ll,ll> ma;
   rep(n)   
        for(ll j=i+1;j<n;j++)
            ma[dis[i][j]]++;
   
   for(ll k=1;k<=n-1;k++)
   {
       cout<<ma[k]<<"\n";
   }
               
   return 0;        
}  
   

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

using namespace std;

const int mod = 1e9 + 7;

int main()  {
    int n;
    cin >> n;
    
    n *= 2;
    
    string s;
    cin >> s;
    
    if (s[0] == 'W') return cout << "0\n", 0;
    
    vector< int> dat(n);
    for (int i = 0; i < n; i ++) dat[i] = (s[i] == 'B'? 1 : 0);
    
    int result = 1;
    int cnt = 0;
    
    for (int i = 0; i < n; i ++) {
        if (dat[i] != cnt % 2) {
            cnt ++;
        }
        else {
            result = result * 1LL * cnt % mod;
            cnt --;
        }
        if (cnt < 0) return cout << "0\n", 0;
    }
    if (cnt != 0) return cout << "0\n", 0;
    
    int fact = 1;
    for (int i = 2; i <= n / 2; i ++) fact = fact * 1LL * i % mod;
    result = result * 1LL * fact % mod;
    cout << result << endl;
}

Measured memory_bytes: 1412
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

DP = [0 for i in range(10**4+1)] #DP[h]=体力hのやつを倒す最小mp
#DPのrangeを大きくとることで後々計算が簡単になる

for h in range(1,H+1):
    DP[h] = min((DP[h - a] + b) for a,b in AB )
    #注：h - a < 0の場合もある.
    #　　この場合 -(h - a) >= len(DP) のときにout of rangeになる
    #これを防ぐにはlen(DP)を十分大きくしておけばいい
    #h - a < 0 のときはDP[h-a] = 0に初期化しておくとbだけが消費mpになる

print(DP[H])


Measured memory_bytes: 3644
#include <stdio.h>

int main(void) {

  int h,w;
  scanf("%d %d", &h, &w);
  int a[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int odd_list[h*w][3];
  int list_number = -1;
  int cur = -1;
  for (int i = 0; i < h; i++) {
    if (i%2 == 0) {
      for (int j = 0; j < w; j++) {
        cur++;
        if (a[i][j]%2 == 1) {
          list_number++;
          odd_list[list_number][0] = i;
          odd_list[list_number][1] = j;
          odd_list[list_number][2] = cur;
        }
      }
    } else {
      for (int j = w-1; j >= 0; j--) {
        cur++;
        if (a[i][j]%2 == 1) {
          list_number++;
          odd_list[list_number][0] = i;
          odd_list[list_number][1] = j;
          odd_list[list_number][2] = cur;
        }
      }
    }
  }
  int end = list_number;
  int operation = 0;
  for (int i = 1; i <= end; i += 2) {
    operation += odd_list[i][2]-odd_list[i-1][2];
  }
  printf("%d\n", operation);
  int y,x;
  int y_,x_;
  for (int i = 1; i <= end; i += 2) {
    y = odd_list[i-1][0];
    x = odd_list[i-1][1];
    while (1) {
      if (y%2 == 0) {
        if (x != w-1) {
          y_ = y;
          x_ = x+1;
        } else {
          y_ = y+1;
          x_ = w-1;
        }
      } else {
        if (x != 0) {
          y_ = y;
          x_ = x-1;
        } else {
          y_ = y+1;
          x_ = 0;
        }
      }
      printf("%d %d %d %d\n", y+1,x+1,y_+1,x_+1);
      if (y_ == odd_list[i][0] && x_ == odd_list[i][1]) {
        break;
      }
      y = y_;
      x = x_;
    }
  }

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p.at(i);
    }
    int ans = 0;
    for(int i=1; i<n-1; i++){
        if(p.at(i-1)<p.at(i)){
            if(p.at(i)<p.at(i+1)){
                ans += 1;
            }
        }
        else if(p.at(i-1)>p.at(i)){
            if(p.at(i)>p.at(i+1)){
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#![allow(unused)]

use std::{cell, cmp, collections, fmt, ops};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use fmt::{Debug, Display};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[cfg(feature = "debug")]
macro_rules! dbg {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! dbgln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! dbg {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! dbgln {
    ($($args:tt)*) => {};
}

mod num {
    //
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

mod bits {
    pub fn is_high(bits: u64, pos: u64) -> bool {
        bits & (1 << pos) != 0
    }
}

fn main() {
    input!(
        box_num: usize,
        child_num: usize,
        candy_num: [usize; box_num]
    );

    // prefix_sum[0] = 0,
    // prefix_sum[i] = candy_num[0] + ... + candy_num[i - 1]
    let mut prefix_sum = 0;

    // Number of i s.t. prefix_sum[i] % child_num == key
    let mut mod_cnt = HashMap::new();
    mod_cnt.insert(0, 1);

    let mut ans = 0_usize;
    for candy in candy_num {
        prefix_sum += candy;
        let entry = mod_cnt.entry(prefix_sum % child_num).or_insert(0);
        ans += *entry;
        *entry += 1;
    }

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

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 14588
/* AtCoder My Practice
 * author: Leonardone @ NEETSDKASU
 */
#include <stdio.h>
#include <stdlib.h>

#define N_MAX (200001)

typedef struct _range {
    int upper, lower;
    struct _range *ubound, *lbound;
} Range;

Range *newRange(int lower, int upper) {
    Range *range = (Range*)malloc(sizeof(Range));
    range->lower = lower;
    range->upper = upper;
    return range;
}

int idx[N_MAX];
long long sum;
Range range;

void calc(int value, register int index) {
    register Range *tmp = &range;
    long long len1, len2, len3;
    for (;;) {
        if (tmp->lower <= index && index <= tmp->upper) {
            len1 = (long long)(tmp->upper - tmp->lower + 1);
            len2 = (long long)(tmp->upper - index);
            len3 = (long long)(index - tmp->lower);
            sum += (len1 * (len1 + 1LL) - (len2 * (len2 + 1LL)) - (len3 * (len3 + 1))) / 2LL * (long long)value;
            if (tmp->lower == index) {
                tmp->lower++;
            } else if (tmp->upper == index) {
                tmp->upper--;
            } else {
                tmp->lbound = newRange(tmp->lower, index - 1);
                tmp->ubound = newRange(index + 1, tmp->upper);
                tmp->lower = tmp->upper = index;
            }
            break;
        } else if (index < tmp->lower) {
            tmp = tmp->lbound;
        } else {
            tmp = tmp->ubound;
        }
    }
}

char buf[N_MAX * 10];
char *x = buf;

int getInt(void) {
    register char *p = x;
    register int v = 0;
    while (*p < '0' || '9' < *p) p++;
    while ('0' <= *p && *p <= '9') {
        v = v * 10 + (int)(*p - '0');
        p++;
    }
    x = p;
    return v;
}

int main(void){
    register int i, n;
    int a;
    
    a = fread(buf, sizeof(char), sizeof(buf), stdin);
    
    n = getInt();

    for (i = 0; i < n; i++) {
        a = getInt();
        idx[a] = i;
    }
    
    range.upper = n - 1;
    
    for (i = 1; i <= n; i++) {
        calc(i, idx[i]);
    }
    
    printf("%lld\n", sum);

    return 0;
}


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

int main(void)
{
	int n;
	char buf[256];
	
	while (1){
		scanf("%d", &n);
		
		if (n == -1) break;
		
		int i = 0;
		do {
			buf[i++] = (n % 4) + '0';
			n /= 4;
		} while (n != 0);
		buf[i] = '\0';
		char out[256];
		for (int j = 0; j < i; j++){
			out[j] = buf[i - j - 1];
		}
		out[i] = '\0';
		
		printf("%s\n", out);
	}
	
	return (0);
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
import queue
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Prim(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = list(set(V))

    used = set([])
    q = []
    heapq.heappush(q, (0, V[0]))

    ret = 0
    while q:
        c, v = heapq.heappop(q)

        if v in used:
            continue
        used.add(v)
        ret += c
        for u in g[v]:
            heapq.heappush(q, (g[v][u], u))
    return ret


@mt
def slv(S):
    even = len(S) % 2 == 0
    hte = S[0] == S[-1]
    if even != hte:
        return 'Second'
    return 'First'


def main():
    S = read_str()

    print(slv(S))


if __name__ == '__main__':
    main()


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

int main(void){
  int a[200000],q,index=0,i;
  char str[16];

  fgets(str,sizeof(str),stdin);
  q=atoi(str);

  while(q-->0){
    fgets(str,sizeof(str),stdin);
    if(str[0]=='0'){ a[index]=atoi(str+2); index++; }
    else if(str[0]=='1'){ i=atoi(str+2);  printf("%d\n",a[i]); }
    else{ index--; }//str[0]=='2'
  }

  return 0;
}



Measured memory_bytes: 2560
N, M = list(map(int, input().split()))
nums = [list(map(int, input().split())) for i in range(M)]
if [1, 0] in nums and N==1:
  print('0')
  quit()
if [1, 0] in nums:
  print('-1')
  quit()
dic = {}
 
for (s, c) in nums:
  if s in dic and dic[s] != c:
    print('-1')
    quit()
  else:
    dic[s] = c
if N == 1:
  total = 0
else:
  total = 10**(N-1)    
for key in sorted(dic.keys()):
    if key == 1:
   		total = 10**(N-key)*dic[key]
    else:
        total += 10**(N-key)*dic[key]
print(total)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
  string s,t; cin>>s>>t;
  
  string r=t.substr(0,s.length());
  
  if(s==r) cout<<"Yes";
  else cout<<"No";
  
  
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

	int watch = 2 * D + 1;
	int n = (N + (watch - 1)) / watch;
	cout << n << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007

#define ARRAY_MAX 105


int main(){

    ll n,w,ans = 0;
    cin >> n >> w;
    vector<ll> weight(n),value(n);
    vector<ll> cnt(4,0);//重さ
    vector<ll> v[4];//価値

    REP(i,4){
        cnt[i] = 0;
    }

    REP(i,n){
        cin >> weight[i] >> value[i];
        cnt[weight[i]-weight[0]]++;//各重さの品物が何個あるか数える
        v[weight[i]-weight[0]].push_back(value[i]);//各重さの品物の価値を求める
    }

    sort(v[0].begin(),v[0].end(),greater<ll>());
    sort(v[1].begin(),v[1].end(),greater<ll>());
    sort(v[2].begin(),v[2].end(),greater<ll>());
    sort(v[3].begin(),v[3].end(),greater<ll>());
    //価値の高いものから使う

    REP(a,cnt[0]+1){
        REP(b,cnt[1]+1){
            REP(c,cnt[2]+1){
                REP(d,cnt[3]+1){

                    ll w_sum = 0;
                    ll weight_mini = weight[0];
                    w_sum += a*weight[0] + b*(weight[0]+1) + c*(weight[0]+2) + d*(weight[0]+3);
                    if(w_sum > w){
                        //重さの制約を満たしていない
                        continue;
                    }
                    ll value_sum = 0;
                    REP(i,a){
                        value_sum += v[0][i];
                    }
                    REP(i,b){
                        value_sum += v[1][i];
                    }
                    REP(i,c){
                        value_sum += v[2][i];
                    }
                    REP(i,d){
                        value_sum += v[3][i];
                    }
                    ans = max(ans,value_sum);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

ac_cnt = 0
wa_cnt = 0
d = {}

for _ in range(m):
  p, s = input().split()
  if p not in d:
    d[p] = [s]
  else:
    d[p].append(s)
    
for i in d:
  if 'AC' in d[i]:
    ac_cnt += 1
    wa_cnt += d[i].index('AC')
print(ac_cnt, wa_cnt)

Measured memory_bytes: 34668
#include<stdio.h>

int main(void){
    unsigned char a,b,c,d,e,f;
    scanf("%c%c%c%c%c%c\n",&a,&b,&c,&d,&e,&f);
    if((c==d) && (e==f)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using  namespace std;


int main (void) {

    int x, a, b;

    cin >> x >> a >> b;
    
    if (b - a <= 0){
        cout << "delicious" << endl;
    }else if (b - a >= x + 1) {
        cout << "dangerous" << endl;
    }else if (b - a <= x ){
        cout << "safe" << endl;
    }

    return 0;
}


Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	long long n, m, d;
	cin >> n >> m >> d;

	if (d > 0) {
		printf("%.10f\n", (double)(m - 1) * 2 * (n - d) / (n*n));
	}
	else {
		printf("%.10f\n", (double)(m - 1) / n);
	}

	return 0;
}

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

int bucket[55];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		bucket[a-1]++;
		bucket[b-1]++;
	}
	for(int i = 0; i < n; i++)
		printf("%d\n", bucket[i]);
}


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

int main() {
  string N;
  cin >> N;
  long long A = N.size();
  long long count = 0;
  for (long long i = 0; i < A; i++){
    count += N[i] - '0';
  }
  if (count % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3748
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

//abc163

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int r;
    cin>>r;
    cout<<FS<<(double)2*M_PI*r<<endl;
}//言語C++を選択！！

//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 3780
#include <iostream>
using namespace std;
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0||c>0)
  {
      c=c-b;
      a=a-d;
      if(c<=0)
      {
        cout<<"Yes";
        break;
      }
      else if(a<=0)
      {
        cout<<"No";
        break;
      }
  }
  return 0;
}


Measured memory_bytes: 3584
def main():
    s = int(input())
    N = 10**9

    y2 = 1
    y3 = s // N + 1
    x3 = N - s % N
    if y3 == N+1:
        y2 = 0
        y3 = N
        x3 = N
    
    print("0 0 1000000000 {} {} {}".format(str(y2),str(x3),str(y3))) 

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <cstdio> 
#include <iostream> 
using namespace std;
typedef long long ll;            //>10^18
typedef long double ld;          //3.3621e-4932 ~ 1.18937e4932
typedef unsigned long long ull;  //>10^20
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;  
int n;
ll a[MAXN];
ll s[MAXN] = {0};
int main(int argc, char *argv[]){
	scanf("%ull", &n);
	ll cnt = 0;
	for(int i = 1; i <= n; i++){
		scanf("%lld", &a[i]);
		cnt += a[i];
	}
	for(int i = 1; i <= n; i++){
		s[i] = cnt - a[i];
		cnt -= a[i];
	} 
	int ans = 0, cot;
	for(int i = 1; i <= n; i++){
		cot = ((a[i] % MOD) * (s[i] % MOD)) % MOD;
		ans = ((ans % MOD) + (cot % MOD)) % MOD;
	} 
	cout << ans;
	return 0;
}

Measured memory_bytes: 6812
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;

ll n, x, mas[2000005];

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i < n; i ++)
    {
        cin >> x;
        mas[x] ++;
    }
    for (int i = 1; i <= n; i ++)
        cout << mas[i] << endl;
    return 0;
}


Measured memory_bytes: 5224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;cin>>n;
  double x[n];string s[n];
  double ans=0;
  for(int i=0;i<n;i++){
    cin>>x[i]>>s[i];
    if(s[i]=="JPY")ans+=x[i];
    else ans+=x[i]*380000;
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 256
def test(X, Y): 
  x = (4*X - Y) / 2
  y = (Y - 2*X) / 2
  
  if (x >= 0 and x % 1 == 0 and
     y >= 0 and y % 1 == 0):
      print('Yes')
  else:
    print('No')
  
X, Y = input().split()
test(int(X), int(Y))

Measured memory_bytes: 61908
#include <iostream>
#include <array>

int
main ()
{
    std::array<std::array<int, 10>, 10> m = {};

    int n;
    std::cin >> n;

    for (int i = 1; i <= n; ++i) {
      int begin_degit = [](int i){
        while ( 10 <= i ) i /= 10;
        return i;
      }(i);
      int end_digit = i % 10;
      m[begin_degit][end_digit]++;
    }
    int answer = 0;
    for (int k = 0; k < 10; ++k) {
      int sum_k = 0;
      for (int l = 0; l < 10; ++l) {
        sum_k += m[k][l] * m[l][k];
      }
      answer += sum_k;
    }
    // answer = tr(m * m);

    std::cout << answer << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

int c[10][10];
int main(){
	int T;
	while(1){
		int N;
		cin >> N;
		int S = 0;
		
		for(int i = 0 ; i < N ; i++)
			for(int j = 0 ; j < N ; j++)
				cin >> c[i][j];
	
		int G = 0;
		for(int i = 0 ; i < N ; i++){
				G = G * 10 + i + 1;
		}
		int ten[100] = {};
		ten[0] = 1;
		for(int i = 1 ; i < 10 ; i++) ten[i] = ten[i-1] * 10;
		
		priority_queue< pair<int,int> , vector< pair<int,int> > , greater< pair<int,int> > > Q;
		Q.push( make_pair(0,G) );
		map<int,int> done;
		int ans = 0;

		while(Q.size()){

			pair<int,int> q = Q.top(); Q.pop();
			
			if( done[q.second]++ ) continue;
		
			ans = max( ans , q.first );
			for(int i = 0 ; i < N ; i++){
				for(int j = i+1 ; j < N ; j++){
					int next = q.second;

					int A = q.second / ten[i] % 10;
					int B = q.second / ten[j] % 10;
					
					
					next -= A * ten[i];
					next -= B * ten[j];
					next += A * ten[j];
					next += B * ten[i];
					Q.push(make_pair(q.first+c[i][j],next));
				}
			}
		}
		cout << ans << endl;
		return 0;
	}
}

Measured memory_bytes: 8660
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> l(2*N);
  rep(i,2*N){
    cin >> l[i];
  }
  sort(All(l));
  int ans = 0;
  for(int i=0;i<2*N;i+=2){
    ans += l[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
while True:
  a, op, b=input().split()
  a=int(a)
  b=int(b)
  if op=="?":
    break
  elif op=="+":
    print(a+b)
  elif op=="-":
    print(a-b)
  elif op=="/":
    print(int(a/b))
  elif op=="*":
    print(a*b)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 5e5+10;
int n,S,T,a[N],b[N],cnt,id[2][N];
poly v1[N],v2[N];
map<int,int>f,g;

namespace Flow{
	int n,tot=-1,first[N],to[N<<1],flow[N<<1],last[N<<1];
	inline void add(int x,int y,int z){to[++tot]=y,flow[tot]=z,last[tot]=first[x],first[x]=tot;}
	inline void Add(int x,int y,int z){
		add(x,y,z),add(y,x,0);
	}
	int hd,tl,q[N],deep[N];
	inline bool bfs(int s,int t){
	    For(i,1,n) deep[i]=0;
	    hd=0,q[tl=1]=s,deep[s]=1;
	    while (hd<tl){
	    	int u=q[++hd];
			for (int i=first[u];i!=-1;i=last[i]) if (!deep[to[i]]&&flow[i]) deep[q[++tl]=to[i]]=deep[u]+1;
		}
	    return deep[t];
	}
	int cur[N];
	inline void init(){For(i,1,n) cur[i]=first[i];}
	inline int dfs(int u,int t,int dist){
	    if (u==t||!dist) return dist;
		int Flow=0,f;
	    for (int i=cur[u];i!=-1;i=last[i]){
	        cur[u]=i;
	        if (deep[to[i]]==deep[u]+1&&(f=dfs(to[i],t,min(dist,flow[i])))){
	            dist-=f,Flow+=f,flow[i]-=f,flow[i^1]+=f;
	            if (!dist) break;
	        }
	    }
	    return Flow;
	}
	const int inf = 1e9;
	inline int Dinic(int s,int t){
		int ans=0;
		while (bfs(s,t)) init(),ans+=dfs(s,t,inf);
		return ans;
	}
}

int main(){
	n=read();
	For(i,1,n) a[i]=read()+1;
	For(i,1,n) b[i]=read()+1;
	int ans=n;
	For(i,1,n){
		if (a[i]==b[i]&&a[i]==i) --ans,id[0][i]=id[1][i]=-1;
	}
	fil(Flow::first,-1),S=1,T=2,cnt=2;
	For(i,1,n) if (!id[0][i]){
		++cnt;
		int tot=0;
		for (int j=i;!id[0][j];j=a[j]){
			id[0][j]=cnt;
			if (b[j]==j) ++tot;
			v1[cnt].pb(j);
		}
		Flow::Add(S,cnt,tot);
		Flow::Add(cnt,T,0);
	}
	int cnt1=cnt;
	For(i,1,n) if (!id[1][i]){
		++cnt;
		int tot=0;
		for (int j=i;!id[1][j];j=b[j]){
			id[1][j]=cnt;
			if (a[j]==j) ++tot; 
			v2[cnt].pb(j);
		}
		Flow::Add(cnt,T,tot);
		Flow::Add(S,cnt,0);
	}
	Flow::n=cnt;
	For(i,1,cnt1){
		f.clear(),g.clear();
		for (auto j:v1[i]){
			if (a[j]==b[j]) f[id[1][j]]++;
			g[id[1][j]]++;
		}
		for (auto j:f) Flow::Add(i,j.fi,j.se);
		for (auto j:g) Flow::Add(j.fi,i,j.se);
	}
	printf("%d\n",ans-Flow::Dinic(S,T));
}

Measured memory_bytes: 43992
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int n;
	cin>>n;
	int s=n/500*1000;
	n%=500;
	s+=n/5*5;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_ ; ++i)
#define drep(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_ ; --i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 3) + (x << 1) + (ch - 0x30);
		ch = getchar();
	}
	return flag * x;
}
 
#define Maxn 5009
int n, a[Maxn], b[Maxn], m;
LL ans;
int main() {
	n = read(), m = read();
	rep(i, 1, n) a[i] = read();
	clear(b, 0x3f);
	LL ans = LLONG_MAX;
	rep(i, 0, n) {
		LL _buff = 0;
		rep(j, 1, n) {
			int tmp = (j - (i + 1) + n) % n + 1;
			b[j] = min(b[j], a[tmp]); 
			//printf("%d %d -> %d\n", j, i, tmp);
			_buff += b[j];
		}
		ans = min(_buff + 1ll * i * m, ans);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int grade[200000];

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);

    for (int i = 0; i < n; ++i)
        scanf("%d", grade+i);
    
    for (int i = k; i < n; ++i)
    {
        if (grade[i-k] < grade[i])
            printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

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

    int shinsu = -2;
    int s = n;
    int amari = 0;
    string ret = "";

    if (s)
    {
        while (s)
        {
            ret = to_string(s & 1) + ret;
            s -= s & 1;
            s /= shinsu;
        }
        cout << ret << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


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

int64_t mod = 998244353 ;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


vector<int> getprime(int n){
    vector<int> p(0) ;
    vector<bool> table(n+1,0) ;
    for (int i = 2; i <= n; i++)
    {
        if (table.at(i) == 0)
        {
            p.push_back(i) ;
            for (size_t j = 2; j < n/i ; j++)
            {
                table.at(i*j) = 1 ;
            }
            
        }
        
    }
    return p ;
}

int main(){
    int n,m ;
    cin >> n >> m ;
    vector<int> menu(m,0) ;
    int k,a ;
    for (int i = 0; i < n; i++)
    {
        cin >> k ;
        for (int j = 0; j < k; j++)
        {
            cin >> a ;
            menu.at(a-1) ++ ;
        }
        
    }
    
    int ans = 0 ;
    for (int i = 0; i < m; i++)
    {
        if (menu.at(i) == n)
        {
            ans ++ ;
        }
        
    }
    
    cout << ans << endl ;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1<<20;

int n;
vector<pair<int, int>> adj[10005];


void dijkstra(){
    priority_queue<pair<int, int>> PQ;
    bool visited[n];
    int d[n];

    for(int i=0; i<n; i++){
        visited[i] = false;
        d[i] = INF;
    }

    PQ.push({0, 0});
    d[0] = 0;

    while(!PQ.empty()){

        pair<int, int> p = PQ.top(); PQ.pop();
        int u = p.second;

        visited[u] = true;

        if(d[u] < p.first * (-1)) continue;
        
        for(int i=0; i<adj[u].size(); i++){
            int v = adj[u][i].first;
            if(visited[v] == false && d[v] > d[u] + adj[u][i].second){
                d[v] = d[u] + adj[u][i].second;
                PQ.push({d[v] * (-1), v});
            }
        }
    }

    for(int i=0; i<n; i++){
        printf("%d %d\n", i, d[i]);
    }

}

int main(void){
    cin >> n;
    for(int i=0; i<n; i++){
        int u, k; cin >> u >> k;
        for(int j=0; j<k; j++){
            int v, c; cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();
}


Measured memory_bytes: 8216
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 60);
const int INf = 1e9;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}
const ll MOD = 1000000007; int ans =0;
int main() {
    string s; cin >> s; int cnt = 0;
    rep(i, s.size()) {
        if (s[i] == 'p') cnt++;
    }cout << s.size() / 2 - cnt << endl;
}

Measured memory_bytes: 512
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    long a, b;
    readf("%s %s", &a, &b);
    readln;
    
    auto g = gcd(a, b);
    
    long[] ans;
    ans ~= 1;
    
    long k = 2;
    while (k <= g / k) {
        if (g % k == 0) {
            ans ~= k;
            while (g % k == 0) { g /= k; }
        }
        
        ++k;
    }
    
    if (g > 1) { ans ~= g; }
    
    debug { ans.writeln; }
    
    ans.length.writeln;
}

Measured memory_bytes: 256
(defun main ()
  (let ((n (read))
        (s1 (read))
        (s2 (read)))
    (declare (ignore n))
    (loop :for c1 :across (string s1)
          :for c2 :across (string s2)
          :do (format t "~(~C~C~)" c1 c2))
    (terpri)))

(main)



Measured memory_bytes: 12772
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int N, X, Y;

int dist(int a, int b){
	return min(min(abs(b-a), abs(X-a)+1+abs(b-Y)),abs(Y-a)+1+abs(b-X));
}
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> N >> X >> Y;
	vector<int> ans(N-1, 0);
	for (int i = 0; i < N-1; i++)
	{
		for (int j = i+1; j < N; j++)
		{
			int tmp = dist(i+1, j+1);
			ans[tmp-1]++;
		}
	}
	for (int i = 0; i < N-1; i++)
	{
		cout << ans[i] <<endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;


int main(){
   int N,M,C;
   cin >> N >> M >> C;
   int B[M];
   for(int i=0;i<M;i++) cin >> B[i];
   int ans =0;
   for(int i=0; i<N; i++){
      int S=C;
      for(int j=0;j<M; j++){
         int A;
         cin >> A;
         S+=A*B[j];
      }
      if(S>0) ans++;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#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;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(int a, int b, int mod) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int a[200005];


void solve()
{
int n;
cin>>n;
multiset<int,greater<int>>s;
fr(i,1,n)
 { int d; cin>>d; s.insert(d); a[i]=d;}

  fr(i,1,n)
 {
    
     if(a[i]==*s.begin())
     {
         auto it=s.begin();
         s.erase(it);
         cout<<*s.begin()<<endl;
         s.insert(*it);
     }
     else
        cout<<*s.begin()<<endl;
 }

}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	fr(i,1,t) {
		solve();
	}
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}





Measured memory_bytes: 12544