akhauriyash/Code-Regression huggingface dataset:
function bubbleSort(list) {
  let flag = true;
  let i = 0;
  while (flag) {
    flag = false;
    for (let j = list.length - 1; j >= i + 1; j--) {
      if (list[j - 1][1] > list[j][1]) {
        let a = list[j - 1];
        let b = list[j];
        list[j - 1] = b;
        list[j] = a;
        flag = true;
      }
    }
    i++;
  }
  return list;
}

function selectionSort(list) {
  for (i = 0; list.length - 1 > i; i++) {
    let minj = i;
    for (j = i; list.length > j; j++) {
      if (list[minj][1] > list[j][1]) {
        minj = j;
      }
    }
    if (i != minj) {
      const a = list[i];
      const b = list[minj];
      list[minj] = a;
      list[i] = b;
    }
  }
  return list;
}

function createMap(list) {
  const alphabet = list.map(x => x[0]);
  const num = list.map(x => x[1]);

  const m = [];
  for (i = 0; list.length > i; i++) {
    m.push([alphabet[i], num[i]])
  }
  return m;
}

const listA = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n")[1].split(' ');
const listB = JSON.parse(JSON.stringify(listA));


const bubbleSortResult = bubbleSort(createMap(listA)).map(x => `${x[0]}${x[1]}`).join(" ");
console.log(bubbleSortResult);
console.log('Stable');

const selectionSortResult = selectionSort(createMap(listB)).map(x => `${x[0]}${x[1]}`).join(" ");
console.log(selectionSortResult);
console.log(bubbleSortResult === selectionSortResult ? "Stable" : "Not stable");



Measured memory_bytes: 15196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
ll divisor(ll a,ll b){
  if(a % b == 0)return b;
  ll acopy = 0;
  acopy = a;
  a = b;
  b = acopy % b;
  divisor(a,b);
}
int main(){
  ll n,m;
  string s,t;
  cin >> n >> m >> s >> t;
  ll koubai = 0;
  koubai = n / divisor(n,m) * m;
  ll checkn = 0;
  checkn = koubai / m;
  ll checkm = 0;
  checkm = koubai / n;
  bool can = true;
  for(int i = 0;i <= n / checkn - 1;i++){
    if(s[checkn * i] != t[checkm * i])can = false;
  }
  if(can)cout << koubai << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int x[5];
  REP(i,5)cin>>x[i];
  REP(i,5)if(x[i]==0)cout<<i+1<<endl;
  return 0;
}


Measured memory_bytes: 3584
#include<iostream>
int main()
{
	int a;
	int b;
	std::cin >> a;
	std::cin >> b;
	if (a < b) {
		std::cout << "a < b" << std::endl;
	}
	else if (a>b){
		std::cout << "a > b" << std::endl;
	}

        else if (a==b){
                std::cout<<"a == b"<<std::endl;
}
 	
}



Measured memory_bytes: 3120
#include<stdio.h>
#include <stdlib.h>
int main(){
  int n,a[500000],i;
  long long ans,m,sum=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  m=ans=2*a[1]-sum;
  ans=llabs(ans);
  for(i=2;i<n;i++){
    m+=2*a[i];
    if(m>=0){
      if(m<ans)ans=m;
    }else{
      if(ans>0-m)ans=0-m;
    }
  }
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100003;
int n,cnt[MaxN],ans;

int main() {
    scanf("%d",&n);
    for (int i=1;i<=n;++i) {
        int x;
        scanf("%d",&x);
        cnt[x]++;
    }
    ans=0;
    for (int i=1;i<=100000;++i) {
        ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int ans = 0;
		for(int i = 0;i < N;i++) {
			int a = scn.nextInt();
			boolean prime = true;
			for(int j = 2;j <= Math.sqrt(a);j++) {
				if(a % j == 0) {
					prime = false;
					break;
				}
			}
			if(prime)ans++;
		}
		System.out.println(ans);
	}

}



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

int memo[100];

int fib(int n){
	if(memo[n])return memo[n];

	memo[n]=fib(n-1)+fib(n-2);
	return memo[n];
}

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

	memo[0]=memo[1]=1;
	cout<<fib(n)<<endl;

	return 0;
}



