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

#define DEBUG 0

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define fill1(a,z) fill_n(a, sizeof(a)/sizeof(a[0]), z)
#define fill2(a,z) fill_n(a[0], sizeof(a)/sizeof(a[0][0]), z)
#define fill3(a,z) fill_n(a[0][0], sizeof(a)/sizeof(a[0][0][0]), z)
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) {for (auto x : v) {pr(x)} nl}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 100000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int32_t main()
{
    #ifdef DEBUG
    //freopen("A.txt","r",stdin);
    //freopen("","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int h,w;
    cin >> h >> w;
    vector<string> grid;
    for0(i,h) {
        string row;
        cin >> row;
        grid.push_back(row);
    }
    
    int dp[h+1][w+1];
    fill2(dp, INF);
    dp[0][0] = grid[0][0] == '#';
    
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (i == 0 && j == 0)
                continue;
            int a = INF, b = INF;
            if (i > 0) {
                a = dp[i-1][j] + (grid[i][j] != grid[i-1][j] and grid[i][j] == '#');
            }
            if (j > 0) {
                b = dp[i][j-1] + (grid[i][j] != grid[i][j-1] and grid[i][j] == '#');
            }
            dp[i][j] = min(a,b);
        }
    }
    
    int ans = dp[h-1][w-1];
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 384
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

N=int(input())
A = [ int(input()) for _ in range(N) ]
ans = A[0]
for x in A[1:]:
  ans = ans * x // gcd(ans, x)
print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	ll x;
	ll result;
	cin>>x;

	result=(x/11)*2;

	if(x%11==0);
	else if(x%11>=7) result+=2;
	else result++;

	cout<<result<<endl;
}



Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){

	int n;
	bool col[8];
	int ex1 = 0;

	cin >> n;

	rep(i, 0, 8) {
		col[i] = false;
	}

	rep(i, 0, n) {
		int a;
		cin >> a;
		if (a>=1&&a <400) {
			col[0] = true;
		}
		else if (400 <= a && a < 800) {
			col[1] = true;
		}
		else if (800 <= a && a < 1200) {
			col[2] = true;
		}
		else if (1200 <= a && a < 1600) {
			col[3] = true;
		}
		else if (1600 <= a && a < 2000) {
			col[4] = true;
		}
		else if (2000 <= a && a < 2400) {
			col[5] = true;
		}
		else if (2400 <= a && a < 2800) {
			col[6] = true;
		}
		else if (2800 <= a && a < 3200) {
			col[7] = true;
		}
		else {
			ex1++;
		}
	}


	int ans1 = 0;

	rep(i, 0, 8) {
		if (col[i]) {
			ans1++;
		}
	}

	if (ans1 == 0 && ex1 > 0) {
		cout << 1 << ' ' << ex1 << endl;
	}
	else {
		cout << ans1 << ' ' << ans1 + ex1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;

	VI F(N+1,0);
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}

	eFOR(i, 2, N) {
		int n = i;
		int a = 2;
		while (n >= a) {
			if (n%a == 0) {
				//printf("%d * ", a);
				F[a]++;
				n /= a;
			}
			else {
				a++;
			}
		}
	}
	int ans = 1;
	REP(i, N+1) {
		//cout << F[i] << endl;
		ans *= (F[i] + 1);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




ll sum_(ll x,ll y){
  return (y-x-1)*(y-x)/2;
}

int main(){
  ll D;
  cin >> D;
  vector<ll> c(26);
  FOR(i,0,26) cin >> c[i];
  vector<ll> last(26,0),s(26);
  vector<vector<ll>> S;
  vector<ll> t_(D);

  FOR(i,0,D){
    FOR(j,0,26){
      cin >> s[j];
    }
    S.push_back(s);
  }

  ll ans = 0;

  FOR(i,0,D) cin >> t_[i];
  
  FOR(i,0,D){
    ll t;
    t = t_[i];
    t--;
    ans += S[i][t];
    last[t] = i+1;
    FOR(j,0,26){
      ans -= c[j] * (i+1 - last[j]);
    }
    //cout << ans << endl;
  }

  vector<set<ll>> use(26);//日にち
  FOR(i,0,26){
    use[i].insert(0);
    use[i].insert(D+1);
  }
  FOR(i,0,D){
    use[t_[i]-1].insert(i+1);
  }


  ll M;
  cin >> M;
  FOR(k,0,M){
    ll d,q,b;
    cin >> d >> q;

    b = t_[d-1];
    t_[d-1] = q;
    
    ll deff = S[d-1][q-1]-S[d-1][b-1];
    use[b-1].erase(d);
    use[q-1].insert(d);

    auto br = use[b-1].upper_bound(d);
    auto bl = use[b-1].upper_bound(d);
    bl--;

    auto qr = use[q-1].upper_bound(d);
    auto ql = use[q-1].upper_bound(d);
    ql--;ql--;

    deff += (sum_(*bl,d)+sum_(d,*br))*c[b-1];
    deff += sum_(*ql,*qr)*c[q-1];

    deff -= (sum_(*ql,d)+sum_(d,*qr))*c[q-1];
    deff -= sum_(*bl,*br)*c[b-1]; 

    ans += deff;
    cout << ans << endl;
  }



}



Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] xyh = new int[N][3];

		for(int i=0;i<N;i++) {
			xyh[i][0] = sc.nextInt();
			xyh[i][1] = sc.nextInt();
			xyh[i][2] = sc.nextInt();
		}

		Arrays.sort(xyh, (a,b)->Integer.compare(b[2], a[2]));
		if(xyh[0][2] == 0) {
			System.out.println("7 7 1");
			return;
		}

		boolean flag = true;
		for(int i=0;i<=100;i++) {
			for(int j=0;j<=100;j++) {
				int h = 0;
				for(int k=0;k<N;k++) {
					if(h == 0) {
						if(xyh[k][2] == 0) {
							continue;
						}else {
							h = xyh[k][2] + Math.abs(xyh[k][0] - i) + Math.abs(xyh[k][1] - j);
						}
					}

					int hk = Math.max(0, h - Math.abs(xyh[k][0] - i) - Math.abs(xyh[k][1] - j));
					if(xyh[k][2] != hk) {
						flag = false;
						break;
					}
				}

				if(flag) {
					System.out.println(i + " " + j + " " + h);
					return;
				}else {
					flag = true;
				}
			}
		}
	}

}


