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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n-1) {
    if (a[i] < a[i+1]) {
      a[i+1]--;
    } 
    if (a[i] > a[i+1]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int n,x=0,y=0,ans=100000,c=0;
  cin>>n>>x;
  rep(i,x-n+1,n+x) cout<<i<<" ";
  cout << endl;
  
  return 0;
}

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

/**
 * Copyright (c)
 * author        :   Sujeet Kumar 
 * question name :   
 * link          :   
 */

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define repA(i,v) for(auto i:v)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define vi vector<int>
#define vll vector<ll>
#define vi2(n,m) vector<vector<int> > v(n,vector<int>(m));
ll power(ll x,ll y,ll p){ll res=1; x=x%p;if(x==0) return 0;while(y>0)
{if(y&1) res=(res*x)%p;y=y>>1; x=(x*x)%p;}return res;}


void solve(){
	int n;cin>>n;
	vi a(n),b(n);
	int c = 0;
	rep(i,0,n){
		cin>>a[i];
		cin>>b[i];
		if(a[i]==b[i])	c++;
		else if(a[i]!=b[i])	c=0;
		if(c==3){
			cout<<"Yes"<<endl;
			return;
		}
	}
	cout<<"No"<<endl;
	return ;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    clock_t start=clock();

	ll test = 1;
	// cin>>test;
	while(test--)	solve();

	clock_t end=clock();
	cerr<<fixed<<setprecision(15)<<((double)(end-start))/CLOCKS_PER_SEC<<endl;
	return 0;
}
/**
 * Test Cases:-
 */


Measured memory_bytes: 3844
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let r:f64 = read().unwrap();
    let cir = 2.0 * std::f64::consts::PI * r;
    println!("{}", cir);
}


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

int main(){
    int N,K,sum=0; cin>>N>>K;
    vector<int> x(N);
    for(int i=0;i<N;i++){
        cin>>x[i];
        sum+=2*min(x[i],K-x[i]);
    }
    cout<<sum<<endl;
}

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

typedef long long ll;

using namespace std;

int main(void) {
    int N; cin >> N;
    vector<int> d(N, 0);
    for (int i = 0; i < N; i++) { cin >> d[i]; }
    sort(d.begin(), d.end());
    int di = N / 2;
    int median = (d[di] + d[di-1]) / 2;
    cout << d[di] - d[di - 1] << endl;
}

Measured memory_bytes: 640
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    dictType = dict()
    for i in range(1, 10):
        for j in range(1, 10): dictType[(i, j)] = 0
    for i in range(1, N + 1):
        bottom = i % 10
        if bottom == 0: continue
        top = i
        while top >= 10: top //= 10
        dictType[(top, bottom)] += 1

    ans = 0
    for i in range(1, N + 1):
        bottom = i % 10
        if bottom == 0: continue
        top = i
        while top >= 10: top //= 10
        ans += dictType[(bottom, top)]
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9184
#include<cstdio>
#include<algorithm>
using namespace std;
long long gcd(long long a, long long b) {
    while(b){
    	a%=b;
    	swap(a,b);
	}
	return a;
}
long long t,a,b,c,d;
int main(){
	scanf("%lld",&t);
	for (int i=1;i<=t;i++) {
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		int x=0;
		long long z=(a-c)%gcd(b,d);//Icannotunderstand
		if(z==0)z=gcd(b, d);
		if(b-c<=z)x=1;//Icanunderstand
		if(a<b||d<b)x=0;//Icanunderstand
		if(x==0)printf("No\n");
		else printf("Yes\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 600005;
const int mod = 1000000007;
int n, m, l, r;
int fact[N], ifact[N], inv[N];
inline void init_fact(int n = 600000) {
	inv[1] = 1;
	for (int i = 2; i <= n; i++)
		inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = 1ll * fact[i - 1] * i % mod;
		ifact[i] = 1ll * ifact[i - 1] * inv[i] % mod;
	}
}
inline int C(int x, int y) {
	if (x < 0 || y < 0 || x < y) return 0;
	return 1ll * fact[x] * ifact[y] % mod * ifact[x - y] % mod;
}
inline int cc(int a, int b, int s) {
	if (s < 0) return 0;
	int res = 0;
	for (int i = 0, i_end = min(s / (b + 1), n - m); i <= i_end; i++) {
		int cur = 1ll * C(n - m, i) * C(n + s - i * (b + 1), n) % mod;
		if (i & 1) cur = mod - cur;
		res = (res + cur) % mod;
	}
	return res;
}
inline int calc(int k) {
	int res = 0;
	for (int x = 1, x_end = k / m; x <= x_end; x++) {
		res = (res + (cc(x, x - 1, k - x * m) - cc(x + 1, x - 1, k - (x + 1) * m) + mod) % mod) % mod;
	}
	res = 1ll * res * C(n, m) % mod;
	return (C(n + k, n) - res + mod) % mod;
}
int main() {
	init_fact();
	scanf("%d%d%d%d", &n, &m, &l, &r);
	printf("%d\n", (calc(r) - calc(l - 1) + mod) % mod);
	return 0;
}


Measured memory_bytes: 7296
answer = []
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    count = 0
    for i in range(1, n-1):
        for j in range(i+1, n):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    count += 1
    answer.append(count)
    
for i in range(len(answer)):
    print(answer[i])


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define tamask (1 << 21)
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vi> graph;

int n;
bool mat[25][25];
ll dp[21][tamask];

ll solve (int id, int mask) {
	if (id == n) return 1;
	if (dp[id][mask] != -1) return dp[id][mask];
	ll suma = 0;
	for (int i = 0; i < n; ++i)
	{
		if (mat[id][i] && !(mask & (1 << i))) {
			suma += solve(id + 1, mask | (1 << i));
			suma %= mod;
		}
	}
	return dp[id][mask] = suma;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			cin >> mat[i][j];
		}
	}
	for (int i = 0; i < 21; ++i)
	{
		for (int j = 0; j < tamask; ++j)
		{
			dp[i][j] = -1;
		}
	}
	cout << solve(0, 0) << "\n";
	return 0;
}