Measured memory_bytes: 3104
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

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

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	ll a;
	long double b;
	cin >> a >> b;
	cout << static_cast<ll>(a * b) << endl;
	return 0;
}


Measured memory_bytes: 3748
A = int(input())
B = int(input())
C = int(input())
X = int(input())

result = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if a * 500 + b * 100 + c * 50 == X:
                result += 1

print(result)


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

typedef long long ll;

const int N = 105;
const int W = 100005;
const int M = 1e9 + 7;

int n, w;

ll dp[N][W], p[N], v[N];

ll calc(int i, int j) {
    if(i == n) return 0;

    ll &r = dp[i][j];

    if(r != -1) return r;

    ll res = calc(i + 1, j);

    if(j >= p[i]) res = max(res, v[i] + calc(i + 1, j - p[i]));

    return r = res;
}
int main() {
    cin >> n >> w;
    fore(i, 0, n) cin >> p[i] >> v[i];
    memset(dp, -1, sizeof dp);
    cout << calc(0, w) << endl;
    return 0;
}

Measured memory_bytes: 82304
# -*- coding: utf-8 -*-


def main():
    from collections import Counter
    s = sorted(Counter(list(input())).items(), key=lambda x: x[0])
    t = sorted(Counter(list(input())).items(), key=lambda x: x[0])
    diff_s = [0] * 26
    diff_t = [0] * 26
    alphabets = [chr(ord('a') + i) for i in range(26)]

    if len(s) == len(t):
        for alpha, count in s:
            if alpha in alphabets:
                diff_s[alphabets.index(alpha)] = count

        for alpha, count in t:
            if alpha in alphabets:
                diff_t[alphabets.index(alpha)] = count

        for si, ti in zip(sorted(diff_s), sorted(diff_t)):
            if si != ti:
                print('No')
                exit()

        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 5516
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int t[n],a[n];
  rep(i,n) cin>>t[i];
  rep(i,n) cin>>a[i];
  int ans=1;
  PII b[n];
  rep(i,n) b[i]={0,0};
  int prev=-1;
  
  rep(i,n){
    if(prev!=t[i]){
      b[i]={t[i],t[i]};
    }else{
      b[i]={t[i],(int)1};
    }
    prev=t[i];
  }
  prev=-1;
  
  repn(i,n-1){
    if(prev!=a[i]){
      if(b[i].F < a[i]){
	cout<<0<<endl;
	return 0;
      }else if(b[i].F == b[i].S && b[i].F != a[i]){
		cout<<0<<endl;
	return 0;
      }
      else{
	b[i]={a[i],a[i]};
      }
    }else{
      b[i]={min(a[i],b[i].F),max((int)1,b[i].S)};
    }
    prev=a[i];
  }
  
  rep(i,n){
    //cout<<b[i].F<<" "<<b[i].S<<endl;
    int num=b[i].F-b[i].S;
    num++;
    num%=MOD;
    ans=ans*num%MOD;
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 6664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <queue>

using namespace std;

typedef long long LL;

const int N = 1e5+5;
const int P = 998244353;

const int INF = 0x3f3f3f3f;
const LL INFLL = 0x3f3f3f3f3f3f3f3f;

int n, m;
char c[105];
int vis[256], cnt;

vector <int> V, Vc;

inline void init() {
    scanf("%s", c);
    n = strlen(c);
    cin >> m;
    for(int i = 0; i < n; i++) {
        if(vis[c[i] - 'a'] == 0) cnt++;
        vis[c[i] - 'a'] = 1;
    }
    if(cnt == 1) {
        LL len = (LL) n * m;
        cout << len / 2 << endl;
        return ;
    }
    int cur = 1;
    for(int i = 0; i < n; i++) {
        if(c[i] == c[i + 1]) cur++;
        else {
            V.push_back(cur);
            Vc.push_back(c[i] - 'a');
            cur = 1;
        }
    }
    LL ans = 0;
    int len = V.size();
    if(Vc[0] == Vc[len - 1]) {
        ans += V[0] / 2;
        ans += V[len - 1] / 2;
        ans += (LL)(V[0] + V[len - 1]) / 2 * (m - 1);
    }
    else {
        ans += (LL)V[0] / 2 * m;
        ans += (LL)V[len - 1] / 2 * m;
    }
    len--;
    for(int i = 1; i < len; i++) {
        ans += (LL)V[i] / 2 * m;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{

	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int m, n;
		m = in.nextInt();
		n = in.nextInt();
		if (m < n)
			System.out.println("a < b");
		else if (m == n)
			System.out.println("a == b");
		else
		{
			System.out.println("a > b");
		}

	}

}

Measured memory_bytes: 26316
a, b, c, d = map(int, input().split())
ans = b - a + 1

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def calc(d):
    global a, b
    c1 = (a - 1) // d
    c2 = b // d
    return c2 - c1

lcm = c * d // gcd(c, d)
print(ans - calc(c) - calc(d) + calc(lcm))


Measured memory_bytes: 2940
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

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

const int N = (int) 1e6 + 7;
const int MOD = (int) 1e9 + 7;

bool ask(int n) {
  cout << "? " << n << endl;
  string ch;
  cin >> ch;
  return ch == "Y";
}

bool ask_st(string s) {
  cout << "? " << s << endl;
  string ch;
  cin >> ch;
  return ch == "Y";
}

int main() {
  #ifdef LOCAL
  freopen("in.txt", "r", stdin);
  #endif

  int len = 1;
  bool flag = 0;
  for (long long i = 10; i <= 10000000000ll; i = i * 10) {
    if (!ask(i)) {
      flag = 1;
      break;
    }
    len++;
  }
  if (!flag) {
    for (long long i = 1; i <= 10000000000ll; i = i * 10) {
      if (ask(i + 1)) {
        cout << "! " << i << endl;
        return 0;
      }
    }
  } else {
    string prefix = "";
    for (int i = 1; i <= len; i++) {
      int l = (i == 1), r = 9;
      int pos = -1;
      while (l <= r) {
        int mid = (l + r) / 2;
        string cur = prefix;
        cur += char(mid + '0');
        for (int j = i + 1; j <= len + 1; j++)
          cur += "9";
        if (ask_st(cur)) {
          pos = mid;
          r = mid - 1;
        } else {
          l = mid + 1;
        }
      }
      //assert(pos >= 0);
      prefix += char(pos + '0');
    }
    cout << "! " << prefix << endl;
  }
  return 0;
}

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

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int A, B, C;

int main(){
	getint(A), getint(B), getint(C);
	return puts(A == B && B == C ? "Yes" : "No"), 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int[] l = Arrays.stream(line.split(" ")).mapToInt(Integer::valueOf)
                                                .toArray();
        System.out.println(l[0] * l[1] + " " + (l[0] * 2 + l[1] *2));
    }
}


Measured memory_bytes: 32264
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 2e5;

char s[maxn + 5];
char t[maxn + 5];
char a[maxn + 5];
char b[maxn + 5];
bool flag;

int main(){
	memset(a, '#', sizeof(a));
	memset(b, '#', sizeof(b));
	scanf("%s", s);
	scanf("%s", t);
	int len = strlen(s);
	for(int i = 0; i <= len - 1; i++){
		if(a[s[i] - 'a'] == '#' || a[s[i] - 'a'] == t[i]){
			a[s[i] - 'a'] = t[i];
		}
		else flag = 1;
		if(b[t[i] - 'a'] == '#' || b[t[i] - 'a'] == s[i]){
			b[t[i] - 'a'] = s[i];
		}
		else flag = 1;
		if(flag){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <set>
#include <fstream>
#include <cstring>
#include <climits>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long
#define mod 1000000007

pair<ll, ll> dp[101][100001];

//dp[i][j].first is the no of ways to distribute j candies among students i onwards
//dp[i][j].second is the no of ways to distribute atmost j candies among students i onwards

ll solve_ite(int* a, int n, int total_candies) {

	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j <= total_candies; j++) {
			if (j > a[i])
				dp[i][j].first = dp[i + 1][j].second - dp[i + 1][j - a[i] - 1].second + mod;
			else
				dp[i][j].first = dp[i + 1][j].second;
			if (j == 0)
				dp[i][j].second = dp[i][j].first;
			else
				dp[i][j].second = dp[i][j].first + dp[i][j - 1].second;
			dp[i][j].first %= mod;
			dp[i][j].second %= mod;
		}
	}
	return dp[0][total_candies].first;
}

int main() {
  
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < 101; ++i) {
		for (int j = 0; j < 100001; ++j) {
			dp[i][j].first = 0;
			dp[i][j].second = 0;
		}
	}
	dp[n][0].first = 1;
	dp[n][0].second = 1;
	for (int j = 0; j <= k; ++j) {
		dp[n][j].second = 1;
	}
	cout << solve_ite(a, n, k);

	return 0;
}

Measured memory_bytes: 158080
#include<iostream>
using namespace std;
#define N 101

int main(){
    int n,m,l,A[N][N],B[N][N];
    long C[N][N] = {0};

    cin>>n>>m>>l;

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

    for(int i=0;i<m;i++)
    {
        for(int j=0;j<l;j++)
        {
            cin>>B[i][j];
        }
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<l;j++)
        {
            for(int k=0;k<m;k++)
            {
                C[i][j] += A[i][k]*B[k][j];
            }
        }    
    }


    for(int i=0;i<n;i++)
    {
        for(int j=0;j<l;j++)
        {
            if(j!=0)cout<<" ";
                cout<<C[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    ll n;
    cin>>n;
    map<ll,ll> p;
    ll a = 2;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    while(n>=a*a){
        if(n%a==0){
            n/=a;
            p[a]++;
        }else{
            a++;
        }
    }
    p[n]++;
    ll max_p=1,cnt=0;
    ll ans=0;
    for(auto i:p){
        ll c = i.second;
        ll d=1;
        while(c>=d){
            c-=d;
            d++;
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<cstdio>  
#include<cstring>  
#include<algorithm>  
#include<iostream>  
#include<string>  
#include<vector>  
#include<stack>  
#include<bitset>  
#include<cstdlib>  
#include<cmath>  
#include<set>  
#include<list>  
#include<deque>  
#include<map>  
#include<queue>
using namespace std;
typedef long long ll;
const ll inf=1<<29;
const ll Maxn=1e6;

ll a[10];

int main(){
	int ans=0,anw=0;
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+1+3);
	for(int i=1;i<=3;i++){
		if(a[i]%2==0) break;
		if(a[i]%2==1) ans++;
	}
	if(ans<3) printf("0\n");
	if(ans==3) printf("%lld",a[1]*a[2]);
}



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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H.at(i);
    int checker = 0;
    priority_queue<int> ans;
    for(int i = 0; i < N - 1; i++){
        if(H.at(i) >= H.at(i+1)) checker++;
        else{
            ans.push(checker);
            checker = 0;
        }
    }
    ans.push(checker);
    cout << ans.top() << endl;
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

long long xorsum(long long x){
	if(x%4==0) return x;
	if(x%4==1) return 1;
	if(x%4==2) return x^1;
	if(x%4==3) return 0;
	return 1;
}

int main() {
	ll A,B; cin >> A >> B;
	cout << ( xorsum(A)^A^xorsum(B) ) << endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys

MOD = 10**9 + 7
N=int(input())
dp = [{} for i in range(N+1)]
dp[0] = {"XXX":1}

# 終わりではない
def ok(l):
    r = True
    r = r and not "AGC" in l
    r = r and not "AGC" in l[1]+l[0]+l[2]+l[3]
    r = r and not "AGC" in l[0]+l[2]+l[1]+l[3]
    r = r and not "AGC" in l[0]+l[1]+l[3]+l[2]
    return r

# 最後の3つが決まると，わかる
for i in range(N):
    for key in dp[i]:
        for c in "ATCG":
            s = key+c
            if ok(s):
                new_key = s[1:4]
                if not new_key in dp[i+1]:
                    dp[i+1][new_key] = dp[i][key]
                else:
                    dp[i+1][new_key] += dp[i][key]

cnt = 0
for k in dp[N]:
    cnt += dp[N][k]


print(cnt % MOD)

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

int main () {
    int n; cin >> n;
    vector<string> ss(n);
    map<string, int> memo;
    int max_cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> ss[i];
        if (memo.find(ss[i]) == memo.end()) {
            memo[ss[i]] = 0;
        }
        memo[ss[i]] = memo[ss[i]] + 1;
        if (memo[ss[i]] > max_cnt) {
            max_cnt = memo[ss[i]];
        }
    }
    vector<string> ans;
    for (auto it = memo.begin(); it != memo.end(); it++) {
        if ((*it).second == max_cnt) {
            ans.push_back((*it).first);
        }
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 28404
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int c[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	std::sort(c,c+a);
	int ret=a;
	for(int i=0;i<a;i++)b-=c[i];
	ret+=b/c[0];printf("%d\n",ret);
}

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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
  int n, d;
  cin >> n >> d;
  int den = 2 * d + 1;
  cout << (n + den - 1) / den << "\n";
}

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


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    ll N, C; cin >> N >> C;
    vl X(N+2, 0), V(N+2, 0); 
    FOR(i,1,N+1) cin >> X[i] >> V[i];
    X[N + 1] = C;
   
    // clockwise
    vl dpL(N + 2, 0);
    // dpL[i] := max cal to get from [0,i] 
    ll sum = 0;
    FOR(i,1,N+1) {
        sum += V[i];
        sum -= (X[i] - X[i - 1]);
        dpL[i] = max(dpL[i-1], sum);
    }

    // counter clockwise
    vl dpR(N + 2, 0);
    sum = 0;
    for (int i=N; i>=1; i--) {
        sum += V[i];
        sum -= (X[i+1] - X[i]);
        dpR[i] = max(dpR[i+1], sum);
    }

    ll ans = 0;
    FOR(i, 0, N+1) {
        ans = max(ans, dpL[i] - X[i] + dpR[i + 1]);
        ans = max(ans, dpR[i+1] - (C - X[i+1]) + dpL[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N - 1);
    rep(i, N) cin >> A.at(i);
    rep(i, N) cin >> B.at(i);
    rep(i, N - 1) cin >> C.at(i);

    int sum = 0;
    rep(i, N) {
        sum += B.at(A.at(i) - 1);
        dump(sum);
        if(i > 0 && A.at(i) - A.at(i - 1) == 1) {
            sum += C.at(A.at(i) - 2);
            dump(sum);
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
/*input
1900
*/
 
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.14159265
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr
 
#define mod 998244353
 
struct node{
    ll val;
};
struct Interval {int start, end;};
bool compare(struct node n1, struct node n2) {
    return (n1.val < n2.val);
}
 
 
 ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 





 
int main() 
{
    ll n; cin>>n;
    ll ans;
    if(n%1000==0)
    	ans = 0;
    else
    	ans = 1000*((n/1000) + 1) - n;
    cout<<ans<<endl;
    return 0;  
}
 

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;

lli n,l,t;
lli x[e5],w[e5];
lli reverse_ants;
lli cross_ants;
lli ans[e5];

int main(){
  cin >> n >> l >> t;
  for(lli i = 0;i < n;i++) cin >> x[i] >> w[i];
  for(lli i = 0;i < n;i++){
    if(w[i] != w[0]){
      reverse_ants++;
      if(w[0] == 1){
        if((x[i]-x[0]+l)%l-t%l <= (t%l)) cross_ants++;
        if(2*(t%l)-((x[i]-x[0]+l)%l) >= l) cross_ants++;
      }else{
        if((x[0]-x[i]+l)%l-t%l <= (t%l)) cross_ants++;
        if(2*(t%l)-((x[0]-x[i]+l)%l) >= l) cross_ants++;
      }
    }

  }
  cross_ants += reverse_ants*(t/l)*2;
  cerr << t/l << " " << cross_ants << endl;
  for(lli i = 0;i < n;i++){
    if(w[i] == 1) x[i] = (x[i]+t)%l;
    else{
      x[i] -= t;
      if(x[i] < 0) x[i] += l*((-x[i])/l);
      x[i] = (x[i]+l)%l;
    }
  }
  lli hoge = x[0];
  for(lli i = 0;i < n;i++){
    x[i] = (x[i]-hoge+l)%l;
  }
  for(lli i = 1;i < n;i++){
    if(x[i] == 0){
      if(w[i] == 2) x[i] += l;
    }
  }
  sort(x,x+n);
  for(lli i = 0;i < n;i++) x[i] = (x[i]+hoge)%l;
  lli start;
  if(w[0] == 1) start = cross_ants%n;
  else start = (n*(cross_ants/n)-cross_ants+n)%n;
  for(lli i = 0,j = start;i < n;i++,j = (j+1)%n){
    ans[j] = x[i];
  }

  for(lli i = 0;i < n;i++){
    cout << ans[i] << endl;
  }

}


Measured memory_bytes: 6016
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    int n,m,t,row_m=0,col_m=0,r,c;
    cin>>n>>m>>t;
   // map<pair<int,int>,int > m;
    map<int,int> row,col;
    map<pair<int,int>,int> man;
    vector<int> rv,cv;
    for(int i=0;i<t;i++)
    {
        int x,y;
        cin>>x>>y;
        man[make_pair(x,y)]=1;
        row[x]++;
        col[y]++;
        if(row[x]>row_m)
        {
            row_m=row[x];
            rv.clear();
        }
        if(row[x]==row_m)
        rv.push_back(x);
        if(col[y]>col_m)
        {
            col_m=col[y];
            cv.clear();
        }
        if(col[y]==col_m)
        cv.push_back(y);
    }
    for(int i=0;i<rv.size();i++)
        for(int j=0;j<cv.size();j++)
    {
        if(man[make_pair(rv[i],cv[j])]!=1)
        {
            cout<<row_m+col_m<<endl;
            return 0;
        }
    }
    cout<<row_m+col_m-1<<endl;
    return 0;
}



Measured memory_bytes: 52504
#define taskname "test"

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 1e5 + 5;
string s, t;
int q;

struct fenwick
{
    int val[maxn];

    void init(string&s)
    {
        fill(begin(val), end(val), 0);
        for(int i = 1; i < (int)s.size(); ++i)
        {
            int x = i;
            for(; x < maxn; x += x & -x)
                val[x] += (s[i] - 'A' + 1);
        }
    }

    int get(int x)
    {
        int res = 0;
        for(; x > 0; x -= x & -x)
            res += val[x];
        return res;
    }

    int get(int l, int r)
    {
        return get(r) - get(l - 1);
    }
} tree_s, tree_t;

void read_input()
{
    cin >> s >> t;
    s = " " + s; t = " " + t;
    cin >> q;
}

void solve()
{
    tree_s.init(s); tree_t.init(t);
    for(; q > 0; --q)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if(tree_s.get(a, b) % 3 == tree_t.get(c, d) % 3)
            cout << "YES\n";
        else cout << "NO\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}


Measured memory_bytes: 1644
from math import ceil
N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]

def attack(n):
    s = 0
    for h in H:
        h -= B*n
        if h > 0:
            s += ceil(h/(A-B))
    return s <= n

l = 0
r = 0
for h in H:
    r = max(ceil(h/B),r)

while l != r-1:
    mid = (l+r)//2
    if attack(mid):
        r = mid
    else:
        l = mid

print(r)

Measured memory_bytes: 50648
#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main(void)
{
	long N,A,B;
	cin >> N>>A>>B;
	
	if ((N * A) <= B)
	{
		cout << (N * A) << endl;
	}
	else
	{
		cout << B << endl;
	}
	
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
xya=[]
for i in range(n):
    xya.append(list(map(int,input().split())))
#1:左、2:右、3:下、4:上　が黒
ll=[0,0]
ur=[w,h]
for i in range(n):
    if xya[i][2]==1:
        ll[0]=max(ll[0],xya[i][0])
    elif xya[i][2]==2:
        ur[0]=min(ur[0],xya[i][0])
    elif xya[i][2]==3:
        ll[1]=max(ll[1],xya[i][1])
    elif xya[i][2]==4:
        ur[1]=min(ur[1],xya[i][1])
if ur[0]-ll[0]<=0 or ur[1]-ll[1]<=0:
    print(0)
else:
    print((ur[0]-ll[0])*(ur[1]-ll[1]))

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;
#define debug3(x) rep(i, sizeof(x)) cout << x[i] << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

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

set<ll> make_primes(int s = limit) {
    set<ll> primes;

    REP(i, 2, s) {
        bool is_prime = true;
        for (auto p : primes) {
            if (i % p == 0) {
                is_prime = false;
                break;
            }
        }
        if (is_prime) primes.insert(i);
    }
    return primes;
}

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

    set<ll> primes = make_primes();
    map<ll, ll> csum;

    for (int i = 3; i < limit; i += 2) {
        csum[i] = csum[i - 2] + (primes.count(i) && primes.count((i + 1) / 2));
    }

    int q;
    cin >> q;

    rep(i, q) {
        int l, r;
        cin >> l >> r;
        cout << csum[r] - csum[l - 2] << endl;
    }
    return 0;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;

using namespace std;
const int MAX = 1000005;
const int MOD = 1000000007;

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(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    COMinit();
    int N;
    cin >> N;
    vector<ll> A(N);
    map<int,int> mp;
    vector<vector<pair<int,int>>> p(N);
    //p[i][j] == pair<int,int>(a,b) :=  i番目の数のj番目の素因数の数はaでその数はb個
    rep(j,N){
        cin >> A[j];
        //ここでA[i]を素因数分解して集合を作る
        ll t = A[j];
        for(ll i=2;i*i<=A[j];i++){
            if(t%i==0){
                int cnt = 0;
                while(t%i==0){
                    cnt++;
                    t/= i;
                }
                p[j].push_back({i,cnt});
                //p[0] := {i,cnt}; 
                //i:= 素因数
                //cnt:= 何個その素因数を含むか
            }
        }
        if(t&&t!=1){
            p[j].push_back({t,1});
            //tを1つ素因数として含む
        }
        for(auto x:p[j]){
            //cout << "Prime factor = " << x.first << " nums = " << x.second << endl;
            if(mp.count(x.first)==0){
                //もしも今までにその素因数を含んでいなかったら
                //集合の中にその素因数を入れる
                mp[x.first] = x.second;
            }else{
                //もしもその素因数を含んでいたが、
                //数が少なかったら大きい奴に合わせる
                if(mp[x.first]<x.second)mp[x.first] = x.second;
            }
        }
    }

    ll ans = 0;
    /*
    for(auto x:mp){
        cout << "Prime factor = " << x.first << " nums = " << x.second << endl;
        //
        // こいつらの値を掛け算した奴が最小公倍数lcmになる
        // つまり lcm *= pow(x.first,x.second);
        // だから各A[i]について、求めたい値は lcm/A[i] であるので
        // ans += lcm/A[i];
        // ここで mod上の逆元を使うことで /A[i] を * inv[A[i]]に変換する
        // すると求めたい答えはrep(i,N) ans += L*inv[A[i]]となる
    }*/
    ll L = 1;
    for(auto x:mp){
        L *= pow(x.first,x.second);
        L%= mod;
    }
    
    for(int i=0;i<N;i++){
        ans += L*inv[A[i]];
        ans %= mod;
    }
    
    cout << ans%mod << endl;
}

Measured memory_bytes: 24832
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

string A, B, C;

int main() {
  cin >> A >> B >> C;
  if (A.back() == B.front() && B.back() == C.front()) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
	int a,b;
	cin>>a>>b;
	V<int> c(a);
	fo(i,a)
	cin>>c[i];
	Sort(c);
	int d=0;
	fo(i,a)
	d+=c[i];
	cout<<a+(b-d)/c[0]<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
template<class T> inline bool chmax(int a, int b, T c, T d) { return c > d ? a : b; }
template<class T> inline bool chmin(int a, int b, T c, T d) { return c > d ? a : b; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<ut, VI, greater<LL> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W, R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL maps[SIZE2][SIZE2];
LL A[SIZE];
LL solve() {
	LL a, b;
	cin >> N >> a >> b;
	if (a == b) {
		cout << 1 << endl;
		return 0;
	}
	if (N <= 1 or a>b) {
		cout << 0 << endl;
		return 0;
	}
	N -= 2;
	cout << max(0LL,N * b - N * a + 1) << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	solve();


	//cin >> N;
	return 0;

}

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

using namespace std;

int main() {
    int h, w, n;
    cin >> h >> w >> n;

    int count = 0;
    int ans = 0;

    if (w < h) {
        for (int i = 1; i <= h; i++) {
            count += h;
            ans++;
            if(count >= n) {
                cout << ans << endl;
                return 0;
            }
        }
    }else {
        for (int i = 1; i <= w; i++) {
            count += w;
            ans++;
            if(count >= n) {
                cout << ans << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
s = int(input())
judge = '0'

k = s % 100
z = (s - k)/100

if 0 < z <= 12:
    judge = '1'
if 0 < k <= 12:
    judge += '1'
else:
    judge += '0'

if judge == '00':
    print('NA')
elif judge == '01':
    print('YYMM')
elif judge == '10':
    print('MMYY')
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3064
import std.stdio, std.format, std.string, std.conv;

void main()
{
  int[] hVals = new int[]( 150_0001 );
  int[] wVals = new int[]( 150_0001 );
  
  while ( true ) {
	int n, m;
	string input = readln;
	formattedRead( input, "%d %d\n", &n, &m );
	if ( n == 0 && m == 0 ) break;

	int[] hs = new int[]( n );
	foreach ( i; 0 .. n ) {
	  hs[ i ] = to!int( strip( readln ) );
	}
	int[] ws = new int[]( m );
	foreach ( i; 0 .. m ) {
	  ws[ i ] = to!int( strip( readln ) );
	}

	collect( hVals, hs );
	collect( wVals, ws );
	int ans = 0;
	foreach ( i; 1 .. 150_0001 ) {
	  ans += hVals[ i ] * wVals[ i ];
	}
	writeln( ans );
  }
}

void collect( int[] vals, int[] vs ) {
  vals[] = 0;
  foreach ( i; 0 .. vs.length ) {
	int sum = 0;
	foreach ( v; vs[ i .. $ ] ) {
	  sum += v;
	  vals[ sum ]++;
	}
  }
}

Measured memory_bytes: 16672
N, M = map(int, input().split())
A = [""] * N
B = [""] * M

for i in range(N):
    A[i] = input()
for i in range(M):
    B[i] = input()

trm = [""] * M

for i in range(N-M+1):
    for j in range(N-M+1):
        trm = [A[k+i][j:j+M] for k in range(M)]
        if B == trm:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

Measured memory_bytes: 3064