akhauriyash/Code-Regression huggingface dataset:
import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;
 
long count;
 
void main()
{
    readln();
    int[] list = readln().split.to!(int[]);
    auto sortedList = list.dup.sort();

    bool[] bList;
    long[][] cycleList;
    bList.length = list.length;

    foreach(i; 0..list.length)
    {
        if(bList[i])
            continue;
        long nextIndex = i;
        long[] cycle;
        while(true)
        {
            bList[nextIndex] = true;
            cycle ~= list[nextIndex];
            nextIndex = sortedList.countUntil(list[nextIndex]);
            if(i == nextIndex)
                break;
        }
        cycleList ~= cycle;
    }
    long min = sortedList[0];
    foreach(c; cycleList)
    {
        long cMin = c.reduce!"a<b?a:b";
        long a = cMin * (c.length - 2) + c.sum();
        long b = min * (c.length - 1) + c.sum() - cMin + (min+cMin)*2;
        count += a<b?a:b;
    }
    writeln(count);
}
 
sizediff_t minIndex(alias pred="a<b", R) (R list)
    if(isForwardRange!R && !isInfinite!R && is(typeof(binaryFun!pred(list.front, list.front))))
{
    assert(!list.empty);
    typeof(list.front) min = list.front;
    sizediff_t minPos;
    sizediff_t curPos;
    for(list.popFront(); !list.empty; list.popFront())
    {
        curPos++;
 
        if(binaryFun!pred(list.front, min))
        {
            min = list.front;
            minPos = curPos;
        }
    }
    return minPos;
}



Measured memory_bytes: 2524
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int a,b,c,i,k = 0;
	while ( cin >> a >> b >> c){
		for( i = a ; i <= b ; i++ ){
			if ( (c % i) == 0 ){
				k++;
			}
		}
		cout << k << endl;
	}
	return 0;
} 


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, M, S; cin >> N >> M >> S;
  using Tuple = tuple<ll, ll, ll>;
  vector nbr(N, vector<Tuple>());
  for (ll i = 0; i < M; i++) {
    ll u, v, a, b; cin >> u >> v >> a >> b; u--; v--;
    nbr.at(u).emplace_back(v, a, b);
    nbr.at(v).emplace_back(u, a, b);
  }
  vector<ll> C(N), D(N);
  for (ll i = 0; i < N; i++) {
    ll c, d; cin >> c >> d;
    C.at(i) = c;
    D.at(i) = d;
  }
  ll lim = 50 * N + 1;
  vector rec(N, vector(lim, LLONG_MAX));
  priority_queue<Tuple, vector<Tuple>, greater<Tuple>> pque;
  if (S >= lim) S = lim - 1;
  auto check = [&](ll t, ll n, ll s) -> void {
    if (!(0 <= s && s < lim && t < rec.at(n).at(s))) return;
    pque.emplace(t, n, s);
    for (ll y = s; y >= 0 && t < rec.at(n).at(y); y--) rec.at(n).at(y) = t;
  };
  rec.at(0).at(S) = 0;
  pque.emplace(0, 0, S);
  while (!pque.empty()) {
    auto [t, i, s] = pque.top(); pque.pop();
    if (rec.at(i).at(s) < t) continue;
    check(t + D.at(i), i, s + C.at(i));
    for (auto [j, a, b] : nbr.at(i)) check(t + b, j, s - a);
  }
  for (ll j = 1; j < N; j++) {
    cout << rec.at(j).at(0) << "\n";
  }

  return 0;
}



