akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, P;
vector<ll> W, B;

int main(void) {
  cin >> N >> P;
  W.resize(N), B.resize(N);
  REP(i, 0, N) cin >> W[i] >> B[i];

  vector<pll> vec;
  REP(i, 0, N) vec.push_back(pll(-((100 - P) * W[i] + P * B[i]), i));

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

  ll white = 0, all = 0;
  REP(i, 0, N) all += B[i];

  ll ans;
  REP(i, 0, N) {
    ll idx = vec[i].second;
    white += W[idx];
    all += W[idx] - B[idx];

    if(white * 100 >= P * all) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    if(X == 3) {
        ans += 100000;
    } else if(X == 2) {
        ans += 200000;
    } else if(X == 1) {
        ans += 300000;
    }
    if(Y == 3) {
        ans += 100000;
    } else if(Y == 2) {
        ans += 200000;
    } else if(Y == 1) {
        ans += 300000;
    }
    if(X == 1 && Y == 1) ans += 400000;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, m, p;
	int[] x;

	void run(){
		for(;;){
			n=sc.nextInt();
			m=sc.nextInt();
			p=sc.nextInt();
			if((n|m|p)==0){
				break;
			}
			m--;
			x=new int[n];
			for(int i=0; i<n; i++){
				x[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int sum=0;
		for(int i : x){
			sum+=i;
		}
		if(x[m]==0){
			println("0");
		}else{
			println(sum*(100-p)/x[m]+"");
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 27700
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int a, b, H, W, N, used[100009], c, d; vector<int>x[50009];
vector<pair<int, int>>X[100009], Y[100009];
int main() {
	cin >> N >> H >> W;
	for (int i = 0; i < N; i++) { cin >> a >> b; if (a == 1 || b == 1 || a == H || b == W)d = 1; X[a].push_back(make_pair(b, i)); Y[b].push_back(make_pair(a, i)); }
	for (int i = 0; i < 100009; i++) {
		sort(X[i].begin(), X[i].end()); sort(Y[i].begin(), Y[i].end());
		for (int j = 0; j < (int)X[i].size() - 1; j++) { x[X[i][j].second].push_back(X[i][j + 1].second); x[X[i][j + 1].second].push_back(X[i][j].second); }
		for (int j = 0; j < (int)Y[i].size() - 1; j++) { x[Y[i][j].second].push_back(Y[i][j + 1].second); x[Y[i][j + 1].second].push_back(Y[i][j].second); }
	}
	for (int i = 0; i < N; i++) {
		if (used[i] == true)continue;
		queue<int>Q; Q.push(i); used[i] = true;
		while (!Q.empty()) {
			int a1 = Q.front(); Q.pop();
			for (int j : x[a1]) { if (used[j] == false) { used[j] = true; Q.push(j); } }
		}
		c++;
	}
	if (c == 1)d = 1;
	cout << (N - 1) + (c - d) << endl;
	return 0;
}

Measured memory_bytes: 11852
def modpow(a, n, p):
    if n == 0:
        return 1
    elif n == 1:
        return a % p
    if n % 2 == 1:
        return (a * modpow(a, n-1, p)) % p
    tmp = modpow(a, n//2, p)
    return (tmp * tmp) % p


def modfactrial(a, p):
    ret = 1
    for i in range(a, 1, -1):
        ret = ret * i % p
    return ret


def main():
    mod = 10 ** 9 + 7
    n, a, b = map(int, input().split())

    # まずは繰り返し2乗法によって全部の組み合わせを求める
    # すべての組み合わせは、花を選ぶ/選ばないで組み合わせを決めれる

    ans = (modpow(2, n, mod) - 1) % mod

    # a本選んだときの数を引く
    c_a = 1
    for i in range(n, n-a, -1):
        c_a *= i
        c_a %= mod
    c_a *= modpow(modfactrial(a, mod), mod-2, mod)
    ans -= c_a
    ans %= mod

    # b本選んだときの数を引く
    c_b = 1
    for i in range(n, n-b, -1):
        c_b *= i
        c_b %= mod
    c_b *= modpow(modfactrial(b, mod), mod-2, mod)
    ans -= c_b
    ans %= mod

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
local mma = math.max
local n = io.read("*n")
local t_pos, a_pos = io.read("*n", "*n")

local edge = {}
local t_asked, a_asked = {}, {}
local t_len, a_len = {}, {}
for i = 1, n do
  edge[i] = {}
  t_asked[i], a_asked[i] = false, false
  t_len[i], a_len[i] = 0, 0
end
for i = 1, n - 1 do
  local x, y = io.read("*n", "*n")
  table.insert(edge[x], y)
  table.insert(edge[y], x)
end

local tasks = {t_pos}
while 0 < #tasks do
  local src = tasks[#tasks]
  table.remove(tasks)
  t_asked[src] = true
  for i = 1, #edge[src] do
    local dst = edge[src][i]
    if not t_asked[dst] then
      t_len[dst] = t_len[src] + 1
      table.insert(tasks, dst)
    end
  end
end
tasks = {a_pos}
while 0 < #tasks do
  local src = tasks[#tasks]
  table.remove(tasks)
  a_asked[src] = true
  for i = 1, #edge[src] do
    local dst = edge[src][i]
    if not a_asked[dst] then
      a_len[dst] = a_len[src] + 1
      table.insert(tasks, dst)
    end
  end
end

tasks = {t_pos}
for i = 1, n do
  t_asked[i] = false
end
local cand = 0
while 0 < #tasks do
  local src = tasks[#tasks]
  table.remove(tasks)
  t_asked[src] = true
  cand = mma(cand, a_len[src])
  for i = 1, #edge[src] do
    local dst = edge[src][i]
    if not t_asked[dst] then
      if t_len[dst] < a_len[dst] then
        table.insert(tasks, dst)
      end
    end
  end
end
print(cand - 1)


Measured memory_bytes: 14176
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int A, B, N;
  cin >> A >> B >> N;
  int r = min(B - 1, N);
  cout << A * r / B << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int n; cin >> n;
	int k, s; cin >> k >> s;
	vector<int> ans(n);
	if (s == 1000000000) {
		rep(i, k)ans[i] = s;
		Rep(i, k, n)ans[i] = 1;
	}
	else {
		rep(i, k)ans[i] = s;
		Rep(i, k, n)ans[i] = s + 1;
	}
	rep(i, n) {
		if (i > 0)cout << " ";
		cout << ans[i];
	}
	cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	//stop
		return 0;
}


Measured memory_bytes: 18176
N, K = map(int, input().split())
remaining = (N-1)*(N-2)//2 - K
if remaining < 0:
    print(-1)
    exit()
edges = []
for i in range(2, N+1):
    edges.append((1, i))
u = 2
v = 3
while remaining > 0:
    edges.append((u, v))
    v += 1
    if v == N+1:
        u += 1
        v = u + 1
    remaining -= 1
print(len(edges))
for u, v in edges:
    print(u, v)


Measured memory_bytes: 43120
n = int(input())
a = list(map(int, input().split()))
CurrentMoney = 1000
for i in range(n-1):
    Stocks = 0
    if a[i] < a[i+1]:
        Stocks = CurrentMoney // a[i]
    CurrentMoney += (a[i+1] - a[i])*Stocks

print(CurrentMoney)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    double limit = (double)sum / (4.0 * (double)m);
    int num = 0;
    for (int i = 0; i < n; ++i) {
        if ((double)a[i] >= limit) num++;
    }
    if (num >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int main(void){
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    while (1){
        if (a+1 != b){
            a = a+1;
        }else{
            printf("Borys\n");
            return 0;
        }
        if (b-1 != a){
            b = b-1;
        }else{
            printf("Alice\n");
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
const ll INF=1e18;
  string a,b;
 ll dp[3005][3005];
ll LCS(ll i,ll j){
    if(i==0||j==0)
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    ll ans=0;
   if(a[i-1]==b[j-1]){
        ans=1+LCS(i-1,j-1);
   }
 ans=max(ans,LCS(i-1,j));
 ans=max(ans,LCS(i,j-1));
 return dp[i][j]=ans;
}
int main(){
    IOS;
    cin>>a>>b;
    string s="";
    memset(dp,-1,sizeof(dp));
    ll l=LCS(a.length(),b.length());
    ll n=a.length(),m=b.length();
  while(n>0&&m>0&&l!=0){
      if(a[n-1]==b[m-1]&&LCS(n,m)==l){
          s+=a[n-1];
        //cout<<a[n-1];
       n--;
       m--;
       l--;
      }
      else 
        if(LCS(n-1,m)==l){
          n--;
      }
      else 
      m--;
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}


Measured memory_bytes: 71168
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N),R(N);
  for(int i(0);i<N;i++){
    cin>>A[i];
  }
  sort(A.rbegin(),A.rend());
  R[N-1] = A[N-1];
  for(int i(N-2);i>=0;i--){
    R[i] = R[i+1] + A[i];
  }
  // for(int i(0);i<N;i++){
  //   cout << A[i] << " ";
  // }
  // cout << endl;
  // for(int i(0);i<N;i++){
  //   cout << R[i] << " ";
  // }
  // cout << endl;
  for(int i(0);i<N-1;i++){
    //cout << A[i] << " " << R[i+1] << endl;
    if(A[i] > R[i+1]*2){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << N << endl;
  return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, k, o = 0, d[102][43210] = {}, z = 0, f[130] = {};
    vector<int> a, b[43210] = {}, g[43210] = {};
    cin >> n >> m >> k;
    for (int i = 0; i < m; i++) a.push_back(i);
    for (int i = 0; i < (1 << (m - 1)); i++) {
        bool g[8] = {}, y = 0;
        for (int j = 0; j < m - 1; j++) if (i & (1 << j)) g[j] = 1;
        for (int j = 1; j < m - 1; j++) if (g[j] && g[j - 1]) y = 1;
        if (!y) f[i] = 1;
    }
    map<vector<int>, int> p;
    do {
        b[o] = a;
        p[a] = o++;
    } while (next_permutation(a.begin(), a.end()));
    for (int i = 0; i < o; i++) {
        for (int j = 0; j < (1 << (m - 1)); j++) if (f[j]) {
            vector<int> c = b[i];
            for (int l = 0; l < m - 1; l++) if (j & (1 << l)) swap(c[l], c[l + 1]);
            g[i].push_back(p[c]);
            //cout << b[i][0] << b[i][1] << b[i][2] << ' ' << c[0] << c[1] << c[2] << '\n';
        }
    }
    d[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < o; j++) {
            for (int l : g[j]) {
                d[i][j] += d[i - 1][l];
                if (d[i][j] >= mod) d[i][j] -= mod;
            }
        }
    }
    for (int i = 0; i < o; i++) if (b[i][k - 1] == 0) {
        z += d[n][i];
        if (z >= mod) z -= mod;
    }
    cout << z;
}


Measured memory_bytes: 37120
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int n;
	while(cin >> n)
	{
		int res = 1;
		for(int i = 1; i <= n; i++)
		{
			res += i;
		}
		cout << res << endl;
	}
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
LL n,a,b;
cin>>n>>a>>b;

cout<<a*(n/(a+b))+min(a,n%(a+b));

}


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

int main() {
    string s; cin >> s;
    int n = s.length();

    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 1 + 1 << endl;
            return 0;
        }
    }

    for (int i = 1; i < n - 1; i++) {
        if (s[i - 1] == s[i + 1]) {
            cout << i - 1 + 1 << " " << i + 1 + 1 << endl;
            return 0;
        }
    }

    cout << "-1 -1" << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n,...) for (int i = 1 , ##__VA_ARGS__ ; i <= n ; i++)
#define REP(i,n,...) for (int i = 0 , ##__VA_ARGS__ ; i < n ; i++)
#define ll long long
#define LL long long
#define mp make_pair
#define x first
#define y second

const int MAXN = 100005;

int n , a[MAXN];

int main (void) {
  cin >> n;
  FOR(i,n) scanf("%d",a+i);
  int ans = 0 , flag = 0;
  FOR(i,n) if (a[i] == i) {
    if (flag) flag = 0;
    else {
      ans++;
      flag = 1;
    }
  }
  else flag = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
def main():
    s = input()
    q = int(input())
    left = ""
    right = ""
    hanten = False
    for i in range(q):
        query = input().split()
        if query[0] == "1":
            hanten = not hanten
        else:
            c = query[2]
            if query[1] == "1":
                if not hanten:
                    left = c + left
                else:
                    right += c
            else:
                if not hanten:
                    right += c
                else:
                    left = c + left
        #print(query)
        #print(s,left,right)
    #left = left[::-1]
    answer = left + s + right

    if not hanten:
        print(answer)
    else:
        print(answer[::-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)


int def = 1e9, ans = 1e9;
const int NUMBER = 753;
string S, numStr;
vector<int> ls;
int main() {
	cin >> S;
	REP(i,S.size()){
		numStr = S[i];
		ls.push_back(stoi(numStr));
		
	}
	REP(i, ls.size() - 2) {
		ans = min(ans, abs(ls[i] * 100 + ls[i + 1] * 10 + ls[i + 2] - NUMBER));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    string s;cin >>s;
    string t;cin >>t;
    ll n=s.size();
    ll m=t.size();
    vector<vector<ll>>dp(n+1,vector<ll>(m+1,INF));
    for (int i = 0; i <=n; ++i) {
        dp[i][0]=i;
    }
    for (int j = 0; j <= m; ++j) {
        dp[0][j]=j;
    }
    for (int i = 0; i <n; ++i) {
        for (int j = 0; j < m; ++j) {
            ll cost=(s[i]==t[j])?0:1;
            dp[i+1][j+1]=min({dp[i][j+1]+1,dp[i+1][j]+1,dp[i][j]+cost});
        }
    }
//    for (int i = 0; i <= n; ++i) {
//        for (int j = 0; j <=m; ++j) {
//            cout <<dp[i][j]<<" ";
//        }
//        cout <<endl;
//    }
    cout <<dp[n][m]<<endl;
    return 0;
}




Measured memory_bytes: 10788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		try(BufferedReader input = new BufferedReader(new InputStreamReader(System.in))){

			String[] l1 = input.readLine().split(" ");
			String[] l2 = input.readLine().split(" ");

			int ROW = Integer.parseInt(l1[0]);
			int COLUMN = Integer.parseInt(l1[1]);
			int r = Integer.parseInt(l2[0]);
			int c = Integer.parseInt(l2[1]);

			System.out.println((ROW - r) * (COLUMN - c));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}


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

#define Bye return 0
#define ll long long

using namespace std;

void solve(){
    ll n, k, res, x; cin>>n>>k;
    x = n/k;
    res = min(n, min(abs(n - x*k), abs(n - (x+1)*k)));
    cout<<res<<endl;
}

int main(){
    solve();
    Bye;
}

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


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

  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll ub = 2e9;
  ll lb = 0;
  rep(i,100){
    ll mid = (ub+lb)/2;
    if(mid==0) break;
    ll tans = 0;
    rep(j,n){
      if(a[j]>mid){
        tans += (a[j]+mid-1)/mid-1;
      }
    }
    if(tans>k) lb = mid;
    else ub = mid;
  }
  cout << ub << endl;

  return 0;
    

}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> t(N), d(N);
  vector<pair<i64, i64>> vec;
  rep(i,0,N) {
    cin >> t[i] >> d[i];
    t[i]--;
    vec.push_back({d[i], t[i]});
  }
  sort(all(vec));
  reverse(all(vec));

  vector<vector<i64>> st(N);
  i64 sum = 0;
  i64 cnt = 0;
  rep(i,0,K) {
    sum += vec[i].first;
    st[vec[i].second].push_back(vec[i].first);
    if(st[vec[i].second].size() == 1) {
      cnt++;
    }
  }


  vector<i64> MINs;
  rep(i,0,N) {
    sort(all(st[i]));
    rep(j,0,(i64)st[i].size() - 1) {
      MINs.push_back(st[i][j]);
    }
  }

  sort(all(MINs));
  reverse(all(MINs));

 

  i64 res = sum + cnt * cnt;

  rep(i,K,N) {
    if(MINs.size() == 0) break;
    i64 x = vec[i].first;
    i64 ty = vec[i].second;
    if(st[ty].size() >= 1) continue;
    st[ty].push_back(x);
    i64 y = MINs.back();
    MINs.pop_back();
    sum = sum - y + x;
    cnt++;

    res = max(res, sum + cnt * cnt);


  }

  cout << res << endl;
}


Measured memory_bytes: 8560
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
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; }

signed main(){
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if(s == u){
        cout << a - 1 << " " << b << endl;
    }else if(t == u){
        cout << a << " " << b -1 << endl;
    }else{
        cout << a << " " << b << endl;
    }
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<lint> vi;
typedef vector<vi> vvi;
#define all(x) (x).rbegin(), (x).rend()
#define pb push_back
int main()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vi a(x);
    vi b(y);
    vi c(z);
    rep(i, x)
    {
        cin >> a[i];
    }
    rep(i, y)
    {
        cin >> b[i];
    }
    rep(i, z)
    {
        cin >> c[i];
    }
    vi ab(x * y);
    rep(i, x)
    {
        rep(j, y)
        {
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(all(ab));
    ab.resize(k);
    vi abc(k * z);
    rep(i, k)
    {
        rep(j, z)
        {
            abc.push_back(ab[i] + c[j]);
        }
    }
    sort(all(abc));
    rep(i, k)
    {
        cout << abc[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 64760
p = 10**9+7
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
dp = [[0 for _ in range(K+1)] for _ in range(N+1)]
dq = [[0 for _ in range(K+2)] for _ in range(N+1)]
for j in range(K+1):
    if j>A[N]:
        dp[N][j] = 0
    else:
        dp[N][j] = 1
    dq[N][j+1] = (dq[N][j]+dp[N][j])%p
for i in range(N-1,0,-1):
    for j in range(K+1):
        dp[i][j] = (dq[i+1][j+1]-dq[i+1][max(0,j-A[i])])%p
        dq[i][j+1] = (dq[i][j]+dp[i][j])%p
print(dp[1][K])

Measured memory_bytes: 259976
from collections import deque
def main():
  s=deque(list(input()))
  q=int(input())
  ok=1
  for i in range(q):
    query=list(input().split())
    if query[0]=='1':
      ok=(ok+1)%2
    else:
      f,c=query[1],query[2]
      if ok:
        if f=='1':
          s.appendleft(c)
        else:
          s.append(c)
      else:
        if f=='1':
          s.append(c)
        else:
          s.appendleft(c)
  s=list(s)
  if ok:
    print(''.join(s))
  else:
    print(''.join(s[::-1]))
if __name__=='__main__':
  main()

Measured memory_bytes: 8548
N = gets.to_i
ary = gets.split.map(&:to_i)
hash = {}
ary.each do |n|
    hash[n] = hash[n].to_i + 1
end
l = hash.sort
max_vals = {}
l.each_with_index do |a, i|
    pre = i==0 ? 0 : (l[i-1][0]-l[i][0]).abs == 1 ? l[i-1][1] : 0
    post = i==l.size-1 ? 0 : (l[i+1][0]-l[i][0]).abs == 1 ? l[i+1][1] : 0
    max_vals[l[i][0]] = pre + l[i][1] + post
end
puts max_vals.max{|a, b| a[1]<=>b[1]}[1]

Measured memory_bytes: 21928
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long S, long long W){
  cout << (S <= W ? "unsafe" : "safe") << endl;
}

signed main(){
  long long S;
  scanf("%lld",&S);
  long long W;
  scanf("%lld",&W);
  solve(S, W);
}


Measured memory_bytes: 3768
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int r, d, x;
    cin >> r >> d >> x;
    
    rep(i, 10){
        x = r * x - d;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;
int main(){
    ll n;
    cin>>n;
    ll canride[5];
    rep(i,5)cin>>canride[i];
    int mini=0;
    rep(i,5)if(canride[i]<canride[mini]){
        mini=i;
    }
    cout<<4+(n+canride[mini]-1)/canride[mini]<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll arr[MAX],mx[MAX],sum,ans;
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    for(int i=1; i<=n*3; i++)
        cin>>arr[i];
    priority_queue<int>x,y;
    for(int i=1; i<=n; i++)
    {
        x.push(arr[i]*-1);
        mx[i]=mx[i-1]+arr[i];
    }
    for(int i=n+1; i<=n*2; i++)
    {
        int cur=x.top()*-1;
        mx[i]=mx[i-1];
        if(cur<arr[i]);
        {
            x.pop();
            mx[i]-=cur;
            mx[i]+=arr[i];
            x.push(arr[i]*-1);
        }
    }
    for(int i=n*2+1; i<=n*3; i++)
    {
        y.push(arr[i]);
        sum+=arr[i];
    }
    ans=mx[2*n]-sum;
    for(int i=2*n; i>n; i--)
    {
        if(y.top()>arr[i])
        {
            sum-=y.top();
            y.pop();
            sum+=arr[i];
            y.push(arr[i]);
        }
        ans=max(ans,mx[i-1]-sum);
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 8212
from bisect import bisect_right,bisect

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
N = int(input())


def triangle(n):
  return n*(n+1)//2

T = [ triangle(i) for i in range(1, 10**6)]

#print(factorization(N))

ans = 0
for _, i in factorization(N):
  ans += bisect_right(T, i) 

  
  
if N == 1:
  ans = 0
print(ans)

Measured memory_bytes: 48836
import java.io.InputStreamReader;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		try(Scanner scan = new Scanner(new InputStreamReader(System.in))){
			StringBuilder s = new StringBuilder(scan.nextLine());
			int K = scan.nextInt();
			
			int index = 0;
			
			while(K > 0 && index < s.length()){
				int diff = ('z' - s.charAt(index) + 1) % 26;
				if(K - diff >= 0){
					K -= diff;
					s.replace(index, index+1, "a");
				}
				index++;
			}
			
			char c = s.charAt(s.length()-1);
			for(;K>0; K--){
				c++;
				if(c > 'z'){
					c = 'a';
				}
			}

			s.replace(s.length()-1, s.length(), String.valueOf(c));
			
			System.out.println(s.toString());
		}
	}
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, m, p, a[5000], b[5000], c[5000];
LL d[2500];
LL const INF = -2e12;

int main() {
	cin >> n >> m >> p;
	inc(i, m) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
		c[i] -= p;
	}
	
	inc(i, n) { d[i] = INF; }
	d[0] = 0;
	
	bool inf = false;
	inc(q, n * 2) {
		bool cont = false;
		inc(i, m) {
			bool flag = false;
			if(d[ a[i] ] != INF) {
				flag = setmax(d[ b[i] ], d[ a[i] ] + c[i]);
				cont |= flag;
			}
			if(flag && q >= n && b[i] == n - 1) { inf = true; cont = false; break; }
		}
		if(! cont) { break; }
	}
	
	if(inf) { cout << -1 << endl; }
	else { cout << max(0LL, d[n - 1]) << endl; }
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  ll k, a, b;
  cin >> k >> a >> b;
  if (b <= a + 1 || k <= a) {
    cout << k + 1 << endl;
  } else {
    k -= (a + 1);

    ll ans = b + (k / 2) * (b - a) + (k % 2 == 1);
    cout << ans << endl;
  }
}
//////////////////////////////////////////////


Measured memory_bytes: 256
/**
*    created: 28.06.2020 00:45:22
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
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 int mod = 1000000007;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, m, k;
    cin >> n >> m  >> k;
    vector<int> a(n);
    vector<int> b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    int t = 0;
    rep(i,m) t += b[i];

    int j = m;
    int ans = 0;
    rep(i,n+1) {
        while (j > 0 && t > k) {
            j--;
            t -= b[j];
        }
        if (t > k) break;
        chmax(ans,i+j);
        if (i == n) break;
        t += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6380
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b;
	cin>>a>>b;
	cout<<b*2-a<<endl;
}










Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

using mint = modint998244353;

ostream& operator<<(ostream& out, mint m){
  out << m.val();
  return out;
}

struct node{
  mint sum,evinv;
  int sumzw;
};

node empty(){
  return {0,0,0};
}

int n,k;

node lacz(node a,node b){
  return { a.sum + b.sum, 
    a.evinv + b.evinv + a.sumzw * b.sum,
    a.sumzw + b.sumzw};
}

node mapping(mint x, node a){
  return {a.sum * x, a.evinv * x, a.sumzw};
}
mint composition(mint x,mint y){
  return x * y;
}
mint jeden(){
  return 1;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> k;
  lazy_segtree<node, lacz, empty , mint, mapping, composition, jeden> tree(
    vector<node>(n,{0,0,1}));
  
  vector<int> p(n);
  R(i,n){
    cin >> p[i];
    p[i]--;
  }
  R(i,k)tree.set(p[i], {1,0,0});
  
  mint kinv = mint(1) / k;
  mint res = 0;
  R(i,n-k){
    res += tree.all_prod().evinv * kinv;
    res += mint(k-1) / 2;
    tree.apply(0, n, (k-1) * kinv);
    tree.set(p[i+k], {1,0,0});
  } 
  res += mint(k) * (k - 1) / 4;
  cout << res << "\n";
}


Measured memory_bytes: 15636
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
    
    public static void main(String args[])throws IOException
    {
	
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	while(true)
	    {	
	
		
		String[] elements = in.readLine().split(" ");
		int N,M;
		double P;
		N = Integer.parseInt(elements[0]);
		M = Integer.parseInt(elements[1]);
		P = Double.parseDouble(elements[2]);
	

		if(N == 0 && M == 0 && P == 0)
		    break;

		int the_number=0,sum;
		sum = 0;
		for(int i=0;i<N;i++)
		    {
			int X;
			X = Integer.parseInt(in.readLine()); 
	
			sum += X*100;
			if(i+1 == M)
			    {
				the_number = X;
			    }
		    }
		if(the_number == 0)
		    System.out.println(0);
		else
		    System.out.println((int)((sum-(sum*(P*0.01) ) )/the_number) );
	    }	



    }
    
}

Measured memory_bytes: 10000
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<bitset>
using namespace std;
#define LL long long 
#define LD long double
int n,m,a[85][85],b[85][85];
bitset<12820>dp[85][85];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);//+
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&b[i][j]);//-
	dp[0][1][6402]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			for(int k=0;k<=12810;k++)
			{
				int now=k+(a[i][j]-b[i][j]);
				if(now<=12810&&now>=0)
				dp[i][j][k]=(dp[i][j][k]|dp[i-1][j][now]|dp[i][j-1][now]);
				now=k+(b[i][j]-a[i][j]);
				if(now<=12810&&now>=0)
				dp[i][j][k]=(dp[i][j][k]|dp[i-1][j][now]|dp[i][j-1][now]);
			}
		}	
	for(int i=0;i<=6400;i++)
		if(dp[n][m][6402+i]|dp[n][m][6402-i])
		{
			printf("%d\n",i);
			return 0;
		}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define mod 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 200001

vector <int> adj[MAX];
int status[MAX];
bool vis[MAX];
ll w = 0, b = 0;

void dfs (int s) {
    vis[s] = true;
    w += (!status[s]);
    b += (status[s]);
    for (auto it : adj[s]) {
        if (!vis[it]) {
            dfs(it);
        }
    }
}

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

    int n, m;
    cin >> n >> m;
    int value[n][m];
    int arr[n][m];
    int k = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            char c;
            cin >> c;
            value[i][j] = k++;
            arr[i][j] = (c == '#'? 1 : 0);
            status[k - 1] = arr[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int v = value[i][j];
            if (arr[i][j]) {
                if (i - 1 >= 0 && !arr[i - 1][j]) adj[v].pb(value[i - 1][j]) , adj[value[i - 1][j]].pb(v);
                if (i + 1 < n && !arr[i + 1][j]) adj[v].pb(value[i + 1][j]) , adj[value[i + 1][j]].pb(v);
                if (j - 1 >= 0 && !arr[i][j - 1]) adj[v].pb(value[i][j - 1]) , adj[value[i][j - 1]].pb(v);
                if (j + 1 < m && !arr[i][j + 1]) adj[v].pb(value[i][j + 1]) , adj[value[i][j + 1]].pb(v);
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < k; i++) {
        if (!vis[i]) {
            w = 0;
            b = 0;
            dfs(i);
            ans += (b * w);
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int a[2][123];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", a[i] + j);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int cur = 0;
    for (int j = 0; j <= i; ++j) {
      cur += a[0][j];
    }
    for (int j = i; j < n; ++j) {
      cur += a[1][j];
    }
    ans = max(ans, cur);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>

#include<string>
using namespace std;

int main() {
	string s;cin>>s;
	for(int i=0;i<26;i++){
		char can='a'+i;
		int flag=1;
		for(int j=0;j<s.size();j++){
			if(s[j]==can)flag=0;
		}
		if(flag){
			cout<<can<<endl;
			break;
		}else{
			if(i==25){
				cout<<"None"<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 512
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  int ok = n, ng = -1;
  vector<int> ans(n);

  int L = 0, R = 0;
  int cl = 0, cr = 0;
  int cl2 = 0, cr2 = 0;
  for(int i = 0; i < n; i++) {
    if(s[i] == 'R') cl2++;
    else cl++;
    if(i - 1 < n) {
      if(s[i] == 'R' && s[i+1] == 'L') {
        ans[L] += cl;
        ans[R] += cr;
        cl = cr = 0;
        L = i, R = i + 1;
        swap(cl, cl2);
        swap(cr, cr2);
      }
    }
    swap(cl, cr);
    swap(L, R);
    swap(cl2, cr2);
  }
  ans[L] += cl;
  ans[R] += cr;

  for(int i = 0; i < n; i++) cout << ans[i] << " \n"[i == n - 1];

  return 0;
}


Measured memory_bytes: 1104