akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
#define M 500010
ll dat[M];
void init(){
  rep(i,M) dat[i] = 0;
}
void add(ll i, ll x){
  for(; i<M; i += i&-i) dat[i] += x;
}
ll sum(ll i){
  ll res = 0;
  for(; i>0; i -= i&-i) res += dat[i];
  return res;
}
ll rangesum(ll L, ll R){
  return sum(R) - sum(L-1);
}

ll A[M] = {};
vector<ll> QL[M], QID[M];
ll ans[M];

ll N, Q;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  cin >> N >> Q;
  init();
  for(ll i=1; i<=N; i++){
    ll a;
    cin >> a;
    add(i, a);
  }
  rep(i, Q){
    ll t, L, R;
    cin >> t >> L >> R;
    if (t == 0)
      add(L+1, R);
    else
      cout << rangesum(L+1, R) << endl;
  }
}

Measured memory_bytes: 31756
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int Q;
	cin>>Q;
	string T;
	for(int i=1;i<=Q;i++)
	{
		int t;
		cin>>t;
		if(t==1)
		{
			swap(s,T);
		}
		if(t==2)
		{
			int f;
			char c;
			cin>>f>>c;
			if(f==1) T.push_back(c);
			if(f==2) s.push_back(c);
		}
	}
	reverse(T.begin(),T.end());
	cout<<T+s<<endl;
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a;
      cin >> a;
      //aの下二桁(1かも)
      int b = a%100;
      //aの下一桁
      int c = b%10;
      
      cout << (a-b)/100 + (b-c)/10 + c << endl;
    }

Measured memory_bytes: 256
#define z 1000000
a[z],b[z],n,i,x,c;main(){for(i=2;i<z;i++)a[i]=i;for(i=0;i<z;i++)if(a[i]!=0){b[x++]=i;for(c=i;c<z;c+=i)a[c]=0;}while(scanf("%d",&n)!=-1){c=0;while(b[c]<=n && b[c]!=0){c++;}printf("%d\n",c);}exit(0);}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
ans = "Yes"

L_max = max(L)
L_min = min(L)

if L_max - L_min >= 2:
    ans = "No"
elif L_max == L_min:
    if not(N >= L[0]*2 or L[0] == N-1):
        ans = "No"
else:
    num_alone = L.count(L_min)
    not_alone_L = [v-num_alone for v in L if v == L_max]
    if not_alone_L[0] <= 0 or len(not_alone_L) < not_alone_L[0]*2:
        ans = "No"
print(ans)


Measured memory_bytes: 14040
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

#define REP(i,N) for(int i = 0; i < N; i++)

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

a,b = 0,0
A.sort(reverse=True)
for i in range(N-1):
    if A[i] == A[i+1]:
        a = A[i]
        A.remove(a)
        A.remove(a)
        break
for i in range(N-3):
    if A[i] == A[i+1]:
        b = A[i]
        break

print(a*b)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int idx=0;
	for(int i=1;i<s.size();i++){
		if(s[i]==s[i-1]) idx++;
	}
	cout<<s.size()-idx-1;
}


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n;
	vector <int> a(n);
	bool flag = true;
	for (int i =0; i<n; i++) {
		cin >> a[i];
		if (a[i] % 2 != 0) {
			continue;
		} else {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    ll n;
    cin >> n;
    string ans = "";
    bool done = false;
    while (!done)
    {
        bool final = n <= 26;
        int diff = (n - 1) % 26;
        ans.insert(0, 1, 'a' + diff);
        n = (n - 1) / 26;

        done = n <= 1 && final;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    map<string,int> sun;
    sun["SUN"]=7;
    sun["MON"]=6;
    sun["TUE"]=5;
    sun["WED"]=4;
    sun["THU"]=3;
    sun["FRI"]=2;
    sun["SAT"]=1;
    string s;
    cin >> s;
    cout << sun.at(s) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N],d[N],e[N],t;

void dfs_a( int u ){
  int v;
  color[u] = GRAY;
  d[u] = ++t;
  for ( v = 0 ; v < n ; v++ ){
    if( M[u][v] == 0)continue;
    if( color[v] == WHITE ){
      dfs_a( v );
    }
  }
  color[u] = BLACK;
  e[u] = ++t;
}

void dfs_b(){
  int u;
  for ( u = 0 ; u < n; u++ ){
    color[u] = WHITE;
  }
  t = 0;
  for( u = 0 ; u < n ; u++ ){
    if( color[u] == WHITE )dfs_a(u);
  }
  for( u = 0 ; u < n ; u++ ){
    printf("%d %d %d\n",u+1 ,d[u] ,e[u]);
  }
}

int main( void ){
  int u,v,k,i,j;

  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      M[i][j] = 0;
    }
  }
  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d",&u,&k);
    u--;
    for( j = 0 ; j < k ; j++ ){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }
  dfs_b();

  return 0;
}