Measured memory_bytes: 344320
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=998244353;
#define N 510100
ll int n,m;
ll int a[N],b[N];
int used[N];
int ask(int x){
    cout<<x<<endl;
    cout.flush();
    string s;cin>>s;
    if(s[0]=='V'){
        return 0;
    }
    if(s[0]=='M'){
        return 1;
    }
    return 2;
}
main(){
    n=in();
    int c=ask(0);
    if(c==0)return 0;
    int lc=c,rc=c;
    int l=0,r=n;
    while(1){
        int mid=(l+r)/2;
        int check=ask(mid);
        if(check==0)return 0;
        if(((mid-l)^(check+2-lc))&1){
            r=mid;
            rc=check;
        }
        else{
            l=mid;
            lc=check;
        }
    }
    return 0;
}

Measured memory_bytes: 976
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

int count_bit(bitset<15> bit, int a){
    int res = 0;
    REP(i, a) res += bit[i];
    return res;
}

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

    int N;
    cin >> N;

    vi a(N);
    vector<vector<pii>> say;
    
    REP(i, N){
        cin >> a.at(i);
        vector<pii> say_i;
        REP(j, a.at(i)){
            int x, y;
            cin >> x >> y;
            say_i.emplace_back(pii(x, y));
        }
        say.emplace_back(say_i);
    }
    
    int res = 0;
    for(ll tmp = 0; tmp < (1 << 15); tmp++){
        bitset<15> bit(tmp); // 1 なら正直者
        bool ok = true;
        REP(i, N){
            if(!bit.test(i)) continue; // i が不親切な人ならとばす
            
            REP(j, a.at(i)){
                int human = say.at(i).at(j).first - 1;
                int honest = say.at(i).at(j).second;
                if(bit.test(human) != honest){
                    ok = false;
                }
            }
        }
        // OKなら答え更新
        if(ok){
            res = max(res, count_bit(bit, N));
        }
    }
    cout << res << endl;

    return 0;
};


Measured memory_bytes: 256
s=input()
L = int(s[:2])
R = int(s[2:])
if 1 <= L <= 12:
    if 1 <= R <= 12:
        print('AMBIGUOUS') 
    else:
        print('MMYY')
else:
    if 1 <= R <= 12:
        print('YYMM') 
    else:
        print('NA')

Measured memory_bytes: 3060
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
////////////////いろいろあるよ//////////////////////////////////
int main(){
	string S,K;
  	cin >> S >> K;
  REP(i,S.size()){
  	if(S[i]!=K[i]){cout << "No" << endl; return 0;}
  }
    
  cout << "Yes" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> xx(n), yy(m);
  for (int i = 0; i < n; i++) cin >> xx.at(i);
  for (int i = 0; i < m; i++) cin >> yy.at(i);
  xx.push_back(x);
  yy.push_back(y);
  sort(xx.begin(), xx.end());
  sort(yy.begin(), yy.end());
  if (xx.at(n) < yy.at(0)) cout << "No ";
  cout << "War" << endl;
}

Measured memory_bytes: 256
from collections import Counter

a = map(int, input().split())
c = Counter(a)
d = {1: 300000, 2: 200000, 3: 100000}

ret = sum(c[rank] * d[rank] for rank in range(1, 3 + 1))
if c[1] == 2:
    ret += 400000
print(ret)


Measured memory_bytes: 38464
def solve():
    a, b = read()
    result = think(a, b)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b):
    if b == 1:
        return 0
    accum = [a + (a - 1) * r for r in range(100)]
    for i in range(len(accum)):
        if accum[i] >= b:
            return i + 1


def write(result):
    print(result)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define pb push_back
#define in insert
#define ff first
#define ss second
#define mp make_pair
#define int long long
#define uint unsigned long long
#define rep(i,x,m) for(int i=x;i<m;i++)
#define repr(i,x,m) for(int i=x;i>=m;i--)
#define MOD 1000000007
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define vi vector<int>
#define vs vector<string>
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
#define noob ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int ans=0;


