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

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n > m ? "No" : "Yes") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void){
    int n;
    int count;
    int prime[1000000];
    int i,j;
    while(cin>>n){
        count=0;
        fill(prime,prime+1000000,0);
        prime[0]=prime[1]=1;
        for(i=2;i<=n;i++){
            if(prime[i]==0){
                count++;
                for(j=2*i;j<=n;j+=i){
                    prime[j]=1;
                }
            }
        }
        cout<<count<<endl;
    }
    return(0);
}

Measured memory_bytes: 5064
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main { 
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String[] line = sc.nextLine().split(" ");
    	int itemsCount = Integer.parseInt(line[0]);
    	int couponCount = Integer.parseInt(line[1]);
    	String[] priceLine = sc.nextLine().split(" ");
    	PriorityQueue<Long> priceQueue = new PriorityQueue(Collections.reverseOrder());
    	for(int i = 0;i<itemsCount;i++) {
    		Long eachNumber = Long.parseLong(priceLine[i]);
    		priceQueue.add(eachNumber);
    	}
    	for(int i = 1;i<=couponCount;i++) {
    		Long biggestNumber = priceQueue.poll();
    		if(biggestNumber != 0) {
    			biggestNumber = biggestNumber/2;
			
    		}
    		priceQueue.add(biggestNumber);
    	}
    	Iterator<Long> iterator = priceQueue.iterator();
    	Long result = 0L;
    	while(iterator.hasNext()) {
    		result = result + iterator.next();
    	}
    	
    	System.out.println(result);
    	
    }
}

Measured memory_bytes: 55108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int c[10][10];

