akhauriyash/Code-Regression huggingface dataset:
#line 1 "/workspaces/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

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

  int d;
  constexpr int m = 26;
  cin >> d;

  vl c(m);
  REP(i, m) { cin >> c[i]; }

  vector<vl> s(d, vl(m, 0));
  REP(i, d) {
    REP(j, m) { cin >> s[i][j]; }
  }

  vi ans(d, 2);
  REP(i, d) { cout << ans[i] << endl; }
  return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const ll LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=5050;
string a,b;
void solve(int T){
	int ans=INF,tmp=0;
	cin>>a>>b;
	
	for(int i=0;i<a.size()-b.size()+1;i++){
		tmp=0;
		for(int j=0;j<b.size();j++){
			if(a[i+j]!=b[j])tmp++;
		}
		ans=min(ans,tmp);
	}
	printf("%d",ans);
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

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

using namespace std;

bool binary_search(vector<int> list, int v) {
  int l = 0, r = list.size();
  
  while (abs(r - l) >= 1) {
    int m = (l + r) / 2;
    
    if (list[m] == v) {
      return true;
    } else if (list[m] < v) {
      l = m + 1;
    } else {
      r = m;
    }
  }
  
  return false;
}

int main() {
  int K, S, ans = 0;
  
  
  vector<int> possible;
  
  cin >> K >> S;
  
  for (int i = 0; i <= K; i++) {
    possible.push_back(S - i);
  }
  
  sort(possible.begin(), possible.end());
  
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if (binary_search(possible, x + y)) {
        ans++;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){
    long a, b, k;
    cin >> a >> b >> k;
    
    for (int i = 0; i < k; i++) {
        if (i % 2 == 0) {
            if (a % 2 != 0) {
                a--;
            }
            b += a/2;
            a /= 2;
        } else {
            if (b % 2 != 0) {
                b--;
            }
            a += b/2;
            b /= 2;
        }
    }
    
    cout<< a << " " << b << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if (r <= x && x <= W - r && r <= y && y <= H - r)
    puts("Yes");
  else
    puts("No");

  return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

struct MyStruct
{
	int list[13];
};


signed main() {
	int i, j, n;
	string s;
	bool flag = false;
	vector<int>list;

	
	while (!flag)
	{
		string ss;
		cin >> ss;

		if (ss !="0") {
			int sum = 0;
			for (i = 0; i < ss.length(); i++) {
				sum += (int)ss[i] - 48;
			}
			list.push_back(sum);
		}
		else {
			flag = true;
			break;
		}


	}


	for (i = 0; i < list.size(); i++) {
		cout << list[i] << endl;
	}







	getchar();
	getchar();
	return 0;
}


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

int main()
{
    int h,a,c;
    cin >> h >> a;
    c = 0;
    while( h > 0 )
    {
        h = h - a;
        c++;
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s.back()!='s'){s+="s";}
    else{s+="es";}
    cout<<s;
    return 0;
}


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

int main(void){
  long N, D;
  cin>>N>>D;
  long retval=0;
  long X, Y;
  for(long i=0;i<N;i++){
    cin>>X>>Y;
    if(X*X+Y*Y<=D*D){
      retval++;
    }
  }
  cout<<retval<<endl;
}


Measured memory_bytes: 3160
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m,c=INTM()
    b=LIST()
    ct=0
    for i in range(n):
        a=LIST()
        temp=0
        for k in range(m):
            temp+=b[k]*a[k]
        if temp+c>0:
            ct+=1
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
N, D = map(int, input().split())
X = [[] for i in range(N)]
for i in range(N):
    X[i] = list(map(int, input().split()))

num = 0
for i in range(N):
    for j in range(i + 1, N):
        tmp = 0
        for k in range(D):
            tmp += (X[i][k] - X[j][k]) ** 2

        if int(tmp ** 0.5) ** 2 == tmp:
            num += 1

print(num)



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

constexpr int INFI = 1145141919;

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

    int N, K;
    std::cin >> N >> K;

    std::vector<int> x(N);
    for(int i=0; i<N; i++){
        int buf;
        std::cin >> buf;
        x[i] = buf;
    }

    int ans=0;
    for(int i=0; i<N; i++){
        ans = ans + 2*std::min(x[i], K-x[i]);
    }

    std::cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define dbg(P)      cout<<P<<" "
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;
ll n;
ll mul(ll a, ll b) {
    return (ll) a * b % mod;
}

struct matrix{
    std::vector<std::vector<ll>> t;
    matrix() 
    {
      t.resize(n,vector<ll>(n));
    } 

matrix operator*(const matrix& b) const{
  matrix ans= matrix();
  fr(i,0,n){
    fr(j,0,n){
      fr(k,0,n){
        ans.t[i][j]+=mul(t[i][k],b.t[k][j]);
        if(ans.t[i][j]>=mod)
          ans.t[i][j] -=mod;
      }
    }
  }
  return ans;      
}
};
void solve()
{
// string s;
  ll k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>k;
  std::vector<std::vector<ll>> a(n,std::vector<ll>(n));
  for (ll i = 0; i < n; ++i)
  {
    fr(j,0,n)
  cin>>a[i][j];
  }
   matrix answer = matrix();
    for(ll i = 0; i < n; ++i) 
        answer.t[i][i] = 1;
      matrix m = matrix();
      m.t = a;
      while(k)
      {
        if(k%2)
        answer=answer*m;
        m = m*m;
        k/=2;
      }

    for(ll i = 0; i < n; ++i) {
        for(ll j = 0; j < n; ++j) {
             c+= answer.t[i][j];
             if(c>=mod)
              c-=mod;
        }
    }
   c(c);
}

signed main(){
     
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 384
#include <bits/stdc++.h>
#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 R;
    cin >> R;
    cout << 2 * R * M_PI << endl;
    return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int M,D;
  cin>>M>>D;
  int a=0;
  repeat(m,1,M+1) {
    repeat(d,1,D+1) {
      int d10 = d/10;
      int d1 = d%10;
      if(d1>=2&&d10>=2&&d1*d10==m) {
	a++;
      }
    }
  }
  cout << a << endl;
  return 0;
}


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

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

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

    if(s[0] == 'S')
        cout << "Cloudy" <<endl;
    if(s[0] == 'C')
        cout << "Rainy" <<endl;
    if(s[0] == 'R')
        cout << "Sunny" << endl;
     
    return 0;
}


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

using namespace std;

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

    int MOD=1e9+7;
    int h,w;
    cin>>h>>w;
    vector<vector<int>> board(h, vector<int>(w));
    string temp;
    for(int i=0;i<h;i++){
        cin>>temp;
        for(int j=0;j<w;j++){
            if(temp[j]=='.'){
                board[i][j]=0;
            }else{
                board[i][j]=1;
            }
        }
    }

    
    vector<vector<int>> dp(h+1, vector<int>(w+1));
    dp[1][1]=1;
    for(int i=1;i<min(h,w)+1;i++){
        for(int j=i;j<w+1;j++){
            if(board[i-1][j-1]==1){
                dp[i][j]=0;
            }else{
                dp[i][j]=max((int)(((long long)dp[i-1][j]+(long long)dp[i][j-1])%(long long)MOD), dp[i][j]);
            }
        }

        for(int j=i;j<h+1;j++){
            if(board[j-1][i-1]==1){
                dp[j][i]=0;
            }else{
                dp[j][i]=max((int)(((long long)dp[j][i-1]+(long long)dp[j-1][i])%(long long)MOD), dp[j][i]);
            }
        }
    }
    cout<<dp[h][w]<<endl;

}

Measured memory_bytes: 11080
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(){

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    long int inp;
    long int tmp=0,tmp1=0,tmp2=0,tmp3=0,ans;
    cin>>inp;
     for(long int i=1;i<=inp;i++){
        tmp = tmp + i;
    }   
    for(long int j=1;j<=inp;j++){
        if(j%3==0){
            tmp1 = tmp1+j;
        }   
        if(j%5==0){
            tmp2 = tmp2+j;
        }   
        if((j%3==0)&&(j%5==0)){
            tmp3 = tmp3+j;
        }   
    }   
    ans = tmp - tmp1 - tmp2 + tmp3;
    cout<<ans;



}


Measured memory_bytes: 3588
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

dist i j = sum $ drop f $ take t $ [0,6,7,5,5,20,15]
  where
    f = min i j
    t = max i j

toll i j = x f t
  where
    f = min i j
    t = max i j
    x n 2 = [0,300]!!n
    x n 3 = [0,500,350]!!n
    x n 4 = [0,600,450,250]!!n
    x n 5 = [0,700,600,400,250]!!n
    x n 6 = [0,1350,1150,1000,850,600]!!n
    x n 7 = [0,1650,1500,1350,1300,1150,500]!!n
    

time h m = 60*h + m
lt = time 17 30
rt = time 19 30
off t = lt<=t && t<=rt

main = do
    d <- getInt
    when (d/=0) $ do
        td <- apply2 time <$> getInts
        a <- getInt
        ta <- apply2 time <$> getInts
        print $ if (off td || off ta) && (dist d a <= 40) then toll d a `div` 2 `divCeil` 50 * 50 else toll d a
        main

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
-- templete



Measured memory_bytes: 4148
//https://atcoder.jp/contests/abc163/tasks/abc163_d
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
constexpr ll MOD=1e9+7;
int main() {
#if LOCAL&01
  std::ifstream in("./test/sample-1.in");
  //std::ifstream in("./input.txt");
  std::cin.rdbuf(in.rdbuf());
#else
  cin.tie(0);
  ios::sync_with_stdio(false);
#endif
  ll N,K; cin>>N>>K;

  ll st=0;
  FOR(i,0,K-1){
    st+=i;
  }
  ll ed=0;
  FOR(i,0,K-1){
    ed+=(N-i);
  }

  ll ans=0;
  FOR(k,K,N+1+1){
    dump(k);
    st += (k-1);
    ed += (N-(k-1));
    ll num = max(ed-st+1,0LL);
    ans += num;   
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs64 a(n);
    rep (i, n) cin >> a[i];

    const s64 inf = 1e18;
    vector< vector< vs64 > > dp(n + 1, vector< vs64 >(3, vs64(2, -inf)));
    rep (i, 2) dp[0][i + 1][0] = 0;

    rep (i, n)
    {
        if (i % 2 == 0)
        {
            dp[i + 1][0][0] = dp[i][0][0];
            dp[i + 1][1][0] = max(dp[i][1][1], dp[i][1][0]);
            dp[i + 1][1][1] = dp[i][0][0] + a[i];
            dp[i + 1][2][1] = dp[i][1][0] + a[i];
        }
        else
        {
            dp[i + 1][0][0] = max(dp[i][1][0], dp[i][1][1]);
            dp[i + 1][1][0] = max(dp[i][2][0], dp[i][2][1]);
            dp[i + 1][0][1] = dp[i][0][0] + a[i];
            dp[i + 1][1][1] = dp[i][1][0] + a[i];
            dp[i + 1][2][1] = dp[i][1][0] + a[i];
        }
    }

    cout << max(dp[n][1][0], dp[n][1][1]) << "\n";
    return 0;
}



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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int N, Q;
ll cnt[201010];
vector<int> G[201010];
bool used[201010];

void dfs(int pos, int add_cnt, int from)
{
    cnt[pos] += add_cnt;
    if (G[pos].size() == 1)
    {
        return;
    }

    for (int i = 0; i < G[pos].size(); i++)
    {
        int next = G[pos][i];
        if (next == from)
        {
            continue;
        }
        dfs(next, cnt[pos], pos);
    }
}

int main()
{
    cin >> N >> Q;
    rep(i, N - 1)
    {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i, Q)
    {
        int p, x;
        cin >> p >> x;
        cnt[p] += x;
    }

    G[1].push_back(0);
    dfs(1, 0, 0);

    rep(i, N)
    {
        cout << cnt[i + 1];
        if (i != N - 1)
        {
            cout << " ";
        }
        else
        {
            cout << endl;
        }
        }
}


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

bool compare(pair<pair<string,int>,int> a, pair<pair<string,int>,int> b){
	if(a.first.first != b.first.first)
		return a.first.first < b.first.first;
	else
		return a.first.second >  b.first.second;
}
int main(){

	int N;
	cin >> N;
	string S;
	int P;
	vector<pair<pair<string, int>,int> > pairs(N);

	for(int i = 0; i < N; i++){
		cin >> S >> P;
		pairs[i] = make_pair(make_pair(S,P),i);
	}
	sort(pairs.begin(),pairs.end(),compare);
	for(int i = 0; i < N; i++){
		cout << pairs[i].second + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long double solve(vector<int>& P, int k) {
        int n = P.size();

        vector<long double> E(n + 1, 0);
        for (int i = 0; i < n; ++i) {
            int x = P[i];
            E[i + 1] = (x + 1.0) / 2.0;
            E[i + 1] += E[i];
        }

        long double res = 0;
        for (int i = 0; i + k <= n; ++i) {
            res = max(res, E[i + k] - E[i]);
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n, k;
    cin >> n >> k;
    vector<int> P(n);
    for (int i = 0; i < n; ++i) {
        cin >> P[i];
    }

    Solution sol;

    cout << sol.solve(P, k) << "\n";
    return 0;
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, MAX = LLONG_MAX;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	string S;
	cin >> S;
	lint minv = SZ(S);
	REP(i, SZ(S) - 1) {
		if (S[i] != S[i + 1]) {
			chmin(minv, max(i + 1, SZ(S) - i - 1));
		}
	}
	cout << minv;
}


Measured memory_bytes: 512
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    string a;
    string b;
    string c;
    scan(a, b, c);
    // writeln(a[$ - 1]);
    if ((a[$ - 1] == b[0]) && (b[$ - 1] == c[0]))
    {
        writeln("YES");
        return;
    }
    writeln("NO");

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

int main(){
        char s[101],t[101];
        cin >> s;
        cin >> t;

        int nu;
        for(nu=0; s[nu]!='\0'; nu++){int a=0;}

        int same[100],count=0;
        for(int i=0; i<nu; i++){
                if(s[i]==t[0]){
                        same[count]=i;
                        count++;
                }
        }

        for(int i=0; i<count; i++){
                int tc=0;
                for(int j=same[i]; j<nu; j++){
                        if(s[j]!=t[tc])break;
                        else tc++;
                }
                for(int j=0; j<same[i]; j++){
                        if(s[j]!=t[tc])break;
                        else tc++;
                }
                if(tc==nu){
                        cout << "Yes" << endl;
                        return 0;
                }
        }

        cout << "No" << endl;
        return 0;
}


Measured memory_bytes: 256
import numpy as np
N,K=map(int, input().split())
X=list(map(int, input().split()))
ans=np.inf
for i in range(N-K+1):
  l=X[i]
  r=X[i+K-1]
  ans=min(ans, r-l+min(abs(l), abs(r)))
print(ans)

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int a,b;cin >> a >> b;
  int sum=1,ans=0;
  while(sum<b){
    sum+=a-1;
    ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
def partition(a, p, r):
    x = a[r][1]
    i = p - 1
    for j in range(p, r):
        if a[j][1] <= x:
            i += 1
            a[i], a[j] = a[j], a[i]
    a[r], a[i + 1] = a[i + 1], a[r]
    return i + 1


def quick_sort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quick_sort(a, p, q - 1)
        quick_sort(a, q + 1, r)


#
# l = [int(i) for i in input().split()]
# quick_sort(l, 0, len(l) - 1)
# print(l)

n = int(input())
l = []

for i in range(n):
    a, b = input().split()
    l.append((a, int(b)))

l1 = l.copy()
quick_sort(l1, 0, len(l) - 1)
# print(l1)

l2 = l.copy()
l2_sorted = sorted(l2, key=lambda x: x[1])
# print(l2_sorted)

if l1 == l2_sorted:
    print("Stable")
else:
    print("Not stable")

for x, y in l1:
    print(x, y)



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

int a[200];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n)scanf("%d", &a[i]);
		int search; scanf("%d", &search);
		int s = 0, g = n - 1;
		int cnt = 0;
		while (s <= g) {
			cnt++;
			if (a[(s + g) / 2] == search)break;
			if (a[(s + g) / 2] < search)s = (s + g) / 2 + 1;
			else g = (s + g) / 2 - 1;
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int ans=0,gc=0,pc=0;
string a;
int main()
{
	cin>>a;
    for (int i=0;i<a.size();i++)
	{
		if(gc==pc)
		{
			gc++;
			if(a[i]=='p') ans--;
		}
		else
		{
			pc++;
			if(a[i]=='g') ans++;
		}
	}    
    cout<<ans<<endl;
    return 0;	
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int n,m,q;
VVI G(101010);
VI v(101010);
VI d(101010);
VI c(101010);
VI col(101010,0);
VI rest(101010,-1);

void solve(int u,int w,int k){
  if(col[u]>0&&rest[u]>=k) return;
  if(col[u]==0) col[u]=w;
  rest[u]=k;
  for(int i:G[u]){
    if(k>0) solve(i,w,k-1);
  }
}

int main(){
  int i,j;
  cin>>n>>m;
  for(i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--; b--;
    G[a].pb(b);
    G[b].pb(a);
  }  
  cin>>q;
  for(i=0;i<q;i++){
    cin>>v[i]>>d[i]>>c[i];
    v[i]--;
  }
  for(i=q-1;i>=0;i--) solve(v[i],c[i],d[i]);
  for(i=0;i<n;i++){
    cout<<col[i]<<endl;
  }

  return 0;
}

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

using namespace std;

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

int main() {
	int N;
	cin >> N;
	REP(n, N) {
		if (n) puts("");
		
		int maps[9][9];
		bool ans[9][9] = {};
		
		REP(i, 9) REP(j, 9) {
			scanf("%d", &maps[i][j]);
			maps[i][j]--;
		}
		
		REP(i, 3) REP(j, 3) {
			int cnt[9] = {};
			REP(k, 3) REP(l, 3) cnt[maps[i * 3 + k][j * 3 + l]]++;
			REP(k, 3) REP(l, 3) if (cnt[maps[i * 3 + k][j * 3 + l]] > 1)
				ans[i * 3 + k][j * 3 + l] = true;
		}
		
		REP(i, 9) {
			int cnt[9] = {};
			REP(j, 9) cnt[maps[i][j]]++;
			REP(j, 9) if (cnt[maps[i][j]] > 1) ans[i][j] = true;
			
			memset(cnt, 0, sizeof(cnt));
			REP(j, 9) cnt[maps[j][i]]++;
			REP(j, 9) if (cnt[maps[j][i]] > 1) ans[j][i] = true;
		}
		
		REP(i, 9) {
			REP(j, 9) printf("%c%d", ans[i][j] ? '*' : ' ', maps[i][j] + 1);
			puts("");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int N;
	while(cin>>N){
		if(N==0) break;
		int ans=0;
		rep(i,2,N){
			rep(j,1,N){
				if(i*(2*j+i-1)==2*N) ans++;
			}
		}
		o(ans);
	}
}

Measured memory_bytes: 1156
import Data.List
import Data.Array
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Control.Monad
import Control.Monad.State
import Control.Monad.ST
import Debug.Trace

next :: [Int] -> Int
next [x] = x
next ls = next $ insert (head $ sort ls) $ filter (/=0) $ map (`mod`(head $ sort ls)) (tail $ sort ls)

main :: IO ()
main = do
  _ <- read <$> getLine :: IO Int
  ls <- map read.words <$> getLine
  putStrLn $ show $ next ls


Measured memory_bytes: 39804
n=int(input())
ab=[]
for i in range(n):
	x,y=map(int,input().split())
	ab.append([x,y])
ab.sort(key=lambda x:x[1])
time=0
out=0
for i in range(n):
	time+=ab[i][0]
	if time>ab[i][1]:
		out+=1
if out==0:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 38044
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
   string s;
   cin>>s;
   
   for(int i=1;i<3;i++){
       if(s[i]!=s[i-1]){
           cout<<"Yes";
           return 0;
       }
   }
   cout<<"No";


}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        long A = nextInt(r);
        long B = nextInt(r);

        long ans = A > B ? calcLCM(A, B) : calcLCM(B, A);
        System.out.println(ans);
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        String str = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            str += (char)c;
        }
        return Integer.parseInt(str);
    }

    public static long calcLCM(long large, long small) {
        long result = 0;
        long tmp = small;
        while (true) {
            if (small % large == 0) {
                result = small;
                break;
            } else {
                small += tmp;
            }
        }
        return result;
    }
}


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

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

    vector<int> B(N-1);
    rep(i,N-1) cin >> B[i];

    vector<int> A(N);
    A[0] = B[0];
    rep(i,N-2) A[i+1] = min(B[i], B[i+1]);
    A[N-1] = B[N-2];

    int sum = accumulate(A.begin(), A.end(), 0);

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main()
{	
	long long int a,b;
	char c;
	scanf("%lld %c %lld",&a,&c,&b);
	if(c =='+')
	 printf("%lld",a+b);
	else if(c =='-')
	 printf("%lld",a-b);
	return 0;
}

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

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;

const int N = 100005;
int n;
ll a[N], b[N], c[N];
ll dp[N][3];

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
}

void process()
{
    dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
    for(int i = 1; i < n; i++)
    {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }
    cout << max({ dp[n-1][0], dp[n-1][1], dp[n-1][2] }) << endl;
}



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

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

    int n;
    cin >> n;
    cout << n*n*n << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int keta(int num) {
    int res = 0;
    if(num == 0)
        return 1;
    while(num > 0) {
        num /= 10;
        res++;
    }
    return res;
}

bool check(int num, vector<int> s, vector<int> c, int N) {
    if(N != keta(num))
        return false;
    int M = s.size();
    string str = "";
    if(num == 0)
        str = "0";
    while(num > 0) {
        str = ((char)('0' + num % 10)) + str;
        num /= 10;
    }
    rep(i, M) {
        if(str[s[i] - 1] - '0' != c[i]) {
            return false;
        }
    }
    return true;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(M), c(M);
    rep(i, M) cin >> s[i] >> c[i];
    for(int i = 0; i <= 999; i++) {
        if(check(i, s, c, N)) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
int n, m, k;

int main() {
    cin >> n >> m >> k;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(i*m + j*n - 2*i*j == k) {
                cout << "Yes" << "\n";
                return 0;
            }
        }
    }
    cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
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)*}
  };
}
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, 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")
  };
}