void ram5564()
{
   char arr[102][102];int row,col,a[102][102];
    cin>>row>>col;
    //char arr[r+2][c+2];
    //cout<<row<<col;
    for(int i=1;i<=row;++i)
    {
        for(int j=1;j<=col;++j)
        {
            cin>>arr[i][j];
            //cout<<arr[i][j];
        }
        //cout<<endl;
    }

    rep(i,0,102)
    rep(j,0,102)
    a[i][j]=1e9;
    if(arr[1][1]=='#')
        a[1][1]=1;
    else
        a[1][1]=0;
   // cout<<a[1][1]<<endl;
   
    for(int i=1;i<=row;++i)
    {
        for(int j=1;j<=col;++j)
        {
            if(i==1&&j==1)
                a[1][1]=(arr[1][j]=='#');
            else
            {
              if(i>1)
              {
                a[i][j]=min(a[i-1][j]+((arr[i][j]=='#'&&arr[i-1][j]=='.')),a[i][j]);
                
              }
             if(j>1)
              {
                a[i][j]=min(a[i][j],a[i][j-1]+(arr[i][j]=='#'&&arr[i][j-1]=='.'));
                
              }
          }
            
        }
    }
     // for(int i=1;i<=row;++i)
     // {
     //     for(int j=1;j<=col;++j)
     //         cout<<a[i][j]<<"  ";
     //     cout<<endl;
     // }
    
  
   cout<<a[row][col];


}

