akhauriyash/Code-Regression huggingface dataset:
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

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

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

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

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	H := readInt()
	W := readInt()
	S := make([][]byte, H)
	for i := range S {
		S[i] = readBytes()
	}
	hp := make([][]int, H)
	for i := range hp {
		hp[i] = make([]int, W)
		for j := 0; j < W; {
			for j < W && S[i][j] == '#' {
				j++
			}
			k := j
			for k < W && S[i][k] == '.' {
				k++
			}
			v := k - j
			for ; j < k; j++ {
				hp[i][j] = v
			}
		}
	}

	wp := make([][]int, H)
	for i := range wp {
		wp[i] = make([]int, W)
	}

	for i := 0; i < W; i++ {
		for j := 0; j < H; {
			for j < H && S[j][i] == '#' {
				j++
			}
			k := j
			for k < H && S[k][i] == '.' {
				k++
			}
			v := k - j
			for ; j < k; j++ {
				wp[j][i] = v
			}
		}
	}

	var ans int
	for i := range S {
		for j := range S[i] {
			ans = max(ans, hp[i][j]+wp[i][j]-1)
		}
	}
	println(ans)
}

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


Measured memory_bytes: 72576
#include<bits/stdc++.h>
using namespace std;
int n,k=2,a[100001],dp[100001];
int main()
{
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        dp[i] = 1e9;
        cin >> a[i]; if(i==1){ dp[i] = 0; continue; }
        for(int j=1; j<=k; j++) if(i - j > 0)dp[i] = min(dp[i],dp[i-j] + abs(a[i] - a[i-j]));
    }
    cout << dp[n];
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
const int MOD = 1000000007;

vector<vector<int> > edge(100000);
// true = white, false = black
vector<vector<long long> > dp(100000, vector<long long>(2, 0));
vector<bool> used(100000, false);
void dfs(int par, int ver) {
  if (used[ver]) return;
  used[ver] = true;
  long long black = 1, white = 1;
  for (int e : edge[ver]) if (e != par) {
    dfs(ver, e);
    (black *= dp[e][true]) %= MOD;
    (white *= (dp[e][true] + dp[e][false]) % MOD) %= MOD;
  }
  dp[ver][false] = black;
  dp[ver][true] = white;
}

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

  int n; cin >> n;
  REP(i, n-1) {
    int x, y; cin >> x >> y;
    --x;
    --y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  dfs(-1, 0);
  cout << (dp[0][true] + dp[0][false]) % MOD << '\n';
  return 0;
}


Measured memory_bytes: 18176
#include<stdio.h>
#include<math.h>
int main()
{
	int a[10][10],n,d,m=0;
	double b;
	scanf("%d%d",&n,&d);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			b=0;
			for(int k=0;k<d;k++)
			{
				b=b+pow(a[i][k]-a[j][k],2);
			}
			b=sqrt(b);
			if(b-int(b)==0)
			m++;
		}
	}
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 100000
int n,k;
long long T[MAX];
int check(long long p){
	int i=0;
	for(int j=0;j<k;j++){
		long long s = 0;
		while(s+T[i]<=p){
			s += T[i];
			i++;
			if(i==n) return n;
		}
	}
	return i;
}
int solve(){
	long long left = 0;
	long long right = MAX*10000;
	long long mid;
	while(left<right-1){
		mid = (right+left)/2;
		if(check(mid)==n){
			right = mid;
		}else{
			left = mid;
		}
	}
	return right;
}

int main(void){
	cin >> n >> k;
	for(int i=0;i<n;i++) cin >> T[i];
	long long ans = solve();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3876
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int a = scanner.nextInt();
        if(x < a) {
        	System.out.println(0);
        } else {
        	System.out.println(10);
        }
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,d,min;
  cin>>n>>d;
  if(n%(2*d+1)==0){
    min=(n/(2*d+1));
  }else{
    min=(n/(2*d+1))+1;
  }
  cout<<min<<endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())

l = [0] * (N + 1)
l[0] = 2
l[1] = 1

for i in range(N + 1):
    if i == 0 or i == 1:
        continue
    else:
        l[i] = l[i - 2] + l[i - 1]

