akhauriyash/Code-Regression huggingface dataset:
<?php
    while( true ) {
        fscanf( STDIN, "%d%d", $H, $W );
        if( 0 == $H && 0 == $W ) { break; }
         
        $buf = array();
        for( $i=0; $i<$H; $i++ ) {
            $row = '';
            for( $j=0; $j<$W; $j++ ) {
                $row .= '#';
            }
            array_push( $buf, $row );
        }
        print implode( "\n", $buf ).PHP_EOL.PHP_EOL;
    }
	return;

?>

Measured memory_bytes: 6712
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
map<ll,int> cnt;
struct Card{
	int c[4];
	void modify()
	{
		vector<vi> a(4);
		for(int i=0;i<4;i++)
		{
			for(int j=i;j<4;j++) a[i].push_back(c[j]);
			for(int j=0;j<i;j++) a[i].push_back(c[j]);
		}
		sort(a.begin(),a.end());
		for(int i=0;i<4;i++) c[i]=a[0][i];
	}
	inline int factor()
	{
		if(c[0]==c[1]&&c[1]==c[2]&&c[2]==c[3]) return 4;
		if(c[0]==c[2]&&c[1]==c[3]) return 2;
		return 1;
	}
}card[500];
inline ll Hash(Card a)
{
	ll ret=0;
	ll step=1000000000;
	for(int i=0;i<4;i++)
	{
		ret+=1LL*a.c[i]*step;
		step/=1000;
	}
	return ret;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		Card &cc=card[i];
		cin>>cc.c[0]>>cc.c[1]>>cc.c[2]>>cc.c[3];
		cc.modify();
		cnt[Hash(cc)]++;
	}
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			cnt[Hash(card[i])]--;
			cnt[Hash(card[j])]--;
			for(int k=0;k<4;k++)
			{
				Card up;
				int p=0;
				for(int kk=k;kk<4;kk++)
					up.c[p++]=card[i].c[kk];
				for(int kk=0;kk<k;kk++)
					up.c[p++]=card[i].c[kk];
				Card down=card[j];
				Card Back={up.c[0],down.c[1],down.c[0],up.c[1]};
				Card Front={up.c[3],up.c[2],down.c[3],down.c[2]};
				Card Left={up.c[0],up.c[3],down.c[2],down.c[1]};
				Card Right={up.c[2],up.c[1],down.c[0],down.c[3]};
				Back.modify();
				Front.modify();
				Left.modify();
				Right.modify();
				ll cur=1;
				ll bn=Hash(Back),fn=Hash(Front),ln=Hash(Left),rn=Hash(Right);
				//dbg(i,j,k,bn,fn,ln,rn);
				bool ok=1;
				if(!cnt[bn]) ok=0;
				cur*=cnt[bn];
				cnt[bn]--;
				if(!cnt[fn]) ok=0;
				cur*=cnt[fn];
				cnt[fn]--;
				if(!cnt[ln]) ok=0;
				cur*=cnt[ln];
				cnt[ln]--;
				if(!cnt[rn]) ok=0;
				cur*=cnt[rn];
				cnt[rn]--;
				cur*=Back.factor()*Front.factor()*Left.factor()*Right.factor();
				cnt[bn]++;
				cnt[fn]++;
				cnt[ln]++;
				cnt[rn]++;
				if(ok)
					ans+=cur;
			}
			cnt[Hash(card[i])]++;
			cnt[Hash(card[j])]++;
			//dbg(i,j,ans);
		}
	}
	cout<<ans/3<<endl;

}