fn main() {
  input!{
    K: u64,
    A: u64,
    B: u64,
  }
  for i in 0..1001 {
    let ik = i*K;
    if A <= ik && ik <= B {
      println!("OK");
      return;
    }
  }
  println!("NG");

}



Measured memory_bytes: 2124
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int ma=0;
int ind;
V<int> g[200005];
void dfs(int cur,int par,int now){
  if(chmax(ma,now))ind=cur;
  for(int v:g[cur]){
    if(v==par)continue;
    dfs(v,cur,now+1);
  }
}
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    g[--a].push_back(--b);
    g[b].push_back(a);
  }
  dfs(0,-1,0);
  ma=0;
  dfs(ind,-1,0);
  cout<<(ma%3%2==0?"First":"Second")<<"\n";
}


Measured memory_bytes: 16768
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>


using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================

	ll N;
	cin >> N;

	ll lim = 0;
	for (int i = 1; i <= N; i++)
	{
		if ((i * i + i) / 2 >= N)
		{
			lim = i;
			break;
		}
	}



	for (int i = lim; i >= 1; i--)
	{
		if (N >= i)
		{
			cout << i << endl;
			N -= i;
		}
	}



}





Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def answer(N, S, T):
  sList = list(S)
  tList = list(T)
  result = ""
  for i in range(N):
    result = result + sList[i] + tList[i]
  return result