Measured memory_bytes: 636
#include<cstdio>
#define abs(x) ((x)<0? -(x):(x))
#define min(a,b) ((a)<(b)? (a):(b))
int t[2005];
int main() {
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	for(register int i=1;i<=n;++i) {
		for(register int j=i+1;j<=n;++j) {
			int minn=min(abs(x-i)+abs(y-j)+1,j-i);
			++t[minn];
		}
	}
	for(register int i=1;i<=n-1;++i) printf("%d\n",t[i]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<bitset>
#include<stack>
#include<cctype>
#define key_value (ch[ch[root][1]][0])
#define PR(x) cout<<#x<<": "<<x<<endl;
using namespace std;
typedef long long ll;
const double eps = 1e-4;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 3e5+7;
const int maxm = 1e6+7;
const double pi = acos(-1.0);

bool a[maxn],b[maxn];
int main(){
	int n,m; cin>>n>>m;
	for(int i=0; i<m; i++){
		int u,v; scanf("%d%d",&u,&v);
		if(u>v)
			swap(u,v);
		if(u==1)
			a[v]=true;
		if(v==n)
			b[u]=true;
	}
	for(int i=0; i<n; i++){
		if(a[i]&&b[i]){
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
}

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

 
ll  INF=101010101010;
int main() {
    int n;
    cin>>n;
    vector<ll> h(n);
    vector<ll> dp(n);
    rep(i,n)cin>>h[i];
    rep(i,n)dp[i]=INF;

    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        if(i>=2)dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		int dis = Math.abs(A-B);
		if (dis%2==0) {
			System.out.println(Math.abs(Math.min(A, B)+dis/2));
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}




Measured memory_bytes: 35760
#define _CRT_SECURE_NO_WARNINGS
#define REL
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

int n, k;
ll a[200000], ans;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("threesum.in", "r", stdin);
	//freopen("threesum.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	if (k >= n)
	{
		cout << 0;
		return 0;
	}
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n - k; i++)
		ans += a[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
import sys
from bisect import bisect_left,bisect_right
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    A,B,Q=map(int,input().split())
    s=[-INF]+sorted([int(input()) for _ in range(A)])+[INF]
    t=[-INF]+sorted([int(input()) for _ in range(B)])+[INF]
    for _ in range(Q):
        x=int(input())
        Sr=bisect_left(s,x)
        Sl=Sr-1
        Tr=bisect_left(t,x)
        Tl=Tr-1
        l=[[s[Sr],s[Sl]],[t[Tr],t[Tl]]]
        ans=INF
        for k in range(2):
            for i in range(2):
                for j in range(2):
                    tmp=abs(x-l[k][i])+abs(l[k][i]-l[not k][j])
                    ans=min(ans,tmp)
        print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 65244
#include <iostream>
using namespace std;
int A[100000]={};
int k,key;
void sort(int n){
    for(int j=1;j<=n;j++){
        key=A[j];
        k=j-1;
        while(k>0 && A[k]>key){
            A[k+1]=A[k];
            k=k-1;
        }
        A[k+1]=key;
        for(int l=1;l<=n;l++){
            if(l==n){
                cout<<A[l];
            }
            else{
                cout<<A[l]<<" ";
            }
        }
        cout<<endl;
    }
}
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>A[i];
    }
    sort(n);
    return 0;
}


Measured memory_bytes: 3072
//To leave a good impact on people I meet and places I go
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FIO  ios_base::sync_with_stdio(0);cin.tie(0)
#define f(i, n) for(int i = 0; i < n; i++)

signed main()
{
	FIO;
	int T;
	T=1;
	while(T--)
	{
		int x, k, d;
		cin>>x>>k>>d;
		int px = abs(x);
		int m = px/d;
		if(x<px)
		{
			int curr = min(k, m);
			x+=(curr*d);
			k-=curr;
			int eq = 0;
			if(abs(x)==abs(x+d)) eq = 1;
			if(!eq && k%2 == 1)
			{
				x = abs(x+d);
			}
			else x = abs(x);
		}
		else
		{
			int curr = min(k, m);
			x-=(curr*d);
			k-=curr;
			int eq = 0;
			if(abs(x)==abs(x+d)) eq = 1;
			if(!eq && k%2 == 1)
			{
				x = abs(x-d);
			}
			else x = abs(x);
		}
		cout<<x<<endl;

	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

 

int main() {
	int x; cin >> x;
	int n = 1;
	while (n*(n + 1) / 2 < x)n++;
	print(n);

	return 0;
}

Measured memory_bytes: 256
import math

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

p = 0.0

for i in range(n):
  i += 1
  num_required = 0.0
  if i < k:
    num_required = math.ceil(math.log2(k / i))
  p += 0.5 ** num_required

p /= n
print(p)

Measured memory_bytes: 2940
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 21
using namespace std;

int a[N][1 << N | 1];
int f[1 << N | 1][2];

inline int L(int x)
{
    return 31 - __builtin_clz(x);
}

int main(void)
{
    int n, k;
    int i, j, p, q;

    scanf("%d %d", &n, &k);
    for(i = 0; i <= n; i ++)
        for(j = 0; j < (1 << i); j ++)
            scanf("%1d", &a[i][j | 1 << i]);

    for(i = 2; i < (1 << (n + 1)); i ++)
        if(i & (1 << (L(i) - 1)))
        {
            f[i][1] = i ^ (1 << L(i));
            f[i][0] = f[f[i][1]][0];
        }
        else
        {
            f[i][0] = i ^ (1 << L(i)) ^ (1 << (L(i) - 1));
            f[i][1] = f[f[i][0]][1];
        }

    for(i = n; i >= 1; i --)
        for(j = 1 << i; j < (1 << (n + 1)); j ++)
            if(a[i][j])
            {
                p = j >> i;
                q = (j & ((1 << i) - 1)) | (1 << i);
                if(f[q][0])
                    a[L(f[q][0])][(p << 1 | 0) << L(f[q][0]) | (f[q][0] ^ (1 << L(f[q][0])))] += a[i][j];
                if(f[q][1])
                    a[L(f[q][1])][(p << 1 | 1) << L(f[q][1]) | (f[q][1] ^ (1 << L(f[q][1])))] += a[i][j];
                a[0][p] += a[i][j];
            }
    // for(i=1;i<(1<<(n+1));i++)cout<<a[0][i]<<' ';cout<<endl;

    for(i = p = 1; i < (1 << (n + 1)); i ++)
        if(a[0][i] >= k && L(i) > L(p))
            p = i;
    for(i = L(p) - 1; i > -1; i --)
        printf("%d", !!(p & (1 << i)));
    printf("\n");

    return 0;
}


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

using namespace std;

#define ll long long
#define ld long double

#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); }
template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); }

#define mod (int)(1e9 + 7)
#define INF LLONG_MAX

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

  ll N;
  cin >> N;

  bool dp[110] = {0};
  dp[4] = true;
  dp[7] = true;

  for (int i = 8; i <= N; i++) {
    if (dp[i - 4] || dp[i - 7]) {
      dp[i] = true;
    }
  }

  if (dp[N]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N, S=0, T=0, x;
    cin >> N;
    for(int i=0; i<N; i++) {
        cin >> x;
        S += x;
        T += x*x;
    }
    x = (2*S+N) / (2*N);
    cout << N*x*x - 2*S*x + T << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    int64_t s, c;
    cin >> s >> c;
    // If not exchange
    int64_t ans = min(s, c/2);
    int64_t ss = s + c/2;
    ans = max(ans, min(c, (ss/2) * 2)/2);
    cout << ans << endl;
    return 0;
}

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

typedef long long LL;

const double PI = acos(-1.0);

LL x, n;

int work() {

    scanf("%lld", &n);
    x = 100;

    for (int i = 1; i <= 10000; ++i) {
        x = x + x/100;
        if (x >= n) { printf("%d\n", i); return 0; }
    }

    return 0;
}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    
    ll minMove = min({a, b, c, d, e});

    ll ans = ((n + minMove - 1) /minMove) + 4;

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//Littleboy123 Template 1.1

#include <bits/stdc++.h>
using namespace std;

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(a) cout << (a) << '\n'
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

//End of template

int main(){
	init();

	//debug
	/*
	ifstream in("input.in");
	streambuf *cinbuf = std::cin.rdbuf();
	cin.rdbuf(in.rdbuf());

	ofstream out("out.txt");
	streambuf *coutbuf = std::cout.rdbuf();
	cout.rdbuf(out.rdbuf());
	*/
	//end debug

	int n;
	cin >> n;
	int count = 0;
	int y;
	map<int, int> ada;
	FOR(i, 0, n){
		cin >> y;
		if(ada[y] == 0){
			ada[y]++;
			count++;
		}
		else{
			ada[y]--;
			count--;
		}
	}
	cout << count << nl;
	return 0;
}

Measured memory_bytes: 4992
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c = LI()
    if len(list(set([a,b,c]))) == 2:
        print("Yes")
    else:
        print("No") 
    return

#Solve
if __name__ == "__main__":
    solve()


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

using namespace std;
int64_t base = 1;

int64_t f(int64_t m, int64_t n){
    m++;
    return m / (base << n) * (base << (n - 1)) + max(int64_t(0), m % (base << n) - (base << (n - 1)));
}

int main(){
    int64_t a, b;
    cin >> a >> b;
    a--;
    int64_t ans = 0;
    for (int64_t i = 40; i > 0; i--){
       ans += ((f(b, i) - f(a, i)) % 2) * (base << (i - 1));
    }

    cout << ans << endl;
}

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

int main() {
    ll n,k;
    cin>>n>>k;
    int rank=0,num[n]={0},a[n];
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    int now=0,next=a[0],temp,frs=0,sco=0;
    num[0]=1;
    while(1){
        if(num[next]==1)break;
        num[next]=1;
        temp=next;
        next=a[next];
        now=temp;
        frs++;
    }
    while(1){
        if(num[next]==2)break;
        num[next]=2;
        temp=next;
        next=a[next];
        now=temp;
        sco++;
    }
    ll times;
    if(k<=frs){
        times=k;
    }else{
        k-=frs;
        times=k%sco;
        times+=frs;
    }
    int ans=0;
    rep(i,times){
        now=ans;
        ans=a[now];
    }
    cout << ans+1 <<endl;
    return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, d, x;
    cin >> n >> d >> x;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        ll temp = 1;
        while (temp <= d) 
        {
            ans++;
            temp += a[i];
        }
    }

    cout << ans + x << endl;
}

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

main(){
	int n , m ;
	int c[1010] ;
	while( cin >> n >> m , n , m ){
		for( int i=0 ; i<n ; i++ ) cin >> c[i] ;
		sort(c,c+n,greater<int>()) ;
		int sum = 0 ;
		for( int i=0 ; i<n ; i++ ){
			if( (i+1)%m ) sum += c[i] ;
		}
		cout << sum << endl ;
	}
}

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

using namespace std;

int main() {
  int n;
  cin>>n;
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;i++) {
    cin>>a[i];
  }
  for(int i=0;i<n;i++) {
    cin>>b[i];
  }
  for(int i=0;i<n-1;i++) {
    cin>>c[i];
  }
  int x=a[0];
  int count=b[x-1];

  for(int i=1;i<n;i++) {
          count=count+b[a[i]-1];
          if(a[i]==(a[i-1]+1)) {
                  count=count+c[a[i]-2];
          }
  }

  cout<<count<<endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<P> items(M);
    rep(i, M) cin >> items[i].first >> items[i].second;
    ll ans = 0;
    rep(i, M) {
        vector<bool> visited(N, false);
        queue<ll> queue;
        visited[0] = true;
        queue.push(0);
        Graph graph(N);
        rep(j, M) {
            if (i == j) continue;
            ll a = items[j].first;
            ll b = items[j].second;
            a--;
            b--;
            graph[a].push_back(b);
            graph[b].push_back(a);
        }
        while (!queue.empty()) {
            ll v = queue.front();
            queue.pop();
            for (ll u : graph[v]) {
                if (!visited[u]) {
                    visited[u] = true;
                    queue.push(u);
                }
            }
        }
        bool ok = true;
        rep(j, N) {
            if (!visited[j]) ok = false;
        }
        if (ok) ans++;
    }
    cout << M - ans << '\n';
}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
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);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    ll N;
    cin >>  N;
    cout << (N%2==0 ? N/2-1 : N/2) << endl;
} 