Measured memory_bytes: 80128
#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>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin>>a>>b;
    if(a>b)cout<<a-1<<endl;
    else cout<<a<<endl;

    return 0;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        ArrayList<Integer> A = new ArrayList<>();
        ArrayList<Integer> B = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            A.add(ni());
            B.add(ni());
        }
        Collections.sort(A);
        Collections.sort(B);
        int minmed = 0;
        int maxmed = 0;
        int ans = 0;
        if(N%2==0){
            minmed = (A.get(N/2-1) + A.get(N/2));
            maxmed = (B.get(N/2-1) + B.get(N/2));
            ans = maxmed - minmed +1;
        }else{
            minmed = A.get((N-1)/2);
            maxmed = B.get((N-1)/2);
            ans = maxmed - minmed +1;
        }
        // System.out.println(minmed);
        // System.out.println(maxmed);
        out.println(ans);
    }

    final int mod = 1000000007;
    int mul(int x, int y){
        return (int)((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        return x >= mod ? (x - mod) : x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 63280
fun main(args: Array<String>) {
    val s = readLine()!!
    for (i in 0..(s.length - 2)) {
        if (s[i] == s[i + 1]) {
            println("${i+1} ${i+2}")
            return
        }
    }
    for (i in 0..(s.length - 3)) {
        if (s[i] == s[i + 2]) {
            println("${i+1} ${i+3}")
            return
        }
    }
    println("-1 -1")
}


Measured memory_bytes: 34280
#include<cstdio>
int main(void){char s[1200];int a[26]={0},i=0,n;while(scanf("%c",s+i++)!=EOF);n=i;for(i=0;i<n;++i){if((0<=(s[i]|0x20)-'a')&&((s[i]|0x20)-'a'<=25)){++a[(s[i]|0x20)-'a'];}};for(i=0;i<26;printf("%c : %d\n",'a'+i,a[i]),++i);return(0);}


Measured memory_bytes: 2692
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();
        var k = int.Parse(input.ReadLine());
        var n = s.Length;

        //var ss = new List<C>();
        //for(int i=0; i<n; i++) {
        //    var c = new C() { c = s[i], idx = i };
        //    ss.Add(c);
        //}

        //ss.Sort((x, y) => x.c - y.c);

        //HashSet<string> hash = new HashSet<string>();

        HashSet<string> hash = new HashSet<string>();
        List<string> list = new List<string>();
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                if (j - i + 1 <= k) {
                    var ss = s.Substring(i, j - i + 1);
                    if (!hash.Contains(ss)) {
                        hash.Add(ss);
                        list.Add(ss);
                    }
                }
            }
        }

        list.Sort(StringComparer.OrdinalIgnoreCase);

        return list[k - 1];
    }

    class C
    {
        public char c;
        public int idx;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13280
import Data.List
import Data.Array.IO
import Control.Monad
import Data.Char

main = do
  [h, w] <- map read . words <$> getLine :: IO [Int]
  input <- concat . map toMineNum . lines <$> getContents :: IO [Int]
  area <- newListArray ((1, 1), (h, w)) input :: IO (IOUArray (Int, Int) Int)
  mine <- newArray ((1, 1), (h, w)) 0 :: IO (IOUArray (Int, Int) Int)
  areaList <- getElems area
  mine' <- foldM (repeatAddMine area (h, w)) mine [(i, j) | i <- [1..h], j <- [1..w]]
  mineList <- getElems mine'
  let ans = unlines . toString w $ zipWith (\x y -> if x == 1 then '#' else intToDigit y) areaList mineList
  putStr ans

toString :: Int -> String -> [String]
toString _ [] = []
toString w s = (take w s) : (toString w $ drop w s)

toMineNum :: String -> [Int]
toMineNum []  = []
toMineNum (x:xs)
  | x == '.'  = 0:toMineNum xs
  | otherwise = 1:toMineNum xs

addMine :: IOUArray (Int, Int) Int -> (Int, Int) -> Int -> (Int, Int) -> IO Int
addMine area (h, w) n (x, y)
  | 1 <= x && x <= h && 1 <= y && y <= w = do
    m <- readArray area (x, y)
    return $ m + n
  | otherwise = return n

repeatAddMine :: IOUArray (Int, Int) Int -> (Int, Int) -> IOUArray (Int, Int) Int -> (Int, Int) -> IO (IOUArray (Int, Int) Int)
repeatAddMine area (h, w) mine (x, y) = do
  n <- foldM (addMine area (h, w)) 0 [(i, j) | i <- [x-1, x, x+1], j <- [y-1, y, y+1], (i, j) /= (x, y)]
  writeArray mine (x, y) n
  return mine


Measured memory_bytes: 1148
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>

int main()
{
    int A, B, C;

    scanf("%d %d %d", &A, &B, &C);

    if (A == B && B == C)
    {
        printf("Yes\n");
        return 0;
    }
    
    printf("No\n");
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	int list[4][3][10]={};
	for(int i=0;i<n;i++){
		int b,f,r,v;
		cin >> b >> f >> r >> v;
		list[b-1][f-1][r-1]+=v;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				cout << " " << list[i][j][k];
			}
			cout << endl;
		}
		if(i!=3){
			for(int j=0;j<20;j++)cout << '#';
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3096
import sys
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))
    sorted_A = sorted(A)

    l_left = N/2
    l_right = N/2 + 1
    for i in range(1, N + 1):
        if A[i - 1] <= sorted_A[l_left - 1]:
            print sorted_A[l_right - 1]
        else:
            print sorted_A[l_left - 1]


if __name__ == '__main__':
    main()

Measured memory_bytes: 30444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define for1(i, m, n) for (int i = m; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a > b) {
        puts("a > b");
    } else if (a < b) {
        puts("a < b");
    } else {
        puts("a == b");
    }
    return 0;
}


Measured memory_bytes: 3044
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];

		for (int i = 0; i < N-1; i++) {
			A[i] = sc.nextInt();
		}

		int result = A[0];
		for (int i = 0; i < N - 1; i++) {
			result += Math.min(A[i], A[i+1]);
		}

		System.out.println(result + A[N - 2]);
	}
}


