akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void) {
	int n, m;
	int i, j;
	int ans = 1000;

	int h[1000];

	char s;
	char str[1000];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	int  k;
	
	int hako[2];
	int sa;
	

	for (i = 0; i < 2; i++) {
		hako[i] = 0;
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j <= i; j++) {
			hako[0] = hako[0] + h[j];
		}
		for (k = i+1; k < n; k++) {
			hako[1] = hako[1] + h[k];
		}
		sa = hako[0] - hako[1];
		hako[0] = 0;
		hako[1] = 0;
		if (sa < 0) {
			sa = sa * (-1);
		}
		if (ans > sa) {
			ans = sa;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int adis1 = 0;
		int adis2 = 0;
		int bdis1 = 0;
		int bdis2 = 0;
		int[][] nums = new int[3][3];
		String answer = "Yes";

		// input
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				nums[i][j] = scan.nextInt();
			}
		}

		// acheck
		adis1 = nums[1][0] - nums[0][0];
		adis2 = nums[2][0] - nums[1][0];
		for(int j = 1; j < 3; j++){
			if(nums[1][j] - nums[0][j] != adis1){
				answer = "No";
			}
			if(nums[2][j] - nums[1][j] != adis2){
				answer = "No";
			}
		}
		bdis1 = nums[0][1] - nums[0][0];
		bdis2 = nums[0][2] - nums[0][1];
		for(int i = 0; i < 3; i++){
			if(nums[i][1] - nums[i][0] != bdis1){
				answer = "No";
			}
			if(nums[i][2] - nums[i][1] != bdis2){
				answer = "No";
			}
		}

		System.out.println(answer);

	}
}



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

