akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
int main(void){
    int h,a;
    scanf("%d %d",&h,&a);
    int A;
    if(a>=h){
        A=1;
    }else{
        if(h%a==0){
            A=h/a;
        }else{
            A=h/a+1;
        }
    }
    printf("%d\n",A);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        int k = s.Length;
        int c = 0;
        for (int i = 0; i < k; i++)
            c += s[i] == 'o' ? 1 : 0;
        if (c + (15 - k) >= 8)
            Console.WriteLine("YES");
        else
            Console.WriteLine("NO");
    }
}

Measured memory_bytes: 11092
import itertools as it
import time

N, A, B, C = map(int, input().split())
l = []


for i in range(N):
	l.append(int(input()))
	
allocate = (list(it.product("0123", repeat = N)))
least_score = 99999999999999999999999
for lst in allocate:
	if lst.count("0") * lst.count("1") * lst.count("2") >= 1:
		abc = [[], [], [], []]
		for i in range(len(lst)):
			abc[int(lst[i])].append(l[i])
		# print(abc)
		score = (len(abc[0]) - 1 + len(abc[1]) - 1 + len(abc[2]) - 1) * 10 + abs(sum(abc[0]) - A) + abs(sum(abc[1]) - B) + abs(sum(abc[2]) - C)
		if score < least_score:
			least_score = score
			
print(least_score)

Measured memory_bytes: 54188
N = int(input())

dp = [0] * (1 << N)
dp[0] = 1
curr = {0}
MOD = 10**9+7

for _ in range(N):
    a = [1 << i for i, v in enumerate(input().split()) if v == '1']
    nxt = set()
    for i in curr:
        dpi = dp[i] % MOD
        for j in a:
            if i & j:
                continue
            dp[i | j] += dpi
            nxt.add(i | j)
    curr = nxt
print(dp[(1 << N) - 1] % MOD)

Measured memory_bytes: 137316
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

