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

typedef long long               ll;
typedef long double             ld;


#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
}

ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}

void fileio()
{
    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

ll sz(ll n)
{
	ll s=0;
	while(n)
	{
		s++;
		n/=10;
	}
	return s;
}

bool square(ll n)
{
	ll s=sqrt(n);
	return sq(s)==n;
}

int solve()
{
	ll a,b;
	sll2(a,b);
	ll t=sz(b);
	a*=power(10,t);
	a+=b;
	if(square(a)) printf("Yes");
	else printf("No");

	return 0;
}


int main()
{

//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();
}



///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


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

int main() {
    int n; cin >> n;
    double sum = 0.0;
    for (int i = 0; i < n; i++) {
        double x; cin >> x;
        string u; cin >> u;
        if (u == "JPY") {
            sum += x;
        } else {
            sum += x * 380000.0;
        }
    }

    printf("%.10lf\n", sum);
    return 0;
}

Measured memory_bytes: 256
r, c = map(int, input().split())
data = [list(map(int, input().split())) for i in range(r)]
for x in data:
    x.append(sum(x))
    print(' '.join(map(str, x)))
else:
    subdata = [sum(data[i][j] for i in range(r)) for j in range(c)]
    subdata.append(sum(subdata))
    print(' '.join(
        map(str, subdata)
    ))



Measured memory_bytes: 5700
import sys
import numpy as np
# from numba import njit

# @njit(cache=True)
def calcCycle(N,K,P,C,cycleIDs,cycleItemCnts,cycleTotalScores):
	cycleID = 0

	for n in range(N):

		v = n
		currentCycleItemCnt = 0
		currentCycleTotal = 0

		if cycleIDs[v] != -1:
			continue
			# print(currentCycleItemCnt, currentCycleTotal)
		else:
			while True:
				# 全頂点について、属するサイクルを計算する
				currentCycleItemCnt += 1
				currentCycleTotal += C[v]

				v = P[v]
				if v == n:
					# サイクル発見
					cycleIDs[v] = cycleID
					cycleItemCnts[cycleID] = currentCycleItemCnt
					cycleTotalScores[cycleID] = currentCycleTotal
					cycleID += 1
					break

				# 一応、一度サイクルを計算した頂点については、
				# その頂点の属するサイクルの情報をメモっておく。。。
				cycleIDs[v] = cycleID

def upd(P,C,K,v,ans,currentCycleItemCnt,currentCycleTotal):

	# procCnt = 0
	currentCycleSumTmp = 0

	for k in range(min(K,currentCycleItemCnt)):

		# 頂点vにコマが置かれた時の最高スコアを計算し、
		# これまでの最高スコアを上回ったら、これまでの最高スコアを更新する

		procCnt = k+1
		currentCycleSumTmp += C[v]

		cycleLoopCnt = 0
		if 0 < currentCycleTotal:
			cycleLoopCnt = ( K - procCnt ) // currentCycleItemCnt

		# print("v=", v, "currentCycleSumTmp=", currentCycleSumTmp, "procCnt, cycleLoopCnt, currentCycleTotal=", procCnt, cycleLoopCnt, currentCycleTotal)
		ans = max( ans, currentCycleSumTmp + cycleLoopCnt * currentCycleTotal )
		v = P[v]

	return ans





def main(N,K,P,C,cycleIDs,cycleItemCnts,cycleTotalScores):

	ans = -1e18


	for n in range(N):

		v = n
		currentCycleItemCnt, currentCycleTotal = cycleItemCnts[ cycleIDs[v] ], cycleTotalScores[ cycleIDs[v] ]

		ans=upd(P,C,K,v,ans,currentCycleItemCnt,currentCycleTotal)
		# currentCycleSumTmp = 0
		# for k in range(min(K,currentCycleItemCnt)):

		# 	procCnt = k+1
		# 	currentCycleSumTmp += C[v]

		# 	cycleLoopCnt = 0
		# 	if 0 < currentCycleTotal:
		# 		cycleLoopCnt = ( K - procCnt ) // currentCycleItemCnt

		# 	# print("v=", v, "currentCycleSumTmp=", currentCycleSumTmp, "procCnt, cycleLoopCnt, currentCycleTotal=", procCnt, cycleLoopCnt, currentCycleTotal)
		# 	ans = max( ans, currentCycleSumTmp + cycleLoopCnt * currentCycleTotal )
		# 	v = P[v]


	print(int(ans))

if sys.argv[-1]=='ONLINE_JUDGE':
	# from numba import njit
	from numba.pycc import CC
	cc=CC('my_module')
	cc.export('calcCycle','void(i8,i8,i8[:],i8[:],i8[:],i8[:],i8[:])')(calcCycle)
	# cc.export('main','void(i8,i8,i8[:],i8[:],i8[:],i8[:],i8[:])')(main)
	cc.export('upd','i8(i8[:],i8[:],i8,i8,i8,i8,i8)')(upd)
	# cc.export('upd','UniTuple(i8,3)(i8[:],i8[:],i8,i8,i8,i8,i8)')(upd)
	# main=njit(main, cache=True)
	cc.compile()
	exit(0)
from my_module import upd,calcCycle
# from my_module import main,calcCycle
# from my_module import calcCycle



if __name__ == "__main__":
	N,K = map(int,input().split())
	P = np.array( input().split(), np.int64 )
	P -= 1
	C = np.array( input().split(), np.int64 )

	# 一度計算したサイクル情報を一応キャッシュしておく。。。
	# あんまり意味なさそう
	cycleIDs = np.full( N, -1, dtype=np.int64 )
	cycleItemCnts = np.full( N, -1, dtype=np.int64 )
	cycleTotalScores = np.full( N, -1, dtype=np.int64 )

	calcCycle(N,K,P,C,cycleIDs,cycleItemCnts,cycleTotalScores)

	# print(cycleItemCnts)


	main(N,K,P,C,cycleIDs,cycleItemCnts,cycleTotalScores)
	#print(ans)




Measured memory_bytes: 28012
#include<iostream>
//DS
#include<vector>
#include<set>
#include<string>
#include<array>
#include<list>
#include<deque>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
//Algo
#include<algorithm>
//Helper
#include<cmath>
#include<iterator>

using namespace std;

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define repi(i,j,N) for(int (i)=(j);(i)<(N);(i)++)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define ll long long

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;

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

	int a, b; cin >> a >> b;
	cout << (ll)a * b;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
  int n;
  cin >> n;
  Graph g(n+1);

  //有向グラフの入力
  for(int i=0;i<n;i++){
    int u,k;
    cin >> u >> k;
    for(int j=0;j<k;j++){
      int v;
      cin >> v;
      g[u].push_back(v);
    }
  }

  //BFSのためのデータ構造
  vector<int> dist(n+1,-1); //全頂点を"未訪問"に初期化
  queue<int> que;

  //初期条件(頂点1を初期ノードとする)
  dist[1] = 0;
  que.push(1);

  //BFS開始
  while(!que.empty()){
    int v = que.front(); //キューから先頭頂点を取り出す
    que.pop();

    //vから辿れる頂点をすべて調べる
    for(int nv: g[v]){
      if(dist[nv] != -1) continue; //発見済みはスルー

      // 新たな白色頂点nvについて距離情報を更新してキューに追加する
      dist[nv] = dist[v] + 1;
      que.push(nv);
    }
  }

  //結果出力
  for(int v=1;v<=n;v++)
    cout << v << " " << dist[v] << endl;
}


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