int main() {
  std::vector<int> a(4);
  string c;
  cin>>c;
  for(int i=0;i<4;i++){
      a.at(i)=c.at(i)-'0';
  }
  stringstream ss;
 for(int tmp=0;tmp<(1<<3);tmp++){
     int sum=a.at(0);
     ss<<a.at(0);
     bitset<3> s(tmp);
     for(int i=1;i<4;i++){
         if(s.test(i-1)){
             sum+=a.at(i);
             ss<<'+';
         }
         else{
             sum-=a.at(i);
             ss<<'-';
         }
         ss<<a.at(i);
     }
     
     if(sum==7){
         ss<<"=7";
         cout<<ss.str()<<endl;
         break;
     }
     ss.str("");
     ss.clear(stringstream::goodbit);
 }
 
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, l[105], ans=0;
int main() {
   cin >> n;
   for (int i=0; i<n; i++) cin >> l[i];
   sort(l, l+n);
   
   for (int i=0; i<=n-3; i++) {
       for (int j=i+1; j<=n-2; j++) {
           for (int k=j+1; k<=n-1; k++) {
               if (l[i]!=l[j] && l[j]!=l[k] && l[i]!=l[k] && l[i]+l[j]>l[k]) ans++;
           }
       }
   }
   
   cout << ans;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
inline long long myabs(long long x){return x<0?-x:x;}
int n,m;
vector<int>G[100010];
int col[100010];
bool vis[100010];
long long k[100010],b[100010];
long long a[100010];
int tot;
long long ans;
bool odd;
int u,v;
void prework(int x,int p)
{
	vis[x]=true;
	for(int i=(int)G[x].size()-1;i>=0;i--)
	{
		int y=G[x][i];
		if(y==p)continue;
		if(vis[y])
		{
			if(col[x]==col[y])odd=true;
			u=x;v=y;
			continue;
		}
		col[y]=col[x]^1;
		prework(y,x);
	}
} 
void dfs(int x,int p)
{
	for(int i=(int)G[x].size()-1;i>=0;i--)
	{
		int y=G[x][i];
		if(y==p || (x==u && y==v) || (x==v && y==u))continue;
		dfs(y,x);
		k[x]+=k[y];
		b[x]+=b[y]; 
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	col[1]=1;
	prework(1,0);
	long long num=0;
	for(int i=1;i<=n;i++)if(col[i])b[i]=1;else b[i]=-1;
	for(int i=1;i<=n;i++)num+=b[i];
	if(n-1==m)
	{
		if(num)
		{
			printf("-1");
			return 0;
		}
	}
	else
	{
		if(odd)
		{
			if(num%2==1)
			{
				printf("-1");
				return 0;
			}
			b[u]-=num/2;b[v]-=num/2;
			ans+=myabs(num/2);
		}
		else
		{
			if(num)
			{
				printf("-1");
				return 0;
			}
			k[u]=1;k[v]=-1;
		}
	}
	dfs(1,0);
	a[++tot]=0;
	for(int i=1;i<=n;i++)
	{
		if(!k[i])ans+=myabs(b[i]);
		else
		{
			if(k[i])b[i]=-b[i];
			a[++tot]=b[i];
		}
	}
	sort(a+1,a+tot+1);
	for(int i=1;i<=tot;i++)ans+=myabs(a[i]-a[(tot+1)/2]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 16384
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
  
def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
a = list(map(int, input().split()))

lcm_a = lcm(a[0], a[1])
for i in range(1, N):
    lcm_a = lcm(lcm_a, a[i])

ans = 0
for i in range(N):
    ans += (lcm_a - 1) % a[i]
   
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  double sum = 0,n = 0,i;
  for(i=0;;i++){
    double a,b;
    if(scanf("%lf,%lf",&a,&b) == EOF) break;
    sum+=a*b;
    n+=b;
  }
  printf("%d\n%d\n",(int)sum,(int)floor(n/i+0.5));
  return 0;
}

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

int dp[105][4][2];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int K;
  cin >> K;
  dp[0][0][0] = 1;
  rep(i,n)rep(j,4)rep(k,2) {
    int nd = s[i]-'0';
    rep(d,10) {
      int ni = i+1, nj = j, nk = k;
      if (d != 0) nj++;
      if (nj > K) continue;
      if (k == 0) {
        if (d > nd) continue;
        if (d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
x = list(map(int, input().split()))

n = x[0]
m = x[1]

a = []
for i in range(0, n):
    y = list(map(int, input().split()))
    a.append([y[0],y[1]])

c = []
for i in range(0, m):
    z = list(map(int, input().split()))
    c.append([z[0],z[1]])

for i in range(0, n):
    s_ = 9999999999
    s = 0
    for j in range(0, m):
        t = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if t < s_:
            s_ = t
            s = j + 1
    print(s)

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int a,b,c,n;
    cin >> a >> b >> c >> n;
    int ans = 0;
    for (int i = 0;i < n/a+1;++i) for (int j = 0;j < (n-a*i)/b+1;++j) if ((n-a*i-b*j)%c == 0) ans++;
    cout << ans << endl;
    return 0;
}

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

int main(int argc, char *argv[])
{
    const int MAX = 1000000;
    int a, d, n, cnt;
    bool prime[MAX] = {false, false, true};
    for (int i = 3; i < MAX; ++i) {
        if (i % 2 == 0) {
            prime[i] = false;
            continue;
        }
        prime[i] = true;
        for (int j = 3; j <= sqrt(i); j += 2) {
            if (i % j == 0) {
                prime[i] = false;
                break;
            }
        }
    }
    while (cin >> a >> d >> n, n) {
        cnt = 0;
        while (1) {
            if (prime[a]) {
                cnt++;
                if (cnt == n)
                    break;
            }
            a += d;
        }
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 2144
def LI(): return [int(x) for x in input().split()];
def I(): return int(input());
def S(): return input();
def LS(): return S().split();

dp = [0] * 100010;
ch = [True] * 100010;
n, m = LI();
for _ in range(m):
    ch[I()] = False;
dp[0] = 1;

for i in range(n):
    if ch[i+1]:
        dp[i+1] += dp[i];
    if ch[i+2]:
        dp[i+2] += dp[i];

print(dp[n]%1000000007);

Measured memory_bytes: 463476
#include <stdio.h>

int main(void){

  int n,m,p,x[100];
  int i;

  for(;;){

    scanf("%d %d %d",&n,&m,&p);
    if(n==0 && m==0 && p==0)break;

    int pool=0;

    for(i=0;i<n;i++){
      scanf("%d",&x[i]);
      pool += 100 * x[i];
    }

    if(x[m-1]==0)printf("0\n");
    else printf("%d\n",(pool*(100-p))/(100*x[m-1]));


  }

  return 0;
}

Measured memory_bytes: 612
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = scanner.nextInt();
            }
            if (n < 2) {
                System.out.println(0);
                return;
            }
            int[] dp = new int[n];
            dp[1] = Math.abs(nums[0] - nums[1]);

            for (int i = 2; i < n; i++) {
                int a = dp[i - 2] + Math.abs(nums[i] - nums[i - 2]);
                int b = dp[i - 1] + Math.abs(nums[i] - nums[i - 1]);
                dp[i] = Math.min(a, b);
            }
            System.out.println(dp[n - 1]);
        }
    }
}


Measured memory_bytes: 49048
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

type Edge struct {
	to, cost int
}

// 辺のリストで表現されるグラフ
type Graph struct {
	Edges [][]Edge // Edge[i][j]: 頂点iのj番目の辺
	Pred  []int    // 遷移元
	Cost  []int    // 始点からの最小コスト
}

// 頂点数nのリスト型グラフを返す
func NewGraph(n int) *Graph {
	g := &Graph{
		Edges: make([][]Edge, n),
		Pred:  make([]int, n),
		Cost:  make([]int, n),
	}
	for i := 0; i < n; i++ {
		g.Edges[i] = make([]Edge, 0)
		g.Pred[i] = -1
		g.Cost[i] = 1 << 60
	}
	return g
}

// 辺の追加
func (g *Graph) AddEdge(from, to, cost int) {
	g.Edges[from] = append(g.Edges[from], Edge{to, cost})
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()
	g := NewGraph(n)
	for i := 0; i < m; i++ {
		l, r, d := nextInt()-1, nextInt()-1, nextInt()
		g.AddEdge(l, r, d)
		g.AddEdge(r, l, -d)
	}

	x := make([]int, n)
	visited := make([]bool, n)
	for i := 0; i < n; i++ {
		if visited[i] {
			continue
		}
		q := []int{i}
		for len(q) > 0 {
			v := q[0]
			visited[v] = true
			for _, e := range g.Edges[v] {
				if !visited[e.to] {
					x[e.to] = x[v] + e.cost
					visited[e.to] = true
					q = append(q, e.to)
				} else if x[e.to] != x[v]+e.cost {
					puts("No")
					return
				}
			}
			q = q[1:]
		}
	}
	puts("Yes")
}


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  for ( int i = 0; i < n-2; i++){
    if (s.substr(i, 3) == "ABC"){
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
from math import sqrt 
N = int(input())
k = [list(map(int, input().split())) for _ in range(N)]
result = 0
for i in range(N):
    for j in range(N):
        if i != j:
            result += sqrt((k[i][0] - k[j][0]) * (k[i][0] - k[j][0]) + (k[i][1] - k[j][1]) * (k[i][1] - k[j][1]))
print(result / N)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int H, A;
  cin >> H >> A;
  if (H%A==0) {
    cout << H/A << endl;
  }
  else {
    cout << 1+(H-(H%A))/A << endl;
  }
}

Measured memory_bytes: 3564
# coding: utf-8
# Your code here!

#READ INPUT
N,M = map(int,input().split())
switches = list()
for i in range(M):
    curSwitch = [int(temp) for temp in input().split()] #read as list
    switches.append(curSwitch[1:])

p = [int(p) for p in input().split()]

#iterate through each possible combination of switches
numValidComb=0
for i in range(2**N):
    bit = [(i>>j)&1 for j in range(N)]
    numActiveBulb = 0
    for curBulb in range(M):
        curS = switches[curBulb]
        curP = p[curBulb]
        
        ind = [x-1 for x in curS]
        activeSwitch = [bit[this] for this in ind]

        if (sum(activeSwitch)%2 == curP):
            numActiveBulb+=1
    
    if (numActiveBulb==M):
        numValidComb+=1
        
print(numValidComb)


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

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

    vector<int> vecH(n);
    for(int i=0; i<n; i++)  cin >> vecH.at(i);

    bool check = true;
    vecH[0]--;
    for(int i=1; i<n; i++){
        if(vecH[i-1] == vecH[i])
            continue;
        else if(vecH[i-1] > vecH[i]){
            check = false;
            break;
        }

        vecH[i]--;
    }

    string ans = check ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <utility>
#define llint long long

using namespace std;

llint N, K;
llint a[200005];
llint sum[200005];
pair<llint, int> p[200005];

llint bit[200005];

void init()
{
	for(int i = 1; i <= N+1; i++) bit[i] = 0;
}

llint query(llint i)
{
	i++;
	llint ret = 0;
	while(i > 0){
		ret += bit[i];
		i -= i & (-i);
	}
	return ret;
}

void add(llint i, llint val)
{
	i++;
	while(i <= N+1){
		 bit[i] += val;
		i += i & (-i);
	}
}

int main(void)
{
	cin >> N >> K;
	for(int i = 1; i <= N; i++){
		cin >> a[i];
		a[i] -= K;
	}
	
	for(int i = 1; i <= N; i++) sum[i] = sum[i-1] + a[i];
	for(int i = 0; i <= N; i++) p[i] = make_pair(sum[i], i);
	sort(p, p+N+1);
	
	llint ans = 0;
	for(int i = 0; i <= N; i++){
		ans += query(p[i].second);
		add(p[i].second, 1);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8064
mod = 2019
s = input()
n = len(s)
w = 0
d = [0] * mod
p = 1
for i in reversed(range(n)):
	w += int(s[i]) * p
	p *= 10
	p %= mod
	w %= mod
	d[w] += 1
d[0] += 1
o = 0
for x in d:
	o += x * (x - 1) // 2
print(o)


Measured memory_bytes: 9256
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
constexpr int inf = (1 << 30) - 1;
constexpr lint linf = (1ll << 60) - 1;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

bool prime[200001];

int main() {

    int X;
    cin >> X;
    rep(i, 2, 200000) prime[i] = true;
    rep(i, 0, 200000) {
        if(prime[i]) {
            for(int j = i + i; j <= 200000; j += i) {
                prime[j] = false;
            }
        }
    }
    rep(i, X, 200000) {
        if(prime[i]) {
            cout << i << '\n';
            return 0;
        }
    }

}


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

#define ll long long

using namespace std;

int f(int x) {
    int d = 0;
    while (x) {
        x /= 10;
        d++;
    }
    return d % 2 == 1;
}

int main() {
    int n, sol;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        sol += f(i);
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 256
from itertools import product, permutations, combinations

n = int(input())
pn = tuple(map(int, input().split(' ')))
qn = tuple(map(int, input().split(' ')))

orders = []
for i, v in enumerate(permutations(range(1, n + 1), n)):
    if v == pn:
        orders.append(i)
    if v == qn:
        orders.append(i)
        
print(abs(orders[0] - orders[1]))



Measured memory_bytes: 39024
#include<stdio.h>
int main(void){
  int a,b,sum=0;
  scanf("%d %d",&a,&b);
  for(int i=a-1;i>0;i--){
    sum+=i;
  }
  for(int i=b-1;i>0;i--){
    sum+=i;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
#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> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll n,d;cin>>n>>d;
    vector<ll> x(n);
    vector<ll> y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    ll count =0;

    rep(i,n){
        double a;
        a = sqrt(x[i]*x[i]+y[i]*y[i]);
        if(a<=d)count++;

    }
    cout<<count<<endl;
}

Measured memory_bytes: 6376
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
signed main(){
    string s;cin>>s;
    int red=0;int blue=0;
    int n=(int)s.length();
    rep(i,n){
        if(s[i]=='0')red++;
        else blue++;
    }
    cout<<2*min(red,blue)<<endl;
    return 0;
}

Measured memory_bytes: 512
s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
INF = l1 + l2


def match(i, j):
    if s2[i - 1] == s1[j - 1]:
        return 0
    else:
        return 1


ans = [[INF] * (1 + l1) for _ in range(1 + l2)]
# 初期化：dp[0][i] = i
ans[0][0] = 0

# ans[i][j]:= s1のi文字目、s2のj文字目を一致させた時のmin編集距離
# ans[i][j] = min(ans[i-1][j],ans[i][j-1],match+ans[i-1][j-1])
for i in range(l2 + 1):
    for j in range(l1 + 1):
        if i == 0:
            ans[i][j] = j
        elif j == 0:
            ans[i][j] = i
        else:
            ans[i][j] = min(
                ans[i - 1][j] + 1, ans[i][j - 1] + 1, match(i, j) + ans[i - 1][j - 1]
            )
print(ans[l2][l1])
#print(ans)



Measured memory_bytes: 43068
#include <iostream>

bool judge(int x) {
    for (int i = 2; i < x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}

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

    for (int x = 1; x < 10; ++x) {
        for (int y = 1; y < 10; ++y) {
            if (N == x * y) {
                std::cout << "Yes" << '\n';
                return 0;
            }
        }
    }
    std::cout << "No" << '\n';
}

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

using namespace std;

void print_vec(vector<int> &vec) {
    for (int i = 0; i < vec.size(); i++) {
        if (i != 0) cout << " ";
        cout << vec[i];
    }
    cout << endl;
}

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

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

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }

        if (minj != i) {
            int tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            cnt++;
        }
    }
    print_vec(A);
    cout << cnt << endl;
}




Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
//#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int r, g, b;
	int k;

	cin >> r >> g >> b;
	cin >> k;

	int i;
	for (i = 0; i < k; i++)
	{
		if (r >= g)
		{
			g *= 2;
		}
		else if (g >= b)
		{
			b *= 2;
		}
	}
	if (r < g && g < b)
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
}


	
	

	
	
/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

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

int main() {
    
    int n,req;
    cin>>n>>req;
    vector<int> v(n),w(n);
    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    
    vector<vector<long long int>> dp(req+1,vector<long long int>(n+1,0));
    for(int i=1;i<=req;i++){
        for(int j=1;j<=n;j++){
            if(i>=w[j-1]){
                dp[i][j]=max(dp[i-w[j-1]][j-1]+v[j-1],dp[i][j-1]);
            }
            else
                dp[i][j]=dp[i][j-1];
        }
    }
    cout<<dp[req][n];
    return 0;
}

Measured memory_bytes: 85232
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)


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

    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << a[k-1] << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int n,m;
	List<List<Integer>> graph;
	static int[] memo;//graph.get(i)の有向パスの最大を記録

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	private void solve() {
		n = nextInt();
		m = nextInt();
		graph = new ArrayList<List<Integer>>();
		for(int i=0;i<=n;i++)graph.add(new ArrayList<Integer>());
		for(int i=0;i<m;i++)graph.get(nextInt()).add(nextInt());

		memo = new int [n+1];
		Arrays.fill(memo, -1);
		for(int i=1;i<=n;i++)if(memo[i]<0)memo[i] = SearchVerticesPass(i);

		Arrays.sort(memo);
		System.out.println(memo[n]);
	}

	private int SearchVerticesPass(int vi) {
		if(memo[vi]>=0)return memo[vi];//
		List<Integer>V = graph.get(vi);
		int cntmax=0,t;
		for(int i=0;i<V.size();i++)if((t=SearchVerticesPass(V.get(i))+1)>cntmax)cntmax=t;
		memo[vi] = cntmax;
		return memo[vi];
	}

	private int nextInt() {
		return Integer.parseInt(sc.next());
	}
} 

Measured memory_bytes: 70584
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ct=0;
    for(int i=1;i<=n;i++){
        int m=i;
        int evenct=0;
        while(m>0){
            evenct++;
            m/=10;
        }
        if(evenct%2==1){
            ct++;
        }
    }
    cout << ct << "\n";
}


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

#define INF 1LL << 60
#define pb push_back
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)

int N;

int main() {
    cin >> N;
    ll in, sum = 0, negative = 0, m = INF;
    REP(i, N) {
        cin >> in;
        ll a = abs(in);
        sum += a;
        if (in < 0) negative++;
        if (m > a) m = a;
    }

    if (negative % 2 == 1) {
        sum -= 2 * m;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input()) #手持ちのカード枚数

cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
'''
0: S
1: H
2: C
3: D
'''
for n in range(N):
    ch,rank = input().split()
    rank = int(rank)
    cards[pattern.index(ch)][rank-1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)


Measured memory_bytes: 5612
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
const int siz = 8;
vector<string> s(siz);






//サブ関数
//入力
void input()
{
	REP(i, siz) {
		cin >> s[i];
	}
}

bool isOut(int h, int w)
{
	if (h < 0 || w < 0)return true;
	if (7 < h || 7 < w)return true;
	return false;
}

int evaluate(bool mami, int h, int w)
{
	char me = (mami ? 'o' : 'x');
	if (s[h][w] != '.')return 0;

	int sumValue = 0;
	int dy[8] = { -1,-1,-1,0,1,1,1,0 };
	int dx[8] = { -1,0,1,1,1,0,-1,-1 };
	REP(dir, 8) {
		int y = h;
		int x = w;
		int value = 0;
		while (true) {
			y += dy[dir];
			x += dx[dir];
			if (isOut(y, x))break;
			if (s[y][x] == '.') break;

			if (s[y][x] != me)value++;
			else {
				sumValue += value;
				break;
			}
		}
	}
	return sumValue;
}

void put_cookie(bool mami, int h, int w)
{
	char me = (mami ? 'o' : 'x');

	int dy[8] = { -1,-1,-1,0,1,1,1,0 };
	int dx[8] = { -1,0,1,1,1,0,-1,-1 };
	REP(dir, 8) {
		int y = h;
		int x = w;
		bool change = false;

		while (true) {
			y += dy[dir];
			x += dx[dir];
			if (isOut(y, x))break;
			if (s[y][x] == '.') break;
			if (s[y][x] == me) {
				change = true;
				break;
			}
		}
		if (change) {
			y = h;
			x = w;
			do {
				s[y][x] = me;
				y += dy[dir];
				x += dx[dir];
			} while (s[y][x] != me);
		}
	}
}

bool search(bool mami)
{
	int maxH = 0;
	int maxW = 0;
	int maxV = 0;
	REP(i, siz)REP(j, siz) {
		int tmpV = evaluate(mami, i, j);
		if (mami) {
			if (maxV < tmpV) {
				maxH = i;
				maxW = j;
				maxV = tmpV;
			}
		}
		else {
			if (maxV <= tmpV) {
				maxH = i;
				maxW = j;
				maxV = tmpV;
			}
		}
	}
	if (maxV) {
		put_cookie(mami, maxH, maxW);
		return true;
	}
	else {
		return false;
	}
}

//計算
void calc()
{
	bool mami = true;
	int cnt = 0;
	while (cnt < 2) {
		if (search(mami))cnt = 0;
		else cnt++;

		mami = !mami;
	}

}


//出力
void output()
{
	//cerr << endl << endl;
	for (auto row : s) {
		cout << row << endl;
	}
}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	//debug();
	
	return 0;
}



Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a > b) {
            if (a > c ) {
                output(a - b == c);
            } else output(c-a == b);
        } else if (b > c) {
            output(b-c == a);
        } else {
            output(c -b ==a );
        }
    }

    static private void output(boolean b) {
        String r = b ? "Yes" : "No";
        System.out.println(r);
    }
}


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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int n;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N_MAX = 100;
int main() {
    int n;
    int a[2][N_MAX];
    cin >> n;

    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin >> a[i][j];
        }
    }

    for(int i=1;i<n;i++){
        a[0][i] += a[0][i-1];
    }
    a[1][0] += a[0][0];
    for(int i = 1; i<n; i++){
        a[1][i] += max(a[0][i], a[1][i-1]);
    }

    cout << a[1][n-1] << endl;

    return 0;
}

