akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int match_dice(int *dice1, int *dice2);
int match_face(int *face1, int *face2);

int table[7][6] = {{0},{1,2,3,5,4,6},{2,6,3,1,4,5},{3,6,5,1,2,4},
                     {4,6,2,1,5,3},{5,6,4,1,3,2},{6,5,3,2,4,1}};


int main(void)
{
    int dice[100][7];
    int flag;
    int n;
    int i,j;

    scanf("%d", &n);

    for (i = 0; i < n; i++){
        for (j = 1; j < 7; j++){
            scanf("%d", &dice[i][j]);
        }
    }
    flag = 0;
    for (i = 0; i < n-1; i++){
        for (j = i + 1; j < n; j++){
            flag += match_dice(dice[i], dice[j]);
        }
    }
    if (flag == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

}

int match_dice(int *dice1, int *dice2)
{
    int face1[5], face2[5];
    int i,j;

    for (int i = 0; i < 5; i++){
        face1[i] = dice1[table[1][i + 1]];
    }
    for (int i = 1; i < 7; i++){
        if (dice1[1] == dice2[i]){
            for (int j = 0; j < 5; j++){
                face2[j] = dice2[table[i][j + 1]];
            }
            if(match_face(face1, face2) == 1){
                return (1);
            }
        }
    }
    return (0);

}
int match_face(int *face1, int *face2)
{
    int i,j,k;

    if (face1[4] != face2[4]){
        return (0);
    }

    for (i = 0; i < 4; i++){
        if (face1[0] == face2[i]){
            for (j = 0; j < 4; j++){
                if (face1[j] != face2[(i + j) % 4]){
                    break;
                }
            }
            if (j == 4){
                return (1);
            }
        }
    }

    return (0);
}


Measured memory_bytes: 2100
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, M, Q;
    std::cin >> N >> M >> Q;

    boost::multi_array<int64_t, 2> mat(boost::extents[N][N]);
    for (decltype(M) i = 0; i < M; ++i) {
        int64_t l, r;
        std::cin >> l >> r;
        l--; r--;

        for (int y = 0; y <= l; ++y) {
            ++mat[y][r];
        }
        #if 0
        for (int y = 0; y <= l; ++y) {
            for (int x = r; x < N; ++x) {
                ++mat[y][x];
            }
        }
        #endif
    }

    for (int y = 0; y < N; ++y) {
        int sum = 0;
        for (int x = 0; x < N; ++x) {
            mat[y][x] += sum;
            sum = mat[y][x];
        }
    }

    for (decltype(Q) i = 0; i < Q; ++i) {
        int64_t p, q;
        std::cin >> p >> q;
        p--; q--;
        std::cout << mat[p][q] << std::endl;
    }

    return 0;
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int N;
    cin >> N;
    vector<string> U(N), X(N);
    rep(i, N){
        cin >> X[i] >> U[i];
    }
    double ans = 0.;
    rep(i, N){
        if(U[i] == "JPY")ans += stod(X[i]);
        else ans += stod(X[i])*380000;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  int a[n + 5], sum = 1;
  vector<int> nasu;
  rep(i, n){
    cin >> a[i];
  }
  sort(a, a +n);
  a[n] = INF;
  rep(i, n){
    if(a[i] != a[i + 1]){
      nasu.pu(sum);
      sum = 1;
    } else {
      sum ++;
    }
  }
  sort(all(nasu));
  if(nasu.size() <= k){
    cout << "0\n";
  } else {
    sum = 0;
    for(int i = 0;i < nasu.size() - k;i ++){
      sum += nasu[i];
    }
    cout << sum << '\n';
  }
  return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
const int N = 10 * 1000 + 20;
long long a[N], b[N], n, plu, mn;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) 
		cin >> a[i];
	for (int i = 0; i < n; i++) 
		cin >> b[i];
	for (int i = 0; i < n; i++) 
		if (b[i] - a[i] > 0) {
			plu += (b[i] - a[i]) / 2;
			a[i] = b[i] + (b[i] % 2); b[i] = a[i];
		}
	for (int i = 0; i < n; i++)
		mn += a[i] - b[i];
	if (plu >= mn)
		cout << "Yes";
	else 
		cout << "No";
			
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int count=1;
  int sum=0;
  for(int i=0;i<a;i++){
    int c;
    cin>>c;
    if(sum+c<=b){
      count++;
      sum+=c;
    }else break;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <string>
    #include <map>
    #include <algorithm>
    #include <queue>
    #include <iomanip> 
    #include <math.h>
    #include <unordered_map>
    #include <set>
    #include <functional> 
     
    #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
    #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
    #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
    static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
    typedef long long ll;
    template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
    template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }
     
    using namespace std;
     
     
     
    int main() {
     
    	ios_base::sync_with_stdio(0);cin.tie(0);
    	
    	ll n, h;
    	cin >> n >> h;
    	ll a[188888];
    	ll b[188888];
    	ll a_max = 0;
    	ll b_max = 0;
    	ll a_max_number, b_max_number;
    	
    	rep(i,n) {
    		cin >> a[i] >> b[i];
    		if (a_max < a[i]) {
    			a_max = a[i];
    			a_max_number = i;
    		}
    		if (b_max < b[i]) {
    			b_max = b[i];
    			b_max_number = i;
    		}
    	}
     
    	ll number = 0;
     
    	sort(b, b + n);
     
    	for(int i=n-1;i>=0;i--) {
    		if (b[i] > a[a_max_number] && h > 0) {
    			//if (a[i] < b[i]) {
    				h -= b[i];
    				number++;
    			//}
    		}
    	}
    	
     
    	if (h>0){
    		
    		ll t = (h + ll(a[a_max_number] - 1)) / a[a_max_number];
    			//ceil(double(1.0 * h) / );
    		
    		number += t;
    	
    	}
     
     
    	cout << number << endl;
     
     
    	return 0;
    }

Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int a, b, c, d, e, k;
    cin >> a >> b >> c
    	>> d >> e >> k;
    int v[5] = {a, b, c, d, e};
    cout << ((*max_element(v , v + 5) - *min_element(v, v+5)) <= k ? "Yay!" : ":(") << endl; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>

using namespace std;
int main()
{
	int H, W;
	cin >> H >> W;
	string base;
	for (int x = 0; x < H; x++) {
		for (int y = 0; y < W; y++) {
			cin >> base;
			if (base.find("snuke") != string::npos) {
				printf("%c", y + 'A');
				cout << x + 1;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PLL> VP;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "

int main()
{
    ll N, Y;
    cin >> N >> Y;
    for(int i=0; i<=N; i++){
        for(int j=0; j<=N; j++){
            if(1000*i+5000*j+10000*(N-i-j)==Y && N-i-j>=0){
                cout << N-i-j << " " << j << " " << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,i;
  double x,ans=0.0;
  string u;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>x>>u;
    if(u=="JPY") ans+=x;
    else if(u=="BTC") ans+=x*380000.0;
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <math.h>
 
int main(void){
    int i,n,s[1000];
    double h,sum;
     
    while(1){
 
        scanf("%d",&n);
        if(!n) break;
         
        sum = 0;
        h = 0;
         
        for(i=0;i<n;i++){
            scanf("%d",&s[i]);
            sum += s[i];
        }
     
        sum /= n;
     
   //     printf("%lf ",sum);
         
        for(i=0;i<n;i++){
            h += pow(s[i]-sum, 2.0);
        }
             
        h /= n;
 
   //     printf("%lf ",h);
 
        printf("%lf\n",pow(h,1.0/2.0));
     
    }
     
    return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}
 
LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}

int main(){
  int N;
  cin >> N;
  
  cout << N*(N+1)/2 << endl;
  
  return 0;
}
  


Measured memory_bytes: 256
import javax.swing.text.html.HTMLDocument;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

class Main {
    public static void main(String[] args){
        try {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int h1=Integer.parseInt(ss[0]);
            int s1=Integer.parseInt(ss[1]);
            int h2=Integer.parseInt(ss[2]);
            int s2=Integer.parseInt(ss[3]);
            double d=(h2/(double)s1);
            if(d!=(int)d){
                d=(int)d + 1;
            }
            double e=(h1/(double)s2);
            if(e!=(int)e){
                e=(int)e+1;
            }
            if(d<=e){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        } catch (Exception e) {
            System.out.println("kkkk "+ e.getMessage());
        }
    }
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
}

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

int main() {
    int n, k;
    ll a[200010];
    cin >> n >> k;
    rep (i, n) cin >> a[i];

    for (int i=0; i<(n-k); i++) {
        if (a[i] < a[i+k]) cout << "Yes"<< endl;
        else cout << "No"<< endl;
    }

	return 0;
}


Measured memory_bytes: 5148
// 簡易競プロテンプレ
#include <bits/stdc++.h>
using namespace std;
string s;
int main(void){
 cin >> s;
 int mi, ma;
 for(mi=0;;mi++) if (s[mi]=='A') break;
 for(ma=s.size()-1;;ma--) if (s[ma]=='Z') break;
 cout << ma - mi + 1 << endl;
 return 0;
}

Measured memory_bytes: 640
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    int n, k, q;
    cin >> n >> k >> q;

    vector<int> s(n + 1);
    for(int i = 0; i < q; i++){
        int a;
        cin >> a;
        s[a]++;
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        s[i] -= q;
        if(k + s[i] <= 0) cout << "No\n";
        else cout << "Yes\n";
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	if (a=="RRR")
		cout<<3<<endl;
	else if (a=="SRR"||a=="RRS")
		cout<<2<<endl;
	else if (a=="SSS")
		cout<<0<<endl;
	else
		cout<<1<<endl;
	return 0;
}


Measured memory_bytes: 3620
N,M=list(map(int,input().split()))
a=""
sw=[]
pattern=[]
def bit(i,turn):
    if i==N:
        pattern.append(list(turn))
    else:
        bit(i+1,turn+"0")
        bit(i+1,turn+"1")
for i in range(M):
    k=list(map(int,input().split()))
    sw.append(k)
hantei=list(map(int,input().split()))
bit(0,a)
count=0
ans=0
for i in pattern:
    sw_list=[0]*(N+1)
    for j in range(M):
        k=sw[j]
        for l in k[1:]:
            if i[l-1]=="1":
                sw_list[j]+=1
    for m in range(M):
        if sw_list[m]%2!=hantei[m]:break
    else:ans+=1
print(ans)


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

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long;
using pll = pair<ll, ll>;

const ll mod = 1000000007;

const ll MAXS = 2001;
ll dp[MAXS];

int main()
{
    ll S;
    cin >> S;

    dp[0] = 1;

    for (ll i=3;i<=S;++i)
    {
        dp[i] += (i - 1 >= 0 ? dp[i - 1] : 0);
        dp[i] += (i - 3 >= 0 ? dp[i - 3] : 0);
        dp[i] %= mod;
    }

    cout << dp[S] << endl;

    return 0;
}


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

int main() {
	int n,k;
	cin >> n >> k;
	
	int a = k;
	for(int i = 1;i < n; i++) {
		a *= (k-1);
	}
	cout << a << endl;
	return 0;
}

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

int main()
{
    string s;
    string t;
    cin >> s >> t;

    int ans = 0;

    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3912
import math
x = int(input())
ans = x
def isPrime(n):
  if n < 2:
    return False
  if n == 2:
    return True
  if n % 2 == 0:
    # ２ではない偶数は素数ではない
    return False
  
  # nの半分まで計算する範囲を絞る
  m = math.floor(n / 2) + 1
  for p in range(3, m, 2): # 奇数だけ計算する
      if n % p == 0:
        return False
  return True

for i in range(x):
    if isPrime(x+i):
        print(x+i)
        break

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int r;
  cin >> r;
  cout << (r<1200?"ABC":r<2800?"ARC":"AGC")<<endl;

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
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;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans;
    if(s == "RRR") {
        ans = 3;
    } else if(s == "SSS") {
        ans = 0;
    } else if(s == "SRR" || s == "RRS") {
        ans = 2;
    } else {
        ans = 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
char stage[501][501];
int n;
int countblackcol(){
	int res=0;
	for (int x = 0; x < n; ++x)
	{
		int y;
		for (y = 0; y < n; ++y)
		{
			if(stage[y][x]=='.') break;
		}
		if(y==n) res++;
	}
	return res;
}
int searchrow(){
	//黒一行を作るまでの回数の最小を調べる
	int minv = n+1;
	for (int y = 0; y < n; ++y)
	{
		int v = 0;
		int ty;
		//塗りつぶし開始までの準備
		for (ty = 0; ty < n; ++ty)
		{
			if(stage[ty][y]=='#') break;
		}
		if(ty == n) v=1;
		//塗りつぶす個数
		for (int x = 0; x < n; ++x)
		{
			if(stage[y][x]=='.') v++;
		}
		//行動回数が最小のものを残す
		if(minv > v){
			minv = v;
		}
		
	}
	return minv;
}
int main(){
	// freopen("in.txt","r",stdin);
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		scanf("%s",stage[i]);
	}
	//どこに張り付けたとしても縦一列にはならない
	//つまり初めに縦一列黒なものから増えない
	int ans = searchrow();
	if(ans==n+1){
		cout << "-1" << endl;
		return 0;
	}
	//縦一列黒ではない個数を調べる
	ans += n - countblackcol();
	cout << ans << endl;
	//横一列すべて黒にするまでにかかる最小試行数
	

	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main() {
    int n, i, j, a[100][100], u, k, b;
    scanf("%d", &n);
    
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            a[i][j]  = 0;
        }
    }
    
    for (i = 0; i < n; ++i) {
        scanf("%d %d", &u, &k);
        for (j = 0; j < k; ++j) {
            scanf("%d", &b);
            a[u-1][b-1]  = 1;
        }
    }
    
    
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            printf("%d", a[i][j]);
            if (j != n-1) printf(" ");
            
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll B[N]{};
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (i + A[i] < N) {
            B[i + A[i]]++;
        }
        if (i - A[i] > 0) {
             ans += B[i - A[i]];
        }
    }
    
    cout << ans << "\n";
    return 0;
}

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

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll BIG_MOD = ll(1e9)+7;
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
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; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = BIG_MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= BIG_MOD;
	if (u < 0) { u += BIG_MOD; }
	return u;
}
// 順列
ll permutation(ll n, ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % BIG_MOD; }
	return result;
}
// 組み合わせ
ll combination(ll n, ll m) {
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++) { div = (div * i) % BIG_MOD; }
	return (p * modinv(div)) % BIG_MOD;
}

int main() {
	int N, K;
	cin >> N >> K;
	ll result = 0;

	for(ll i = K; i <= N+1; i++) {
		result += i * (N - i + 1) + 1;
		result %= 1000000007;
	}

	cout << result << endl;
  return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nk = IO.RSInt;
            var a = IO.RSInt;

            for (int j = 0; j < nk[1]; j++)
            {
                var table = new int[nk[0]];

                for (int i = 0; i < nk[0]; i++)
                {
                    table[Max(i - a[i], 0)]++;
                    if (i + a[i] >= nk[0] - 1) continue;
                    table[i + a[i] + 1]--;
                }

                for (int i = 0; i < nk[0]; i++)
                {
                    if (0 < i) table[i] += table[i - 1];
                }
                a = table;
                if (a.Where(x => x != nk[0]).Count() == 0) break;
            }
            IO.OutJoinSpace(a);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 61356
package main

import "fmt"

func main() {
	var N int

	fmt.Scan(&N)
	var match bool
	for indexA := 1; indexA < 10; indexA++ {			
		for indexB := 1; indexB < 10; indexB++ {
			var multi = indexA*indexB			
			if( multi == N ){
				match = true
			}
		}
	}	
	if match {
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

char a[1000][1000];
int h,w;
bool safe(int i,int j)
{
  return (i>=0 && j>=0 && i<h && j<w && a[i][j]=='.');
}

int row[]={-1,1,0,0};
int col[]={0,0,1,-1};



void solve()
{
  int c1,c2,d1,d2;
  cin>>h>>w>>c1>>c2>>d1>>d2;
  rep(i,h)
  {
    rep(j,w)
      cin>>a[i][j];
  }
  c1--;c2--;d1--;d2--;
  int cost[h][w];
  memset(cost,-1,sizeof(cost));

  queue<pi> q1,q2;
  q1.push({c1,c2});
  q2.push({c1,c2});
  cost[c1][c2]=0;

  while(!q1.empty() || !q2.empty())
  {
    if(!q1.empty())
    {
      pi curr=q1.front();
      q1.pop();

      rep(i,4)
      {
          int x=curr.ff+row[i],y=curr.ss+col[i];
          if(safe(x,y) && (cost[x][y]==-1 || cost[x][y]>cost[curr.ff][curr.ss]))
          {
            cost[x][y]=cost[curr.ff][curr.ss];
            q1.push({x,y});
            q2.push({x,y});
          }
      }
    }

    else if(!q2.empty())
    {
      pi curr=q2.front();
      q2.pop();

      loop(i,-2,+2)
      {
        loop(j,-2,+2)
        {
          int sum=abs(i)+abs(j);
          int x=curr.ff,y=curr.ss;
          int dx=x+i,dy=y+j;

          if(safe(dx,dy) && (cost[dx][dy]==-1 || cost[dx][dy]>cost[x][y]+1))
          {
            cost[dx][dy]=cost[x][y]+1;
            q2.push({dx,dy});
            q1.push({dx,dy});
          }
        }
      }
    }

  }

  cout<<cost[d1][d2]<<endl;

} 

int main()
{

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

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

  int t=1;
  // cin>>t;
  while(t--)
  {
    solve();
  }

  return 0;
}


Measured memory_bytes: 8604
#include<bits/stdc++.h>
using namespace std;
#define int      long long int
int32_t main()
{   ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    map<string,int>mp;
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size()<<'\n';
    return 0;
}

Measured memory_bytes: 19244
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,i,count;
  count=0;
  scanf("%d",&N);
  int A[N+1],B[N+1];
  for(i=0;i<N;i++){
    scanf("%d %d",&A[i],&B[i]);
    if(A[i]==B[i]){
      count++;
      if(count>2){
        printf("Yes");
        return 0;
      }
    }
    else count=0;
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 1724
import sys
import math
input=sys.stdin.readline

n,h=map(int,input().split())

once=[]
infinity=[]

for i in range(n):
  a,b=map(int,input().split())
  once.append(b)
  infinity.append(a)
  
once.sort(reverse=True)

pin=max(infinity)

once2=[]
for i in range(n):
  if once[i]>pin:
    once2.append(once[i])
  
  else:
      break

ans=0
for i in once2:
    ans+=1
    h-=i
    if h<=0:
        print(ans)
        exit()

ans+=math.ceil(h/pin)


print(ans)
  

Measured memory_bytes: 17812
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  long long N, a[300005];

  cin>>N;
  REP(i,0,3*N) cin>>a[i];

  sort(a,a+3*N,greater<long long >());

  long long ans = 0;
  REP(i,0,2*N) {
    if(i%2 == 1) ans += a[i];
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 2560
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,h,w,a,b,ans=0;
  cin >> n >> h >> w;
  for(int i=0; i<n; i++) {
    cin >> a >> b;
    if(a>=h&&b>=w) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
    long long N;
    cin >> N;
    vector <long long> d(N);
    for (long long i=0; i<N; i++) cin >> d.at(i);
    sort(d.begin(), d.end());
    cout << d.at(N/2)-d.at((N/2)-1) << endl;
}

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

int main(){

  int N;
  cin >> N;
  map<int,int> mp;
  int num;
  int MAX_NUM=0;
  for(int i=0;i<N;i++){
    cin >> num;
    MAX_NUM=max(MAX_NUM,num);
    mp[num]++;
  }

  if(mp.size()==1){
    if(N==1){
      cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
    return 0;
  }

  int ans = 0;
  int now;
  while(1){
    now=mp.begin()->first;

    for(int i=2;i<1000000;i++){
      mp.erase(now*i);
      if(now*i>=MAX_NUM) break;
    }

    if(mp[now]==1){
      ans++;
    }
    mp.erase(now);
    if(mp.size()==0){
      cout << ans << endl;
      return 0;
    }
  }
}

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

int main(){
 
    double N,K;
    cin>>N>>K;
    double win=0.0;
    for(double i=1;i<=N;i++){
        if(i>=K) win+=1/N;
        else{
            double p=1.0;
            double j=i;
            while(j<K){
                j*=2;
                p*=0.5;
            }
            win+=p/N;
        }
    }
    cout<<setprecision(15)<<win<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	char a, b;
	cin >> a >> b;
	if (a == 'H'){
		if (b == 'H'){
			cout << "H" << endl;
		}
		else{
			cout << "D" << endl;
		}
	}
	else {
		if (b == 'D'){
			cout << "H" << endl;
		}
		else{
			cout << "D" << endl;
		}
	}
	return 0;
}

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

typedef long long ll;
const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

struct ModComb{
    vector<ll> po, inv;
    ll N;

    ModComb(ll n) : N(n), po(n), inv(n) {
        po[0] = 1;
        for(int i = 1; i < N; i++)  po[i] = (po[i-1] * i) % mod;
        inv[N-1] = modpow(po[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--)   inv[i] = (inv[i+1] * (i+1)) % mod;
    }
    
    ll nCk(ll n, ll k){
        if(n < k)   return 0;
        return (((po[n]*inv[n-k])%mod)*inv[k])%mod;
    }

    ll nPk(ll n, ll k){
        if(n < k)   return 0;
        return (po[n]*inv[n-k])%mod;
    }

    ll nHk(ll n, ll k){
        if(n == 0 && k == 0)    return 1;
        return nCk(n+k-1, k-1);
    }
};

int main(){
    int n, k;
    cin >> n >> k;
    ModComb mc(2100);
    cout << mc.nHk(n, k) << endl;
    return 0;
}


Measured memory_bytes: 3112
L, R = gets.chomp.split(" ").map(&:to_i)
MOD = 2019
MOD2 = 673
MOD3 = 3

ans = 0
if (R - L) < (MOD - 1) && (L % MOD) < (R % MOD) then
  if ((R - L) > (MOD2 - 1) || (L % MOD2) >= (R % MOD2)) && ((R - L) > (MOD3 - 1) || (L % MOD3) >= (R % MOD3)) then
    # 3 * 673 = 2019
    ans = 0
  else
    ans = MOD
    (L..R).to_a.combination(2){|a, b| w = (a * b) % MOD; ans = w if w < ans}
  end
end

puts ans


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

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

fn main() {
    let patterns = ["eraser", "erase", "dreamer", "dream"];
    let s = patterns.iter().fold(read::<String>(), |s, x| s.replace(x, ""));
    println!("{}", if s.is_empty() {"YES"} else {"NO"});
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c=0,d,n;
    string s,s1,s2;
    cin >> s >> s1 >> s2;   
    cout << s[0] << s1[1] << s2[2] << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = (1e9) + 100;
int main(){
  int n;
  cin >> n;
  vector<int> DP(n+1,INF);
  DP[0] = -INF;
  for(int i = 0; i < n; ++i){
    int a;
    cin >> a;
    int id = lower_bound(DP.begin(), DP.end(), a) - DP.begin();
    DP[id] = a;
  }
  cout << lower_bound(DP.begin(), DP.end(), INF) - DP.begin() - 1 << endl;
  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int f[N],prime[N],n,ans[N],x=0,a,b,temp;
void Check(){
	f[1]=1;
	for(int i=2;i<=N;i++){
			if(!f[i]) 
			prime[x++]=i;
	for(int j=0;j<x;j++){
	if(i*prime[j]>N) break;
	f[i*prime[j]]=1;
	if(i%prime[j]==0) break;
}
}
}
int main(){
	Check();
	ans[1]=0;
		for(int i=3;i<=N;i+=2){
		if(!f[i]&&!f[(i+1)>>1]){
		ans[i]=temp+1;
		temp=ans[i];
	}
	else
	ans[i]=temp;
	}
		cin>>n;
		while(n--){
			cin>>a>>b;
			if(!f[a]&&!f[(a+1)>>1])
			cout<<(ans[b]-ans[a]+1)<<endl;
			else
			cout<<ans[b]-ans[a]<<endl;
		}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N, A, B; cin >> N >> A >> B;
    if(B < A) cout << 0;
    else if(N == 1 && A != B) cout << 0;
    else if(N == 1 && A == B) cout << 1;
    else cout << (B - A) * (N - 2) + 1;

    return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

ll f(ll n){
    if(n%2){
        return 3*n+1;
    }else{
        return n/2;
    }
}

void Main(){
    ll s;
    cin >> s;
    map<ll, bool> mp;
    mp[s] = true;
    ll cnt = 1;
    while(1){
        s = f(s);
        cnt++;
        if(mp[s]){
            cout << cnt << el;return;
        }
        mp[s] = true;
    }
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int k = s.nextInt();
		int t = s.nextInt();

		int[] arr = new int[t];
		int max = 0;
		int index = 0;
		for(int i=0;i<t;i++){
			arr[i] = s.nextInt();
			if(arr[i]>max){
				max = arr[i];
				index = i;
			}
		}
		int sum = 0;
		for(int i=0;i<t;i++){
			
			if(i!=index){
				sum += arr[i];
			}
		}

		if(max>sum){
			System.out.println(max-sum-1);
		}else{
			System.out.println(0);
		}

	}
}

Measured memory_bytes: 9428
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    const B = arg[2].split(" ").map(n=>parseInt(n));
    
    const sum = A.reduce((m,n)=>m+n);
    
    let cnt  = 0;
    let rest = 0;

    for(let i=0; i<N; i++) {
        if(A[i] >= B[i]) {
            cnt += B[i];
            continue;
        }
        
        let temp = B[i] - A[i];
        
        cnt += A[i];
        cnt += Math.min(temp, A[parseInt(i)+1]);
        
        A[parseInt(i)+1] = Math.max(A[parseInt(i)+1] - temp, 0);
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32044
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

ll sq(ll x){
	return x*x;
}

int main(void){
	int a,b,c;
	set<int> s;
	cin >> a >> b >> c;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout << (s.size()) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
MIN = a[0]
keep = 0
for i in range(n):
    by = abs((a[0]/2)-a[i])
    if by <= MIN:
        MIN = by
        keep = i
print(a[0],a[keep])


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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

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

    return 0;
}

/*



*/

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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

void solve1(int64, int64, int64);

const int mod = 1000000007;
struct mint {
    int64 x; // typedef long long int64;
    mint(int64 x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(int64 t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

mint nCr(int64 n, int64 r) {
    if (n < r) return 0;
    mint x = 1;
    mint y = 1;
    for (int i=1; i<=r; i++) {
        x *= (n - i + 1);
        y *= i;
    }
    return x / y;
}


const int N = 1000000;
int main() {
    int64 n,a,b;
    cin >> n >> a >> b;

    mint ans = mint(2).pow(n);
    ans -= 1;
    ans -= nCr(n,a);
    ans -= nCr(n,b);



    cout << ans.x << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};


int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> A(M),B(M);
    rep(i,M){
        cin >> A[i] >> B[i];
    }
    UnionFind uf(N+1);
    vector<ll> ans(M+1);
    ans[M] = N*(N-1)/2;
    for(int i=M-1;i>=0;i--){
        if(uf.issame(A[i],B[i])){
            ans[i]=ans[i+1];
            continue;
        }
        ll size_a = uf.size(A[i]);
        ll size_b = uf.size(B[i]);
        ans[i] = ans[i+1] - size_a * size_b;
        uf.merge(A[i],B[i]);
    }
    rep(i,M){
        cout << ans[i+1] << endl;
    }
    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    string sun = "Sunny";
    string clo = "Cloudy";
    string rai = "Rainy";
    if(s == sun) cout << clo << endl;
    else if(s == clo) cout << rai << endl;
    else if(s == rai) cout << sun << endl;
    return 0;
}

Measured memory_bytes: 256