int gcd(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

ll gcdp(int a,int b,int c){
    if(a==b&&b==c){
        return a;
    }
    else if(a==b) return gcd(a,c)*3;
    else if(a==c) return gcd(b,a)*3;
    else if(c==b) return gcd(a,b)*3;
    else return gcd(gcd(a,b),c)*6;
}


int main(){
    int k;
    cin>>k;
    ll ans=0;
    repi(a,1,k+1){
        repi(b,a,k+1){
            repi(c,b,k+1){
                ans+=gcdp(a,b,c);
            }
        }
    }
    cout<<ans<<endl;
}

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

int main() {
    string s;
    ll ans;
    cin >> s;
    
    rep(i,s.length()) {
        ans += int(s[i] - '0');
    }
   
    if (ans%9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	vector<int> dp(n, INT_MAX);
	for (auto &x : v) {
		cin >> x;
	}
	dp[0] = 0;
	for (int i{}; i < n; i++) {
		for (int j{1}; j <= k ; j++) {
			if (j + i < n) {
				dp[i + j] = min( dp[i + j] , dp[i] + abs(v[j + i] - v[i]) );
			}
		}
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 4052
N = int(input())
L = [[0,0,0]]
A = 0
for i in range(N):
    t,x,y = map(int, input().split())
    L.append([t,x,y])
for i in range(N):
    dx = abs(L[i+1][1])-abs(L[i][1])
    dy = abs(L[i+1][2])-abs(L[i][2])
    dt = L[i+1][0] - L[i][0]
    if dt < dx + dy or (dt - (dx + dy)) % 2 != 0:
        A += 1
        break
if A == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 59352
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
a=list(map(int1,input().split()))
ans=0
for i,x in enumerate(a):
    if i==a[x]:
        ans+=1
ans//=2
print(ans)

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

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

total = sum(line)

sikii = total / 4 /m

cnt = 0


for i in line:
    if i >= sikii:
        cnt += 1
    

if cnt >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
//hail to jwalaji
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli n,m,maxa=0;
vector<lli> adj[200005];
vector<bool> stat(200005,0);
lli dfs(lli a){
    //cout<<"a : "<<a<<endl;
    stat[a]=1;
    lli temp=0;
for(auto &it: adj[a]){
    if(!stat[it]){
            //cout<<"it : "<<it<<endl;
        stat[it]=1;
        temp+=dfs(it);
    }
}
//cout<<"temp+1 : "<<temp+1<<endl;
return temp+1;
}
lli solve(){
for(lli i=1;i<=n;i++){
    if(!stat[i]){
        maxa=max(maxa,dfs(i));
    }
}
return maxa;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
cin>>n>>m;
//cout<<adj[1].size();
for(lli i=0;i<m;i++){
        lli a,b;
    cin>>a>>b;
    adj[a].push_back(b);
    adj[b].push_back(a);
}
cout<<solve()<<endl;
return 0;
}


Measured memory_bytes: 23932
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
	string s;
	while(cin>>s&&s!="#"){
		//board:ball=1,null=0
		int board[10][10]; rep(i,10)rep(j,10) board[i][j]=0;
		//getinfo
		int nowY=0,nowX=0,h=1,w=0,tmpw=0;
		for(int i=0;i<(int)s.size();i++){
			if(s[i]=='b'){
				board[nowY][nowX]=1;
				nowX++;
				tmpw++;
			}else if('1'<=s[i]&&s[i]<='9'){
				nowX+=s[i]-'0';
				tmpw+=s[i]-'0';
			}else if(s[i]=='/'){
				nowY++; nowX=0;
				if(!w) w=tmpw;
				h++;
			}
		}
		//rep(i,h)rep(j,w) cout<<board[i][j];
		//swap
		int a,b,c,d; cin>>a>>b>>c>>d;
		a--; b--; c--; d--;
		board[a][b]=0; board[c][d]=1;
		//rep(i,h)rep(j,w) cout<<board[i][j];
		//print
		int cnt=0;
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				if(board[y][x]){
					if(cnt) cout<<cnt;
					cnt=0;
					cout<<"b";
				}else{
					cnt++;
				}
			}
			if(cnt) cout<<cnt;
			cnt=0;
			if(y!=h-1) cout<<"/";
		}
		cout<<endl;
	}
	return 0;
}



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

double sqnorm(double x1, double y1, double x2, double y2) {
    return pow((x1 - x2), 2) + pow((y1 - y2), 2);
}

int main(void) {
    int N; cin >> N;
    double x1, y1, x2, y2, x3, y3;
    double lsq, msq, nsq, l, n;
    double cos, a, b, c, d, e, f, det;
    double r, px, py;
    for(int i = 0; i < N; i++) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        lsq = sqnorm(x1, y1, x2, y2);
        msq = sqnorm(x2, y2, x3, y3);
        nsq = sqnorm(x3, y3, x1, y1);
        l = sqrt(lsq);
        n = sqrt(nsq);
        cos = (msq + nsq - lsq) / (2.0 * sqrt(msq * nsq));
        r = sqrt(lsq / (4.0 * (1.0 - cos * cos)));
        a = (x2 - x1) / l;
        b = (y2 - y1) / l;
        c = (x3 - x1) / n;
        d = (y3 - y1) / n;
        e = l / 2.0;
        f = n / 2.0;
        det = a* d - b * c;
        px = (d * e - b * f) / det + x1;
        py = (-c * e + a * f) / det + y1;
        r = roundf(r * 1000.0) / 1000.0;
        px = roundf(px * 1000.0) / 1000.0;
        py = roundf(py * 1000.0) / 1000.0;
        printf("%.3f %.3f %.3f\n", px, py, r);
    }
}

Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
	long long a,b,c,d,e,f,g,x,y,z;
	scanf("%lld%lld%lld",&a,&b,&c);
	x=a;
	y=b;
	z=c;
	while(1)
	{
		if(a%2!=0||b%2!=0||c%2!=0)
		{
			printf("%d\n",g);
			break;
		}
		d=a;
		e=b;
		f=c;
		a=(e+f)/2;
		b=(d+f)/2;
		c=(e+d)/2;
		g++;
		if(a==x&&b==y&&c==z)
		{
			printf("-1\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as MA
import qualified Data.Map.Strict as M
import qualified Data.Vector.Mutable as VM
import Control.Monad
import Data.IORef

main = do
    (n, _) <- MA.fromJust . BS.readInt <$> BS.getLine
    m <- newIORef (0 :: Int)
    hm <- newIORef (M.empty :: M.Map BS.ByteString Int)
    forM [0..n-1] $ \_ -> do
        s <- BS.getLine
        modifyIORef' hm (\hm' -> case M.lookup s hm' of 
                                    Just v -> M.insert s (v + 1) hm'
                                    Nothing -> M.insert s 0 hm'
                        )
        now <- (M.! s) <$> readIORef hm
        modifyIORef' m (\m' -> if now > m' then now else m')
    m' <- readIORef m
    hm' <- readIORef hm
    forM_ (M.keys (M.filter (== m') hm')) $ \l -> 
        BS.putStrLn l


Measured memory_bytes: 69628
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		String S = sc.next();
		sc.close();
		int[] a = new int [n];
		for(int i=0;i<n;i++)a[i]=Integer.parseInt(S.substring(i, i+1));
		List<Integer> list = new ArrayList<Integer>();
		//0ならtrue 1ならfalse;
		boolean Evenf = true;
		if(a[0]==1) Evenf = false;
		if(a.length==1) {
			if(!Evenf)list.add(1);
		}

		//a[0]が0ならば0をlistの先頭に追加して調整
		if(Evenf) list.add(0);

		for(int i=1,cnt=1;i<n;i++) {
			if(a[i]==a[i-1]) {
				cnt++;
			}else {
				list.add(cnt);
				cnt=1;
			}
			if(i==n-1) {
				list.add(cnt);
			}
		}

		List<Integer> sums = new ArrayList<Integer>();

		for(int loop=0,l=0,r=K*2+1;loop<list.size();loop+=2,l+=2,r+=2) {
			int sum = 0;
			for(int i=l;i<r&&i<list.size();i++)sum += list.get(i);

			sums.add(sum);
		}
		Collections.sort(sums,Collections.reverseOrder());
		System.out.println(sums.get(0));
	}
}