Measured memory_bytes: 256
MOD = 998244353


class Combination:

    def __init__(self, n, mod):
        self.mod = mod
        self.fact = [1] * (n+1)
        self.ifact = [1] * (n+1)

        for i in range(1, n+1):
            self.fact[i] = i*self.fact[i-1] % mod
            self.ifact[i] = pow(i, mod-2, mod) * self.ifact[i-1] % mod

    def get(self, n: int, k: int):
        if k < 0 or n < k:
            return 0
        return self.fact[n] * self.ifact[k] * self.ifact[n-k] % MOD

    def __call__(self, n: int, k: int):
        return self.get(n, k)


def main():
    N, M, K = [int(x) for x in input().split()]
    comb = Combination(N, MOD)
    ans = 0
    for i in range(0, K+1):
        ans += M * pow(M-1, N-i-1, MOD) * comb(N-1, i)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24584
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

#define SENTINEL (1000000001)

int c = 0;
int S[500000];
int L[250001];
int R[250001];

static void Merge(int A[], int left, int mid, int right);
static void MergeSort(int A[], int left, int right);

int main(void) {
	int i;
	int n;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d", &S[i]);
	}
	
	MergeSort(S, 0, n);
	
	for (i = 0; i < n; ++i) {
		if (i > 0) {
			putchar(' ');
		}
		printf("%d", S[i]);
	}
	putchar('\n');
	
	printf("%d\n", c);

	return 0;
}