N = int(input())
S, T = input().split()
X = answer(N, S, T)
print(X)


Measured memory_bytes: 2940
n = int(input())
a = list(input())
wcnt,ecnt,ans,box = 0,0,0,[]
W = a.count("W")
E = a.count("E")
for i in range(n-1):
  if a[i] == "W":
    box.append(E+wcnt)
    wcnt += 1
    W -= 1
  else:
    box.append(E+wcnt)
    ecnt += 1
    E -= 1
if a[n-1] == "W":
  W -= 1
  box.append(E+wcnt)
  wcnt += 1
else:
  E -= 1
  box.append(E+wcnt)
  ecnt += 1
print(min(box))

Measured memory_bytes: 23464
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    rep(i,3){
        if(s[i] == '1') s[i] = '9';
        else s[i] = '1';
    }

    dunk(s);
}

   

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		boolean[][] hasOkasi = new boolean[n][k];
		
		for(int i = 0; i < k; i++) {
			int d = sc.nextInt();
			for(int j = 0; j < d; j++) {
				int temp = sc.nextInt() - 1;
				hasOkasi[temp][i] = true;
			}
		}
		
		int count = 0;
		for(int i = 0; i < n; i++) {
			count++;
			for(int j = 0; j < k; j++) {
				if(hasOkasi[i][j]) {
					count--;
					break;
				}
			}
		}
		
		System.out.println(count);
		
	}

}


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