Measured memory_bytes: 25172
s,x,y,h,w,k,n;main(i){for(;scanf("%d",&n)*n;printf("%d\n",s))for(s=0;n--;s+=k*200+400)for(k=2-scanf("%d%d%d%d",&x,&y,&h,&w),i=6;x+y+h<i*20+41&w<"(*-27<A"[i]-39;)k=i--;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define All(x) (x).begin(), (x).end()
#define lowbit(x) ((x) & -(x))
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const ll mod = 1e9 + 7;
const int N = 4e6 + 10;
const db pi = acos(-1);
list<int> v;
int main()
{
	int Q = read();
	auto it = v.begin();
	while(Q --)
	{
		int op = read();
		if(op == 0) it = v.insert(it, read());
		if(op == 1) advance(it, read());
		if(op == 2) it = v.erase(it);
	}
	for(auto x : v) cout << x << endl;
	return 0;
}



Measured memory_bytes: 18580
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;

const int maxn = 105, maxv = 1e5+5;
int n, s;
ll w[maxn], v[maxn], dp[maxn][maxv];
//dp(i, j): minimum weight to obtain value j using the first i objects
int main(){
	scanf("%d %d", &n, &s);
	int ts = 0;
	for(int i = 1; i<=n; i++){
		scanf("%lld %lld", &w[i], &v[i]);
		ts += v[i];
	}
	for(int i = 1; i<=ts; i++) dp[0][i] = 1e15;
	for(int i = 1; i<=n; i++){
		for(int j = 0; j<=ts; j++){
			dp[i][j] = dp[i-1][j];
			if (j-v[i]>=0) dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]]+w[i]);
		}
	}
	ll ans;
	for(int i = ts; i>=0; i--) if (dp[n][i]<=s) {ans = i; break;}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
#define Yes cout<<"Yes"<<endl; 
#define No cout<<"No"<<endl;
#define YES cout<<"YES"<<endl; 
#define NO cout<<"NO"<<endl;
#define yes cout<<"yes"<<endl; 
#define no cout<<"no"<<endl;
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
   string s;
   cin>>s;
   ll an=0;
   rep(i,s.size()){
       ll a = s[i] - '0';
    an+=a;
   }
   if(an%9==0){
       Yes;
   }else
   {
       No;
   }
   
    return 0;
}


Measured memory_bytes: 3708
#include<stdio.h>
#include<string.h>
#define INT 2147483647
#define M 2000000
int size=0;


void maxHeapify(int *A,int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if(l<=size && A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(l<=size && A[r]>A[largest])
    largest = r;
  if(largest!=i){
    int tmp;
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(A,largest);
  }
}

void insert(int *A){
  scanf("%d",&A[++size]);
  int p=size;
  while(A[p/2]<A[p]){
    int tmp;
    tmp=A[p/2];
    A[p/2]=A[p];
    A[p]=tmp;
    p/=2;
  }
}

int extract(int *A){
  int max;
  max= A[1];
  A[1]=A[size--];
  maxHeapify(A,1);
  return max;
}

int main(){
  int heap[M];
  char order[8];
  heap[0]=INT;
  while(1){
    scanf("%s",order);
    if(!strcmp("end",order)) break;
    else if(!strcmp("insert",order)) insert(heap);
    else if(!strcmp("extract",order)) printf("%d\n",extract(heap));
  }
  return 0;
}



Measured memory_bytes: 5716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n, k, l[15], r[15];
ll dp[200010], sum[200010];
const int mod = 998244353;
int main() {
    cin >> n >> k;
    for (int i = 1; i <= k; ++i) {
        scanf("%d%d", &l[i], &r[i]);
    }
    dp[1] = 1;
    sum[1] = 1;
    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j <= k; ++j) {
            if (i - l[j] < 1) continue;
            int left = max(i - r[j], 1);
            int right = i - l[j];
            //cout << i << " " << j << " " << left << " " << right << endl;
            dp[i] += sum[right] - sum[left - 1];
            dp[i] = (dp[i] % mod + mod) % mod;
        }
        //cout << i << " " << dp[i] << endl;
        sum[i] = dp[i] + sum[i - 1];
        sum[i] = (sum[i] % mod + mod) % mod;
    }
    printf("%lld\n", dp[n]);
}


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

#define MAX_N 200000

vector <int> adjlist[MAX_N];

int main(void)
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--; b--;
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }
    bool flag = false;
    for (int i = 0; i < adjlist[0].size(); i++) {
        int v = adjlist[0][i];
        for (int j = 0; j < adjlist[v].size(); j++) {
            if (adjlist[v][j] == n - 1) {
                flag = true;
                break;
            }
        }
    }
    if (flag) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