void Merge(int A[], int left, int mid, int right) {
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	memcpy(L, A + left, n1 * sizeof(int));
	memcpy(R, A + mid, n2 * sizeof(int));
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for (k = left; k < right; ++k) {
		++c;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			++i;
		} else {
			A[k] = R[j];
			++j;
		}
	}
}

void MergeSort(int A[], int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

Measured memory_bytes: 4524
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

int a[100005];

int main()
{
    int sov,tmp;
    scanf("%d",&sov);
    rep(i,sov){scanf("%d",&tmp);a[tmp]++;}
    rer(i,0,100000) if(a[i]>1)sov-=(a[i]-1);
    if(!(sov&1))sov-=1;
    printf("%d\n",sov);
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>


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



int main(){
  int number;
  int i,l,j,k;
  
  int ar[150];
  int array[150][150];

  
  
  
  scanf("%d",&number);
  
  
  
  for(i=1;i<=number;i++){
    scanf("%d%d",&ar[i-1],&ar[i]);
  }
  
  
  
  
  for(i=1;i<=number;i++){
    array[i][i]=0;
  }


  
  for(i=2;i<=number;i++){
    for(l=1;l<=number-i+1;l++){
      
      j=i+l-1;
      array[l][j]=(1<<21);
      
      for(k=l;k<=j-1;k++){
	array[l][j]=min(array[l][j],array[l][k]+array[k+1][j]+ar[l-1]*ar[k]*ar[j]);
      }
    }


  }



  printf("%d\n",array[1][number]);


  /* for(i=0;i<number;i++){
    for(l=0;l<number;l++){
      printf("%d\n",array[i][l]);
    }}
  */

  
  return 0;
}



Measured memory_bytes: 2116
#include<cstdio>
#include<algorithm>
main(){
    int A,B,K,i;
    scanf("%d%d%d",&A,&B,&K);
    for(i=A;i<=std::min(A+K-1,B);)printf("%d\n",i++);
    for(i=std::max(A+K,B-K+1);i<=B;)printf("%d\n",i++);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
int main(){
  ll N,K;
  cin>>N>>K;
  ll ans=0;
  for(ll i=K;i<=N+1;i++){
    ll low=i*(i-1)/2;
    ll high=i*(2*N-i+1)/2;
    ll tmp=high-low+1;
    ans=(ans+tmp)%MOD;
  }
  cout<<ans<<endl;
}

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

int main(){
  int n,u,k,b[120][120],a;
  cin>>n;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      b[i][j]=0;   
    }
  }
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>a;
      b[u][a]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout<<b[i][j];
      if(j<n)cout<<" ";
    }
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 3156
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){
  return a < b ? a : b;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d",&n, &q);

  for(i = 1; i <= n; i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }

  return 0;
}

