akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  ll n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];
  sort(all(a));
  a.erase(unique(all(a)), a.end());
  //rep(i, n) std::cout << a[i] << " ";
  int ans = a.size();
  if(ans%2 == 0) ans--;

  std::cout << ans << '\n';
}


Measured memory_bytes: 640
//It is made by ljh2000
//有志者，事竟成，破釜沉舟，百二秦关终属楚；苦心人，天不负，卧薪尝胆，三千越甲可吞吴。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#define lc root<<1
#define rc root<<1|1
using namespace std;
typedef long long LL;
const int MAXN = 200011;
int n,Q;
struct node{ LL set,add,sum; }a[MAXN*3];
inline void update(int root){ a[root].sum=a[lc].sum+a[rc].sum; }
inline int getint(){
    int w=0,q=0; char c=getchar(); while((c<'0'||c>'9') && c!='-') c=getchar();
    if(c=='-') q=1,c=getchar(); while (c>='0'&&c<='9') w=w*10+c-'0',c=getchar(); return q?-w:w;
}

inline void pushdown(int root,int l,int r){
	if(a[root].set==0 && a[root].add==0) return  ; if(l==r) return ;
	int mid=(l+r)>>1;
	if(a[root].set>0) {
		a[lc].set=a[rc].set=a[root].set;
		a[lc].sum=1LL*a[root].set*(mid-l+1); a[rc].sum=1LL*a[root].set*(r-mid);
		a[lc].add=a[rc].add=a[root].set=0;
	}

	if(a[root].add>0) {
		a[lc].add+=a[root].add; a[rc].add+=a[root].add;
		a[lc].sum+=1LL*a[root].add*(mid-l+1); a[rc].sum+=1LL*a[root].add*(r-mid);
		a[root].add=0;
	}
}

inline void modify(int root,int l,int r,int ql,int qr,LL val){
	pushdown(root,l,r);
	if(ql<=l && r<=qr) {
		a[root].set=val; a[root].add=0;
		a[root].sum=1LL*(r-l+1)*val;
		return ;
	}
	int mid=(l+r)>>1;
	if(ql<=mid) modify(lc,l,mid,ql,qr,val);
	if(qr>mid) modify(rc,mid+1,r,ql,qr,val);
	update(root);
}

inline void add(int root,int l,int r,int ql,int qr,LL val){
	pushdown(root,l,r);
	if(ql<=l && r<=qr) {
		a[root].sum+=1LL*val*(r-l+1);
		a[root].add+=val;
		return ;
	}
	int mid=(l+r)>>1;
	if(ql<=mid) add(lc,l,mid,ql,qr,val);
	if(qr>mid) add(rc,mid+1,r,ql,qr,val);
	update(root);
}

inline LL query(int root,int l,int r,int ql,int qr){
	if(ql<=l && r<=qr) return a[root].sum;
	pushdown(root,l,r); int mid=(l+r)>>1;
	if(qr<=mid) return query(lc,l,mid,ql,qr);
	else if(ql>mid) return query(rc,mid+1,r,ql,qr);
	return query(lc,l,mid,ql,qr)+query(rc,mid+1,r,ql,qr);
}

inline void dfs(int root,int l,int r){
	if(l==r) { printf("%lld\n",a[root].sum); return ; }
	pushdown(root,l,r); int mid=(l+r)>>1;
	dfs(lc,l,mid); dfs(rc,mid+1,r);
}

inline void work(){
	n=getint(); Q=getint(); int x; LL y; int l,r,mid,pos;
	while(Q--) {
		x=getint(); scanf("%lld",&y);
		if(x==1) { add(1,1,n,1,1,y); continue; }
		l=1; r=x; pos=0;
		while(l<=r) {
			mid=(l+r)>>1;
			if(1LL*query(1,1,n,mid,mid)*(x-mid+1)-query(1,1,n,mid,x) <= y) r=mid-1;
			else l=mid+1,pos=mid;
		}
		y-=1LL*query(1,1,n,pos+1,pos+1)*(x-pos)-query(1,1,n,pos+1,x);
		modify(1,1,n,pos+1,x, query(1,1,n,pos+1,pos+1) );
		if(y/(x-pos)) add(1,1,n,pos+1,x,y/(x-pos));
		if(y%(x-pos)) add(1,1,n,pos+1,pos+y%(x-pos),1);
	}
	dfs(1,1,n);
}

