akhauriyash/Code-Regression huggingface dataset:
class Dice:
    val=[]
    def __init__(self, lst):
        self.val.append(lst[0])
        self.val.append(lst[1])
        self.val.append(lst[2])
        self.val.append(lst[3])
        self.val.append(lst[4])
        self.val.append(lst[5])

    def rotate(self,dir):
        if dir=="N":
            tmp=self.val[0]
            self.val[0]=self.val[1]
            self.val[1]=self.val[5]
            self.val[5]=self.val[4]
            self.val[4]=tmp
        if dir=="E":
            tmp=self.val[0]
            self.val[0]=self.val[3]
            self.val[3]=self.val[5]
            self.val[5]=self.val[2]
            self.val[2]=tmp
        if dir=="S":
            tmp=self.val[0]
            self.val[0]=self.val[4]
            self.val[4]=self.val[5]
            self.val[5]=self.val[1]
            self.val[1]=tmp
        if dir=="W":
            tmp=self.val[0]
            self.val[0]=self.val[2]
            self.val[2]=self.val[5]
            self.val[5]=self.val[3]
            self.val[3]=tmp

def int_to_dir(n):
    if n==0:
        return "N"
    if n==1:
        return "E"
    if n==2:
        return "S"
    if n==3:
        return "W"
    

x = list(map(int,input().split()))
q = int(input())

D = Dice(x)

import random 

for i in range(q):
    a,b=map(int,input().split())
    count=0
    while True:
        D.rotate(int_to_dir(random.randint(0,4)))
        #count+=1
        if D.val[0]==a and D.val[1]==b:
            
            print(D.val[2])
            break



Measured memory_bytes: 8188
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int a, b; cin >> a >> b;
    int ans = 0;

    for(int i=a; i<=b; ++i){
        string s = to_string(i);
        string t = s;
        reverse(t.begin(), t.end());
        if(s == t) ++ans;
    }
    cout << ans << endl;

    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const unsigned long long h = 1e9+7;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M)%M;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s.length();
    vector<ll> a(2020,0);
    a[0]++;
    ll m = 2019;
    ll cnt = 0;
    rep(i,n){
        cnt += (s[n-i-1]-'0')*RepeatSquaring(10,i,m);
        cnt %= m;
        a[cnt]++;
    }
    ll ans = 0;
    rep(i,2020){
        ans += a[i]*(a[i]-1)/2;
    }
    PRINT(ans);
}    


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
const ll mod = 998244353;
ll power(ll x, ll y, ll p) {
	ll res = 1ll;
	x = x % p;
	while (y) {
		if (y & 1ll)res = (res * x) % p;
		y = y >> 1ll;
		x = (x * x) % p;
	}
	return res;
}
signed main(){
  int n,m;
  cin>>n>>m;
  int r=0;
  if(n*2<=m)r=n+(m-n*2)/4;
  else r=m/2;
  cout<<r;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
 
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}


void solve()
{
  si s;
  rep(i,0,3)
  {
    ll a;
    cin>>a;
    s.insert(a);
  }
  cout<<s.size();
}

int main()
{
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
}

Measured memory_bytes: 3608
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		int sum = 0;
		for (int i=0; i<N; i++) {
			int a = sc.nextInt();
			sum += a;
			list.add(a);
		}
		int ave = new BigDecimal((double)sum/N).setScale(0,  BigDecimal.ROUND_HALF_UP).intValue();
		int cost = 0;
		for (int v: list) cost += (v-ave)*(v-ave);
		System.out.println(cost);
		sc.close();
	}

}


Measured memory_bytes: 10444
Residents = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for l in range(n):
    b ,f ,r ,v  = list(map(int,input().split()))
    Residents[b-1][f-1][r-1] += v
for k in range(4):
    for j in range(3):
        print(' '+ ' '.join(map(str,Residents[k][j])))
    if (k ==3): break
    print('####################') 


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  const int INF = 100000000;
  int n,m,x;cin >>n>>m>>x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  for(int i=0;i<n;++i){
    cin >> c[i];
    for(int j=0;j<m;++j)cin >> a[i][j];
  }
  int min_out=INF;
  for (int bit=0;bit < (1<<n); ++bit) {
    int tmp_c = 0;
    vector<int> tmp(m,0);
    for (int i = 0; i < n ; ++i) {
      if (bit & (1<<i)) {
        for(int j=0;j<m;++j) tmp[j] += a[i][j];
        tmp_c += c[i];
      }
    }
    if(x<=*min_element(tmp.begin(),tmp.end())) min_out = min(min_out,tmp_c);
  }
  if(min_out==INF){
    cout << -1 << endl;
  } else {
    cout << min_out << endl;
  }
  return 0;
}