Measured memory_bytes: 26580
#include<stdio.h>
int main()
{
    long i,H,N,Ai,sum=0;

    scanf("%ld",&H);
    scanf("%ld",&N);

    for(i=1;i<=N;i++)
    {
        scanf("%ld",&Ai);

        sum=sum+Ai;
    }
    if(sum>=H)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}




Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
#define rip(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main() {
	int n;
	int ans = 0;
	cin >> n;
	vector<int>v(n), c(n);
	rep(i, n - 1) {
		cin >> v[i];
	}
	rep(i, n - 1) {
		cin >> c[i];
	}
	rep(i, n - 1) {
		if (v[i] - c[i] > 0)
			ans += v[i] - c[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n;
  int i;
  int mo;
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    for(i=0;i<9;i++){
      scanf("%d",&mo);
      n-=mo;
    }
    printf("%d\n",n);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<stack>
#include<queue>
#include<sstream>
#include<bitset>
#include<cstdio>
using namespace std;
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
int main()
{
	//in_out_txt();
	fast();
	int n;
	cin>>n;
	cout<<(24-n)+24<<endl;
	return 0;
}

Measured memory_bytes: 256
W,H,N=map(int,input().split())
w_max=W
w_min=0
h_max=H
h_min=0
for _ in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        w_min=max(w_min,x)
    elif a==2:
        w_max=min(w_max,x)
    elif a==3:
        h_min=max(h_min,y)
    else:
        h_max=min(h_max,y)
print(max((w_max-w_min),0)*max((h_max-h_min),0))

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main(void){
	double a, b, c, h, s, l, angle, radian, pi = 3.1415926;
	
	scanf("%lf %lf %lf\n", &a, &b, &angle);
	radian = angle * pi / 180;
	c = a*a + b*b - 2*a*b*cos(radian);
	c = sqrt(c);
	l = a+b+c;
	h = b*sin(radian);
	s = a*h/2;
	printf("%f %f %f\n", s, l, h);
	
	return 0;
}



Measured memory_bytes: 2084
#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 N,Q;
string S;
vector<char> t,d;
int f(int p){
  REP(i,Q){
    if(S[p]==t[i])p+=(d[i]=='L'?-1:1);
  }
  if(p==0)return -1;
  if(p==N+1)return 1;
  return 0;
}

int main(){
  cin>>N>>Q;
  cin>>S;
  S="*"+S+"*";
  REP(i,Q){
    char a,b;
    cin>>a>>b;
    t.push_back(a);
    d.push_back(b);
  }
  // FOR(i,1,N+1)cerr<<f(i);
  // cerr<<endl;
  int l,r,ll,rr;
  l=0;
  r=N+1;
  while(r-l!=1){
    int c=(l+r)/2;
    if(f(c)==-1)l=c;
    else r=c;
  }
  ll=r;

  l=0;
  r=N+1;
  while(r-l!=1){
    int c=(l+r)/2;
    if(f(c)==1)r=c;
    else l=c;
  }
  rr=l;
  cout<<rr-ll+1<<endl;
  return 0;
}


Measured memory_bytes: 1016
import itertools

while True:
    n, x = list(map(int, input().split()))
    
    if n == x == 0 : 
          break
      
    count = 0
        
    for v in itertools.combinations(range(1,n+1), 3):
        if sum(v) == x :
            count += 1
           
    print(count)
            


Measured memory_bytes: 5632
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main(void)
{
    int k, s;

    cin >> k >> s;

    int count = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            int z = s - i - j;
            if (0 <= z && z <= k) {
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2* b);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) (y) < 0 || h <= (y) || (x) < 0 || w <= (x)
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n; cin >> n;
    vector<double> x(n), y(n);
    VI a(n);
    FOR(i, 0, n) {
        a[i] = i;
        cin >> x[i] >> y[i];
    }

    double ans = 0;
    do {
        FOR(i, 1, n)ans += sqrtl((x[a[i]] - x[a[i - 1]]) * (x[a[i]] - x[a[i - 1]]) + (y[a[i]] - y[a[i - 1]]) * (y[a[i]] - y[a[i - 1]]));
    } while (next_permutation(all(a)));
    eFOR(i, 1, n)ans /= i;
    cout << ans << "\n";
}


Measured memory_bytes: 256
import java.lang.Math.abs
import java.lang.Math.sqrt
import java.util.*
//import kotlin.math.abs
//import kotlin.math.sqrt

fun main(args: Array<String>) {
    val argList = Scanner(System.`in`)


    val firstLine = argList.nextLine().split(" ")
    val n = firstLine[0].toInt()
    val d = firstLine[1].toInt()
    val x = mutableListOf<List<Int>>()

    while (argList.hasNext()) {
        x.add(argList.nextLine().split(" ").map { it.toInt() })
    }

    val e = GoodDistance()
    println(e.execute(n, d, x))

}

class GoodDistance {
    fun execute(n: Int, d: Int, x: List<List<Int>>): Int {
        var count = 0
        val nIndex = n - 1

        for ((index, i) in x.withIndex()) {
            val nextIndex = index + 1
            for (j in nextIndex..nIndex) {
                if (judgeDis(i, x[j])) {
                    count++
                }
            }
        }

//        x.forEachIndexed { index, i ->
//
//            val nextIndex = index + 1
//            for (j in nextIndex..nIndex) {
//                if (judgeDis(i, x[j])) {
//                    count++
//                }
//            }
//        }

        return count
    }

    private fun judgeDis(i: List<Int>, j: List<Int>): Boolean {
        val d = mutableListOf<Int>()
        for ((index, value) in i.withIndex() ) {
            val sumAbs = abs(j[index] - value)
            d.add(sumAbs * sumAbs)
        }


//        val a = i.mapIndexed { index, value ->
//            val sumAbs = abs(j[index] - value)
//            sumAbs * sumAbs
//        }

        val result = sqrt(d.sum().toDouble())

        return result == result.toInt().toDouble()
    }
}

Measured memory_bytes: 35964
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    int count = 0;
    for(int i=0;i<n;i++){
      double x = sc.nextInt();
      double y = sc.nextInt();
      double dis = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
      if(dis<=d){
        count++;
      }
    }
      System.out.println(count);
  }
}