Measured memory_bytes: 764
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	long long N,W,w[1005],v[1005],dp[100005]={0};
	cin>>N>>W;
	for(int i=0;i<N;i++)
	{
		cin>>w[i]>>v[i];
	}

	for(int i=0;i<N;i++)
	{
		for(int j=W-w[i];j>=0;j--)
		{
			dp[j+w[i]]=max(dp[j]+v[i],dp[j+w[i]]);
		}
	}
	long long max=0;
	for(int i=0;i<100005;i++)
		if(dp[i]>max)max=dp[i];
	printf("%Ld\n",max);
	return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main() {
	int i;
	string a, b;
	cin >> a >> b;
	for (i = 0; i < b.size(); i++) {
		cout << a.substr(i, 1) << b.substr(i, 1);
	}
	if (i < a.size()) {
		cout << a.substr(i, 1);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, s[112];
int sum;

int main()
{
	in >> N;
	rep(i, N) { in >> s[i]; }

	std::sort(s, s + N);
	rep(i, N) { sum += s[i]; }
	if (sum % 10 == 0)
	{
		rep(i, N)
		{
			if (s[i] % 10 != 0) { sum -= s[i]; }
			if (sum % 10 != 0) { break; }
		}
		if (sum % 10 == 0) { sum = 0; }
	}

	out << sum << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int dorm[4][3][10];
    int i, j, k, n;
    int b, f, r, v;
    for(i = 0; i < 4; i++){
        for(j = 0; j < 3; j++){
            for(k = 0; k < 10; k++){
                dorm[i][j][k] = 0;
            }
        }
    }
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf(" %d %d %d %d",&b, &f, &r, &v);
        dorm[b-1][f-1][r-1] += v;
    }
    
    for(i = 0; i < 4; i++){
        for(j = 0; j < 3; j++){
            for(k = 0; k < 10; k++){
                printf(" %d", dorm[i][j][k]);
            }
            printf("\n");
        }
        if(i < 3){
            printf("####################\n");
            
        }
    }
     return 0;
}

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

int main(){
	int n; cin >> n;
	vector<int> a(n);
	rep(i,n-1){
		int b;cin >> b;
		b--;
		a.at(b)++;
	}
	rep(i,n){
		cout << a.at(i) << endl;
	}
}



	







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

typedef unsigned int uint;
uint s;

int main() {
	cin >> s;
	uint temp = s;
	uint sum = 0;
	while (1) {
		sum += temp % 10;
		temp = temp / 10;
		if (temp == 0) break;
	}

	if (s % sum <1 ) cout << "Yes" << endl;
	else			 cout << "No" << endl;
	return 0;
}

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

#define       pb                 push_back
#define       mx                 200005
#define       MOD                1000000007
#define 	  optimize           ios::sync_with_stdio(0);cin.tie(0);
#define 	  inf                0x3f3f3f3f
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);