string S, T;
int Q;
vector<int> spsum, tpsum;

int main() {
    std::ios::sync_with_stdio(false);
    cin>>S>>T;
    spsum.resize(S.size());
    for(int i = 0; i < S.size(); i++) {
        spsum[i] = S[i] == 'A'? 1 : 2;
        if(i) spsum[i] += spsum[i - 1];
    }
    tpsum.resize(T.size());
    for(int i = 0; i < T.size(); i++) {
        tpsum[i] = T[i] == 'A'? 1 : 2;
        if(i) tpsum[i] += tpsum[i - 1];
    }
    cin>>Q;
    for(int i = 0; i < Q; i++) {
        int a, b, c, d; cin>>a>>b>>c>>d;
        a--;b--;c--;d--;

        int x = spsum[b] - (a? spsum[a - 1] : 0);
        int y = tpsum[d] - (c? tpsum[c - 1] : 0);
        if(x % 3 == y % 3) printf("YES\n");
        else printf("NO\n");
    }
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

int main() {
  long x, y;
  cin >> x >> y;

  long cnt = 1;
  while(2 * x <= y) {
    cnt++; 
    x *= 2;
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 3592
/*
this is the most obvious problem I've seen and B was so hard...
*/
#include<bits/stdc++.h>

using namespace std;

int N, K, dp[309][309][309];
char sir[309];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%s\n", sir + 1), N = strlen (sir + 1);
scanf ("%d", &K);
for (int i=N; i>=1; i--)
    for (int j=i; j<=N; j++)
    {
        if (i == j)
        {
            dp[i][j][0] = 1;
            continue;
        }
        if (j == i + 1)
        {
            dp[i][j][0] = (sir[i] == sir[j] ? 2 : 1);
            dp[i][j][1] = 2;
            continue;
        }
        for (int k=0; k<=K && k<=(j - i + 1) / 2; k++)
        {
            dp[i][j][k] = max (dp[i + 1][j][k], dp[i][j - 1][k]);
            if (k >= (sir[i] != sir[j]))
                dp[i][j][k] = max (dp[i][j][k], 2 + dp[i + 1][j - 1][k - (sir[i] != sir[j])]);
        }
    }
int ans = 0;
for (int k=0; k<=K; k++)
    if (dp[1][N][k] > ans)
        ans = dp[1][N][k];
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 112512
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		Collections.sort(num);
		
		System.out.println(num.get(0)+num.get(1));
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/

const int mod = 1e9 + 7;

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

    int n; cin >> n;
    vector <ll> A(n), suff(n+1, 0);
    for (ll &i: A) cin >> i;   
    for (int i = n-1; i >= 0; --i) {
        suff[i] = A[i];
        if (i < n-1) (suff[i] += suff[i+1]) %= mod;
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        (ans += A[i] * suff[i+1]) %= mod;
    }

    cout << ans;


    return 0;
}



Measured memory_bytes: 6352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



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

    int n, a, b;
    cin >> n >> a >> b;
    int ans = a * n > b ? b : a * n;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import Foundation


func readStr() -> String {
  return readLine()!
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

let N = readInt()
var A = readInts()
if N % 2 == 0 {
    let Alice = A.sorted().enumerated().filter{ $0.0 % 2 != 0 }.map{ $0.1 }.reduce(0, +)
    let Bob = A.sorted().enumerated().filter{ $0.0 % 2 == 0 }.map{ $0.1 }.reduce(0, +)
    print(Alice - Bob)
} else {
    let Alice = A.sorted().enumerated().filter{ $0.0 % 2 == 0 }.map{ $0.1 }.reduce(0, +)
    let Bob = A.sorted().enumerated().filter{ $0.0 % 2 != 0 }.map{ $0.1 }.reduce(0, +)
    print(Alice - Bob)
}



Measured memory_bytes: 13688
use proconio::{input, fastout};

const MOD: i64 = 1000000007;
#[fastout]
fn main() {
    input! {
        n: i64,
        k: i64
    }
    let mut num = 0;
    for i in k..n+2 {
        num += i*(n+1-i) + 1;
    }
    num %= MOD;
    println!("{}",num)
}


Measured memory_bytes: 2168
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(A: "List[int]"):
    if sum(A) >= 22:
        ret = 'bust'
    else:
        ret = 'win'
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [int(next(tokens)) for _ in range(3)]  # type: "List[int]"
    solve(A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main ()
{	
 	int a,b;
 	scanf("%d", &a);
 	scanf("%d", &b);
 	if(a==1&&b==2){
  	printf("3"); 
 	}
 	else if(a==2&&b==1){
 	 printf("3"); 
 	}
	 else if(a==1&&b==2){
 	 printf("3"); 
	 }
	 else if(a==1&&b==2){
  	printf("3"); 
	}
 	else if(a==1&&b==3){
  	printf("2");
	 }
	else if(a==3&&b==1){
  	printf("2");
 	}
	else if(a==2&&b==3){
 	 printf("1");
	 }
 	else if(a==3&&b==2){
  	printf("1");
 	}
  return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)

int main(void){
    int N;
    cin >> N;
    
    deque<int> d;
    rep(i, N){
        char s[20];
        int x;
        scanf("%s %d\n", s, &x);
        if(*s == 'i') d.push_front(x);
        else if(s[6] == 'F') d.pop_front();
        else if(s[6] == 'L') d.pop_back();
        else{
            for(int j = 0, len = d.size(); j < len; ++j){
                if(d[j] == x){
                    d.erase(d.begin() + j);
                    break;
                }
            }
        }
    }
    
    int i;
    int len = d.size() - 1;
    for(i = 0; i < len; ++i)
        printf("%d ", d[i]);    
    printf("%d\n", d[i]); 
    return 0;
}


Measured memory_bytes: 7076