Measured memory_bytes: 3600
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(n)]

ans = 0
for i in range(n):
        tmp = 0
        for j in range(m):
                tmp += a[i][j]*b[j]
        if tmp+c >0:
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    i64 N;
    cin >> N;
    i64 ans = 1e17;
    for(i64 i = 1; i <= 1e7; i++) {
        if(N % i == 0) {
            ans = min(ans, i + N / i - 2);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  char x, y;
  cin >> x >> y;
  int a = x - 'A';
  int b = y - 'A';

  if(a > b) {
    cout << ">";
  } else if(a < b) {
    cout << "<";
  } else {
    cout << "=";
  }


  return 0;
}



Measured memory_bytes: 256
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    int n;
    cin >> n;
    vector<int>h(n);
    for(int i=0;i<n;i++)cin >> h[i];
    vector<int>f(n,0);
    int ans=0;
    while(1){
        int flag=0;
        for(int i=0;i<n;i++){
            if(h[i]!=f[i]){
                f[i]++;
                flag=1;
            }
            else if(h[i]==f[i] && flag==1){
                ans++;
                flag=0;
            }
        }
        if(flag==1)ans++;
        bool g=true;
        for(int i=0;i<n;i++){
            if(h[i]!=f[i])break;
            if(i==n-1)g=false;
        }
        if(g==false)break;
    }
    cout << ans << endl;

}

int main(){
    solve();
    return 0;
}




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

int main(){
	string a,b;
	cin >> a>> b;
int l = a.size();
int p = b.size()-1;

	if(b.substr(0,p) == a){
		cout << "Yes" <<endl;
	}
	else{
		cout << "No" <<endl;
	}

}

Measured memory_bytes: 3628
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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 end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    double ans=0;
    in >> N;
    vector<double> A(N);
    
    REP(i,N){
        in >> A[i];
    }

    REP(i,N){
        ans = ans + 1.0/A[i];
    }

    ans = 1.0/ans;

    out << ans << endl;


 

 

}

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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max({a * c, a * d, b * c, b * d}) << endl;
  return 0;
}

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

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )

#define INF 1000000000

void swap(int* x, int *y)
{
	int t;

	t = *x;
	*x = *y;
	*y = t;
}

int binary_search(int p[], int n, int key)
{
	int left, right, middle;

	left = 0;
	right = n-1;


	while (left <= right)
	{
		middle = (left + right) / 2;

		if (p[middle] == key)
			return middle;
		else if (p[middle] > key)
		{
			right = middle - 1;
		}
		else if (p[middle] < key)
		{
			left = middle + 1;
		}
	}

	return -1;

}

void bubble_sort(int p[], int n)
{
	int i, j;

	for (i = 0; i < n-1; i++)
	{
		for (j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[i], &p[i + 1]);
		}
	}
}

int main()
{
	int a, b,c;
	
	scanf("%d%d%d", &a, &b, &c);

	if (a > b)
		swap(&a, &b);

	if (a > c)
		swap(&a, &c);

	if (b > c)
		swap(&b, &c);

	printf("%d %d %d\n", a, b, c);

}


Measured memory_bytes: 2144
// AtCoder_175A. Rainy Season
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define FIO         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ALL(v)      v.begin(), v.end()
#define PB          push_back
#define MP          make_pair
#define UB          upper_bound
#define LB          lower_bound
#define PI          2*acos(0.0)
#define MOD         1000000007
#define GCD(a, b)   __gcd(a, b)
#define LCM(a, b)   ((a)*(b)) / GCD(a, b)
#define INPUT       freopen("input.txt", "r", stdin);
#define OUTPUT      freopen("output.txt", "w", stdout);
#define PRINT(a)    for(auto i : a) cout << i << " "; cout << endl;
#define PRINTS(s)   for(auto i=s.begin(); i!=s.end(); i++) cout << *i << " "; cout << endl;
#define PRINTM(m)   for(auto i=m.begin(); i!=m.end(); i++) cout << i->first << " " << i->second << endl;

int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
string lowerCase = "abcdefghijklmnopqrstuvwxyz";
string upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/// Graph moves
const int fxKing[] = {+1,+1,+0,-1,-1,-1,+0,+1}; /// King's move
const int fyKing[] = {+0,+1,+1,+1,+0,-1,-1,-1}; /// King's move
const int fxKnight[] = {+2,+1,-1,-2,-2,-1,+1,+2}; /// Knight's move
const int fyKnight[] = {+1,+2,+2,+1,-1,-2,-2,-1}; /// Knight's move