using namespace std;

typedef       long long int      ll;
typedef       vector<int> 	     vi;

int main()
{
    int a;
    string s;

    cin >> a >> s;

    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;



    return 0;
}


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

inline void init() {
#ifdef __LOCAL__
  freopen("in", "r", stdin);
#endif
}

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

ll dis(ll ax, ll ay, ll bx, ll by) {
  return abs(ax - bx) + abs(ay - by);
}

int main() {
  init();
  int n; cin >> n;
  ll x = 0, y = 0, t = 0;
  bool ok = true;
  while (n--) {
    ll ct, cx, cy; cin >> ct >> cx >> cy;
    int ddis = dis(x, y, cx, cy);
    int tt = (ct - t);
    int dif = tt - ddis;
    if (ddis > tt || (dif % 2)) {
      ok = false;
      break;
    }
    x = cx;
    y = cy;
    t = ct;
  }
  if (ok) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long lon:g

signed main(){
	int n;
	int s[100];
	cin >> n;
	int ans = 0;
	int mim = INF;
	LOOP(i,n){
		cin >> s[i];
		ans+=s[i];
		if(s[i]%10)
			mim = min(mim,s[i]);
	}
	if(ans%10){
		cout << ans << endl;
	}else{
		if(mim==INF) cout << 0 << endl;
		else		cout << ans-mim << endl;
	}
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "homework"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;
	
int gcd(int a, int b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 303;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int dp[22][(1 << 21)];
bool a[21][21];
vector<int> m[22];

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

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

	for (int mask = 0; mask < (1 << n); mask++) {
		m[__builtin_popcount(mask)].push_back(mask);
	}

	for (int i = 0; i <= n; i++) {
		for (int mask: m[i]) {
			dp[i][mask] = 0;
		}
	}

	dp[0][0] = 1;

	for (int i = 0; i < n; i++) {
		for (int mask: m[i]) {
			for (int k = 0; k < n; k++) {
				if (!((mask >> k) & 1)) {
					if (a[i][k]) {
						int nm = mask | (1 << k);
						dp[i + 1][nm] += dp[i][mask];
						dp[i + 1][nm] %= MOD;
					}
				}
			}
		}
	}
	// for (int i = 0; i <= n; i++) {
	// 	for (int j = 0; j < (1 << n); j++) {
	// 		cout << dp[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }

	cout << dp[n][(1 << n) - 1];
}

Measured memory_bytes: 185392
import bisect
N=int(input())

O=[]
E=[]
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
    if i%2==0:
        O.append(a)
    else:
        E.append(a)
        
A.sort()
Odd=0
Eve=0
for i in range(len(O)):
    if bisect.bisect_left(A,O[i])%2==0:
        Odd+=1
    else:
        Eve+=1
print(Eve)

Measured memory_bytes: 8344
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    print('A' if ord(ns()) < 97 else 'a')
    return

solve()


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

int main ()
{
    long long N;
    long long count;
    std::cin >> N;
    std::vector<std::string> s(N);
    std::unordered_map<std::string, long long> map;

    for (int i = 0; i < N; i++)
    {
        // 受け取った文字列をソート
        std::cin >> s[i];
        std::sort(s[i].begin(), s[i].end());

        std::string tgt_s = {s[i]};
        if (map.count(tgt_s) == 0)
        {
            map[tgt_s] = 1;
        }
        else if (map.count(tgt_s) > 0)
        {
            count += map[tgt_s];
            map[tgt_s]++;
        }
    }

    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 17700
package main

import (
	"fmt"
)

func main() {
	var N int 
	fmt.Scan(&N)
	var s string
	var ac, wa, tle, re int
	for i := 0; i < N; i++ {
		fmt.Scan(&s)
		if s == "AC" {
			ac++
		} else if s == "WA" {
			wa++
		} else if s == "TLE" {
			tle++
		} else {
			re++
		}
	}
	fmt.Println("AC x", ac)
	fmt.Println("WA x", wa)
	fmt.Println("TLE x", tle)
	fmt.Println("RE x", re)

	
}



Measured memory_bytes: 6324
module ArrayL = ArrayLabels
module ListL = ListLabels

let dbg = Printf.printf "[debug]%s"

let max_num = 100_000_000_000
let prime = 1_000_000_007

let id = fun x -> x
let tuple2 x y = (x,y)
let tuple3 x y z = (x,y,z)
let succ x = x + 1
let pred x = x - 1

let (++) n m =
  let rec aux i =
    if i = m then [m]
    else i :: aux (i+1) in
  if n > m then [] else aux n

let (++^) n m = n ++ (m-1)

let scan fmt f = Scanf.sscanf (read_line ()) fmt f

let scan_lines n fmt f =
  List.map (fun _ -> scan fmt f) (0++^n)

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  Array.iteri (fun i line ->
      let s = Scanf.Scanning.from_string @@ read_line () in
      Array.iteri (fun j _ ->
          arr.(i).(j) <- Scanf.bscanf s " %s" conv;
        ) line) arr; arr

let between n x m = n <= x && x < m

let string_to_list s =
  List.map (String.get s) (0 ++^ String.length s)

let (n, m) = scan "%d %d" tuple2

let rec pow n m =
  let ( * ) x y = (x * y) mod prime in
  if m = 0 then 1
  else if m mod 2 = 0 then pow (n*n) (m /2)
  else n * pow (n*n) ((pred m) /2)

let () =
  Printf.printf "%d\n" @@ pow n m



Measured memory_bytes: 2428
#include <iostream>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<deque>
#include<iomanip>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<stack>
#include<unordered_set>
using namespace std;
//	int x=atoi(s.c_str()); s_to_in;
int dx[] = { -1,0,0 };
int dy[] = { 0,1,-1 };
#define endl '\n'
long long mo = 1e9;
const long double P = 3.141592653589793238L;
void trust_yourself()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
long long gcd(long long x, long long y)
{
	if (x == 0)
		return y;
	return gcd(y%x, x);
}
long long fast_power(long long x, long long y, long long mo)
{
	long long p = 1;
	while (y)
	{
		if (y & 1)
			p = (p*x) % mo;
		y = (y >> 1); //y/=2
		x = (x*x) % mo;
	}

	return p;
}
long long convert_to_num(string x) {
	long long  num = 0;
	for (int i = 0; i < x.size(); i++) {
		num *= 2;
		num += x[i] - '0';
	}
	return num;
}

long long com(long long n, long long r) {
	long long p = 1, p1 = 1;
	for (long long i = r + 1; i <= n; i++) {
		p = p * i;
		p /= p1;
		p1++;
	}
	return p;
}


int main()
{
	trust_yourself();
	
	long long n,l;
  cin>>n;
  l=n/500;
  n=n%500;
  cout<<(l*1000)+(n/5)*5;
	
	return 0;

}

Measured memory_bytes: 256
#include<map>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=200005;
int n;map<char,char>M1,M2;
char c1[MAXN],c2[MAXN];
int main(){
	scanf("%s%s",c1+1,c2+1);
	n=strlen(c1+1);
	for(int i=1;i<=n;i++){
		if(M1[c1[i]]&&M1[c1[i]]!=c2[i]){
			printf("No\n");return 0;
		}
		if(M2[c2[i]]&&M2[c2[i]]!=c1[i]){
			printf("No\n");return 0;
		}
		if(!M1[c1[i]]&&!M2[c2[i]]){
			M1[c1[i]]=c2[i];
			M2[c2[i]]=c1[i];
		}
	}
	printf("Yes\n");
}
/*
abcdefg
bcdefga
*/

Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad
import Data.Int (Int64)
import Data.List (foldl')
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  [a,b] :: [Int] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  if a == b
    then print $ a + b
    else print $ 2 * max a b - 1


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=',')
		{
			cout<<s[i];
		}
		else
		{
			cout<<" ";
		}
	}
	return 0;
 } 

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

long long n,m,a,b,ans;

int main()
{
	scanf("%lld",&n);
	m=sqrt(n);
	for(int i=m;i>=1;i--)
		if(n%i==0)
		{
			a=i;
			b=n/i;
			break;
		}
	ans=a+b-2;
	printf("%lld",ans);
	
	return 0;
} 

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n, a, b;
    cin >> n >> a >> b;
    cout << max(0ll, (b - a) * (n - 2) + 1) << endl;

}   

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