print(l[N])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int n,k;
  cin>>n>>k;
  long long int num;
  num=n%k;
  if(num!=0){
     
  while(true){
    if(num<=k/2){
      break;
    }
    num=abs(num-k);
   
 
  }
  }
  cout<<num<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
    int a,b,c,x;
    int ans = 0;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(x == i*500+j*100+k*50){
                    ans++;
                }
            }
        }
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
import bisect

N=int(input())
S=list(input())
Q=int(input())

alphabet="abcdefghijklmnopqrstuvwxyz"
bag={l:[] for l in alphabet}
for i in range(N):
    bag[S[i]].append(i+1)
#print(bag)

for i in range(Q):
    Type,a,b=input().split()
    if Type=='1':
        a=int(a)
        if S[a-1]!=b:
            bag[S[a-1]].remove(a)
            S[a-1]=b
            bisect.insort(bag[b],a)
    else:
        cnt=0
        a,b=int(a),int(b)
        for l in alphabet:
            bl=len(bag[l])
            if bl>0:
                left=bisect.bisect_left(bag[l],a)
                if left!=bl and bag[l][left]<=b:
                        cnt+=1
        print(cnt)

Measured memory_bytes: 104448
#include<iostream>
using namespace std;
int main(){
    char a[105];   
	int u[2]={0};
    cin>>a;
    for(int i=0;i<100;i++){
        if(a[i]=='C') u[0]=1;
        if(a[i]=='F'&&u[0]) u[1]=1;
    }
    if(u[1]) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

using namespace std;


int do_devide(int n, int* a){

  int seccess = 1, i;

  for (i = 0; i < (n-1); i++){
    if (a[i] % 2 == 0){
      a[i] = a[i] / 2;
    } else {
      seccess = 0;
      break;
    }
  }
  return seccess;
}


int main(){

  int n;
  cin >> n;
  int i=0, a[n], l, j=0;

  while (cin >> l) {
      a[i] = l;
      i += 1;
    }

  for (; do_devide(n, a) == 1;){
    j += 1;
  }

  cout << j << "\n";

  return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  ll bis = 1; // ビスケット
  ll yen = 0;
  if (a >= b) {
    bis += (ll) k;
  } else {
    rep(i, k) {
      int r = k - i - 1; // 残り
      if (yen > 0) {
        bis += b;
        yen--;
      } else if (bis >= a) {
        // ビスケットを叩いて増やすより、一旦円に交換してからの方が多いなら交換する
        if (r > 0 && (bis + r + 1) < (bis - a + b + (r - 1))) {
          bis -= a;
          yen++;
        } else {
          bis++;
        }
      } else {
        bis++;
      }
    }
  }
  cout << bis << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    ll ans = LONG_LONG_MIN;
    rep(left, n + 1) {
        rep(right, n - left + 1) {
            ll remain = k - (left + right);
            if (remain < 0) continue;
            priority_queue<ll, vector<ll>, greater<ll>> pq;
            rep(i, left) pq.push(v[i]);
            rep(i, right) pq.push(v[n - 1 - i]);
            ll tmp = 0;
            rep(i, k) {
                if (sz(pq) == 0) break;
                ll v = pq.top(); pq.pop();
                if ((remain > 0) && (v < 0)) {
                    remain--;
                }
                else {
                    tmp += v;
                }
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
int vis[101];
int a[102];
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n 
   int a,b;
   cin>>a>>b;
   cout << a*b << endl;

    return 0;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  char a,b;
  cin >> a >> b;
  if(a == 'H' && b == 'H') cout << "H" << endl;
  else if(a == 'H' && b == 'D') cout << "D" << endl;
  else if(a == 'D' && b == 'H') cout << "D" << endl;
  else cout << "H" << endl;

}

Measured memory_bytes: 3564
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, k] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const dvs = []

for (let i = 1; i <= Math.min(a, b); i++) {
  if (a % i === 0 && b % i === 0) {
    dvs.push(i)
  }
}

console.log(dvs[dvs.length - k])


Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static int Calc(int data1, int data2) {

            int ans = data1 % data2;
            if (ans == 0) { return data2; }

            return Calc(data2, ans);    
        }

        static void Main(string[] args)
        {
            int inputData = int.Parse(Console.ReadLine());
            //string stringData = Console.ReadLine();

            Console.WriteLine(2* Math.PI * inputData);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27612
/*
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const ll INF=20050208;
/*------------main part------------*/



ll num[200005];
string place[200005];
ll beg;
ll pre[200005];
ll en;
ll ans=0;
int main()
{
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>num[i];
	}
	ll sum=num[0];
	for(ll i=0;i<n;i++)
	{
		en++;
		ans+=en-beg;
		if(en>=n)
			break;
		while(sum+num[en]!=(sum^num[en]))
		{
			sum^=num[beg];
			beg++;
		}
		sum^=num[en];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String[] array = s.split(" ");

		int r = Integer.parseInt(array[0]);
		int g = Integer.parseInt(array[1]);
		int b = Integer.parseInt(array[2]);

		int x = (100 * r) + (10 * g) + b;

		if (x % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21204
import java.util.*;

public class Main {
  public static boolean check(int num) {
    int i;
    for(i = 1; i * i <= num; i++) {
      if(i * i == num) return true;
    }
    return false;
  }

  public static void main(String[] args) {
    int i, j, number_l, number_r, ans = 2019;
    Scanner sc = new Scanner(System.in);
    number_l = Integer.parseInt(sc.next());
    number_r = Integer.parseInt(sc.next());
    if(number_r - number_l >= 2019) {
      ans = 0;
    } else {
      for(i = number_l; i <= number_r; i++) {
        if(i % 2019 == 0) {
          ans = 0;
          break;
        }
        for(j = i + 1; j <= number_r; j++) {
          if(ans > ((i % 2019) * (j % 2019)) % 2019) ans = (i % 2019) * (j % 2019) % 2019;
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
N, K = map(int, input().split(' '))
p = list(map(int, input().split()))

psum = []
pini = sum(p[:K])
psum.append(pini)
for i in range(1, N-K+1):
    pini = pini - p[i-1] + p[i+K-1]
    psum.append(pini)
print((max(psum)+K)/2)

Measured memory_bytes: 25060
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
struct _IO { _IO() { ios::sync_with_stdio(false); cin.tie(nullptr); } }_io;
typedef long long ll; typedef long double db;

ll exgcd(ll a, ll b, ll& x, ll& y)
{
	if (!b)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll d = exgcd(b, a % b, x, y);
	ll t = x;
	x = y;
	y = t - (a / b) * y;
	return d;
}
ll getInv(ll a, ll mod)
{
	ll x, y;
	return exgcd(a, mod, x, y) == 1 ? (x % mod + mod) % mod : -1;
}

int main()
{
	string s;
	cin >> s;
	if (s.size() == 1)
	{
		if (s == "s") s.append("es");
		else s.append("s");
		cout << s << endl;
		return 0;
	}

	if (s.substr(s.size() - 1, 1) == "s") s.append("es");
	else s.append("s");
	cout << s << endl;

	return 0;
}

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

int main(){

  ll n, k, s; cin >> n >> k >> s;
  ll out = s+1;
  if(1'000'000'000<out) out = 1;
  for(int i=0; i<n; i++){
    ll p=s;;
    if(k<=i) p = out;
    cout << p << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 1280
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn dfs(n: usize, edges: &[[bool; 50]], visited: &mut [bool], v: usize) {
    visited[v] = true;
    for i in 0..n {
        if edges[v][i] && visited[i] == false {
            dfs(n, edges, visited, i);
        }
    }
}

fn main() {
    input!{
      n: usize,
      m: usize,
      abs: [[usize; 2]; m],
    }

    let mut edges = [[false; 50]; 50];
    for i in 0..m {
        let a = abs[i][0] - 1;
        let b = abs[i][1] - 1;
        edges[a][b] = true;
        edges[b][a] = true;
    }

    let mut ans = 0;
    for i in 0..m {
        let a = abs[i][0] - 1;
        let b = abs[i][1] - 1;

        edges[a][b] = false;
        edges[b][a] = false;

        let mut visited = vec![false; n];
        dfs(n, &edges, &mut visited, 0);

        let mut bridge = false;
        for i in 0..n {
            if visited[i] == false { bridge = true; }
        }
        if bridge { ans += 1; }

        edges[a][b] = true;
        edges[b][a] = true;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string str_t,str_s;
	int x;
	cin >> str_s >> str_t;
	x= str_t.size()-str_s.size();
	str_t.pop_back();
	if(x==1 and str_s==str_t)
		cout << "Yes\n";
	else
		cout <<"No\n";
	return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>

int main(){
	
	int N,Y,i,j;
	scanf("%d %d",&N,&Y);
	
	for(i=0;i<=N;i++){
		for(j=0;j<=N-i;j++){
			if(N-i-j>=0&&10000*i+5000*j+1000*(N-i-j)==Y){
				printf("\n%d %d %d\n",i,j,N-i-j);
				return 0;
			}
		}
	}
	
	printf("\n-1 -1 -1\n");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        if((s.charAt(0)==s.charAt(1))&(s.charAt(2)==s.charAt(3))&(s.charAt(0)!=s.charAt(2))){
            System.out.println("Yes");
        }else if((s.charAt(0)==s.charAt(2))&(s.charAt(1)==s.charAt(3))&(s.charAt(0)!=s.charAt(1))){
            System.out.println("Yes");
        }else if((s.charAt(0)==s.charAt(3))&(s.charAt(1)==s.charAt(2))&(s.charAt(0)!=s.charAt(1))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }



        }
    }


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  while(cin>>n,n>=0){
    vector<int> ans;
    if(n==0){cout<<"0"<<endl;continue;}
    while(n){
      ans.push_back(n%4);
      n /= 4;
    }
    rep(i,ans.size())cout<<ans[ans.size()-i-1];
    cout<<endl;
  }

}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, m;
    cin >> n >> m;
    vi a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    UnionFind uf(n);
    vll ans(m+1);
    ans[m] = n * (n-1) / 2;
    for (int i = m-1; i >= 0; i--) {
        if (uf.same(a[i], b[i])) {
            ans[i] = ans[i+1];
        } else {
            int x = uf.size(a[i]), y = uf.size(b[i]);
            ans[i] = ans[i+1] - x * y;
        }
        uf.unite(a[i], b[i]); 
    }
    for (int i = 1; i <= m; ++i) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N, M, R; cin >> N >> M >> R;
	vector<int> r(R);
	for (int i = 0; i < R; i++)
		cin >> r[i];
	vector<vector<int>> dis(N + 1, vector<int>(N + 1,1e8));
	for (int i = 0; i < M; i++) {
		int a, b, c; cin >> a >> b >> c;
		dis[a][b] = c, dis[b][a] = c;
	}
	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	sort(r.begin(), r.end());
	vector<int> a(R);
	a = r;
	int ans = 1e8;
	do {
		//cout << r.size() << endl;
		//cout << r[0] <<" "<< r[1] << endl;
		/*
		for (int i = 0; i < R; i++) {
			cout << r[i] << " ";
		}
		cout << endl;
		*/
		int temp = 0;
		for (int i = 0; i < R-1; i++) {
			//cout << r[i] << " " ;
			temp += dis[r[i]][r[i + 1]];
		}
		ans = min(ans, temp);
		!next_permutation(r.begin(), r.end());
	} while (r!=a);
	//cout << endl;
	cout << ans << endl;
}

Measured memory_bytes: 384
import Control.Applicative ((<$>))
import Data.List (sortBy)

main :: IO ()
main = solve <$> readLn >>= print
  
solve :: Int -> Int
solve n = head $ dropWhile (>n) lst
  where lst = sortBy (flip compare) . concat $ [1] : [ takeWhile (<= 1000) $ map (b^) [2..]| b <- [2 .. 31]]


Measured memory_bytes: 508
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

std::string S;
int ans;

int main()
{
	in >> S;

	for (int i = S.length() / 2 - 1; i >= 0; --i)
	{
		bool flag = true;
		rep(j, i)
		{
			if (S[j] != S[j + i])
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			ans = i;
			break;
		}
	}

	out << ans * 2 << std::endl;
	return 0;
}

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

using namespace std;

void print(vector<int32_t> v) {
    for (uint32_t i = 0; i < v.size() - 1; i++) {
        cout << v[i] << " ";
    }
    cout << v[v.size() - 1] << endl;
}

int main() {
    int32_t N, steps = 0;

    cin >> N;

    vector<int32_t> A(N);

    for (int32_t i = 0; i < N; i++) {
        cin >> A[i];
    }

    for (int32_t i = 0; i < N; i++) {
        int32_t mini = i;
        for (int32_t j = i; j < N; j++) {
            if (A[j] < A[mini]) {
                mini = j;
            }
        }

        if (i != mini) {
            int32_t temp = A[i];
            A[i] = A[mini];
            A[mini] = temp;
            steps++;
        }
    }

    print(A);
    cout << steps << endl;

    return 0;
}

Measured memory_bytes: 3136
#include <iostream>

#define N_MAX 100000 

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  char S[N_MAX];
  for(int i = 0; i < N; i++) cin >> S[i];

  int CC[N_MAX] = {0};
  int num = 0;
  for(int i = 0; i < N-1; i++) {
    if(CC[i] == 0) {
      if(S[i] == 'O' && S[i+1] == 'X') {
	num++;
	CC[i] = 1;
	CC[i+1] = 1;
      }
      if(S[i] == 'X' && S[i+1] == 'O') {
	num++;
	CC[i] = 1;
	CC[i+1] = 1;
      }
    }
  }

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
	set<string>S;
	int n;cin>>n;
	char prev;
	for(int i=1;i<=n;++i){
		string s;cin>>s;
		if(i==1){S.insert(s);prev=s[s.size()-1];}
		if(i!=1){
			if(s[0]!=prev || S.find(s)!=S.end()){
				cout<<"No\n";return 0;
			}else{
				prev=s[s.size()-1];
				S.insert(s);
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}

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

for i in range(n+1):
    for j in range(n-i+1):
         if i*1000 + j*5000 + (n-i-j)*10000 == y:
                print((n-i-j), j, i)
                exit()
else:
    print(-1, -1, -1)

Measured memory_bytes: 9112
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using VPI = vector<PII>;
using VPL = vector<PLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
	//i=m -> n-1(昇順)
#define RREP(i,m,n) for(int i=(m);i>=(n);i--)
	//i=m -> n(降順)

int main(){
  int n;
  cin >> n;
  VVI d(n,VI(2));
  REP(i,0,n){
    cin >> d[i][0] >> d[i][1];
  }
  
  REP(i,0,n-2){
    if(d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

int main(){
 int a,b,n;
 int x,i;
 int sum;

 while(scanf("%d %d %d",&a,&b,&n)!=EOF)
 {
  sum=0;
  a = a%b;

  for(i=0;i<n;i++)
  {
   a=a*10;
   sum+=a/b;
   a=a%b;
   if(a==0)break;
  }

  printf("%d\n",sum);

  }

return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    int a[5], k, ans = 0;
    for(int i = 0; i < 5; i++)
        cin >> a[i];
    cin >> k;
    for(int i = 0; i < 5; i++)
        for(int j = 0; j < 5; j++)
            if(a[i] < a[j] && a[j] - a[i] > k)
                ans++;
    if(ans)cout << ":(";
    else cout << "Yay!";
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    string s; cin >> s;
    int ct = 0;
    rep(i,3) if (s[i] == 'o') ct++;
    cout << 700+ct*100 << endl;
}

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  string ans = "NO";
  int a, b, c;
  cin >> a >> b >> c;

  if (b - a == c - b) {
    ans = "YES";
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]
t.sort()
cnt = 0
on_bus = 1
arr_time = t[0]
waiting_time = 0
for i in range(1,n):
    on_bus += 1
    waiting_time = t[i] - arr_time
    if on_bus > c or waiting_time >k:
        on_bus = 1
        arr_time = t[i]
        waiting_time = 0
        cnt += 1
print(cnt+1)

Measured memory_bytes: 7488
#include <iostream>
using namespace std;
typedef long long ll;

static const int MAXV=100000;

int main(void){
    // Your code here!
    int N;
    ll W;
    cin >> N >> W;
    
    ll w[N], v[N];
    
    for(int i = 0;  i < N; i++){
        cin >> w[i] >> v[i];
    }
    
    ll dp[MAXV+1];
    for(int i = 0; i <= MAXV; i++){
        dp[i] = 1e13;
    }
    /* 価値iを作れる時のmin weight*/
    dp[0] = 0;
    
    for(int i = 0; i < N; i++){
        for(int j = MAXV; j >= 0; j--){
            if(j-v[i] >= 0){
                dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
            } 
        }
    }
    
    ll ans = 0;
    for(int i = 0; i <= MAXV; i++){
        if(dp[i] <= W) ans = max(ans, ll(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void)
{
  int n;
  while(scanf("%d",&n)){
    int count[10]={0};
    int i;
    int no;
    if(n==0)
      break;

    for(i=0;i<n;i++){
      scanf("%d",&no);
      count[no]++;
    }
    for(i=0;i<10;i++){
      int j;
      for(j=0;j<count[i];j++)
	putchar('*');
      if(count[i]==0)
	putchar('-');
      putchar('\n');
    }
  }


  return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000
int main()
{
  string s; cin >> s;
  string ans;
  if (s[0] == 'A') s[0] = '0';
  else {
    cout << "WA" << endl;
    return 0;
  }

  int cnt = 0;
  REP(i, SIZE(s)) {
    if (i == 0 || i == 1 || i == SIZE(s) - 1) continue;
    if (s[i] == 'C') {
      s[i] = '0';
      cnt++;
    }
  }
  if (cnt != 1) {
    cout << "WA" << endl;
    return 0;
  }

  REP(i, SIZE(s)) {
    if (s[i] == '0') continue;
    if ('a' <= s[i] && s[i] <= 'z') ans = "AC";
    else {
      ans = "WA";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int i, a ;
	scanf("%d",&a);
	for(i = 1; i*i < a; i++)
	{
		if(i*i > a)
			break;
	}
	if(i*i == a)
	{
	printf("%d\n",i*i);
	}
	else
		printf("%d\n",(i-1)*(i-1));
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (ll)1e9+8
#define OO 1e18
#define EPS 1e-9
#define Endl '\n'
#define all(v) (v).begin(),(v).end()
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=1e5+5;
const int N=1e4+5,M=N*2;
ll a[maxn];
ll awl[maxn];
ll a5r[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=1;i<=n;++i)awl[i]=__gcd(a[i],awl[i-1]);
    for(int i=n;i>=1;--i)a5r[i]=__gcd(a[i],a5r[i+1]);
    ll ans=awl[n];
    for(int i=0;i<=n;++i)
        ans=max(ans,__gcd(awl[i],a5r[i+2]));
    printf("%lld\n",ans);
    re 0;
}

Measured memory_bytes: 2688
#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 n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  rep(i, k) ans += l[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int numBroken = sc.nextInt();
		boolean ok[] = new boolean[num + 1];
		for(int i = 0; i <= num; i ++) {
			ok[i] = true;
		}
		for(int i = 0; i < numBroken; i ++) {
			ok[sc.nextInt()] = false;
		}

		long dp[] = new long[num + 1];
		dp[0] = 1;
		dp[1] = ok[1] ? 1 : 0;

		for(int i = 2; i <= num; i ++) {
			dp[i] = ok[i] ? mod(dp[i - 1] + dp[i - 2]) : 0;
		}

		System.out.println(dp[num]);
	}

	static long MOD = (long)Math.pow(10, 9) + 7;
	public static long mod(long i) {
		return i % MOD + ((i % MOD) < 0 ? MOD : 0);
	}
	
	static long powerMod(long x, long y) {
		if (y == 0) {
			return 1;
		} else if (y == 1) {
			return x;
		} else if (y % 2 == 0) {
			long tmp = powerMod(x, y / 2);
			return mod(tmp * tmp);
		} else {
			long tmp = powerMod(x, y / 2);
			return mod(mod(tmp * tmp) * x);
		}
	}
	
	static long invMod(long x) {
		return powerMod(x, MOD - 2);
	}
	
	static int MAX_FACT = 200_100;
	static long factMod[] = new long[MAX_FACT];
	static void prepareFact() {
		factMod[0] = 1;
		for(int i = 1; i < MAX_FACT; i ++) {
			factMod[i] = mod(factMod[i - 1] * i);
		}
	}
	
	static long combiMod(int n, int r) {
		if(n < 0 || n < r) { return 0; }
		if(r == 0 || r == n) { return 1; }
		return mod(mod(factMod[n] * invMod(factMod[r])) * invMod(factMod[n - r]));
	}
}

Measured memory_bytes: 56512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int N;

int main(){
  int K, X;
  cin >> K >> X;
  for(int i = X - K +1; i <= X + K - 1; i++){
    cout << i << " ";
  }
  cout << endl;
  
					
}


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

int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d;
  e = (d-b);
  f = (c-a);
  cout << c-e << " " << d+f << " " << (c-e)-f << " " << (d+f)-e;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

const int limit = 200010;
int ary[limit];

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

	rep(i, n) {
		int s, t, c;
		cin >> s >> t >> c;
		s = 2 * s - 1;
		t = 2 * t;
		c--;

		ary[s]^=(1 << c);
		ary[t]^=(1 << c);
	}

	rep(i,1,limit) ary[i]^=ary[i-1];

	int ans = 0;
	rep(i,limit) chmax(ans,__builtin_popcount(ary[i]));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;



int main(void) {
	int n, m, a, b;
	cin >> n >> m;
	vector<pair<int, int>>p(m);
	for (int i = 0;i < m;i++) {
		cin >> a >> b;
		p[i] = make_pair(b, a);
	}
	sort(p.begin(), p.end());
	int t = 0, ans = 0;
	for (int i = 0;i < m;i++) {
		if (t <= p[i].second) {
			ans++;
			t = p[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>


using namespace std;

int main() {

	/* ----- 変数宣言 ----- */
	int x, a, b;

	/* ----- 入力 ----- */
	cin >> x >> a >> b;

	/* ----- 計算 ----- */
	x = (x - a) % b;

	cout << x << endl;
}


Measured memory_bytes: 256
'''
import random

random.seed(1000)

D = 365
cs = [random.randrange(0, 101) for _ in range(26)]
ss = [[random.randrange(0, 20001) for _ in range(26)] for _ in range(D)]

'''
D = int(input())
cs = list(map(int, input().split()))
ss = [list(map(int, input().split())) for _ in range(D)]
#'''
width = 20

def calc(ts):
    last = [-1] * 26
    sat = 0
    for i, t in enumerate(ts):
        sat += ss[i][t-1]
        last[t-1] = i
        sat -= sum(c * (i - l) for c, l in zip(cs, last))       
    return sat

def search(ts):
    last = [-1] * 26
    sat = 0
    for i, t in enumerate(ts):
        sat += ss[i][t-1]
        last[t-1] = i
        sat -= sum(c * (i - l) for c, l in zip(cs, last))
    
    deltas = [-(10 ** 9)]
    i = len(ts)
    for t in range(1, 27):
        tmp = last[t-1]
        last[t-1] = i
        delta = ss[i][t-1] + sum(c * (i - l) for c, l in zip(cs, last))
        last[t-1] = tmp
        deltas.append(sat + delta)

    ls = sorted(enumerate(deltas), key = lambda t: t[1], reverse = True)
    return ls[:width]

#ビームサーチのつもり
best5ts = [[]]
for i in range(D):
    possible_best5ts = []
    possible_sats = []
    for ts in best5ts:
        best5t, sats = map(list, zip(*search(ts)))
        possible_best5ts += [ts + [t] for t in best5t]
        possible_sats += sats
    ls = sorted(enumerate(possible_sats), key = lambda t: t[1], reverse = True)
    best5ts = []
    for i, _ in ls[:width]:
        best5ts.append(possible_best5ts[i])

ts = best5ts[0]

print(*ts, sep = '\n')
#print(calc(ts) + 365 * 10 ** 6)


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

int main() {
    string ans = "No";
    int X;
    cin >> X;
    if(X >= 30)
        ans = "Yes";

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];
ll dp[101];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	ll ans = b;
	ll res = a;
	res -= a / c + a / d;
	res += a / lcm(c, d);
	ans -= b / c + b / d;
	ans += b / lcm(c, d);
	ans -= res;
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

template <typename T>
inline void Read(T& x)
{
    bool Neg = false;
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') Neg = !Neg;
    x = c - '0';
    for (c = getchar(); c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    if (Neg) x = -x;
}

template <typename T>
inline void Write(T x)
{
    if (x < 0)
    {
        putchar('-'); x = -x;
    }
    T p = 1;
    for (T temp = x / 10; temp > 0; temp /= 10) p *= 10;
    for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
}

typedef long long ll;

int n,p;
string s;
int cnt[2000001];
int pow_10[2000001], pre_cal[2000001];

int main()
{
    Read(n); Read(p);
    char c;
    while(c = getchar())
    {
        if (c == ' ' || c == '\n') break;
        s += c;
    }
    pow_10[0] = 1;
    for (int i=1;i<=2000000;i++) 
        pow_10[i] = (1LL * pow_10[i-1] * 10)%p;
    s = '*' + s;
    int cnt_2 = 0, cnt_5 = 0;
    int x = p;
    int zz = 1;
    while(x % 2 == 0)
    {
        zz *= 2;
        cnt_2++;
        x/=2;
    }
    while(x % 5 == 0)
    {
        zz *= 5;
        cnt_5++;
        x/=5;
    }
    ll ans = 0;
    for (int j=1;j<=6;j++)
    {
        if (j > n) break;
        int cur = 0;
        for (int i=1;i<=j;i++)
            cur = cur*10 + (s[i] - '0');
        if (cur % p == 0) ans++;
        for (int i=j+1;i<=n;i++)
        {
            cur = cur - (s[i - j] - '0') * pow_10[j-1];
            cur = cur*10 + (s[i] - '0');
            cur = (cur%p + p)%p;
            if (cur == 0)
                ans++;
        }
    }
    vector<ll> val;
    ll cur = 0;
    val.push_back(0);
    for (int i=1;i<=n;i++)
    {
        cur = (cur + (1LL * (s[i] - '0') * pow_10[n - i + 1])%x)%x;
        val.push_back(cur);
    }
    sort(val.begin(), val.end());
    int id = lower_bound(val.begin(), val.end(), 0) - val.begin();
    cur = 0;
    ll pre = 1, val_pre = 0;  
    cnt[id]++;
    int tmp = 0;
    for (int i=1;i<=6;i++)
        cur = (cur + (1LL * (s[i] - '0') * pow_10[n - i + 1])%x)%x;
    for (int i=1;i<=7;i++)
        tmp = tmp * 10 + (s[i] - '0');
    pre_cal[7] = tmp;
    for (int i=8;i<=n;i++)
    {
        tmp = tmp - (s[i - 7] * pow_10[6]);
        tmp = tmp * 10 + (s[i] - '0');
        tmp = (tmp%zz + zz)%zz;
        pre_cal[i] = tmp;
    }
    for (int i=7;i<=n;i++)
    {
        int tmp = pre_cal[i];
        cur = (cur + (1LL * (s[i] - '0') * pow_10[n - i + 1])%x)%x;
        int id = lower_bound(val.begin(), val.end(), cur) - val.begin();
        if (tmp % zz == 0)
            ans += cnt[id];
        val_pre = (val_pre + (1LL * (s[pre] - '0') * pow_10[n - pre + 1])%x)%x;
        id = lower_bound(val.begin(), val.end(), val_pre) - val.begin();
        cnt[id]++;
        pre++;     
    }
    Write(ans);
}

Measured memory_bytes: 15284
#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;
void ans2();
void ans3();
signed main()
{
    cin >> s;
    rep(i,0,s.size()){
        if(s[i]==',')cout << " ";
        else cout << s[i];
    }
    cout << endl;

 //   str ss;
 //   cin >> ss;
 //   cout << ss.size() << endl;
  //  ans2();
      //  ans3();
    return 0;
}
/*
void ans2(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    str a1="";
    str a2="";
    str b1="";
    str b2="";
    rep(i,b,d){
        a1+='U';
        b1+='D';
    }
    rep(j,a,c){
        a2+='R';
        b2+='L';
    }
    str ans=a1;
    ans+=a2;
    ans+=b1;
    ans+=b2;
    ans+='L';
    ans+=a1;
    ans+='U';
    ans+=a2;
    ans+="RDR";
    ans+=b1;
    ans+='D';
    ans+=b2;
    ans+="LU";
    cout << ans << endl;
    cout << ans.size() << endl;
    return ;
}

set<string> an;
void ans3(){
    int n,m;
    cin >> n >> m;
    rep(i,0,n){
        rep(j,0,n){
            if((i+j)>=(m-n)&&(i+j)<=m){
                str ss=to_string(i);
                ss+='#';
                ss+=std::to_string(j);
                ss+='#';
                ss+=std::to_string(m-(i+j));
                an.insert(ss);
            }
        }
    }
    cout << ss.size() << endl;
    return;
}*/



Measured memory_bytes: 256