string s[100010];
int pd[100010][26];
int c[100010];
int main() {
    int n; cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> s[i];
        char array[10];
        for (int j=0; j<10; ++j) {
            array[j] = s[i][j];
        }
        sort(array, array+10);
        for (int j=0; j<10; ++j) {
            s[i][j] = array[j];
        }
        //cout << s[i] << endl;
        c[i]=1;
    }
 
  	map<string, long long int> m;
    for(int i=0; i<n; ++i) {
        m[s[i]]++;
    }
  	
	long long int ans =0;
    for( auto i = m.begin(); i != m.end() ; ++i ) {
        //std::cout << i->first << " " << i->second << "\n";
      	long long int tmp = (i->second);
    	ans += (tmp-1)*((tmp-1)+1)/2;
    }
 
    cout << ans << endl;
 
    return 0;
}



Measured memory_bytes: 18560
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static void Main()
    {
        long H = long.Parse(Console.ReadLine());
        long num = 1;
        long ans = 0;
        while (H >= 2)
        {
            H = H / 2;
            ans+=num;
            num *= 2;
        }
        ans += num;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
import java.util.*;

class Main2{
    public static void main(String[] args){
        // 入力受付
        Scanner sc = new Scanner(System.in);    //scanner
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        // バトル
        while(true){
            // 高橋くんの攻撃
            C-=B;
            if(C<=0){
                System.out.println("Yes");
                break;
            }
            // 青木くんの攻撃
            A-=D;
            if(A<=0){
                System.out.println("No");
                break;
            }
        }
    }
}


// 別解
class Main{
    public static void main(String[] args){
        // 入力受付
        Scanner sc = new Scanner(System.in);    //scanner
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        // 計算
        if( (A+D-1)/D >= (C+B-1)/B)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 35820
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,boundary=1,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0
s=input()
if s[2]==s[3] and s[4]==s[5]:
    a=0
else:
    a=1
ans=Yn[a]
print(ans)


Measured memory_bytes: 39276
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  int n;
  cin>>n;
  
  vector<int> P(n),Q(n);
  rep(i,n) cin>>P[i];
  rep(i,n) cin>>Q[i];
  
  int x=0;
  do{
    x++;
  }while(next_permutation(ALL(P)));
  
  int y=0;
  do{
    y++;
  }while(next_permutation(ALL(Q)));
  
  cout<<abs(x-y)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll n,m;
ll a[maxn];
int main() {
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<n;i++){
		if(a[i]==a[i+1]){
			cout<<"NO\n";
			return 0;
		}
	} 
	cout<<"YES\n";
    return 0;
}



Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	sum= a+b+c;
	int ans=max(a,max(b,c));
		sum +=ans*(pow(2,k)-1);
		cout <<sum<<endl;
		return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    cin >> N;
    for(int i = 1; ;i++){
        if(i*i > N){
            ans = (i -1) * (i - 1);
            break;
        }
    }
    cout << ans << endl;
    return 0;
    
}

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

int N,M,Q;
vector<ll> a,b,c,d;

ll ans = 0;

void dfs(vector<int> &A){
  
  int L = A.size();
  if(L==N){
    ll sum = 0;
    for(int i=0;i<Q;i++){
      if(A[b[i]-1]-A[a[i]-1]==c[i]){
        sum += d[i];
      }
    }
    ans = max(ans,sum);
    return;
  }
  
  int under;
  if(L==0){
    under = 1;
  }else{
    under = A[L-1];
  }
  
  for(int v=under;v<=M;v++){
    A.push_back(v);
    dfs(A);
    A.pop_back();
  }
}

int main(){
  cin >> N >> M >> Q;
  a.resize(Q);b.resize(Q);c.resize(Q);d.resize(Q);
  for(int i=0;i<Q;i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
  vector<int> A;
  dfs(A);
  cout << ans << endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
const ll inf = 1e10;



int n;
pair<ll,ll> a[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>a[i].first>>a[i].second;
	if (a[i].first>a[i].second) {
	    swap(a[i].first, a[i].second);
	}
    }


    ll l1=inf,r1=0,l2=inf,r2=0;
    for (int i=0; i<n; i++) {
	l1=min(l1,a[i].first);
	r1=max(r1,a[i].first);
	
	l2=min(l2,a[i].second);
	r2=max(r2,a[i].second);
    }

    ll ans = (r1-l1)*(r2-l2); //global min and global max are in different sets
    


    
    ll len = max(r1,r2) - min(l1,l2);

    sort(a,a+n);
    reverse(a,a+n);



    //init multiset with elements from `second`
    multiset<ll> ms;
    for (int i=0; i<n; i++) ms.insert(a[i].second);


    //global min and global max are both in first set
    //this means that we're trying to minimize range in the second set
    //

    //iterate first set from hi to lo,
    //->this keeps an "upper bound" on the high values that contribute from first set
    
    //(5,6) swapping in the 5 is an improvement on the upper bound
    //(3,300) but we have to wait until here to swap in the 3 for 5 to become the upper bound
    //...

    
    for (int i=0; i<n; i++) {
	//swap `second` with `first` (i.e, swap with something smaller)
	
	ms.erase(ms.find(a[i].second)); ms.insert(a[i].first);
	
	ll cur = len*(*ms.rbegin() - *ms.begin());
	//watch(cur);
	ans = min(cur, ans);
    }
  
    
    cout<<ans<<endl;  

    return 0;
}


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

int main() {
	size_t H, W;
	cin >> H >> W;
	vector<string> A(H + 2);
	for (size_t i = 0; i < W + 2; ++i) {
		if (i == 1) A[0] += '#';
		else A[0] += '.';
	}
	for (size_t i = 1; i <= H; ++i) {
		cin >> A[i];
		A[i] = '.' + A[i] + '.';
	}
	for (size_t i = 0; i < W + 2; ++i) {
		if (i == W) A[H + 1] += '#';
		else A[H + 1] += '.';
	}
	bool ans = true;
	for (size_t i = 1; i <= H; ++i) {
		for (size_t j = 1; j <= W; ++j) {
			if (A[i][j] == '#') {
				int tmp1 = 0, tmp2 = 0;
				if (A[i - 1][j] == '#') ++tmp1;
				if (A[i][j - 1] == '#') ++tmp1;
				if (A[i + 1][j] == '#') ++tmp2;
				if (A[i][j + 1] == '#') ++tmp2;
				if (tmp1 != 1 || tmp2 != 1) ans = false;
			}
		}
	}
	if (ans) cout << "Possible";
	else cout << "Impossible";
}

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


int main() {
  
  int p, q, r;
  cin >> p >> q >>r;
  
  vector<int> jikan;
  jikan = { p, q, r};
  
  sort ( jikan.begin(), jikan.end() );
  
  cout << jikan.at(0) + jikan.at(1) << endl;
  
}

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

using namespace std;

#define llong long long int
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    llong n, m;
    cin >> n >> m;
    vector<llong> cum(n + 1);
    cum[0] = 0;
    rep(i, n) {
        llong a;
        cin >> a;
        cum[i + 1] = cum[i] + a;
    }

    map<llong, llong> M;
    for (int i = 0; i < n + 1; ++i) {
        M[cum[i] % m] += 1;
    }

    llong ans = 0;
    stl_rep(itr, M) {
        ans += itr->second * max((llong)0, (itr->second - 1)) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int n; cin>>n;
    deque<ll> b;
    for(int i=0;i<n;i++){
        ll a; cin>>a;
        if(i%2==0){
            b.push_back(a);
        }
        else{
            b.push_front(a);
        }
    }
    int size=b.size();
    if(n%2==0){
        for(auto itr=b.begin();itr<b.end();itr++){
            cout<<*itr<<" ";
        }
    }
    else{
        for(auto itr=b.end()-1;itr>=b.begin();itr--){
            cout<<*itr<<" ";
        }
    }

    return 0;
}

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

a=[]

for i in range(0,n):
    aa=input().split()
    for j in range(0,m+1):
        aa[j]=int(aa[j])
    a.append(aa)

smin=1000000*n
d=1000000*n


for i in range(0,2**n):
    mo=0
    x2=[0 for i2 in range(0,m)]
    
    for j in range(0,n):
        if ((i>>j)&1)==1:
            mo+=a[j][0]
            for k in range(0,m):
                x2[k]+=a[j][k+1]

    if min(x2)>=x:
        if mo<smin:
            smin=mo
    

if smin==d:
    print(-1)

else:
    print(smin)

Measured memory_bytes: 9248
program apple
implicit none
integer::d, n
 read(5,*)d, n
  if(d==0 .and. n<100) then
   print*,n
  else if(d==0 .and. n==100)then
   print*,101
  else if(d==1 .and. n<100)then
   print*,n*100
  else if(d==1 .and. n==100)then
   print*,10100
  else if(d==2 .and. n<100)then
   print*,n*10000
  else
   print*,1010000
  end if
end program apple

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	string s;
	cin>>n>>s;
	ll cnt[2][214514];
	cnt[0][0]=cnt[1][0]=0;
	for(int i=1;i<=n;i++){
		cnt[0][i]=cnt[0][i-1];
		cnt[1][i]=cnt[1][i-1];
		if(s[i-1]=='W')cnt[0][i]++;
		else cnt[1][i]++;
	}
	ll ans=1e9;
	for(int i=0;i<=n;i++){
		ans=min(ans,max(cnt[0][i],cnt[1][n]-cnt[1][i]));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

long long getXY(vector<long> elements)
{ 
  int n = elements.size();
  
  vector< vector<long long> > xy(n, vector<long long>(n, 0));
  
  for(int gap=0; gap<n; gap++)
  {
    for(int i=0; i<n && i+gap<n; i++)
    {
      int j = i+gap;
      if(i == j)
        xy[i][j] = elements[i];
      else
        xy[i][j] = max( elements[i] - xy[i+1][j], elements[j] - xy[i][j-1]);
    }
  }
  
  return xy[0][n-1];
}

int main()
{
  int n;
  cin >> n;
  
  vector<long> elements(n);
  
  for(int i=0; i<n; i++)
  {
    cin >> elements[i];
  }
  
  cout << getXY(elements) << endl;
  
  return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
const double EPS = 1e-8;

struct P{
  double x, y;
  bool f;
  P(){}
  P(double x, double y, bool f) :x(x), y(y), f(f) {}
};

bool const operator<(const P &a, const P &b) {
  return a.x != b.x ? a.x < b.x : a.y != b.y ? a.y < b.y : a.f < b.f;
}

int main() {
  int n, m;
  while(cin >> n >> m, n||m) {
    P p[n+m];
    REP(i, n+m){
      int x, y;
      cin >> x >> y;
      p[i] = P(x,y,i>=n);
    }
    bool dame = 0;
    for (int i=1; i<n+m; ++i) {
      REP(j, i) {
//        cout << n << " " << m << endl;
        dame = 0;
        vector<P> v;
        
        if (p[i].x == p[j].x) {
          int f = -1;
          REP(k, n+m) {
            if (p[i].x == p[k].x) v.push_back(p[k]);
            else {
              if (f == -1) {
                f = (p[k].x > p[i].x) ^ p[k].f;
              } else {
                if (f != (p[k].x > p[i].x) ^ p[k].f) {
                  dame = 1;
                  break;
                }
              }
            }
          }
        } else {
          double a = (p[j].y-p[i].y) / (p[j].x-p[i].x);
          double b = p[i].y - a*p[i].x;

          //cout << a << " " << b << endl;
          int f = -1;
          REP(k, n+m) {
            if (abs(p[k].y - a*p[k].x - b) < EPS) {
              v.push_back(p[k]);
            } else {
              bool ue = p[k].y > a*p[k].x + b;
              //cout << p[k].f << " " << ue  << endl;
              //cout << ue << " " << k <<  " " << (p[k].f ^ ue) << endl;
              if (f == -1) {
                f = p[k].f ^ ue;
              } else {
                if (f != p[k].f ^ ue) {
                  dame = 1;
                  break;
                }
              }
            }
          }
        }
        if (!dame) {
          sort(ALL(v));
          int f = -1;
          int state = 0;
          REP(k, v.size()) {
            //cout << v[k].x << " " << v[k].y << endl;
            if (f == -1) {
              f = v[k].f;
            } else {
              if (f != v[k].f) {
                if (state == 0)
                  state = 1;
                else {
                  dame = 1;
                  break;
                }
              }
            }
            f = v[k].f;
          }
          if (!dame) {
            //printf("%d %d (%f,%f) (%f,%f)", i, j, p[i].x,p[i].y , p[j].x, p[j].y);
            break;
          }
        }
      }
      if (!dame) break;
    }
    if (!dame) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 904
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n-1)]
    r = []
    for i in range(n-1):
        s = a[i][0] + a[i][1]
        for j in range(i+1,n-1):
            if s <= a[j][1]:
                s = a[j][1]
            else:
                if s % a[j][2] > 0:
                    s += a[j][2] - s % a[j][2]
            s += a[j][0]
        r.append(s)
    r.append(0)

    return '\n'.join(map(str,r))

print(main())




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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,m;
  cin >> n >> m;
  REP(i,m/2){
    cout << i+1 << " " << m-i << "\n";
  }
  REP(i,(m+1)/2){
    cout << n-i << " " << n - m + i << "\n";
  }
  return 0;
}

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

int main() {
  int N;
  scanf("%d", &N);
  int A = N / 2;
  int B = N - A;

  int min_sum_all = 100000;
  for (int i = 0; i < N / 2; i++) {
    int sum_A = 0;
    int sum_B = 0;

    int tmp_A = A;
    while (tmp_A > 0) {
      int a = tmp_A % 10;
      sum_A += a;
      tmp_A = tmp_A / 10;
    }

    int tmp_B = B;
    while (tmp_B > 0) {
      int b = tmp_B % 10;
      sum_B += b;
      tmp_B = tmp_B / 10;
    }

    if (sum_A + sum_B < min_sum_all) {
      min_sum_all = sum_A + sum_B;
    }
    
    A--;
    B++;
  }
  printf("%d", min_sum_all);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int k, i, d[100003] = {}, ds, pv, nv;
    priority_queue<P, vector<P>, greater<P>> pq;

    scanf("%d", &k);

    for (i = 0; i < k; i++) {
        d[i] = INF;
    }

    for (i = 1; i < 10; i++) {
        if (d[i % k] > i) {
            d[i % k] = i;
            pq.push(P(i, i % k));
        }
    }

    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        ds = p.first;
        pv = p.second;
        if (d[pv] < ds) {
            continue;
        }
        for (i = 0; i < 10; i++) {
            nv = (pv * 10 + i) % k;
            if (d[nv] > ds + i) {
                d[nv] = ds + i;
                pq.push(P(d[nv], nv));
            }
        }
    }

    printf("%d\n", d[0]);

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef set<ll> si;
typedef map<string, ll> msi;
#define hell 1000000007
#define MAX 1000000000
#define max_int 1000000
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define pi 3.1415926536
#define r0 return 0
#define rep(i,a,b) for(ll i = a;i<b;i++)

// void solve() 
// {


//     return;
// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    // int t=1;
    // cin>>t;
    // while(t--)
    // {
    //     int n;
    //     cin>>n;

    //     //solve();     
    // }
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(ceil(a/d)>=ceil(c/b)?"Yes":"No");
}
 

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
    
    lli n;
    cin >> n;
    vector <lli> colour(n+1),visited(n+1);
    vector < vector <lli> > graph(n+1);
    colour[1] = 0;
    visited[1]= 1;
    map < pair <lli,lli>,lli > distances;
    for(int i =1;i<n;i++){
        lli u,v,w;
        cin >> u >> v >> w;
        graph[u].push_back(v);
        graph[v].push_back(u);
        distances[{u,v}] = w;
        distances[{v,u}] = w;
    }
    queue <lli> q;
    q.push(1);
    while(!q.empty()){
        lli parent = q.front();
        q.pop();
        for(int i =0;i<graph[parent].size();i++){
                lli child = graph[parent][i];
            if(!visited[child]){
                if(distances[{parent,child}] % 2 ==0){
                    colour[child] = colour[parent];
                }else{
                    colour[child] = colour[parent] ^ 1;
                }
                q.push(child);
                visited[child] = 1;
            }
        }
    }
    for(int i =1;i<=n;i++)cout << colour[i] << "\n";
    cout << endl;
}


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

int D;
int C[26];
int S[365][26];

int64_t evaluate(const vector<int> &T) {
  int64_t res = 0;
  vector<int> last(26);
  for (int i = 0; i < T.size(); ++i) {
    res += S[i][T[i] - 1];
    last[T[i] - 1] = i + 1;
    for (int j = 0; j < 26; ++j) {
      res -= C[j] * (i + 1 - last[j]);
    }
  }
  return res;
}

int64_t evaluate_modify(const vector<int> &T, int d, int q, int64_t v) {
  if (T[d - 1] == q) return v;
  int64_t res = v - S[d - 1][T[d - 1] - 1] + S[d - 1][q - 1];
  auto sum = [](int n) { return (n + 1) * n / 2; };
  for (int x : { T[d - 1], q }) {
    int l, r;
    for (l = d - 2; ~l; --l) if (T[l] == x) break;
    for (r = d; r < T.size(); ++r) if (T[r] == x) break;
    res += (x == q ? -1 : +1) * C[x - 1] * sum((d - 1) - l - 1);
    res += (x == q ? -1 : +1) * C[x - 1] * sum(r - (d - 1) - 1);
    res -= (x == q ? -1 : +1) * C[x - 1] * sum(r - l - 1);
  }
  return res;
}

int main() {
  cin >> D;
  for (int i = 0; i < 26; ++i) cin >> C[i];
  for (int i = 0; i < D; ++i) for (int j = 0; j < 26; ++j) cin >> S[i][j];

  vector<int> T(D);
  for (int i = 0; i < D; ++i) cin >> T[i];

  int v = evaluate(T);

  int M;
  cin >> M;
  for (int i = 0; i < M; ++i) {
    int d, q;
    cin >> d >> q;
    v = evaluate_modify(T, d, q, v);
    T[d - 1] = q;
    cout << v << endl;
  }


  return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll ans = 1;
  while(ans * 2 <= n) ans *= 2;
  cout << ans << endl;
}

Measured memory_bytes: 3596
n = gets.chomp
str = gets.chomp

len = str.length
ans = len

wcounts = []
ecounts = []

len.times do |i|
  wcounts[i] = i == 0 ? 0 : wcounts[i-1]
  wcounts[i] += 1 if str[i] == 'W'
end

len.times do |i|
  j = len - i - 1
  ecounts[j] = j == len - 1 ? 0 : ecounts[j+1]
  ecounts[j] += 1 if str[j] == 'E'
end

# p wcounts
# p ecounts

ans = len

len.times do |i|
  if i == 0
    count = ecounts[i+1]
  elsif i == len - 1
    count = wcounts[i]
  else
    count = wcounts[i] + ecounts[i+1]
  end
  ans = [ans, count].min
end

puts ans


Measured memory_bytes: 7180
S = input()
N = len(S)
ans = [0]*N

cnt = 0
for i in range(N-1):
    if S[i] == 'R':
        cnt += 1
        if S[i+1] == 'L':
            ans[i+1] = cnt//2
            ans[i] = (cnt+1)//2
    else:
        cnt = 0


cnt = 0
for i in reversed(range(1, N)):
    if S[i] == 'L':
        cnt += 1
        if S[i-1] == 'R':
            ans[i-1] += cnt//2
            ans[i] += (cnt+1)//2
    else:
        cnt = 0

print(*ans)


Measured memory_bytes: 6400
import math

k = int(input())

ans = 0

for i in range(k):
  for j in range(i,k):
    for h in range(j, k):
      if i == j == h:
        ans += math.gcd(math.gcd(i+1, j+1), h+1)
      elif (i != j) and (j != h) and (i != h):
        ans += math.gcd(math.gcd(i+1, j+1), h+1) * 6
      else:
      	ans += math.gcd(math.gcd(i+1, j+1), h+1) * 3
      
print(ans)

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

int main() {
	string S, T;
	cin >> S >> T;
	sort(S.begin(), S.end());
	sort(T.begin(), T.end(), greater<char>());
	if (S < T) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll two[75],s;
int a[210],b[75],c[210];
int i,j,k,l,t,n,m,mx,tot,top,now;
int main(){
    cin>>s;
    two[0]=1;
    for(i=1;i<=50;i++) two[i]=(ll)two[i-1]*2;
    mx=50;
    while (two[mx]>s) mx--;
    s-=two[mx];
    m=mx;
    tot=2*m;
    now=m;
    c[++top]=now+1;
    c[++top]=now+1;
    now++;
    tot+=2;
    while (s){
        while (two[mx]>s) mx--;
        s-=two[mx];
        b[mx]=++now;
        c[++top]=now;
        tot+=2;
    }
    printf("%d\n",tot);
    for(i=0;i<=m;i++){
        if (i) printf("%d ",i);
        if (b[i]) printf("%d ",b[i]);
    }
    for(i=1;i<=m;i++) printf("%d ",i);
    for(i=1;i<=top;i++) printf("%d ",c[i]);
}


Measured memory_bytes: 256
import fractions
N = int(input())
A = list(map(int, input().split()))
right = [A[0]]*N
left = [A[-1]]*N
for i in range(1,N):
    right[i] = fractions.gcd(right[i-1],A[i])
    left[N-1-i] = fractions.gcd(left[N-i],A[N-1-i])
ans = left[1]
for i in range(N-2):
    ans = max(ans,fractions.gcd(right[i],left[i+2]))
print(max(ans,right[N-2]))


Measured memory_bytes: 16152
#include <bits/stdc++.h>
#define mod 1000000007
#define djfs first
#define akdk second
#define N 100000000
#define fo(i,m,n) for(int i=m;i<n;i++)
#define M 7
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
using ul=unsigned long long;
using pii=pair<int,int>;
using vvi=vector<vector<int>>;
using vi=vector<int>;
using pll=pair<ll,ll>;
using vsi=vector<set<int>>;
using vll=vector<ll>;

ll power(ll a,ll n){
    ll j=0;
    ll x=1;
    while(1ll<<j<=n){
        if(1ll<<j&n)
            x=(x*a)%mod;

        a=a*a%mod;
        j++;
    }

    return x;
}

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

}

int lb(vi &a,int x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;
    while(l<=r){
        int mid=(l+r)/2;
        if(x>=a[mid]){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind+1;

}

int up(vll &a,ll x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;

    while(l<=r){
        int mid=(l+r)/2;
        if(a[mid]>x){
            r=mid-1;
            ind=mid;
        }
        else
            l=mid+1;

    }

    return ind;
}

ll max(ll a,ll b){
    if(a>b)
        return a;
    else
        return b;

}

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

}

void yn(bool a){
    if(a)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

}


bool isodd(int a,int b,int agx,int agy){

    return (abs(a-agx)+abs(b-agy))%2;

}
int fap(vi &par,int x){
    if(par[x]!=x)
        par[x]=fap(par,par[x]);

    return par[x];
}

void unin(vi &par,vi &rank,int x,int y){
    int px=fap(par,x);
    int py=fap(par,y);

    if(px!=py){
        if(rank[px]<rank[py])
            swap(px,py);

        par[py]=px;
        rank[px]+=rank[py];
    }
}

struct fenwick_tree
{
    vll bit;
    int n;
    fenwick_tree(int n){
        this->n=n;
        bit=vll(n+1);
    }

    void update(int idx,ll val){
        while(idx<=n){
            bit[idx]+=val;
            idx+=idx&-idx;
        }
    }

    void rupdate(int l,int r,int x){
        update(l,x);
        update(r+1,-x);
    }

    ll query(int idx){
        ll tot=0;
        while(idx){
            tot+=bit[idx];
            idx-=idx&-idx;
        }

        return tot;
    }

};


int main(){

    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    cout<<max(max(a*c,b*d),max(a*d,b*c))<<endl;

}


Measured memory_bytes: 3636