akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

# https://atcoder.jp/contests/abc112/submissions/4015190

N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]

confirmed = []
for cx in range(100+1):
    for cy in range(100+1):
        before = None
        for X, Y, H in src:
            if H == 0:
                continue

            tmp = H + abs(X-cx) + abs(Y-cy)
            if tmp < 0:
                continue

            if before == None:
                before = tmp
            elif before != tmp:
                break
        else:
            confirmed.append((cx, cy, tmp))

#print(confirmed)

for cx,cy,ch in confirmed:
    for x,y,h in src:
        if h != max(ch - abs(x-cx) - abs(y-cy), 0): break
    else:
        print(cx,cy,ch)
        exit()

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

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    set<int> as;
    map<int, int> am;
    for(int i = 0; i < n; i++) {
        std::cin >> a[i];
        as.insert(a[i]);
    }

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

    for(auto itr = as.begin(); itr != as.end(); itr++) {
        int num = upper_bound(a.begin(), a.end(), *itr) -
                  lower_bound(a.begin(), a.end(), *itr);


        am.insert(make_pair(*itr, num));          
    }

    int ans = 0;
    for (auto itr = am.begin(); itr != am.end(); itr++) {
        if(itr->first != itr->second) {
            if(itr->second > itr->first) {
                ans += itr->second - itr->first;
            } else {
                ans += itr->second;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 12680
#include<stdio.h>
#include<string.h>
#define LEN 100005


typedef struct pp{
  char name[100];
  int t;
}P;


P Q[LEN+1];
int head, tail, n;

void enqueue(P);
P dequeue();


int main(){
  int elaps = 0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  tail = n+1;
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }


  head = 1;
  while(head != tail){
    if(Q[head].t <= q){
    elaps += Q[head].t; 
    printf("%s %d\n",Q[head].name,elaps);
    dequeue(Q[head]);
    }
    else if(Q[head].t > q){
      elaps += q;
      Q[head].t = Q[head].t - q;
      enqueue(dequeue(Q[head]));
    }
  } 
  return 0;
}

P dequeue(){
  P p;
  p = Q[head];
  if(head >= LEN)
    head = 0;
  else
    head = head++;
  return p;
}

void enqueue(P x){
  Q[tail] = x;
  if(tail >= LEN)
    tail = 0;
  else 
    tail=tail+1;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll K, X;
int main(){
    scanf("%lld%lld", &K, &X);
    if(K*500>=X){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std ;
int lg10(int x ){
	int cnt = 0 ;
	while ( x != 0 ) {
		x /= 10 ;
		cnt ++ ;
	}
	return cnt ;
}
int main(int argc, char** argv) {
	int n ;
	cin >> n ;
	int div1 = 10 , div2 = 1 ;
	string ans = "No" ;
	for ( int i = 0 ; i < lg10(n) ; i++ ) {
		if ( ( n % div1 ) / div2 == 9 ) {
			ans = "Yes" ;
			break ;
		} 
		div1 *= 10 ;
		div2 *= 10 ;
	}
	cout << ans ;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d){
        cout << "Yes" << endl;
        return 0;
    }
    if(abs(a-b)<=d && abs(b-c)<=d){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int pow;
  int limit = N;
  
  for (int i = 0; i < N; i++){
    pow = 1;
    
    for (int j = 0; j < i; j++){
      pow *= 2;
    }
    
    if (K < pow){
      limit = i;
      break;
    }
  }
  
  int total = 1;
  
  for (int i = 0; i < limit; i++){
    total *= 2;
  }
  
  for (int i = 0; i < N - limit; i++){
    total += K;
  }
  
  cout << total << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = 0; j < m; j++) {
      int a;
      cin >> a;
      sum += a*b[j];
    }
    sum += c;
    if (sum > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
using namespace std;


const int MAX=30;

int count=0;

int w,h;
int tile[MAX][MAX];//0->rot 1->schwarz 2->besucht

int search(int a,int b)
{
    if(a<0 || a>=h || b<0 || b>=w)
    {
        return 0;
    }
    switch(tile[a][b])
    {
        case 0:
        case 2:
            return 0;
        case 1:
        {
            count++;
            tile[a][b]=2;
            search(a-1,b);
            search(a+1,b);
            search(a,b-1);
            search(a,b+1);
        }
    }
    return 1;
}


int main(void)
{
    while(scanf("%d%d",&w,&h)==2 &&(w||h))
    {
        int rc=0;
        int sa,sb;
        while(rc<w*h)
        {
            int ch=getchar();
            switch(ch)
            {
                case '.':
                    tile[rc/w][rc%w]=1;
                    rc++;
                    break;
                case '#':
                    tile[rc/w][rc%w]=0;
                    rc++;
                    break;
                case '@':
                    tile[rc/w][rc%w]=1;
                    sa=rc/w;
                    sb=rc%w;
                    rc++;
                    break;
            }
        }
        count=0;
        search(sa,sb);
        printf("%d\n",count);
    }
    return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n  >>m;
	VI p(m), z(m);
	rep(i, m){
		string s;
		cin >>p[i] >>s;
		z[i] = s[0]=='A'? 1:0;
	}
	int ans1=0, ans2=0;
	map<int, int> mp1, mp2;
	rep(i, m){
		if(mp1[p[i]] !=1 && z[i]==0) mp2[p[i]]++;
		if(z[i]==1) mp1[p[i]]=1;
	}
	
	for(auto x:mp1) if(x.second==1) ans1++;
	for(auto x:mp2){
		if(mp1[x.first]==1) ans2 += x.second;
	}
	cout << ans1 <<" "<<ans2 <<"\n";
	return 0;
}



Measured memory_bytes: 6912
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int H, W, M; cin >> H >> W >> M;
    vector<int> cntH(H), cntW(W), bombH(M), bombW(M);
    int max_h = -1, max_w = -1;
    rep(i, M){
        int a, b; cin >> a >> b; a--; b--;
        cntH[a]++, cntW[b]++;
        chmax(max_h, cntH[a]); chmax(max_w, cntW[b]);
        bombH[i] = a, bombW[i] = b;
    }
    int res = max_h + max_w;
    ll maxh_cnt = 0, maxw_cnt = 0, closs_cnt = 0;

    rep(i, H){
        if(cntH[i]==max_h)maxh_cnt++;
    }
    rep(i, W){
        if(cntW[i]==max_w)maxw_cnt++;
    }

    rep(i, M){
        int a = bombH[i], b = bombW[i];
        if(cntH[a] == max_h && cntW[b] == max_w)closs_cnt++;
    }
    if(closs_cnt == maxh_cnt * maxw_cnt)res--;
    cout << res << ln;
}
    


Measured memory_bytes: 7976
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main(void) {

    int N = 0;
    int D = 0;

    cin >> N;
    cin >> D;

    int* X = NULL;
    int* Y = NULL;
    double* distance = NULL;

    X = new int[N];
    Y = new int[N];
    distance = new double[N];

    for( int ii = 0; ii < N; ii++ ) {
        cin >> X[ii];
        cin >> Y[ii];

        double tmpX2 = 0.0;
        double tmpY2 = 0.0;

        tmpX2 = pow( X[ii], 2 );
        tmpY2 = pow( Y[ii], 2 );

        distance[ii] = sqrt( tmpX2 + tmpY2 );
    }

    int count = 0;
    for(int ii = 0; ii < N; ii++ ) {
        if( ( D - distance[ii] ) >= 0 ) {
            count++;
        }
    }

    cout << count;

    return 0;
}



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

int main(){
	string x;
	cin>>x;
	int len=x.length();
	len--;
	if(x[2]==x[3]&&x[4]==x[5]){
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
    int a,b;
    cin>>a>>b;
    if(a>8||b>8){
    	cout<<":(";
    }
    else{
    	cout<<"Yay!";
    }
    return 0;
} 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES  // M_PI等のフラグ

#include <iostream>
#include <bitset>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <list>

#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

using namespace std;


void solve(){
    int N;
    cin >> N;
    vector<uint64_t> As(N, 0);
    vector<uint64_t> ruiseki(N+1, 0);
    for (int i=0; i<N; i++) {
        cin >> As.at(i);
        ruiseki.at(i+1) = (ruiseki.at(i) + As.at(i))%MOD;
    }

    /*
    求めたい値 =
    + A[1](A[0])
    + A[2](A[0]+A[1])
    + A[3](A[0]+A[1]+A[2])
    ...
    */

    uint64_t ans = 0;
    for (int i=1; i<N; i++) {
        ans += (As.at(i) * ruiseki.at(i))%MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> e(n);
  vector<int> w(n);
  int cnte = 0, cntw = 0;
  for (int i = 0; i < n; i++) {
    if(s[i] == 'E') {
      cnte++;
    } else {
      cntw++;
    }
    e[i] = cnte;
    w[i] = cntw;
  }

  int ans = 1000000;
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    if (s[i] == 'W') {
      tmp += max(w[i] - 1, 0);
      tmp += cnte - e[i];
    } else {
      tmp += w[i];
      tmp += cnte - e[i];
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int N;
  cin >> N;
  int T, A;
  cin >> T >> A;
  vector<int> H(N);
  int tmp = (T - A) / 0.006;
  int m = INT_MAX;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> H[i];
    H[i] = abs(H[i] - tmp);
    if (H[i] < m) {
      m = H[i];
      ans = i + 1;
    }
  }
  cout << ans << endl;
}


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

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}
template < typename T, typename U >
ostream &operator<<(ostream &os, const pair< T, U > &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

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

struct edge {
	int from, to, d, c, i;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

template < typename A, size_t N, typename T >
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	bitset< 4000001 > dp(0);
	dp[0] = 1;
	rep(i, N) dp |= (dp << A[i]);
	int S = 0;
	rep(i, N) S += A[i];
	S = (S + 1) / 2;
	int ans;
	while (1) {
		if (dp[S]) {
			ans = S;
			break;
		}
		S++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
int a[85][85], b[85][85];
bool dp[85][85][12800+12800+1];
int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    int mid = 12800;
    for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) scanf("%d", &a[i][j]);
    for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) scanf("%d", &b[i][j]);
    dp[1][1][mid+a[1][1]-b[1][1]] = 1;
    dp[1][1][mid+b[1][1]-a[1][1]] = 1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(i == 1 && j == 1) continue;
            if(i > 1){
                for(int k=0;k<=mid+mid;k++){
                    if(!dp[i-1][j][k]) continue;
                    dp[i][j][k+a[i][j]-b[i][j]] = 1;
                    dp[i][j][k+b[i][j]-a[i][j]] = 1;
                }
            }
            if(j > 1){
                for(int k=0;k<=mid+mid;k++){
                    if(!dp[i][j-1][k]) continue;
                    dp[i][j][k+a[i][j]-b[i][j]] = 1;
                    dp[i][j][k+b[i][j]-a[i][j]] = 1;
                }
            }
        }
    }
    int ans = 1e9;
    for(int k=0;k<=mid+mid;k++) if(dp[h][w][k]) ans = min(ans, abs(k-mid));
    printf("%d\n", ans);
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    setint st;
    rep(i, n)
    {
        int a;
        cin >> a;
        if (st.count(a) == 1)
        {
            NO;
            return;
        }
        st.insert(a);
    }
    YES;
}

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


Measured memory_bytes: 9600
import bisect, collections
 
 
 
def solution():
    d = collections.defaultdict(int)
    n = int(input().strip())
    a = [int(x) for x in input().strip().split(" ")]
    for x in a:
        d[x] += 1
    total = 0
    for _, v in d.items():
        total += v*(v-1)//2
    for x in a:
        print(total-d[x]*(d[x]-1)//2+(d[x]-1)*(d[x]-2)//2)
    

def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()

if __name__ == "__main__":
    main()

Measured memory_bytes: 86920
// acdart
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <bitset>
#include <cctype>
#include <fstream>
#include <numeric>
#include <utility>
#include <iomanip>
#include <complex>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned long long ULL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef vector< vll > vvll;
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define se second
#define fi first
#define PI 3.1415926535897932384626433832795
#define mod9 1000000009ll
#define mod7 1000000007ll
#define inf 0x3f3f3f3f
#define inf8  1023456789ll
#define inf16 10000000000000000ll
const long long INF = 10000000000000000ll;
#define SZ(x) ((int)(x).size())
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i,a,b) for(i=a;i<=b;i++)
#define lp(i, n) for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n) for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n) for(int i=(j);i>=(int)(n);--i)
#define lson (id << 1)
#define rson (id << 1 | 1)
#define lowb(x) (x & (-x))
#define eps 1e-7
/*********default*********/
#define maxm 
#define maxn 


int main()
{
	int n, m, k;
	
	scanf("%d%d%d", &n, &m, &k);
	int fg = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			int x = i * m + j * n - 2 * i * j;
			if (x == k) {
				fg = 1;
				break;
			}
		}
		if (fg) break;
	}
	puts(fg ? "Yes" : "No");
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// Binary Indexed Tree 1-index
// 一点加算、区間和 O(logN)
// http://hos.ac/slides/20140319_bit.pdf
ll N;
ll bit[1000010];

void bitadd(ll a, ll w){
    for(ll x = a; x <= N; x += x & -x) bit[x] += w;
}
ll sum(ll a){
    ll ret = 0;
    for(ll x = a; x > 0; x -= x & -x) ret += bit[x];
    return ret;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll p(n);
    vll idx(n+1, -1);
    rep(i, n){
        cin >> p[i];
        idx[p[i]] = i;
    }
    vll lidx1(n+1, -1);
    vll lidx2(n+1, -1);
    vll ridx1(n+1, n);
    vll ridx2(n+1, n);
    N = n;
    rep(i, n){
        bitadd(p[i], 1);
        ll s1 = sum(n)-sum(p[i]);
        ll s2 = n-p[i]-s1;
        chmin(s1, 2ll);
        chmin(s2, 2ll);
        ll p1 = i, p2 = i;
        ll c1 = 0, c2 = 0;
        dump(s1, s2, p1, p2);
        while(s1 > 0){
            p1--;
            if(p[p1] > p[i]){
                if(c1 == 0) lidx2[p[i]] = idx[p[p1]];
                else lidx1[p[i]] = idx[p[p1]];
                s1--;
                c1++;
            }
        }
        while(s2 > 0){
            p2++;
            if(p[p2] > p[i]){
                if(c2 == 0) ridx1[p[i]] = idx[p[p2]];
                else ridx2[p[i]] = idx[p[p2]];
                s2--;
                c2++;
            }
        }
    }
    ll ans = 0;
    dump(lidx1);
    dump(lidx2);
    dump(idx);
    dump(ridx1);
    dump(ridx2);
    repr(i, 1, n+1){
        ll tmp = (lidx2[i]-lidx1[i])*(ridx1[i]-idx[i])+(idx[i]-lidx2[i])*(ridx2[i]-ridx1[i]);
        tmp *= i;
        ans += tmp;
        dump(tmp, ans);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()

vector<pair<int, pair<int, int> > > v;
int N, W, H;

void wh(int pos, int s, int& h, int& w)
{
	h = -1, w = -1;
	int th = v[pos].second.first;
	int tw = v[pos].second.second;
	s %= 2 * (tw + th);
	if (s < tw) w = s;
	else if (s < tw + th) h = s - tw;
	else if (s < 2 * tw + th) w = s - tw - th;
	else h = s - 2 * tw - th;
	h = min(h, th-h);
	w = min(w, tw-w);
	if (h == 0 || w == 0) cout << "er" << endl;
}

void cu(int pos, int h, int w)
{
	int th = v[pos].second.first;
	int tw = v[pos].second.second;
	if (h != -1) {
		v.pb(MP(h*tw, MP(h, tw)));
		v.pb(MP((th-h)*tw, MP(th-h, tw)));
		v.erase(v.begin()+pos);
	} else {
		v.pb(MP(th*w,MP(th, w)));
		v.pb(MP(th*(tw-w),MP(th, tw-w)));
		v.erase(v.begin()+pos);
	}
}


int main()
{
	cin >> N >> W >> H;
	while(W) {
		v.pb(MP(H*W, MP(H, W)));
		rep(i, N) {
			int s, pos, h, w;
			cin >> pos >> s;
			pos--;
			wh(pos, s, h, w);
			cu(pos, h, w);
		}
		sort(all(v));
		rep(i, v.size()) {
			cout << v[i].first << " \n"[i == (int)v.size()-1];
		}
		v.erase(all(v));
		cin >> N >> W >> H;
	}
}



Measured memory_bytes: 3028
A,B = map(int,input().split())
c = 0
for i in range(A,B+1):
  s = str(i)
  k = True
  for j in range(len(s)//2):
    if s[j] != s[(j+1)*-1]: 
      k = False
      break
  if k:
      c+=1     
print(c)

Measured memory_bytes: 9040
#include<bits/stdc++.h>
#define ll long long
const int N = 1010;

struct edge{
	int next, to;
	double w;
};

edge e[2 * N * N];
int first[N], x[N], y[N], r[N], n, cnt = 0;
double dist[N];
bool vis[N];

ll sqr(int _x){
	return 1ll * _x * _x;
}

double dis(int x1, int y1, int x2, int y2){
	return sqrt(sqr(x1 - x2) + sqr(y1 - y2));
}

void addedge(int u, int v, double w){
	e[++ cnt] = {first[u], v, w};
	first[u] = cnt;
	e[++ cnt] = {first[v], u, w};
	first[v] = cnt;
}

std::priority_queue<std::pair <int, int>> pq;

void dijkstra(int s){
	memset(vis, 0, sizeof(vis));
	for (int i = 0; i < N; ++ i)
		dist[i] = 1e100;
	dist[s] = 0;
	pq.push({-dist[s], s});
	while (!pq.empty()){
		int i = pq.top().second;
		pq.pop();
		if (vis[i])
			continue;
		vis[i] = 1;
		for (int j = first[i]; j; j = e[j].next){
			int x = e[j].to;
			if (!vis[x] && dist[x] > dist[i] + e[j].w){
				dist[x] = dist[i] + e[j].w;
				pq.push({-dist[x], x});
			}
		}
	}
}

int main(){
	int x_s, y_s, x_t, y_t;
	scanf("%d%d%d%d", &x_s, &y_s, &x_t, &y_t);
	scanf("%d", &n);
	int s = n, t = n + 1;
	for (int i = 0; i < n; ++ i){
		scanf("%d%d%d", &x[i], &y[i], &r[i]);
	}
	addedge(s, t, dis(x_s, y_s, x_t, y_t));
	for (int i = 0; i < n; ++ i){
		addedge(s, i, std::max(0.0, dis(x_s, y_s, x[i], y[i]) - r[i]));
		addedge(t, i, std::max(0.0, dis(x_t, y_t, x[i], y[i]) - r[i]));
		for (int j = 0; j < n; ++ j){
			if (j == i)
				continue;
			addedge(i, j, std::max(0.0, dis(x[j], y[j], x[i], y[i]) - r[i] - r[j]));
		}
	}
	dijkstra(s);
	printf("%.10lf", dist[t]);
	return 0;
}

Measured memory_bytes: 33780
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N, D;
    cin >> N >> D;
    long X,Y;
    long count=0;
    for(size_t i=0;i<N; i++)
    {
        cin >> X >> Y;
        if(sqrt(X*X + Y*Y) <= D) count++;
    }
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3692
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int x,n; cin>>x>>n; 
    map <int,bool> mp;
    for (int i=1;i<=n;i++){
        int a; cin>>a; 
        mp[a] = true; 
    }
    for (int i=x,j=x; true ; i--,j++){
        if (mp.count(i)==0){
            cout << i << endl;
            return;
        }
        if (mp.count(j)==0){
            cout << j <<endl;
            return;
        }
    }
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N, C;
    cin >> N >> C;
    int D[C][C];
    for(int yi = 0 ; yi < C; yi++){
        for(int xi = 0; xi < C; xi++){
            cin >> D[yi][xi];
        }
    }
    ll c[N][N];
    for(int yi = 0; yi < N; yi++){
        for(int xi = 0; xi  < N; xi++){
            ll tmp = 0;
            cin >> tmp;
            c[yi][xi] = tmp -1;
        }
    }
    ll cost[3][C];//yi mod3をC色に塗り替えるときに掛かるコスト
    for(int yi = 0; yi < 3; yi++){
        for(int xi = 0; xi < C; xi++){
            cost[yi][xi] = 0;
        }
    }
    for(int yi = 0; yi < N; yi++){
        for(int xi = 0; xi < N; xi++){
            for(int ci = 0; ci < C; ci++){
                cost[(xi + yi + 2) % 3][ci] += D[c[yi][xi]][ci];
            }
        }
    }
    ll m = 1ll << 60;
    for(int ai = 0; ai < C; ai++){
        for(int bi = 0; bi < C; bi++){
            for(int ci = 0; ci < C; ci++){
                if(!(ai != bi && bi != ci && ci != ai)){
                    continue;
                }
                m = min(m,cost[0][ai] + cost[1][bi] + cost[2][ci]);
            }
        }
    }
    cout << m << endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef unsigned long long ll;

// v[i] := iが偶数のときは i/2 + 1桁とi/2 + 2桁 の15個の数字のFizzBuzzStringの文字数
// v[i] := iが奇数のときは i/2+2 桁のFizzBuzzStringの文字数
vector<ll> v;
// m[i] := i に対応する 10^x 未満の最大の15^x + 1を返す.
map<int,ll> m;

//stinrg -> ll
ll s_to_i(string s){
	ll n = 0;
	for(ll i=0 ; i < s.size() ; i++ ){
		n *= 10;
		n += s[i] - '0';
	}
	return n;
}

// ll -> string
string i_to_s(ll n){
	string s;
	do{
		s.push_back((n%10)+'0');
		n /= 10;
	}while( n != 0 );
	
	reverse(s.begin(),s.end());
	return s;
}

/// [a,a+14] までのFizzBuzzStringを返す. (a は 15^x + 1)
string get_fb(ll a){
	string res;
	for(ll i=a ; i < a+15 ; i++ ){
		if( i % 3 == 0 && i % 5 == 0 ){
			res += "FizzBuzz";
		}else if( i % 3 == 0 ){
			res += "Fizz";
		}else if( i % 5 == 0 ){
			res += "Buzz";
		}else{
			res += i_to_s(i);
		}
	}
	return res;
}

// 10^x を返す
ll pow10(int x){
	ll res = 1;
	for(int i=0 ; i < x ; i++ ){
		res *= 10ull;
	}
	return res;
}

// k を超えない最大の(32 + 8*d) * x を返す. (d は桁数, x についての二分探索)
ll search(ll k, ll d, ll& x){
	ll low = 0, high = 1e+17;
	while( high - low > 1 ){
		ll mid = (low + high) / 2;
		ll n = (32 + 8*d) * mid;
		if( n < k ){
			low = mid;
		}else{
			high = mid;
		}
	}
	ll a = (32 + 8*d) * low;
	ll b = (32 + 8*d) * high;
	if( b <= k ){
		x = high;
		return b;
	}
	x = low;
	return a;
}

// FizzBuzzString の k 文字目を返す.
char get_ch(ll k){
	
	char res;
	for(int i=0 ; i < v.size() ; i++ ){
		if( k < v[i]  ){ // v[i] のところに答えがある 
			
			if( i % 2 == 0 ){ // 桁の変わる中間のとき
				// m[i]から15個分の数字のFizzBuzzStringをたどる
				string s = get_fb( m[i] );
				for(int i=0 ; i < s.size() ; i++ ){
					if( k == 0 ){
						return res = s[i];
					}
					k--;
				}
			}else{
				// k+y を超えない最大の(32 + 8*d) * x を返す.
				ll x;
				ll n = search(k, i/2+2, x);
				k = k - n;
				ll b = (m[i-1]+15) + 15 * x;
				// bから15個分の数字のFizzBuzzStringをたどる
				string s = get_fb( b );
				for(int i=0 ; i < s.size() ; i++ ){
					if( k == 0 ){
						return res = s[i];
					}
					k--;
				}
			}
		}else{ // 次に進める
			k = k - v[i];
		}
	}
	return res;
}

int main(){
	ll k;
	cin >> k;
	
	for(int i=2 ; i < 18 ; i++ ){
		// 10^i 未満で最大の 15^x + 1(= a) を求める
		ll a;
		for(ll j = pow10(i-1)-1 ; ; j-- ){
			if( j % 15 == 1 ){
				a = j;
				break;
			}
		}
		// a .. a+14 までのFizzBuzzの文字数を実際に生成して求める.
		string s = get_fb(a);
		v.push_back( s.size() );
		m[v.size()-1] = a;
		
		// i 桁のFizzBuzzStringの長さを求める. (桁数の変わる境界部分は除く)
		// 数字 15個のかたまりが b 個ある
		ll b = (pow10(i) - (a+15)) / 15;
		// 15個の長さは FizzとBuzzで32文字, 桁数 i の数字が8個なので 32 + 8*i
		ll len = b * (32 + 8 * i);
		v.push_back( len );
	}
	
	// 20文字出力
	for(ll i=k ; i < k+20 ; i++ ){
		cout << get_ch(i-1);
	}
	cout << endl;
}

Measured memory_bytes: 1224
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    string s;
    cin>>n;
    cin>>s;
    if(s.size()<=n)
    {
        cout<<s;
    }
    else
    {
      for(int i=0;i<n;i++)
      {
        cout<<s[i];
      }
      	cout<<"..."<<endl;
    }
    return 0;
}


Measured memory_bytes: 3524
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>

using namespace std;
const int maxn = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long ll;


int n, x, y;
int a[maxn];
int main(){
	cin >> n >> x >> y;
	int d1, d2;
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			d1 = j - i;
			d2 = abs(x - i) + abs(y - j) + 1;
			a[min(d1, d2)]++;
		}
	}
	for(int i = 1; i < n; i++) cout << a[i] << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
 int n;
 double x[10];
 char u[10];
 int i;
 double sum=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
     scanf("%lf",&x[i]);
     scanf("%s",&u[i]);
 }
 for(i=0;i<n;i++){
     if(u[i]=='J')
        sum=sum+x[i];
     else if(u[i]=='B')
        sum=sum+(x[i]*380000);
 }
 printf("%f",sum);
}

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

int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  for(int i = 0;i < N;++i) {
    cin >> vec.at(i);
  }
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  for(int i = 0;i < N;++i) {
    if(vec.at(i) == "AC") {
      ++a;
    } else if(vec.at(i) == "WA") {
      ++b;
    } else if(vec.at(i) == "TLE") {
      ++c;
    }
  }
  d = N - (a + b + c);
  cout << "AC x " << a << endl;
  cout <<  "WA x " << b << endl;
  cout <<  "TLE x " << c << endl;
  cout <<  "RE x " << d << endl;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int N;
    ll K;
    cin >> N;
    cin >> K;
    vector<ll> A(N);
    rep(i,N) {
        cin >> A[i];
        A[i] --;
    }
    map<int, int> mp;
    vector<int> mcnt;
    bool flag = true;
    int i = 0, cnt = 0, pos;
    while (flag) {
        if (mp.find(i) != mp.end()) {
            flag = false;
            pos = mp[i];
            break; }
        mp[i] = cnt;
        i = A[i];
        cnt++;
    }
    // cout << mp << endl;
    int loop = mp.size() - pos;
    int id;
    if (K <= pos) {
        id = K;
    }
    else{
        id = pos + ((K - pos)%loop);
    }
    // DEBUG_PRINT(pos);
    // DEBUG_PRINT(loop);
    // DEBUG_PRINT(id);
    i = 0;
    while (id > 0) {
        id --;
        i = A[i];

    }
    cout << i + 1 << "\n";
    return 0;
}


Measured memory_bytes: 13832
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int c0 = 0;
		int c1 = 0;

		for(char x: S.toCharArray()){
			if(x == '0'){
				c0++;
			} else {
				c1++;
			}
		}

		System.out.println(2 * Math.min(c0, c1));
	}
}

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