Measured memory_bytes: 49404
import sys
import socket

if socket.gethostname() in ['N551J', 'F551C']:
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    a = read_int_list()
    res = 0
    i = 0
    while i < n:
        j = i + 1
        while j < n and a[j - 1] == a[j]:
            j += 1
        l = j - i
        res += l // 2
        i = j
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include<iostream>
#include<cstdlib>

int before(int num1,int num2,int taxbf,int s){
	//消費税率変更前の合計の価格を計算するよ
	int aft1 = num1*(100+taxbf)/100;	//一つ目の商品の税込価格
	int aft2 = num2*(100+taxbf)/100;	//二つ目の商品の税込価格
	int sum = aft1+aft2;	//合計

	if(sum==s){
		//sの値と一致したら1(処理を実行せよ)を
		return 1;
	}else if(sum<s){
		//sの値より小さければ0(継続せよ)を
		return 0;
	}else if(sum>s){
		//sの値より大きければ2(これ以上処理を継続する必要はない)を
		return 2;
	}
	//ここまででリターンされないようであれば-1(エラー)を返すよ
	return -1;
}

int  after(int fspro,int scpro,int taxaf){
	//消費税率変更後の合計価格を計算するよ
	int fstax = fspro*(100+taxaf)/100;		//一つ目の商品の税込価格
	int sctax = scpro*(100+taxaf)/100;		//二つ目の商品の税込価格
	int sum=fstax+sctax;								//税込価格の合計
	//返値は税込価格の合計だよ
	return sum;
}

