akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define N_MAX 1007

using namespace std;

int n;

struct Barrier
{
    double x, y;
    double r;
};

double sq (double a)
{
    return a * a;
}

double dist (Barrier a, Barrier b)
{
    return max(0.0, sqrt(sq(a.x - b.x) + sq(a.y - b.y)) - a.r - b.r);
}

struct Edge
{
    int u;
    double d;
};

double cost[N_MAX][N_MAX];

Barrier barriers[N_MAX];

double d[N_MAX];

struct Path
{
    int finish;
    double d;
};

bool operator < (const Path &a, const Path &b)
{
    return a.d > b.d;
}

priority_queue <Path> pq;

bool visited[N_MAX];

void dijkstra ()
{
    pq.push(Path{0, 0});
    while(!pq.empty())
    {
        Path p = pq.top();
        pq.pop();
        if(visited[p.finish] == true)
            continue;
        visited[p.finish] = true;
        d[p.finish] = p.d;
        for(int i = 1; i <= n + 1; i++)
            if(p.finish != i && visited[i] == false)
                pq.push(Path{i, p.d + cost[p.finish][i]});
    }
}

Barrier start, finish;

int main()
{
    cin >> start.x >> start.y;
    cin >> finish.x >> finish.y;
    cin >> n;
    barriers[0] = start;
    barriers[n + 1] = finish;
    barriers[0].r = barriers[n + 1].r = 0;
    for(int i = 1; i <= n; i++)
        cin >> barriers[i].x >> barriers[i].y >> barriers[i].r;
    for(int i = 0; i <= n + 1; i++)
        for(int j = 0; j <= n + 1; j++)
            cost[i][j] = dist(barriers[i], barriers[j]);
    dijkstra();
    cout << fixed << setprecision(17) << d[n + 1];
    return 0;
}


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