int main(){
  int64_t N,A,B;
  cin >> N >> A >> B;
  if(A>B){
    cout << 0 << endl;
    return 0;
  }
  if((N==1)&&(A!=B)){
    cout << 0 << endl;
    return 0;
  }
  int64_t ans=0;
  ans=B*(N-1)+A-(A*(N-1)+B)+1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <complex>
using namespace std;
typedef complex<int> P;

int main()
{
  int W, H;
  while (cin >> W >> H && !(W == 0 && H == 0)) {
    vector<string> grid(H);
    P start;
    for (int i = 0; i < H; i++) {
      cin >> grid[i];
      for (int j = 0; j < W; j++) {
        if (grid[i][j] == '@') {
          start = P(i, j);
          grid[i][j] = '.';
        }
      }
    }

    queue<P> q;
    q.push(start);
    vector<vector<bool> > visited(H, vector<bool>(W, false));
    visited[start.real()][start.imag()] = true;
    int ans = 0;
    while (!q.empty()) {
      const P p = q.front();
      q.pop();
      ans++;

      static const P dir[] = {P(-1,0), P(1,0), P(0,-1), P(0,1)};
      for (int d = 0; d < 4; d++) {
        const P next = p + dir[d];
        if (0 <= next.real() && next.real() < H && 0 <= next.imag() && next.imag() < W
            && grid[next.real()][next.imag()] == '.' && !visited[next.real()][next.imag()]) {
          visited[next.real()][next.imag()] = true;
          q.push(next);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))

const ll MOD=998244353;
const ll mod=998244353;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};


const ll MaxN=201001;

ll f[MaxN], rf[MaxN];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    REP(i, 1, MaxN) f[i] = (f[i - 1] * i) % mod;
    REP(i, 0, MaxN) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(ll n, ll k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

ll ruijou(ll n, ll k){
    if(k==0) return 1;
    ll x=k/2;
    long long t=ruijou(n,x);
    t=(t*t)%MOD;
    if(k%2==1) return (n*t)%MOD;
    else return t%MOD;
}

int main(){
    init();
    ll N,M,K; cin>>N>>M>>K;
    ll ans=0;
    rep(i,K+1){
        ll x=(M*ruijou(M-1,N-i-1))%MOD;
        x=(x*C(N-1,i))%MOD;
        ans=(ans+x)%MOD;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 6768
import math
N= int(input())
x=[0]*N
y=[0]*N
for i in range(N):
  x[i], y[i]=map(int, (input()).split() )
S = 0
nb =0
for i in range(N) :
  for j in range(0, i) :
    S += math.sqrt( (x[i]-x[j])**2 + (y[i]-y[j])**2 )
    nb += 1
print(S/nb*(N-1))




Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n, m;
    cin >> n >> m;

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

    int sum_a = 0;
    for (auto &&i : a) {
        sum_a += i;
    }

    int select = 0;
    for (auto &&i : a) {
        if (i * 4 * m >= sum_a) {
            select++;
        }
    }

    cout << (select >= m ? "Yes" : "No") << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

struct N {
  int i;
  ll val;
  bool a;
};
bool operator<(const N &l, const N &r) { return l.val < r.val; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<N> v(n * 2);
  vll a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i * 2].val >> v[i * 2 + 1].val;
    a[i] = v[i * 2].val;
    b[i] = v[i * 2 + 1].val;
    v[i * 2].i = i;
    v[i * 2 + 1].i = i;
    v[i * 2].a = true;
    v[i * 2 + 1].a = false;
  }
  ll ans = 0;
  ll sa = 0, sb = 0;
  for (int i = 0; i < n; i++) {
    sa += a[i];
    sb += b[i];
  }
  ans = min(sa, sb);
  vi count(n);
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++)
    count[v[i].i]++;
  bool ok = false;
  for (int i = 0; i < n; i++) {
    if (count[i] == 2)
      ok = true;
  }
  if (ok) {
    ll sum = 0;
    for (int i = 0; i < n; i++)
      sum += v[i].val;
    ans = min(ans, sum);
  } else {
    ll sum = 0;
    for (int i = 0; i < n; i++)
      sum += v[i].val;
    for (int i = 0; i < n; i++) {
      ll sc = sum;
      if (count[i] > 0) {
        sc -= min(a[i], b[i]);
        int k = 0;
        while (true) {
          if (v[n + k].i != i) {
            sc += v[n + k].val;
            break;
          }
          k++;
        }
        ans = min(ans, sc);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
 
int32_t main() 
{
    IO;
    int n;
    cin>>n;
    int sum = 0;
    for(int i=1;i<=n;i++)
    {
        if(i%3 == 0 || i%5 == 0)
        {
            
        }
        else
        sum += i;
    }
    cout<<sum;
	return 0;
}


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

int main() {
  int n,t,a;
  cin >>n>>t>>a;
  vector<int> h(n);
  for(int i=0; i<n; ++i) cin >> h.at(i);
  
  vector<double> tem(n);
  for(int i=0; i<n; ++i) {
    tem.at(i)= t-h.at(i)*0.006;
  }
  
  double chikasacopy =1000;
  int result=0;
  for(int i=0; i<n; ++i){
    double chikasa= abs(a-tem.at(i));
    if(chikasa<chikasacopy) {
      chikasacopy = chikasa;
      result =i+1;
    }
  }
  cout <<result;
}

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

int main(void)
{
	int s;
	
	scanf("%d", &s);
	
	if( ( (s / 100 > 12) || (s / 100 == 0 ) ) && ( (s % 100 > 12 ) || (s % 100 == 0) ) ) {
		printf("NA\n");
		return 0;
	} else if( ( (s / 100 > 12) || (s / 100 == 0 ) ) && ( (s % 100 <= 12 ) && (s % 100 > 0) ) ) {
		printf("YYMM\n");
		return 0;
	} else if( ( (s / 100 <= 12) && (s / 100 > 0 ) ) && ( (s % 100 <= 12 ) && (s % 100 > 0) ) ) {
		printf("AMBIGUOUS\n");
		return 0;
	} else {
		printf("MMYY\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define lli long long int

using namespace std;

int main(){
    lli n,ct=0;
    cin>>n;
    lli a[n];
    for(lli i=0;i<n;i++){
        cin>>a[i];
    }
    for(lli i=0;i<n-2;i++){
        for(lli j=i+1;j<n-1;j++){
            for(lli k=j+1;k<n;k++){
                if((a[i]+a[j]>a[k]) && abs(a[i]-a[j])<a[k] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i]){
                    ct=ct+1;
                }
            }
        }
    }
    cout<<ct<<endl;
}

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

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

Node *search(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

void delete_node(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void delete_first() {
    delete_node(nil->next);
}

void delete_last() {
    delete_node(nil->prev);
}

void delete_key(int key) {
    delete_node(search(key));
}

void print_list() {
    Node *cur = nil->next;
    int i = 0;
    while (true) {
        if (cur == nil) break;
        if (i++ > 0) cout << " ";
        cout << cur->key;
        cur = cur->next;
    }
    cout << endl;
}

int main() {
    int n;
    scanf("%d", &n);
    char s[100];
    int key;

    init();

    for (int i = 0; i < n; i++) {
        scanf("%s%d", s, &key);
        string str = s;
        if (str == "insert") {
            insert(key);
        } else if (str == "delete") {
            delete_key(key);
        } else if (str == "deleteFirst") {
            delete_first();
        } else if (str == "deleteLast") {
            delete_last();
        }
    }
    print_list();
    return 0;
}


Measured memory_bytes: 34524