void warshall_floyd(int n) {
  for (int k = 0; k < n; k++) {      // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
}

int main() {
  int h, w;
  cin >> h >> w;
  REP(i, 10) {
    REP(j, 10) {
      int x;
      cin >> x;
      c[i][j] = x;
    }
  }
  warshall_floyd(10);
  int ans = 0;
  REP(i, h) {
    REP(j, w) {
      int x;
      cin >> x;
      if (x == -1) continue;
      ans += c[x][1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
H = [int(h) for h in input().split()]

max_num = 0
next_i = 0
for i in range(N-1):
    # print(i)
    if i != next_i:
        # print('passed')
        continue
    num = 0
    for j in range(i, N-1):
        if H[j] >= H[j+1]:
            num += 1
        else:
            break
    # print('num:', num)
    if num > max_num:
        max_num = num
        # print('max num is updated')
    next_i = i + num + 1
    # print('next_i:', next_i)
    # print('')

print(max_num)


Measured memory_bytes: 14224
import collections

n = int(input())
ans_list = []
for x in range(1,100):
  for y in range(1,100):
    for z in range(1,100):
        ans_list.append(x*x+y*y+z*z+x*y+y*z+z*x)

counter = collections.Counter(ans_list)
for i in range(1,n+1):
  print(counter[i])

Measured memory_bytes: 146224
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int a[5000];
int dp[5000];
int n,k;
int check(int x){
	int i,j;
	if(a[x]>=k) return 1;
	FOR(i,1,k) dp[i]=0;
	dp[0]=1;
	FOR(i,0,n){
		if(i!=x&&a[i]<k){
			for(j=k-a[i];j>=0;j--){
				if(dp[j]) dp[j+a[i]]=1;
			}
		}
	}
	FOR(i,k-a[x],k){
		if(dp[i]) return 1;
	}
	return 0;
}
int main(void)
{
	int i,l,r,mid;
	scanf("%d%d",&n,&k);
	FOR(i,0,n) scanf("%d",&a[i]);
	qsort(a,n,sizeof(int),comp);
	l=-1,r=n;
	while(r-l>1){
		mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid;
	}
	printf("%d\n",l+1);
	return 0;
}

Measured memory_bytes: 252
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Puneet    //FastRead class is taken from different online Sources
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastInput in = new FastInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, FastInput in, PrintWriter out) {

            int a = in.ni(), b = in.ni(), k = in.ni();

            int p = 0, ans = 1;

            for (int i = Math.min(a, b); i > 0; i--) {
                if (a % i == 0 && b % i == 0) {
                    p++;
                    if (p == k) {
                        ans = i;
                        break;
                    }

                }
            }

            out.println(ans);
        }

    }

    static class FastInput {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastInput.SpaceCharFilter filter;

        public FastInput(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21588
N, K = map(int, input().split())
from collections import defaultdict

graph = defaultdict(list)
for i in range(N - 1):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

mod = 10 ** 9 + 7

import sys

sys.setrecursionlimit(10 ** 9)


def dfs(prev, now, graph):
    if prev == -1:
        mul = K - 1
    else:
        mul = K - 2

    if K < len(graph[now]):
        return 0
    else:
        tmp = 1
        for v in graph[now]:
            if v == prev:
                continue
            else:
                tmp *= mul
                mul -= 1
                tmp %= mod
                tmp *= dfs(now, v, graph)
                tmp %= mod
    return tmp

ans = K
ans *= dfs(-1, 0, graph)
print(ans % mod)


Measured memory_bytes: 96204
/*
Owner: dxxrk
Problem: STring
Date: 21/11/2019
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s; cin >> s;
	
	string t = "";
	
	for(int i = 0; i < s.size(); i++){
		t += s[i];
		if(t.size() >= 2){
			if(t.substr(int(t.size()) - 2, 2) == "ST"){
				t.erase(int(t.size()) - 2, 2);
			}
		}
	}
	
	cout << t.size();
	return 0;
}


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

int main() {
    int N,ans=0;
    string S;
    cin >> N >> S;
    S.push_back('#');
    for(int i=0;i+1<S.size();i++) {
        if(S[i]!=S[i+1]) ans++;
    }
    cout << ans << endl;
    return 0; 
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
map<char, tuple<int, map<int, int>>> arrays;

pair<int,int> num(const string &s, int i) {
  int v = 0;
  while(i < s.size() && '0' <= s[i] && s[i] <= '9') {
    v *= 10;
    v += s[i] - '0';
    ++i;
  }
  return make_pair(v, i);
}

pair<int,int> expr(const string &s, int i) {
  if ('0' <= s[i] && s[i] <= '9') return num(s,i);
  char aname = s[i];
  auto p = expr(s, i+2);
  if (arrays.find(aname) == end(arrays)) throw "array was not declared";
  if (get<0>(arrays[aname]) <= p.first) throw "out of array";
  if (get<1>(arrays[aname]).find(p.first) == end(get<1>(arrays[aname]))) throw "referred undefined value";
  return make_pair(get<1>(arrays[aname])[p.first], p.second + 1);
}

void parse(const string &s) {
  if (s.find('=') != string::npos) {
    char aname = s[0];
    auto lhs = expr(s, 2);
    auto rhs = expr(s, lhs.second + 2);
    if (get<0>(arrays[aname]) <= lhs.first) throw "out of array";
    get<1>(arrays[aname])[lhs.first] = rhs.first;
  } else {
    char aname = s[0];
    int size = expr(s, 2).first;
    if (arrays.find(aname) != end(arrays)) throw "conflict array name";
    arrays[aname] = make_tuple(size, map<int,int>());
  }
}

int main() {
  while(1){
    vector<string> lines;
    while(1) {
      string line;
      cin>>line;
      if(line==".")break;
      lines.push_back(line);
    }
    if(lines.empty())break;
    arrays.clear();
    int bug = 0;
    REP(i,lines.size()) {
      try {
        parse(lines[i]);
      } catch(...) {
        bug = i+1;
        break;
      }
    }
    cout << bug << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>
#include <vector>
#define LL long long
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
using namespace std;
struct E{
	int to, nxt, l;
}e[maxn << 1];
int head[maxn], tot = 0;
void addedge(int u, int v, int l){
	e[++tot].to = v, e[tot].nxt = head[u], e[tot].l = l;
	head[u] = tot;
}
int n, sz[maxn], v[maxn], Min = INF; LL ans = 0;
void dfs(int cur, int fa, int L){
	sz[cur] = 1; int Max = 0;
	for (int i = head[cur]; i; i = e[i].nxt){
		if (e[i].to != fa){
			dfs(e[i].to, cur, e[i].l);
			sz[cur] += sz[e[i].to];
			Max = max(Max, sz[e[i].to]);
		}
	}
	ans += 2ll * min(sz[cur], n - sz[cur]) * L;
	v[cur] = max(Max, n - sz[cur]); Min = min(Min, v[cur]);
}
vector <int> c;
int main(){
	scanf("%d", &n);
	for (int u, v, l, i = 1; i < n; i++){
		scanf("%d%d%d", &u, &v, &l);
		addedge(u, v, l); addedge(v, u, l);
	}
	dfs(1, 0, 0);
	for (int i = 1; i <= n; i++)
		if (v[i] == Min) c.push_back(i);
	if (c.size() == 1){
		Min = INF;
		for (int i = head[c[0]]; i; i = e[i].nxt)
			Min = min(Min, e[i].l);
		ans -= Min;
	}
	if (c.size() == 2){
		for (int i = head[c[0]]; i; i = e[i].nxt)
			if (e[i].to == c[1]) ans -= e[i].l;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 10368
n=int(raw_input())
il=map(int,raw_input().split())
s=0
t=0
cnt=[]
while t<n-1:
    if il[t]==il[t+1]:
        cnt.append(t+1-s)
        s=t+1
    t+=1
    if t==n-1:
        cnt.append(t+1-s)
ans=0
if len(cnt)<=3:
    print(sum(cnt))
else:
    for i in xrange(len(cnt)-2):
        ans=max(ans,cnt[i]+cnt[i+1]+cnt[i+2])
    print(ans)

Measured memory_bytes: 7708
def ss(n):
    return n / s(n)
def s(n):
    return sum([int(a) for a in str(n)])

K = int(input())
n = 0
d = 1
while K > 0:
    t1=ss(n+d)
    t2=ss(n+10*d)
    if t1 > t2:
        d *= 10
    n += d
    print(n)
    K -= 1


Measured memory_bytes: 39024
//aoj0184
#include<iostream>
using namespace std;

int main() {
	int n;
	while(cin>>n,n){
		int agenum[7] = {};
		for (int i = 0; i < n; i++) {
			int a;	
			cin >> a;
			if (a < 10) { agenum[0] += 1; }
			else if (a < 20) { agenum[1] += 1; }
			else if (a < 30) { agenum[2] += 1; }
			else if (a < 40) { agenum[3] += 1; }
			else if (a < 50) { agenum[4] += 1; }
			else if (a < 60) { agenum[5] += 1; }
			else { agenum[6] += 1; }
		}

		for (int i = 0; i < 7; i++) {
			cout << agenum[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2960
#include <stdio.h>

int gcd(int a, int b){
	int t;
	while((a % b) != 0){
		t = b;
		b = a % b;
		a = t;
	}
	return b;
}

int main(){
	int a,b;
	int t;
	while(scanf("%d%d", &a, &b) != EOF){
		t = gcd(a,b);
		printf("%d %d\n", t, a/t*b);
	}
}

Measured memory_bytes: 0
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(k,n):
        if a[i-k]<a[i]:
            print('Yes')
        else:
            print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 31612
#include<stdio.h>
int main(){
  int a,h,m,s;
  scanf("%d", &a);
  s=a%60;
  m=((a-s)/60)%60;
  h=(a-s-60*m)/3600;  
  printf("%d:%d:%d\n", h,m,s);
  return 0;
}

Measured memory_bytes: 592
P = [1 for _ in range(100)]
P[0]=0
P[1]=0
for i in range(2,11):
    for j in range(i*i,100,i):
        P[j]=0
Q = []
for i in range(100):
    if P[i]==1:
        Q.append(i)
N = int(input())
G = {p:0 for p in Q}
for n in range(2,N+1):
    k = n
    i = 0
    while k>1 and i<len(Q):
        if k%Q[i]==0:
            k = k//Q[i]
            G[Q[i]] += 1
        else:
            i += 1
C2 = 0
C4 = 0
C14 = 0
C24 = 0
C74 = 0
for x in G:
    if G[x]>=2:
        C2 += 1
    if G[x]>=4:
        C4 += 1
    if G[x]>=14:
        C14 += 1
    if G[x]>=24:
        C24 += 1
    if G[x]>=74:
        C74 += 1
cnt = 0
cnt += C24*(C2-1)
cnt += C14*(C4-1)
cnt += (C4*(C4-1))//2*(C2-2)
cnt += C74
print(cnt) 

Measured memory_bytes: 3064
L = int(input())

Lbin = (bin(L)[2:])[::-1]
N = len(Lbin)
M = 2 * (N - 1) + Lbin.count("1") - 1
print(N, M)

for i in range(0, N - 1):
    print(i + 1, i + 2, 0)
    print(i + 1, i + 2, 2 ** i)

weight = L
for i in range(0, N - 1):
    if Lbin[i] == '1':  # 2^iの位
        weight -= 2 ** i
        print(i + 1, N, weight)

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

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            var itemCount = int.Parse(Console.ReadLine());
            var terms = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
            var max = terms.Max();
            var min = terms.Min();
            var sum = terms.Sum();

            Console.WriteLine($"{min} {max} {sum}");
        }
    }
}



Measured memory_bytes: 18656
#include <stdio.h>
int main(void){
   int S;
   int h,m,s;
   
   scanf("%d\n", &S);
   
   h = S / (60*60);
   m = (S - 60*60*h) / 60;
   s = S % 60;
   
   printf("%d:%d:%d\n", h,m,s);
   return 0;
}


Measured memory_bytes: 2100
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
struct star_t { int x, y, b; };
bool operator < (star_t p, star_t q) { return p.b < q.b; }
int main() {
    int n, d; scanf("%d%d", &n, &d);
    vector<star_t> s(n); repeat (i,n) scanf("%d%d%d", &s[i].x, &s[i].y, &s[i].b);
    whole(sort, s);
    ll ans = 0;
    map<int, int> x, y;
    for (int i = 0, j = 0; j < n; ++ j) {
        x[s[j].x] += 1;
        y[s[j].y] += 1;
        while (s[i].b + d < s[j].b) {
            x[s[i].x] -= 1; if (not x[s[i].x]) x.erase(s[i].x);
            y[s[i].y] -= 1; if (not y[s[i].y]) y.erase(s[i].y);
            ++ i;
        }
        ll dx = x.rbegin()->first - x.begin()->first;
        ll dy = y.rbegin()->first - y.begin()->first;
        setmax(ans, dx * dy);
    }
    printf("%lld\n", ans);
    return 0;
}

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

ll b[1001000];
bool del[1001000] = {};
ll a[1001];
int cnt[100];
int main(){
  ll n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  int c = 0;
  int tp = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      b[c] = a[j] - a[i - 1];
      ll tmp = b[c];
      c++;
      for (int kk = 0; tmp > 0; kk++) {
        if (tmp & 1) {
          cnt[kk]++;
        }
        tmp >>= 1;
        tp = max(tp, kk);
      }
    }
  }

  for (int i = tp; i >= 0; i--) {
    if (cnt[i] >= k) {
      for (int j = 0; j < n * (n + 1) / 2; j++) {
        if (del[j]) continue;
        if (((b[j] >> i) & 1) == 0) {
          del[j] = true;
          int k = 0;
          while (b[j] > 0) {
            cnt[k] -= b[j] & 1;
            k++;
            b[j] >>= 1;
          }
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i <= tp; i++) {
    if (cnt[i] >= k) {
      ans += (1LL << i);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int dp[1<<16];

int main(){
  int n;
  while(cin>>n,n){
    vector<int> v[17];
    for(int i=0;i<n;i++){
      for(int j=0;j<=n;j++){
	int tmp;
	cin>>tmp;
	v[i].push_back(tmp);
      }
    }
    for(int i=1;i<=1<<n;i++){
      dp[i]=1000000;
    }
    dp[0]=0;
    for(int i=0;i<1<<n;i++){
      int t;
      for(int j=0;j<n;j++){
	int clear = i>>j;
	if( ( clear &1 ) == 1)continue;
	t=v[j][0];
	for(int k=1;k<=n;k++){
	  clear= i>>(k-1);
	  if( (clear&1) != 1)continue;
	  t=min(t,v[j][k]);
	}
	dp[i + (1<<j)] = min(dp[i+ (1<<j)],dp[i]+t);
      }
    }
    cout << dp[(1<<n)-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1476
#include<iostream>
using namespace std;
int main(){
	int a[1000000]={0,0,1,2},n,k=0,count=2;
	for(int i=4;i<1000000;i++){
		for(int j=2;j*j<=i;j++){
			if(i%j==0){k++;break;}
		}
		if(k==0)count++;
		a[i]=count;
		k=0;
	}
	while(cin>>n)cout<<a[n]<<endl;
	return 0;
}

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

char A[105];
int ans;
int main()
{
    cin >> A + 1;
    for (int i = 1; i <= strlen(A + 1) / 2; i++) {
        if (A[i] != A[strlen(A + 1) - i + 1])
            ans++;
    }
    cout << ans;

    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,a,b;
  cin >> n >> a >> b;

  if(a>b || (a!=b && n==1)){
    cout << 0 << endl;
    return 0;
  }
  cout << max(0LL,((n-1)*b+a)-((n-1)*a+b)+1) << endl;
}


Measured memory_bytes: 384
/*
 *  Created on: 16 / 8 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO

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

#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)
#define test(t)      while(t--)

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//const ld EPS = 1e-8;
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
	//stp(0)
	Eslam__Waheed;
	ss s; cin >> s;
	short c = count(all(s), 'S');
	if (c == 0 || c == 3)
		cout << 3 - c;
	else
	if (c == 2)
		cout << 1;
	else
	{
		if (s[1] == 'S')
			cout << 1;
		else
			cout << 2;
	}
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define all(c) (c).begin(),(c).end()
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}
void dump() {}
template <class H, class... T>void dump(H&& head, T&&... tail)
{cout << head << (sizeof...(tail)==0 ? "\n" : " "); dump(forward<T>(tail)...);}

template<class T>
T powf(T n, int exp){
  T ret = 1, pow2 = n;
  while(exp>0){
    if(exp & 1) ret *= pow2;
    pow2*=pow2; exp/=2;
  }
  return ret;
}

vector<P> prime_factor(int n){
  vector<P> ret;
  int f = 2; int sq = sqrt(n);
  while(n > 1 && f <= sq){
    int e = 0;
    while(n % f == 0){
      ++e; n/=f;
    }
    if(e > 0) ret.push_back(P(f,e));
    ++f;
  }
  if(n > 1) ret.push_back(P(n,1));
  return ret;
}

class modint{
  public:
  ll n;
  int mod = 1e9+7;

  modint (const ll x=0) noexcept : n(x) {}
  modint inverse(){return powf(*this, mod-2);}
  modint& operator+=(const modint a){n+=a.n; n%=mod; return *this;}
  modint operator+(const modint a){ return modint(*this)+=a; }
  modint& operator-=(const modint a){n+=(mod-a.n); n%=mod; return *this;}
  modint operator-(const modint a){return modint(*this)-=a;}
  modint& operator*=(const modint a){n*=a.n; n%=mod; return *this;}
  modint operator*(const modint a){return modint(*this)*=a;}
  modint& operator/=(modint a){return (*this)*=a.inverse();}
  modint operator/(const modint a){return modint(*this)/=a;}
};
ostream& operator<<(ostream& o, const modint& m){o<<m.n; return o;}

modint fact(int n){
  static vector<modint> f = {1,1};
  while(n >= (int)f.size()) f.push_back(f[f.size()-1]*modint(f.size()));
  return f[n];
}

modint combin(int n, int k){
  return fact(n)/fact(n-k)/fact(k);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m;
  cin >> n >> m;
  modint ans = 1;
  vector<P> pf = prime_factor(m);
  for(auto p : pf){
    ans *= combin(p.second + n - 1, p.second);
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    string S; cin>>S;
    int N = S.size();
    vector<vector<int>> J(26,vector<int> (N,0));
    rep(i,N){
        int tmp = S.at(i) - 'a';
        J.at(tmp).at(i) = 1;
    }
    rep(i,26){
        rep(j,N-1){
            J.at(i).at(j+1) += J.at(i).at(j);
        }
    }
    int l = -1,r = -1;
    int flag = 0;
    rep(i,26){
        int num = J.at(i).at(N-1);
        // cout<<num<<endl; 
        if(num==0)continue;
        rep1(j,num){
            auto iter1 = lower_bound(J.at(i).begin(),J.at(i).end(),j);
            auto iter2 = lower_bound(J.at(i).begin(),J.at(i).end(),j+1);
            int d1 = distance(J.at(i).begin(),iter1);
            int d2 = distance(J.at(i).begin(),iter2);
            //cout<<(char)('a'+i)<<endl;
            //cout<<d1<<" "<<d2<<endl;
            if(d2-d1+1<=3){
                l = d1+1;
                r = d2+1;
                flag = 1;
                break;
            }
        }
        if(flag)break;
    }
    cout<<l<<" "<<r<<endl;
}


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

using namespace std;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX = 1e5 + 5;

int main() {
    int n, q;
    cin >> n;
    long long a[MAX] = {0}, ans = 0;
    for (int i=0; i<n; i++) {
        int x;
        cin >> x;
        a[x-1]++;
        ans += x;
    }
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        ans -= a[b-1] * b;
        ans += a[b-1] * c;
        a[c-1] += a[b-1];
        a[b-1] = 0;
        cout << ans << "\n";
    }
}


Measured memory_bytes: 4404
/* bimillahir rahmanir rahim...
 * AUTHOR
 * mubin_akib */
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b) - 1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a) - 1; i >= 0; i--)
#define REP(i, a, b) for(int i = a; i <= (b); ++i)
#define trav(a,x) for(auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

void solve() {
    ll n, x, mn, cnt = 1;
    cin >> n >> mn;
    FOR(i, 1, n){
        cin >> x;
        if(x <= mn){
            cnt++;
            mn = x;
        }
    }
    cout << cnt << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int l[200003],r[200003],n,k,c;
string s;
int main(){
	cin>>n>>c>>k>>s;k++;
	l[0]=(s[0]=='o');
	for(int i=1;i<s.size();i++)
		if(s[i]=='o')
			l[i]=i>=k?l[i-k]+1:1;
		else
			l[i]=l[i-1];
	r[n-1]=(s[n-1]=='o');
	for(int i=n-2;i>=0;i--)
		if(s[i]=='o')
			r[i]=r[i+k]+1;
		else
			r[i]=r[i+1];
	for(int i=0;i<n;i++)
		if(s[i]=='o'){
			int res=0;
			if(i>0)res+=l[i-1];
			if(i<n-1)res+=r[i+1];
			if(res<c)cout<<i+1<<endl; 
		}
} 

Measured memory_bytes: 3332
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << max({a,b,c}) - min({a,b,c}) << endl;
}

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

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
A = [0] + A

x = [0] * (N+1)
#print(A[1:N+1:2])
#print(A[2:N:2])
x[1] = sum(A[1:N+1:2]) - sum(A[2:N:2])
for i in range(1, N):
    x[i+1] = 2 * A[i] - x[i]

print(" ".join(map(str, x[1:])))

Measured memory_bytes: 19912
N = int(input())
R = [tuple(map(int, input().split())) for _ in range(N)]
B = [tuple(map(int, input().split())) for _ in range(N)]


R.sort(reverse=True, key=lambda k: k[1])
B.sort()

p = []
q = []
for c, d in B:
    for a, b in R:
        if (a, b) in p:
            continue
        if a < c and b < d:
            p.append((a, b))
            q.append((c, d))
            break

print(len(p))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int e=100;
  int f=100;
  for(int i=1;i<=100;i++){
    if(a-d*i<=0){
       e=i;
       i=101;
    }
  }
  for(int i=1;i<=100;i++){
    if(c-b*i<=0){
       f=i;
       i=101;
    }
  }
  if(f<=e){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


struct UnionFind{
    int par[MAX];
    int kosuu[MAX];
    UnionFind(int n){
        REP(i,n) par[i]=i;
        REP(i,n) kosuu[i] = 1;
    }

    int root(int x){
        int tmp;
        if(par[x]==x) return x;
        else{
            tmp=root(par[x]);
            par[x]=tmp;
            return tmp;
        }
    }

    bool same(int x,int y){
        return root(x) == root(y);
    }

    void unite(int x,int y){
        if(not same(x,y)){ 
        kosuu[root(y)] += kosuu[root(x)];
        par[root(x)] = root(y);
        }
    }

    int renketu_kosuu(int x){
        return kosuu[root(x)];
    }
};


signed main(){
    int n,m;
    cin >> n >> m;
    UnionFind U(n+1);

    pair<int,int> A[m];
    REP(i,m){
        scanf("%lld%lld",&A[i].fi,&A[i].se);
    }

    int ans[m+1];
    int renketu = 0;
    REPR(i,m-1){
        int x = A[i].fi;
        int y = A[i].se;
        if(U.same(x,y)){
            ans[i] = renketu;
            continue;
        }
        int mae = U.renketu_kosuu(x) * (U.renketu_kosuu(x) -1) / 2;
        mae += U.renketu_kosuu(y) * (U.renketu_kosuu(y) -1) / 2;
        U.unite(x,y);
        renketu += U.renketu_kosuu(x) * (U.renketu_kosuu(x) -1) / 2 - mae;
        ans[i] = renketu;
    }



   
    ans[m] = 0; 
    REP(i,m){
        cout << n * (n-1) / 2 - ans[i+1] << endl;
    }


}


Measured memory_bytes: 6528
N, x = map(int, input().split())
A    = list(map(int, input().split()))

A.sort()

R = 0
F = False

for a in A[:-1]:
    if a <= x:
        R += 1
        x -= a
    else:
        break
        F = True

if A[-1] == x or (A[-1] > x and F == True):
    R += 1

print(R)


Measured memory_bytes: 3060
using System;

public class Hello
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        var p11 = n % 11;
        var b11 = n / 11;
        var ret = b11 * 2;
        if (p11 > 6) ret += 2;
        else if (p11 > 0 && p11 <= 6) ret += 1;
        Console.WriteLine(ret);
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n, a, ans = 1;
  cin >> n;

  rep(i, n) cin >> a, ans = lcm(a, ans);

  cout << ans << endl;
  return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    string str[n+10];
    for(int i=0;i<n;i++){
      cin>>str[i];
      string str2="";
      str2+=str[i][0];
      for(int j=0;j<str[i].size();j++){
	if(!(str[i][j]!='a'&&str[i][j]!='i'&&str[i][j]!='u'&&str[i][j]!='e'&&str[i][j]!='o')){
	  if(j==str[i].size()-1)break;
	  str2+=str[i][j+1];
	}
      }
      str[i]=str2;
      //cout<<str[i]<<endl;
    }
    bool flag=true;
    int ma=1;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i==j)continue;
	if(i!=j&&str[i]==str[j])
	  flag=false;
	int cnt=0;
	while(str[i][cnt]==str[j][cnt]&&str[i].size()>cnt&&str[j].size()>cnt){
	  cnt++;
	  //cout<<str[i][cnt]<<" "<<str[j][cnt]<<endl;
	  ma=max(ma,cnt+1);
	}
      }
    }
    cout<<((flag==true)?ma:-1)<<endl;
      
  }
  return 0;
}