int main(){
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    ll cnt=1;
    char prev=s[0];
    ll ans=0;
    for(ll i=1;i<n;i++){
        if(s[i]!=prev){
            cnt++;
        }else{
            ans++;
        }
        prev=s[i];
    }
    if(cnt>=2*k+1){
        cout<<ans+2*k<<endl;
    }else if(cnt==2*k){
        cout<<ans+2*k-1<<endl;
    }else{
        cout<<ans+cnt-1<<endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[20];
ll dfs(int l,int r,int L,int R){
    if(r-l<=1)return 0;
    ll ans=LLONG_MAX;
    for(int i=l+1;i<r;i++)
        ans=min(ans,(L+R)*a[i]+dfs(l,i,L,L+R)+dfs(i,r,L+R,R));
    return ans;
}
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    ll ret=dfs(1,n,1,1);
    cout<<ret+a[1]+a[n]<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>

using namespace std;
typedef long long ll;

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
  
    ll k;
    vector<ll> d;

    ll Q,N;
    string S;
    cin>>S;
    for(i=0;i<S.length();i++){
        if(S[i]-'0'!=i%2){
            ans++;
        }
    }
    for(i=0;i<S.length();i++){
        if(S[i]-'0'!=(i+1)%2){
            anss++;
        }
    }
    

        cout<< min(ans,anss) << endl;

 
}

Measured memory_bytes: 512
n=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
from itertools import permutations
jun = list(permutations(range(1,n+1),n))
ansp=-1
ansq=-1
for a,b in enumerate(jun):
    if b==P:
        ansp=a
    if b==Q:
        ansq=a
print(abs(ansp-ansq))        

Measured memory_bytes: 8052
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

a,b,c = MI()
print(min(c,b//a))

Measured memory_bytes: 12500
def main():
    D, G = map(int, input().split())
    info = [tuple(map(int, input().split())) for _ in range(D)]

    ans = 100 * 10
    for bit in range(1<<D):
        score = 0
        num_problem = 0

        # complete bonus
        for i in range(D):
            if (bit>>i) & 1:
                base = 100 * (i+1)
                score += base * info[i][0] + info[i][1]
                num_problem += info[i][0]
        # other 
        for i in range(D-1, -1, -1):
            if score >= G:
                break
            
            if not((bit>>i) & 1):
                base = 100 * (i+1)
                rest = G - score
                need = (rest + base - 1) // base

                if need > info[i][0] - 1:
                    score += base * (info[i][0] - 1)
                    num_problem += (info[i][0] - 1)
                else:
                    score += base * need
                    num_problem += need
                    break
        
        if score >= G:
            ans = min(ans, num_problem)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);




ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}


#define comuse Comuse()

ll combi(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;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


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


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}


ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}