using namespace std;

using ll = long long;

int hoge(int x) {
    for (int i = 0; i <= 30; i++) {
        if (x < (1 << i)) return i - 1;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    map<int, ll> memo;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        int a;
        ll b;
        cin >> a >> b;
        memo[a] += b;
        sum += b;
    }
    vector<int> v[30];
    for (auto& p : memo) {
        v[hoge(p.first)].push_back(p.first);
    }

    int d = 0;
    ll ans = 0, bar = 0;
    for (int i = 29; i >= 0; i--) {
        if ((d | (1 << i)) <= K) {
            ll t = 0;
            for (int j : v[i]) {
                t += memo[j];
                int nex = j - (1 << i);
                int tmp = hoge(nex);
                if (tmp < 0) {
                    bar += memo[j];
                    continue;
                }
                if (memo.find(nex) == memo.end()) {
                    v[tmp].push_back(nex);
                }
                memo[nex] += memo[j];
            }
            ans = max(ans, sum - t);
            d |= 1 << i;
        } else {
            for (int j : v[i]) {
                sum -= memo[j];
            }
        }
    }
    ans = max(ans, sum);
    cout << ans << endl;
    return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    while ((B <= A) && (K > 0)) {
        B *= 2;
        K--;
    }
    while ((B > A) && (K > 0)) {
        C *= 2;
        K--;
    }
    if ((C > B) && (B > A)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
n = gets.to_i
array = gets.split(" ").map(&:to_i)
inf = 999999999
dp = Array.new(n, inf)
dp[0] = 0 ; dp[1] = (array[1] - array[0]).abs
# p array
# p dp
2.upto(n-1) do |i|
  dp[i] = [dp[i-2] + (array[i] - array[i-2]).abs, dp[i-1] + (array[i] - array[i-1]).abs].min
end

puts dp[-1]


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

const int N = 200005;
const int INF = 1000000005;
const int MOD = 998244353;
typedef long long i64;

i64 _sqrt(i64 x) {
    i64 l = 1, r = INF, mid;
    while (l < r) {
        mid = (l + r) >> 1;
        if (l == mid) break;
        if (mid * mid <= x) l = mid;
        else r = mid;
    }
    return l;
}
int main ()
{
    i64 Q, a, b;
    cin >> Q;
    while (Q--) {
        cin >> a >> b;
        if (a == 1 && b == 1) {puts("0"); continue;}
        i64 x = a * b - 1, cnt = 0;
        i64 m = _sqrt(x);
        if (m == x / m) ++cnt;
        i64 p = (x / m - m);
        if (a > m && a <= x && x / (x / a) == a) {
            i64 k = x / a;
            if (k + 1 < m && x / (k + 1) < a - 1) ;
            else if (p) --p;
            else ++cnt;
        }
        if (b > m && b <= x && x / (x / b) == b) {
            i64 k = x / b;
            if (k + 1 < m && x / (k + 1) < b - 1) ;
            else if (p) --p;
            else ++cnt;
        }
        if (a > m && b > m) printf("%lld\n", 2 * m - cnt);
        else printf("%lld\n", 2 * m - 1 - cnt);
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
      double r = scan.nextDouble();
      double S = Math.PI * r * r;
      double L = 2 * Math.PI * r;
      System.out.println(String.format("%.8f",S) + " " + L);
     }
    }




Measured memory_bytes: 28152
//PCK2014pre 7 ??????????????¬???/////

#include<iostream>
#include<string.h>
using namespace std;
int prev[200000],next[200000];

int main()
{
	int N,M,Q,a,q,o;
	int ba = 0;
	cin >> N >> M >> Q;
	/*for(int i=0;i<N;i++){
		if(i==0){
			prev[i] = N - 1;
			next[i] = 1;
		}
		else if(i == N-1){
			prev[i] = N - 2;
			next[i] = 0;
		}
		else{
			prev[i] = i - 1;
			next[i] = i + 1;
		}
	}*/
	for(int i=0;i<N;i++){
        prev[i] = (i-1+N)%N;
        next[i] = (i+1)%N;
    }
	
	for(int i=0;i<M;i++){
		cin >> a;
		for(int j=0;j<a;j++)
			ba=a%2==1?prev[ba]:next[ba];
			
		next[prev[ba]] = next[ba];
		prev[next[ba]] = prev[ba];
		o = next[ba];
		prev[ba] = -1;
		next[ba] = -1;
		ba = o;
	}
	
	for(int i=0;i<Q;i++){
		cin >> q;
		if(prev[q] != -1) cout << "1" << endl;
		else cout << "0" << endl;
	}
	/*for(int i=0;i<N;i++)
		cout << i << " " << prev[i] << " " << next[i] << endl;
	cout << "AAA";*/
	return 0;
}

Measured memory_bytes: 2712
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, P, Q;
int C[500010], D[500010];

signed main() {
    cin >> N >> P >> Q;
    rep(i,0,N) {
        cin >> C[i];
        D[i] = P*i + C[i];
    }
    sort(D, D+N);

    int sum = accumulate(C, C+N, 0LL), ans = -INF;
    repq(i,0,N) {
        chmax(ans, sum + P*Q*i + P*i*(i-1));
        if(i < N) sum -= D[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10920
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //~ freopen("file.in", "r", stdin);
    string s;
    cin>>s;
    if(s[0]=='9' or s[1]=='9')
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int n; scanf("%d", &n);
	for(int k = 1; k * (k + 1) / 2 <= n; k++) if(k * (k + 1) / 2 == n){
		int s[500][500] = {};
		for(int i = 0, p = 1; i < k; i++){
			for(int j = 0; j < k - i; j++) s[i][j + i] = p++;
		}
		int t[500][500] = {};
		for(int i = 0; i < k; i++) for(int j = 0; j < k; j++) if(s[i][j] > 0) t[j + 1][i] = s[i][j];
		for(int i = 0; i < k + 1; i++) for(int j = 0; j < k; j++) if(s[i][j] == 0) s[i][j] = t[i][j];
		puts("Yes");
		printf("%d\n", k + 1);
		for(int i = 0; i < k + 1; i++){
			printf("%d ", k);
			for(int j = 0; j < k; j++) printf("%d%c", s[i][j], j + 1 == k ? '\n' : ' ');
		}
		return 0;
	}
	puts("No");
	return 0;
}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  string s = to_string(r) + to_string(g) + to_string(b);
  int num = stoi(s);
  if (num % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    all = 0
    for a in A: all ^= a

    ans = [all ^ a for a in A]
    print(" ".join(map(str, ans)))



if __name__ == "__main__":
    main()


Measured memory_bytes: 121852
from collections import defaultdict

def main():
    N = int(input())
    a = list(map(int, input().split()))
    dct = defaultdict(int)

    for i in a:
        if dct[i] != 0:
            print("NO")
            return 
        else:
            dct[i] += 1
    
    print("YES")
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 33996