Measured memory_bytes: 31156
#include<stdio.h>
int n,A[50];
int solve(int i,int m){
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  int res = solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}

int main(){
  int q,M,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M)){printf("yes\n");}
    else {printf("no\n");}
  }
  return 0;
}

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

const int N = 2e5+5;
int n, a[N];
ll pre[N];

ll sum(int l, int r) {
    return pre[r] - pre[l-1];
}

ll g(ll a, ll b, ll c, ll d) {
    return max(max(a,b),max(c,d)) - min(min(a,b),min(c,d));
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pre[i] = a[i] + pre[i-1];
    }
    ll ans = 1e18;
    int o1 = 1, o2 = 3;
    for (int i = 2; i <= n-2; i++) {
        o2 = max(o2,i+1);
        while (o1+1 < i && abs(sum(o1+2,i)-sum(1,o1+1)) <
                           abs(sum(o1+1,i)-sum(1,o1)))
            o1++;
        while (o2+1 < n && abs(sum(i+1,o2+1)-sum(o2+2,n) <
                           abs(sum(i+1,o2)-sum(o2+1,n))))
            o2++;
        ans = min(ans,g(sum(1,o1),sum(o1+1,i),sum(i+1,o2),sum(o2+1,n)));
        //printf("%d: o1 = %d, o2 = %d\n",i,o1,o2);
    }
    cout << ans << '\n';
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=1000000007;

int main(){
    int n;cin>>n;
    int t[n],a[n];
    rep(i,n)cin>>t[i];
    rep(i,n)cin>>a[i];
    int com[n];
    rep(i,n)com[i]=min(t[i],a[i]);
    com[0]=com[n-1]=1;
    rep(i,n-1){
        if(t[i]!=t[i+1]){
            com[i+1]=1;
            if(t[i+1]>a[i+1])com[i+1]=0;
        }
    }
    rep(i,n-1){
        if(a[i]!=a[i+1]){
            com[i]=1;
            if(a[i]>t[i])com[i]=0;
        }
    }
    ll ans=1;
    rep(i,n){
        ans*=com[i]%mod;
        ans%=mod;
    }
    cout<<ans*(t[n-1]==a[0]?1:0)<<endl;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
	int a, b, c, i, j = 0;
	
	scanf("%d %d %d", &a, &b, &c);
	
	for (i = a; i <= b; i++) {
		if ((c % i) == 0)
			j++;
	}
	
	printf("%d\n", j);
	
	return 0;
}