/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //ll N=262144;
  //vll segtree(2*N-1);
  ll x,y;
    cin>>x>>y;
  if(x%y==0){
    cout<<"-1\n";
  }
  else{
    cout<<x<<"\n";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)

int main(){
    ll n;
    std::cin >> n;
    std::vector<ll> a(n);
    rep(i,n){
        std::cin >> a[i];
    }
    ll sum=0;
    for(int i=0;i<n-1;++i){
        for(int j=i+1;j<n;++j){
            if(a[i]>a[j]){
                sum+=a[i]-a[j];
                a[j]+=a[i]-a[j];
            }else{
                break;
            }
        }
    }
    std::cout << sum << std::endl;
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;

char s[15];
int len, a[15];
LL f[15], sum;

void dfs(int x, int cnt){
	if(x >= len){
		int pos = cnt;
		int now = 0; pos--;
		for(int i = len; i >= 1; i --){
			if(i == a[pos]) now = 0, pos--;
			sum += (s[i] - '0') * f[now];
			now++;
		}
		return;
	}
	for(int i = x + 1; i <= len; i ++){
		a[cnt] = x;
		dfs(i, cnt + 1);
	}
}

int main()
{
	f[0] = 1;
	for(int i = 1; i <= 10; i ++) f[i] = f[i - 1] * 10;
	scanf(" %s", s + 1);
	len = strlen(s + 1);
	dfs(0, 0);
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;

int main()
{
  lint n, k;
  cin >> n >> k;
  vector<lint> a(n);
  REP(i,n){
    lint tmp;
    cin >> tmp;
    tmp--;
    a[i] = tmp;
  }

  vector<lint> seen(n, false);
  vector<lint> way;
  lint next = 0;
  while(!seen[next]){
    seen[next] = true;
    way.push_back(next);
    next = a[next];
  }

  auto itr = find(ALL(way), next);
  lint loop_begin = distance(way.begin(), itr);
  lint loop_size = way.size() - loop_begin;
  lint res;
  if(k <= loop_begin) res = way[k];
  else{
    k -= loop_begin;
    k %= loop_size;
    res = way[loop_begin+k];
  }

  //cout << loop_begin << " " << loop_size << "\n";
  cout << res+1 << "\n";
  return 0;
}


Measured memory_bytes: 8440
N, M = map(int, input().split())
H = list(map(int, input().split()))

a = [set() for _ in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    a[A-1].add(B)
    a[B-1].add(A)

ans = 0

for i in range(N):
    flag = 0
    if a[i] == set():
        ans += 1
    else:
        for j in a[i]:
            if H[j-1] >= H[i]:
                flag = 1
                break

        if flag == 0:
            ans += 1

print(ans)


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

// 300, 5min

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

int N, A, B;

int main()
{
    cin >> N >> A >> B;
    if((B - A) % 2 == 0) {
        printf("Alice\n");
    } else {
        printf("Borys\n");
    }
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 13.06.2020 15:12:10       
**/
#include <bits/stdc++.h>

using namespace std;

long long Solve(int w, int h, int k) {
  k = 2 * k - 2;
  long long ans = 0;
  for (int x = 1; x < w; x++) {
    for (int y0 = 1; y0 < h; y0++) {
      int a = (w - x) * y0 - __gcd(x, y0);
      if (a > k + 2 * w) {
        break;
      }
      // a + x * y1 <= k?
      // y1 <= (k - a) / x
      int bound = min(h - 1, max(0, (k - a) / x));
      ans += bound;
      for (int y1 = bound + 1; y1 < h; y1++) {
        int b = a + x * y1;
        if (b > k + 2 * w) {
          break;
        }
        int c = b - __gcd(w - x, y1) - __gcd(w, abs(y0 - y1));
        if (c <= k) {
          ans += 1;
        }
      }
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int w, h, k;
  cin >> w >> h >> k;
  cout << 2 * (Solve(w, h, k) + Solve(h, w, k)) << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#define INF 0x3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=2000;
const int mod=1e9+7;
int dp[maxn];
int main()
{
    //cout<<pow_mod(1,100);
    int n;
    cin>>n;
    dp[0]=1;
    for(int i=3;i<=maxn;++i)
        for(int j=0;j<=i-3;++j)
        dp[i]=(dp[i]+dp[j])%mod;
    cout<<dp[n]<<endl;
    return 0;
}


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

using namespace std;

#define MAX_V 23456
#define INF (1<<29)

struct edge {
    int to, cap, rev;
    edge (int to, int cap, int rev) :
        to(to), cap(cap), rev(rev) {}
};

vector<edge> G[MAX_V];
int level[MAX_V], iter[MAX_V];

void add_edge(int from, int to, int cap)
{
    G[from].push_back(edge(to, cap, G[to].size()));
    G[to].push_back(edge(from, 0, G[from].size()-1));
}

void bfs(int s)
{
    memset(level, -1, sizeof(level));
    queue<int> Q;
    level[s] = 0;
    Q.push(s);
    while (!Q.empty()) {
	int v = Q.front(); Q.pop();
	for (int i = 0; i < (int)G[v].size(); i++) {
	    edge &e = G[v][i];
	    if (e.cap > 0 && level[e.to] < 0) {
		level[e.to] = level[v] + 1;
		Q.push(e.to);
	    }
	}
    }
}

int dfs(int v, int t, int f)
{
    if (v == t) return f;
    for (int &i = iter[v]; i < (int)G[v].size(); i++) {
	edge &e = G[v][i];
	if (e.cap > 0 && level[v] < level[e.to]) {
	    int d = dfs(e.to, t, min(f, e.cap));
	    if (d > 0) {
		e.cap -= d;
		G[e.to][e.rev].cap += d;
		return d;
	    }
	}
    }
    return 0;
}

int max_flow(int s, int t)
{
    int flow = 0;
    for (;;) {
	bfs(s);
	if (level[t] < 0) return flow;
	memset(iter, 0, sizeof(iter));
	int f;
	while ((f = dfs(s, t, INF)) > 0) {
	    flow += f;
	}
    }
}

bool is_outside(int x, int y, int W, int H)
{
    return (x == 0 || x == W - 1 || y == 0 || y == H - 1);
}

int solve(int H, int W,
          vector<vector<char>> &S)
{
    int src = 2 * H * W, sink = src + 1;
    const int di[] = {-1, +0, +1, +0};
    const int dj[] = {+0, -1, +0, +1};
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int u = i * W + j, v = H * W + u;
            
            if (S[i][j] == 'X') {
                if (is_outside(j, i, W, H)) {
                    return -1;
                }
                add_edge(src, u, INF);
                add_edge(u, v, INF);
            } else {
                add_edge(u, v, 1);
            }

            if (is_outside(j, i, W, H)) {
                add_edge(v, sink, INF);                
            }
            
            for (int k = 0; k < 4; k++) {
                int ni = i + di[k];
                int nj = j + dj[k];
                if (0 <= ni && ni < H && 0 <= nj && nj < W) {
                    add_edge(v, ni * W + nj, INF);
                }
            }
        }
    }
    return max_flow(src, sink);
}

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }
    cout << solve(H, W, S) << endl;
    return 0;
}


Measured memory_bytes: 3072
/*
g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
./main.exe
*/

#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <climits>
//intの最大値: INT_MAX
//longの最大値: LONG_MAX
//long longの最大値: LLONG_MAX
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <queue>
#include <stack>
#include <tuple>
//最大公約数: gcd()
//最小公倍数: lcm()

#define ll long long int

using namespace std;

template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::less<T>());
    return;
}

template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::greater<T>());
    return;
}