Measured memory_bytes: 10756
#include <stdio.h>

main(){
  int a, b, m, n, temp1, ans1, ans2;
  int i;


  while(1){
    if(scanf("%d %d", &a, &b)==EOF) break;
    m=a;
    n=b;
    while(1){
      temp1=a%b;
      if(temp1==0){
	ans1=b;
	break;
      }
      a=b;
      b=temp1;
    }

    ans2=(double)m*((double)n/(double)ans1);
    printf("%d %d\n", ans1, ans2);
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 5e3 + 10;

int N, P[MAX_N], pre2d[MAX_N][MAX_N];
ll A, B, F[MAX_N];

int count(int x1, int x2, int y1, int y2) {
    return pre2d[x2][y2] - pre2d[x2][y1 - 1] - pre2d[x1 - 1][y2] + pre2d[x1 - 1][y1 - 1];
}

int main() {
    scanf("%d%lld%lld", &N, &A, &B);
    for (int i = 1; i <= N; i++) scanf("%d", &P[i]);
    P[0] = 0; P[N + 1] = N + 1;
    for (int i = 1; i <= N; i++) {
        pre2d[i][P[i]] = 1;
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) pre2d[i][j] += pre2d[i][j - 1];
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) pre2d[i][j] += pre2d[i - 1][j];
    }
    for (int i = 1; i <= N + 1; i++) {
        F[i] = LLONG_MAX;
        for (int j = 0; j < i; j++) {
            if (P[j] > P[i]) continue;
            ll v = F[j];
            int tot = i - j - 1, heavy;
            if (A >= B) {
                heavy = count(j + 1, i - 1, P[i], N);
            } else {
                heavy = count(j + 1, i - 1, 1, P[j]);
            }
            v += max(A, B) * heavy + min(A, B) * (tot - heavy);
            F[i] = min(F[i], v);
        }
    }
    printf("%lld\n", F[N + 1]);
}