Measured memory_bytes: 596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            String S = in.next();
            int e = 0;
            int w = 0;
            for (int i = 0; i < S.length(); i++) {
                if (S.charAt(i) == 'E') e++;
                else w++;
            }

            int ans = S.length();
            int ce = 0;
            int cw = 0;
            for (int i = 0; i < S.length(); i++) {
                int right_e = e - ce;
                if (S.charAt(i) == 'E') --right_e;
                ans = Math.min(ans, cw + right_e);
                if (S.charAt(i) == 'E') ++ce;
                else ++cw;
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 42284
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 9999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int>pi;

/*---------------------------------------------------*/

int main(){
  int n;
  cin>>n;
  if(n<1200)cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
  return 0;
}


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

int main(void){
  int M, D;
  cin >> M >> D;
  int day_ten, day_one;
  int count;
  for(int i = 1; i < M + 1; i++){
    for(int j = 1; j < D + 1; j++){
      day_ten = j / 10;
      day_one = j % 10;
      if(day_ten <= 1 || day_one <= 1){
        continue;
      } else if(day_ten * day_one == i){
        count++;
      }
    }
  }
  cout << count;
}

Measured memory_bytes: 256
/* Start coding only after you have clear idea.*/
#pragma GCC optimize(2)
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
const int N = 1e6 + 11;
#define inf 2000000007
#define mod 1000000007
#define IosF ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

int prime[N/3];
int miniFactor[N];
int primepos = 0;
void euler()
{
    int tmp;
    for (int i = 2; i < N; i++)
    {
        if (!miniFactor[i]) prime[primepos++] = i, miniFactor[i] = i;
        for (int j = 0; (tmp = i*prime[j]) < N && j<primepos; j++)
        {
            miniFactor[tmp] = prime[j];
            if (!(i % prime[j])) break;
        }
    }
}

vector<ll> Q;
int main() {
    IosF;
    euler();
    ll n, k;
    cin >> n;
    for ( int i = 0; i < primepos; ++ i ) {
        k = 1ll * prime[i];
        while ( k <= n ) {
            Q.push_back(k);
            k *= 1ll * prime[i];
        }
    }
    sort(Q.begin(), Q.end());
    int len = Q.size(), res = 0;
//    cout << len << endl;
    k = n;
    for ( int i = 0; i < len; ++ i ) {
        if ( k % Q[i] ) continue;
        if ( k < Q[i] ) break;
        k /= Q[i];
        ++ res;
    }
    for ( int i = 0; i < primepos; ++ i ) {
        while ( !(n % prime[i]) ) n /= prime[i];
    }
    if ( n > 1 ) ++ res;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 9520
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    string a, b;
    cin >> a >> b;
    if(a[0] == b[2] && b[0] == a[2] && a[1] == b[1])
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


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

vector<int> g[MAX];
vector<int> dp(MAX,-1);

int dfs(int i, int p){
    if(dp[i] != -1) return dp[i];
    vector<int> v;
    rep(j,g[i].size()){
        if(g[i][j] != p) v.push_back(dfs(g[i][j],i));
    }
    sort(v.begin(),v.end(),greater<int>());
    rep(i,v.size()) v[i] += i+1;
    int d = 0;
    rep(i,v.size()) d = max(d,v[i]);
    return dp[i] = d;
}

int main(){
    int n;
    cin >> n;
    rep(i,n-1) {
        int a;
        cin >> a;
        a--;
        g[a].push_back(i+1);
        g[i+1].push_back(a);
    }
    cout << dfs(0,-1) << endl;
    return 0;
}

Measured memory_bytes: 18560
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans += a[i] - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
main :: IO ()
main = do
    [n,tt] <- map read . words <$> getLine :: IO [Int]
    ct <- map ((\[a,b] -> (a,b)) . (map read . words))
        . lines <$> getContents :: IO [(Int,Int)]
    let lst = [ c | (c,t) <- ct, t <= tt ]
    putStrLn $ if null lst then "TLE" else show $ minimum lst

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a,b,x,ans=0;
  cin >> a >> b >> x;
  if (a == 0) {
    ans = b/x;
    ans++;
  } else {
    ans = b/x-(a-1)/x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;




int main() {
	int n;
	ll d;
	cin >> n >> d;
	ll d2 = d * d;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		ll dis = x * x + y * y;

		if (dis <= d2) {
			cnt++;
		}
		
	}

	cout << cnt << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
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;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/


int main()
{
  ll n;string s;cin>>n>>s;
  if(n%2==1){
    cout<<"No"<<endl;return 0;
  }else{
    for(ll i=0;i<n/2;i++){
      if(s[i]!=s[n/2+i]){
        cout<<"No"<<endl;return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin>>n;
	int d1[n];
	int d2[n];
	for(int i=0;i<n;i++){
		cin>>d1[i]>>d2[i];
	}
	bool ch=false;
	for(int i=0;i<n;i++){
		if(i+2<n){
			if(d1[i]==d2[i]&&d1[i+1]==d2[i+1]&&d1[i+2]==d2[i+2]){
				ch=true;
			}
		}
	}
	if(ch){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

        
	

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main()
{
    int r,d,x;
    
    cin >> r >> d >> x;
    vector<int> x_i(11,0);
    x_i[0] = x;
    for(int i = 1; i <= 10; i++) {
        x_i[i] = r *x_i[i-1] - d;
        cout << x_i[i] << endl;
    }

    return 0;
}


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



int main(){
	int hasil = 0;
	string s;
	cin >> s;
	for(int i = 0 ; i <= 3 ; i++){
		if(s[i] == '+') hasil++;
		if(s[i] == '-') hasil--;
	}
	printf("%d\n",hasil);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//F
//遠くにいく
//X,Yのabsの最大
int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;

    ll res = 48 - n;


    cout << res << endl;


    return 0;    

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n; cin >> n;
  vector<int> b(100005, 0);
  rep(i, n) {
    int a; cin >> a;
    b[a]++;
  }
  int ans = 0;
  for (int i = 0; i < 100000; i++) {
    chmax(ans, b[i] + b[i+1] + b[i+2]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

ll A[1010], B[1010], C[1010];
vector<ll> D, E;
int main()
{
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	for (int i = 0; i < X; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < Y; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < Z; i++) {
		cin >> C[i];
	}
	sort(A, A + X);
	sort(B, B + Y);
	sort(C, C + Z);
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			D.push_back(A[i] + B[j]);
		}
	}
	sort(D.begin(), D.end(), greater<ll>());
	for (int i = 0; i < min(X * Y, K); i++) {
		for (int j = 0; j < Z; j++) {
			E.push_back(D[i] + C[j]);
		}
	}
	sort(E.begin(), E.end(), greater<ll>());
	for (int i = 0; i < min(X * Y * Z, K); i++) {
		cout << E[i] << endl;
	}
}


Measured memory_bytes: 43364
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
for i in range(n):
  a = list(map(int,input().split()))
  score = 0
  for i in range(m):
    x = a[i]
    score += x * b[i]
  score += c
  if score > 0:
    count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int a,b,c,n;
    while(~scanf("%d",&n)){
    while(n--)
    {
        cin>>a>>b>>c;
        if(a+b>c&&a+c>b&&b+c>a&&(a*a+b*b==c*c||a*a==b*b+c*c||a*a+c*c==b*b))
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    }
    return 0;
}



Measured memory_bytes: 3120
k = int(input())

def dfs(d, val, A):
	A.append(val)

	if d == 10:
		return

	for i in range(-1, 2):
		add = (val % 10) + i
		if add >= 0 and add <= 9:
			dfs(d + 1, val * 10 + add, A)

A = []
for v in range(1, 10): # 呼び出し
	dfs(1, v, A)
A.sort()
print(A[k - 1])

Measured memory_bytes: 61776
#include <bits/stdc++.h>
using namespace std;
const int N = 4e4 + 5;

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int h, n;
  cin >> h >> n;

  int dp[N];
  memset(dp, 0x3f, sizeof dp);
  dp[0] = 0;

  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;

    for (int j = 0; j+a < N; ++j) {
      dp[j+a] = min(dp[j+a], dp[j] + b);
    }
  }

  int mn = INT_MAX;
  for (int i = h; i < N; ++i)
    mn = min(mn, dp[i]);
  cout << mn << '\n';
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int siz=2e5+7;
ll fac[siz];
int n,k;
ll m;
ll bigmod(int x,ll y){
    if(x==0) return 1ll;
    if(x==1) return y;
    ll ans=bigmod(x/2,y)%mod;
    ans=(ans*ans)%mod;
    if(x%2) ans=(ans*y)%mod;
    return ans;
}
ll ncr(int n,int r){
    ll ans=fac[n];
    ans=(ans*bigmod(mod-2,fac[r]))%mod;
    return ans=(ans*bigmod(mod-2,fac[n-r]))%mod;
}
int main()
{

    fac[0]=1;
    for(int i=1;i<=200000;i++) fac[i]=(fac[i-1]*i*1ll)%mod;

    scanf("%d%lld%d",&n,&m,&k);
    ll ans=0ll;
    for(int i=0;i<=min(n,k);i++){
        ll y=ncr(n-1,i);
        ll x=(bigmod(n-1-i,m-1)*m)%mod;
        ans=(ans+(x*y)%mod)%mod;
    }

    printf("%lld\n",ans);


    return 0;
}


Measured memory_bytes: 5428
use std::io::*;
use std::str::FromStr;

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

use std::cmp::min;

fn main() {
    let h: usize = read();
    let w: usize = read();
    let mut map: Vec<Vec<char>> = vec![vec!['#'; w + 2]; h + 2];

    for i in 1..h + 1 {
        let row: String = read();
        let mut rowc: Vec<char> = row.chars().collect();
        for w in 0..rowc.len() {
            map[i][w + 1] = rowc[w];
        }
    }

    for i in 0..map.len() {
        let mi = &map[i];
        let mut row: String = "".to_string();
        for i in mi {
            row += &i.to_string();
        }
        println!("{}", row);
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#define N 300005
#define mod 1000000007
#define ll long long
using namespace std;
ll up,n,m,k;
ll ans=0,fac[N*3],ifac[N*3],mul[N*3];
inline ll calc(int a,int b){return fac[a]*ifac[b]%mod*ifac[a-b]%mod;}
inline ll ksm(ll x,int p){
	ll ret=1;
	while(p){
		if(p&1)ret=ret*x%mod;
		x=x*x%mod,p>>=1;
	}
	return ret;
}
int main(){
	cin>>n>>m>>k,up=n+m+k,fac[0]=mul[0]=ifac[1]=ifac[0]=1;
	for(ll i=2;i<=up;++i)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;
	for(ll i=1;i<=up;++i)mul[i]=mul[i-1]*3%mod,(ifac[i]*=ifac[i-1])%=mod,fac[i]=fac[i-1]*i%mod;
	if(m<k)m^=k,k^=m,m^=k;
	for(ll i=0,j=1;i<=m+k;++i){
		(ans+=calc(n-1+i,n-1)*mul[m+k-i]%mod*j%mod)%=mod;
		if(i<k)(j<<=1)%=mod;
		else if(i>=m)(j+=j-calc(i,k)-calc(i,i-m))%=mod;
		else (j+=j-calc(i,k))%=mod;
	}
	cout<<(ans+mod)%mod;
	return 0;
}


Measured memory_bytes: 21376
#include <stdio.h>
#define N 100
#define INF 1000000
int m[N][N];
int num;
void matrixChainOrder(int *p);

int main(){
  int p[N];
  int i,j,ans;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }
  matrixChainOrder(p);

  return 0;
}

void matrixChainOrder(int *p){
  int i,j,k,l,n,q;

  n = num;
  for(i=1;i<=n;i++){
    m[i][i] = 0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i +l -1;
      m[i][j] = INF;
      for(k=i;k<=j-1;k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if(m[i][j] > q) m[i][j] = q;

      }
    }
  }
  	printf("%d\n",m[1][n]);
}




Measured memory_bytes: 2112
#include<iostream>
#include<set>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)

int main(){
    int a,b;
    cin >> a >> b ;

    if(a==b){
        rep(i, a) cout << a;
        cout << "\n";
    }else{
        if(a>b){
            rep(i ,a) cout << b;
            cout << "\n";
        }else{
            rep(i, b) cout << a;
            cout << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
    Scanner reader=new Scanner(System.in);
    int A= reader.nextInt();
    int B= reader.nextInt();
    int C= reader.nextInt();
    int D= reader.nextInt();
    int X=A+B;
    int Y=C+D;
    if (X>Y) {
    	System.out.println("Left");
    }
    else if(Y>X) {
    	System.out.println("Right");
    
	}
    else {
    	System.out.println("Balanced");	
    }
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
ll N, Answer = 0;cin >> N;
vector<ll> V(N);
vector<bool> Ans(N, 0);

rep(i, 0, N)cin >> V[i];

for(ll i = N - 1; i >= N/2; i--){

     if(V[i] == 1)Ans[i] = 1;

     if(V[i] == 0)Ans[i] = 0;

}

for(ll i = N/2 - 1; i >= 0; i--){

    ll a = 2, count = 0;

    while(a*(i + 1) <= N){

        if(Ans[a*(i + 1) - 1] == 1)count++;

        a++;
    
    }

    if(count%2 == V[i])Ans[i] = 0;

    else Ans[i] = 1;
}

ll a = 1;

for(auto ans : Ans ){

    if(ans)Answer++;

}

cout << Answer << endl;

for(auto ans : Ans ){

    if(ans)cout << a << " ";

    a++;
}

}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = i+1; j < n; j++)
        {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;

  int A, B;
  cin >> A >> B;

  string U;
  cin >> U;

  if(U==S) {
    cout << A-1 << " " << B << endl;
  } else {
    cout << A << " " << B-1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
<?php
$input = fgets(STDIN);
$array = explode(' ', $input);

if ($array[0] === '0') {
   echo 1;
} elseif ( $array[1] === '0') {
   echo 2;
} elseif ( $array[2] === '0') {
   echo 3;
} elseif ( $array[3] === '0') {
   echo 4;
} else {
   echo 5;
} 

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

int main(){
    int a[1000];
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        cout<<a[n-i-1]<<' ';
    }
    cout<<a[0]<<'\n';
}


Measured memory_bytes: 3080
#!/usr/bin/python
# -*- Coding: utf-8 -*-

n = int(input())
s_li = [input() for x in range(n)]

num_AC = s_li.count("AC")
num_WA = s_li.count("WA")
num_TLE = s_li.count("TLE")
num_RE = s_li.count("RE")

print("AC x "+str(num_AC))
print("WA x "+str(num_WA))
print("TLE x "+str(num_TLE))
print("RE x "+str(num_RE))


Measured memory_bytes: 16148
#include <iostream>
#include <vector>

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    int groups;

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        groups = N;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        groups--;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  int N, M; cin >> N >> M;
  UnionFind t(N);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b; 
    a--;
    b--;
    t.unite(a, b);
  }
  cout << t.groups - 1 << endl;
}

Measured memory_bytes: 3704
def bakt():
    len_s = [0]*int(1e+5+1)
    N, K = map(int, input().split())
    for _ in range(N):
        a, b = map(int, input().split())
        len_s[a] += b
    len_a = 0
    for i, j in enumerate(len_s):
        len_a += j 
        if len_a >= K:
            print(i)
            break
            
            
if __name__ == '__main__':
    bakt()


Measured memory_bytes: 5740
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int r = sc.nextInt();
    if (h + r > 0)
    System.out.println(1);
    if (h + r == 0)
    System.out.println(0);
    if (h + r < 0)
    System.out.println(-1);
  }
}


Measured memory_bytes: 26212
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    int a, b, c;
    cin >> a >> b >> c;

    int ans = max(a * 10 + b + c, max(b * 10 + a + c, c * 10 + a + b));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main()
{
    int ant[6];
    int k;
    rep(i,5) cin >> ant[i];
    cin >> k;
    if(ant[4]-ant[0]<=k) cout << "Yay!";
    else cout << ":(";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

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


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

using namespace std;

vector <int> v;
map <int, int> m;

int main() {
	int N, H;
	scanf("%d %d", &N, &H);
	for (int i = 0; i < N; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		v.push_back(x);
		v.push_back(y);
		m[x]++;
	}
	sort(v.begin(), v.end());
	int ans = 0, cur = 0;
	for (int i = v.size() - 1; i >= 0; i--) {
		cur += v[i];
		ans++;
		if (cur >= H) {
			printf("%d\n", ans);
			return 0;
		}
		if (m.count(v[i]) > 0) {
			 int x = H - cur;
			 int xx = x / v[i];
			 if (xx * v[i] < x) 
			 	xx++;
			ans += xx;
			printf("%d\n", ans);
			return 0;
		}
	}
	printf("-1 -1 -1\n");
	return 0;	
}

Measured memory_bytes: 1784
#lにa回、rにb回進む
x,y = map(int,input().split())
#x = a +2b
#y = 2a+b
#x+y = 3a+3b
#a+b = (x+y)/3
#b=x-a+b
b = x-(x+y)/3
a = (x-2*b)
ans = 0
#print("a:{} b:{}".format(a,b))
if a<0 or b<0 or b-int(b)>0.00001 or a-int(a)>0.00001:
  print(ans)
  exit()

MAX = int(a+b)+1
MOD = 1000000007

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]

#テーブルを作る前処理
def COMinit():
    fac[0],fac[1] = 1,1
    finv[0],finv[1] = 1,1
    inv[1] = 1
    for i in range(2,MAX):
      fac[i] = fac[i - 1] * i % MOD
      inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
      finv[i] = finv[i - 1] * inv[i] % MOD

#二項係数計算
def COM(n,k):
  if n < k:
    return 0
  if n < 0 or k < 0:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

COMinit()
print(COM(int(a+b),int(a)))

Measured memory_bytes: 82200
n = int(input())
*D, = map(int, input().split())
mod = 998244353
if D[0] != 0:
    print(0)
    exit()
C = {}
for d in D:
    try:
        C[d] += 1
    except BaseException:
        C[d] = 1
ans = 1
for d in D[1:]:
    try:
        ans = (ans * C[d - 1]) % mod
    except BaseException:
        ans = 0
print(ans)


Measured memory_bytes: 19552
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  
  string s;
  cin >> s;
  
  if(s[K - 1] == 'A')
    s[K - 1] = 'a';
  else if(s[K - 1] == 'B')
    s[K - 1] = 'b';
  else
    s[K - 1] = 'c';
  
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll mini = A * (N - 2);
    ll maxi = B * (N - 2);
    cout << max(0LL, maxi - mini + 1) << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(){
    string s;int w;
    cin>>s;
    cin>>w;
    string ans;
    rep(i,s.size()){
        if(i%w==0) ans.push_back(s[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

template<typename T>
string join(vector<T>& vec, string sep = " "){
    stringstream ss;
    for(int i = 0; i < vec.size(); i++){
        ss << vec[i] << (i + 1 == vec.size() ? "" : sep);
    }
    return ss.str();
}

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

    int n;
    cin >> n;

    cout << n / 3 << endl;

    return 0;
}


Measured memory_bytes: 256
import copy
h, w = map(int, input().split())
c = []
for i in range(10):
    c.append(list(map(int, input().split())))
a = []
for i in range(h):
    a.append(list(map(int, input().split())))

for i in range(10):
    c_new = [[None for x in range(10)] for y in range(10)]
    for j in range(10):
        for k in range(10):
            c_new[j][k] = min(c[j][k], c[j][i] + c[i][k])
    c = copy.copy(c_new)

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == -1:
            continue
        else:
            ans += c_new[a[i][j]][1]
print (ans)


Measured memory_bytes: 3956
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long int;

int main(){
	ll N, K[3][100000];
	cin >> N;
	vector<tuple<ll, ll, ll>> v;
	for (ll i = 0; i < N; i++) cin >> K[0][i];
	for (ll i = 0; i < N; i++) cin >> K[1][i];
	for (ll i = 0; i < N; i++) cin >> K[2][i];
	
	for (ll k = 0; k < 3; k++)
		for (ll i = 0; i < N; i++)
			v.push_back(make_tuple(k, K[k][i], 1));
	
	sort(v.begin(), v.end(), [](auto& a, auto& b)->bool{
		if (get<1>(a) < get<1>(b))
			return true;
		if (get<1>(a) == get<1>(b)
			&& get<0>(a) > get<0>(b))
		{
			return true;
		}
		return false;
	});
	
	ll sum;
	for (ll k = 0; k < 3; k++)
	{
		sum = 0;
		for (ll i = 0; i < 3 * N; i++)
		{
			if (get<0>(v[i]) == k + 1)
				get<2>(v[i]) = sum;
			else if (get<0>(v[i]) == k)
				sum += get<2>(v[i]);
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 17004
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2300

#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  double S[25][3];
  for (auto i=0; i<N; i++) {
    cin >> S[i][0] >> S[i][1] >> S[i][2];
  }
  double T[25][25];
  fill(&T[0][0], &T[0][0]+25*25, 0);
  for (auto i=0; i<N; i++) {
    for (auto j=0; j<N; j++) {
      for (auto k=0; k<3; k++) {
	double temp = S[i][k] - S[j][k];
	T[i][j] += temp * temp;
      }
    } 
  }
  int P[25];
  for (int i=0; i<N-M; i++) {
    P[i] = 0;
  }
  for (int j=N-M; j<N; j++) {
    P[j] = 1;
  }
  double max = 0;
  do {
    double sum = 0;
    for (auto i=0; i<N; i++) {
      if (!P[i]) continue;
      for (auto j=i+1; j<N; j++) {
	if (P[j]) sum += T[i][j];
      }
    }
    if (max < sum) max = sum;
  } while (next_permutation(P, P+N));
  cout << fixed << setprecision(6) << max << endl;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long a;
    long long ans1=1000000000000000000,ans2=1;
    int flag=0;
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a);
        if(a!=0)
            ans1/=a;
        if(a==0)
            flag=1;
        ans2*=a;
    }
    if(flag)
        printf("0\n");
    else if(ans1==0)
        printf("-1\n");
    else
        printf("%lld\n",ans2);
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using myTuple = std::tuple<int, int, int>;

inline int abs_( int x )
{
	return ( x > 0 ? x : -x );
}

inline int max_( int x, int y )
{
	return ( x > y ? x : y );
}

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

	std::vector< std::tuple<int, int, int> > v;
	for ( int i = 0; i < N; i++ )
	{
		int x, y, h;
		std::cin >> x >> y >> h;
		v.emplace_back( std::make_tuple( x, y, h ) );
	}

	int Cx, Cy, Ch;

	if ( N == 1 )
	{
		// 座標が1つしか与えられなかった場合は、それを中心座標とする（それ以外情報が無いので）
		Cx = std::get<0>( v[0] );
		Cy = std::get<1>( v[0] );
		Ch = std::get<2>( v[0] );
	}
	else
	{
		for ( int i = 0; i <= 100; i++ )
		{
			for ( int j = 0; j <= 100; j++ )
			{
				bool okflg = true;
				for ( int k = 0; k < N; k++ )
				{
					if ( std::get<2>( v[k] ) <= 0 )
					{
						// 高さが0の点は無視
						continue;
					}

					int tmpH = std::get<2>( v[k] ) + abs_( i - std::get<0>( v[k] ) ) + abs_( j - std::get<1>( v[k] ) );

					for ( int l = 0; l < N; l++ )
					{
						if ( max_( tmpH - abs_( std::get<0>( v[l] ) - i ) - abs_( std::get<1>( v[l] ) - j ), 0 ) != std::get<2>( v[l] ) )
						{
							okflg = false;
							break;
						}
					}

					if ( okflg )
					{
						Cx = i;
						Cy = j;
						Ch = tmpH;
						goto end;
					}
					else
					{
						break;
					}
				}
			}
		}
	}
end:
	std::cout << Cx << " " << Cy << " " << Ch << std::endl;

	return ( 0 );
}


Measured memory_bytes: 760
from math import isinf

N, Ma, Mb = map(int, input().split())
a = [0]*N
b = [0]*N
c = [0]*N
for i in range(N):
    a[i],b[i],c[i] = map(int, input().split())

W_MAX = 40*10
dp = [[float('inf')]*(W_MAX+1) for _ in range(W_MAX+1)]
dp[0][0] = 0

for i in range(N):
    for wa in reversed(range(W_MAX+1)):
        for wb in reversed(range(W_MAX+1)):
            if isinf(dp[wa][wb]): continue
            if wa+a[i]<=W_MAX and wb+b[i]<=W_MAX:
                dp[wa+a[i]][wb+b[i]] = min(dp[wa+a[i]][wb+b[i]],
                                           dp[wa][wb]+c[i])

ans = float('inf')
for wa in range(1, W_MAX+1):
    for wb in range(1, W_MAX+1):
        if wa*Mb == wb*Ma:
            ans = min(ans, dp[wa][wb])

if isinf(ans): ans = -1
print(ans)

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

int main()
{
    int n; cin>>n;
    int ans=0,key=1;
    for(int i=1;i<=n;i++)
    {
        int temp; cin>>temp;
        if(temp==key)
        {
            key++;
        }
        else
            ans++;
    }
    if(ans==n)
        cout<<-1;
    else
        cout<<ans;
}


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

int main(){
  int N,M; cin >> N >> M; char A[N][N],B[M][M];
  rep(i,N) rep(j,N) cin >> A[i][j];
  rep(i,M) rep(j,M) cin >> B[i][j];
  bool check = false;
  rep(i,N-M+1) rep(j,N-M+1) {
      rep(k,M) rep(l,M) if (B[k][l] != A[i+k][j+l]) goto fail; 
      check = true; goto pass; fail:;
  }
  pass: if (check) cout << "Yes" << endl;
  else cout << "No" << endl;}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second

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

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
const int MAXL = 21;

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

vector<int> edges[MAXN];
int distA[MAXN];
int distB[MAXN];

void dfs_dist(int u, int p, int d, int* dist) {
	dist[u] = d;
	for (int v : edges[u]) if (v != p) dfs_dist(v, u, d + 1, dist);
}

inline int solve(int a, int b, int n) {
	int ans = 0;
	
	for (int i = 1; i <= n; i++) {
		if (distA[i] < distB[i]) {
			ans = max(ans, distB[i]);
		}
	}

	return ans - 1;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	int n, a, b; cin >> n >> a >> b;
	for (int i = 1; i < n; i++) {
		int u, v; cin >> u >> v;
		edges[u].pb(v);
		edges[v].pb(u);
	}

	dfs_dist(a, a, 0, distA);
	dfs_dist(b, b, 0, distB);
	int ans = solve(a, b, n);

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11648
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();
		int l = a * 2 + b * 2;
		int s = a * b;
		System.out.println(s + " " + l);
	}
}


Measured memory_bytes: 26320