int main(void){
	int mxdata[10000];
	//<追記>データ数900〜1000って多すぎだよ！！！
	//最初配列格納数100にしてランタイムエラー食らったんだよ！
	//ある程度余裕を持ってとった方がいいですね・・・
	int roop=0;
	int x,y,s;
	//最初だけ普通に入力を処理するよ
	std::cin >> x >> y >> s;
	//最終入力以外0が指定されない0で判定するよ
	while(s!=0){
		int bef1,bef2;
		int deco;
		int price,max;
		max = 0;
		for(bef1=1;bef1<s;bef1++){
			//最終処理はbef1=s-1だよ
			for(bef2=1;bef2<s;bef2++){
				//最終処理はbef2=s-1だよ
				deco = before(bef1,bef2,x,s);
				if(deco==0){
					//sの値を超えなかったらループ処理を継続するよ
					continue;
				}else if(deco==1){
					//sの値と一致したら処理を開始するよ
					price = after(bef1,bef2,y);
					//maxの値がpriceより小さければmaxにpriceの値を代入するよ
					if(max<price)
						max = price;
				}else if(deco==2){
					//sの値を超えたらそれ以上ループ処理を実行しても価値はないのでbreakするよ
					break;
				}else if(deco==-1){
					//エラーだよ before関数を確認してね
					std::exit(-1);
				}
			}
		}
		//値を格納するよ
		mxdata[roop]=max;
		//roop回数を記憶するよ この位置で足すことにより配列とかの問題をなんとかしているよ
		roop += 1;
		//二つ目以降の入力を受け付けるよ
		std::cin >> x >> y >> s;
	}

	//エラーチェックだよ roopが0の時に出力を待たずにエラー終了するよ
	if(roop==0)
		std::exit(-1);

	//最終処理(出力)だよ
	int finroop;
	for(finroop=0;finroop<roop;finroop++){
		std::cout << mxdata[finroop] <<std::endl;
	}

	return 0;

}



Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

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

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;cin>>n;
	VI l(n);
	rep(i,n)cin>>l.at(i);
	sort(all(l));
	reverse(all(l));
	LL ans=0;
	rep(i,n-2){
		for(int j=i+1;j<n-1;j++){
			if(l.at(i)>=l.at(j)*2){
				break;
			}
			for(int k=j+1;k<n;k++){
				if(l.at(i)<l.at(j)+l.at(k)){
					ans++;
				}else{
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);

    vector<int> vis(n);
    vector<vector<int> > g(n);
    int i;
    vector<int> v0,v1;
    int prev,curr;
    for(i=0; i<m; i++) {
        int a,b;
        scanf("%d%d", &a, &b); a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        if(i==0) {
            v0.push_back(a);
            v0.push_back(b);
            vis[a]=vis[b]=1;
            prev=a; curr=b;
        }
    }
    while(1) {
        int siz=g[curr].size();
        for(i=0; i<siz; i++) {
            int next=g[curr][i];
            if(next==prev) continue;
            if(vis[next]) continue;

            v0.push_back(next);
            vis[next]=1;
            prev=curr;
            curr=next;
            break;
        }
        if(i<siz) {
            continue;
        }
        else {
            break;
        }
    }

    curr=v0[0];
    prev=v0[1];
    while(1) {
        int siz=g[curr].size();
        for(i=0; i<siz; i++) {
            int next=g[curr][i];
            if(next==prev) continue;
            if(vis[next]) continue;

            v1.push_back(next);
            vis[next]=1;
            prev=curr;
            curr=next;
            break;
        }
        if(i<siz) {
            continue;
        }
        else {
            break;
        }
    }

    int num=(int)v0.size()+(int)v1.size();
    printf("%d\n", num);
    for(i=0; i<(int)v1.size(); i++) {
        printf("%d ", v1[(int)v1.size()-1-i]+1);
    }
    for(i=0; i<(int)v0.size(); i++) {
        printf("%d ", v0[i]+1);
    }
    printf("\n");

    return 0;
}



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

vector <ll> vec;
ll prime[200000];

void sieve(ll n)
{
	for(ll i=2;i<n;i++)
	{
		if(prime[i]==-1)
		{
			vec.push_back(i);
			for(ll j=2;j*i<n;j++)
			{
				prime[i*j] = 1;
			}
		}
	}
}

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    memset(prime,-1,sizeof(prime));
    sieve(200000);
    
    ll x;
    cin>>x;
    cout<<*lower_bound(vec.begin(),vec.end(),x);
    
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN=1e5+10;
int a[MAXN],n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	int cur=1;
	while(a[cur]>=cur) ++cur;
	--cur;
	int up=(a[cur]-cur)&1^1;
	int nxt=cur;
	while(a[nxt]>=cur) ++nxt; 
	--nxt;
	int rt=(nxt-cur)&1^1;
	puts(up&&rt?"Second":"First");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	vector<int> a(3),b(3);
	for(int i = 0; i < 3; i++){
		cin >> a[i] >> b[i];
	}
	vector<int > deg(4);
	for(int i = 0; i < 3; i++){
		deg[a[i]-1]++;
		deg[b[i]-1]++;
	}
	int one=0,two=0;
	for(int i = 0; i < 4; i++){
		if(deg[i]==1)one++;
		else if(deg[i]==2)two++;
	}

	if(one==2 && two==2) cout << "YES" <<  endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;
	f = 0;

	rep(i, n){
		int a;
		cin >> a;
		f += a - 1;
	}

	cout << f << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
class dsu {
public:
   vector<int> p;
   vector<int> sz;
   int n , cc;

   dsu(int _n) : n(_n) , cc(_n) {
      p.resize(n);
      sz.resize(n);
      fill(sz.begin() , sz.end() , 1);
      iota(p.begin(), p.end(), 0);
   }

   inline int get(int u) {
      return (u == p[u] ? u : (p[u] = get(p[u])));
   }

   inline bool unite(int u, int v) {
      u = get(u);
      v = get(v);

      if(u == v)return false;

      if(sz[v] < sz[u])swap(u , v);
      p[u] = v;
      sz[v] += sz[u];
      cc--;
      return true;
   }
};


int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int n , q;
   long long m;
   cin >> n >> m >> q;
   vector<pair<int , int> > zero , one;
   for(int i = 0 ; i < q  ; ++i){
      int u , v , c;
      cin >> u >> v >> c;
      if(c){
         one.emplace_back(u , v);
      }
      else{
         zero.emplace_back(u , v);
      }
   }
   dsu d(n);
   for(auto e : zero){
      int u = e.first , v = e.second;
      if(d.unite(u , v))m--;
   }
   vector<int> pr(n , -1);
   for(int i = 0 ; i < n ; ++i)
      pr[i] = d.get(i);
   bool need = false;
   for(auto e : one){
      int u = pr[e.first] , v = pr[e.second];
      if(u == v || d.cc <= 2){
         cout << "No\n";
         return 0;
      }
      need = true;
   }
   if(!need){     // bug is here you have to check there is no extra edges
      long long canAdd = 1ll * d.cc * (d.cc - 1) / 2;
      cout << ((m >= (d.cc - 1) && m <= canAdd) ? "Yes" : "No") << "\n";
      return 0;
   }
   m -= d.cc;
   long long rem = 1ll * d.cc * (d.cc - 1) / 2;
   rem -= d.cc;
   cout << ((m < 0 || m > rem) ? "No\n" : "Yes\n");
}

Measured memory_bytes: 2420
#include<stdio.h>
int main()
{
	int i,j,x,y;
	while(1)
	{
		scanf("%d %d",&i,&j);
		if(i==0&&j==0) break;
		for(x=1;x<=i;x++)
		{
			for(y=1;y<=j;y++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	 return 0;
	
}

Measured memory_bytes: 1004
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	vector<long long> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end());
	long long x = a.back();
	long long y = a[0];
	long long mini = 1e15;

	for (int i = 0; i < n - 1; i++) {
		long long diff = abs((x - a[i]) - a[i]);
		if (diff < mini) {
			mini = diff;
			y = a[i];
		}
	}

	cout << x << " " << y << endl;
	return 0;
}


Measured memory_bytes: 1024
from collections import deque
 
n = int(input())
a = list(map(int,input().split()))
 
b = deque([])
 
for i,ai in enumerate(a):
  if i%2 == 0:
    b.append(ai)
    
  else:
    b.appendleft(ai)
    
if n%2 == 1:
  b = list(b)[::-1]
  print(*b)
else:
  print(*b)

Measured memory_bytes: 25412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct Dijkstra {
    const T inf = numeric_limits<T>::max() / 2 - 1;
    vector<T> dist;
    vector<int> path;
    
    Dijkstra() {}
    Dijkstra(int n) {
        graph.resize(n);
        dist.resize(n);
        prev.resize(n);
    }
    
    void add_edge(int from, int to, T cost) {
        graph[from].emplace_back(to, cost);
    }
    
    void get_distance(int from) {
        priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
        fill(dist.begin(), dist.end(), inf);
        fill(prev.begin(), prev.end(), -1);
        dist[from] = 0;
        pq.push(make_pair(0, from));
        while(!pq.empty()) {
            pair<T, int> p = pq.top(); pq.pop();
            if (dist[p.second] < p.first) continue;
            for (auto e : graph[p.second]) {
                if (dist[e.first] > (dist[p.second] + e.second)) {
                    dist[e.first] = dist[p.second] + e.second;
                    prev[e.first] = p.second;
                    pq.push(make_pair(dist[e.first], e.first));
                }
            }
        }
    }
    
    void get_path(int to) {
        path = vector<int>(0);
        for (; to != -1; to = prev[to]) {
            path.push_back(to);
        }
        reverse(path.begin(), path.end());
    }
    
private:
    vector<vector<pair<int, T>>> graph;
    vector<T> prev;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    // vector<vector<pair<ll, ll>>> g(n);
    Dijkstra<ll> di(n);
    rep(i, n - 1) {
        ll u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        // g[u].push_back(make_pair(v, w));
        // g[v].push_back(make_pair(u, w));
        di.add_edge(u, v, w);
        di.add_edge(v, u, w);
    }
    di.get_distance(0);
    vector<ll> ans(n, 0);
    rep(i, n) {
        ans[i] = di.dist[i] % 2;
    }
    rep(i, n) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, M, Q;
int v[100100], d[100100], c[100100];
int dp[100100][11];
int col[100100];
vector<int> G[100100];

void dfs(int V, int D, int C)
{
    if(~dp[V][D]){
        return;
    }
    dp[V][D] = 0;
    if(col[V] == 0){
        col[V] = C;
    }
    if(D == 0)return;
    for(int i = 0; i < (int)G[V].size(); i++){
        int to = G[V][i];
        dfs(to, D - 1, C);
    }
    return;
}

signed main()
{
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    memset(dp, -1, sizeof(dp));
    cin >> Q;
    for(int i = 0; i < Q; i++){
        cin >> v[i] >> d[i] >> c[i];
    }
    for(int i = Q - 1; i >= 0; i--){
        v[i]--;
        dfs(v[i], d[i], c[i]);
    }
    for(int i = 0; i < N; i++){
        printf("%d\n", col[i]);
    }



    return 0;
}


Measured memory_bytes: 12408
// AOJ CGL_3_B Is-Convex
// 2018.5.3 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } SEG, LINE;

#define INF			1e8
#define EPS			1e-8
#define EQ(a,b)		(fabs((a)-(b))<EPS)
#define PPeQ(a,b)	(EQ(a.x,b.x)&&EQ(a.y,b.y))

int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }
PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
PP vmul(PP p1, PP p2) { PP r;
	r.x = p1.x * p2.x - p1.y * p2.y, r.y = p1.x * p2.y + p1.y * p2.x; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double dist(PP p1, PP p2) {	return hypot(p1.x-p2.x, p1.y-p2.y); };
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int ccw(PP p0, PP p1, PP p2)
{
	PP a, b;
	double t;

	a = vsub(p1, p0), b = vsub(p2, p0), t = cross(a, b);
	if (t >  EPS) return 1;	if (t < -EPS) return -1;
	if (dot(a, b) < -EPS) return 2;	if (norm(a) < norm(b)) return -2;
	return 0;
}

int isConvex(int n, PP *p)
{
	int i, t;

	p[n] = p[0], p[n+1] = p[1];
	for  (i = 0; i < n; i++) {
		t = ccw(p[i], p[i+1], p[i+2]);
		if (t == -1) return 0;
	}
	return 1;
}

PP p[110];

int main()
{
	int n, i;

	n = in();
	for (i = 0; i < n; i++) p[i].x = in(), p[i].y = in();
	putchar('0'+ isConvex(n, p)), putchar('\n');
	return 0;
}



Measured memory_bytes: 2120
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    int ans = 0;
    if(n < 10) ans = n;
    else{
        ans += 9;
        if(n >= 100){
            if(n < 1000) ans += n - 99;
            else{
                ans += 900;
                if(n >= 10000){
                    if(n < 100000) ans += n - 9999;
                    else ans += 90000;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k; cin >> n >> k;
	int ans = 0;
	rep(i, n) {
		int x; cin >> x;
		ans += 2 * min(abs(x), abs(k - x));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
int length;
int k;
int* a;
//int sum;
int main(){
  while(1){
  std::cin>>length;
  std::cin>>k;
    if(k==0&&length==0)return 0;
  a=new int[length];
  for(int i=0;i<length;i++){
    int input=0;
    std::cin>>input;
    a[i]=input;
  }
  int* sums=new int[length];
  int s=0;
  for(int i=0;i<length;i++){
    s+=a[i];
    sums[i]=s;
  }
    //std::cout<<"\n";
  int max=0;
  int psum=0;
    int idx=0;
  for(int i=0;i<length-k;i++){
    int diff=sums[i+k]-sums[i];
    if(diff>max){
      max=diff;
      idx=i;
      
    //std::cout<<"\n";
    }
      //std::cout<<diff;
  }
  std::cout<<max;
    std::cout<<"\n";
  //std::cout<<std::to_string(idx)+"\n";
  //std::cout<<s;
  }
  return 0;
}


Measured memory_bytes: 3804
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  i64 N, K;
  cin >> N >> K;
  cout << (N - K + 1) << endl;


  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int64_t N,A,B;
  cin>>N>>A>>B;
  
  if(N==1&&A!=B){cout<<0<<endl;}
  else if(N==1&&A==B){cout<<1<<endl;}
  else if(N>1&&A>B){cout<<0<<endl;}
  else if(N>1&&A<=B){
  cout<<(N-2)*(B-A)+1<<endl;}
  return 0;}

Measured memory_bytes: 256
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		byte[] cc = sc.next().getBytes();
		int n = cc.length, k = n;
		for (int i = 1; i < n; i++)
			if (cc[i - 1] != cc[i])
				k = Math.min(k, Math.max(i, n - i));
		println(k);
	}
}


Measured memory_bytes: 39700
#include <stdio.h>
const int N = 10000;
int main()
{
	int a[N] = {0}, n, maxn = -1000005, minn = 1000005;
	long long sum = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		if(a[i] > maxn)
		{
			maxn = a[i];
		}
		if(a[i] < minn)
		{
			minn = a[i];
		}
		sum += a[i]; 
		
	}
	printf("%d %d %lld\n", minn, maxn, sum);
	return 0;
	
} 


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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define mkp make_pair
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
int arr[mxn];
int n, m, k, q;
string s, t;

#define PI 3.1415926535897932384626433

long double calcAngle(double h, double m){
    long double hdeg = h*30;
    long double mdeg= m*6;
    hdeg+=mdeg/12;
    long double deg = abs(hdeg-mdeg);
    return  deg;
}

void solve() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double angle = calcAngle(h, m);
    cout.precision(20);
    cout << sqrt(a * a + b * b - 2.0 * a * b * cos((double) angle * PI / 180.0)) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 4164
def water(H, start, stop):
    if max(H) == 0:
        return

    # water
    valley = min(H[start:stop])
    for i in range(start, stop):
        H[i] -= valley
    global ans
    ans += valley

    # search for next area
    valley_indices = [start + i for i, h in enumerate(H[start:stop]) if h == 0]
    if valley_indices[0] != start:
        valley_indices = [start - 1] + valley_indices
    if valley_indices[-1] != stop - 1:
        valley_indices += [stop]
    for i in range(len(valley_indices) - 1):
        if valley_indices[i + 1] - valley_indices[i] > 1:
            water(H, valley_indices[i] + 1, valley_indices[i + 1])


N = int(input())
H = [int(s) for s in input().split()]

ans = 0
water(H, 0, N)
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int k = sc.nextInt();
        int x = sc.nextInt();
        
        for(int i = 0; i < 2*k-1; i++){
            System.out.print((x-k+1+i) + " ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 21844
import sys

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

def isAsc(lst):
  for i in range(len(lst)-1):
    if lst[i]>lst[i+1]:
      return False
  else:
    return True

if isAsc(plist):
  print("YES")
  sys.exit()

for i in range(N-1):
  for j in range(i+1,N):
    p2list=plist[:]
    p2list[i],p2list[j] = plist[j],plist[i]
    #print(p2list)
    if isAsc(p2list):
      print("YES")
      sys.exit()
      
print("NO")

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

int main() {
    int n, m;
    int p[100001] = {0};
    char s[100001][2] = {0};
    
    scanf("%d %d", &n, &m);
    for(int cnt = 0; cnt < m; cnt++)
        scanf("%d %s", &p[cnt], s[cnt]);
    
    int c[100001][3] = {0};
    
    for(int cnt = 0; cnt < m; cnt++) {
        c[p[cnt]][0]++;
        if((s[cnt][0] == 'W') && (c[p[cnt]][2] == 0))
            c[p[cnt]][1]++;
        else if(s[cnt][0] == 'A')
            c[p[cnt]][2] = 1;
    }
        
    int ok = 0;
    int pena = 0;
    
    for(int cnt = 1; cnt <= n; cnt++) {
        if(c[cnt][2]) {
            ok++;
            pena += c[cnt][1];
        }
    }
    
    printf("%d %d", ok, pena);
    
    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int m = n;
    int wa=0;
    while(n>0){
        wa+=n%10;
        n/=10;
    }
    if(m%wa==0)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

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

  const regex re("^A[a-z]+C[a-z]+$");
  cout << (regex_match(S, re) ? "AC" : "WA") << endl;
  return 0;
}


Measured memory_bytes: 3800
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		int max = 0;
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		    max = max(max, a[i]);
		}
		
		// 計算
		double k = max/2;
		double min = max;
		int index = 0;
		for(int i = 0; i < n; i++){
		    if(abs(k - a[i]) < min && a[i] < max){
		        index = i;
		        min = abs(k - a[i]);
		    }
		}
		
		// 出力
		System.out.println(max + " " + a[index]);
		
	}

}




Measured memory_bytes: 49896
N = input()

hoge = []
for i in range(1, int(N) + 1):
    x, y = input().split()
    hoge.append([x, y])

d = 0
for i in range(int(N)):
    for j in range(i, int(N)):
        d += (((int(hoge[i][0]) - int(hoge[j][0])) ** 2 + (int(hoge[i][1]) - int(hoge[j][1])) ** 2) ** (1 / 2))

print(d * (2/int(N)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
# define pb push_back
# define FOR(i,a,n) for(int i=a;i<n;i++)
# define mp make_pair
# define RFOR(i,a,n) for(int i=n;i>a;i--)
# define pii pair<long long int,long long int>
#define ub upper_bound
#define lb lower_bound
#define MOD 1000000007
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        cout.tie(0);
	ll k;
	cin>>k;
	string str;
	cin>>str;
	if(k>=str.size())
	cout<<str<<endl;
	else
	{
		for(int i=0;i<k;i++)
		cout<<str[i];
		cout<<"...";
		cout<<endl;
	}
}

Measured memory_bytes: 3656
N, M = [int(x) for x in input().split()]
ans = [0] * N
pen = [0] * N
for _ in range(M):
    ps, S = [x for x in input().split()]
    p = int(ps)-1
    if S == 'WA':
        if ans[p] == 0:
            pen[p] += 1
    else:
        ans[p] = 1
ans1 = 0
ans2 = 0
for a, p in zip(ans, pen):
    ans1 += a
    ans2 += (a*p)
print(ans1, ans2)


Measured memory_bytes: 46424