signed main()
{
        noob
               // #ifndef ONLINE_JUDGE
               //   freopen("input.txt","r",stdin);
               //   freopen("output.txt","w",stdout);
               //   #endif   
        
        int t=1;
        //      cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 384
{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}
{-# OPTIONS_GHC -O2 #-}

import Data.Array.IArray
import Data.Array.Unboxed
import Data.Array.ST
import Data.Char
import Data.List
import Data.Int
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Control.Monad.ST

inf :: Int64
inf = 1000000000000000

getInts :: IO [Int]
getInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

dijkstra :: Array Int [(Int, Int)] -> Int -> [Int64]
dijkstra g source = runST $ do
    ds :: STUArray s Int Int64 <- newArray (1, n) maxBound
    writeArray ds source 0
    let
      step :: S.Set (Int64, Int) -> ST s ()
      step q =
          case S.minView q of
            Nothing -> return ()
            Just ((d, v), q) -> do
              let
                relax q (u, w) = do
                    d <- readArray ds u

                    if d' < d
                      then do
                        writeArray ds u d'
                        return $ S.insert (d', u) q
                      else return q
                  where
                    d' = d + (fromIntegral w)

              foldM relax q (g!v) >>= step

    step $ S.singleton (0, source)

    ds' :: UArray Int Int64 <- freeze ds
    return (elems ds')
  where
    n = snd $ bounds g

main :: IO ()
main = do
	[n, m, s, t] <- getInts
	es <- replicateM m getInts
	let gy = accumArray (flip (:)) [] (1, n) $ concatMap (\[u, v, y, s] -> [(u, (v, y)), (v, (u, y))]) es
	let gs = accumArray (flip (:)) [] (1, n) $ concatMap (\[u, v, y, s] -> [(u, (v, s)), (v, (u, s))]) es
	putStrLn $ unwords $ map show $ map (inf-) $ scanr1 min $ zipWith (+) (dijkstra gy s) (dijkstra gs t) 

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

#define MAXN (1 << 18)
#define ll long long

int n, q, A, B;
int x[MAXN];
ll seg1[MAXN << 1], seg2[MAXN << 1];

ll query(ll *seg, int u, int l, int r, int ql, int qr){
	if(ql <= l && r <= qr) return seg[u];
	int m = l + r >> 1, ls = u << 1, rs = ls | 1;
	ll ret = LLONG_MAX;
	if(!(m < ql)) ret = std::min(ret, query(seg, ls, l, m, ql, qr));
	if(!(qr < m + 1)) ret = std::min(ret, query(seg, rs, m + 1, r, ql, qr));
	return ret;
}

void insert(ll *seg, int u, int l, int r, int pos, ll val){
	if(l == r){
		seg[u] = val;
		return;
	}
	int m = l + r >> 1, ls = u << 1, rs = ls | 1;
	if(pos <= m) insert(seg, ls, l, m, pos, val);
	else insert(seg, rs, m + 1, r, pos, val);
	seg[u] = std::min(seg[ls], seg[rs]);
}

int main(){
	scanf("%d%d%d%d", &n, &q, &A, &B);
	memset(seg1, 0x7f, sizeof seg1);
	memset(seg2, 0x7f, sizeof seg2);
	x[0] = B;
	insert(seg1, 1, 1, n, A, A);
	insert(seg2, 1, 1, n, A, -A);
	ll delta = 0;
	for(int i = 1; i <= q; ++ i){
		scanf("%d", x + i);
		
		ll tmp1 = query(seg1, 1, 1, n, x[i] + 1, n) - x[i];
		ll tmp2 = query(seg2, 1, 1, n, 1, x[i]) + x[i];
		tmp1 = std::min(tmp1, tmp2);
		
		ll now = query(seg1, 1, 1, n, x[i - 1], x[i - 1]) - x[i - 1] + delta;
		if(tmp1 < now){
			insert(seg1, 1, 1, n, x[i - 1], tmp1 + x[i - 1] - std::abs(x[i] - x[i - 1]));
			insert(seg2, 1, 1, n, x[i - 1], tmp1 - x[i - 1] - std::abs(x[i] - x[i - 1]));
		}
		
		delta += std::abs(x[i] - x[i - 1]);
	}
	ll ans = LLONG_MAX;
	for(int i = 1; i <= n; ++ i){
		ans = std::min(ans, query(seg1, 1, 1, n, i, i) - i + delta);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9216
N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))

a_max = max(a)

if a.count(a_max) >= 2:
    for _ in range(N):
        print(a_max)
    exit()

for i in a:
    if i == a_max:
        tmp = sorted(a)
        tmp = tmp[:-1]
        print(max(tmp))
    else:
        print(a_max)



Measured memory_bytes: 15604
# C - Exception Handling 
# 累積 max の問題
N = int(input())
A = [int(input()) for _ in range(N)]

# lm[i]; iより左にある値の中の最大値。 便宜上 lm[0] = 0 (i = 0 より左はない)
lm = [0]*N
# rm[i]; iより右にある値の中の最大値。 便宜上 lr[n-1] = 0 (i = n-1 より右はない)
rm = [0]*N
# 求める値は max(lm[i], rm[i]) (i = 0,1,2,...,n-1) 

# i = 0 より右にある値は i = 1,2,...,n-1 の n-1 個
for l in range(1,N): 
    lm[l] = max(lm[l-1], A[l-1])
    
# i = N-1 より左にある値は i = 0,1,2,...,n-2 の n-1 個
for r in  range(N-2,0-1,-1):# range(a,b) は [a,b)であることに注意
    rm[r] = max(rm[r+1],A[r+1])


for a in range(N):
    ans = max(lm[a],rm[a])
    print(ans)

Measured memory_bytes: 20176
def print(a, b, str)
  puts str.slice(a..b)
end

def reverse(a, b, str)
  str[a..b] = str.slice(a..b).reverse
end

def replace(a, b, p, str)
  str[a..b] = p
end

commands = ['print', 'reverse', 'replace']

str = gets.chomp
n = gets.chomp.to_i

n.times do
  command, *args = gets.chomp.split("\s")
  args[0], args[1] = args[0].to_i, args[1].to_i
  __send__(command, *(args+[str])) if commands.include?(command)
end

Measured memory_bytes: 8740
import java.util.Scanner;
class Main 
{
  public static void main(String[] args) 
  {
    Scanner input=new Scanner(System.in);
    int a=input.nextInt();
    int b=input.nextInt();
    int temp=a*a;
    if(a>=1 && a<=100 && b>=0 && b<=temp)
    {
      System.out.println(temp-b);
    }
  }
}

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

public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int n;
		int[] ans;
		String str;
		String[] s;
		str = bf.readLine();
		n = Integer.parseInt(str);
		str = bf.readLine();
		s = str.split(" ");
		ans = new int[n];
		for(int i = 0;i < n;++i) {
			ans[Integer.parseInt(s[i])-1] = i+1;
		}
		for(int i = 0;i < n;++i) {
			System.out.print(ans[i]);
			if(i != n-1) {
				System.out.print(" ");
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 43716
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;
int a[1000005];
int n;
int np[1005],ha[1000005];
int gcd(int a,int b){
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int now=a[1];
	for(int i=2;i<=n;i++)
		now=gcd(now,a[i]);
	if(now!=1){
		puts("not coprime");
		return 0;
	}
	for(int i=2;i<=1000;i++){
		if(np[i]) continue;
		for(int j=i*2;j<=1000;j+=i)
			np[j]=1;
		bool flag=0;int cnt=0;
		for(int j=1;j<=n;j++) {
			flag=0;
			while (a[j] % i == 0) a[j] /= i, flag = 1;
			cnt += flag;
		}
		if(cnt>1){
			puts("setwise coprime");
			return 0;
		}
	}
	for(int i=1;i<=n;i++)
		ha[a[i]]++;
	for(int i=2;i<=1000000;i++)
		if(ha[i]>1){
			puts("setwise coprime");
			return 0;
		}
	puts("pairwise coprime");
	return 0;
}


Measured memory_bytes: 7820
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

constexpr long long mod = static_cast<long long>(1e9 + 7);

int main() {
    std::string str;
    cin >> str;

    assert(str.size() == 4);

    bool ans = false;

    if(str[0] == str[1] && str[1] == str[2]) ans = true;
    else if (str[1] == str[2] && str[2] == str[3]) ans = true;

    if(ans) cout << "Yes" <<endl;
    else cout <<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
x, y, z = input().split()
x = int(x)
y = int(y)
z = int(z)

cnt = 0
rest = x

while(True):
    if(rest - (y + z) >= z):
        x -= y + z
        cnt += 1
        rest -= (y + z)
    else:
        break


print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n, m, k;
    cin>>n>>m>>k;
    vi a(n), b(m), v(n+m);
    for(int i = 0; i < n; i++)cin>>a[i];
    for(int i = 0; i < n; i++)v[i]=a[n-i-1];
    for(int i = 0; i < m; i++){
        cin>>b[i];
        v[n+i]=b[i];
    }
    int j = 0, s = 0, mx = 0;
    for(int i = 0; i < n+m; i++){
        s+=v[i];
        if(s>k)s-=v[j++];
        if(i>=n-1&&j<=n&&s<=k)mx=max(mx, i-j+1);
    }
    s=0, j = n+m-1;
    for(int i = n+m-1; i >= 0; i--){
        s+=v[i];
        if(s>k)s-=v[j--];
        if(i<=n&&j>=n-1&&s<=k)mx=max(mx, j-i+1);
    }
    cout<<mx;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 9420
gets;s=gets.chomp
a=[r=o=q=0]*26
s.each_byte{|b|a[b-97]+=1;q|=1<<b-97}
s.each_byte{|b|o|=1<<b-97;q^=1<<b-97 if 0==a[b-97]-=1;r=[r,(o&q).to_s(2).count(?1)].max}
p r

Measured memory_bytes: 1788
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    int n;cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    long long up = 0;
    long long resu = 1;
    for(int i=0;i<n-1;++i){
        if(up*(a[i+1]-a[i])<0){
            resu++;
            up = 0;
            continue;
        }
        if(a[i+1]-a[i]>0)up=1;
        if(a[i+1]-a[i]<0)up=-1;
    }
    cout<<resu<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=2e5+10;
int b[L];
int w[L];
char S[L];
int main() {
	int N;
	cin >> N >> (S+1);
	for(int i=1;i<=N;i++){
		w[i]+=w[i-1];
		if(S[i]=='#'){
			w[i]++;
		}
	}
	int ret=w[N];
	//cerr << w[N] << endl;
	for(int i=N;i>=1;i--){
		b[i]+=b[i+1];
		if(S[i]=='.'){
			b[i]++;
		}
		//cerr << w[i-1] << ", " << b[i] << endl;
		ret=min(ret,w[i-1]+b[i]);
	}
	cout << ret << endl;

	return 0;
}



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

using namespace std;

template<class T>
void copy(vector<T> from, vector<T> to) {
  copy(from.begin(), from.end(), back_inserter(to));
}

template<class T>
void sort(vector<T> a) {
  sort(a.begin(), a.end());
}

template<class T>
void input_to(vector<T> a) {
  T a_i;
  cin >> a_i;
  a.push_back(a_i);
}

int main() {
  int a[] = {0, 1, 0, 2, 0, 2, 0, 0, 2, 0, 2, 0};
  int x, y;
  cin >> x >> y;
  
  if (a[x - 1] == a[y - 1]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using namespace std;

#include<iostream>
#include<algorithm>
#include<cstdio>

int main()
{
   long long int N,arr[100000],i;

    while(scanf("%lld",&N)==1)
    {
        int sum=0,sum1=0;
        for(i=0;i<N;i++)
            scanf("%lld",&arr[i]);

        sort(arr,arr+N);
        for(i=0;i<N;i++)
        {

            sum=sum+sum1+arr[i];
            sum1+=arr[i];
        }


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

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

using namespace std;

int main()
{
	string s;
	cin>>s;
	for(int i=0;i<(int)s.size();i++) {
		if(s[i]=='7') {
			puts("Yes");
			return 0;
		}
	}	
	puts("No");
	return 0;
} 

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
#define fileio freopen("template.in", "r", stdin), freopen("template.out", "w", stdout);
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;

int main() {
    fastio;
    //fileio;
        
    int n;
    cin >> n;
    ll answer = 0;
    FOR(i, 1, n) {
        int num = n - i;
        for (int j = 1; j <= sqrt(num); j++) {
            if (num % j == 0) {
                answer += 2;
                if (num/j == j) {answer--;}
            }
        }
    }
    cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 3692
using System;
using System.Collections;
class main{
	public static void Main(){
		string[] str = Console.ReadLine().Split(' ');
		int a = int.Parse(str[0]), b = int.Parse(str[1]);
		int d, r;
		double f;
		d = a / b;
		r = a % b;
		f = (double)a / (double)b;
		Console.Write("{0} {1} {2}", d, r, f.ToString("F5"));
	}
}

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

bool solve() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  string S; cin >> S;
  rep(i, B, D) if(S[i-1] == '#' && S[i] == '#') return false;
  rep(i, A, C) if(S[i-1] == '#' && S[i] == '#') return false;
  if(C < D) return true;
  int cnt = 0;
  rep(i, B-2, D+1) {
    if(S[i] != '#') cnt++;
    else cnt = 0;
    if(cnt >= 3) return true;
  }
  return false;
}

int main() {
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}



Measured memory_bytes: 256
a = input()
if len(a) == 1:
    print(int(a))
    exit()
ans = 0
for i in range(2**(len(a)-1)):
    b = format(i, 'b').zfill((len(a)-1))
    li = []
    num = [a[0]]
    for i in range(len(b)):
        if b[i] == '1':
            ans += int(''.join(num))
            num = [a[i+1]]
        else:
            num.append(a[i+1])
    ans += int(''.join(num))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    ll ans = 0;
    REP(i, N-1) {
        if (a[i] > x) {
            ans += a[i+1];
            a[i+1] = 0LL;
            ans += a[i] - x;
            a[i] = x;
        } else {
            ans += max(0LL, a[i+1] - (x - a[i]));
            a[i+1] = min(a[i+1], x - a[i]);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;

int main()
{
	int n, k;
	cin >> n >> k;
	int arr[n];
	for(int i = 0; i < n; i++) cin >> arr[i];
	sort(arr,arr+n);
	int sum = 0;
	for(int i = 0; i < k; i++) sum += arr[i];
	cout << sum << "\n";
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=
vector<int>v;

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n,k;
	
	while(cin>>n>>k)
	{
		v.resize(n);
		
		for(int i=0;i<n;i++)
		{
			cin>>v[i];
		}
		
		sort(v.begin(),v.end());
		
		int sum=0;
		
		for(int i=0;i<k;i++)
			sum+=v[i];
		
		cout<<sum<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func search(now int, a []float64, k int) bool {
	count := 0
	for i := 0; i < len(a); i++ {
		for {
			if a[i] <= float64(now) {
				break
			}
			a[i] = a[i] / 2
			count++
		}
	}
	fmt.Println(count)
	fmt.Println(count >= k)
	//達成できるんだったらtrue
	return count >= k
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	n := iScan()
	k := iScan()
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = fScan()
	}
	l := 0.01
	r := 1e9 + 1
	for i := 0; i < 60; i++ {
		c := (r + l) / 2
		A := 0
		for _, v := range a {
			A += int(v / c)
		}
		if A > k {
			l = c
		} else {
			r = c
		}
	}
	fmt.Println(int(math.Ceil(l)))
}

Measured memory_bytes: 5840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;cin>>a>>b;
    if(a>=13)
    {
        cout<<b<<"\n";
    }
    else
        if(a>=6 && a<=12)
    {
        cout<<b/2<<"\n";
    }
    else
    {
        cout<<"0"<<"\n";
    }



    return 0;
}


Measured memory_bytes: 256
# 回答を読んで作成
# 全体の半分に到達可能、ただし１行もしくは１列の時は動けない
h,w = map(int, input().split())
if h==1 or w==1:
  ans = 1
else:
  ch = (h*w)/2
  ans = (ch//1)+((h*w)%2)
print(int(ans))

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

using namespace std;

bool valid_postal_code(string s, int a, int b) {
    if (s[a] != '-')
        return false;

    for (int i = 0; i < a; ++i) {
        if (isdigit(s[i]) == 0)
            return false;
    }
    for (int i = 0; i < b; ++i) {
        int idx = a + 1 + i;
        if (isdigit(s[idx]) == 0)
            return false;
    }
    return true;
}

int main() {
    int a, b;
    cin >> a >> b;

    string s;
    cin >> s;

    if (valid_postal_code(s, a, b))
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 256
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
using std::vector;
#include<string>
using std::string;
#include<set>
using std::set;
#include<map>
using std::map;
#include<unordered_map>
#include<queue>
#include<tuple>
using std::get;
using std::pair;
using std::tuple;
#include<iostream>
#include<sstream>
#include<iomanip>
using lnt = long long int;
using unt = unsigned long long int;
using ust = unsigned;
using dou = double;
using P = std::pair<int,int>;
#define FZ(i,n)       for(int i=0;i<(n);++i)
#define FB(i,n)       for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed)   for(int i=st;i<(ed);++i)
#define FC(i,n)       for(int i=n;i;--i)
#define FZU(i,n)      for(ust i=0;i!=(n);++i)
#define FVU(i,st,ed)  for(ust i=st;i<(ed);++i)
#define FCU(i,n)      for(ust i=n;i;--i)
#define ALL(x)        std::begin(x),std::end(x)
#define DTRL(x,y)     do{auto&x_(x),&y_(y);if(x_!=y_)return x_<y_;}while(0)

#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%lld",&(x))
#define RII64(x,y) scanf("%lld%lld",&(x),&(y))

#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;

int main(){
    int n;
    std::cin >> n;
    int mx = -1;
    int ans = 0;
    for(int i=0;i<n;++i){
        int x;
        std::cin >> x;
        if(mx <= x){
            ++ans;
            mx = x;
        }
    }
    std::cout << ans << '\n';
}


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

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int> A(M);
  for(int i=0;i<M;i++){
    cin >> A.at(i);
  }
  
  int date = N;
  for(int i=0;i<M;i++){
    date -= A.at(i);
  }
  
  if(date<0){
    date = -1;
  }
  
  cout << date << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int n, a[200100], b[200100];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d %d", a + i, b + i);
	sort(a, a + n);
	sort(b, b + n);
	if (n & 1)
		printf("%d\n", b[n / 2] - a[n / 2] + 1);
	else
		printf("%d\n", (b[n / 2 - 1] + b[n / 2]) - (a[n / 2 - 1] + a[n / 2]) + 1);
}

Measured memory_bytes: 3292
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int a[3];
  cin >> a[0]>>a[1]>>a[2];
  sort(a,a+3);
  if(a[0]==a[1]&&a[0]==5){
    if(a[2]==7) cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
  }
  else cout <<"NO"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double a[200005];
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]=(a[i]+1)/2.0;
    }
    double ans=0;
    for(int i=1;i<=k;i++){
        ans+=a[i];
    }
    double num=ans;
    for(int i=2;i<=n-k+1;i++){
        num=num-a[i-1]+a[i+k-1];
        ans=max(ans,num);
    }
    printf("%.10f",ans);
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] S = new int[N];
		for(int i = 0 ; i < N ; i++){
			S[i] = sc.nextInt();
		}
		sc.close();

		if(N==K){
			System.out.println(1);
		}
		else{
			int ans = 0;
			for(int i = K; i < N ; i+=(K-1)){
				ans++;
			}
			ans++;
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 50608
#include <algorithm>
#include<iostream>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;

  int sum = 0;

  for(int i = 0; i < 2; i++){
    if(a > b){
      sum += a;
      a--;
    }
    else {
      sum += b;
      b--;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())
ans = deque()
ans.append(S)
turncnt = 0
for i in range(Q):
    query = input().split()
    if (query[0] == "1"):
        turncnt = turncnt + 1
    if (query[0] == "2"):
        if (query[1] == "1"):
            if (turncnt % 2 == 0):
                ans.appendleft(query[2])
            else:
                ans.append(query[2])
        if (query[1] == "2"):
            if (turncnt % 2 == 0):
                ans.append(query[2])
            else:
                ans.appendleft(query[2])

anstr = "".join(ans)
if (turncnt % 2 == 1):
    anstr = anstr[::-1]
print(anstr)


Measured memory_bytes: 6900
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		long[] arr = new long[N];
		long ans = 1;
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextLong();
		}
		ans*=arr[0];
		for (int i = 1; i < N; i++) {
			long curGCD = GCD(ans,arr[i]);
			arr[i]/=curGCD; //Trying to avoid overflow
			ans*=arr[i];
		}
		System.out.println(ans);
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a, b);
		return GCD(Math.max(a, b)%Math.min(a, b),Math.min(a, b));
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
using ll = long long;
int main(void){
    // Your code here!
    int n;ll h,w;
    cin>>n>>h>>w;
    vector<pair<ll,ll>> ab(n);
    
    int count =0;
    for(int i=0;i<n;++i){
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ab.begin(),ab.end());
    for(int i=0;i<n;i++){
        if(ab[i].first >= h && ab[i].second >= w) count++;
    }
    cout << count << endl;
}


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

using namespace std;

int main(){
  int N;
  int a, b, c, d;
  cin >> N;
   
  a = N / 1000;
  b = (N % 1000) / 100;
  c = (N % 100) / 10;
  d = N % 10;
  
  if ((a==b && b == c) || (b == c && c == d)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }  
}

Measured memory_bytes: 256
s = input()
n = len(s)
first, last = 0,0

for i in range(n):
  b,f = i+1, n-i
  if s[-1-i] == 'A':
    first = f
  if s[i] == 'Z':
    last = b

# print(first, last)
print(last - first+1)
   

Measured memory_bytes: 9164
#include <cstdio>
#include <algorithm>

namespace DinicFlows {
	typedef long long LL;
	const LL Inf = 0x3f3f3f3f3f3f3f3f;
	const int MN = 200005, MM = 400005;
	
	int N, S, T;
	int h[MN], iter[MN], nxt[MM * 2], to[MM * 2], tot; LL w[MM * 2];
	
	inline void SetST(int, int);
	inline void Init(int _N) {
		N = _N, tot = 1;
		for (int i = 1; i <= N; ++i) h[i] = 0;
		SetST(_N - 1, _N);
	}
	inline void SetST(int _S, int _T) { S = _S, T = _T; }
	
	inline void ins(int u, int v, LL x) { nxt[++tot] = h[u], to[tot] = v, w[tot] = x, h[u] = tot; }
	inline void insw(int u, int v, LL w1 = Inf, LL w2 = 0) {
		if (!u) u = S; if (!v) v = T;
		ins(u, v, w1), ins(v, u, w2);
	}
	
	int lv[MN], que[MN], l, r;
	
	inline bool Lvl() {
		for (int i = 1; i <= N; ++i) lv[i] = 0;
		lv[S] = 1;
		que[l = r = 1] = S;
		while (l <= r) {
			int u = que[l++];
			for (int i = h[u]; i; i = nxt[i])
				if (w[i] && !lv[to[i]]) {
					lv[to[i]] = lv[u] + 1;
					que[++r] = to[i];
				}
		}
		return lv[T] != 0;
	}
	
	LL Flow(int u, LL f) {
		if (u == T) return f;
		LL d = 0, s = 0;
		for (int &i = iter[u]; i; i = nxt[i])
			if (w[i] && lv[to[i]] == lv[u] + 1) {
				d = Flow(to[i], std::min(f, w[i]));
				f -= d, s += d;
				w[i] -= d, w[i ^ 1] += d;
				if (!f) break;
			}
		return s;
	}
	
	inline LL Dinic() {
		LL Ans = 0;
		while (Lvl()) {
			for (int i = 1; i <= N; ++i) iter[i] = h[i];
			Ans += Flow(S, Inf);
		}
		return Ans;
	}
}
using DinicFlows::h;
using DinicFlows::to;
using DinicFlows::nxt;
using DinicFlows::w;
using DinicFlows::insw;

const int MN = 100005;

int N, mch[MN], vis[MN];
int eu[MN], ev[MN], M;

void DFS(int u) {
	for (int j = h[u]; j; j = nxt[j]) {
		if (to[j] == N + N || vis[to[j] - N]) continue;
		int id = to[j] - N;
		vis[id] = 1;
		for (int k = h[to[j]]; k; k = nxt[k]) if(w[k])
			++M, eu[id] = u, ev[id] = to[k], DFS(to[k]);
	}
}

int main() {
	scanf("%d", &N);
	DinicFlows::Init(N + N + 1);
	for (int i = 1; i <= N; ++i) insw(0, i, 1);
	for (int i = 1, c, x; i < N; ++i) {
		scanf("%d", &c);
		while (c--) scanf("%d", &x), insw(x, N + i, 1);
		insw(N + i, 0, 1);
	}
	if (DinicFlows::Dinic() != N - 1) return puts("-1"), 0;
	int Root = 0;
	for (int i = h[N + N]; i; i = nxt[i]) if (w[i]) Root = to[i];
	DFS(Root);
	if (M != N - 1) return puts("-1"), 0;
	for (int i = 1; i < N; ++i) printf("%d %d\n", eu[i], ev[i]);
	return 0;
}

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

int main(){
  int a,b,c,k;
  int ans = 0;
  cin >> a >> b >> c >> k;
  ans += min(a,k);
  k = k-(a+b);
  if(k>0)ans -= k;
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int s,t;
    cin>>n;
    vector<pair<int,int> > v;
    for(int i=0;i<n;i++){
    	cin>>s>>t;
    	v.pb(make_pair(t,s));
    }
    int num=0,ans=0;
    sort(be(v));
    for(auto& i:v){
    	if(i.second>=num){
    		num=i.first+1;
    		ans++;
    	}
    }
    cout <<ans<<endl;
    return 0;
}



Measured memory_bytes: 3912
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	int maxx=0,minn=0x3f3f3f3f;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		maxx=max(maxx,x);
		minn=min(minn,x);
	}
	printf("%d\n",maxx-minn);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int x, y;
    cin >> x >> y;
    cout << x + y/2 << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3656
n, w = map(int, input().split())

inf = 10 ** 10
dp = [[inf] * (10**5+3) for _ in range(n+1)]
dp[0][0] = 0
for i in range(n):
    weight, value = map(int, input().split())
    for j in range(10**5 + 3):
        if j - value >= 0:
            dp[i+1][j] = min(
                dp[i][j - value] + weight,
                dp[i][j]
            )
        else:
            dp[i+1][j] = dp[i][j]
for i in reversed(range(10**5+3)):
    if dp[n][i] <= w:
        print(i)
        break



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

using namespace std;
using ll = long long;

int n;
ll A[405];
ll pre[405];

ll getSum(int i, int j) {
  ll res = pre[j];
  if (i > 0) {
    res -= pre[i - 1];
  }
  return res;
}

ll dp[405][405];

ll solve(int i, int j) {
  if (i == j) { return 0; }
  ll& res = dp[i][j];
  if (res != -1) { return res; }
  res = numeric_limits<ll>::max();
  for (int k = i; k < j; k++) {
    ll left = solve(i, k);
    ll right = solve(k + 1, j);
    res = min(res, left + right + getSum(i, j));
  }
  return res;
}

int main() {
  fill(&dp[0][0], &dp[0][0] + 405 * 405, -1LL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    pre[i] = A[i];
    if (i > 0) {
      pre[i] += pre[i - 1];
    }
  }
  cout << solve(0, n - 1) << '\n';
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    cout.precision(12);
    int n;
    cin >> n;
    vector<double> p(n+1);
    rep(i, 1, n+1)
        cin >> p[i];
    vector<vector<double>> dp(n+1, vector<double>(n+1,0.0));
    dp[0][0] = 1.0;
    rep(i, 1, n+1)
        rep(j, 0, i+1)
        {
            if (j == 0)
                dp[i][j] = dp[i-1][j] * (1.0 - p[i]);
            else 
                dp[i][j] = dp[i-1][j] * (1.0 - p[i]) + dp[i-1][j-1] * p[i];
        }
    double sum = 0.0;
    rep(i, (n+1)/2, n+1)
        sum += dp[n][i];
    cout << sum << setprecision(12);
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int money = 100000;
  for(int i=0;i<n;i++){
    money*=1.05;
    if(money%1000!=0){
      money/=1000;
      money*=1000;
      money+=1000;
    }
  }
  cout<<money<<endl;
}



Measured memory_bytes: 2996