Measured memory_bytes: 3148
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then List.range n `To m  else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (n,x,y) = scan "%d %d %d" Tuple3.make

let () =
  let arr = Array.make_matrix (succ n) (succ n) 0 in
  ListL.iter (1++n) ~f:(fun i ->
      ListL.iter (i++n) ~f:(fun j -> arr.(i).(j) <- j - i));
  ListL.iter (1++x) ~f:(fun i ->
      ListL.iter (x+1++n) ~f:(fun j ->
          arr.(i).(j) <- min (arr.(i).(x) + abs (j-y) + 1) arr.(i).(j)));
  ListL.iter (x+1++^y) ~f:(fun i ->
      ListL.iter (i+1++n) ~f:(fun j ->
          arr.(i).(j) <- min ((i-x) + abs (j-y) + 1) arr.(i).(j)));
  let h = Hashtbl.create n in
  ListL.iter (1++n) ~f:(fun i ->
      ListL.iter (i+1++n) ~f:(fun j ->
          Hashtbl.modify_def 0 arr.(i).(j) succ h));
  (* Array.print ~sep:"\n" (Array.print Int.print) stderr arr ; *)
  ListL.iter (1++^n) ~f:(fun i ->
      Printf.printf "%d\n" @@ Hashtbl.find_default h i 0)


Measured memory_bytes: 51972
N, K = map(int, input().split())
h = list(map(int, input().split()))

INF = int(1e20)
dp = [INF] * (N)
dp[0] = 0


for i in range(N-1):
    for j in range(K+1):
        if j == 0:
            continue
        if i + j >= N:
            break
        else:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))

print(dp[N-1])

Measured memory_bytes: 53728
#include<stdio.h>
int main(){
int N,i,j;

scanf("%d",&N);
for(i=0;i<=100;i+=4){
  for(j=0;j<=100;j+=7){
    if(N== i + j){
      printf("Yes\n");
      return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}

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

int main() {
    int n;
    int cnt = 0;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p.at(i);
    }
    for(int i = 0; i < n; i++){
        if(p.at(i) != i+1)cnt++;
    }
    if(cnt == 0 || cnt == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 400000    // the max length of deque

typedef struct {
    int queue[N];
    int head;
    int tail;
    int length;
} Deque;

void push(Deque *_dq, int _d, int _x) {
    if (_dq->length == 0) {
        _dq->queue[_dq->head] = _x;
    }
    else {
        if (_d == 0) {  // add new element at the beginning of deque
            _dq->head = (N + _dq->head - 1)%N;
            _dq->queue[_dq->head] = _x;
        }
        else {          // _d == 1, add new element at the end of deque
            _dq->tail = (N + _dq->tail + 1)%N;
            _dq->queue[_dq->tail] = _x;
        }
    }
    ++_dq->length;
}

void randomAccess(Deque *_dq, int _p) {
    printf("%d\n", _dq->queue[(_dq->head + _p)%N]);
}

void pop(Deque *_dq, int _d) {
    if (_dq->head != _dq->tail) {
        if (_d == 0) {	// delete the first element
            _dq->head = (N + _dq->head + 1)%N;
        }
        else {			// _d == 1, delete the last element
            _dq->tail = (N + _dq->tail - 1)%N;
        }
    }
    --_dq->length;
}

int main() {
    int q;	// amount of querries
	int op;	// number of operation, 0: push, 1: randomAccess, 2: pop
	int si;	// the second input
	int x;	// input value
	int i;	// index
	Deque dq;
    dq.head = 0;
    dq.tail = 0;
    dq.length = 0;
	scanf("%d", &q);
	for (i = 0; i != q; ++i) {
		scanf("%d%d", &op, &si);
		switch (op) {
			case 0:		// push()
				scanf("%d", &x);
				push(&dq, si, x);
				break;
			case 1:		// randomAccess()
				randomAccess(&dq, si);
				break;
			default:	// op == 2, pop()
				pop(&dq, si);
		}
	}
	return 0;
}


Measured memory_bytes: 3268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

void Main()
{
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) {
		cout << s;
	}
	else {
		cout << "red";
	}
}
 
int main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  pair<long long,pair<long long,int>> P[100000];
  for(int i=0;i<M;i++){
    long long p,y;
    cin>>p>>y;
    P[i]=make_pair(p,make_pair(y,i));
  }
  sort(P,P+M);
  long long A[100000];
  int num=1;
  for(int i=0;i<M;i++){
    if(i!=0&&P[i].first!=P[i-1].first) num=1;
    int n=P[i].second.second;
    A[n]=1000000*P[i].first+num;
    num++;
  }
  for(int i=0;i<M;i++){
    int judge=0;
    long long X=A[i];
    while(X>=1000000){
      X/=10;
      judge++;
    }
    for(int j=0;j<6-judge;j++) cout<<0;
    cout<<A[i]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 6308
N,K=map(int,input().split())
A=[]
B=[0]*N
ans=0
for i in range(K):
    input()
    A=list(map(int,input().split()))
    for j in A:
        B[j-1]=1
for i in B:
    if i==0:
        ans+=1
print(ans)

Measured memory_bytes: 9148
#include <iostream>
#include <cstring>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;


int main(){		
	string s;
	cin >> s;
	int x = 0;
	vector <int> v;
	for(int i = 0;s[i]!='\0';i++){
		if(s[i]=='R'){
			x++;
		}
		else{
			v.push_back(x);
			x = 0;
		}
	}
	v.push_back(x);
	sort(v.begin(),v.end());
	int n = v.size()-1;
	cout<<v[n]<<"\n";
	return 0;
}	


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

using namespace std;

typedef long long ll;

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

int main(void) {
    ll H, N;
    cin >> H >> N;

    ll acc = 0;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        acc += a;
    }

    if (H <= acc) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
while 1:
    t,h,s=map(int,raw_input().split())
    if t==h==s==-1:
        break
    rs=2*60*60-t*60*60-h*60-s
    rs3=rs*3
    nt=rs/3600;nh=(rs%3600)/60;ns=rs%60
    nt3=rs3/3600;nh3=(rs3%3600)/60;ns3=rs3%60
    print("%02d:%02d:%02d"%(nt,nh,ns))
    print("%02d:%02d:%02d"%(nt3,nh3,ns3))

Measured memory_bytes: 6460
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
ll solve(ll n, ll a[], ll b[]){
	for (ll i = 0; i < 3; i++) b[i] -= a[i];
	ll dp[n + 1];
	dp[0] = 0;
	for (ll i = 1; i <= n; i++){
		dp[i] = 0;
		for (ll j = 0; j < 3; j++){
			if (i - a[j] >= 0) dp[i] = max(dp[i], dp[i - a[j]] + b[j]);
		}
	}
	for (ll i = 0; i < 3; i++) b[i] += a[i];
	return dp[n];
}
int main(){
	ll n, a[3], b[3];
	scanf("%lld", &n);
	for (ll i = 0; i < 3; i++) scanf("%lld", &a[i]);
	for (ll i = 0; i < 3; i++) scanf("%lld", &b[i]);
	ll t = solve(n, a, b) + n;
	printf("%lld\n", solve(t, b, a) + t);
}

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

using namespace std;

int main() {
  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  int64_t answer = numeric_limits<int64_t>::min();
  answer = max(answer, a * c);
  answer = max(answer, a * d);
  answer = max(answer, b * c);
  answer = max(answer, b * d);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3632
# coding: utf-8

visited = [False]*101
discovery_time = [0]*101
finish_time = [0]*101
A = [[] for _ in range(101)]
time = 0

def dfs(n):
    global time
    if visited[n] == True:
        return
    time += 1
    discovery_time[n] = time
    visited[n] = True
    for i in A[n]:
        dfs(i)
    time += 1
    finish_time[n] = time

n = int(input().rstrip())
for i in range(n):
    line = [int(j) for j in input().rstrip().split()]
    A[i+1].extend(line[2:])

for i in range(n):
    dfs(i+1)
    
for i in range(n):
    print(str(i+1)+ " "+ str(discovery_time[i+1])+" "+str(finish_time[i+1]))



Measured memory_bytes: 5628
from collections import deque
import bisect

N = int(input())

A = [int(input()) for i in range(N)]

q = deque([A[0]])

for a in A[1:]:
    idx = bisect.bisect_left(q, a)
    if idx == 0:
        q.appendleft(a)
    else:
        q[idx-1] = a

print(len(q))

Measured memory_bytes: 14608
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C;
    cin>>A>>B>>C;
    if(A==7 && B==5 && C==5){cout<<"YES"<<endl;return 0;}
    else if(A==5 && B==7 && C==5){cout<<"YES"<<endl;return 0;}
    else if(A==5 && B==5 && C==7){cout<<"YES"<<endl;return 0;}
    else{cout<<"NO"<<endl;return 0;}
    
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

static class Program
{
    static void Main()
    {
        var k = int.Parse( Console.ReadLine() );
        Enumerable.Repeat<Func<string>>( Console.ReadLine, k * 2 )
            .Select( (x, i) => new { v = x(), k = i >> 1 } )
            .GroupBy( 
                x => x.k, 
                x => x.v.Reverse()
                    .Select( (y, i) => new { v = y - '0', i } ) )
            .Select( 
                x => x.SelectMany( y => y )
                    .GroupBy( y => y.i, y => y.v )
                    .Select( y => y.Sum() )
                    .Aggregate(
                        new { c = false, d = new List<int>() },
                        (a, b) => {
                            var v = b + ( a.c ? 1 : 0 );
                            var c = v >= 10;
                            a.d.Add( c ? v - 10 : v );
                            return new { c, d = a.d };
                            },
                        y => {
                            if ( y.c )
                                y.d.Add( 1 );
                            return y.d
                                .Select( z => (char)( z + '0' ) )
                                .Reverse()
                                .ToArray();
                            } ) )
            .Select( x => x.Length > 80 ? "overflow" : new string( x ) )
            .ToList()
            .ForEach( Console.WriteLine );
    }
}

Measured memory_bytes: 6800
H,W = map(int,input().split())

a = []

N = 0
ans = []

for i in range(H):

    A = list(map(int,input().split()))

    a.append(A)

for i in range(H-1):

    for j in range(W):

        if a[i][j] % 2 == 1:

            a[i+1][j] += 1

            ans.append([i+1,j+1,i+2,j+1])

            N += 1

for j in range(W-1):

    if a[-1][j] % 2 == 1:

        a[-1][j+1] += 1

        ans.append([H,j+1,H,j+2])

        N += 1

print (N)

for i in ans:

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


Measured memory_bytes: 64476
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<map>
#include<set> 
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<math.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll s1,s2,s3,s4;
	s1=a*c;s2=a*d;s3=b*c;s4=b*d;
	ll max1=max(s1,s2);
	ll max2=max(s3,s4); 
	if(max1>=max2)
		cout<<max1<<endl;
	else
		cout<<max2<<endl;
	return 0;
}


Measured memory_bytes: 3624