akhauriyash/Code-Regression huggingface dataset:
N, Q = map(int, input().split())
s = str(input())
coms = [list(map(str, input().split())) for _ in range(Q)]


def isOK(A, index, coms, c):
    # シミュレーションを行う
    for com in coms:
        if com[0] == A[index]:
            if com[1] == 'R':
                index += 1
                if index == len(A):
                    return c == 'R'
            elif com[1] == 'L':
                index -= 1
                if index == -1:
                    return c == 'L'
    return False


def lower_bound(A, coms):
    ng = -1
    ok = len(A)

    while(abs(ok-ng) > 1):
        mid = (ok + ng) // 2

        if isOK(A, mid, coms, 'R'):
            ok = mid
        else:
            ng = mid
    return ok


def upper_bound(A, coms):
    ng = len(A)
    ok = -1

    while(abs(ok-ng) > 1):
        mid = (ok + ng) // 2

        if isOK(A, mid, coms, 'L'):
            ok = mid
        else:
            ng = mid
    return ok


lower = lower_bound(s, coms)
upper = upper_bound(s, coms)
print(lower-upper-1)

Measured memory_bytes: 39356
#include<iostream>
using namespace std;
int main(){
        int n,i,j;
        cin >> n;
        int a[3];
        a[0] = n%10;
        a[1] = n/10%10;
        a[2] = n/100;
        for(i=a[2]-1;i<10;i++){
                j = i+1;
                if((n<=(j*100+j*10+j))&&(n>(i*100+i*10+i))){
                         break;
                }
        }
        cout << j * 100 + j *10 + j << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll L, R, A, B, C, D;
    scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
    L = A+B;
    R = C+D;
    if(L==R) printf("Balanced\n");
    else if(L>R) printf("Left\n");
    else printf("Right\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
 
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
 
#define csh(a,n) memset(a,n,sizeof(a));
int main(){
	ll n;
	ll k;
	cin>>n>>k;
	ll sum=0;
	if(k==0){
		cout<<n*n<<endl;
		return 0;
	}
	for(ll i=k+1;i<=n;i++){
		ll p=n/i;
			sum+=p*(i-k);
			sum+=(n%i>=k)?(n%i)-k+1:0;

	}
	cout<<sum<<endl;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll  long long
#define pb  push_back
#define fi  first
#define se  second
#define mp  make_pair
#define FOR(i,n,m)  for(int i=0;i<n;i+=m)
#define For(i,n,m)  for(int i=1;i<=n;i+=m)
#define clr(x,val)  memset(x,val,sizeof(x))
#define __          int t; scanf("%d",&t); while(t--)
const double pi=acos(-1.0);
int main(){
   vector<ll> v;
   ll ind=-1,x;
   FOR(i,3,1) { cin>>x; v.pb(x); if(x%2==0) ind=i; }
   sort(v.begin(),v.end());
   if(ind!=-1) cout<<0<<endl;
   else cout<<v[0]*v[1]<<endl;
  return 0;
}

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

int main()
{
    int N;
    std::cin >> N;
    int N1=N/100;
    int N3=(N-N1*100)%10;
    if(N1==N3){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        s: chars,
        t: chars
    }
    for i in 0..n {
        print!("{}{}", s[i], t[i]);
    }
    println!("");
}


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

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

void solve(long long N){
    std::string ns = std::to_string(N);
    if (ns[1] == ns[2] && (ns[0] == ns[1] || ns[2] == ns[3])) cout << YES << endl; else cout << NO << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3752
/*2019/07/29 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
/*
int asc_t(const void *a,const void *b){return ((user_t*)a)->score - ((user_t*)b)->score;}
int desc_t(const void *a,const void *b){return ((user_t*)b)->score - ((user_t*)a)->score;}
*/

int main(){
    char str[10000];
    int a;
    scanf("%d",&a);
    scanf("%s",str);

    if(a>=3200){
        printf("%s\n",str);
    }else{
        printf("red\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;

int main(){
    ll n;cin>>n;
    string s=to_string(n);
    int a=0;
    for(char x:s)a+=x-'0';
    if(n%a)cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())

MOD = 10 ** 9 + 7
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        for k in range(1 << (W - 1)):
            # 横同士の繋がり
            ok = True
            for l in range(W - 2):
                if (k >> l) & 1 and (k >> (l + 1) & 1):
                    ok = False

            if not ok:
                continue

            if j > 0 and k >> (j - 1) & 1:
                dp[i + 1][j - 1] += dp[i][j]
                dp[i + 1][j - 1] %= MOD
            elif j < W - 1 and k >> j & 1:
                dp[i + 1][j + 1] += dp[i][j]
                dp[i + 1][j + 1] %= MOD
            else:
                dp[i + 1][j] += dp[i][j]
                dp[i + 1][j] %= MOD

print(dp[-1][K - 1])


Measured memory_bytes: 45036
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;

ll flg[33][101010];

int main(){

	ll N, C;
	cin >> N >> C;
	for(ll i = 0; i < N; i++){
		ll s, t, c;
		cin >> s >> t >> c;
		for(ll j = s; j <= t; j++)flg[c][j] = 1;
	}
	ll ans = 0;
	for(ll i = 1; i <= 101000; i++){
		ll cnt = 0;
		for(ll j = 1; j <= C; j++)cnt += flg[j][i];
		ans = max(ans, cnt);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define trav(a, x) for(auto& a : x)
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n,a,b;
    cin >> n >> a >> b;

    cout << min(a,b) << " " << max(0,a+b-n) << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
ans = 0
ab = []
for i in range(n):
  ab.append(list(map(int,input().split())))
ab.sort()

i = 0
while m > 0:
  if m > ab[i][1]:
    ans = ans + ab[i][0]*ab[i][1]
  else:
    ans = ans + ab[i][0]*m
  m -= ab[i][1]
  i += 1

print(ans)

Measured memory_bytes: 27756
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const solve = (arr, q) => {
    const result = [];
    let time = 0;
    for (;arr.length !== 0;) {
        const currentQ = arr.shift();
        if (currentQ[1] - q <= 0) {
            const endQ = [currentQ[0], currentQ[1] + time];
            result.push(endQ);
            time += currentQ[1];
        } else {
            const newQ = [currentQ[0], currentQ[1] - q];
            arr.push(newQ);
            time += q;
        }
    } 

    return result;
};

const q = parseInt(line[0].split(' ')[1]);
const data = line.slice(1, line.length-1).map(x => x.split(' ')).map(x => [x[0], parseInt(x[1])]);
const ans = solve(data, q, 0).map(x => x[0] + ' ' + x[1]).join('\n');

console.log(ans);



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

int main() {
  int n;
  cin >> n;
  // 全部偶数なら先手が負ける
  // 後手は先手のマネをすることで、相手の手番に常に全て偶数にすることができる
  // つまり、後手が最後の林檎を食べられる
  // 一つでも奇数があれば、後手の手番を全て偶数にできる
  bool even = true;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a % 2 == 1)
      even = false;
  }
  if (even)
    cout << "second" << endl;
  else
    cout << "first" << endl;
}


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

int main()
{
	int n,d,i;
	cin>>n>>d;
	double di;
	int x,y,c=0;
	for(i=0;i<n;i++)
	{
	    cin>>x>>y;
	    di=sqrt(pow(x,2)+pow(y,2));
	    if(di<=double(d))
	    {
	        c++;
	    }
	}
	cout<<c<<"\n";
	return 0;
}

Measured memory_bytes: 3676
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		int result = 0;
		for(int i = 0; i < s.length(); i++){
		    if(i%2 == 1) continue;
		    System.out.print(s.charAt(i));
		}
		
		// 出力
		//System.out.println(result);
	}
}



Measured memory_bytes: 31368
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 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()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  //vector<string> in(N); rep(i,N) cin>>in[i];
  
  vector<string> vec(N+1,"");
  cout<<0<<'\n'<<flush;
  string s; cin>>s; if(s=="Vacant") return 0;
  //string s=in[0]; if(s=="Vacant") return 0;
  vec[0]=s,vec[N]=s;
  ll left=0,right=N;
  while(true){
    ll mid=(left+right)/2;
    cout<<mid<<'\n'<<flush;
    //cout<<left<<" "<<mid<<" "<<right<<'\n';
    string ss; cin>>ss; if(ss=="Vacant") return 0;
    //string ss=in[mid]; cout<<in[mid]<<'\n'; if(ss=="Vacant") return 0;
    vec[mid]=ss;
    if((mid-left+1)%2==0&&vec[left]==vec[mid]) {right=mid; continue;}
    if((mid-left+1)%2==1&&vec[left]!=vec[mid]) {right=mid; continue;}
    if((right-mid+1)%2==0&&vec[right]==vec[mid]) {left=mid; continue;}
    if((right-mid+1)%2==1&&vec[right]!=vec[mid]) {left=mid; continue;}
  }
  return 0;
}

Measured memory_bytes: 6284
main :: IO ()
main = do
  [a,b,c,x,y] <- map read . words <$> getLine
  print $ solve a b c x y

solve :: Int -> Int -> Int -> Int -> Int -> Int
solve a b c x y
  | x > y = minimum [2*c*x, 2*c*y + a*(x-y), a*x + b*y]
  | x < y = minimum [2*c*y, 2*c*x + b*(y-x), a*x + b*y]
  | otherwise = minimum [2*c*x, a*x + b*y]


Measured memory_bytes: 508
#pragma comment(linker, "/STACK:60777216")  

#include <cassert>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdlib>
#include<memory.h>
#include<ctime>
#include<bitset>
#include<fstream>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>

using namespace std;

typedef long double ld;

typedef long long ll;
typedef pair<int,int>	pii;
typedef pair<ld,ld>	pdd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef pair<ll,ll> pl;

#define FOR(i,a,b)		for(int i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)				memset(a,b,sizeof a)
#define pb				push_back

int p[22222];
int r[22222];
int a[22222];
int b[22222];

int main(){	
#ifdef LocalHost
	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif

	int n;
	cin>>n;
	REP(i,n)cin>>p[i],p[i]--,r[p[i]]=i;

	REP(i,n){
		a[i] = 1 + n * i;
		b[i] = 1 + n * (n-i);
	}

	REP(i,n)a[p[i]]+=i;

	REP(i,n){
		if(i)printf(" ");
		printf("%d",a[i]);
	}
	puts("");
	REP(i,n){
		if(i)printf(" ");
		printf("%d",b[i]);
	}
	puts("");


#ifdef LocalHost
	printf("TIME: %.3lf\n",ld(clock())/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 896
--{-# LANGUAGE OverloadedStrings #-}
--{-# LANGUAGE OverloadedLists   #-}
{-# LANGUAGE BangPatterns      #-} --引数に!
{-# LANGUAGE MultiWayIf        #-}
{-# LANGUAGE TupleSections     #-}

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import Data.Array  --変数衝突
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import qualified Data.Vector.Unboxed as V
import Control.Monad
import Control.Monad.State
import Control.Monad.ST
import qualified Data.ByteString.Lazy.Char8 as B
--import Debug.Trace

type Ans = Int

cntAB :: String -> Int
cntAB [] = 0
cntAB ('A':'B':str) = 1+(cntAB str)
cntAB (s:str) = cntAB str

cntjoint :: [B.ByteString] -> Int -> Int -> Int -> Int
cntjoint [] a b ba =
  if (a == 0 && b >= 1) || (b == 0 && a >= 1) then ba
    else if a == 0 && b == 0 then max (ba-1) 0
      else ba+1+(min (a-1) (b-1))
cntjoint (bs:bss) a b ba =
  if B.last bs == 'A' && B.head bs == 'B' then cntjoint bss a b (ba+1)
    else if B.last bs == 'A' then cntjoint bss (a+1) b ba
      else if B.head bs == 'B' then cntjoint bss a (b+1) ba
        else cntjoint bss a b ba

solve :: Int -> [B.ByteString] -> Int
solve n bss = (cntjoint bss 0 0 0) + (sum $ map (cntAB. B.unpack) bss)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

main0 :: B.ByteString -> Ans
main0 cont =
  let remLines0 = map B.words (B.lines cont)
      [n']:remLines1 = remLines0
      n = readBInt n'
      bss = take n remLines1
  in solve n (map (\[x] -> x) bss)

main :: IO ()
main = print . main0 =<< B.getContents


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

 using namespace std;

 int main() {
   int N, K, i, ans;

   cin >> N >> K;

   vector<int> l(N);

   for (i = 0; i < N; i++) cin >> l.at(i);

   sort(l.begin(), l.end());
   reverse(l.begin(), l.end());

   ans = 0;
   for (i = 0; i < K; i++) {
     ans += l.at(i);
   }

   cout << ans << endl;
 }


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

int main() {
    int N;
    cin>>N;
    int P[N];
    for(int i=0;i<N;++i){
        cin>>P[i];
        P[i]--;
    }
    int DP[N];
    for(int i=0;i<N;++i){
        DP[i] = 0;
    }
    for(int i=0;i<N;++i){
        if(P[i]==0)DP[0]++;
        else{
            if(DP[P[i]-1]>0) DP[P[i]] = DP[P[i]-1] + 1;
            else DP[P[i]] = 1;
        }
    }
    int ans = 0;
    for(int i=0;i<N;++i){
        if(ans < DP[i])ans = DP[i];
    }
    cout<<N-ans<<endl;
}


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

int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  map<string,int> mp1,mp2;
  rep(i,n){
    cin>>s[i];
    mp1[s[i]]++;
  }
  int m;
  cin>>m;
  vector<string> t(m);
  set<string> st;
  rep(i,m){
    cin>>t[i];
    mp2[t[i]]++;
    //st.insert(t[i]);
  }
  int ans=0;
  /*rep(i,n){
    if(!st.count(s[i])){
      ans++;
    }
  }*/
  for(auto p:mp1){
    if(p.second-mp2[p.first]>ans){
      ans=p.second-mp2[p.first];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
d = defaultdict(int)
for i in range(n):
    s = input()
    d[s] += 1
print('AC x ' + str(d['AC']))
print('WA x ' + str(d['WA']))
print('TLE x ' + str(d['TLE']))
print('RE x ' + str(d['RE']))


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

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

		int total = 0;
		for(int i=0; i<n; i++){
			int l = sc.nextInt();
			int r = sc.nextInt();

			total += (r - l + 1);	
		}

		System.out.println(total);
	}
}


Measured memory_bytes: 27732
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int H,N,A,i,sum=0;
    bool x=false;
    scanf("%ld",&H);
    scanf("%ld",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&A);
        sum=sum+A;
        if(sum>=H)
        {
            x=true;
        }
    }
    if(x==true)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

}


Measured memory_bytes: 256
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s
  let w = map solve v
  let x = map (\x-> if x then "YES" else "NO") $ w
  mapM_ putStrLn x

solve::[Double] -> Bool
solve [xa,ya,xb,yb,xc,yc,xd,yd] =
  abs(dot u v)/len(u)/len(v) < eps
  where u = (xb-xa, yb-ya)
        v = (xd-xc, yd-yc)
        dot (a,b) (c,d) = a*c + b*d
        len (a,b) = sqrt(a^2+b^2)
        eps=1e-9

Measured memory_bytes: 4428
// Last Change: 09/01/2019 21:24:44.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

  cout << (1 + (N - 1)) * (N - 1) / 2 << endl;
}


Measured memory_bytes: 888
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        
        if (n >= 30) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();

        }

    }



Measured memory_bytes: 35620
#include<bits/stdc++.h>
using namespace std;
long long n,a[200005],dp[200005];
long long solve(long long k)
{
    if(k>n)
    return 2000000000;
    if(k==n)
    return 0;
    if(dp[k]!=-1)
    return dp[k];
    dp[k]=min(solve(k+1)+abs(a[k]-a[k+1]),solve(k+2)+abs(a[k]-a[k+2]));
    return dp[k];
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    dp[i]=-1;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    cout<<solve(1);
    return 0;
}

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

using namespace std;

int main()
{
	int year, month, day;
	scanf("%d/%d/%d", &year, &month, &day);

	if
	(
		(year > 2019) ||
		(year == 2019 && month > 4) ||
		(year == 2019 && month == 4 && day > 30)
	)
		cout << "TBD" << endl;
	else
		cout << "Heisei" << endl;

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
bool prime(int N){
	if(N==1)
		return 0;
	for(int i=2;i*i<=N;i++){
		if(N%i==0)
			return 0;
	}
	return 1;
}
int main(){
	int Q;
	cin>>Q;
	int isprime[SIZE]={};
	for(int i=1;i<SIZE;i++)
		isprime[i]=(i%2 && prime(i) && prime((i+1)/2));
	for(int i=0;i<SIZE-1;i++){
		isprime[i+1]+=isprime[i];
	}
	for(int i=0;i<Q;i++){
		int l,r;
		cin>>l>>r;
		cout<<isprime[r]-isprime[l-1]<<endl;
	}
	return 0;
}

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

int main(){
  string T;
  cin >> T;
  
  int N = T.size();
  
  for(int i=0;i<N;i++){
    if(T.at(i) == '?') cout << "D";
    else cout << T.at(i);
  }
}

Measured memory_bytes: 3752
from collections import defaultdict
n = int(input())
L = list(map(int, input().split()))
L.sort()
s = defaultdict(int)
for l in L:
    s[l] += 1
L = set(L)

s = dict(s)
ans = 0
for a in L:
    for b in L:
        for c in L:
            if a < b and b < c and a+b > c and b+c > a and c+a > b:
                ans += s[a]*s[b]*s[c]
print(ans)


Measured memory_bytes: 9472
#include <iostream>
#include <cstdio>
using namespace std;
long long n, m;
long long ans = 9223372036854775807;
int main(){
	register long long i, j, k;
	cin >> n;
	for(i = 1; i * i <= n; ++i){
		if(n % i == 0)ans = min(ans,(i+n/i)-2);
	}
	cout << ans << endl;
	return 0;
}

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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

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

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
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 SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int MAXN = 2E5 + 10;

int n, K;
ll a[MAXN];

int s[MAXN];

void update(int i, int c){
	for (; i <= n + 1; i = (i | i - 1) + 1)
		s[i] += c;
}

int query(int i){
	int ret = 0;
	for (; i > 0; i &= i - 1)
		ret += s[i];
	return ret;
}

int main(){
	scanf("%d%d", &n, &K);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", a + i), a[i] -= K;

	vector<ll> c(1, 0);
	for (int i = 1; i <= n; ++i){
		a[i] += a[i - 1];
		c.push_back(a[i]);

		eput(i, a[i]);
	}
	sort(all(c));
	c.erase(unique(all(c)), c.end());
	for (int i = 0; i <= n; ++i)
		a[i] = lower_bound(all(c), a[i]) - c.begin() + 1;

	ll ans = 0;
	for (int i = 1; i <= n; ++i){
		update(a[i - 1], 1);
		ans += query(a[i]);

		eput(i, a[i - 1], ans);
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 4336
// https://atcoder.jp/contests/abc161/tasks/abc161_d

use proconio::fastout;
use proconio::input;
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! { k: u32 }
    let mut queue: VecDeque<u64> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9].into_iter().collect();
    let mut ans = 0;
    for _ in 1..=k {
        let x = queue.pop_front().unwrap();
        ans = x;
        let base = 10 * x + x % 10;
        if x % 10 != 0 {
            queue.push_back(base - 1);
        }
        queue.push_back(base);
        if x % 10 != 9 {
            queue.push_back(base + 1);
        }
    }
    println!("{}", ans);
}


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

int main() {

	int a, b;

	cin >> a >> b;

	if (a >= 13) {
		cout << b << endl;
	}
	else if (a <= 12 && a >= 6) {
		cout << b / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;

}

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

int main(){
    int n;
    int x = 0;

    cin >> n;
    if(n>=10){
        x = n % 10;
    }else if(n>=100){
        x = n % 100;
    }else{
        x = n;
    }

    string s;
    switch (x)
    {
    case 3:
        s = "bon";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        s = "pon";
        break;
    default:
        s = "hon";
        break;
    }

    cout << s << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(c-a-b<=0) {
    cout << "No" << endl;
    return 0;
  }
  if(4*a*b<(c-a-b)*(c-a-b)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int a,b[10000],min=10000000000,max=-10000000000,c;
    scanf("%d",&a);
    for(int i=0;i<a;i++){
        scanf("%d",&b[i]);
    }
    for(int i=0;i<a;i++){
        if(min>b[i]) min=b[i];
        if(max<b[i]) max=b[i];
    }
    printf("%d",max-min);
    return 0;
}


Measured memory_bytes: 128
//ΔARC 078C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
int a[222222];
LL ab(LL x)
{
	if(x<0)
		return -x;
	return x;
}
int main()
{
	int n,i;
	LL s,p,ans;
	scanf("%d",&n);
	s=0;
	for(i=1;i<=n;i=i+1){
		scanf("%d",a+i);
		s+=(LL)a[i];
	}
	p=0;
	ans=(LL)1<<60;
	for(i=1;i<n;i=i+1){
		p+=a[i];
		ans=min(ans,ab(s-p-p));
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
int n;
int a[10][10][10]={};
cin>>n;

for(int i=0;i<n;i++){
int x,y,g,h;
cin>>x>>y>>g>>h;
a[x][y][g]+=h;
}

for(int x=1;x<5;x++){
for(int y=1;y<4;y++){
for(int g=1;g<11;g++){
cout<<" "<<a[x][y][g];
}
if(x==10 && y==3){}
else{cout<<endl;}
}
if(x<4){cout<<"####################"<<endl;}
}



return 0;
}


Measured memory_bytes: 3088
while True:

	a, op, b = map(str, raw_input().split())

	a = int(a)
	b = int(b)

	if op == '+':
		print a + b
	elif op == '-':
		print a - b
	elif op == '*':
		print a * b
	elif op == '/':
		if b != 0:
			print a / b
	elif op == '?':
		break
	else:
		break

Measured memory_bytes: 6456
#include<bits/stdc++.h>
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 (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

    int N; cin>>N;
    const int MAX=1000;
    vector<vector<int>> sum(MAX+1,vector<int>(MAX+1));
    for(int i=0;i<N;i++){
        int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
        sum[y1][x1]++; sum[y1][x2]--;
        sum[y2][x1]--; sum[y2][x2]++;
    }
    for(int i=0;i<=MAX;i++){
        for(int j=1;j<=MAX;j++) sum[i][j]+=sum[i][j-1];
    }
    for(int j=0;j<=MAX;j++){
        for(int i=1;i<=MAX;i++) sum[i][j]+=sum[i-1][j];
    }
    int ans=0;
    for(int i=0;i<=MAX;i++) for(int j=0;j<=MAX;j++){
        chmax(ans,sum[i][j]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6828
import sys


def resolve():
    for line in sys.stdin:
        h, w = map(int, line.split())

        if h == w == 0:
            return

        for i in range(h):
            if i % 2 == 0:
                for j in range(w):
                    if j % 2 == 0:
                        print('#', end='')
                    else:
                        print('.', end='')
            else:
                for j in range(w):
                    if j % 2 == 1:
                        print('#', end='')
                    else:
                        print('.', end='')
            print()
        print()


resolve()


Measured memory_bytes: 7008
#include <stdio.h>

int main(void){
  int k,a,b;
  int i;
  int flag = 0;
  
  scanf("%d %d %d",&k, &a, &b);
  
  for(i = a; i <= b; i++){
    if(i % k == 0)flag = 1;
  }
  
  if(flag == 1){
    printf("OK\n");
  }else{
    printf("NG\n");
  }
  
  return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0010
{
    class Program
    {
        static void Main(string[] args)
        {
           
              
            int n = int.Parse(Console.ReadLine());
            double[] px = new double[n];
            double[] py = new double[n];
            double[] r = new double[n];
            for (int i = 0; i < n; i++)
            {
                double[] array = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
                double x1 = array[0];
                double y1 = array[1];
                double x2 = array[2];
                double y2 = array[3];
                double x3 = array[4];
                double y3 = array[5];
                double xx1 = array[0] * array[0];
                double yy1 = array[1] * array[1];
                double xx2 = array[2] * array[2];
                double yy2 = array[3] * array[3];
                double xx3 = array[4] * array[4];
                double yy3 = array[5] * array[5];

                px[i] = (2 * (y2 - y1) * (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3) - 2 * (y3 - y1) * (x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2)) / (2 * (x2 - x1) * 2 * (y3 - y1) - 2 * (x3 - x1) * 2 * (y2 - y1));
                py[i] = ((x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2) * 2 * (x3 - x1) - (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3) * 2 * (x2 - x1)) / (2 * (x2 - x1) * 2 * (y3 - y1) - 2 * (x3 - x1) * 2 * (y2 - y1));
                r[i] = Math.Sqrt((px[i] - x1) * (px[i] - x1) + (py[i] - y1) * (py[i] - y1));

                Console.WriteLine(px[i].ToString("f3") + " " + py[i].ToString("f3") + " " + r[i].ToString("f3"));

            }
        }
    }
}



Measured memory_bytes: 18336
#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=3e5+5;
string no="NO",yes="YES";
const unsigned int MOD = 1000000007;
int max_char=26;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    while(t--)
    {

    ll l,r,d;
    cin>>l>>r>>d;
    ll sum=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            sum++;
    }
    cout<<sum;
    }
    return 0;
}













Measured memory_bytes: 3636
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

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

int main() {
	int h, w;
	string f[50];
	cin >> h >> w;
	for (int i = 0; i < h; ++i)
		cin >> f[i];

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (f[i][j] == '.') {
				int cnt = 0;
				for (int k = 0; k < 8; ++k) {
					int ny = i + dy[k];
					int nx = j + dx[k];
					if (ny < 0 || ny >= h || nx < 0 || nx >= w)
						continue;

					if (f[ny][nx] == '#')
						cnt++;
				}
				cout << cnt;
			}
			else {
				cout << '#';
			}
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    for(int i=0; i<2; i++){
        for(int j=0; j<N; j++){
            cin >> A.at(i).at(j);
        }
    }
    int mx = 0;
    int temp = 0;
    int r = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            temp += A.at(r).at(j);
            if(i==j){
                r = 1;
                temp += A.at(r).at(j);
            }
        }
        mx = max(temp, mx);
        temp = 0;
        r = 0;
    }
    cout << mx << endl;
}

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

int w,h;
bool map[50][50];

void Del(int x,int y){

  map[y][x]=false;

  if(x!=w-1){
    if(map[y][x+1]==true){
      Del(x+1,y);
    }

    if(y!=0){
      if(map[y-1][x+1]==true){
        Del(x+1,y-1);
      }
    }
    if(y!=h-1){
      if(map[y+1][x+1]==true){
        Del(x+1,y+1);
      }
    }

  }


  if(x!=0){
    if(map[y][x-1]==true){
      Del(x-1,y);
    }
    if(y!=0){
      if(map[y-1][x-1]==true){
        Del(x-1,y-1);
      }
    }
    if(y!=h-1){
      if(map[y+1][x-1]==true){
        Del(x-1,y+1);
      }
    }

  }


  if(y!=h-1){
    if(map[y+1][x]==true){
      Del(x,y+1);
    }
  }
  if(y!=0){
    if(map[y-1][x]==true){
      Del(x,y-1);
    }
  }

}


int main(){


  int sum;

  while(cin >> w >> h){
    if(w==0 && h==0){ break; }

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        cin >> map[i][j];
      }
    }

    sum = 0;

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        if(map[i][j]==1){
          sum++;
          Del(j,i);
        }
      }
    }

    cout << sum << endl;

  }



  return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vint p[26];

int get_id(char a, int s) {
    int id = a - 'a';
    return *lower_bound(all(p[id]), s);
}

int main() {
    string s, t;
    cin >> s >> t;
    int sl = s.length();
    int tl = t.length();

    rep(i, sl) {
        int id = s[i] - 'a';
        p[id].push_back(i);
    }

    ll ans = 0;
    ll id = 0;
    rep(i, tl) {
        if (p[t[i]-'a'].size() == 0) {
            puts("-1");
            return 0;
        }
    }

    char prev = 'A';
    rep(i, tl) {
        bool c = prev == t[i];
        if (p[t[i]-'a'].back() < id+c) {
            id = 0;
            c = false;
            ans += sl;
        }
        id = get_id(t[i], id+c);
        prev = t[i];
    }
    ans += id;
    ans++;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int r,g; cin >> r >> g;
    cout << 2*g-r << endl;
    return 0;
}

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

sum_A = sum(A)
sum_B = sum(B)

diff = []
neg = 0
count = 0

if sum_B > sum_A:
    print(-1)
    exit()

for a, b in zip(A, B):
    diff += [a-b]
    if a < b:
        count += 1
        neg += a - b

for d in sorted(diff, reverse=True):
    if neg >= 0:
        break
    count += 1
    neg += d

print(count)

Measured memory_bytes: 18524
#include <cstdio>
#include <cstring>
#include <iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
template<class T> void rd(T &x) {
	x=0; int f=1,ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=getchar();}
	x*=f;
}
template<class T> inline bool Cmin(T &x,T y) {return x>y?x=y,1:0;}
const int mod=998244353;
const int maxn=300+5;
int n,k; char S[maxn];
int a[maxn];
int dp[maxn][maxn][maxn];
inline void add(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
inline void sub(int &x,int y) {x-=y; if(x<0) x+=mod;}
void init() {
	int len=strlen(S);
	S[len]='0';
	for(int i=0,cnt=0;i<=len;++i) {
		if(S[i]=='0') a[++n]=cnt,cnt=0;
		else ++cnt;
	}
	int sum=0;
	for(int i=1;i<=n;++i) sum+=a[i];
	Cmin(k,sum);
}
int main() {
	scanf("%s",S);
	rd(k);
	init();
	dp[0][0][0]=1;
	for(int i=1;i<=n;++i) {
		for(int j=0;j<=k;++j) for(int h=j;h<=k;++h) {
			add(dp[i][j][h],dp[i-1][j][h]);
			if(j&&h) add(dp[i][j][h],dp[i][j-1][h-1]);
		}
		for(int h=0;h<=k;++h) {
			int sum=0;
			for(int j=h;j>=0;--j) {
				add(sum,dp[i-1][j+1][h]);
				if(j+a[i]<h) sub(sum,dp[i-1][j+a[i]+1][h]);
				add(dp[i][j][h],sum);
			}
		}
	}
	int an=0;
	for(int h=0;h<=k;++h) {
		add(an,dp[n][0][h]);
	}
	printf("%d\n",an);
	return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

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

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

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

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

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

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

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

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

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(i64, a, b, c, d, e, k);
  outl(e - a <= k ? "Yay!" : ":(");

  return 0;
}


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

class flower{
public:
	string name;
	int bo,si;
	flower(string name,int si,int bo):name(name),bo(bo),si(si){}
};

bool operator < (flower a,flower b){
	if(a.si*b.bo!=b.si*a.bo) return a.si*b.bo>b.si*a.bo;
	else return a.name<b.name;
}

int main()
{
	int n;
	while(cin>>n && n!=0){
		vector<string> F(n);
		vector<flower> ans;
		int p[50],a[50],b[50],c[50],d[50],e[50],f[50],s[50],m[50];
		for(int i=0;i<n;i++){
			cin>>F[i]>>p[i]>>a[i]>>b[i]>>c[i]>>d[i]>>e[i]>>f[i]>>s[i]>>m[i];
			ans.push_back(flower(F[i],(s[i]*f[i]*m[i]-p[i]),(a[i]+b[i]+c[i]+(d[i]+e[i])*m[i])));
//			cout<<ans[i].k<<endl;
//			cout<<ans[i].name<<endl;
		}
		sort(ans.begin(),ans.end());
		for(int i=0;i<n;i++)
			cout<<ans[i].name<<endl;
		cout<<"#"<<endl;
	}
}

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


char a[102][102];
int dx[]={ 0,1,0,-1};
int dy[]={-1,0,1,0};

int main(){
	bool fst=true;
	int n;
	cin>>n;
	while(n--){
		memset(a,' ',sizeof(a));
		int m,y,x,dir;
		cin>>m;
		if(m==1){
			if(!fst)cout<<endl;		
			cout<<"#\n";
			fst=false;
			continue;
		}
		y=m;x=1;dir=0;
		a[y][x]='#';
		while(1){
			for(int i=0;i<m-1;i++){
				if(a[y+2*dy[dir]][x+2*dx[dir]]=='#')break;
				y+=dy[dir];
				x+=dx[dir];
				a[y][x]='#';
			}
			dir=(dir+1)%4;
			if(a[y+2*dy[dir]][x+2*dx[dir]]=='#')break;
			if(a[y-1][x-1]=='#'||a[y-1][x+1]=='#'||a[y+1][x-1]=='#'||a[y+1][x+1]=='#')break;
		}
		if(!fst)cout<<endl;
		fst=false;	
		for(int i=1;i<=m;i++){
			for(int j=1;j<=m;j++)cout<<a[i][j];
			cout<<endl;
		}
	}
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N; cin >> N;
  vector<bitset<10>> statusOfStores(N);
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 10; j++){
      int tmp = 0;
      cin >> tmp;
      if(tmp == 1){
        statusOfStores[i].set(9-j);
      }
    }
  }
  vector<vector<int>> benefits(N, vector<int>(11));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 11; j++){
      cin >> benefits[i][j];
    }
  }
  long long max = -100000000000;
  for(int tmp = 1; tmp < (1 << 10); tmp++){
    bitset<10> s(tmp);
    long long sum = 0;
    for(int i = 0; i < N; i++){
      sum += benefits[i][(s&statusOfStores[i]).count()];
    }
    if(sum > max){
      max = sum;
    }
  }
  cout << max <<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include<functional>
#include <set>
#include <map>
#include <climits>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) ir(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
using namespace std;
#define gamma 0.5772156649015328606065120
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define N 100005
#define maxn 10005
typedef long long int LL;

int x[1010];
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&x[i]);
    int ans=-1;
    int a,b,f,c,h,he;
    for(a=0; a<n; a++)
        for(b=0; b<n; b++)
        {
            if(a==b)
                continue;
            h=x[a]*x[b];
            if(h<ans)
                continue;
            he=h;
            c=h%10;
            h/=10;
            f=0;
            while(h)
            {
                int d=h%10;
                if(d==c-1)
                    c--;
                else
                {
                    f=1;
                    break;
                }
                h/=10;
            }
            if(f==0&&he>ans)
                ans=he;

        }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 3216