Measured memory_bytes: 98176
N=parse(Int,readline())
K=split(readline())
Xi=map(x->parse(Int,x),K)

minP=N*100^2
for i in 1:100
    ss=0
    for j in 1:N
        ss+=(Xi[j]-i)^2
    end
    if ss < minP
        minP = ss
#        println("min",ss)
    end
end
    
print(minP)

Measured memory_bytes: 172552
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int main(){
    ll n,x; cin >> n >> x;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    ll ans = max(0LL,a[0]-x);
    a[0] = min(a[0],x);
    REP(i,n-1){
        if(a[i] + a[i+1] > x){
            ll diff = a[i+1] + a[i] - x;
            a[i+1] -= diff;
            ans += diff;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
string s;
map<char, int>  cnt;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>s;
    
    for (auto i : s) {
        cnt[i]++;
    }
    
    int ok = 0;
    if(cnt.size() == 2){
        if(cnt.begin()->second == 2 && cnt.rbegin()->second == 2){
            ok = 1;
        }
    }
    
    
    if(ok)cout<<"Yes\n";
    else cout<<"No\n";
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> R(N, 0);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    R.at(a-1)++;
    R.at(b-1)++;
  }
  
  for (int i = 0; i < N; i++) {
    cout << R.at(i) << endl;
  }
}

Measured memory_bytes: 256
from collections import deque
from itertools import product
h, w = list(map(int,input().split()))
sy, sx = list(map(int,input().split()))
gy, gx = list(map(int,input().split()))
sx, sy, gx, gy = sx-1, sy-1, gx-1, gy-1
 
G = [list(input()) for _ in range(h)]
D = [[10**6]*w for _ in range(h)]
D[sy][sx] = 0
Q = deque([(sy, sx)])
while Q:
    y, x = Q.pop()
    for dy, dx in product(range(-2, 3), repeat=2):
        ny, nx = y+dy, x+dx
        if dx==dy==0:
            G[y][x] = '#'
            continue
        elif ny<0 or h<=ny or nx<0 or w<=nx:
            continue
        elif G[ny][nx] == '#':
            continue
        elif abs(dy)+abs(dx)<=1:
            G[ny][nx] = '#'
            D[ny][nx] = D[y][x]
            Q.append((ny, nx))
        elif D[ny][nx] == 10**6:
            D[ny][nx] = D[y][x]+1
            Q.appendleft((ny, nx))
            
if D[gy][gx] == 10**6:
    print(-1)
else:
    print(D[gy][gx])


Measured memory_bytes: 136248
//Catchharsh
    //I Luv Kunj017
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (ll x,ll n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    int main()
    {   
         IOS;
         ll n,m,i,j,k;
         cin>>n>>m;
         cout<<max({n+m,n-m,n*m});    
         
    }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define rep(i, n) for(int i = 1; i <= (n); ++i)

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

  rep(i, N){
    if (i*(i+1)/2 >= N){
      x = i;
      break;
    }
  }
  int y = x*(x+1)/2;
  int dame = y - N;
  rep(i, x){
    if (i == dame){
      continue;
    }
    cout << i << endl;
  }
}

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

namespace _085A_Already2018
{
    class Program
    {
        static void Main(string[] args)
        {
            String s;
            s = Console.ReadLine();
            char[] cs = s.ToCharArray();
            cs[3] = '8';

            Console.WriteLine(cs);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "b.cpp"

int main() {
  ll n;
  cin >> n;
  constexpr ll maxi = 1e18;
  ll ans = 1;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      puts("0");
      return 0;
    }
  }

  rep(i, n) {
    if (a[i] > maxi/ans) {
      cout << -1 << el;
      return 0;
    } else {
      ans *= a[i];
    }
  }

  cout << ans << el;
}


Measured memory_bytes: 3968
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int dp[110][110][4];

int main() {
	int w,h,i,j;
	while(cin>>w>>h,w){
		memset(dp,0,sizeof(dp));
		for(i=0;i<h;i++){
			dp[i][0][0]=1;
		}
		for(j=0;j<w;j++){
			dp[0][j][2]=1;
		}
		for(i=1;i<h;i++){
			for(j=1;j<w;j++){
				dp[i][j][0]=dp[i-1][j][0]+dp[i-1][j][1];
				dp[i][j][1]=dp[i-1][j][2];
				dp[i][j][2]=dp[i][j-1][2]+dp[i][j-1][3];
				dp[i][j][3]=dp[i][j-1][0];
				dp[i][j][0]%=100000;
				dp[i][j][1]%=100000;
				dp[i][j][2]%=100000;
				dp[i][j][3]%=100000;
			}
		}
/*
for(int k=0;k<4;k++){
for(i=0;i<h;i++){
for(j=0;j<w;j++){
cout<<dp[i][j][k]<<" ";
}
cout<<endl;
}
}
*/
		cout<<(dp[h-1][w-1][0]+dp[h-1][w-1][1]+dp[h-1][w-1][2]+dp[h-1][w-1][3])%100000<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

vector<unsigned int> table { 63, 6, 91, 79, 102, 109, 125, 39, 127, 111 };

void solve(int from, int to)
{
	unsigned int b0 = table[from];
	unsigned int b1 = table[to];
	cout << static_cast<bitset<7>>( b0 ^ b1 ) << endl;
}

int main(int argc, char* argv[])
{
	int num, d;
	vector<int> ds;

	while(1) {
		cin >> num;
		if( num == -1 )
			break;

		for( int i = 0; i < num; i++ ) {
			cin >> d;
			ds.push_back(d);
		}
		int v0 = -1;
		for( auto  v1 : ds ) {
			solve(v0, v1);
			v0 = v1;
		}
		ds.clear();		
	}

    return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int x; cin >> x;
    for(ll a = -200; a <= 200; a++){
        for(ll b = -200; b <= 200; b++){
            if(a*a*a*a*a - b*b*b*b*b == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n, a, b;
  cin >> n >> a >> b;
  cout << min(a * n, b) << '\n';
  return 0;
}


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

const int INF = 1001001001;
template<class T> inline bool chmin(T& a, T b);
template<class T> inline bool chmax(T& a, T b);

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    vector<int> sum(n, INF);
    rep(i,n) {
        if (i==0) {
            sum[0] = 0;
        } else if (i==1) {
            sum[1] = abs(h[1]-h[0]);
        } else {
            chmin(sum[i], sum[i-1]+abs(h[i]-h[i-1]));
            chmin(sum[i], sum[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout << sum[n-1] << endl;
}

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;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();
    int red = 0;
    for (int i = 0; i < s.length; i++) {
      if (s[i] == 'R') red++;
    }
    int blue = N - red;
    if (red > blue) System.out.println("Yes");
    else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  string s;
  cin>>s;
  string ans="2018"+s.substr(4);
  cout(ans);
  return 0;
}

Measured memory_bytes: 125568