ll q, t, a, b, c, d, m, n, k;
ll cnt, Mn, Mx, sum, sum1, sum2, ck;
ll arr1[1000], arr2[1000];

map <ll, ll> mp1, mp2;
set <ll> st1, st2;
vector <ll> vec1, vec2;
string str1, str2, str3;

int main()
{
    FIO;
    t = 1;
    string s;
    while(t--)
    {
        cin >> s ;
        int cnt = 0;
        int ans = 0;
        for(int i=0; i<s.size(); i++){
            if(s[i]=='R') cnt++;
            else{
                ans = max(ans, cnt);
                cnt = 0;
            }
        }
        ans = max(ans, cnt);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3668
s = list(map(int, input().split()))
N = s[0]
A = s[1]
B = s[2]

if (B - A) % 2 == 0:
  print((B - A) // 2)
else:
  print(min(A - 1,N - B) +  1 + (B - A - 1) // 2)

Measured memory_bytes: 38356
#include <bits/stdc++.h>
using namespace std;
int n,i,x,ap[110],ma,mi;
int main()
{
  //  freopen("a.in","r",stdin);
 //   freopen("a.out","w",stdout);
    scanf("%d",&n);
    for(i=1; i<=n; ++i)
    {
        scanf("%d",&x);
        ap[x]++;
        ma=max(ma,x);
    }
    mi=(ma+1)/2;
    for(i=1; i<mi; ++i)
        if(ap[i]!=0)
        {
            printf("Impossible\n");
            return 0;
        }
    for(i=mi+1; i<=ma; ++i)
        if(ap[i]<2)
        {
            printf("Impossible\n");
            return 0;
        }
    if(ma%2==0&&ap[mi]!=1)
    {
        printf("Impossible\n");
        return 0;
    }
    if(ma%2==1&&ap[mi]!=2)
    {
        printf("Impossible\n");
        return 0;
    }
    printf("Possible\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
#define int long long

int P(int x, int y){

   if(y==0) return 1;
   if(y%2==0){
      return P(x*x, y/2);
   }else{
      return P(x, y-1)*x;
   }
}

signed main(){

   int N, K;
   cin>> N>> K;

   cout<< K*P(K-1, N-1)<< endl;

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <cassert>
#include <climits>
#include <cassert>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n) - 1;i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) ((v).begin(), (v).end())
#define F first
#define S second

typedef long long int tint;

const int MOD = 998244353;
tint fact[300010];
tint inv[300010];
tint factinv[300010];

tint choose(tint n, tint k) {
	return (((fact[n] * factinv[k]) % MOD) * factinv[n - k]) % MOD;
}

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

	tint n, a, b, k; cin >> n >> a >> b >> k;
	
	fact[0] = 1;
	forsn(i, 1, n + 1) fact[i] = (fact[i - 1] * i) % MOD;
	inv[0] = 1; inv[1] = 1;
	forsn(i, 1 + 1, n + 1) {
		inv[i] = (MOD - (MOD/i) * inv[MOD%i] % MOD) % MOD;
	}
	factinv[0] = 1; factinv[1] = 1;
	forsn(i, 1 + 1, n + 1) {
		factinv[i] = (factinv[i - 1] * inv[i]) % MOD;
	}
	
	tint res = 0;
	forn(p, n + 1) if (k >= p * a && !((k - p * a) % b)) {
		tint q = (k - p * a) / b;
		if (q <= n) {
			res = (res + (choose(n, p) * choose(n, q)) % MOD) % MOD;
		}
	}
	cout << res << endl;
}



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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   vector<vector<int>> adj(N);
   for (int i = 0; i < N - 1; ++i) {
      int v, u;
      cin >> v >> u;
      --v, --u;
      adj[v].emplace_back(u);
      adj[u].emplace_back(v);
   }
   int ans = 0;
   for (int i = 0; i < N; ++i) {
      ans += int(adj[i].size()) & 1;
   }
   ans >>= 1;
   int low = 1, high = N;
   while (low < high) {
      int mid = (low + high) >> 1;
      int cans = 0;
      function<int(int, int)> dfs = [&](int v, int p) {
         multiset<int> nxts;
         for (int u : adj[v]) {
            if (u != p) {
               nxts.emplace(dfs(u, v) + 1);
            }
         }
         vector<int> bigs;
         while (nxts.size()) {
            int x = *(--nxts.end());
            nxts.erase(nxts.find(x));
            auto it = nxts.upper_bound(mid - x);
            if (it == nxts.begin()) {
               bigs.emplace_back(x);
            } else {
               nxts.erase(--it);
               cans++;
            }
         }
         reverse(bigs.begin(), bigs.end());
         while (bigs.size() && bigs.back() == mid) {
            cans++;
            bigs.pop_back();
         }
         if (bigs.empty()) return 0;
         cans += int(bigs.size()) - (v > 0);
         return bigs[0];
      };
      dfs(0, -1);
      if (ans == cans) {
         high = mid;
      } else {
         low = mid + 1;
      }
   }
   cout << ans << " " << low << "\n";
   return 0;
}


Measured memory_bytes: 20352
let N = stdin.ReadLine() |> int
let W = stdin.ReadLine().Split() |> Array.map int

let rec solver l r t i =
    if i = -1 then t
    else
        let ln = l - W.[i]
        let rn = r + W.[i]
        if t < abs (ln - rn) then t
        else solver ln rn (abs (ln - rn)) (i - 1)

solver (Array.sum W) 0 (Array.sum W) (N - 1) |> stdout.WriteLine

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

// merge sort: https://qiita.com/wabisuke2718/items/5ec44eb5be01b5e62fb3
void merge(long long int n[], long long int b[], int left, int mid, int right)
{
    int num = right - left;
    int *tmp = new int[num];
    int *tmp2 = new int [num];

    int iw = 0;
    int il = left;
    int ir = mid;
    //add
    int iw2 = 0;
    int il2 = left;
    int ir2 = mid;

    while (il < mid && ir < right)
    {
        if (n[il] <= n[ir])
        {
            tmp[iw++] = n[il++];
            tmp2[iw2++] = b[il2++];//add
        } else {
            tmp[iw++] = n[ir++];
            tmp2[iw2++] = b[ir2++];//add
        }
    }

    while (il < mid)
    {
        tmp[iw++] = n[il++];
        tmp2[iw2++] = b[il2++];
    }
    while (ir < right)
    {
        tmp[iw++] = n[ir++];
        tmp2[iw2++] = b[ir2++];
    }

    for (int i=0; i<num; i++)
    {
        n[left + i] = tmp[i];
        b[left + i] = tmp2[i];
    }

    delete[] tmp;
    delete[] tmp2;
}


void merge_sort_sub(long long int n[], long long int b[], int left, int right)
{
    if (right - left <= 1) return;

    int mid = left + (right - left) / 2;
    merge_sort_sub(n, b, left, mid);
    merge_sort_sub(n, b, mid, right);

    merge(n, b, left, mid, right);
}


void merge_sort(long long int n[], long long int b[], int len)
{
    merge_sort_sub(n, b, 0, len);
}

int main()
{
    int N, M;
    cin >> N >> M;
    long long int a[N];
    long long int b[N];
    for(int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
    }

    merge_sort(a, b, N);

    long long int cost = 0;
    long long int count = 0;
    for(int i = 0; i < N; i++)
    {
        if(count + b[i] <= M)
        {
            cost += a[i]*b[i];
            count += b[i];
        }
        else
        {
            cost += a[i]*(M-count);
            count += (M-count);
            break;
        }
    }

    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 2664
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a>b) a-=1;
  cout<<a<<endl;




  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    cout.precision(15);
    int N;
    double x;
    string u;
    cin >> N;
    double r=380000.0;
    double ans=0;
    for (int i=0;i<N;i++) {
        cin >> x >> u;
        if (u=="BTC") {
            ans += x * r;
        } else {
            ans += x;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

int main() {
    
    int N;
    cin >> N;
    vector<int> d(N);
    
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    
    int ans = 0;
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            ans += d[i] * d[j];
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int k,n;
  cin>>k>>n;
  VI a(n);
  rep(i,n){
    cin>>a[i];
  }
  VI dist(n);
  rep(i,n-1){
    dist[i]=abs(a[i]-a[i+1]);
    //cout<<a[i+1]<<endl;
  }

  dist[n-1]=abs(k-a[n-1])+a[0];
  sort(all(dist));

  //rep(i,n) cout<<dist[i]<<endl;
  ll ans=0;
  rep(i,n-1) ans+=dist[i];
  cout<<ans<<endl;

}


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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
      cout << "vowel" << endl;
  }  else {
      cout << "consonant" << endl;
  }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    int ans=0;
    FOR(i,a,b){
        string s = to_string(i);
        bool ng=false;
        rep(j,s.size()){
            if (s[j]!=s[s.size()-j-1]){
                ng = true;
                break;
            }
        }
        if (!ng) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define F(i, a, n) for(int i=a;i<n;i++)
#define REP(i, n) F(i, 0, n)
#define REP1(i, n) for(int i=1;i<=n;i++)
#define REV(i, n) for(int i=n;i>=0;i--)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const ll MAX = 1e6 + 5;

string s;
bool f = true;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>s;
	for(int i=0;i<s.size();i+=2){
		if(s[i] == 'L'){
			f = false;
			break;
		}
		if(i-1 >= 0 && s[i-1] == 'R'){
			f = false;
			break;
		}
	}
	if(f)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<math.h>

using namespace std;

const int MAX_N = 100001;

struct edge {int to,cost;};
vector<edge> tree[MAX_N];
bool flag[MAX_N] = {false};
int depth[MAX_N];
int s,t,c;
double sum = 0.0;
double ans = 0.0;
double p;
int N;

void dfs(int v,int d){
	flag[v] = true;
	depth[v] = d;
	for(int i = 0;i < tree[v].size();i++){
		if(!flag[tree[v][i].to]){
			sum += tree[v][i].cost * pow(p,(d+1.0));
			dfs(tree[v][i].to,d+1);
		}
	}
}

int main(){
	scanf("%lf %d",&p,&N);
	
	for(int i =0; i<N-1; i++){
		scanf("%d %d %d",&s,&t,&c);
		s--;
		t--;
		edge e;
		e.to = t;
		e.cost = c;
		tree[s].push_back(e);
		e.to = s;
		tree[t].push_back(e);
	}
	
	dfs(0,0);
	
	ans = 2*sum;
	for(int i = 1; i < N;i++){
		ans += sum * pow(p,depth[i]);
	}
	printf("%.10lf\n",ans);
	
	return 0;
}

Measured memory_bytes: 15024
import java.io.*;
import java.util.*;

class Main
{
  static int[] A;
  
  static boolean isValid() //check if the current array needs swaps or doesn't need swaps:
  {
    for (int i = 0; i < A.length; i++)
    {
      if (A[i] == i + 1)
      {
        return false;
      }
    }
    return true;
  }
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    A = new int[N];
    for (int i = 0; i < N; i++)
    {
      A[i] = sc.nextInt();
    }
    int swaps = 0;
    while (!isValid())
    {
      //look through all elements through 1 to N - 1:
      for (int i = 0; i < A.length - 1; i++)
      {
        if (A[i] == i + 1) //xx or xo
        {
          swaps += 1;
          //swap A[i] and A[i + 1]:
          int temp = A[i];
          A[i] = A[i + 1];
          A[i + 1] = temp;
        }
      }
      if (A[N - 1] == N) //ox
      {
        swaps += 1;
        int temp = A[N - 1];
        A[N - 1] = A[N - 2];
        A[N - 2] = temp;
      }
    }
    System.out.println(swaps);
  }
}

Measured memory_bytes: 59596
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  int a,b,c,d,e,k;
cin >>a>>b>>c>>d>>e>>k;
if(b-a<=k &&c-b<=k &&d-c<=k &&e-d<=k &&c-a<=k &&d-a<=k &&e-a<=k&&d-b<=k &&e-b<=k&&c-b<=k &&d-c<=k &&e-c<=k) cout <<"Yay!"<< endl;
else cout <<":("<< endl;
}

Measured memory_bytes: 256
//Ojas Kumar Dubey //
// el_freki //
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define v1 vector<int>
#define mapp map<int,int>
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int modulo=1000000007;
#define test int t;cin>>t;while(t--)
#define f(i,j,n) for(int i=j;i<n;i++)
#define r(i,j,n) for(int i=j-1;i>=n;i--)
#define min INT_MIN
#define maxx INT_MAX
#define all(container) container.begin() , container.end()
#define sz(container) (int)container.size()
#define pii pair <int , int>
#define pll pair <long long int , long long int>
#define setp(x) setprecision(x)
int power(int a,int n){
    a%=modulo;
    n%=modulo;
    int var=a,ans=1;
    while(n){
        if(n&1)
            ans=((ans%modulo)*(var%modulo))%modulo;
        var=((var%modulo)*(var%modulo))%modulo;
        n=n>>1;
    }
    return ans;
}
// ------------------------------------Template End------------------------------ //
void solve(){
    int n;
    cin>>n;
    while(n>=1000){
        n = n%1000;
    }
    //cout<<n;
    if(n==0) cout<<n<<endl;
    else cout<<1000-n<<endl;
}
signed main(){
	fast;
    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt",
    #endif
	solve();
}

			
	



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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ar[3] = { a,b,c };
	sort(ar, ar + 3);
	if ((ar[0] == 5) && (ar[1] == 5) && (ar[2] == 7)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 256
n = int(input())
list = []
for i in range(n):
    keep = input()
    list.append(keep)
double = 0
b = 0
a = 0
include = 0
for j in range(n):
    if list[j][0] == "B" and list[j][-1:] == "A":
        double += 1
    elif list[j][0] == "B":
        b += 1
    elif list[j][-1:] == "A":
        a += 1
for k in range(n):
    keep_len = len(list[k])
    for l in range(keep_len-1):
        if list[k][l] == "A" and list[k][l+1] == "B":
            include += 1
if b == 0 and a == 0 and double == 0:
    print(include)
elif b == 0 and a == 0:
    print(double-1 + include)
elif b == 0 or a == 0:
    print(double-1 + include + 1)
else:
    print(double-1 + include + min(b, a) + 1)

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

int64_t N;
//N_max = 1000000000000001
string str = "";

void input(){
    cin >> N;
}

void solve(){
    //a~z,aa~zz,aaa~zzz 26進数ってことやな。最大10桁
    int res;

    for (int i=0;i<11;i++){
        N=N-1;
        res = N%26;
        N = N/26;
        str = char('a' + res) + str;
        if (N==0) break;
    }
    cout << str << endl; 
}

int main(){
    input();
    solve();
    return 0;
}

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

using namespace std;

typedef long long int lli;

string str = "01235789";

void func(lli n)
{
  if(n == 0) return;
  func(n/8);
  cout << str[n%8];
}

int main()
{
  lli n;

  while(cin>>n && n){
    func(n);
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
cnt = [0] * 4
for i in range(3):
    a, b = map(lambda x: int(x) - 1, input().split())
    cnt[a] += 1
    cnt[b] += 1
ans = all(x < 3 for x in cnt)
print(['NO', 'YES'][ans])


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
typedef pair<ll,int> P;
P x[100005], y[100005];
struct edge {ll cost; int from,to;};
vector<edge> E;
int par[100005]; //親
int tree_rank[100005]; //木の深さ

bool comp(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}

void init_union_find(int n){
  rep(i, n){
    par[i] = i;
    tree_rank[i] = 0;
  }
}

// 木の根を求める
int find(int x){
  if (par[x] == x) return x;
  else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (tree_rank[x] < tree_rank[y]) par[x] = y;
  else{
    par[y] = x;
    if (tree_rank[x] == tree_rank[y]) tree_rank[x]++;
  }
}

// xとyが同じ要素に属するかどうか
bool same(int x, int y){
  return find(x) == find(y);
}


int kruskal() {
  sort(ALL(E), comp);
  init_union_find(N);
  ll res = 0ll;
  for (auto e: E) {
    if (!same(e.from, e.to)) {
      unite(e.from, e.to);
      res += e.cost;
    }
  }
  return res;
}

int main() {
  INCANT;
  cin >> N;
  int a,b;
  rep(i, N) {
    cin >> a >> b;
    x[i] = P(a, i);
    y[i] = P(b, i);
  }
  sort(x, x+N);
  sort(y, y+N);
  rep(i, N-1) {
    edge e1 = {x[i+1].first-x[i].first, x[i].second, x[i+1].second}; 
    E.push_back(e1);
    edge e2 = {y[i+1].first-y[i].first, y[i].second, y[i+1].second}; 
    E.push_back(e2);
  }
  ll ret = kruskal();
  cout << ret << endl;
  return 0;
}

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

int main() {
  
  string S, T;
  
  cin >> S;
  cin >> T;
  
  T.pop_back();
  
  if(S==T) {
    
    cout << "Yes" << endl;
    
  } else {
    
    cout << "No" << endl;
    
  }
  
  return 0;
  
}

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

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i=0; i<N; i++) cin >> X.at(i);
    int Xmax = 0, Xmin = 101;
    for(int i=0; i<N; i++){
        if(X.at(i) < Xmin) Xmin = X.at(i);
        if(X.at(i) > Xmax) Xmax = X.at(i);
    }
    int min = 10000000;
    for(int i=Xmin; i<=Xmax; i++){
        int sum = 0;
        for(int j=0; j<N; j++) sum += pow((X.at(j) - i), 2);
        if(sum < min) min = sum;
    }
    cout << min << endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define pb push
#define mp make_pair
#define X first
#define Y second
#define Mad(a,b) a=(a+b)%mod;
typedef long long ll;

using namespace std;
typedef pair<ll,ll> P;
queue<P> Q;
#define N 3010
ll n,m,d[N],c[N];string s;
int main(){
    cin>>n>>m>>s;
    Q.pb(mp(0,0));
    while(m--){
	ll a,b;cin>>a>>b;
	if(Q.back().Y<b)Q.pb(mp(a,b));
    }
    lol(i,N)d[i]=0;d[0]=1;
    for(ll i=0,rnd=0,bef=0;i<=n;i++){
	ll cnt=0;
	while(!Q.empty()){
	    if(not(Q.front().X<=i))break;
	    rnd=Q.front().Y;
	    for(ll j=max(i-1,bef);j<rnd;j++)cnt+=s[j]-'0';
	    bef=rnd;Q.pop();
	}
	//lol(j,10)cout<<d[j]<<" ";cout<<endl;
	lol(j,N)c[j]=0;
	lol(j,N-cnt)c[j+cnt]=d[j];
	lol(j,N)d[j]=c[j];
	//lol(j,10)cout<<d[j]<<" ";cout<<endl;
	//cout<<"#####"<<endl;
	lol(j,N)c[j]=0;
	ll lim=max(0LL,rnd-i);
	for(ll j=0;j<=lim;j++)Mad(c[j],d[j]+d[j+1]);
	lol(j,N)d[j]=c[j];
    }
    cout<<d[0]<<endl;
    return 0;
}






Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
using namespace std;

int A,B,C,D,E,F;
int main(){
    scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
    int x = 1;
    int y = 0;

    for(int a=0;a<=30;a++){
        for(int b=0;b<=30;b++){
            int w = a*A+b*B;
            if (100*w > F || a+b==0)continue;
            int r = F - 100*w;
            for(int c=0;c*C<=w*E && c*C<=r;c++){
                int d = (min(r, w*E)-c*C)/D;
                int s = c*C + d*D;
                if (s > w*E || s > r )continue;
                int p = 100*w+s;
                int q = s;
                if (p*y <= x*q){
                    x = p;
                    y=q;
                }
            }
        }
    }
    printf("%d %d\n", x,y);

}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <stdio.h>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <queue>

using namespace std;

#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define MP make_pair
#define EPS      1e-9
#define F        first
#define S        second
#define sc(x)     scanf("%d",&x)
#define scl(x)     scanf("%I64d",&x)
#define sq(x)     (x)*(x)
#define INF (1000000000)
#define oo (1ll<<60)
#define PI acos(-1)
#define POW(x) ((x)*(x))

typedef stringstream ss;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<int, int> ii;
typedef vector<int> rows;
typedef vector<rows> matrix;

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

const int MOD = 1000000007;
const int N = 1e5 + 10;


int main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif
	int r,g;
	cin>>r>>g;
	cout<<2*g-r<<endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).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 main()
{
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	if (H == 0) H = 12;
	if (M == 60) M = 60;

	double dm = (double)M / (double)60;
	double dh = (double)H / (double)12 + dm / 12;

	double rdiff = 2 * PI * (dh - dm);

	double c = cos(rdiff);
	double x = (double)A * (double)A + (double)B * (double)B - 2 * (double)A * (double)B * cos(rdiff);

	cout << setprecision(15) << sqrt(x) << endl;

	return 0;
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
#define pc putchar
#define mo 1000000007
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=65;
int l,r,lenl,lenr,pl[N],pr[N],dp[N][2][2],ans;
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
//问题可以转化成y-x=y^x的对数,那么y二进制下为1,x为0或1,y二进制下为0,x必为0 
int dfs(int pos,int x1,int x2){
	if(!pos) return 1;
	if(dp[pos][x1][x2]!=-1) return dp[pos][x1][x2];
	int &res=dp[pos][x1][x2];res=0;
	int t1=x1?pl[pos]:0,t2=x2?pr[pos]:1;
	for(int y=t1;y<=t2;y++)
		for(int x=t1;x<=y;x++)
			res=(res+dfs(pos-1,x1&(x==t1),x2&(y==t2)))%mo;
	return res;
}
signed main(){
	memset(dp,-1,sizeof(dp));
	l=read(),r=read();
	while(l){
		pl[++lenl]=l&1;
		l>>=1;
	}
	while(r){
		pr[++lenr]=r&1;
		r>>=1;
	}
	for(int i=lenl;i<=lenr;i++) ans=(ans+dfs(i-1,i==lenl,i==lenr))%mo;//枚举哪个最高位为1 
	write(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

void swap( int &a, int &b )
{
 	int temp = a;
	a = b;
	b = temp;
	
	return;
}

int main()
{
	char s[2];
	int cup[3] = { 1, 0, 0 };
	
	while( scanf( "%c,%c", &s[0], &s[1] ) != EOF ){
	 	swap( cup[s[0] - 'A'], cup[s[1] - 'A'] );
	}
	
	for( int i = 0; i < 3; i++ ){
		if( cup[i] == 1 ){
			printf( "%c\n", 'A' + i );
		}
	}

 	return 0;
}

Measured memory_bytes: 1140
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int p = 1000000007;
const int MAX = 1000;
bool not_prime[MAX];
vector<int> prime;

class Fp {
protected:
	ll n;
public:
	Fp(ll N) :n(N % p) {};
	Fp operator+(ll m) {
		return Fp(n + m);
	}
	Fp operator-(ll m) {
		return Fp(n - m + p);
	}
	Fp operator*(ll m) {
		return Fp(n * m);
	}
	Fp operator/(ll m) {
		return *this * Fp(m).pow(p - 2).get();
	}
	Fp pow(int i) {
		if (i == 0) return Fp(1);
		if (i % 2) return *this * pow(i - 1).get();
		Fp tmp = pow(i / 2);
		return tmp * tmp.get();
	}
	ll get() {
		return n;
	}
};

vector<P> prime_fact(int x) {
	vector<P> res;
	ITER(itr, prime) {
		if (*itr * *itr > x) break;
		if (x % *itr) continue;
		res.emplace_back(*itr, 0);
		while (x % *itr == 0) {
			res.rbegin()->second++;
			x /= *itr;
		}
	}
	if (x > 1) res.emplace_back(x, 1);
	return res;
}

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

	for (int i = 2;i < MAX;++i) {
		if (not_prime[i]) continue;
		prime.push_back(i);
		for (int j = i * i;j < MAX;j += i) {
			not_prime[j] = true;
		}
	}

	int N;
	cin >> N;
	vector<int> A(N);
	map<int, int> lcm;
	REP(i, N) {
		cin >> A[i];
		vector<P> f = prime_fact(A[i]);
		ITER(itr, f) {
			lcm[itr->first] = max(lcm[itr->first], itr->second);
		}
	}
	Fp a(1);
	ITER(itr, lcm) {
		a = a * Fp(itr->first).pow(itr->second).get();
	}
	Fp res(0);
	REP(i, N) res = res + (a / A[i]).get();
	cout << res.get() << endl;

	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;
using ll = long long int;

int main(void) {
    int k; cin >> k;
    string s; cin >> s;
    if (s.size() <= k) cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		long[] A = new long[N];
		String[] a = new String[N];
		int max = 42;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			// 二進数を42桁で左側を0で埋める
			a[i] = String.format("%42s", Long.toBinaryString(A[i])).replace(" ", "0");
		}
		sc.close();
		String k = String.format("%42s", Long.toBinaryString(K)).replace(" ", "0");

		long[] c = new long[max];
		int[] b = new int[max];
		for(int i = 0; i < max; i++) {
			if(k.charAt(i) == '1') {
				b[i]++;;
			}
		}
		for(String s : a) {
			for(int i = 0; i < max; i++) {
				if(s.charAt(i) == '1') {
					c[i]++;
				}
			}
		}
		long[][] dp = new long[max + 1][2];
		for(int i = 0; i <= max; i++) {
			dp[i][0] = -1;
			dp[i][1] = -1;
		}
		dp[0][0] = 0;
		for(int i = 0; i < max; i++) {
			long t = (long)Math.pow(2, max - 1 - i);
			long v0 = t * c[i];			// i桁目を0としたときの報酬
			long v1 = t * (N - c[i]);	// i桁目を1としたときの報酬
			if(dp[i][1] != -1) {
				dp[i + 1][1] = dp[i][1] + Math.max(v0, v1);
			}

			if(dp[i][0] != -1) {
				if(b[i] == 1) {
					dp[i + 1][1] = Math.max(dp[i + 1][1], dp[i][0] + v0);
					dp[i + 1][0] = dp[i][0] + Math.max(v1, v0);
				}else {
					dp[i + 1][0] = dp[i][0] + v0;
				}
			}
		}
		long ans = Math.max(dp[max][0], dp[max][1]);
		System.out.println(ans);
	}
	static void disp(long[] a) {
		for(long i : a) {
			System.out.printf("%d ", i);
		}
		System.out.println();
	}
	static void disp(int[] a) {
		for(long i : a) {
			System.out.printf("%d ", i);
		}
		System.out.println();
	}
}

Measured memory_bytes: 167620
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd
from itertools import accumulate
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    A = list(map(int, sys.stdin.readline().split()))
    print(reduce(gcd,A))

Measured memory_bytes: 16288