akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <ctime>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	REP(i,3){
		string s;
		cin >> s;
		cout << (char)(s[0] + 'A' - 'a');
	}
	cout << endl;

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[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" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


fn main() {
    input!{h:usize, w:usize, c:[chars;h]};
    for i in 0..h {
        for j in 0..w { print!("{}", c[i][j]);} println!("");
        for j in 0..w { print!("{}", c[i][j]);} println!("");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, int> P;
static const int INF = 1e9;
static const int SIZE = 100001;

struct edge
{
	int to, cost;
};

vector<edge> G[SIZE];
int d[SIZE];
int n;

void bfs(int v)
{
	for (int i = 0; i < n; ++i)
	{
		d[i] = INF;
	}
	d[v] = 0;
	priority_queue < P, vector<P>, greater<P> > pque;
	pque.push(P(0, v));
	while (!pque.empty())
	{
		P p = pque.top();
		pque.pop();
		int vertex = p.second;
		for (int i = 0; i < G[vertex].size(); ++i)
		{
			edge e = G[vertex][i];
			if (d[e.to] > d[vertex] + e.cost)
			{
				d[e.to] = d[vertex] + e.cost;
				pque.push(P(d[e.to], e.to));
			}
		}
	}
}

void solve()
{
	cin >> n;
	for (int i = 0; i < n - 1; ++i)
	{
		int s, t, w;
		cin >> s >> t >> w;
		edge e1, e2;
		e1.to = t;
		e2.to = s;
		e1.cost = e2.cost = w;
		G[s].push_back(e1);
		G[t].push_back(e2);
	}
	bfs(0);
	int maxDist = 0;
	int maxv = 0;
	for (int i = 1; i < n; ++i)
	{
		if (maxDist < d[i])
		{
			maxDist = d[i];
			maxv = i;
		}
	}
	bfs(maxv);
	maxDist = 0;
	for (int i = 0; i < n; ++i)
	{
		if (maxDist < d[i])
		{
			maxDist = d[i];
		}
	}
	cout << maxDist << endl;
}

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

Measured memory_bytes: 7984
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0

for i in range(N):#N番目で下に
  curr = 0
  for j in range(i+1):
    curr += A[j]
  for j in range(i,N):
    curr += B[j]
  ans = max(ans,curr)
  
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define debug 1

//bool cmp(double a,double b) {return a>b;}

int main(int argc,char **argv) {
	int n;
	cin>>n;
	
	double v[n];
	for(int i=0;i<n;i++)
		cin>>v[i];
	
	sort(v,v+n);
	
/*	int now=2;
	double ans=0,num=1;
	for(int i=0;i<n;i++) {
		num/=(double)2;
		for(int j=0;i<n && j<now;i++,j++) {
			ans+=num*v[i];
		}
		now*=2;
	}*/
	double ans=v[0];
	for(int i=1;i<n;i++)
		ans=(v[i]+ans)/(double)2;
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
from math import ceil
H,W,K=map(int,input().split())
grid=[input() for i in range(H)]

for i in range(H):
  for j in range(W):
    if grid[i][j]=="S":
      S=(i,j)

stack=deque([(S[0],S[1],0)])
visited=[[False]*(W) for i in range(H)]
visited[S[0]][S[1]]=True
a=float("inf")
t=[-1,1]
while stack:
  i,j,m=stack.popleft()
  if m>K:
    break
  a=min(a,min(i,H-1-i,j,W-1-j))
  if a==0:
    break
  for s in t:
    if not visited[i+s][j] and grid[i+s][j]!="#":
      stack.append((i+s,j,m+1))
    if not visited[i][j+s] and grid[i][j+s]!="#":
      stack.append((i,j+s,m+1))
    visited[i+s][j]=True
    visited[i][j+s]=True
ans=1+ceil(a/K)
print(ans)


    
        
        
          
  


Measured memory_bytes: 56688
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = [int(input()) for _ in range(n)]
for i in range(len(a)):
    for o in range(len(a[1])):
        if a[i][o] in b:
            a[i][o] = 0
for i in a:
    if i == [0,0,0]:
        print("Yes")
        quit()
for i in range(3):
    if a[0][i] == 0 and a[1][i] ==0 and a[2][i] ==0:
        print("Yes")
        quit()
if a[0][0] == 0 and a[2][2] ==0 and a[1][1] == 0:
    print("Yes")
    quit()
if a[0][2] == 0 and a[1][1] == 0 and a[2][0] ==0:
    print("Yes")
    quit()
print("No")


Measured memory_bytes: 38384
def count_word(t_array, w)
  length = t_array.length
  word_count = 0
  for i in 0..(length-1)
    if t_array[i].downcase == w
      word_count += 1
    end
  end
  return word_count
end

w = gets.chomp
t_array = []
loop do
  t = gets.chomp.split
  if t == ["END_OF_TEXT"]
    break
  end
  t_array.push(t)
  t_array.flatten!
end
puts count_word(t_array, w)

Measured memory_bytes: 8552
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
// 0 - top
// 1 - north
// 2 - west
// 3 - east
// 4 - south
// 5 - bottom

// north
// east
// south
// west
int next[4][6] = {
  {1, 5, 2, 3, 0, 4}, 
  {3, 1, 0, 5, 4, 2},
  {4, 0, 2, 3, 5, 1},
  {2, 1, 5, 0, 4, 3}
};


int main(){
  int N;
  while(cin>>N && N){
    int number[6] = {1, 2, 3, 4, 5, 6};
    string dir[4] = {"north", "east", "south", "west"};
    map<string, int> dic;
    REP(i, 4) dic[dir[i]] = i;
    REP(i, N){
      string s; cin>>s;
      int r = dic[s];
      int newnumber[6];
      REP(j, 6) newnumber[next[r][j]] = number[j];
      REP(j, 6) number[j] = newnumber[j];
    }
    cout<<number[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let x: i32 = read();
    let y: i32 = read();
    let z: i32 = read();
    println!("{}", (x - z) / (y + z));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 1; i < s.length(); i++) {
        if (s[i-1] != s[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3708
n,k = input().strip().split()
n,k = int(n),int(k)
h = list(map(int,input().strip().split()))

dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,n):
  min_cost = 10**10
  if i < k:
    _k = i
  else:
    _k = k  
  for j in range(1,_k+1):
    cost = dp[i-j] + abs(h[i-j] - h[i])
    if min_cost > cost:
      min_cost = cost
  dp[i] = min_cost
  
print(dp[n-1])

Measured memory_bytes: 52448
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return x*f;
}

#define MAXN 10
int N,D,Ans;
int X[MAXN+5][MAXN+5];

bool Check(int *A,int *B){
	int All=0;
	for(int i=1;i<=D;i++)
		All+=(A[i]-B[i])*(A[i]-B[i]);
	return int(sqrt(All))*int(sqrt(All))==All;
}

int main(){
	N=read(),D=read();
	for(int i=1;i<=N;i++)
		for(int j=1;j<=D;j++)
			scanf("%d",&X[i][j]);
	for(int i=1;i<=N;i++)
		for(int j=i+1;j<=N;j++)
			Ans+=Check(X[i],X[j]);
	printf("%d",Ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    print(2*b-a);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int gcd(ll a,ll b)
{
    if(a>b)
        {
            a=gcd(a-b,b);
        }
    else if(b>a)
        {
            b=gcd(a,b-a);
        }
    else
        return a;
}
int main()
{
    ll n,g;
    cin >> n;
    g=gcd(360,n);
    //cout << g;
    g=(n*360)/g;
    g = g/n;
    cout << g;
}


Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var H, W int
var matrix [][]string
var memo map[pair]int

type pair struct {
	x, y int
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &H, &W)

	matrix = make([][]string, H)
	for i := 0; i < len(matrix); i++ {
		matrix[i] = make([]string, W)
	}

	for i := 0; i < H; i++ {
		var str string
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%s", &str)
		matrix[i] = strings.Split(str, "")
	}

	memo := make(map[pair]int)

	ans := 0
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if matrix[i][j] == "#" {
				if v, e := memo[pair{i, j}]; e {
					ans = ans + v
					// fmt.Println("memo", i, j)
					continue
				}

				done := make(map[pair]struct{})
				count := search(i, j, done, false)
				for p, _ := range done {
					if matrix[p.x][p.y] == "#" {
						// fmt.Println("add memo", p, count)
						memo[p] = count
					}
				}
				ans = ans + count
			}
		}
	}
	fmt.Println(ans)
}

var dif = [4]pair{pair{-1, 0}, pair{1, 0}, pair{0, -1}, pair{0, 1}}

func search(x, y int, done map[pair]struct{}, wantWhite bool) int {
	if x < 0 || y < 0 || x >= H || y >= W {
		return 0
	}
	if _, e := done[pair{x, y}]; e {
		return 0
	}

	count := 0
	if wantWhite && matrix[x][y] == "." {
		done[pair{x, y}] = struct{}{}

		count++ // for this "."
		for _, d := range dif {
			count = count + search(x+d.x, y+d.y, done, false)
		}
	} else if !wantWhite && matrix[x][y] == "#" {
		done[pair{x, y}] = struct{}{}

		for _, d := range dif {
			count = count + search(x+d.x, y+d.y, done, true)
		}
	}

	return count
}


Measured memory_bytes: 113536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
ll n,arr[10005],x,k,d;

int main()
{
    cin>>x>>k>>d;
    x=abs(x);
    ll e = x/d;

    ll u=0,l=0;
    if(e<=k){
        u=x%d;
        l=k-e;
        if(l%2!=0 && l!=0){
            ll a=abs(d+u);
            ll b=abs(u-d);
            u=min(a,b);
        }
    }
    else{

        u=x-(k*d);
    }
    cout<<u<<endl;
    return 0;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**9)
 
N = int(input())
edge = [[] for i in range(N)]
count = [0] * N
color = {}
egs = []
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    count[a] += 1
    count[b] += 1
    edge[a].append(b)
    edge[b].append(a)
    egs.append(tuple(sorted([a, b])))
 
 
ans = max(count)
c = 1
 
 
 
def dfs(idx, pr):
    c = 1
    col = color[pr]
    for i in edge[idx]:
        if i in pr:
            continue
        if c == col:
            c+=1
        x, y = sorted([i, idx])
        color[(x, y)] = c
        dfs(i, (x, y))
        c+=1
 
color[(-1, -1)] = 0
dfs(0, (-1, -1))
print(ans)
for tpl in egs:
    print(color[tpl])
 
 

Measured memory_bytes: 80884
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

//int compare_int(const void *a, const void *b){//qsort 整数比較<
//	return *(int*)a - *(int*)b;
//}
//int compare_int2(const void *a, const void *b){//qsort 整数比較>
//	return *(int*)b - *(int*)a;
//}

int main(void){
	int n,k;
	int A[200010]={0};
	int i;

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

	return 0;
}


Measured memory_bytes: 2444
def main():
    A, B, AB, x, y = map(int, input().split())
    ans = []
    ans.append(A*x + B*y)
    if x < y:
        ans.append(AB*x*2 + B*(y-x))
        ans.append(AB*y*2)
    elif y < x:
        ans.append(AB*y*2 + A*(x-y))
        ans.append(AB*x*2)
    else:
        ans.append(AB*x*2)
    print(min(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
/*
      author  : nishi5451
      created : 14.08.2020 17:56:45
*/

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


int main(){
    int n,d,x;
    cin >> n >> d >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans=x;
    rep(i,n){
        ans += (d-1)/a[i]+1;
    }
    cout << ans << endl;
    return 0;
}

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

struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;
typedef __int128 Int;
const LL MOD=1e9+7;
const LL INF=1e16;


typedef vector<LL> V;
typedef vector<V> VV;
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto &it:v)is>>it;return is;}
#define SPACE " "
template<typename T> ostream& operator<<(ostream& os,vector<T>& v){for(int i=0,sz=v.size();i<sz;i++)os<<(!i)+SPACE<<v[i];return os;}

int main(){
    int N,A;cin>>N>>A;
    VV dp(N+1,V(2501,0));
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        VV nxt=dp;
        int x;cin>>x;
        for(int s=0;s<=i;s++)
            for(int t=x;t<2501;t++)
                nxt[s+1][t]+=dp[s][t-x];
        swap(dp,nxt);
    }
    LL res=0;
    for(int i=0;i<2501;i++)
        for(int j=1;j<=N;j++)
            if(i%j==0&&i/j==A)res+=dp[j][i];
    cout<<res<<endl;
    return 0;
}


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

int main(){
    int k,s;
    cin >> k >> s;
    int si,sj;
    int count=0;
    for(int x=0;x<=k;x++){
        si = s-x;
        // cout << "si =" << si << endl;
        if(si>2*k)continue;
        for(int y=0;y<=k;y++){
            // cout << "si =" << si << endl;
            if(y>si)break;
            if(si-y>k)continue;
            count++;
        }
    }
    cout << count << endl;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int, int> p;

int main(){
  int n;
  cin >> n;
  vector<int> t(n);
  vector<double> v(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }


  vector<double> maxv(50000, 100000);

  int sum_time = 0;
  for (int i = 0; i < n; i++) {
    t[i] *= 2;
    for (int j = sum_time; j <= sum_time + t[i]; j++) {
      maxv[j] = min(maxv[j], v[i]);
    }
    sum_time += t[i];
  }
  maxv[0] = maxv[sum_time] = 0;

  for (int j = 0; j < n; j++) {
    for (int i = 0; i < sum_time; i++) {
      maxv[i+1] = min(maxv[i+1], maxv[i]+0.5);
    }
    for (int i = sum_time-1; i >= 0; i--) {
      maxv[i] = min(maxv[i+1] + 0.5, maxv[i]);
    }
  }

  double res = 0;
  for (int i = 0; i < sum_time; i++) {
    res += double(maxv[i+1] + maxv[i]);
  }
  cout<<setprecision(15);
  cout << res / 4 << endl;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int a, b, c, d;
int main() {
    std::cin >> a >> b >> c >> d;
    if(std::abs(a-c) <= d) {
        std::cout << "Yes" << std::endl;
    }  else if(std::abs(a-b) <= d && std::abs(b-c) <= d) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
#define f first
#define s second
typedef pair<int,int> pii;
const int N=1e3+5;
const int mod=1e9+7;
const ll inf=1e18+7;
int h,w;char a[N][N];int dp[N][N];
int main()
{
    scanf("%d%d",&h,&w);
    dp[0][1]=1;
    forn(i,1,h){
        forn(j,1,w){
            scanf(" %c",&a[i][j]);
            if(a[i][j]=='#')continue;
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    printf("%d\n",dp[h][w]);
    return 0;
}


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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  for (auto &e : a) cin >> e;
  for (auto &e : b) cin >> e;
  int r = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
  while (M--) {
    int x, y, c;
    cin >> x >> y >> c;
    r = min(r, a[x - 1] + b[y - 1] - c);
  }
  cout << r << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n, x, t;
  cin >> n >> x >> t;
  if (n % x == 0){
    n/=x;
    n*=t;
    cout << n << ENDL;
    return 0;
  }
  else{
    n+=(x - (n % x));
    n/=x;
    n*=t;
    cout << n << ENDL;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 3648
n=int(input())

import math

def factorization(n): #nを素因数分解する
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

#    if arr==[]:
#        arr.append([n, 1])  #n=1でarr=[1,1]としたいとき

    return arr

z=factorization(n)

ans=0
for i in range(len(z)):
    for j in range(1,z[i]+1):
        if (z[i]-j)>=0:
            z[i]-=j
            ans+=1
        else:
            break
print(ans)
    

Measured memory_bytes: 9188
n = int(input())
taro = 0
hana = 0

for _ in range(n):
    idiom_list = list(input().split(' '))
    sort_list = sorted(idiom_list)
    if idiom_list[0] == idiom_list[1]:
        taro += 1
        hana += 1
    else:
        if idiom_list == sort_list:
            hana += 3
        else:
            taro += 3

print('{a} {b}'.format(a=taro, b=hana))



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define out(i) cout<<i<<endl;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}
signed main(){
  int n;
  cin>>n;
  int ml=INF;
  for(int a=1;a<sqrt(n)+1;++a){
    int b=n/a;
    if(a*b!=n)continue;
    ml=min( ml,max(to_string(a).length(),to_string(b).length()) );
  }
  out(ml);
  
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
    int n, m, c;
    int b[20+5];
    scanf("%d %d %d", &n, &m, &c);
    for(int i=0; i<m; i++)scanf("%d", &b[i]);
    
    int cnt=0;
    for(int i=0; i<n; i++){
        int ans=c;
        int a;
        for(int j=0; j<m; j++){
            scanf("%d", &a);
            ans+=a*b[j];
        }
        if(ans>0)cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


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

int main() {
  int A;
  int B;
  cin >> A;
  cin >> B;
 if(A==1&&B==2||A==2&&B==1){
   cout << "3";
 }else if(A==2&&B==3||A==3&&B==2){
   cout << "1";
 }else if(A==1&&B==3||A==3&&B==1){
   cout << "2";
 }
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>

int main(){
    int n, d;
    std::cin >> n >> d;

    std::vector<std::vector<int>> x(n, std::vector<int>(d));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < d; ++j){
            std::cin >> x.at(i).at(j);
        }
    }

    float val = 0;
    int count = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i; j < n; ++j){
            for(int k = 0; k < d; ++k){
                val += std::pow(x.at(i).at(k) - x.at(j).at(k), 2);
            }

            val = std::pow(val, 0.5);
            if(0.0 != val && 0.0 == val - (int)val){
                ++count;
            }

            val = 0;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool flag = true;
            for(int i = 1; i < 4; i++)
            {
                if (s[i] == s[i - 1]) flag = false;
            }
            if (flag) Console.WriteLine("Good");
            else Console.WriteLine("Bad");
        }
    }
}


Measured memory_bytes: 25764
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC162
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            long sum = 0;
            for (int i = 1; i <= s[0]; i++)
            {
                if (i % 3 != 0 && i % 5 != 0)
                {
                    sum += i;
                }

            }
            WriteLine(sum);
        }
    }
}


Measured memory_bytes: 28024
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

llong Q, H, S, D, N, ANS = 0;

int main() {
	cin >> Q >> H >> S >> D >> N;
	if (N >= 2) {
		llong M = min(min(min(8 * Q, 4 * H), 2 *S), D);
		ANS += (N / 2) * M;
		N %= 2;
	}

	if (N == 1) {
		llong M = min(min(4 * Q, 2 * H), S);
		ANS += M;
	}

	cout << ANS;
}

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

const ll MOD = 1000000007;

ll pow_(ll a,ll p){
  if(p == 0) return 1;
  if(p == 1) return a%MOD;
  if(p%2 == 0) return pow_((a*a)%MOD,p/2);
  else return (a*pow_((a*a)%MOD,p/2))%MOD;
}

ll inv(ll a){
  return pow_(a,MOD-2);
}

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  ll ans = pow_(2,n);
  ans --;
  vector<ll> con(2*100000+1,1);
  rep1(i,2*100000){
    con[i] = con[i-1]*(n-i+1)%MOD;
    con[i] = con[i]*inv(i)%MOD;
  }
  cout << ((ans-con[a]-con[b])%MOD+MOD)%MOD << endl;
}

Measured memory_bytes: 1792
from functools import lru_cache, reduce
from math import gcd

K = int(input())

memo_b = [[None for _ in range(K)] for _ in range(K)]

def c_gcd(a, b):
    if memo_b[a-1][b-1] is not None:
        return memo_b[a-1][b-1]
    else:
        res = gcd(a, b)
        memo_b[a-1][b-1] = res
    return res

ans = 0
for i in range(1, K+1):
    for j in range(i+1, K+1):
        ans += 6 * c_gcd(i, j)
        for k in range(j+1, K+1):
            ans += 6*c_gcd(c_gcd(i, j), k)


for i in range(1, K+1):
    ans += i

print(ans)


Measured memory_bytes: 9820
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  cin>>n;
  double ans=0.0;
  double x;
  string u;
  double rate = 380000.0;
  REP(i,n){
    cin>>x;
    cin>>u;
    if(u=="BTC"){
      x *= rate;
    }
    ans += x;
  }
  cout << fixed << setprecision(6) << ans << endl;
  return 0;
}


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

using namespace std;

int main(void)
{
  int n;

  cin >> n;
  double buff;
  vector<double> v;

  for(int i = 0;i < n;i++){
    cin >> buff;
    v.push_back(buff);
  }

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

  double box = (v[0] + v[1])/2;
  
  for(int i = 2;i < n;i++){
    box = (box + v[i]) / 2;
  }

  cout << box;
  
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MX = 1e18;         //1(1倍)e(指数)18(10^18)
const ll MOD = 1e9 + 7;
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
int main()
{
    int x, y;
    cin >> x >> y;
    int group[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    cout << (group[x] == group[y] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
program main
integer :: a,b,c,d

read(*,*) a,b,c,d

do while(a > 0 .and. c > 0)
c = c - b
if (c <= 0) exit 
a = a - d
end do

if (a > c) then 
write(*,*) "Yes"
else 
write(*,*) "No"
end if
end program main

Measured memory_bytes: 2796
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

int A,B;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{	
		int N;
		cin >> N;
		vector<char>data(N);
		for (int i = 0; i < N; i++)
		{
			cin >> data[i];
		}
		
		int max = 0;
		int x = 0;
		for (int i = 0;i < N; i++)
		{
			if (data[i] == 'I')
			{
				x++;
				if (x >= max)
				{
					max = x;
				}
			}
			else if (data[i] == 'D')
			{
				x--;
			}
		}
		
		
	
		cout << max << endl;

		
}

Measured memory_bytes: 256
import sys
import heapq as hp
input = sys.stdin.readline
N= int(input())
A = list(map(int,input().split()))

l = A[:N]
r = [-a for a in A[2*N:]]
hp.heapify(l)
hp.heapify(r)
L = sum(l)
R = sum(r)

Lcand = [L]
Rcand = [R]
for a in A[N:2*N]:
    if l[0] < a:
        L += a - l[0]
        hp.heappushpop(l,a)
    Lcand.append(L)

for a in A[N:2*N][::-1]:
    if r[0] < -a:
        R += -a - r[0]
        hp.heappushpop(r,-a)
    Rcand.append(R)

print(max([l+r for l,r in zip(Lcand, Rcand[::-1])]))





Measured memory_bytes: 123272
#include <iostream>
using namespace std;
int main(){
    int r,c,sum;
    sum =0;
    cin >> r >> c;
    int rc[r+1][c+1];
    for(int i=0;i<r;i++){
      for(int j = 0;j<c;j++){
        cin >> rc[i][j];
        sum += rc[i][j];
      }
      rc[i][c] = sum;
      sum = 0;
    }

    for(int k = 0;k<c+1;k++){
      for(int l = 0;l<r;l++){
        sum += rc[l][k];
      }
      rc[r][k] = sum;
      sum = 0;
    }

    for(int i=0;i<r+1;i++){
      for(int j = 0;j<c+1;j++){
        cout << rc[i][j];
        if(j != c){
          cout << " ";
        }
      }
      cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 3068
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 10e9+7;
ll mod2 = 998244353;

vector<int> G[100100];
vector<int> M(100100,1);

int dfs(int v){
    if (M[v]==0) return 0;
    M[v] = 0;
    for(auto next_v:G[v]){
        dfs(next_v);
    }
}

int main(){
    int n,m;cin>>n>>m;
    rep(i,0,m){
        int x,y,z;cin>>x>>y>>z;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int ans = 0;
    rep(i,0,n){
        if (M[i]==1){
            ans++;
            dfs(i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 79488
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

string tofour(int n){
	string ans;
	while(n){
		ans += n%4+'0';
		n/=4;
	}
	reverse(ans.begin(),ans.end());
	return ans.size()?ans:"0";
}
int main(){
	int n;
	while(cin >> n , ~n){
		cout << tofour(n) << endl;
	}
}

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

int n , k , a[1234567] , mx = 0;

void no(){ cout << "IMPOSSIBLE"; exit(0); }

int gcd(int a  , int b)
{
	if(!b) return 1;
	if(a < b) swap(a , b);
	if(a % b == 0) return b;
	else return gcd(b , a % b);	
}


int main()
{
	cin >> n >> k;
	if(n == 1)
	{
		int x;
		cin >> x;
		if(x == k) cout << "POSSIBLE";
		else no();
		return 0;
	}
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	int g = gcd(a[0] , a[1]);
	mx = max(a[0] , a[1]);
	for(int i=2;i<n;i++)
	{
		mx = max(mx , a[i]);
		g = gcd(g , a[i]);
	}
	if(k > mx) no();
	if(g > 1 && gcd(k,g) == 1) no();
	else cout << "POSSIBLE";
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int cnt = 0;
    for(int i = a;i <= b;i++){
        int x1 = i/10000;
        int x2 = i%10000/1000;
        int x3 = i%1000/100;
        int x4 = i%100/10;
        int x5 = i%10;
        if(x1 == x5 && x2 == x4)cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int a,b,c,x,i,j,k,count=0,sum;
  cin >> a >> b >> c >> x;
  for(i=0;i<=a;i++)
  {
    for ( j = 0; j <= b; j++)
    {
      for ( k = 0; k <= c; k++)
      {
        sum = 500*i+100*j+50*k;
        if(sum == x)
        {
          count++;
        }
      }
    }
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 3632
def main():
    import math
    a,b,h,m=map(int, input().split())
    p=math.pi
    ang_h,ang_m=h*p/6+m*p/360,m*p/30
    ang=abs(ang_h-ang_m)
    if ang<p:
        ans=a**2+b**2-2*a*b*math.cos(ang)
        print(math.sqrt(ans))
    else:
        ans=a**2+b**2-2*a*b*math.cos((2*p-ang))
        print(math.sqrt(ans))

if __name__=='__main__':
    main()

Measured memory_bytes: 9464
a,b = map(int,input().split())

if a % 2 == 0:
    print(a*b//2)
elif a == 1 or b == 1:
    print(1)
else :
    if b % 2 == 0:
        print(a*b//2)
    else :
        a = a+1
        b = b+1
        print((a//2*b//2) + ((a//2)-1)*((b//2)-1))

Measured memory_bytes: 3060
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var v = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var c = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            var s = Enumerable.Range(0,n).Where(i => v[i] - c[i] >= 0).Select(i => v[i] - c[i]).Sum();
            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

    void yes(bool fl = true){
            if(fl) cout << "YES\n";
            else cout << "Yes\n";
    }
    void no(bool fl = true){
        if(fl) cout << "NO\n";
        else cout << "No\n";
    }  

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;
        

        
        




        


        void solve(){
            cin >> str;
            if(str[1] == 'R') str[1] = 'B';
            else str[1] = 'R';
            cout << str;
           
        }
    
   

        int main(){
        ios_base::sync_with_stdio(false);
      
        int cases = 1;
        //cin >> cases;

        while(cases--){ 
            solve();
        }

        return 0;

        }

Measured memory_bytes: 3648
import bisect
n = int(input())
ps = [0] * (1 << 16)
for i in range(1 << 16):
    temp = 0
    x = 1    
    for j in range(16):
        if (i >> j) & 1:
#                temp += (-2) ** (2 *j)
            temp += x
        x *= 4
    ps[i] = temp

pattern1 = None
pattern2 = None

for i in range(1 << 16):
    temp2 = 0
    x = -2
    for j in range(16):
        if (i >> j) & 1:
#                temp2 += (-2) ** (2 *j + 1)
            temp2 += x
        x *= 4
    n2 = n - temp2
    pattern1 = bisect.bisect_left(ps, n2)
    if pattern1 != (1 << 16) and ps[pattern1] == n2:
        pattern2 = bin(i)[2:].zfill(16)
        pattern1 = bin(pattern1)[2:].zfill(16)
        break

ans = ""
for i in range(16):
    ans += pattern2[i]
    ans += pattern1[i]
    
true_ans = ""
flag = False
for i in range(len(ans)):
    if ans[i]=="1":
        true_ans += "1"
        flag = True
    elif flag:
        true_ans += "0"

if true_ans == "":
    true_ans = "0"
        
print(true_ans)

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

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = max(a, b); i >= 0; i--)
    {
        if (a % i == 0 && b % i == 0)
            k--;
        if (k == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  n %= 10;
  if(n == 3)cout << "bon" << endl;
  else if(n == 0 || n == 1 || n == 6 || n == 8)cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3632
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXIST2(s,e) (find(ALL(s),(e))!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main(){
	string s;
	cin>>s;
	int n;
	cin>>n;
	int ans=0;
	REP(i,n){
		string r;
		cin>>r;
		REP(j,r.size()){
			bool flag=true;
			REP(k,s.size()){
				int ri=(j+k)%r.size();
				if(r[ri]!=s[k]){
					flag=false;
				}
			}
			if(flag){
				ans++;
				break;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1204
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    x = int(ipt())
    if x < 600:
        print(8)
    elif x < 800:
        print(7)
    elif x < 1000:
        print(6)
    elif x < 1200:
        print(5)
    elif x < 1400:
        print(4)
    elif x < 1600:
        print(3)
    elif x < 1800:
        print(2)
    elif x < 2000:
        print(1)
    else:
        pass


    return None

if __name__ == '__main__':
    main()


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

using namespace std;

int main(void)
{
    int N, Q;
    cin >> N;
    vector<int> S(N);
    for (auto &i : S) cin >> i;
    cin >> Q;
    vector<int> T(Q);
    for (auto &i : T) cin >> i;
    sort(S.begin(), S.end());
    int ans = 0;
    for (auto i : T)
    {
        int l = 0, r = N, m;
        while(l + 1 < r)
        {
            m = (l + r) / 2;
            if (S[m] > i) r = m;
            else l = m;
        }
        if (i == S[l]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3388
def isPalindrome(st): 
    for i in range(0, int(len(st)/2)):  
        if st[i] != st[len(st)-i-1]: 
            return False
    return True
st = input()
if isPalindrome(st):
	n1 = int((len(st) - 1)/2)
	n2 = int((len(st) + 3)/2) - 1
	if isPalindrome(st[0:n1]):
		if isPalindrome(st[n2:]):
			print("Yes")
		else:
			print("No")
	else:
		print("No")
else:
	print("No")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    if (n == 0) {
      	System.out.println(0);
    	return;
    }
    int[] h = new int[n];
    int[] dp = new int[n];

    for (int i = 0; i < n; i++) {
      h[i] = scan.nextInt();
    }

    Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0;
    scan.close();

	for (int i = 1; i < n; i++) {
      for (int j = 1; j <= 2; j++) {
        if (i - j < 0) continue;
        int currentCost = Math.abs(h[i] - h[i-j]);
        dp[i] = Math.min(dp[i], dp[i - j] + currentCost);
      }
    }

    System.out.println(dp[dp.length - 1]);
  }
}

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

int main(){
  int N;
  cin>>N;
  int ans;
  for(int i=1;i<50000;i++){
    ans=i*108/100;
    if(ans==N) {
      cout<<i;
      return 0;
    }
  }  
  cout<<":(";
}

Measured memory_bytes: 256
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd
input=sys.stdin.readline
w=0
ah=an=0
N=int(input())
for h in range(1,3501):
    for n in range(h,3501):
        if (4*h*n-N*n-N*h)!=0 and N*n*h%(4*h*n-N*n-N*h)==0:
            w=N*n*h//(4*h*n-N*n-N*h)
            ah=h
            an=n
            break
print(ah,an,w)

Measured memory_bytes: 68492
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

const ll MOD = 1000000007;

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    mint operator-() const {
        return mint(-x);
    }
    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t/2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}

struct counting {
    vector<mint> fact, ifact;
    counting(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint nCk(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint nPk(int n, int k){
        return fact[n]*ifact[n-k];
    }
    mint factorial (int n){
        return fact[n];
    }
} c(1000009);

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

    mint ans = 1;
    ans = mint(10).pow(N);
    mint sub = 1;
    sub = mint(9).pow(N);
    mint sub2 = mint(8).pow(N);
    cout << ans - sub - sub + sub2 << endl;

}


Measured memory_bytes: 18636