int main() {
    string n, m;
    cin >> n;
    int ans, sumn, summ, i;
    long long power = 1;
    sumn = 0; summ = 0;
    int digit = n.size();
    if (digit == 1) ans = stoi(n);
    else {
        for (i = 0; i < digit - 1; i++) power *= 10;
        m = to_string((n.at(0) - '0') * power -1);
        for (i = 0; i < m.size(); i++) summ += (m.at(i) - '0');
        for (i = 0; i < digit; i++) sumn += (n.at(i) - '0');
        if (sumn > summ) ans = sumn;
        else ans = summ;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <iomanip>
#include <map>
#include <stack>
#include <sstream>

using namespace std;


int main()
 {
	//AC, WA, TLE, or RE
	int qanak = 0;
	int qanak1 = 0;
	int qanak2 = 0;
	int qanak3 = 0;
	    int size;
		std::cin >> size;
		std::vector <string> v1(size);
		//std::vector <int> v2(size);
		for (int i = 0; i < v1.size(); i++)
		{
			std::cin >> v1[i];
		}
		for (int i = 0; i < v1.size(); i++)
		{
			if (v1[i] == "AC")
			{
				qanak++;
			}
			if (v1[i] == "WA")
			{
				qanak1++;
			}
			if (v1[i] == "TLE")
			{
				qanak2++;
			}
			if (v1[i] == "RE")
			{
				qanak3++;
			}
		}
		cout << "AC x " << qanak << endl;
		cout << "WA x " << qanak1 << endl;
		cout << "TLE x " << qanak2 << endl;
		cout << "RE x " << qanak3 << endl;
	
	return 0;


}

Measured memory_bytes: 5196
import std.stdio, std.algorithm, std.conv, std.array, std.string;

int ketasum(int n)
{
    int sum;
    do {
        sum += n % 10;
    } while (n/=10);
    return sum;
}

void main()
{
    int N, A, B;
    readf("%d %d %d", &N, &A, &B);
    int sum;
    foreach (i; 1..N+1) {
        auto s = ketasum(i);
        if (A <= s && s <= B) sum += i;
    }
    writeln(sum);
}

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

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

Measured memory_bytes: 256
x,n = map(int,input().split())
P = list(map(int,input().split()))
i = 0
if not x in P:
    print(x)
else:
    while True:
        ans = x - i
        if not ans in P:
            print(ans)
            break
        else:    
            ans = x + i
            if not ans in P:
                print(ans)
                break
        i = i + 1

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

#define int long long

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n, res = 0;
	cin >> n;

	for (int i = 1; i <=n; ++i) {
		int x = (n / i) * i;
		res += ((x / i) * (x + i)) / 2;
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main(){
    int N,C;
    int D[31][31],c;
    scanf("%d %d",&N,&C);
    int i,j,k,l;
    int mod[3][31]={};
    for(i=1;i<=C;i++)
        for(j=1;j<=C;j++)
            scanf("%d",&D[i][j]);
    for(i=1;i<=N;i++){
        for(j=1;j<=N;j++){
            scanf("%d",&c);
            mod[(i+j)%3][c]++;
        }
    }
    int ans = 1e9;
    for(i=1;i<=C;i++){
        for(j=1;j<=C;j++){
            for(k=1;k<=C;k++){
                if(i == j || j == k || k == i){
                    continue;
                }
                int S = 0;
                for(l=1;l<=C;l++){
                    S += mod[0][l]*D[l][i];
                    S += mod[1][l]*D[l][j];
                    S += mod[2][l]*D[l][k];
                }
                if(ans > S){
                    ans = S;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main ()
{
	int i,n,c=0;
	char s[101];
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n/2;i++)
	{
		if(s[i]!=s[n-i-1])
		{
			c++;
		}
	}
	printf("%d",c);
	return 0;	
}

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

#define MD 1000000007

int dp[2097157], P[25];
int N, A[25][25];
int U[25], n, h;

int solve()
{
    int c = N - n;
    int res = 0;
    n--;
    for (int i = 0; i <= n; i++) if (A[c][U[i]])
    {
        h -= P[U[i]];
        if (dp[h] != -1) res = (res + dp[h]) % MD;
        else
        {
            if (i < n)
            {
                int tmp = U[i];
                U[i] = U[n];
                res = (res + solve()) % MD;
                U[i] = tmp;
            }
            else res = (res + solve()) % MD;
        }
        h += P[U[i]];
    }
    n++;
    dp[h] = res;
    return(res);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for (int i = 0; i < N; i++) P[i] = 1 << i;
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> A[i][j];
    for (int i = 0; i < N; i++) U[i] = i;
    n = N;
    h = (1 << N) - 1;
    int lim = 1 << N;
    dp[0] = 1;
    for (int i = 1; i < lim; i++) dp[i] = -1;
    cout << solve() << '\n';
    return(0);
}

Measured memory_bytes: 8448
using System;

namespace A{
    class Program{
        static void Main(string[] args){
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int temp = 1;
            int ans = 0;
            while(temp < b){
                temp += a - 1;
                ans++;
            }
            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;

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

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

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int op = 0, mi = 0;
    rep(i, n) {
        if (s[i] == '(') ++op;
        else --op;

        mi = min(mi, op);
    }

    for(int i=0;i<-mi;i++) s = '('+s,op++;
    for(int i=0;i<op;i++) s+=')';
    
    cout<<s<<endl;
    return 0;
}

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

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

for i in range(N):
    if B[i]>i+1:
        print(-1)
        sys.exit()

def dfs(B,LEN,ANS):
    #print(B,LEN,ANS)
    if LEN==0:
        for a in ANS[::-1]:
            print(a)
        sys.exit()
    for i in range(LEN-1,-1,-1):
        if B[i]==i+1:
            C=B[:i]+B[i+1:]
            dfs(C,LEN-1,ANS+[i+1])

dfs(B,N,[])
print(-1)

Measured memory_bytes: 38768
fun main(args: Array<String>) {
    val (N, X) = readInputLine().split(" ").map{it.toLong()}
    
    val a = LongArray(N.toInt() + 1)
    val p = LongArray(N.toInt() + 1)
    
    a[0] = 1L
    p[0] = 1L
    
    for (i in 1..N.toInt()) {
        a[i] = a[i - 1] * 2L + 3L
        p[i] = p[i - 1] * 2L + 1L
    }

    println(dfs(a, p, N.toInt(), X))
}

fun readInputLine(): String {
    return readLine()!!
}

fun dfs(a: LongArray, p: LongArray, N: Int, X: Long): Long {
    if (N == 0) {
        return X
    }
    return when {
        X == 1L -> 0L
        1L < X && X <= a[N - 1] + 1L -> dfs(a, p, N - 1, X - 1L)
        X == a[N - 1] + 2L -> p[N - 1] + 1L
        a[N - 1] + 2L < X && X <= a[N - 1] * 2L + 2L -> p[N - 1] + 1L + dfs(a, p, N - 1, X - a[N - 1] - 2L)
        else -> p[N - 1] * 2L + 1L
    }
}


Measured memory_bytes: 38020
#include <iostream>

using namespace std;

int main()
{
    int w,h,x,y,r;
    cin >> w >> h >> x >> y>> r ;
    if(x+r<=w&&x-r>=0&&y+r<=h&& y-r>=0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#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 FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 999999999;

int main(){
   int n;cin>>n;
   if(n%111==0){
      cout << n/111*111;
   }else{
      cout << (n/111+1)*111;
   }
   return 0;
}

Measured memory_bytes: 256
import numpy
import math
def input_parser():
    N=int(input())
    x=[int(i) for i in input().split()]
    return N, x

N, x=input_parser()
reachability_list = numpy.zeros(N)
reachable=1
threshold=0
for idx in range(0,N,1):
    if idx==0:
        reachability_list[idx]=reachable
    else:
        while True:
            if x[idx-1]>threshold:
                reachability_list[idx]=reachable
                threshold+=2
                break
            else:
                target_threshold = math.floor((x[idx-1]-1)/2)*2
                reachable+=(threshold-target_threshold)/2
                threshold=target_threshold
l=numpy.zeros(N)
order=1
for idx in range(0,N,1):
    if not reachability_list[idx]==order:
        l[order-1]=idx-order+1
        order+=1
for itr in range(order-1,N,1):
    l[itr]=N-itr
a=1
for itr in range(0,N,1):
   a=(a*l[itr])%(10**9+7)

def output_parser(output):
    print(output)

output_parser(int(a))

Measured memory_bytes: 23556
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

const int INF = 2 * 1000 * 1000 * 1000;

void solve(int N, const vector<int> &a, const vector<vector<int>>& g, int p, int x, vector<int> &lis, vector<int>& ans)
{
	auto idx = lower_bound(lis.begin(), lis.end(), a[x]) - lis.begin();
	auto val = lis[idx];
	lis[idx] = a[x];
	ans[x] = lower_bound(lis.begin(), lis.end(), INF) - lis.begin();
	for (auto y : g[x]) {
		if (y != p) {
			solve(N, a, g, x, y, lis, ans);
		}
	}
	lis[idx] = val;
}

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto& x : a) {
		cin >> x;
	}
	vector<vector<int>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int u, v;
		cin >> u >> v;
		--u;
		--v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector<int> lis(N, INF);
	vector<int> ans(N);
	solve(N, a, g, -1, 0, lis, ans);
	for (auto x : ans) {
		cout << x << endl;
	}
}


Measured memory_bytes: 36552
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    ll N;
    cin >> N;

    vector<ll> efu(N+1,0);

    for (ll i=1; i<N/2+1; i++) {
        for (ll j=i; j<=N; j+=i) efu[j]++;
    }
    for (ll j=N/2+1; j<=N; j++) efu[j]++;

    // output
    ll ans =0;
    for (int i=i; i<=N; i++) {
        ans +=efu[i]*i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 81372
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
const int mod = 1e9+7;
const int mx = INT_MAX;
const long double pi = 4*atan((long double)1);
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define file "orz"
const int mxN = 2e3+5;
int n,total,arr[mxN];
bool dp[mxN][100005];
signed main()
{
    //freopen(file".inp","r",stdin);
    //freopen(file".out","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>arr[i];
		total+=arr[i]; 	
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=100000;j++)
		{
			dp[i][j]|=dp[i-1][abs(j-arr[i])];
			if(arr[i]+j<=100000)
				dp[i][j]|=dp[i-1][j+arr[i]];
		}
	}
	for(int i=0;i<=100000;i++)
		if(dp[n][i])
			return cout<<((total+i)>>1),0;
}


Measured memory_bytes: 198972
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf1 INT_MAX
#define inf2 LLONG_MAX
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sbit __builtin_popcount
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define rit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define fill(a,b) memset(a,b,sizeof(a))
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define infile ifstream fin; fin.open("input.txt")
#define outfile ofstream fout; fout.open("output.txt")
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<ll,int>
#define pll pair<ll,ll>
#define p_queue priority_queue< plii,vector< plii >,greater< plii > > 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%lld",&x)
#define sst(x) scanf("%s",x)
#define pl(x) printf("%lld\n",x)
#define pi(x) printf("%d\n",x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

inline ll binex(ll a,ll b)
{
    ll ans=1,temp=a%mod;
    while(b!=0){
        if(b&1) ans=(ans*temp)%mod;
        temp=(temp*temp)%mod;
        b=b>>1;
    }
    return ans;
}

inline string solve(string a,string b)
{
    int n=sz(a),m=sz(b),dp[n+1][m+1];
    fill(dp,0);
    rep(i,1,n+1){
        rep(j,1,m+1){
            if(a[i-1]==b[j-1]) dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    if(dp[n][m]==0) return " ";
    /*rep(i,0,n+1){
        rep(j,0,m+1) cerr<<dp[i][j]<<" "; cerr<<endl;
    }*/
    
    string s;
    int i=n,j=m;
    while(sz(s)!=dp[n][m]){
        if(a[i-1]==b[j-1]){
            s.pb(a[i-1]); i--; j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }
    reverse(all(s));
    return s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b; cin>>a>>b;
    cout<<solve(a,b)<<endl;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    int q;
    cin >> q;
    rep(i, q) {
        ll k;
        cin >> k;

        {
            auto it = lower_bound(a.begin(), a.end(), k);
            if (it == a.end()) {
                cout << n <<  ' ';
            } else {
                cout << distance(a.begin(), it) << ' ';
            }
        }
        {
            auto it = upper_bound(a.begin(), a.end(), k);
            if (it == a.end()) {
                cout << n << endl;
            } else {
                cout << distance(a.begin(), it) << endl;
            }
        }
    }

}



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

/* define const */

/* finish defineing const */

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

  if (a*b > c*d)
    cout << a*b << endl;
  else
    cout << c*d << endl;
  
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MODNUM 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

int main(){
    int N;
    int ans = 0;
    cin >> N;
    vi A(N);

    vector<vi> x(N);
    vector<vi> y(N);
    vector<bool> HorU(N);
    
    rep(i,N){
        cin >> A[i];
        rep(j, A[i]) {
            int a, b;
            cin >> a >> b;
            a--;
            x[i].push_back(a);
            y[i].push_back(b);
        }

    }

    //R個の全探索(2^N通り)
    for (int bit = 0; bit < (1 << N); bit++) {
        bool flag = true;
        rep(i, N) HorU[i] = (bit & (1<<i));
        for (int i = 0; i < N; i++) {
            //i番目のビットが立っていた時の処理
            if (bit & (1<<i)) {
                rep(j, A[i]) {
                    if(HorU[x[i][j]] != y[i][j]){
                        flag = false;
                        break;
                    }
                }
            }
        }
        if(flag) {
            ans = max(__builtin_popcount(bit), ans);
        }   
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  n--;
    long long int s=0;
    for(int i=1;i<=n;i++)
    {
        s+=(n/i);
    }
    cout<<s;
  



}  


Measured memory_bytes: 3616
using System;
class Program
{
	static void Main(string[] args)
	{
		
		string[] input = Console.ReadLine().Split(' ');
		int N = int.Parse(input[0]);
		int H = int.Parse(input[1]);
                int W = int.Parse(input[2]);
		// 文字列の入力
int kotae=0;
                for (int i=0;i<N;i++){
		     input = Console.ReadLine().Split(' ');
                     int wei = int.Parse(input[0]);
                     int koremai = int.Parse(input[1]);
                     if(wei>=H){
if(koremai>=W){
kotae++;
}
}
                 }
		//出力
		Console.WriteLine(kotae);
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e5+5;
const int M=(1<<20)+5;
const int p=1e9+7;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
void add(int &x,int y)
{
	x+=y;
	if (x>=p) x-=p;
}
int sum1[M],sum2[M],dp[N],s[N],x[N];

signed main()
{
	x[0]=s[0]=0;
	memset(sum1,0,sizeof(sum1));
	memset(sum2,0,sizeof(sum2));
	int n=read();
	dp[0]=1;
	sum1[0]=1;
	for (int i=1;i<=n;i++)
	{
		x[i]=x[i-1]^read();
		s[i]=s[i-1]+(x[i]==0);
		dp[i]=((s[i-1]*sum1[x[i]]-sum2[x[i]]+1)%p+p)%p;
		add(sum1[x[i]],dp[i]);
		add(sum2[x[i]],dp[i]*s[i]%p);
	}
	if (x[n]) print(dp[n]);
	else
	{
		int ans=dp[n];
		for (int i=1;i<=n;i++) if (x[i]) add(ans,dp[i]);
		print(ans);
	}

	return 0;
}

Measured memory_bytes: 31700
#define rep(x,y)for(int x=0;x<y;x++)
n,k,a[200009];main(){
 scanf("%d%d",&n,&k);
 if(k>=42||k>=n){rep(i,n)printf("%d ",n);return 0;}
 rep(i,n)scanf("%d",a+i);
 while(k--){
  int b[200009]={0},s=0;
  rep(i,n){b[(i-a[i]>0?i-a[i]:0)]++;b[(n-1>i+a[i]?i+a[i]:n-1)+1]--;}
  rep(i,n){s+=b[i];a[i]=s;}
 }
 rep(i,n)printf("%d ",a[i]);
}

Measured memory_bytes: 3272
# A - ι⊥l
# https://atcoder.jp/contests/abc058/tasks/abc058_a

a, b, c = map(int, input().split())

result = 'NO'

if b - a == c - b:
    result = 'YES'
elif a - b == b - c:
    result = 'YES'

print(result)


Measured memory_bytes: 9160
#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; }

using Real=long double;
using Point=complex<Real>;
const Real EPS=1e-10;
const Real pi=acosl(-1);

inline bool eq(Real a,Real b){
    return fabs(a-b)<EPS;
}

Point operator*(const Point &p,const Real &d){
    return Point(real(p)*d,imag(p)*d);
}

// 点 p を反時計回りに theta 回転
Point rotate(Real theta, const Point &p) {
  return Point(cos(theta)*p.real()-sin(theta)*p.imag(),sin(theta)*p.real()+cos(theta)*p.imag());
}

Real dis(Point a,Point b){
    return abs(a-b);
}

Real radian_to_degree(Real r){
    return r*180.0/pi;
}

Real degree_to_radian(Real d){
    return d*pi/180.0;
}
 
//三角形の面積，サラスの公式
Real area_triangle(Point a,Point b,Point c){
    Point x=b-a,y=c-a;
    return fabs(x.real()*y.imag()-x.imag()*y.real())/2;
}
 
struct Circle{
    Point center;
    Real r;
    Circle(Point center,Real r):center(center),r(r){}
};

Circle MinimumBoundingCircle(vector<Point> v){
    int n=v.size();
    
    //ランダムシャッフル．いぢわるされたくないもんだ
    mt19937 mt(time(0));
    shuffle(v.begin(),v.end(),mt);

    Circle ret(0,0);
 
    //3点で円を作る
    auto make_circle2=[&](Point a,Point b){
        Real cx=(a.real()+b.real())/2;
        Real cy=(a.imag()+b.imag())/2;
        return Circle(Point(cx,cy),dis(a,b)/2);
    };
 
    //3点で円を作る
    auto make_circle3=[&](Point A,Point B,Point C){
        //wikiの公式
        Real S=area_triangle(A,B,C);
        Real a=dis(B,C),b=dis(A,C),c=dis(A,B);
        Point cent=A*(a*a*(b*b+c*c-a*a)/(16*S*S))+B*(b*b*(c*c+a*a-b*b)/(16*S*S))+C*(c*c*(a*a+b*b-c*c)/(16*S*S));
        return Circle(cent,dis(cent,A));
    };
 
    auto isIn=[&](Point a){
        return dis(ret.center,a)<ret.r+EPS;
    };

    ret=make_circle2(v[0],v[1]);
    for(int i=2;i<n;i++){
        //v[i]が円に入っていないなら
        if(!isIn(v[i])){
            //円内にないなら点v[i]は必ず円周上に来る
            ret=make_circle2(v[0],v[i]);
            for(int j=1;j<i;j++){
                if(!isIn(v[j])){
                    //この時iとjが円周上を考える
                    ret=make_circle2(v[i],v[j]);
                    //最後の1点の決定
                    for(int k=0;k<j;k++){
                        if(!isIn(v[k])){
                            ret=make_circle3(v[i],v[j],v[k]);
                        }
                    }
                }
            }
        }
    }
    return ret;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(12);

    int n;cin>>n;
    vector<Point> v(n);
    rep(i,n){
        Real x,y;cin>>x>>y;
        v[i]=Point(x,y);
    }
    auto ans=MinimumBoundingCircle(v);
    cout<<ans.r<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		int cnt= 0;
		while(true){
			int S = scn.nextInt();
			if(S==0) break;
			if(cnt!=0) pr.println();
			cnt++;
			int[] c = new int[4];
			for(int k=0;k<4;k++){
				c[k] = scn.nextInt();
			}
			int M = c[3]*500+c[2]*100+c[1]*50+c[0]*10;
			S=M-S;
			if(S/500>0){
					c[3]-=S/500;
					S= S%500;
			}
			if(S/100>0){
					c[2]-=S/100;
					S= S%100;
			}
			if(S/50>0){
					c[1]-=S/50;
					S= S%50;
			}
			if(S/10>0){
					c[0]-=S/10;
					S= S%10;
			}
			if(c[0]>0){
				pr.println(10+" "+c[0]);
			}
			if(c[1]>0){
				pr.println(50+" "+c[1]);
			}
			if(c[2]>0){
				pr.println(100+" "+c[2]);
			}
			if(c[3]>0){
				pr.println(500+" "+c[3]);
			}
		}
		pr.flush();
		scn.close();
	}

}

Measured memory_bytes: 39556
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
    ll a,b,n;cin>>n>>a>>b;
    ll count=0;
    count=n/(a+b)*a;
    n%=(a+b);
    count+=min(a,n);
    cout<<count<<endl;
}

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define ll long long

ll gcd(ll a, ll b){
  if(b == 0LL) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a*b / gcd(a,b);
}

int main(){
  ll a, b;

  while(scanf("%lld %lld",&a,&b) != EOF){
    printf("%lld %lld\n", gcd(a,b), lcm(a,b));
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll a[1005];
ll S[1001 * 500 + 5];

int main()
{
	int N, K;
	cin >> N >> K;
	REP(i, N)
	{
		cin >> a[i];
	}

	int index = 0;
	ll max = 0;
	REP(i, N)
	{
		ll sum = 0;
		FOR(j, N, i)
		{
			sum += a[j];
			S[index++] = sum;
			max = std::max(max, sum);
		}
	}


	ll bit = 1;
	while (bit <= max)
	{
		bit <<= 1;
	}
	int m = index;
	for (; bit > 0; bit >>= 1)
	{
		sort(S, S + m, [&](ll a, ll b) {return (a&bit) > (b&bit); });
		if ((S[0] & bit) == 0)
		{
			continue;
		}
		int ok = 0, ng = m;
		while (abs(ng - ok) > 1)
		{
			int mid = (ok + ng) / 2;
			if ((S[mid] & bit) > 0)
			{
				ok = mid;
			}
			else
			{
				ng = mid;
			}
		}
		if (ng >= K)
		{
			m = ng;
		}
	}
	sort(S, S + m, [](ll a, ll b) {return a > b; });
	ll ans = S[0];
	REP(i, K)
	{
		ans &= S[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
require 'pp'

n = gets.chomp!.to_i
pos = []
n.times do |i|
    a, b = gets.chomp!.split(" ").map(&:to_i)
    pos << [a, b]
end

len = 0
x = pos.permutation(n).to_a
x.each do |pos|
    pos.each_cons(2) do |p1, p2|
        len += Math.sqrt((p2[0] - p1[0]) ** 2 + (p2[1] - p1[1]) ** 2)
    end
end

puts len / x.length.to_f


Measured memory_bytes: 8956
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
struct Str{
    ll time,event,place;
    bool operator<(const Str &r){return time!=r.time?time<r.time:event<r.event;}
};

ll n,q,s,t,x,d;
vector<Str>vec;
set<ll>st;

int main(){
    cin>>n>>q;
    rep(i,n){
        cin>>s>>t>>x;
        vec.push_back({s-x,1,x});
        vec.push_back({t-x,-1,x});
    }
    rep(i,q){
        cin>>d;
        vec.push_back({d,2,0});
    }

    sort(vec.begin(),vec.end());

    rep(i,vec.size()){
        if(vec[i].event==1)st.insert(vec[i].place);
        else if(vec[i].event==-1)st.erase(vec[i].place);
        else{
            cout<<(st.empty()?-1:*st.begin())<<endl;
        }
    }
}

Measured memory_bytes: 26728
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=2e5+5;
ll pw[M][2],dp[M];
ll ct;
ll solve(ll x)
{
	if(x==0)
		return 0;
	if(dp[x]!=-1)
		return dp[x];
	ll z=0;
	ll tx=x;
	while(x)
	{
		z+=x%2;
		x/=2;
	}
	return dp[x]=1+solve(tx%z);
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<n;i++)
		if(s[i]=='1')
			ct++;
	// a = x % ct
	// b = x % (ct+1)
	// c = x % (ct-1)
	ll a=0,b=0,c=0;
	if(ct+1)
	{
		pw[0][0]=1;
		for(int i=0;i<n;i++)
		{
			b = (b*2)%(ct+1);
			if(s[i]=='1')
				b = (b+1)%(ct+1);
			if(i)
				pw[i][0] = (pw[i-1][0]*2)%(ct+1);
		}
	}
	if(ct-1>0)
	{
		pw[0][1] = 1;
		for(int i=0;i<n;i++)
		{
			c = (c*2)%(ct-1);
			if(s[i]=='1')
				c = (c+1)%(ct-1);
			if(i)
				pw[i][1] = (pw[i-1][1]*2)%(ct-1);
		}
	}
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	{
		if(s[i]=='0')
		{
			ll z = pw[n-i-1][0];
			ll r = (b+z)%(ct+1);
			cout<<1+solve(r)<<"\n";
		}
		else
		{
			ll z = pw[n-i-1][1];
			if(ct==1)
			{
				cout<<"0\n";
				continue;
			}
			ll r = (c+(ct-1)-z)%(ct-1);
			cout<<1+solve(r)<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 8440
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

n = r()
tens=1
nines=1
eights=1
mod = 10**9+7
for i in range(n):
    tens=(tens*10)%mod
    nines=(nines*9)%mod
    eights=(eights*8)%mod
print((tens-2*nines+eights)%mod)

Measured memory_bytes: 77408
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int K = sc.nextInt();
		
		String s [] = new String[H];
		for(int i=0;i<H;i++) {
				s[i]=sc.next();
		}
		
		int v[][] = new int[H][W];
		for(int[] tmp:v) {
			Arrays.fill(tmp, -1);
		}
		//上段から#がある行がちょうど1つになるように区切る
		List<Integer> Hmemo = new ArrayList<Integer>();
		for(int i=0;i<H;i++) {
			if(s[i].indexOf("#")!=-1) {
				Hmemo.add(i);
			}
		}
		
		//横に見る
		int memo = 0;
		int Hbefore = 0;
		for(int tmp:Hmemo) {
			int Wbefore = 0;
			String str = s[tmp];
			for(int i=0;i<str.length();i++) {
				if(str.charAt(i)=='#') {
					memo++;
					//Hbeforeから、tmpまで、Wbeforeからiまでにmemoを埋める。
					for(int h=Hbefore;h<=tmp;h++) {
						for(int w=Wbefore;w<=i;w++) {
							v[h][w]=memo;
						}
					}	
					Wbefore = i+1;
					continue;
				}
				
				if(i==str.length()-1) {
					for(int h=Hbefore;h<=tmp;h++) {
						for(int w=Wbefore;w<=i;w++) {
							v[h][w]=memo;
						}
					}
				}
			}
			Hbefore = tmp+1;
		}
		if(Hbefore>0) {
		for(int h=Hbefore;h<H;h++) {
			for(int w=0;w<W;w++) {
				v[h][w]=v[h-1][w];
			}
		}
		}
		
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				sb.append(v[i][j]+" ");
			}
			sb.append("\n");
		}
		System.out.println(sb.toString());
	}

}

Measured memory_bytes: 44824
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <sstream>

using namespace std;
using int64 = long long;

int main() {
    int n, k;
    cin >> n >> k;
    set<int> cnt;
    for (int i=0; i<k; i++) {
        int d;
        cin >> d;
        for (int j=0; j<d; j++) {
            int a;
            cin >> a;
            cnt.insert(a);
        }
    }

    cout << n - cnt.size() << endl;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;
const LL INF = 1LL << 55;

vector<vector<LL>> sea, land;
vector<int> z;
int n, m, r;
vector<vector<LL>> dp;

LL dfs(int cur, int ship) {
    LL ret = dp[cur][ship];
    if (ret >= 0) return ret;
    if (cur == r - 1) return 0;
    ret = land[z[cur]][z[cur + 1]] + dfs(cur + 1, ship);
    for (int i = 0; i < n; i++) {
        LL tmp = land[z[cur]][ship] + sea[ship][i] + land[i][z[cur + 1]];
        if (tmp >= INF) continue;
        tmp += dfs(cur + 1, i);
        ret = min(ret, tmp);
    }
    dp[cur][ship] = ret;
    return ret;
}

int main() {
    while (cin >> n >> m, n | m) {
        sea.clear(); land.clear(); z.clear(); dp.clear();
        sea.resize(n, vector<LL>(n, INF));
        land.resize(n, vector<LL>(n, INF));

        for (int i = 0; i < n; i++) {
            sea[i][i] = land[i][i] = 0;
        }

        for (int i = 0; i < m; i++) {
            int tx, ty, tt;
            char tsl;
            cin >> tx >> ty >> tt >> tsl;
            tx--; ty--;
            if (tsl == 'L') {
                land[tx][ty] = tt;
                land[ty][tx] = tt;
            } else {
                sea[tx][ty] = tt;
                sea[ty][tx] = tt;
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    land[j][k] = min(land[j][k], land[j][i] + land[i][k]);
                    sea[j][k] = min(sea[j][k], sea[j][i] + sea[i][k]);
                }
            }
        }

        cin >> r;
        z.resize(r);
        for (int i = 0; i < r; i++) {
            int tz;
            cin >> tz;
            z[i] = tz - 1;
        }
        dp.resize(r, vector<LL>(n, -1));
        cout << dfs(0, z[0]) << endl;
    }

    return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

int main()
{
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<(H-h)*(W-w)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >=0; i--)
#define REP(i,k,n) for(int i=k;i<n;i++)
using namespace std;
typedef long long ll;
#define mp make_pair
#define pi pair<ll,ll>
#define fi first
#define se second
#define pb push_back
const ll inf = 900900900100100100;
vector<pi> Ga[100100];
vector<pi> Gb[100100];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,START,GOAL;
    cin >> n >> m >> START >> GOAL;
    START--;GOAL--;
    rep(i,m){
        int u,v,a,b;
        cin >> u >> v >> a >> b;
        u--;v--;
        Ga[u].pb(mp(a,v));
        Ga[v].pb(mp(a,u));
        Gb[u].pb(mp(b,v));
        Gb[v].pb(mp(b,u));
    }
    //ダイクストラ法
    // G[i] = pair<ll,int> : iが出発地点，G[i].fiがコスト，G[i].seが行き先
    // d[i]                : d[i]がi地点での最小コスト
    priority_queue<pi, vector<pi>, greater<pi>> que;
    vector<ll> da(100100, inf);
    da[START] = 0;
    que.push(mp(0, START));
    while (!que.empty()) {
        pi p = que.top();
        que.pop();
        ll  cost = p.fi;
        int v = p.se;
        if (da[v] < cost) continue;
        rep(i, Ga[v].size()) {
            pi e = Ga[v][i];
            if (da[e.se] > da[v] + e.fi) {
                da[e.se] = da[v] + e.fi;
                que.push(mp(da[e.se], e.se));
            }
        }
    }
    vector<ll> db(100100, inf);
    db[GOAL] = 0;
    que.push(mp(0,GOAL));
    while (!que.empty()) {
        pi p = que.top();
        que.pop();
        ll  cost = p.fi;
        int v = p.se;
        if (db[v] < cost) continue;
        rep(i, Gb[v].size()) {
            pi e = Gb[v][i];
            if (db[e.se] > db[v] + e.fi) {
                db[e.se] = db[v] + e.fi;
                que.push(mp(db[e.se], e.se));
            }
        }
    }
    vector<ll> cc(100100,inf);

    rrep(i,n){
        ll ans = da[i]+db[i];
        cc[i] = min<ll>(cc[i+1],ans);
    }
    rep(i,n){
        cout << 1000000000000000LL-cc[i] << endl;
    }  return 0;
}

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

int main() {
	int N;
	string S;
	cin >> N >> S;
	int x = 0, MAX = 0;
	for (int i = 0; i < N; i++) MAX = max(x += (S[i] == 'I' ? 1 : -1), MAX);
	cout << MAX << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
signed main(){
    gearup;
    ll n,a,b; cin >> n >> a >> b;
    if(a>b){
        out(0);
        return 0;
    }
    else if(n==1 && a != b){
        out(0);
        return 0;
    }
    ll res = (a+b*(n-2)+b) - (a+b+a*(n-2));
    out(res+1);
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

struct Data{
	unsigned long gcd, lcm;
	struct Data* next;
};

int main(){
	struct Data *datalist, *p;
	unsigned long a, b, x, y;
	datalist = (struct Data*)malloc(sizeof(struct Data));
	datalist->next = NULL;
	p = datalist;

	while(scanf("%d %d", &a, &b) != EOF){
		p->next = (struct Data*)malloc(sizeof(struct Data));
		p = p->next; p->next = NULL;
		x = a; y = b;
		while(x != y){
			if(x > y) x -= y;
			else if(x < y) y -= x;
		}
		p->gcd = x;
		p->lcm = a/x*b;
	}

	p = datalist;
	while(p->next != NULL){
		p = p->next;
		printf("%d %d\n", p->gcd, p->lcm);
	}

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int k,t; cin >> k >> t;
  vi a(t); rep(i,t) cin >> a[i];
  
  sort(all(a));
  int s = 0; rep(i,t-1) s += a[i];

  int ans = max(0,a.back()-s-1);
  cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
minf=-10000000000000
x=[[0,0,0] for i in range(n)]
x[0]=[0,0,a[0]]
for i in range(n-1):
    if i%2==0:
        x[i+1]=[max(x[i][0],x[i][1]),x[i][2],x[i][0]+a[i+1]]
    else:
        x[i+1]=[max(x[i][1],x[i][2]),x[i][0]+a[i+1],x[i][1]+a[i+1]]
print(max(x[-1][1],x[-1][2]) if n%2==0 else max(x[-1][0],x[-1][1]))


Measured memory_bytes: 116520
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a))
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    set<ll> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2) puts("Yes");
    else puts("No");
	return 0;
}

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

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;
typedef long long int ll;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> c(26);
    // 一致するアルファベットをカウント
    for (int i = 0; i < N; ++i) {
        c[S[i] - 'a']++;
    }

    ll ans = 1;
    for (int i = 0; i < 26; ++i) {
        ans *= c[i] + 1;
        ans %= MOD;
    }
    ans = (ans + MOD -1) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 220000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
vi dp(1000,-1);
int f(int a){
	if(dp[a]+1)return dp[a];
	return dp[a]=powmod(fact[a],MOD-2,MOD);
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	string a,b;
	cin>>a>>b;
	if(a==b.substr(0,a.size()))yes;
	else no;


}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    ll A;
    string B;
    ll C;
    cin >> A >> B;
    ll tmp=100;
    for(int i=0; i<4; i++){
        if(i==1)continue;
        C+=(B[i]-'0')*tmp;
        tmp/=10;
    }
    cout << (long long) A*C/100LL << endl;
}

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

int ary[10][10];
int dx[20]={0,1,0,-1,0,1,-1,-1,1,2,0,-2,0};
int dy[20]={0,0,1,0,-1,1,1,-1,-1,0,2,0,-2};
int main(){
	int x,y,s;

	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		for(int i=0;i<=s*4;i++){
			if(0<=x+dx[i]&&x+dx[i]<10&&0<=y+dy[i]&&y+dy[i]<10){
				ary[x+dx[i]][y+dy[i]]++;
			}
		}
	}
	int cnt=0,res=0;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			if(ary[i][j]==0) cnt++;
			res=max(res,ary[i][j]);
		}
	}
	cout<<cnt<<endl<<res<<endl;
	return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005 
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
  scanf("%d",&head);
  RI(tail...);
}
using namespace std;
typedef long long LL;
LL in[M];
int main()
{
	LL n, neg_cnt = 0, sum = 0;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> in[i];
		if(in[i] < 0) neg_cnt++, in[i] *= -1;
		sum += in[i];
	}
	sort(in, in+n);
	if(neg_cnt & 1) sum -= (in[0]*2);
	cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024