int main()
{
    work();
    return 0;
}
//有志者，事竟成，破釜沉舟，百二秦关终属楚；苦心人，天不负，卧薪尝胆，三千越甲可吞吴。


Measured memory_bytes: 9728
N_str=list(reversed(input()))
N=int(N_str[0])
if N==2 or N==4 or N==5 or N==7 or N==9:
    print("hon")
elif N==0 or N==1 or N==6 or N==8:
    print("pon")
elif N==3:
    print("bon")

Measured memory_bytes: 9120
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N], sumA[N];
  for(int i=0;i<N;++i) {
    cin>>A[i];
    sumA[i] = A[i];
  }
  for(int i=1;i<N;++i) {
    sumA[i] += sumA[i-1];
    sumA[i] %= mod;
  }
  ll ans = 0;
  for(int i=0;i<N;++i) {
    ans += A[i]*(sumA[N-1]-sumA[i]+mod)%mod;
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 6672
N = int(input())

def ask(n):
    print(n, flush=True)
    response = input().rstrip()[0]
    if response == 'V':
        exit()
    return response

def condition(start, middle, r_start, r_middle):
    if (middle-start)&1:
        return r_start == r_middle
    else:
        return r_start != r_middle

start = 0
end = N
r_start = ask(0)

for _ in range(19):
    middle = (start + end) // 2
    r_middle = ask(middle)
    if condition(start, middle, r_start, r_middle):
        end = middle
    else:
        start = middle
        r_start = r_middle



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

int main() {
	long long N, L0 = 2, L1 = 1, Ln;
	cin >> N;
	N = N - 1;
	for (int i = 0; i < N; i++) {
		Ln = L0 + L1;
		L0 = L1;
		L1 = Ln;

	}
	if (N == 0) {
		Ln = 1;
	}
	cout << Ln<<endl;

}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define endl '\n'
#define PI cos(-1)
#define ll long long
#define INF 0x3f3f3f3f
#define mod 1000000009
#define lowbit(abcd) (abcd & (-abcd))

int main()
{
    ll n, k, s;
    cin >> n >> k >> s;
    if (k == n)
    {
        for (int i = 1; i < n; i++)
            printf("%lld ", s);
        return !printf("%lld\n", s);
    }
    ll temp = s + 1;
    if (s == 1000000000)
        temp = s - 1;
    printf("%lld", temp);
    for (int i = 1; i <= k; i++)
        printf(" %lld", s);
    for (int i = 1; i <= n - k - 1; i++)
        printf(" %lld", temp);
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
main()
{
	int a, b, c, x, y, z;
	scanf("%d%d%d", &a, &b, &c);
	if (a>=b && a>=c)
	{
		x=a;
		if (b>=c)
		{
			y=b;
			z=c;
		}
		else
		{
			y=c;
			z=b;
		}
	}
	else if (b>=a && b>=c)
	{
		x=b;
		if (a>=c)
		{
			y=a;
			z=c;
		}
		else
		{
			y=c;
			z=a;
		}
	}
	else
	{
		x=c;
		if (b>=a)
		{
			y=b;
			z=a;
		}
		else
		{
			y=a;
			z=b;
		}
	}
	printf("%d\n", (x*10)+y+z);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/*
	Things to remember : check for coners n = 1, pass references instead
*/
/* -------------------------------Solution Sarted--------------------------------------*/

//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5
const int INF = 100000000000005; // 1e15 +5

void solve(){
	int n, ans = 0;
	cin >> n;
	vi a(n);
	scnarr(a, n);

	for(int i = 0; i < n; ++i){
		for(int j = i +1; j < n; ++j){
			for(int k = j +1; k < n; ++k){
				int f = a[i], s = a[j], t = a[k];
				if(f + s > t and s + t > f and t + f > s and s != f and f != t and t != s){
					ans++;
				}
			}
		}
	}

	cout << ans << endl;
	
}

signed main()
{
	faster;
#ifndef ONLINE_JUDGE
	freopen("ip.txt", "r", stdin);
	freopen("op.txt", "w", stdout);
#endif
	// int t; cin >> t; while(t--)
		solve();
	return 0;
}


//Author : Ankit Raj
//Problem Link :

/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs  
dfs
fenwik - BIT
binary_search
segment_tree
*/
	

Measured memory_bytes: 3656
n = int(input())

p1 = 0
p2 = 0

for i in range(n):
        str = input()
        i = str.find(" ")
        str1 = str[: i]
        str2 = str[i+1 :]

        if str1 > str2:
                p1 += 3
        elif str1 < str2:
                p2 += 3
        else:
                p1 += 1
                p2 += 1
        
print("%d %d" % (p1, p2))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
intl calc(intl a){
    a++;
    intl ans = (a / 2 % 2);
    //debug(a);
    if(a % 2) ans ^= (a - 1);
    //debug(ans);
    return ans;
}

signed main(){
    cout << fixed << setprecision(10);
    intl a,b;
    cin >> a >> b;
    cout << (calc(a - 1) ^ calc(b)) << endl;
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;


int main()
{		
		
	  string s,t;
	  cin>>s>>t;
	  ll c=0;
	  for(ll i=0;i<3;i++)
	  {
	  	if(s[i]==t[i])
	  		c++;
	  }
	  cout<<c;



	   


}
    
 
    
    


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    h,w=parseMap(split(readline()))
    c=[readline() for i in 1:h]
    for i in 1:2h
        for j in 1:w
            print(c[(i+1)÷2][j])
        end
        print("\n")
    end
end
main()

Measured memory_bytes: 168348
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>


int main() {

    int N;
    std::cin >> N;

    std::vector<int> hs;

    for (int i = 0; i < N; i++) {
        int h;
        std::cin >> h;
        hs.push_back(h);
    }

    int cnt = 1;

    for (int i = 1; i < N; i++) {

        int h = hs[i];

        bool ok = true;

        for (int j = 0; j < i; j++) {

            if (hs[j] > h) {
                ok = false;
                break;
            }
        }

        if (ok) {
            cnt += 1;
        }

    }

    std::cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

ll gcd(ll a,ll b){
    if(a%b==0){return b;}
    return gcd(b,a%b);
}



int main(){
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        ans+=b-1;
    }
    cout<<ans<<endl;
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int x, y, z;
    cin >> x >> y >> z;

    cout << z << ' ' << x << ' ' << y << "\n";
    return 0;
}

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

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> P;
    vector<int> Q;
    vector<int> R;
    for (int i = 0; i < A; ++i) {int t;  cin >> t;  P.push_back(t);}
    for (int i = 0; i < B; ++i) {int t;  cin >> t;  Q.push_back(t);}
    for (int i = 0; i < C; ++i) {int t;  cin >> t;  R.push_back(t);}

    sort(P.begin(), P.end());
    sort(Q.begin(), Q.end());
    sort(R.begin(), R.end());
    reverse(R.begin(), R.end());

    vector<int> apples;
    for (int i = A - 1; i >= A - X; --i) apples.push_back(P[i]);
    for (int i = B - 1; i >= B - Y; --i) apples.push_back(Q[i]);

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

    int itr = 0;
    for (int i = 0; i < min(C, X + Y); ++i) {
        if (apples[itr] < R[i]) {
            apples.push_back(R[i]);
            ++itr;
        }
    }

    long long ans = 0;
    for (int i = itr; i < X + Y + itr; ++i) {
        ans += apples[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3572
N=int(input())
W=list(map(int,input().split()))

min_diff = 10000
for t in range(N):
    s1,s2=0,0
    for i in range(N):
        if i <= t:
            s1+=W[i]
        else:
            s2+=W[i]
    diff = abs(s1-s2)
    if diff < min_diff:
        min_diff = diff
print(min_diff)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N,M;
map<int, int> D;
int main() {
    cin >> N;
    for (int i = 0; i < N; i++){
        int x;
        cin >> x;
        D[x]++;
    }
    cin >> M;
    for (int i = 0; i < M; i++){
        int x;
        cin >> x;
        D[x]--;
    }
    for (const auto &val : D){
        if (val.second < 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
   return 0;


 }


Measured memory_bytes: 9600
N,K = gets.split.map(&:to_i)
v = gets.split.map(&:to_i)
T = [K, N].min
res = 0

(T+1).times do |a|
  (0..(T-a)).each do |b|
    h = v[0...a]+v[(N-b)...N]    
    h.sort!
    sum = h.inject(&:+) || 0
    [K-a-b, h.length].min.times do |i|
      break if h[i] >= 0
      sum -= h[i]
    end
    res = sum if sum > res
  end
end

puts res


Measured memory_bytes: 1916
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n * 3);
    rep(i, 3 * n) cin >> v[i];

    vector<ll> l(3 * n);
    ll l_sum = accumulate(v.begin(), v.begin() + n, 0ll);
    PQ_ASK lq;
    for (int i = 0; i < n; i++) lq.push(v[i]);
    l[n - 1] = l_sum;
    for (int i = n; i < n * 2; i++) {
        lq.push(v[i]);
        l_sum += v[i];
        ll mi = lq.top();
        l_sum -= mi;
        lq.pop();
        l[i] = l_sum;
    }

    vector<ll> r(3 * n);
    ll r_sum = accumulate(v.begin() + 2 * n, v.end(), 0ll);
    priority_queue<ll> rq;
    for (int i = 3 * n - 1; i >= 2 * n; i--) rq.push(v[i]);
    r[2 * n] = r_sum;
    for (int i = 2 * n - 1; i >= n; i--) {
        rq.push(v[i]);
        r_sum += v[i];
        ll ma = rq.top();
        r_sum -= ma;
        rq.pop();
        r[i] = r_sum;
    }
    ll ans = -INF;
    for (int i = n - 1; i < 2 * n; i++) {
        ll now = l[i] - r[i + 1];
//        printf("%lld %lld %lld\n", l[i], r[i + 1], now);
        cmax(ans, now);
    }
    cout << ans << endl;

}


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

int main()
{
    int n; cin >> n;
    vector<int> x(n); rep(i,n) cin >> x[i];
    int ans = 1000000;
    for(int i = 1; i <= 100; i++) {
    int tmp = 0;
        rep(j,n) {
            tmp += (x[j] - i)*(x[j] - i);
        }
        ans = min(ans,tmp);
    }    
    cout << ans << endl;
}

Measured memory_bytes: 3600
use std::io::{Read, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut iter = input.split_whitespace();


    let r: usize = iter.next().unwrap().parse().unwrap();
    let c: usize = iter.next().unwrap().parse().unwrap();

    let table : Vec<Vec<i32>> = (0..r).map(|_| (0..c).map(|_| iter.next().unwrap().parse().unwrap()).collect() ).collect();

    let mut csum: Vec<i32> = vec![0; r];
    let mut rsum: Vec<i32> = vec![0; c];
    let mut sum: i32 =0;

    for (i,arr) in table.iter().enumerate() {
        for (j, a) in arr.iter().enumerate() {
            csum[i] += *a;
            rsum[j] += *a;
            sum += *a;
        }
    }

    for (i,arr) in table.iter().enumerate() {
        for a in arr {
            out.write_fmt(format_args!("{} ", a)).unwrap();
        }
        out.write_fmt(format_args!("{}\n", csum[i])).unwrap();
    }
    for a in rsum {
        out.write_fmt(format_args!("{} ", a)).unwrap();
    }
    out.write_fmt(format_args!("{}\n", sum)).unwrap();
}



Measured memory_bytes: 5048
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

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

  int h1,h2,m1,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << max(0, (h2 - h1) * 60 + (m2 - m1) - k) << endl;


}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){


	int H, N; cin >> H >> N;
	int sum = 0;
	REP(i,N){ 
		int A; cin >> A;
		sum += A;
	}

	if(sum >= H) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;

}


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

const int N = 1e5+7, K = 61;
long long v[N], d[N], p[N][K], ans[N];

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

    int n;
    cin>>n;

    vector<pair<int, int>> v;
    for (int i=0; i<n; i++) {
        int x;
        cin>>x;
        v.push_back({x, i});
    }
    sort(v.begin(), v.end());

    int ans = 0;
    for (int i=0; i<n; i++)
        if (v[i].second%2 != i%2)
            ans++;
    cout<<ans/2<<endl;
}


Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():

    N, K = [int(i) for i in input().strip().split()]
    hights = [int(i) for i in input().strip().split()]
    min_costs = [10000*N] * N
    min_costs[0] = 0

    for i in range(N):
        for j in range(1, K+1):
            if j <= i:
                min_costs[i] = min(
                    min_costs[i - j] + abs(hights[i] - hights[i - j]), min_costs[i])
            else:
                break
    return min_costs[-1]


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 52320
#include <cstdio>
using namespace std;
int main(void){
    int n, m, c;
    scanf("%d %d %d\n", &n, &m, &c);
    int b[m];
    for(int i=0; i<m; i++) scanf("%d", &b[i]);
    int counter = 0;
    for(int i=0; i<n; i++) {
        int a[m];
        for(int j=0; j<m; j++) scanf("%d", &a[j]);
        int x = c;
        for (int j=0; j<m; j++) x += a[j] * b[j];
        if(x > 0) counter++;
    }
    printf("%d\n", counter);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  string s;
  cin >> s;
  int a = 0, b = 0, c = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == 'a') a++;
    if (s.at(i) == 'b') b++;
    if (s.at(i) == 'c') c++;
  }
  if (a == 0 || b == 0 || c == 0) No();
  else Yes();
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"io"
	"os"
	"strconv"
	"fmt"
)

var (
	nstr   func() string
	stdout *bufio.Writer
)

func init() {
	nstr = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func main() {
	defer stdout.Flush()
	n := nint()
	k := nint()
	aList := getIntSlice(n)

	sumList := make([]int, 0)
	for i:=0;i<n ;i++  {
		for j:=i+1;j<n+1 ;j++  {
			sum := 0
			for tmp:=i;tmp<j ;tmp++  {
				sum += aList[tmp]
			}
			sumList = append(sumList, sum)
		}
	}
	var (
		ans int
		count int
	)
	for i:=40; i>=0; i--{
		checkNum := 1 << uint(i)
		for j:=0;j<len(sumList) ;j++  {
			logical := checkNum & sumList[j]
			if logical !=0{
				count ++
			}
		}
		if count >= k{
			ans += checkNum
			tmp := make([]int, 0)
			for m:=0;m<len(sumList) ;m++  {
				if sumList[m] &( 1 << uint(i)) !=0{
					tmp = append(tmp, sumList[m])
				}

			}
			sumList =  tmp
		}
		count = 0

	}
	fmt.Println(ans)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func nint64() int64 {
	i, err := strconv.ParseInt(nstr(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func nint() int {
	return int(nint64())
}

func getIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = nint()
	}
	return b
}

func getStringSlice(n int) []string {
	b := make([]string, n)
	for i := 0; i < n; i++ {
		b[i] = nstr()
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func bin(i int, prefix bool) string {
	i64 := int64(i)

	if prefix {
		return "0b" + strconv.FormatInt(i64, 2)
	} else {
		return strconv.FormatInt(i64, 2)
	}
}

func strReverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}

	return string(runes)
}



Measured memory_bytes: 14592
#include <iostream>
#include <utility>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
using namespace std;
int main()
{
	while(true){
		int ans,tmp;cin>>ans;
		if(ans==0)break;
		for(int i=0;i<9;i++){
			cin>>tmp;ans-=tmp;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    string a;
	while( getline( cin , a ) ){
		ll cnt = 0;
		ll ans = -1;
		for( ll i = 0 ; i < a.length() ; i++ ){
			if( a[i] == 'A' || a[i] == 'T' || a[i] == 'C' || a[i] == 'G' ){
				cnt++;
			} 
			else{
				ans = max( ans , cnt );
				cnt = 0;
			} 
		}
		ans = max( ans , cnt );
		cout<<ans<<'\n';
	} 
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << ((a > b) ? a - 1 : a);
	return 0;
}

Measured memory_bytes: 256
n = int(input())

a = list(map(int, input().split()))

a.sort()

tmp=0
cnt=0

for bangou in range(1,n+1):
    if tmp<len(a):
        while a[tmp]==bangou:
            cnt+=1
            tmp+=1
            if tmp==len(a):
                break
    print(cnt)
    cnt=0



Measured memory_bytes: 32336
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;



int main(void)
{
    int n,d;
    cin >> n >> d;

    vector<vector<double>> X(n,vector<double>(d));

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

    int count=0;

    for(int i = 0; i < n;i++){
        for(int j = i+1;j<n;j++)
        {
            double distance=0;

            for(int k = 0;k < d;k++)
            {
                distance+= (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }

            distance=sqrt(distance);

            if(distance- floor(distance) == 0)
            {
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  bool b = false;
  for(int i = 0; i < a.length(); i++) {
    if (a[i] == '9') {
      b = true;
    }
  }
  if (b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# input
n, m = map(int, input().split())
data = [[int(i), 1] for i in input().split()]
for i in range(m):
  b, c = map(int, input().split())
  data.append([c, b])
data.sort(key=lambda x:x[0], reverse=True)

# main
ans = 0
cnt = n
for i in range(len(data)):
  if cnt >= data[i][1]:
    ans += data[i][0] * data[i][1]
    cnt -= data[i][1]
  else:
    ans += data[i][0] * cnt
    cnt -= data[i][1]
  if cnt <= 0:
    break
    
# output
print(ans)

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

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

    vector<ll> p(n);
    NREP() cin >> p[i];

    ll ans = 0;

    for (int i = 1; i < n-1; ++i) {
        vector<ll> tmp(3);
        tmp[0] = p.at(i-1);
        tmp[1] = p.at(i);
        tmp[2] = p.at(i+1);
        sort(ALL(tmp));

        if (tmp[1] == p[i]) ans++;
    }


    MSG(ans)
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws Exception {
		int x = Integer.valueOf(inp());
		System.out.println(x * x * x);

	}

	private static String inp() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

}

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

int n, res;
char t[5][22], ans[5][302];

bool check(int idx){
  for(int i = 0; i < 5; i++){
    for(int j = 0; j < n; j++){
      if(t[i][j] == 'X' && ans[i][idx + j] != '.'){
        return false;
      }
    }
  }
  return true;
}

void draw(int idx, char ch){
  for(int i = 0; i < 5; i++){
    for(int j = 0; j < n; j++){
      if(t[i][j] == 'X'){
        ans[i][idx + j] = ch;
      }
    }
  }
}

void dfs(int idx, int cnt){
  if(cnt == 10){
    res = min(res, idx - 1);
    return;
  }
  if(idx > cnt * n || idx == res){
    return;
  }

  dfs(idx + 1, cnt);

  if(check(idx)){
    draw(idx, '0' + cnt);
    dfs(idx + 1, cnt + 1);
    draw(idx, '.');
  }
}

int main(){
  while(cin >> n, n){
    for(int i = 0; i < 5; i++){
      cin >> t[i];
    }
    memset(ans, '.', sizeof(ans));
    res = n * 10 - n;
    dfs(0, 0);
    cout << res + n << endl;
  }
}

Measured memory_bytes: 876
N = int(input())
M = 10**9 + 7

dp = [
    [[[1 if i==0 else 0 for i in range(N-2)] for j in range(4)] for k in range(4)] for l in range(4)
]

dp[0][1][2][0] = 0
dp[0][2][1][0] = 0
dp[1][0][2][0] = 0

for m in range(N-3):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    dp[j][k][l][m+1] += dp[i][j][k][m]
                    dp[0][1][2][m+1] = 0
                    dp[0][2][1][m+1] = 0
                    dp[1][0][2][m+1] = 0

                    if (i==0):
                        for o in range(4):
                            dp[o][1][2][m+1] = 0
                            dp[1][o][2][m+1] = 0

total = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            total += dp[i][j][k][N-3]

total %= M
print(total)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i=1;
		while(true){
			int x=sc.nextInt();
			if(x==0)break;
			System.out.println("Case "+i+": "+x);
			i++;
		}
	}
}

Measured memory_bytes: 41940
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, K, p[1005];
  cin >> N >> K;
  rep(i,N) cin >> p[i];
  sort(p, p+N);
  int ans = 0;
  rep(i,K) ans += p[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3156
//?????????????????????????????????????????????????????????

#include<iostream>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;

int main(){
	int W;
	int H;
	int C;
	int i;
	cin >> W >> H >> C;

	for (i = 1000; i > 1; i--)
	{
		if (W % i== 0 && H % i == 0)
		{
			break;

		}
	}




	cout << W/i * H/i * C<< endl;


}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}

int main(){
	IOS;
	cout.precision(30) ;
	int n ; cin >> n ;
	vll a(n) ; for(int i = 0 ; i < n ; i++) cin >> a[i] ;
	a[0]-- ;
	for(int i = 1 ; i < n ; i++){
		if(a[i] - 1 >= a[i - 1]) a[i]-- ;
		else if(a[i] < a[i - 1]) return cout << "No" << endl , 0 ;
	}
	cout << "Yes" << endl;
		
	return 0;
}


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

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

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

  if (S.at(0) == S.at(1) && S.at(1) != S.at(2) && S.at(2) == S.at(3)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
score_list = []
for i in range(1, N+1):
  town, score_i = map(str, input().split())
  list_i = [i]
  list_i.append(town)
  list_i.append(-int(score_i))

  score_list.append(list_i)

score_list = sorted(score_list, key=lambda x: (x[1],x[2]))

for score in score_list:
  print(score[0])

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }


const string YES = "Yes";
const string NO = "No";

map<char,char> toS;
map<char,char> toT;

void func(std::string S, std::string T){

    REP(i,0,min(S.size(),T.size())){
        char s = S[i];
        char t = T[i];

        if(toS.count(t)==0){
            toS[t] = s;
        }
        else{
            if(toS[t] != s){
                cout<<"No"<<endl;
                return;
            }
        }
        if(toT.count(s)==0){
            toT[s] = t;
        }
        else{
            if(toT[s] != t){
                cout<<"No"<<endl;
                return;
            }
        }
    }

    cout<<"Yes"<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    func(S, T);
    return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;
template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}
template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};

/* ここからコード開始 */

int main(){
  kyopro;
  ll N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  ll l, r;
  ll sum{};
  vector<ll> add(N);
  add.at(0) = 0;
  rep(i, 1, N){
    if(S.substr(i-1,2) == "AC") sum++;
    add.at(i) = sum;
  }
  rep(i, 0, Q){
    cin >> l >> r;
    cout << add.at(r-1) - add.at(l-1) << rt;
  }
}

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

int main()
{
	long long a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	
	if (v <= w)
	{
		cout << "NO" << endl;
		return 0;
	}
	
	if (a < b)
	{
		while(t > 0)
		{
			a += v;
			b += w;
			
			if (a >= b)
			{
				cout << "YES" << endl;
				return 0;
			}
			
			t--;
		}
	}
	else
	{
		while(t > 0)
		{
			a -= v;
			b -= w;
			
			if (a <= b)
			{
				cout << "YES" << endl;
				return 0;
			}
			
			t--;
		}
	}
	
	cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 3632
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int R,G;
	cin >> R >> G;
	cout << 2*G-R << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 998244353;
const ll INF = (ll) 1e15;

pll X[200005];
ll P[200005];

struct BinaryIndexTree {
    BinaryIndexTree(int n)
            : mN(n) {
        mPow = 1;
        while (mPow < n)
            mPow <<= 1;
        node.resize(n + 1);
        REP(i, n + 1) {
            node[i] = 0;
        }
    }

    ~BinaryIndexTree() {
        node.resize(0);
    }

    //! 1-index get
    ll sum(int index) {
        ll sum = 0;
        for (int i = index; i > 0; i -= i & (-i))
            sum += node[i];
        return sum;
    }

    //! 1-index add
    void add(int index, ll value) {
        for (int i = index; i <= mN; i += i & (-i))
            node[i] += value;
    }

    int lowerBound(ll value) {
        if (value <= 0)
            return 0;
        int x = 0;
        for (int k = mPow; k > 0; k >>= 1) {
            if (x + k <= mN && node[x + k] < value) {
                value -= node[x + k];
                x += k;
            }
        }
        return x + 1;
    }

    vector<ll> node;
    ll mN;
    ll mPow;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> X[i].first >> X[i].second;
    }
    sort(X, X + N, [](pll a, pll b) { return a.first < b.first; });
    vector<ll> y;
    REP(i, N) {
        y.push_back(X[i].second);
    }
    sort(y.begin(), y.end());
    P[0] = 1;
    REP(i, N) {
        P[i + 1] = (P[i] * 2LL) % MOD;
    }

    ll ans = 0;
    BinaryIndexTree bit(N + 5);
    REP(i, N) {
        ll yi = lower_bound(y.begin(), y.end(), X[i].second) - y.begin();
        ll ld = bit.sum(yi);
        ll lt = i - ld;
        ll rd = yi - ld;
        ll rt = N - 1 - (ld + lt + rd);
        bit.add(yi + 1, 1);

        ll t[4] = {ld, lt, rt, rd};

        ans += P[N - 1] + (P[N - 1] - 1);
        REP(j, 4) {
            ll m = P[t[j] + t[(j + 1) % 4]] - 1 - (P[t[j]] - 1);
            ans = (ans + MOD - (m % MOD)) % MOD;
        }
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8176
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var S = new char[N, N];
            for (int i = 0; i < N; i++)
            {
                var input = Read();
                for (int j = 0; j < N; j++)
                {
                    S[i, j] = input[j];
                }
            }
            var cnt = 0;
            for (int i = 0; i < N; i++)
            {
                var A = 0;
                var B = i;
                var tmp = new char[N, N];
                for (int j = 0; j < N; j++)
                {
                    for (int k = 0; k < N; k++)
                    {
                        var y = (j + A) % N;
                        var x = (k + B) % N;
                        tmp[y, x] = S[j, k];
                    }
                }
                var suc = true;
                for (int j = 0; j < N; j++)
                {
                    for (int k = j; k < N; k++)
                    {
                        if (tmp[j, k] != tmp[k, j]) { suc = false; break; }
                    }
                    if (!suc) break;
                }
                if (suc) cnt++;
            }

            Console.WriteLine(cnt * N);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 28000
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> b(n - 1), a(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> b[i];
  }
  a[0] = b[0];
  for (int i = 1; i < n - 1; i++) {
    a[i] = min({b[i - 1], b[i]});
  }
  a[n - 1] = b[n - 2];
  cout << accumulate(a.begin(), a.end(), 0);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Author : Pham Ngoc Minh - 12 Tin - CTB
// The Way To Progress Is To Constantly Try
using namespace std;
#define f first
#define s second
#define ll long long
#define fl float
#define db double
#define ii pair<ll,ll>
#define pii pair<ii,ii>
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define oo 10000000000001
#define ooo -1000000000001
#define bost  ios_base::sync_with_stdio(false); cin.tie(0);
int n;
int main()
{
    bost
    cin>>n;
    if(1<=n && n<10){
        cout<<n;
        return 0;
    }
    if(10<=n && n<100){
        cout<<9;
        return 0;
    }
    if(100<=n && n<1000){
        cout<<9+n-100+1;
        return 0;
    }
    if(1000<=n && n<10000){
        cout<<9+900;
        return 0;
    }
    if(10000<=n && n<100000){
        cout<<9+900+n-10000+1;
    }
    if(n==100000){
        cout<<9+900+90000;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
N, K = map(int,input().split())
h = []
INF = 2e9
for i in range (N):
  a = int(input())
  h.append(a)
h.sort()
ans = INF
for i in range (N-K+1):
  ans = min(ans,h[i+K-1]-h[i])
print(ans)


Measured memory_bytes: 7384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = scanner.nextInt();
        }

        for (int i = 0; i < 32; ++i) {
            int count = 0;
            for (int j = 0; j < n; ++j) {
                if (a[j] % 2 == 1) {
                    count++;
                }
                a[j] /= 2;
            }
            if (!(count == 0 || count == (n - count) * 2)) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");

    }
}


Measured memory_bytes: 49828