Measured memory_bytes: 4544
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	string s;
	string a="CODEFESTIVAL2016";
	cin >> s;
	int ans=0;
	for(int i=0; i<s.size(); i++){
		if(s[i]!=a[i]){
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << '=' << x << '\n'
const long long MOD=1e9+7;
//const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?'\n':' ');
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;} return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;} return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    if (N&1){
        for (int i=1;i<=M;++i)
            cout << i << ' ' << N+1-i << '\n';
    } else {
        int ok=1;
        for (int i=1;i<=M;++i){
            if (ok){
                cout << i << ' ' << N+1-i << '\n';
                if (N/2<=i+(i+1)) ok=0;
            } else cout << i << ' ' << N-i << '\n';
        }
    }

}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace _1_A
//{
    class Program
    {
    static void Main(string[] args)
    {
        string a = Console.ReadLine();
        string[] array = a.Split(' ');

        int i = int.Parse(array[0]);
        int j = int.Parse(array[1]);
        int k = int.Parse(array[2]);

        if (i < j && j < k)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
    }
//}

Measured memory_bytes: 8856
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

type pos struct {
	x, y, h int
}

func check(cx, cy int, p []pos) (int, bool) {
	h := p[0].h + abs(p[0].x-cx) + abs(p[0].y-cy)
	// out(cx, cy, h, p[0])
	for _, v := range p {
		x := max(h-abs(v.x-cx)-abs(v.y-cy), 0)
		if x != v.h {
			return 0, false
		}
	}
	return h, true
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	p := make([]pos, N+1)
	for i := 1; i <= N; i++ {
		p[i].x, p[i].y, p[i].h = getInt(), getInt(), getInt()
		if p[i].h > 0 {
			p[0] = p[i]
		}
	}

	for y := 0; y <= 100; y++ {
		for x := 0; x <= 100; x++ {
			h, ok := check(x, y, p)
			if ok {
				out(x, y, h)
				return
			}
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
using namespace std;
int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int count(int y,int m,int d){//1/1/1~y/m/d?????\??°(1/1/1=1)
	int num=0;
	if((!(y%4)&&(y%100))||(!(y%400)))month[1]=29;
	for(int i=0;i<m-1;i++){
		num+=month[i];
	}
	num+=d;
	month[1]=28;
	//printf("%d/%d/%d:%d\n",y,m,d,num);
	return num;
}
int main()
{
	int y1,m1,d1,y2,m2,d2;
	while(cin>>y1>>m1>>d1>>y2>>m2>>d2){
		if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0)break;
		int ans=0;
		if(y1==y2){
			ans=count(y2,m2,d2)-count(y1,m1,d1);
		}else if(y2-y1==1){
			ans=365-count(y1,m1,d1)+count(y2,m2,d2);
			if((!(y1%4)&&(y1%100))||(!(y1%400)))ans++;
		}else{
			y1++;y2--;
			ans+=(y2-y1+1)*365+(y2/4-y2/100+y2/400)-((y1-1)/4-(y1-1)/100+(y1-1)/400);
			ans+=count(++y2,m2,d2)+365-count(--y1,m1,d1);
			if((!(y1%4)&&(y1%100))||(!(y1%400)))ans++;
		}
		cout<<ans<<endl;

	}
    return 0;
}

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

int main(){
  int n, k; cin >> n >> k;
  int l[n];
  for(int i=0; i<n; i++) cin >> l[i];

  sort(l, l+n);

  int ans=0;
  for(int i=0; i<k; i++) ans += l[n-1-i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

inline int read()
{
	int f=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}

int n,k;
char a[15];

int main()
{
	n=read();
	scanf("%s",a+1);
	k=read();
	for(int i=1;i<=n;i++)
	{
		if(a[i]==a[k]) printf("%c",a[i]);
		else printf("*");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<set>
#include<vector>
using namespace std;
int mod=998244353;
int add(int x, int y)
{
	int c=x+y;
	if(c>=mod)c-=mod;
	return c;
}
int sub(int x, int y)
{
	int c=x-y;
	if(c<0)c+=mod;
	return c;
}
int mlt(int x, int y)
{
	long long c=x*1LL*y;
	if(c>=mod)c%=mod;
	return c;
}
int main()
{
	int n;
	cin>>n;
	vector<long double>a(n), b(n);
	int pos=0;
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		if(a[i]>a[pos])pos=i;
	}
	for(int i=0; i<n; i++)cin>>b[i];
	vector<long double>a1,b1;
	for(int i=pos; i<n; i++)
	{
		a1.push_back(a[i]);
		b1.push_back(b[i]);
	}
	for(int i=0; i<=pos; i++)
	{
		a1.push_back(a[i]);
		b1.push_back(b[i]);
	}
	long double cursum=a1[0];
	vector<long double> koefs(n+1), left(n+1), right(n+1), prob(n+1);
	vector<int>nxt(n+1), prev(n+1);
	set<int>positive;
	for(int i=1; i<n; i++)
	{
		prob[i]=1.0/(long double)n;
		left[i]=0.5;
		right[i]=0.5;
		cursum+=a1[i];
		koefs[i]=a1[i-1]/2.0+a1[i+1]/2.0-a1[i]-b1[i];
		if(koefs[i]>0)positive.insert(i);
	}
	cursum/=(long double)n;
	for(int i=0; i<n; i++)
	{
		nxt[i]=i+1;
		prev[i+1]=i;
	}
	set<int>::iterator it;
	while(positive.size()>0)
	{
		/*for(it=positive.begin();it!=positive.end(); it++)cerr<<*it<<' ';
		cerr<<endl;
		for(int i=0; i<=n; i++)cerr<<' '<<koefs[i]<<' '<<left[i]<<' '
		<<right[i]<<' '<<prob[i]<<' '<<nxt[i]<<' '
		<<prev[i]<<endl;
		cerr<<endl;*/
		it=positive.begin();
		int p=*it, pr=prev[p], nx=nxt[p];
		positive.erase(p);
		cursum+=prob[p]*koefs[p];
		prob[pr]+=prob[p]*left[p];
		prob[nx]+=prob[p]*right[p];
		long double valpr, prl=left[pr], prr=right[pr], stay;
		stay=prr*left[p];
		prr=prr*right[p];
		long double sum=prl+prr;
		prl/=sum;
		prr/=sum;
		left[pr]=prl;
		right[pr]=prr;
		long double esc=koefs[pr]+prr*koefs[p], rem=koefs[pr]+koefs[p];
	//	cerr<<"sasa "<<esc<<' '<<rem<<' '<<stay<<endl;
		valpr=esc+rem/(1.0-stay)-rem;
		koefs[pr]=valpr;
		if(valpr>0)
			if(pr>0)
				positive.insert(pr);
		prl=left[nx], prr=right[nx];
	//	cerr<<nx<<' '<<prl<<' '<<prr<<' '<<right[pr]<<endl;
		stay=prl*right[p];
		prl=prl*left[p];
		sum=prl+prr;
		prl/=sum;
		prr/=sum;
		left[nx]=prl;
		right[nx]=prr;
		esc=koefs[nx]+prl*koefs[p], rem=koefs[nx]+koefs[p];
		valpr=esc+rem/(1.0-stay)-rem;
	//	cerr<<"sasa "<<esc<<' '<<rem<<' '<<stay<<endl;
		koefs[nx]=valpr;
		if(valpr>0)
			if(nx>0)
				positive.insert(nx);
		nxt[pr]=nx;
		prev[nx]=pr;
	}
	cout.precision(25);
	cout<<cursum<<endl;
}


Measured memory_bytes: 34644
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int dx[] ={ 0,1,0,-1};
const int dy[] ={-1,0,1, 0};

int main(){
	int n;
	while(cin >> n , n){
		long double dp[16][5][5] = {{{0.0}}};
		char map[5][5];
		rep(i,5)rep(j,5)map[i][j] = 'X';
		rep(i,3)rep(j,3)map[i+1][j+1] = ' ';
		int sx, sy, gx, gy, bx, by;
		char s,t,b;
		cin >> s >> t >> b ;
		sy = (s-'A')/3 +1 , sx = (s-'A')%3 +1;
		gy = (t-'A')/3 +1 , gx = (t-'A')%3 +1;
		by = (b-'A')/3 +1 , bx = (b-'A')%3 +1;
		
		map[by][bx] = 'X';
		dp[n][sy][sx] = 1.0;
		
		while(n){
			for(int y=1;y<=3;y++){
				for(int x=1;x<=3;x++){
					rep(i,4){
						int tx = x+dx[i], ty = y+dy[i] ;
						if(map[ty][tx] == 'X')ty = y , tx = x;
						dp[n-1][ty][tx] += dp[n][y][x] / 4.0;
					}
				}
			}
			n--;
		}
		printf("%.8Lf\n",dp[0][gy][gx]);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    set<int> S;
    rep(i, 3) {
        int tmp; cin>>tmp;
        S.insert(tmp);
    }
    cout << S.size() << endl;

    return 0;
}

Measured memory_bytes: 256
n,m = [int(x) for x in input().split()]
a=[]
b=[]
for i in range(n): a.append([int(x) for x in input().split()])
for j in range(m): b.append(int(input()))
for a_row in a:
    print(sum([x*y for x,y in zip(a_row,b)]))


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

int main() {
    int N; cin >> N;
    int d[N];

    int d_max = 0;
    for (int i = 0; i < N; i++) {
        cin >> d[i];
        d_max = max(d_max, d[i]);
    }

    int num[d_max] = {0};
    for (int i = 0; i < N; i++) {
        num[d[i]]++;
    }

    int res = 0;
    for (int i = 1; i <= d_max; i++) {
        if (num[i]) res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    S = input()
    T = input()
    scnt = [0] * (len(S)+1)
    for i in range(len(S)):
        scnt[i+1] = scnt[i] + (1 if S[i] == "A" else 2)
    tcnt = [0] * (len(T)+1)
    for i in range(len(T)):
        tcnt[i+1] = tcnt[i] + (1 if T[i] == "A" else 2)
    q = int(input())
    for _ in range(q):
        a, b, c, d = map(int, input().split())
        sn = scnt[b] - scnt[a-1]
        tn = tcnt[d] - tcnt[c-1]
        if sn % 3 == tn % 3:
            print("YES")
        else:
            print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 53720
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
n = int(input())
#l, r, d = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

a.insert(0, 0)
ans = 0
for i in range(1, n+1):
    if i % 2 == 1:
        if a[i] % 2 == 1:
            ans += 1

print(ans)


Measured memory_bytes: 10032
import sys
input = sys.stdin.readline

W, H = map(int, input().split())
p = [int(input()) for i in range(W)]
q = [int(input()) for i in range(H)]
p.sort()
q.sort()
row = H + 1
col = W + 1
i = j = 0
ans = 0
while row > 1 or col > 1:
    if i < W and (j == H or p[i] < q[j]):
        ans += p[i] * row
        col -= 1
        i += 1
    else:
        ans += q[j] * col
        row -= 1
        j += 1
print(ans)


Measured memory_bytes: 47452
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

INF = float("inf")

#処理内容
def main():
	N = int(input())
	A = getlist()
	A += [-INF] * 10
	if N % 2 == 0:
		DP0 = [-INF] * (N + 10)
		DP1 = [-INF] * (N + 10)
		DP0[0] = A[0]
		DP1[1] = A[1]
		for i in range(N):
			DP0[i + 2] = max(DP0[i] + A[i + 2] , DP0[i + 2])
			DP1[i + 3] = max(DP0[i] + A[i + 3] , DP1[i + 3])

			DP1[i + 2] = max(DP1[i] + A[i + 2] , DP1[i + 2])

		ans = max(DP0[N - 2], DP1[N - 1])

		print(ans)


	else:
		DP0 = [-INF] * (N + 10)
		DP1 = [-INF] * (N + 10)
		DP2 = [-INF] * (N + 10)
		DP0[0] = A[0]
		DP1[1] = A[1]
		DP2[2] = A[2]
		for i in range(N):
			DP0[i + 2] = max(DP0[i] + A[i + 2] , DP0[i + 2])
			DP1[i + 3] = max(DP0[i] + A[i + 3] , DP1[i + 3])
			DP2[i + 4] = max(DP0[i] + A[i + 4] , DP2[i + 4])

			DP1[i + 2] = max(DP1[i] + A[i + 2] , DP1[i + 2])
			DP2[i + 3] = max(DP1[i] + A[i + 3] , DP2[i + 3])
			
			DP2[i + 2] = max(DP2[i] + A[i + 2] , DP2[i + 2])

		ans = max(DP0[N - 3], DP1[N - 2], DP2[N - 1])

		print(ans)



if __name__ == '__main__':
	main()

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

using namespace std;

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

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

	int n;
	cin >> n;

	pii a[n];
	rep(i, n){
		cin >> a[i].first;
		a[i].second = i;
	}

	sort(a, a + n);
	rep(i, n){
		cout << a[i].second + 1 << (i == n - 1 ? "\n" : " ");
	}
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int A, B;
        Scanner scan = new Scanner(System.in);
        A = scan.nextInt();
        B = scan.nextInt();
        if(A==1&&B==2||A==2&B==1){
            System.out.println(3);
        }if(A==1&&B==3||A==3&B==1){
            System.out.println(2);
        }if(A==2&&B==3||A==3&B==2){
            System.out.println(1);
        }
    }
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<int> h(n);
    for(auto& x : h) {
        cin >> x;
    }
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2; i<n; ++i) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << "\n";
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

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

  if(0<d && 4*a*b<d*d) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){
  char a;
  cin >> a;
  if('a'<=a && a<='z') puts("a");
  if('A'<=a && a<='Z') puts("A");
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    string ans="Yes";
    rep(i,S.length()){
        if(S[i]=='R' and i%2!=0){
            ans="No";
            break;
        }
        if(S[i]=='L' and i%2==0){
            ans="No";
            break;
        }
    }
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

ll INF = 1e18;
ll MOD = 1e9+7;

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

int main() {
    ll SUM = 0;
    int K; cin >> K;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            for(int k = 1; k <= K; k++){
                ll temp = gcd(i, j);
                SUM += gcd(temp, k);
            }
        }
    }
    cout << SUM << endl;
}

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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long int
#define mod (long long)(1e9+7)
#define endl '\n'
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi (acos(-1))
#define F first
#define S second

ll fp(ll n , ll p )
{
    if(p==0)
        return 1;
    if(p==1)
        return n ;
    ll res = fp(n,p/2)%mod ;
    res=((res)*(res))%mod ;
    if(p%2)
        res=(res*n)%mod ;
    return res ;
}


ll n , arr[100005] , a[100005],b[100005] ;
int main()
{
    ENGZ;

    cin>>n ;
    for(int i=1; i<=n; i++)
    {
        cin>>arr[i] ;
        a[i] = __gcd(arr[i],a[i-1]);
    }
    ll ans = a[n] ;
    for(int i=n ; i>=1 ; i--)
    {
        b[i] = __gcd(b[i+1] , arr[i]);
    }
    for(int i=1 ; i<=n ; i++)
    {
        ans = max(ans , __gcd(b[i+1],a[i-1]));
    }
    cout<<ans <<endl  ;
    return 0;
}


Measured memory_bytes: 5932
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    string s,t; cin >> s >> t;
    int n = sz(s);
    int ans = 0;
    rep(i,n) {
        if (s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c;
  cin>>n>>m>>c;
  int b[m];
  int a[n][m];
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  int count=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<m;j++){
      sum+=a[i][j]*b[j];
    }
    sum+=c;
    if(sum>0){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long ll; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss;   
typedef vector<pll> vop; 
typedef vector<ll> vl; 
typedef vector<vl> vvl;
#define REP(i,a,b) for(long long int i=a;i<b;i++)
#define REPR(i,a,b) for(long long int i=a;i>=b;i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007


int main()
{
	fastIO;
	ll t,b=0;
	//cin>>t;
	t=1;
	while(t--)
	{
		ll n,ans=0;
		cin>>n;
  		int flag=0;
  		for(ll i=1;i<=n;i++)
  		{
    		if(i%3!=0 && i%5!=0)
    			ans+=i;
  		}
  		cout<<ans<<endl;

	}
	return 0;
}



Measured memory_bytes: 3636
def m(L,R):
 global c
 i=j=0
 for _ in L[:-1]+R[:-1]:
  if L[i]<R[j]:yield L[i];i+=1
  else:yield R[j];j+=1
  c+=1
def d(A):
 s=len(A)//2
 if len(A)>1:A[:]=m(d(A[:s])+[1e9],d(A[s:])+[1e9])
 return A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


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

long long kur[50],tam[50];

long long fast(long long ang, long long pang){
	if(pang == 1) return ang;
	if(pang == 0) return 1;
	long long tmp = fast(ang,pang/2);
	tmp *= tmp;
	if(pang%2) tmp *= ang;
	return tmp;
}

int main(){
	long long n;
	scanf("%lld",&n);
	long long now = -2;
	kur[1] = 0 ;
	tam[1] = 1 ;
	kur[0] = tam[0] = 0;
	for(long long i=2;i<=32;i++){
		if(now < 0 ) {
			tam[i] = tam[i-1];
			kur[i] = kur[i-1] + now;
		}
		else{
			tam[i] = tam[i-1] + now;
			kur[i] = kur[i-1];
		}
		now *= -2;
	}
	long long pos = 0;
	string has ="";
	bool flag =false;
	for(long long i = 32; i>=0 ; i --){
		if( (pos + fast(-2,i) )+tam[i] >= n && (pos + fast(-2,i))+kur[i] <=n  ) {
			has+="1";
			flag = true ; 
			pos+=fast(-2,i);
		}
		else if(flag) has += "0";
	}
	if(has!="")cout<< has<<endl;
	else cout<<"0\n";
	return 0;
}

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

pair_count = {}
for i in range(1, 10):
    for j in range(1, 10):
        pair_count[(i,j)] = 0

for i in range(1,n+1):
    if(i % 10 == 0):
        continue
    s = str(i)
    key = (int(s[0]), int(s[-1]))
    pair_count[key] += 1

ans = 0
for k, v in pair_count.items():
    k_pair = (k[1], k[0])
    ans += v * pair_count[k_pair]

print(sum([pair_count[k] * pair_count[(k[1], k[0])] for k in pair_count]))
    


Measured memory_bytes: 3064
S = input()
trapLeftSideIndices = []
traps = []
ans = [0] * len(S)

count = [0, 0]
for idx, char in enumerate(S):
    if char == "R" and count[1] == 0:
        count[0] += 1
    elif char == "R":
        traps.append(count)
        count = [1, 0]
    elif char == "L" and count[1] == 0:
        trapLeftSideIndices.append(idx - 1)
        count[1] += 1
    elif char == "L":
        count[1] += 1
else:
    traps.append(count)

for idx, trap in enumerate(traps):
    leftSideNum = (trap[0] - trap[0] // 2) + trap[1] // 2
    rightSideNum = (trap[1] - trap[1] // 2) + trap[0] // 2
    ans[trapLeftSideIndices[idx]] = leftSideNum
    ans[trapLeftSideIndices[idx] + 1] = rightSideNum

print(" ".join(map(str, ans)))


Measured memory_bytes: 17572
JPY = 1
BTC = 380000
n = int(input())
ans = 0
for i in range(n):
    x,u = map(str,input().split())
    if u == 'BTC':
        tmp = float(x) * BTC
    else:
        tmp = int(x) * JPY
    ans += tmp
print(ans)

Measured memory_bytes: 9096
def e_count_median():
    N = int(input())
    Min, Max = [], []
    for _ in range(N):
        a, b = [int(i) for i in input().split()]
        Min.append(a)
        Max.append(b)
    Min.sort()
    Max.sort()

    mid = N // 2
    median_min, median_max = ((Min[mid], Max[mid]) if N % 2 == 1
                              else (Min[mid] + Min[mid - 1], Max[mid] + Max[mid - 1]))
    return median_max - median_min + 1

print(e_count_median())

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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n'&&c!=EOF) s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, ll> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const int inf = 1e9,
N = 3e4 + 11;

int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif //makacha
    string s;
    reads(s);
    for (int i = 0; i < s.size(); i++)
        if (s[i] == '?')
            s[i] = 'D';
    cout << s;
}


Measured memory_bytes: 3696
import bisect
l = sorted([[i**2+j**2,i,j] for j in range(1,150) for i in range(1,150) if i<j and i!=j])
while True:
    h,w = map(int,input().split())
    if h==w==0: break
    rh,rw = l[bisect.bisect_right(l, [h**2+w**2,h,w])][1:]
    print(rh,rw)

Measured memory_bytes: 9140
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>



int main(void)
{
    int a, b, i, j, length;
    char input[10001];

    scanf("%s", input);

    for (i = 0; i < 4; i++) {
        printf("%c", input[i]);
    }
    printf(" ");
    for (; i < 12; i++) {
        printf("%c", input[i]);
    }
    puts("");


    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> number(N);
	map<int, int> ncnt;

	for (int n = 0; n < N; n++) {
		int A;
		cin >> A;
		number[n] = A;
		if (ncnt.count(A) == 0) {
			ncnt[A] = 1;
		}
		else {
			ncnt[A]++;
		}
	}

	for (int m = 0; m < M; m++) {
		int B, C;
		cin >> B >> C;
		number.push_back(C);
		if (ncnt.count(C) == 0) {
			ncnt[C] = B;
		}
		else {
			ncnt[C] += B;
		}
	}

	sort(number.begin(), number.end(), greater<int>());
	number.erase(unique(number.begin(), number.end()), number.end());

	/*
	for (int n : number) {
		cout << n << endl;
	}

	cout << "一覧出力" << endl;
	for (auto itr = ncnt.begin(); itr != ncnt.end(); itr++)
	{
		// キーを出力
		cout << itr->first << endl;
		// 値を出力
		cout << itr->second << endl;
	}
	*/

	long long int sum_card = 0;
	int num_choice = 0;
	for (int n : number) {
		int cnt = min(ncnt[n], N - num_choice);
		sum_card += (long long int)(n) * (long long int)(cnt);
		num_choice += cnt;
		
		if (num_choice >= N)
			break;
	}

	cout << sum_card;

	return 0;

}

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

int main(){
    int N;
    cin >> N;
double ans=0;
    for(int i=0;i<N;i++){
        double x;
        string u;
        cin >> x;
        cin >> u;

        if(u=="BTC"){
            ans+=380000*x;
        }else{
            ans+=x;
        }


    }

cout << ans;


}

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int g = __gcd(a, b);
  int m = 0;
  int x = g;
  while (1) {
    if (g % x == 0) {
      m++;
      if (m == k) {
	cout << x << endl;
	return 0;
      }
    }
    x--;
  }
  return 0;
}



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

using namespace std;

bool sameShape(vector<long long> v, string s){
    if(v.size() == 0)
        return true;
    char c = s[v[0]];
    for(long long i = 1; i< v.size();i++){
        if(c != s[v[i]])
            return false;
    }
    return true;
}

int main(){
    string s,t; cin >> s >> t;
    for(char c = 'a'; c<= 'z'; c++){
        vector<long long> vs;
        vector<long long> vt;
        for(long long i = 0; i < s.size();i++){
            if(s[i] == c)
                vs.push_back(i);
        }
        if(!sameShape(vs,t)){
            cout << "No" << endl;
            return 0;
        }
    }
    for(char c = 'a'; c<= 'z'; c++){
        vector<long long> vt;
        // vector<long long> vt;
        for(long long i = 0; i < s.size();i++){
            if(t[i] == c)
                vt.push_back(i);
        }
        if(!sameShape(vt,s)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main() {
    int n, q;
    cin >> n >> q;
    queue<string> name;
    queue<int> time;
    rep(i, n) {
        string na;
        int t;
        cin >> na >> t;
        name.push(na);
        time.push(t);
    }

    int cnt = 0;
    
    while(!name.empty()) {
        string tmp1 = name.front();
        int tmp2 = time.front();

        if(tmp2 <= q) {
            cnt += tmp2;
            cout << tmp1 << " " << cnt << endl;
            name.pop();
            time.pop();
        }else {
            cnt += q;
            name.pop();
            time.pop();
            name.push(tmp1);
            time.push(tmp2-q);
        }

    }

    return 0;
}


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

int maxVal = 1e5;
const int inf = 2*1e9;

int Knapsack_2(vector<int> &weight, vector<int> &profit, int maxCap)
{
	int n = weight.size();
	
	// It's very important to make DP as long long
	vector<vector<long long>> dp(n + 1, vector<long long>(maxVal + 1, 0));

	/* dp[n][val] represents the minimum capacity of knapsack needed to gain exactly 'val' profit
	 * from the first 'n' elements
	 */

	// No element. There is no way to make any profit
	for(int val = 1; val <= maxVal; val++)
		dp[0][val] = inf;
	
	// An empty knapsack is needed to create zero profit
	for(int i = 1; i <= n; i++)
		dp[i][0] = 0;
	
	// No element and No Profit ==> Empty knapsack would work
	dp[0][0] = 0;

	for(int i = 1; i <= n; i++)
	{
		for(int val = 0; val <= maxVal; val++)
		{
			long long take_it = inf, leave_it = inf;

			leave_it = dp[i-1][val];

			if(val >= profit[i-1])
				take_it = weight[i-1] + dp[i-1][val - profit[i-1]];
			
			dp[i][val] = min(take_it, leave_it);
		}
	}

	for(int ans = maxVal; ans >= 0; ans--)
		if(dp[n][ans] <= maxCap)
			return ans;

}
int main()
{
	int n, maxCap;
	cin >> n >> maxCap;

	vector<int> weight(n), val(n);

	for(int i = 0; i < n; i++)
		cin >> weight[i] >> val[i];

	cout <<	Knapsack_2(weight, val, maxCap);
	return 0;
}





Measured memory_bytes: 83264
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
  char s[5];
  char tmp;
  cin >> s;
  for(int i=0; s[i+1]!='\0'; i++){
    if(s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

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

  vector<double> X(N);
  vector<double> Y(N);

  rep0(i, N) cin >> X[i] >> Y[i];

  double M = 1e5;
  double pi = 3.14159265358979;
  double ans = 0;

  for(double i = 0; i < M; i++) {
    double theta = i / M * 2 * pi;
    double x = cos(theta);
    double y = sin(theta);

    double tempX = 0;
    double tempY = 0;
    rep0(j, N) {
      if (x * X[j] + y * Y[j] > 0) {
        tempX += X[j];
        tempY += Y[j];
      }
    }
    // if(i<10)cout << tempX << SP << tempY << BR;
    ans = max(ans, sqrt(tempX * tempX + tempY * tempY));
  }

  fcout << ans << BR;
  return 0;
}

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

int main(){
    long long N;
    cin >> N;
    long long ans = 0;
    for(long long i=1; i*i<=N; i++){
        if(N % i != 0) continue;
        long long m = N / i - 1;
        long long a = N / (m+1);
        if(a < m)
            ans += m;
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    int N = {};
    cin >> N;
    vector<long int> lucas_numbers(0);
    
    for (int i = 0; i < N + 1; i++) {
        if (i == 0) lucas_numbers.push_back(2);
        else if (i == 1) lucas_numbers.push_back(1);
        else lucas_numbers.push_back(lucas_numbers.at(i-1) + lucas_numbers.at(i-2));
    }
    cout << lucas_numbers.at(N) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>




int main()
{
	long long n;

	std::cin >> n;

	std::vector<long long> v(n);

	for (size_t i = 0; i < v.size(); i++) {
		std::cin >> v[i];
	}

	long long a2, a0, a4;

	a0 = a2 = a4 = 0;

	for (size_t i = 0; i < v.size(); i++) {
		if (v[i] % 4 == 0) {
			a4++;
		} else if (v[i] % 2 == 0) {
			a2++;
		} else {
			a0++;
		}
	}

	if (a2 == 0) {
		if (a0 > a4 + 1) {
			std::cout << "No" << std::endl;
		} else {
			std::cout << "Yes" << std::endl;
		}
		return 0;
	}

	if (a0 == a4 || a0 < a4) {
		std::cout << "Yes" << std::endl;
		return 0;
	} else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char b;
    cin >> b;
    if (b == 'A') cout << 'T' << endl;
    else if (b == 'T') cout << 'A' << endl;
    else if (b == 'C') cout << 'G' << endl;
    else cout << 'C' << endl; 
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    vector<int> s(10);
    for(auto&e:s){
        scanf("%d",&e);
    }
    sort(s.begin(),s.end(),greater<int>());
    for(int i=0;i<3;i++){
        printf("%d\n",s[i]);
    }
    return 0;
}

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

int main(){
    ll n,a,b,c,d,e,ans,x;
    cin >> n >> a >> b >> c >> d >> e;
    ans = 0;
    x = min(a,min(b,min(c,min(d,e))));
    if(n % x == 0){
        ans += n/x;
    }else if(n <= x){
        cout << 5 << endl;
        return 0;
    }else{
        ans += n/x+1;
    }
    ans += 4;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 105;
char A[maxn], B[maxn];

int main(){
    int n;
    scanf("%d%s%s", &n, &A, &B);
    int ans = 2 * n;
    for(int s = 0; s < n; s++){
        int flag = 1;
        for(int i = s, j = 0; i < n && j < n; i++, j++){
            if(A[i] != B[j]){
                flag = 0;
                break;
            }
        }
        if(flag){
            ans = s + n;
            break;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
/*
	0164:Ohajiki Game
*/
#include	<iostream>
#include	<vector>

using namespace std;

int main(void) {
	while(1) {
		int ohajiki, size;
		vector<int> vc;
		
		cin >> size;
		if(size == 0) { break; }
		for(int i = 0; i < size; i++) {
			int a;
			
			cin >> a;
			vc.push_back( a );
		}
		vector<int>::iterator it = vc.begin();
		ohajiki = 32;
		while(1) {
			ohajiki -= (ohajiki - 1) % 5;
			cout << ohajiki << endl;
			if( it == vc.end() ) {
				it = vc.begin();
			}
			if(ohajiki >= *it) {
				ohajiki -= *it;
			} else {
				ohajiki = 0;
			}
			it++;
			cout << ohajiki << endl;
			if(ohajiki == 0) {
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1216
q, h, s, d = map(int, raw_input().split())
n = int(raw_input())
if h > q * 2:
    h = q * 2
if s > h * 2:
    s = h * 2
if d > s * 2:
    d = s * 2
print d * (n / 2) + s * (n % 2)

Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans = 100000000;
  
  for(int n = 0; n < N; n++){
    int x;
    int new_ans = 0;
    cin >> x;
    while(x % 2 == 0){
      x /= 2;
      new_ans++;
    }
    if(ans > new_ans){
      ans = new_ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	static int MAX = 999 + 51;
	static char TERM = 'Z';

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 0) break;

			//load and pre proc.
			char[][] board = new char[n][MAX];
			int check = 0;
			for (int i = 0; i < n; i++) {
				line = br.readLine();
				for (int j = 0; j < line.length(); j++) {
					char c = line.charAt(j);
					board[i][j] = c;
					if (c == '.') {
						check++;
						if (line.charAt(j + 1) >= 'a') {
							board[i][j] = '+';
						}
					}
				}
				board[i][line.length()] = TERM;
			}

			//write off
			//vertical bar.
			for (int j = 0; j < MAX; j++) {
				for (int i = n - 1; i > 0; i--) {
					char c = board[i][j];
					if (c == '+') {
						for (int k = i - 1; k > 0; k--) {
							if (board[k][j] == '.') {
								board[k][j] = '|';
								check--;
							} else break;
						}
					} else if (c == '.') {
						board[i][j] = ' ';
						check--;
					}
				}
				if (check == 0) break;
			}

			//ans.
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < MAX; j++) {
					char c = board[i][j];
					if (c == TERM) break;
					System.out.print(board[i][j]);
				}
				System.out.println();
			}
		} //end while
	} //end main
}

Measured memory_bytes: 66544
#include <stdio.h>
#define error -1
int size=0,list[2000000];

int parent(int i){
   return i/2;
}

int Left(int i){
  return 2*i;
 }

int Right(int i){
  return 2*i+1;  
 }

void maxHeapify(int i){
  int left,right,largest,key;
  left=Left(i);
  right=Right(i);
  
  if(left<=size && list[left]>list[i])
    largest=left;
  else largest=i;
  
  if(right<=size && list[right]>list[largest])
    largest=right;
  
  if(largest!=i){
    key=list[i];
    list[i]=list[largest];
    list[largest]=key;
    maxHeapify(largest);
  }  
}







void heapIncrease(int i,int key){
  int ch;
  if(key<list[i]) return;
  list[i]=key;
  while(i>0 && list[parent(i)]<list[i]){
    ch=list[i];
    list[i]=list[parent(i)];
    list[parent(i)]=ch;
    i=parent(i);
  }
  return;
}


void insert(int key){
  size=size+1;
  list[size]=-1000000;
  heapIncrease(size,key);
}


int heapExtractMax(){
  int max;
  if(size<0) return error;
  max=list[0];
  list[0]=list[size];
  size=size-1;
  maxHeapify(0);
  return max;
}
 
int main(){
  char Inst[10];
  int count,del,key;
 
 while(1){
   
   scanf("%s %d",Inst,&key);
   if(Inst[0]=='i') insert(key);
   else if(Inst[1]=='x'){
     del=heapExtractMax();
     printf("%d\n",del);
   }
   else if(Inst[2]=='d') break;

 }
 return 0;
}

Measured memory_bytes: 4696
using System;

namespace ConsoleApplication1
{

    class Program
    {
        static void Main()
        {
            string input1 = Console.ReadLine();
            string input2 = Console.ReadLine();

            if (TryCompare(input1.Length, input2.Length))
            {
                return;
            }

            for (int i = 0; i < input1.Length; i++)
            {
                int num1 = int.Parse(input1[i].ToString());
                int num2 = int.Parse(input2[i].ToString());
                if (TryCompare(num1, num2))
                {
                    return;
                }
            }

            DisplayEqual();
            
        }

        private static bool TryCompare(int num1, int num2)
        {
            if (num1 > num2)
            {
                DisplayGreater();
                return true;
            }
            if (num2 > num1)
            {
                DisplayLess();
                return true;
            }
            return false;
        }

        private static void DisplayGreater()
        {
            Console.WriteLine("GREATER");
        }

        private static void DisplayLess()
        {
            Console.WriteLine("LESS");
        }

        private static void DisplayEqual()
        {
            Console.WriteLine("EQUAL");
        }
    }

}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int m;
    int keta = 0;

    m = n;
    while (m > 0) {
        keta++;
        m /= 10;
    }

    switch (keta) {
    case 1:
        cout << n << endl;
        break;
    case 2:
        cout << 9 << endl;
        break;
    case 3:
        cout << n - 99 + 9 << endl;
        break;
    case 4:
        cout << 900 + 9 << endl;
        break;
    case 5:
        cout << n - 9999 + 900 + 9 << endl;
        break;
    case 6:
        cout << 90000 + 900 + 9 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
int main()
{
	int n,m,x,y,r;
	scanf("%d %d %d %d %d",&n,&m,&x,&y,&r);
	if(x+r>n || x-r<0 || y+r>m || y-r<0)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}


Measured memory_bytes: 2120
#include<stdio.h>
int c=0, n,i,j,l,m,r,q,a[1000000],temp[1000000];
void input(){
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
}
void pri(){
  for(i=0;i<n-1;i++)printf("%d ",a[i]);
  printf("%d\n%d\n",a[n-1],c);
}
void M(int x[],int left,int right){
  int mid,i,j,k;
  if(left>=right)return;
  mid=(left+right)/2;
  M(x, left, mid);
  M(x, mid + 1, right);
  for (i = left; i <= mid; i++) temp[i] = x[i];
  for (i = mid + 1, j = right; i <= right; i++, j--) temp[i] = x[j];
  i = left;
  j = right;
  for (k = left; k <= right; k++){
    if (temp[i] <= temp[j]){
        x[k] = temp[i++];
        c++;
    }else{
        x[k] = temp[j--];
        c++;
    }
  }
}
int main(){
  input();
  M(a,0,n-1);
  pri();
}


Measured memory_bytes: 5608
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h,i,j;
    cin>>a>>b>>c>>d>>e>>f>>g>>h;
    i=a*e+b*f;
    j=c*e+d*f;
    if(a/10>0){i=i+(a/10)*g;}
    if(c/10>0){j=j+(c/10)*g;}
    if(b/20>0){i=i+(b/20)*h;}
    if(d/20>0){j=j+(d/20)*h;}
    if(i>j){cout<<"hiroshi"<<endl;}else
    if(i<j){cout<<"kenjiro"<<endl;}else
    {cout<<"even"<<endl;}
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;

int l;
double s, p;
 
int main(){
	cin >> l;
	if (l % 3 == 1){
		s = l / 3;
		p = 1.0 / 3;
		s += p;
		cout << fixed << setprecision(7) << s * s * s << '\n';
	}
	else if (l % 3 == 2){
		s = l / 3;
		p = 2.0 / 3;
		s += p;
		cout << fixed << setprecision(7) << s * s * s << '\n';
	}
	else{
		s = l / 3;
		cout << fixed << setprecision(7) << s * s * s << '\n';
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    if (a == b && b == c) {
        printf("1\n");
    } else if (a == b || b == c || c == a) {
        printf("2\n");
    } else {
        printf("3\n");
    }
    return 0;
}

Measured memory_bytes: 128
let n, x = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ls = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let d, ans = ref 0, ref 1
let _ = Array.iter (fun l -> d := !d + l; if !d <= x then incr ans) ls; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
/* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0501 */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			int n = Integer.parseInt(r.readLine());
			if(n==0){ break; }
			
			Map<String,String> map = new HashMap<String,String>();
			for(int i=0;i<n;i++){
				String[] k = r.readLine().split(" ");
				map.put(k[0],k[1]);
			}
			
			int m = Integer.parseInt(r.readLine());
			for(int i=0;i<m;i++){
				String s = r.readLine();
				String s2 = map.get(s);
				if(s2!=null) s = s2;
				
				System.out.print(s);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 35024
#include<stdio.h>
#define N 100
 
#define WHITE  0
#define GRAY  1
#define BLACK 2
 
int n, M[N][N];
int color[N], d[N], f[N];
int tt;
 
void dfs_visit(int);
void dfs();
 
 
int main(){
 
  int u,k,v; 
  int i,j;
 
  scanf("%d", &n);
 
  for (i = 0; i <n; i++ ){
    for (j = 0; j <n; j++ ) {
      M[i][j] = 0;
    }
  }
   
  for ( i = 0; i < n; i++ ){
     
    scanf("%d %d", &u, &k);
    u--;
 
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
 
    }
  }
   
  dfs();
 
  return 0;
}
 
 
 
void dfs_visit(int u){
 
  int v;
 
  color[u] = GRAY;
  tt++;
  d[u] = tt;
 
  for ( v = 0; v < n; v++ ){
    if ( M[u][v] == 0 ) continue;
    if ( color[v] == WHITE ){
      dfs_visit(v);
    }
  }
 
  color[u] = BLACK;
  f[u] = ++tt;
}
 
void dfs(){
 
  int i, u;
 
  for ( i = 0; i < n; i++ ){
    color[i] = WHITE;
  }
   
  tt = 0;
 
  for (u = 0; u < n; u++ ){
    if ( color[u] == WHITE ){
      dfs_visit(u);
    }
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d %d\n", i+1, d[i], f[i]);
  }
}

Measured memory_bytes: 636