akhauriyash/Code-Regression huggingface dataset:
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

s=get_nsp
T=get_nsp
Ns=s.size
Nt=T.size
if Ns<Nt
    puts "UNRESTORABLE"
    exit
end
def make_string(s,t)
flag=true
(Ns-Nt+1).times do|i|
  flag=true
  Nt.times do|j|
    if s[i+j]!="?" and s[i+j]!=t[j]
        flag=false
        break
    end
  end
  if flag
      Nt.times do|j|
          s[i+j]=t[j]
      end
      break
  end
end
Ns.times do|i|
    if s[i]=="?"
        s[i]="a"
    end
end
return s.join(""),flag
end
ans1,flag1=make_string(s.dup,T.dup)
ans2,flag2=make_string(s.reverse.dup,T.reverse.dup)
ans2.reverse!
if flag1 and flag2
    puts ans1>ans2 ? ans2 : ans1
else
    puts "UNRESTORABLE"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,d;
    cin >> s >> d;

    char c[3010];

    int p = s.size();
    int q = d.size();

    int dp[p+2][q+2];

    for(int i=0;i<=p;i++)
    {
        for(int j=0;j<=q;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
            }
            else if(s[i-1]==d[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else 
            {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    // cout << dp[p][q] << endl;
    int i = p;
    int j = q;
    int k=0;
    while(i>0 && j>0)
    {
        if(dp[i][j]==dp[i-1][j])
        {
            i--;
        }
        else if(dp[i][j]==dp[i][j-1])
        {
            j--;
        }
        else 
        {
            c[k]=s[i-1];
            i--;
            j--;
            k++;
        }
    }
    //cout << p << " " << q << endl;

    for(int i=k-1;i>=0;i--)        
        cout << c[i];
    cout  << endl;
    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  //rep(i,n) cout << a[i] << endl;
  vector<int> b(n);
  int count=0;

  for(int i=n-1; i>=n/2; i--){
    b[i] = a[i];
    if(b[i]) count++;
    //cout << i <<" " << b[i] << endl;
  }

  for(int i=n/2-1; i>=0; i--){
    int mem=0;
    int j=(i+1)*2;
    while(j <= n){
      mem ^= b[j-1];
      j += i+1;
    }
    b[i] = mem^a[i];
    if(b[i]) count++;
    //cout << i <<" " << b[i] << endl;
  }

  cout << count << endl;
  rep(i,n){
    if(b[i]) cout << i+1 << " ";
  }
  cout << endl;


  return 0;
}


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

int main() {
  int N, K, A = 1;
  cin >> N >> K;
  
  for(int i=0 ; i < N ; i++){
    if(A <= K){
      A = 2*A;
      continue;
    }
    if(A > K){
      A = A + K;
    }
  }
  
  cout << A << endl;

}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') f = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> bool chkmax(Tp &x, Tp y) {return x > y ? 0 : (x=y,1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x < y ? 0 : (x=y,1);}
template <typename Tp> Tp Max(Tp x, Tp y) {return x > y ? x : y;}
template <typename Tp> Tp Min(Tp x, Tp y) {return x < y ? x : y;}

namespace __pyh_dinic {
	
	//G.clear()
	//G.add(x, y, z)
	//G.dinic();
	
	const int MAXN = 310, MAXM = 1000010;

	const int ss = 0, tt = 305;
	const LL inf = 0x3f3f3f3f3f3f3f3fLL;

	using std::queue;
	
	struct Dinic_graph {
		queue<int>q;
		LL flow[MAXM];

		int cnt;
		int head[MAXN], data[MAXM], nxt[MAXM], cur[MAXN];

		int dis[MAXN];

		void clear() {
			cnt = 0;
			memset(head, -1, sizeof head);
		}

		void add(int x, int y, LL z) {
			nxt[cnt] = head[x]; data[cnt] = y; flow[cnt] = z; head[x] = cnt++;
			nxt[cnt] = head[y]; data[cnt] = x; flow[cnt] = 0; head[y] = cnt++;
		}

		bool bfs() {
			memset(dis, -1, sizeof dis);
			dis[ss] = 0; q.push(ss);

			while (!q.empty()) {
				int now = q.front(); q.pop();
				for (int i = head[now]; i != -1; i = nxt[i]) {
					if (flow[i] && dis[data[i]] == -1) {
						dis[data[i]] = dis[now] + 1;
						q.push(data[i]);
					}
				}
			}

			return dis[tt] != -1;
		}

		LL dfs(int now, LL fl) {
			LL ret = 0;
			if (now == tt) return fl;
			for (int &i = cur[now]; i != -1; i = nxt[i]) {
				if (!flow[i] || dis[data[i]] != dis[now] + 1) continue;
				if (ret = dfs(data[i], Min(fl, flow[i]))) {
					flow[i] -= ret;
					flow[i ^ 1] += ret;
					return ret;
				}
			}
			return 0;
		}

		LL dinic(void) {
			LL ret = 0;
			
			while (bfs()) {
				LL fl;
				memcpy(cur, head, sizeof head);
				while (fl = dfs(ss, inf)) ret += fl;
			}

			return ret;
		}
		
	} G;
	
}

using namespace __pyh_dinic;

int n;
int a[MAXN], b[MAXN];
int c[MAXN], d[MAXN];

int main()
{
	G.clear();

	in(n);
	FOR(i, 1, n) in(a[i]), in(b[i]);
	FOR(i, 1, n) in(c[i]), in(d[i]);

	FOR(i, 1, n) G.add(ss, i, 1), G.add(i + n, tt, 1);
	
	FOR(i, 1, n) FOR(j, 1, n) {
		if (a[i] < c[j] && b[i] < d[j]) G.add(i, j + n, 1);
	}
	
	printf("%lld\n", G.dinic());
	
	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef string S;
S st;
int main(){
	cin>>st;
	st=st.substr(0,st.size()-1);
	while(st.size()){
		if(st.size()%2!=1)st=st.substr(0,st.size()-1);
		S a=st.substr(0,st.size()/2);
		S b=st.substr(st.size()/2,st.size()/2);
		if(a==b)break;
		st=st.substr(0,st.size()-1);
	}
	printf("%d",st.size()-1);
	return 0;
}

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long y,const mint& m){ return m+y; }
mint operator*(long long y,const mint& m){ return m*y; }

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int main(){
	int n,k; scanf("%d%d",&n,&k);

	vector<mint> a(k+1);
	for(int i=k;i>0;i--){
		a[i]=pow(mint(k/i),n);
		for(int j=2*i;j<=k;j+=i) a[i]-=a[j];
	}

	mint ans=0;
	for(int i=1;i<=k;i++) ans+=i*a[i];
	printf("%d\n",ans.to_int());

	return 0;
}


Measured memory_bytes: 3792
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int a[205];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }

    int ans = 0;
    while(1){
        bool flag = false;
        for(int i = 1; i <= n; i++){
            if(a[i] % 2 != 0) flag = true;
            else a[i] /= 2;
        }

        if(flag) break;
        ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut acc = vec![0; n + 1];
    for i in 0..n {
        acc[i + 1] = acc[i] + a[i];
    }
    let mut result = 0usize;
    for i in 0..n - 1 {
        result = (result + a[i] * ((acc[n] - acc[i + 1]) % M) % M) % M;
    }
    println!("{}", result);
}


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

int main()
{
  int a,b;
  cin>>a>>b;
  string x=" ";
  string y=" ";
  for(int i=0;i<b;i++)
  {
    x=x+to_string(a);
  }
  for(int i=0;i<a;i++)
  {
    y=y+to_string(b);
  }
  //cout<<x<<" "<<y;
  if(x<=y)
    cout<<x;
  else
    cout<<y;
  
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(min(41, k)):
    t = [0] * (n+1)
    for j in range(n):
        t[max(0, j-a[j])] += 1
        t[min(j+a[j]+1, n)] -= 1

    for j in range(1, n):
        t[j] += t[j-1]
    a = t[:n]

print(*a)

Measured memory_bytes: 169376
n, t = map(int, input().split())
time = list(map(int, input().split()))
time_sum = 0
for i in range(n - 1):
  interval = time[i + 1] - time[i]
  if interval <= t:
    time_sum += interval
  else:
    time_sum += t
time_sum += t
print(time_sum)

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

void next(int i,vector<int64_t> &L){
    int64_t x;
    x=L.at(i-2)+L.at(i-1);
    L.push_back(x);
}

int main(){
    int n;
    cin>>n;
    vector<int64_t> L(2);
    L.at(0)=2;
    L.at(1)=1;
    if (n==1){
        cout<<1<<endl;
        return 0;
    }
    for(int i=2;i<=n;i++){
        next(i,L);
    }
    cout<<L.at(n)<<endl;
    return 0;
}

Measured memory_bytes: 256
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  
  int x =0;
  int n;
  cin >> n;
  string s;
  cin >> s;
  (s[0]=='D') ? x--: x++;
  int mx = max(0,x);
  for(int i=1;i<s.length();i++)
  {
      (s[i]=='D') ? x--: x++;
      mx = max(x,mx);
      //cout<<x<<" "; 
  }
  //cout<<endl;
  cout<<mx;
  return 0;
}


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

void bubbleSort( int* a, int n )
{
    for( int i = 0; i < n; i++ )
        for( int j = 0; j < n - 1; j++ )
        {
            if( a[j] > a[j+1] )
            {
                int temp = a[j];
                a[j] = a[j+1];
                a[j+1] = temp;
            }
        }
}

int waitingMinute( int* a, int* b, int x )
{
    if( x == 0 )
        return b[0] = a[0];
    
    if( b[x] != 0 )
        return b[x];
    else
        return b[x] = a[x] + waitingMinute( a, b, x - 1 );
}

int main()
{
    int n, a[10000], sum[10000] = {0};

    while( cin >> n )
    {
        if( n == 0 )
            break;

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

        bubbleSort( a, n );
        waitingMinute( a, sum, n - 1 );

        unsigned int s = 0;
        for( int i = 0; i < n - 1; i++ )
            s += sum[i];

        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 3388
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  cout<<((e-a)>k?":(":"Yay!");
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;



int main()
{
    fastInp;

    string s;
    cin >> s;
    
    ll sm =  0;
    for (auto e : s)
        sm += (e - '0');

    if (sm % 9 == 0) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#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(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007


int main()
{
  int A,B,C;
  cin >> A >> B >> C;
  if(A*C<=B)
    cout << C << endl;
  else
    cout << B/A << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int N = Integer.parseInt(str);
        str = br.readLine();
        long[] a = new long[N];
        int cont = 0;
        for (String s:str.split(" ")){
            a[cont] = Integer.parseInt(s);
            cont++;
        }
        int ans = 0;
        for (long i:a){
            while (i%2==0){
                if (i%2==0){
                    i/=2;
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}

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

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (unsigned i = (a); i <= (b); ++i)
#define per(i, a, b) for (unsigned i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

int main(int argc, char const *argv[]) {
  while (1) {
    VI v{1, 2, 3};
    L n;
    L ans = 1;
    cin >> n;
    if (n == 0) { break; }
    for (unsigned i = 0; i < n; i++) {
      S op;
      cin >> op;
      switch (op[0]) {
        case 'N':
          swap(v[0], v[1]);
          v[1] = 7 - v[1];
          break;
        case 'E':
          swap(v[0], v[2]);
          v[0] = 7 - v[0];
          break;
        case 'W':
          swap(v[0], v[2]);
          v[2] = 7 - v[2];
          break;
        case 'S':
          swap(v[0], v[1]);
          v[0] = 7 - v[0];
          break;
        case 'R':
          swap(v[1], v[2]);
          v[2] = 7 - v[2];
          break;
        case 'L':
          swap(v[1], v[2]);
          v[1] = 7 - v[1];
          break;
        default:
          break;
      }
      ans += v[0];
    }

    cout << ans << "\n";
  }

  return 0;
}

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


int main() {
	int N;//区間数
	int Length[200000] = { 0 };//各区間の長さ
	int pay = 0;//支払金額

	int P, B;//P=前(左) B=後ろ(右)
	long TLP = 0, TLB = 0;


	cin >> N;
	for (int n = 0; n < N; n++) cin >> Length[n];

	P = 0;
	B = N - 1;

	while (B-P >= 0) {
		if (TLP <= TLB) {
			TLP += Length[P];
			P++;
		}
		else {
			TLB += Length[B];
			B--;
		}
	}

	pay = abs(TLB - TLP);
	cout << pay << endl;

}

Measured memory_bytes: 1024
#!/usr/bin/env ruby
k = gets.chomp.to_i

@ans = []

def dfs(i)
  return if i > 3234566667

  @ans.push(i)
  mod = i % 10

  dfs(10 * i + mod - 1) if mod > 0
  dfs(10 * i + mod)
  dfs(10 * i + mod + 1) if mod < 9
end

1.upto(9) do |i|
  dfs(i)
end

@ans = @ans.sort
puts @ans[k-1]


Measured memory_bytes: 16988
import numpy as np

import copy

h,w,k = map(int, input().split())

masume=[]
for i in range(h):
  g=list(input())
  gnumber=[]
  for j in g:
    if j=="#":
      gnumber.append(1)
    else:
      gnumber.append(0)
  masume.append(gnumber)
#print(masume)

#print(np.array(masume))

masume=np.array(masume)

#print([2].append(4))

def aaa(num):
  if num==1:
    return [[0],[1]]
  else:
    tmp=aaa(num-1)
    #print(tmp)
    ret=[]
    for i in tmp:
      #print(i)
      tmp=copy.copy(i)
      i.append(0)
      tmp.append(1)
      ret.append(i)
      ret.append(tmp)
    #print(ret)
    return ret
  


#fff=np.matrix([0,0,0,1,1,1]).T*np.matrix([1,1,0,1,0,1])
#print(fff)
#print(masume)
#fff=np.array(fff)
#print(masume*fff)


tate=aaa(h)
yoko=aaa(w)

ans=0
for i in tate:
  for j in yoko:
    fff=np.matrix(i).T*np.matrix(j)
    #print(fff)
    #print(masume)
    fff=np.array(fff)
    koho=sum(sum(masume*fff))
    if koho==k:
      ans+=1

print(ans)

#for i in tate:
#  for j in yoko:
    #print(np.matrix(i).T*np.matrix(j))
    




Measured memory_bytes: 27120
#include <bits/stdc++.h>
#include <atcoder/all>

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

using namespace std;
using namespace atcoder;

using lint=long long;

int main(){
	int n,q; scanf("%d%d",&n,&q);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	fenwick_tree<lint> F(n);
	rep(i,n) F.add(i,a[i]);
	rep(_,q){
		int t,l,r; scanf("%d%d%d",&t,&l,&r);
		if(t==0) F.add(l,r);
		else     printf("%lld\n",F.sum(l,r));
	}

	return 0;
}


Measured memory_bytes: 12112
import java.util.*;

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

	while(true){
	    int n = in.nextInt();
	    if(n == 0) break;

	    int [] a = new int [n];
	    for(int i = 0 ; i < n ; i++){
		a[i] = in.nextInt();
	    }

	    int ans = 0;
	    for(int i = n-1 ; i > 0 ; i--){
		for(int j = 0 ; j < i ; j++){
		    if(a[j] > a[j+1]){
			int tmp = a[j];
			a[j] = a[j+1];
			a[j+1] = tmp;
			ans++;
		    }
		}
	    }
	    System.out.println(ans);
	}
    }
}

Measured memory_bytes: 20832
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 














const int N=3005;
int n,k;
ll a[N];
vector<pi> vec[N];
int main()
{
     cin>>n;
     for(int i=1;i<=n;i++)cin>>a[i];
     for(int i=0;i<N;i++){
          for(int j=0;j<N;j++)
          {
               vec[i].push_back(make_pair(0,0));
          }
     }
     for(int len=1;len<=n;len++)
     {
          for(int i=1;i<=n-len+1;i++)
          {
               int j=i+len-1;
               if(vec[i+1][j].second+a[i]>vec[i][j-1].second+a[j])
               {
                    vec[i][j].first=vec[i+1][j].second+a[i];
                    vec[i][j].second=vec[i+1][j].first;
               }
               else
               {
                    vec[i][j].first=vec[i][j-1].second+a[j];
                    vec[i][j].second=vec[i][j-1].first;
               }
          }
     }
     ll res=vec[1][n].first-vec[1][n].second;
     cout<<res;
     
     
     

}























 

Measured memory_bytes: 153472
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MINF = -1e9;;


int main() {
	int n, k;
	vector<int> h;
	cin >> n >> k;
	h.resize(n);
	rep(i, n) cin >> h[i];

	int cnt=0;
	rep(i, n) {
		if (k <= h[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
import os

def file_input():
    f = open('ABC167/input.txt', 'r')
    sys.stdin = f

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

def init_cmb(N,p):
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def main():
    #file_input()
    N,M,K=map(int, input().split())

    mod=998244353
    ans=0

    init_cmb(N,mod)
    for k in range(K+1):
        ans+=M*cmb(N-1,k,mod)*pow(M-1,N-1-k,mod)

    print(ans%mod)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32964
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N, K;
    cin >> N >> K;
    vint A(N);
    rep(i, N) {
        cin >> A[i];
    }
    auto S = accumulate(A.begin(), A.end(), 0);
    vint p_list;
    for (int i = 1; i <= int(sqrt(S)) + 1; i++) {
        if (S % i == 0) {
            p_list.push_back(i);
            p_list.push_back(S / i);
        }
    }
    sort(p_list.begin(), p_list.end(), greater<int>());


    for(auto &p : p_list) {
        vint B;
        int cnt = 0;
        rep(i, N) {
            if (A[i] % p != 0)
                cnt++;
            B.push_back(A[i] % p);
        }
        int S1 = 0, S2 = 0;
        sort(B.begin(), B.end());
        N = B.size();

        if (cnt == 0) {
            cout << p << endl;
            return 0;
        }
        rep(i, N) {
            S2 += p - B[i];
        }
        int need = INF;
        rep(i, N - 1) {
            S1 += B[i];
            S2 -= p - B[i];
            if (S1 == S2)
                need = min(need, S1);
            //need = min(need, max(S1, S2));
        }
        
        if (need <= K) {
            cout << p << endl;
            return 0;
        }


    }
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;

int main(){
	int N,K;
	cin>>N>>K;
	if(K==1){
		cout<<0<<endl;
	}else{
			cout<<(N-K)<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int K, X;
    cin >> K >> X;

    int sum = 500 * K;
    if (sum >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    size_t N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) {
        input(d[i]);
    }
    i64 res = 0;
    rep(i, N) reps(j, i + 1, N - 1) {
        res += d[i] * d[j];
    }
    outl(res);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=1337;
int main()
{
    ll n,m,c=0;
    cin>>n>>m;
    vector<ll>h(n),ans(n,0);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        if( h[a-1]<=h[b-1] )
        {
            ans[a-1]=1;
        }
        if(h[b-1]<=h[a-1])
        {
            ans[b-1]=1;
        }
    }
   for(int i=0;i<n;i++)
    {
     //   cout<<ans[i]<<" ";
        if(ans[i]==0){ c++; }
    }
    cout<<c<<"\n";
}


Measured memory_bytes: 4840
import numpy as np

x,k,d = map(int, input().split())

x = np.abs(x)

if x - k * d > 0:
	print(x - k * d)
elif x == d:
	if k % 2 == 0: print(x)
	else:print(0)
else:
	times = k - x // d
	num1 = x % d
	num2 = num1 - d
	if times % 2 == 0:
		print(np.abs(num1))
	else:
		print(np.abs(num2))


Measured memory_bytes: 27236
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn=100100;
int n;
int a[maxn];

int main(){
	n=read();
	rep(i,1,n) a[i]=read();
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	rep(i,1,n+1){
		if(a[i]<i){
			i--;
			int num=0;
			for(int j=i+1;j<=n;j++)
				if(a[j]==i) num++;
			if(num&1){
				puts("First");
				return 0;
			}
			if((a[i]-i)&1) puts("First");
			else puts("Second");
			return 0;
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int h, w;
    std::cin >> h >> w;
    std::vector<std::string> b(h);
    std::vector<std::vector<int>> s(h, std::vector<int>(w, -1));
    for (int i = 0; i < h; i++) std::cin >> b[i];
    for (int i = 0; i < h; i++) {
        int p = 0;
        for (int j = 0; j < w; j++) {
            if (b[i][j] == '#') {
                for (int k = p; k < j; k++) s[i][k] += j - p;
                p = j + 1;
            }
        }
        for (int k = p; k < w; k++) s[i][k] += w - p;
    }

    for (int i = 0; i < w; i++) {
        int p = 0;
        for (int j = 0; j < h; j++) {
            if (b[j][i] == '#') {
                for (int k = p; k < j; k++) s[k][i] += j - p;
                p = j + 1;
            }
        }
        for (int k = p; k < h; k++) s[k][i] += h - p;
    }

    int ret = 0;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        ret = std::max(ret, s[i][j]);
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 20096
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B = map(int, readline().split())
S=A-2*B
print(S if S>0 else 0)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main()
{
	int n;
	int l,r;
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>l>>r;
		sum+=r-l+1;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())
cmb = [list(map(int, input().split())) for _ in range(Q)]

def score(seq):
  s = 0
  for q in range(Q):
    if seq[cmb[q][1]-1] - seq[cmb[q][0]-1] == cmb[q][2]:
      s += cmb[q][3]
  return s

p = [i for i in range(1, M+1)]
A = itertools.combinations_with_replacement(p, N)
ans = 0
for a in A:
  ans = max(ans, score(a))
print(ans)

Measured memory_bytes: 9216
/**
 * auther: moririn_cocoa
 */
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second

int main(int argc, char* argv[]) {
  
  int R;
  
  cin >> R;
  
  if ( R < 1200 ) {
    
    cout << "ABC" << endl;
  }
  
  else if ( R >= 1200 && R < 2800 ) {
    
    cout << "ARC" << endl;
  }
  
  else {
    
    cout << "AGC" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		String ans[] = new String[100];
		char tmp[][] = new char[100][100];
		StringBuffer black = new StringBuffer();
		StringBuffer white = new StringBuffer();
		for (int i = 0; i < 100; ++i) {
			black.append("#");
			white.append(".");
		}
		int k = 50;
		for (int i = 0; i < k; ++i)
			tmp[i] = black.toString().toCharArray();

		for(int i = 0; i < k; ++i)
			tmp[i + 50] = black.toString().replaceAll("#", ".").toCharArray();
		
		int j = 0;
		for (int i = 0; i < a - 1; ++i) {
			int tmp2 = i * 2;
			tmp2 %= 100;
			if (tmp2 == 0)
				j += 2;
				tmp[j][tmp2] = '.';
		}
		j = 50;
		for(int i = 0; i < b - 1; ++i) {
			int tmp2 = i * 2;
			tmp2 %= 100;
			if(tmp2 == 0)
				j += 2;
			tmp[j][tmp2] = '#';
		}
		System.out.println(100 + " " + 100);
		for(int i = 0; i < 100; ++i) {
			for(j = 0; j < 100; ++j)
				System.out.print(tmp[i][j]);
			System.out.println();
		}
		
		
	}

}


Measured memory_bytes: 26324
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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






long long mod(998244353);
template<class T> class BinaryIndexTree{
    int n;
    std::vector<unsigned long long> data;
public:
    BinaryIndexTree(): n(0){}
    BinaryIndexTree(int m): n(m), data(m){}

    void add(int k, T a){
        ++k;
        a %= mod;
        if(a < 0) a += mod;
        while(k <= n){
            (data[k - 1] += a) %= mod;
            k += k & -k;
        }
    }

    T getSum(int l, int r){
        //[l, r[
        return ((T)sum(r) - (T)sum(l)) % mod;
    }
private:
    unsigned long long sum(int r){
        unsigned long long s(0);
        while(r > 0){
            (s += data[r-1]) %= mod;
            r -= r & -r;
        }
        return s;
    }
};


int main(){
    int N, K; std::cin >> N >> K;
    BinaryIndexTree<long long> BIT(N);
    BIT.add(0, 1); BIT.add(1, -1);
    std::vector<int> L(K), R(K);
    for(int i(0); i < K; ++i) std::cin >> L[i] >> R[i];
    for(int i(0); i < N; ++i){
        for(int j(0); j < K; ++j){
            long long a(BIT.getSum(0, i+1));
            BIT.add(i + L[j], a);
            BIT.add(i + R[j] + 1, -a);
        }
    }
    long long ans(BIT.getSum(0, N));
    if(ans < 0) ans += mod;
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 4840
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppl                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    int n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    f(i,0,n-1)  
        cout<<s1[i]<<s2[i];
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int r = parseInt(sc.next());
		int g = parseInt(sc.next());
		sc.close();
		out.println((g-r)*2+r);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N; cin >> N;
    vector<vector<Pii>> G(N);
    rep(i,N){
        int A; cin >> A;
        rep(j,A){
            int x,y; cin >> x >> y;
            G[i].push_back(Pii(--x,y));
        }
    }
    int ans=0;
    rep(bit,1<<N){
        bool ok=true;
        int cnt=0;
        rep(i,N){
            if (bit&1<<i){
                ++cnt;
                for (auto p:G[i]){
                    if (p.second==1&&(bit&1<<p.first)) continue;
                    if (p.second==0&&!(bit&1<<p.first)) continue;
                    ok=false;
                }
            }
        }
        if (ok) chmax(ans,cnt);
    }
    cout << ans << endl;
}

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

using namespace std;

const long long N = 2e5 + 5;
long long n;
long long a[N], ans;

pair<long long, long long> calc(long long c, long long d)
{
    if (c == 0)
    {
        return {0, 0};
    }
    else if (c == 1)
    {
        return {0, d};
    }

    pair<long long, long long> ans;
    if (d * 2 >= 10)
    {
        ans = calc(c / 2, ((d * 2) % 10) + ((d * 2) / 10));
        ans.first += c / 2 * 2;
    }
    else
    {
        ans = calc(c / 2, d * 2);
        ans.first += c / 2;
    }
    
    if (c & 1)
    {
        if (ans.second + d >= 10)
        {
            ans.first += 2;
            ans.second = ((ans.second + d) % 10) + ((ans.second + d) / 10);
        }
        else
        {
            ans.first += 1;
            ans.second = ans.second + d;
        }
    }

    return ans;
}

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

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        long long x, y;
        cin >> x >> y;

        pair<long long, long long> t = calc(y, x);
        a[i] = t.second;
        ans += t.first;
    }

    for (int i = 1; i < n; i++)
    {
        if (a[i] + a[i - 1] >= 10)
        {
            ans += 2;
        }
        else
        {
            ans++;
        }

        a[i] = ((a[i] + a[i - 1]) % 10) + ((a[i] + a[i - 1]) / 10);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 1792
import heapq
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
asum = sum(a)
c = []
csum = 0
num = []
for i,j in zip(a,b):
	if i<j:
		i = i + (j-i)
		ans += 1
	if i>j:
		heapq.heappush(num, -1*(i-j))
	csum += i


while csum>asum and len(num):
	i = heapq.heappop(num)*-1
	csum -= i
	ans += 1

if csum>asum: ans = -1
	
print(ans)



Measured memory_bytes: 18484
n, x = map(int, raw_input().split())
arr = map(int, raw_input().split())

def find_gcd(a, b):
    if b % a == 0:
        return a
    else:
        while b % a != 0:
            r = b % a
            b = a
            a = r
        return a

if n == 1:
    print abs(x - arr[0])
else:
    arr.append(x)
    arr.sort()
    dis_arr = []
    for i in range(n):
        dis_arr.append(abs(arr[i]-arr[i+1]))

    dis_arr.sort()
    for i in range(n-1):
        fir = dis_arr[i]
        sec = dis_arr[i+1]
        dis_arr[i+1] = find_gcd(fir, sec)
    print dis_arr[n-1]

Measured memory_bytes: 12384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

ll gcd(ll x,ll y){
    ll b=max(x,y),s=min(x,y);
    if(s<=0)return b;
    return gcd(s,b%s);
}

int main(){
    int K;
    cin>>K;
    ll ans=0;
    vector<vector<vector<ll>>> g(201,vector<vector<ll>>(201,vector<ll>(201,-1)));
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                ans+=gcd(gcd(i,j),k);
            }
        }
    }
    cout<<ans<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

using namespace std;
using ll = long long;
typedef pair<int, int> Pair;

const int MOD = 1000000007;

struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) {
  int x = a.n + b.n;
  return x - (x >= MOD) * MOD;
}
mint operator-(mint a, mint b) {
  int x = a.n - b.n;
  return x + (x < 0) * MOD;
}
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) {
  check_fact(abs(n));
  return n >= 0 ? I_[n] : -I_[n];
}
mint F(int n) {
  check_fact(n);
  return n < 0 ? 0 : F_[n];
}
mint R(int n) {
  check_fact(n);
  return n < 0 ? 0 : R_[n];
}
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

int n, m;
 
int main(){
  priority_queue<int> Q;
  scanf("%d%d",&n,&m);

  for(int i=0;i<n;i++){
    int x;
    scanf("%d",&x);
    Q.push(x);
  }

  for(int i=0;i<m;i++){
    int x = Q.top();
    Q.pop();
    Q.push(x/2);
  }

  long long int r = 0;
  
  while(!Q.empty()){
    r += Q.top();
    Q.pop();
  }

  printf("%lld\n", r);
  return 0;
}

Measured memory_bytes: 892
Option Strict On

Module Module1
    Const n As Int32 = 3
    Dim A, B, C, tmp(n - 1) As Long

    Sub Main()
        'let'
        tmp = Array.ConvertAll(Of String, Long) _
            (Console.ReadLine.Split(), AddressOf Long.Parse)
        A = tmp(0) : B = tmp(1) : C = tmp(2)

        Console.WriteLine _
            (New String() {"Yes", "No"}(Convert.ToInt32(A + B < C)))

    End Sub
End Module

Measured memory_bytes: 13268
#include <iostream>
#include<math.h>
using namespace std;
int main(void){
    // Here your code !
    int N,T;
    cin>>N>>T;
    long long int t[N],ans[N];
    for(int i=0;i<N;i++){
        cin>>t[i];
    }
    ans[0]=T;
    for(int i=1;i<N;i++){
        ans[i]=ans[i-1]+fminl(T,t[i]-t[i-1]);
    }
    cout<<ans[N-1]<<endl;
}


Measured memory_bytes: 3328