//------------------------------------------------------------------------------

int main(){
	int n;
	scanf("%d", &n);

	n %= 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) printf("hon\n");
	else if(n == 0 || n == 1 || n == 6 || n == 8) printf("pon\n");
	else printf("bon\n");
	return 0;
}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    cin >> n;
    vi a(n);
    fo(i, n) cin >> a[i];

    pii maior = {0, 0};
    int ssmaior = 0;
    fo(i, n) {
        if ( a[i] >= maior.ff ) {
            maior.ff = a[i];
            maior.ss = i;
        }
    }
    fo(i, n) {
        if ( i == maior.ss ) continue;
        ssmaior = max(a[i], ssmaior);
    }

    fo(i, n) {
        if ( i == maior.ss ) cout << ssmaior << endl;
        else cout << maior.ff << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

int main() {
    int n;
    cin >> n;
    string _357 = "357";
    if (n < 357) {
        cout << 0 << endl;
    } else {
        vector<int> nums = {357, 375, 537, 573, 735, 753};
        nums.reserve(30000);
//        vector<int> tmp = {357, 375, 537, 573, 735, 753};
        vector<set<string>> tmp(10);
        tmp[3] = {"357", "375", "537", "573", "735", "753"};
        for (int i = 4; i < 10; ++i) {
            for (auto& x : tmp[i - 1]) {
                for (int j = 0; j < x.length(); ++j) {
                    string t = x;
                    t.insert(j, "3");
//                    cout << t << endl;
                    tmp[i].insert(t);
                }
                tmp[i].insert(x + "3");
                for (int j = 0; j < x.length(); ++j) {
                    string t = x;
                    t.insert(j, "5");
                    tmp[i].insert(t);
                }
                tmp[i].insert(x + "5");
                for (int j = 0; j < x.length(); ++j) {
                    string t = x;
                    t.insert(j, "7");
                    tmp[i].insert(t);
                }
                tmp[i].insert(x + "7");
            }
        }
        for (int i = 4; i < 10; ++i) {
            for (auto& s : tmp[i]) {
                nums.push_back(stoi(s));
            }
        }
        sort(nums.begin(), nums.end());
//        for (auto x : nums) {
//            cout << x << endl;
//        }
//        vector<int> cnt;
//        for (int i = 357; i < 1e9; ++i) {
//            if (i & 1 == 0) continue;
//            string s = to_string(i);
//            if (s.find_first_not_of("357") != s.npos) continue;
//            if (s.find('3') == s.npos || s.find('5') == s.npos || s.find('7') == s.npos) continue;
//            cnt.push_back(i);
//        }
//        cout << cnt.size() << endl;
//        sort(cnt.begin(), cnt.end());
//        for (int i = 0; i < cnt.size(); ++i) {
//            if (cnt[i] != nums[i]) {
//                cout << cnt[i] << endl;
//            }
//        }
        for (int i = 0; i < nums.size(); ++i) {
            if (nums[i] > n) {
                cout << i << endl;
                return 0;
            }
        }
        cout << nums.size() << endl;
    }
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 2816
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
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; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    in >> N;
    ll tmp;
    if(N/100==7 || N%10 == 7 || (N/10)%10==7){
        out << "Yes" << endl;
    }else{
        out << "No" << endl;
    }

    

    
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> x(m), dx(m-1);
  for (int i = 0; i < m; i++) cin >> x.at(i);
  sort(x.begin(), x.end());
  for (int i = 0; i < m-1; i++) dx.at(i) = x.at(i+1) - x.at(i);
  sort(dx.begin(), dx.end());
  int move = 0;
  for (int i = 0; i < m - n; i++) move += dx.at(i);
  cout << move << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  for(ll i=n;i<=999;++i) {
    string s=to_string(i);
    if(s[0]==s[1]&&s[1]==s[2]) {
      ans=i;break;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : a
// Date        : Mon Apr  8 20:49:17 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define x first
#define y second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define output(v) cout << (v) << '\n'
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define jam(x, n) cout << "Case #" << x << ": " << n << "\n"
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"
template<class T> inline void amin(T &x, const T &y) { if (y < x) x = y; }
template<class T> inline void amax(T &x, const T &y) { if (x < y) x = y; }

#ifndef _has_trace
#define trace(...)
#define dbstream ostream
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

void solve() {
  vi a(5);
  for (int i = 0; i < 5; ++i) {
    cin >> a[i];
  }
  int k; cin >> k;
  trace(a, k);
  bool ok = 0;
  for (int i = 0; i < 5; ++i) {
    for (int j = i + 1; j < 5; ++j) {
      if (abs(a[i] - a[j]) > k) {
        ok = 1;
        break;
      }
    }
  }
  output(ok ? ":(" : "Yay!");
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}



Measured memory_bytes: 256
n,k = map(int, input().split())
s = input()

prev = s[0]
cnt = 0
hoge = []
for i in range(n):
    if s[i] == prev:
        cnt += 1
    else:
        hoge.append((cnt, prev))
        cnt = 1
        prev = s[i]
hoge.append((cnt, prev))
#print(hoge)
m = len(hoge)
# 必要なのはこれで十分
k = min(k, m//2)
# oxoxo oxoxox xを回せば良い
ans = []
for i, (cnt, si) in enumerate(hoge):
    if i % 2 == 1 and (i+1)//2 <= k:
        if si=="L":
            ans += ["R"]*cnt
        else:
            ans += ["L"]*cnt
    else:
        ans += [si]*cnt

#print(ans)
ret = 0
for i in range(n):
    if ans[i] == "L" and i-1>=0 and ans[i-1] == "L":
        ret += 1
    elif ans[i] == "R" and i+1<n and ans[i+1] == "R":
        ret += 1
print(ret)

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

int main()
{
	string str;
	int command_no;
	cin >> str;
	cin >> command_no;
	
	for (int i = 0; i < command_no; i++)
	{
		string command;
		int arg0, arg1;
		
		cin >> command;
		cin >> arg0 >> arg1;

		if (command == "print")
		{
			string text;
			for(int c = arg0; c <= arg1; c++)
			{
				text += str[c];
			}
			cout << text << endl;
		}
		else if(command == "reverse")
		{
			string text = str;
			for(int c = arg0; c <= arg1; c++)
			{
				text[c] = str[arg1 - c + arg0];
			}
			str = text;
		}
		else if(command == "replace")
		{
			string arg2;
			cin >> arg2;
			string text = str;
			for(int c = arg0; c <= arg1; c++)
			{
				text[c] = arg2[c - arg0];
			}
			str = text;
		}
	}

}


Measured memory_bytes: 3212
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

//#define YA

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cerr << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

const int maxn = (int)2e5 + 5;

vector <int> a[maxn];
int t[maxn][2];
int fl_yes = 0;
int n, m;
string s;

void dfs(int v, int z) {
    if (fl_yes)
        return;
    if (t[v][z] == -1) {
        fl_yes = 1;
        return;
    }
    if (t[v][z])
        return;
    t[v][z] = -1;
    for (int to: a[v]) {
        if ((z == 0 && s[to] != s[v]) || (z == 1 && s[to] == s[v]))
            continue;
        dfs(to, z ^ 1);
    }
    t[v][z] = 1;
}

void solve(bool __attribute__((unused)) read) {
	cin >> n >> m;
    cin >> s;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y; --x; --y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    memset(t, 0, sizeof t);
    for (int i = 0; i < n; ++i) {
        dfs(i, 0);
        dfs(i, 1);
    }
    if (fl_yes) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 22736
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int H, W, K;
    cin >> H >> W >> K;
    vector<string> grid(H);
    for (int i = 0; i < H; i++)
        cin >> grid[i];

    int res = (1<<30);

    for (int msk = 0; msk < (1<<(H-1)); msk++) {
        int parts = __builtin_popcount((unsigned int)msk) + 1;

        vector<int> cur(parts);

        int ans = parts - 1;

        //cerr << "?\n";

        for (int c = 0; c < W; c++) {
            vector<int> A(parts);
            int id = 0;
            for (int r = 0; r < H; r++) {
                if (r && (msk >> (r-1) & 1)) {
                    id++;
                }
                A[id] += grid[r][c] == '1';
            }

            bool reset = false;

            for (int i = 0; i < parts; i++) {
                if (cur[i] + A[i] > K) {
                    reset = true;
                }
            }

            if (!c && reset)
                goto END_ITER;

            ans += reset;

            for (int i = 0; i < parts; i++) {
                if (reset)
                    cur[i] = 0;
                cur[i] += A[i];
            }
        }

        // Solution found
        res = min(res, ans);

        END_ITER:;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define in(n) scanf("%d",&a);
#define out(n) printf("%d\n",a);
#define SIZE 100001
#define INF INT_MAX
#define F first
#define S second

using namespace std;



int main()
{
    FAST_READ;
    string a,b;
    char t;
    int l;
    cin>>a>>b;
    l = a.length();
    if (a == b) {
        cout<<"Yes"<<endl;
        return 0;
    }
    for (int i = 1;i<=l;i++) {
        t = a[l - 1];
        a = t + a;
        a.erase(a.begin() + l);
        if (a == b) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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

int main(){
  int n;
  //while(1){
    cin >> n;
    int x[100] = {0}, y[100] = {0};
    for ( int i = 0; i < n; i++ ) cin >> x[i];
    for ( int i = 0; i < n; i++ ) cin >> y[i];
    double Dxy = 0;
    for ( int p = 1; p <= 3; p++) {
      double dxy = 0;
      for ( int i = 0; i < n; i++ ) dxy += pow( fabs(x[i] - y[i]), p);
      Dxy = pow( dxy, 1.0/p);
      printf ("%lf\n", Dxy);
    }
    Dxy = 0;
    for ( int i = 0; i < n; i++ ) {
      Dxy = max(Dxy, fabs(x[i]-y[i]) );
    }
    printf ("%lf\n", Dxy);
    
    return 0;
 }


Measured memory_bytes: 3364
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	string s;
	cin >> s;
	int N = s.size();
	int a = 0;	
	int b = 0;
	string k = "01";
	for (int i = 0; i < s.size(); i = i + 2) {
		if (s[i] == k[1]) {
			a++;
		}
	}
	for (int i = 1; i < s.size(); i = i + 2) {
		if (s[i] == k[0]) {
			a++;
		}
	}
	for (int i = 0; i < s.size(); i = i + 2) {
		if (s[i] == k[0]) {
			b++;
		}
	}
	for (int i = 1; i < s.size(); i = i + 2) {
		if (s[i] == k[1]) {
			b++;
		}
	}
	cout << min(a, b);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=2005;
int n,k,f[2][maxn][2][2],fac[maxn];
const int mod=924844033;
inline void add(int &x,int y){
	x=((x+y)>=mod?(x+y-mod):(x+y));
}
int main(){
	f[0][0][1][0]=1;
	read(n);read(k);
	int st=0,ed=1;
	fac[0]=1;
	rep(i,1,2000)fac[i]=1ll*fac[i-1]*i%mod;
	rep(x,1,k){
		for(int j=x;j<=n;j+=k){
			memset(f[ed],0,sizeof(f[ed]));
			rep(i,0,n){
				if(j+k>n){
					rep(v1,0,1)rep(v2,0,1)if(f[st][i][v1][v2]){
						add(f[ed][i][1][0],f[st][i][v1][v2]);
						if(v1==0)
							add(f[ed][i+1][1][0],f[st][i][v1][v2]);
					}
					continue;
				}
				rep(v1,0,1)rep(v2,0,1)if(f[st][i][v1][v2]){
					add(f[ed][i][v2][0],f[st][i][v1][v2]);
					if(v1==0)
						add(f[ed][i+1][v2][0],f[st][i][v1][v2]);
					add(f[ed][i+1][v2][1],f[st][i][v1][v2]);
				}
			}
			swap(st,ed);
		}
	}
	int ans=0;
	rep(i,0,n){
		int res=(f[st][i][0][0]+f[st][i][0][1]+f[st][i][1][0]+f[st][i][1][1])%mod;
		res=1ll*res*fac[n-i]%mod;
		if(i&1)
			ans=(ans-res+mod)%mod;
		else
			ans=(ans+res)%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/

void build(){

}
LL n , a , b;
void init(){
  n = getint();
  a = getint();
  b = getint();
}
void solve(){
  if( a > b or ( n == 1 and a != b ) ){
    puts( "0" );
    Bye;
  }
  LL lft = ( n - 1 ) * a + b;
  LL rgt = ( n - 1 ) * b + a;
  printf( "%lld\n" , rgt - lft + 1 );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' && ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
struct Node { int a, b, c, id; } t[MAXN];
struct Edges { int to, next; } e[MAXN * 2];
vector <int> G[MAXN];
int head[MAXN], tot;
int fa[MAXN];
int vis[MAXN], sum[MAXN], f[MAXN];

inline void addedge(int from, int to) {
  e[++tot] = (Edges){to, head[from]};
  head[from] = tot;
  e[++tot] = (Edges){from, head[to]};
  head[to] = tot;
}
inline void Addedge(int from, int to) {
  G[from].push_back(to);
  G[to].push_back(from);
}

int Find(int x) { return fa[x] == x ? x : fa[x] = Find(fa[x]); }
inline bool cmp(Node x, Node y) { return x.c < y.c; }
inline bool cmpp(Node x, Node y) { return x.id < y.id; }

void Dfs(int now, int fa) {
  sum[now] = t[now].b;
  for (auto i : G[now])
    if (i != fa)
      Dfs(i, now), sum[now] += sum[i];
  f[now] = sum[now] + t[now].c;
  for (auto i : G[now])
    if (i != fa)
      f[now] = min(f[now], sum[now] - sum[i] + max(f[i], t[now].c));
}

signed main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; read(n), read(m);
  for (RI i = 1; i <= n; ++i)
    read(t[i].a), read(t[i].b), t[i].c = max(t[i].a - t[i].b, 0ll), t[i].id = i;
  sort(t + 1, t + 1 + n, cmp);
  for (RI i = 1, x, y; i <= m; ++i)
    read(x), read(y), addedge(x, y);
  for (RI i = 1; i <= n; ++i) fa[i] = i;
  for (RI i = 1; i <= n; ++i) {
    vis[t[i].id] = 1;
    for (RI j = head[t[i].id]; j; j = e[j].next)
      if (vis[e[j].to]) {
        int ft = Find(e[j].to);
        if (t[i].id != ft) {
          fa[ft] = t[i].id;
          Addedge(t[i].id, ft);
        }
      }
  }
  int root = t[n].id;
  sort(t + 1, t + 1 + n, cmpp);
  Dfs(root, 0);
  printf("%lld\n", f[root]);

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 22528
//Header files
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

//Short data-types declaration
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vii;  
typedef vector<vector<long long> >vll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;

//Macros
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
#define rep(i,start,end) for(int i=(int)start;i<(int)end;i++)

void solve()
{
	ll n;
	cin>>n;
	string ans="";
	while(n>0)
	{
		int c=(n%26)-1;
		if(c==-1)
			c=25;
		ans=char(c+'a')+ans;
		if(c==25)
			n=n/26-1;
		else n/=26;
	}
	cout<<ans<<endl;


}
int main()
{
	auto start = high_resolution_clock::now();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t=1;
	while(t--)
		solve();
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start); 
	cerr<<duration.count()<<" microseconds\n";
	return 0;
}


Measured memory_bytes: 3672
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		int T = Integer.parseInt(sc.next());
		for(int tr=0; tr<T; tr++){
			char[] X = sc.next().toCharArray();
			char[] Y = sc.next().toCharArray();
			int X_len = X.length;
			int Y_len = Y.length;
			int[][] dp = new int[X_len+1][Y_len+1];
			
			for(int x=0; x<X_len; x++){
				for(int y=0; y<Y_len; y++){
					if(X[x] == Y[y]){
						dp[x+1][y+1] = dp[x][y]+1;
					}else{
						dp[x+1][y+1] = Math.max(dp[x+1][y],dp[x][y+1]);
					}
				}
			}
			System.out.println(dp[X_len][Y_len]);
		}
		sc.close();
	}
	
	
	
}


Measured memory_bytes: 63992
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll N,K,cnt=0;
    string S;
    pair<ll,ll> P;
    P.first=1;
    P.second=0;
    cin>>N>>K>>S;
    vector<pair<ll,ll>> v;
    if(S[0]=='0') v.push_back(P);
    for(ll i=0;i<N;i++){
        pair<ll,ll> p;
        ll cnt=1;
        if(S[i]=='0'){
            while(i+1<N&&S[i+1]=='0'){
                cnt++;
                i++;
            }
            p.first=0;
            p.second=cnt;
        }else{
            while(i+1<N&&S[i+1]=='1'){
                cnt++;
                i++;
            }
            p.first=1;
            p.second=cnt;
        }
        v.push_back(p);
    }
    
    if(v[v.size()-1].first==0) v.push_back(P);

    for(ll i=1;i<v.size();i++) v[i].second+=v[i-1].second;
    if(v.size()<K*2){
        cout<<v[v.size()-1].second<<endl;
        return 0;
    }
    ll ans=v[K*2].second;
    for(ll i=K*2+2;i<v.size();i+=2){
        chmax(ans,v[i].second-v[i-K*2-1].second);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2548
#include<iostream>

using namespace std;

int main() {
    int H, M, S;
    cin >> S;

    H = S / 3600;
    S = S- (H * 3600);
    M = S / 60;
    S = S - (M * 60);

        cout << H << ":" << M << ":" << S << endl;
}


Measured memory_bytes: 3076
N = int(raw_input())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
low = [1] * N
high = [float('inf')] * N
for i in xrange(N):
    high[i] = min(high[i], a[i])
    if i == 0 or a[i] > a[i-1]:
        low[i] = max(low[i], a[i])
for i in xrange(N):
    high[i] = min(high[i], b[i])
    if i == N-1 or b[i] > b[i+1]:
        low[i] = max(low[i], b[i])
M = 10**9+7
ans = 1
for lo, hi in zip(low, high):
    ans = (ans * max(0, hi - lo + 1)) % M
print ans % M


Measured memory_bytes: 18440