akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <vector>
#include <set>
#include <iostream>
using namespace std;
int main() {
    int n, K; cin >> n >> K;
    int h[n]; for (int i = 0; i < n; i++) cin >> h[i];
    set<int> s; for (int i = 0; i < n; i++) s.insert(h[i]);
    s.insert(0);
    vector<int> H(s.begin(), s.end());
    long long dp[2][H.size()][K+1];
    int cur = 0, prev = 1;
    const long long INF = 1LL<<60;
    for (int j = 0; j < H.size(); j++)
        for (int k = 0; k <= K; k++) {
            dp[cur][j][k] = dp[prev][j][k] = INF;
        }
    dp[prev][0][0] = 0;
    for (int i = 0; i < n; i++) {
        long long R[H.size()][K+1], L[H.size()][K+1];
        for (int j = H.size() - 1; j >= 0; j--) {
            for (int k = 0; k <= K; k++)
                if (j == H.size()-1) R[j][k] = dp[prev][j][k];
                else R[j][k] = min(R[j+1][k], dp[prev][j][k]);
        }
        for (int j = 0; j < H.size(); j++) {
            for (int k = 0; k <= K; k++)
                if (j == 0) L[j][k] = INF;
                else L[j][k] = min(L[j-1][k], dp[prev][j-1][k] - H[j-1]);
        }
        for (int j = 0; j < H.size(); j++) {
            int d = (H[j] != h[i]);
            for (int k = 0; k <= K; k++) {
                dp[cur][j][k] = k < d ? INF : min(R[j][k-d], L[j][k-d] + H[j]);
            }
        }
        swap(cur, prev);
    }
    long long ans = INF;
    for (int i = 0; i < H.size(); i++)
        ans = min(ans, *min_element(dp[prev][i], dp[prev][i] + K + 1));
    cout << ans << endl;
}


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

struct hms {
  int t;
  int h, m, s;
  hms(int _h, int _m, int _s) {h=_h;m=_m;s=_s;t=h*3600+m*60+s;}
  hms(int _t) {t = _t; h = t/3600; m = t%3600/60; s=t%60;}
};


int main() {

  int h, m, s;
  while(cin >> h >> m >> s) {
    if (h==-1&&m==-1&&s==-1) break;
    hms ans(hms(2,0,0).t-hms(h,m,s).t);
    printf("%02d:%02d:%02d\n", ans.h,ans.m,ans.s);
    hms ans2(ans.t*3);
    printf("%02d:%02d:%02d\n", ans2.h,ans2.m,ans2.s);
  }
}

Measured memory_bytes: 0
import java.util.ArrayList;
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();
		ArrayList<Integer> po = new ArrayList<Integer>();
		for(int i=0;i<N;i++){
		  po.add(sc.nextInt());
		}
		po.sort(null);
		int min = Integer.MAX_VALUE;
		for(int i=0;i<N - K+1;i++){
		  if(po.get(i+K-1) - po.get(i) < min){
		    min = po.get(i+K-1) - po.get(i);
		  }
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 61764
from scipy.spatial.distance import cdist
import numpy as np
#%%
n, m = map(int, input().split())

st = [list(map(int, input().split())) for _ in range(n)]
cp = [list(map(int, input().split())) for _ in range(m)]
#%%

# for s in st:
#     print(cityblock(s, np.array(cp)))
cd = cdist(st, cp, 'cityblock')
idx = np.argmin(cd, axis=1)
for i in idx:
    print(i+1)

Measured memory_bytes: 44420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin >> a >> b;
	if (a != 1 && b != 1) cout << 1 << endl;
	else if (a != 2 && b != 2) cout << 2 << endl;
	else cout << 3 << endl;
 }

Measured memory_bytes: 256
word = input()
nums = int(input())

for _ in range(nums):
    row = input().split()
    if row[0] == 'replace':
        s, e, st = int(row[1]), int(row[2]), row[3]
        word = word[:s] + st + word[e+1:]
    elif row[0] == 'reverse':
        s, e = int(row[1]), int(row[2])
        word = word[:s] + ''.join(reversed(word[s:e+1])) + word[e+1:]
    elif row[0] == 'print':
        s, e = int(row[1]), int(row[2])
        print(word[s:e+1])



Measured memory_bytes: 5624
A = [0,0,0,0,0]
B = []
for i in range(5):
    A[i] = int(input())
    b = 10 - A[i] %10
    if b == 10:
        b = 0
    B.append ([b, A[i]]) # 10のあまりをだす
B.sort()

re = 0
for i in range(5):
    if i == 4:
        B[i][0] = 0
    re += B[i][0] + B[i][1]
    
print(re)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    r *= 100;
    g *= 10;
    b *= 1;
    int sum;
    sum = r + g + b;
    if(sum % 4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  float a,b,c,d;
  cin>>a>>b>>c>>d;
  int k,l;
  k=ceil(c/b);
  l=ceil(a/d);
  if(k<=l)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3680
//#include <sstream>
//#include <fstream>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <set>
//#include <list>
//#include <map>
//#include <unordered_map>
//#include <functional>
//#include <utility>
//#include <bitset>
//#include <cstdlib>
//#include <ctime>
//#include <cstdio>


#include <stdlib.h>
#include <iostream>
//#include <chrono> //clock
//#include <vector>
#include <string>
#include <iomanip>  //setprecision function
//#include <cmath>	//math
//#include <cstdio>
//#include <vector>	//vector array
//#include <algorithm>	//STL algorithm
//#include <set> //STL library set
//#include <sstream> // for stringstream


using namespace std;
//using namespace std::chrono; 



//c++ templte for help...........................................................

//#define deb(x) cout<<#x<<" "<<x<<endl;/* for debuging  printing variable with name*/
//#define debb(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;										
//#define debbb(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;			

//typedef long long ll;

	
//for taking multiple input
//template<typename... T>
//void input(T&... t){
	//((cin>>t),...);
	//}
	
//for loop
//#define fo(i,n) for(ll i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(ll i=k;i<n;i++)


//to print vector element 
//template<typename T>
//void printV(T vec){
		//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//}
	







//c++ template for help........................................................


int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(16);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
	 // KYA KYA CHEJ IMPORTANT HA WO STATE BN JYAGA AUR HUM LOG STATE KO CHANGE KR SKTA HA JYSA KNPSACK 2 WALE PROBLEM MA KIA THA
	 

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


	if(sum<=n) cout<<n-sum<<endl;
	else cout<<-1<<endl;
	











	
	
	return 0;
}





























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

using namespace std;

int dp[234567][4];

int main(){
  int N; cin >> N;
  int a[N+2], b[N+2], c[N+2];
  for(int i=1; i<=N; ++i) cin >> a[i] >> b[i] >> c[i];
  for(int i=1; i<=N; ++i)
    for(int j=1; j<=3; ++j){
      if(j == 1){
        dp[i][j] = max(max(dp[i-1][2], dp[i-1][3]) + a[i], dp[i][j]);
      }
      else if(j == 2){
        dp[i][j] = max(max(dp[i-1][1], dp[i-1][3]) + b[i], dp[i][j]);
      }
      else{
        dp[i][j] = max(max(dp[i-1][1], dp[i-1][2]) + c[i], dp[i][j]);
      }
    }
  cout << max({dp[N][1], dp[N][2], dp[N][3]}) << "\n";
  return 0;
}


Measured memory_bytes: 2944
def main():
  import sys
  from scipy.sparse.csgraph import floyd_warshall as f
  n,m,l,*t=map(int,sys.stdin.buffer.read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d>n]=-1
  d=d.astype(int)
  print('\n'.join(map(str,[d[i]for i in zip(*[iter(t[m*3+1:])]*2)])))
main()

Measured memory_bytes: 38088
n = int(input())
a = list(map(int, input().split()))
q = int(input())
query = [list(map(int, input().split())) for i in range(q)]

memo = {}
sum_ = 0
for i in range(n):
    if a[i] not in memo:
        memo[a[i]] = 0
    memo[a[i]] += 1
    sum_ += a[i]

for b, c in query:
    diff_num = 0
    if b not in memo:
        print(sum_)
        continue
    diff_cnt = memo[b]
    diff_num -= b * memo[b]
    memo[b] = 0
    
    if c not in memo:
        memo[c] = 0
    memo[c] += diff_cnt
    diff_num += c * diff_cnt
    sum_ += diff_num
    print(sum_)

Measured memory_bytes: 100440
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

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

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	t := "CODEFESTIVAL2016"
	cnt := 0
	fmt.Scan(&s)
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

template <int MAX_N>
class UnionFind {
public:
    int parent[MAX_N];
    int rank[MAX_N];

    UnionFind() {
    }

    void init(int n) {
        for (int j = 0; j < n; ++j) {
            parent[j] = j;
            rank[j] = 0;
        }
    }

    int find(int x) {
        if (parent[x] == x) {
            return x;
        }
        return parent[x] = find(parent[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        } else {
            parent[y] = x;
            if (rank[x] == rank[y]) {
                ++rank[x];
            }
        }

        return true;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

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

int W, H;
string s[1000];
int N;
int x[1010], y[1010];

UnionFind<1010*1010> uf;

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

    cin >> W >> H;
    for (int j = 0; j < H; ++j) {
        cin >> s[j];
    }
    cin >> N;
    for (int j = 0; j < N; ++j) {
        cin >> x[j] >> y[j];
    }

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

    uf.init(W*H);

    int start = 0;
    int goal;
    bool found = false;
    for (int j = 0; !found && j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            if (s[j][k] == 't') {
                found = true;
                goal = j*W + k;
                break;
            }
        }
    }

    for (int j = 0; j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            if (j < H-1) {
                if (s[j][k] != '#' && s[j+1][k] != '#') {
                    uf.unite(W*j+k, W*(j+1)+k);
                }
            }
            if (k < W-1) {
                if (s[j][k] != '#' && s[j][k+1] != '#') {
                    uf.unite(W*j+k, W*j+k+1);
                }
            }
        }
    }

    if (uf.same(start, goal)) {
        cout << 0 << endl;
        return 0;
    }

    for (int j = 0; j < N; ++j) {
        s[y[j]][x[j]] = '.';

        for (int k = 0; k < 4; ++k) {
            int ny = y[j] + dy[k];
            int nx = x[j] + dx[k];
            if (0 <= ny && ny < H && 0 <= nx && nx < W && s[ny][nx] != '#') {
                uf.unite(y[j]*W+x[j], ny*W+nx);
            }
        }

        if (uf.same(start, goal)) {
            cout << j+1 << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 12004
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll N,P;
int main(){
    cin>>N>>P;
    ll tp;
    bool flag = false;
    rep(i,N){
        cin >> tp;
        if(tp%2) flag = true;
    }
    ll ans = pow(2,N-1);
    if(flag) pr(ans);
    else{ if(P) pr(0); else pr(2*ans);}
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace  std;
int main() {
    int N, M;
    int l = 0, r = 1000000;

    cin >> N >> M;
    while(M--) {
        int L, R;
        cin >> L >> R;
        l = max(l, L);
        r = min(r, R);
    }

    int ans = 0;
    if (l <= r) {
        ans = r - l + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define cin1(x) cin>>x
#define cin2(x,y) cin>>x>>y
#define cin3(x,y,z) cin>>x>>y>>z
#define ll long long
#define mp make_pair
#define pb push_back
#define nl printf("\n")
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)
const int todx[] = { -2, -2, -1, -1,  1,  1,  2,  2 };
const int tody[] = { -1,  1, -2,  2, -2,  2, -1,  1 };
bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}


int main(){
    ll n;
    cin>>n;
    cout<<!n<<endl;
}


Measured memory_bytes: 81188
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
A.append(0)
buff = [abs(A[0])]
buff2 = [abs(A[1])]


for i in range(2, N+1):
    buff2.append(abs(A[i]-A[i-2]))
# print('buff2')
# print(buff2)
# print('')
for i in range(1, N+1):
    buff.append(abs(A[i]-A[i-1]))

# print(buff)
mm = sum(buff)
for i in range(N):
    print(mm-buff[i]-buff[i+1]+buff2[i])

# acc = list(accumulate(buff))
# print(acc)0pp0

Measured memory_bytes: 58860
#define _CRT_SECURE_NO_WARNING

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm> 
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,j,i,max;
	scanf("%lld",&j);
	for(i=1;i<sqrt(j)+1;i++)
	{
		if(j%i==0)
		{
			max=i;
		}
	}
	printf("%lld\n",max-1+j/max-1);
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) arr[i] = scanner.nextInt();
        Arrays.sort(arr);
        if (k >= n) System.out.println(0);
        else {
            long sum = 0;
            for (int i = 0; i < n - k; i++) sum += arr[i];
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 64932
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;

int main(){
	int A, B;
	cin>>A>>B;
	int ans = 0;
	
		ans += max(A, B);
		if(ans == A)A--;
		else B--;
		ans+=max(A, B);
		cout<<ans<<endl;
		return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(map(int,input().split()))
c = 0

s = sorted(s)

for i in range(n-1):
    if c == 0:
        c = (s[i] + s[i+1]) / 2 
    else:
        c = (c + s[i+1]) / 2 

print(c)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    int d[n];rep(i,0,n)cin>>d[i];
    sort(d,d+n);
    cout<<d[n/2]-d[n/2-1]<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<(n);i++)
const int MOD = 987654319;// 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=300002;

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

      string s; cin>>s;
      int n=s.length();
      int cnt=0;
      forn(i,n) 
      {
            if(s[i]=='o') cnt++;
      }
      if(cnt+(15-n)>=8) cout<<"YES\n";
      else cout<<"NO\n";
}

Measured memory_bytes: 256
<?php

while (true) {
	$inputs = explode(" ", rtrim(fgets(STDIN)));
	$h = $inputs[0];
	$w = $inputs[1];
	if (($h == 0) && ($w == 0)) {
		break;
	}
	for ($i = 0; $i < $w; ++$i) {
		echo '#';
	}
	echo PHP_EOL;
	for ($j = 2; $j < $h; ++$j) {
		echo '#';
		for ($i = 2; $i < $w; ++$i) {
			echo '.';
		}
		echo '#', PHP_EOL;
	}
	for ($i = 0; $i < $w; ++$i) {
		echo '#';
	}
	echo PHP_EOL, PHP_EOL;
}

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


int main() {
  int L;
  int R;
  int d;
  int Ans=0;
  cin >> L >> R >> d;
  
  for(int i=L; i<=R; i++){
   if(i%d==0){
     Ans++;
   }
  }
  cout << Ans ;

}

Measured memory_bytes: 3620
X, Y = map(int, input().split())
ans = 0

if X == Y == 1:
    ans = 400000

money = {3: 100000, 2: 200000, 1: 300000}
if X <= 3:
    ans += money[X]
if Y <= 3:
    ans += money[Y]

print(ans)


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

using namespace std;

const int N = 55;
char s[N];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  bool ok = 0;
  for (int i = 0; i + 1 < n; i++)
    if (s[i] == 'A' && s[i+1] == 'C')
      ok = 1;
  puts(ok ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
let read_ints () =
  let str = read_line() in
  List.map (fun x -> int_of_string x) (Str.split (Str.regexp " +") str)
;;

let str = read_ints() in
match str with
|x :: [y] -> if (y mod 2 = 0 && y >= 2 * x && y <= 4*x) then print_endline "Yes" else print_endline "No"
|_ -> ()


Measured memory_bytes: 3608
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
  int x, i, j, t;
  x=A[r];
  i=p-1;
  for(j=p; j<r; j++)
  {
    if(A[j]<=x)
    {
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }

  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;

  return i+1;
}

int main(){
  int i, q;

  scanf("%d", &n);

  for(i=0; i<n; i++)
    scanf("%d", &A[i]);

  q=partition(0, n-1);

  for(i=0; i<n; i++)
  {
    if(i)
      printf(" ");
    if(i == q)
      printf("[");

    printf("%d", A[i]);

    if(i == q)
      printf("]");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2108
import java.io.InputStream
import java.util.ArrayDeque

fun main(args: Array<String>) = input.run {
    val n = nextInt()
    val a = nextInts(n)
    val ans = ArrayDeque<Int>()

    a.forEachIndexed { i, v ->
        if (i % 2 == 0) {
            ans.addLast(v)
        } else {
            ans.addFirst(v)
        }
    }

    println(if (n % 2 == 1) {
        ans.reversed()
    } else {
        ans
    }.joinToString(" "))
}

val input = FastScanner()

class FastScanner(private val input: InputStream = System.`in`) {
    private val sb = StringBuilder()
    private val buffer = ByteArray(4096)
    private var pos = 0
    private var size = 0

    fun nextLong(): Long {
        var c = skipWhitespace()

        val sign = if (c == '-'.toInt()) {
            c = read()
            -1
        } else 1

        var ans = 0L

        while (c > ' '.toInt()) {
            ans = ans * 10 + c - '0'.toInt()
            c = read()
        }

        return sign * ans
    }

    fun nextInt() = nextLong().toInt()

    fun nextInts(n: Int) = IntArray(n) { nextInt() }

    private fun skipWhitespace(): Int {
        while (true) {
            val c = read()
            if (c > ' '.toInt() || c < 0) return c
        }
    }

    private fun read(): Int {
        while (pos >= size) {
            if (size < 0) return -1
            size = input.read(buffer, 0, buffer.size)
            pos = 0
        }
        return buffer[pos++].toInt()
    }
}

Measured memory_bytes: 56776
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

int n,a,b,c,d;
string s;
int main(){
  cin >> n >> a >> b >> c >> d >> s;
  bool f = false;
  s = '#' + s + '#';

  auto ispos = [&](int st, int gl){
		 for(int i = st; i+1 <= gl; i++){
		   if(s[i] == '#' && s[i+1] == '#') return false;
		 }
		 return true;
	    };

  if(!ispos(a,c) || !ispos(b,d)){
    cout << "No" << endl;
    return 0;
  }


  if(d < c){
    for(int i = b; i <= d; i++){
      if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') f = true;
    }
  }

  if(c < d) f = true;

  cans(f);

  return 0;
}



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

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (int array1[], int array2[], int l, int r) {
    int pivot = array1[r];
    int i = (l - 1);

    for (int j = l; j <= r - 1; j++) {
        if (array1[j] <= pivot) {
            i++;
            swap(&array1[i], &array1[j]);
            swap(&array2[i], &array2[j]);
        }
    }
    swap(&array1[i + 1], &array1[r]);
    swap(&array2[i + 1], &array2[r]);
    return (i + 1);
}

void quickSort(int array1[], int array2[], int l, int r) {
    if (l < r) {
        int pivot = partition(array1, array2, l, r);
        quickSort(array1, array2, l, pivot - 1);
        quickSort(array1, array2, pivot + 1, r);
    }
}

int main()
{
    int n;
    cin >> n;
    int a[n+1]={0};
    int b[n+1]={0};
    rep(i,n) cin >> a[i+1] >> b[i+1];
    //rep(i,n) cout << a[i+1] << b[i+1] << endl;
    //cout << " " << endl;

    quickSort( b, a, 0, n );
    //rep(i,n+1) cout << a[i] << b[i] << endl;
    //cout << " " << endl;

    int t = 0;
    for( int i = 1; i < n+1; i++ ){
        t += a[i];
        //cout << a[i] << " " << b[i] << " " << t << endl;
        if( t > b[i] ){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  
  else if (A+B == C+D) { 
    cout << "Balanced" << endl;
  }
  
   else { 
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lsk 998244353
int n;
int x[205],y[205];
int vd[205][205];
int main(){
	scanf("%d",&n);
	int ans=1;
	for(int i=1;i<=n;++i)scanf("%d%d",x+i,y+i),ans=(ans<<1)%lsk;
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){int a=1;
			for(int k=j+1;k<=n;++k){
				if((x[j]-x[i])*(y[k]-y[i])==(x[k]-x[i])*(y[j]-y[i]))a=(a<<1)%lsk;
			}ans-=a;ans%=lsk;
		}
	}
	cout<<((ans-n-1)%lsk+lsk)%lsk;
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	while(true){
		int n,x; cin>>n>>x;
		if(n==0&&x==0)break;
		int ans=0;
		for(int i=1;i<=n;++i){
			for(int j=i+1;j<=n;++j){
				for(int k=j+1;k<=n;++k){
					if(i+j+k==x)++ans;
				}
			}
		}
		cout<<ans<<"\n"s;
	}
}


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


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

  int diff = b - a;
  int sum = 0;
  for (int i = 1; i < b - a; i++) {
    sum += i;
  }
  cout << sum - a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long x;
	cin>>x;
	long long res=x/11ll;
	if(res*11ll>=x) {
		cout<<res*2;
	}
	else if(res*11ll+6>=x) {
		cout<<res*2+1;
	}
	else
		cout<<res*2+2;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut tiles = vec![vec![0i64; 2 * k]; 2 * k];

    for _ in 0..n {
        let v = read_vec::<String>();
        let mut x: usize = v[0].parse().unwrap();
        let mut y: usize = v[1].parse().unwrap();
        if v[2] == "W" {
            y += k;
        }
        x %= k * 2;
        y %= k * 2;
        if y >= k {
            x = (x + k) % (k * 2);
            y = y - k;
        }

        tiles[x][y] += 1;
        tiles[x][y + k] -= 1;
        if x < k {
            tiles[x + k][y] -= 1;
            tiles[x + k][y + k] += 1;
        } else if x > k {
            tiles[x - k][y] -= 1;
            tiles[x - k][y + k] += 1;
            tiles[0][y] += 1;
            tiles[0][y + k] -= 1;
        }
    }

    for x in 0..2 * k {
        for y in 1..2 * k {
            tiles[x][y] += tiles[x][y - 1];
        }
    }

    for x in 1..2 * k {
        for y in 0..2 * k {
            tiles[x][y] += tiles[x - 1][y];
        }
    }
    let mut ans = 0;
    for x in 0..k * 2 {
        for y in 0..k * 2 {
            ans = std::cmp::max(
                ans,
                tiles[x][y] + tiles[(x + k) % (2 * k)][(y + k) % (2 * k)],
            );
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 45308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define all(x) ((x).begin(),(x).end())

int main(){
    int H,W; cin >> H >> W;
    cout << string(W+2,'#') << endl;
    FOR(i,0,H){
        string s;cin>>s;
        s = "#" + s + "#";
        cout <<s << endl;
    }
    cout << string(W+2,'#') << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a<b) printf("a < b\n");
	if(a>b) printf("a > b\n");
	if(a==b) printf("a == b\n");
	
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

/*
a[i]=lcp(s[0,N),s[i,N))
time,space:O(N)
*/

template<class T>
vector<int>zalgorithm(T s){
    vector<int>a(s.size());
    a[0]=s.size();
    int i=1,j=0;
    while(i<s.size()){
        while(i+j<s.size()&&s[j]==s[i+j])j++;
        a[i]=j;
        if(j==0){i++;continue;}
        int k=1;
        while(i+k<s.size()&&k+a[k]<j)a[i+k]=a[k],k++;
        i+=k;j-=k;
    }
    return a;
}

int N;

signed main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin>>N;
    vint A(N),B(N);
    rep(i,N)cin>>A[i];
    rep(i,N)cin>>B[i];

    auto conv=[](vint A){
        vint D(A.size());
        rep(i,A.size())D[i]=A[(i+1)%A.size()]^A[i];
        return D;
    };
    auto X=conv(A);
    auto Y=conv(B);


    vector<int>S;
    S.insert(S.end(),all(Y));
    S.insert(S.end(),all(X));
    S.insert(S.end(),all(X));
    auto z=zalgorithm(S);
    rep(k,N){
        if(z[N+k]>=N){
            cout<<k<<" "<<(A[k]^B[0])<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 22956
N = int(input())
p = list(map(int, input().split()))
ans = 0
q = []
for i in range(N):
  if i+1 == p[i]:
    q += [0]
  else:
    q += [1]

for i in range(N):
  if q[i] == 0 and i < N-1:
    q[i], q[i+1] = 1, 1
    ans += 1
  elif q[i] == 0 and i == N-1:
    q[i], q[i-1] = 1, 1
    ans += 1

print(ans)

Measured memory_bytes: 90096
import math

N, K = map(int, input().split())
prob_sum = 0

for i in range(1, N + 1):
    if i < K:
        target = K / i
        exponent = math.log(target, 2)
        prob = (1 / N) * (1 / 2)**math.ceil(exponent)
        prob_sum += prob
    else:
        prob = 1 / N
        prob_sum += prob
print(prob_sum)

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;
	
	string s, t;
	cin >> s >> t;

	string ans;
	rep(i, n){
		ans.push_back(s[i]);
		ans.push_back(t[i]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {

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

    int n; cin >> n;
    
    double ans = 0;
    for (int i = 0; i < n; i++) {
        double a; cin >> a;
        ans += 1. / a;
    }
    
    printf("%.10f\n", 1. / ans);

    return 0;
}


Measured memory_bytes: 256
/*
 * ALDS1_4_D.cpp
 *
 *  Created on: Apr 27, 2018
 *      Author: 13743
 */
#include<iostream>

using namespace std;

int minP = 99999999;
int maxW = 0;
int n, q;
int w[100000];

void bruteForce(int prev, int k, int maxL) {
	if(k == 0 || prev == n-1) {
		int la = 0;
		for(int i=prev+1; i<n; i++) {
			la += w[i];
		}
		int mi = (la>maxL) ? la : maxL;
		minP = (mi < minP) ? mi : minP;
		return;
	}
	int sum = 0;
	for(int i=prev+1; i<n; i++) {
		sum += w[i];
		if(sum > minP) return;
		if(i < n-1 && (sum+w[i+1] <= maxL)) {
			continue;
		}
		if(i < n-1 && (sum+w[i+1] <= maxW)) {
			continue;
		}
		bruteForce(i, k-1, (sum>maxL) ? sum : maxL);
	}
}

bool greedyPuck(int P) {
	int cnt = 0;
	int lw = 0;
	for(int i=0; i<n; i++) {
		lw += w[i];
		if(lw == P) {
			lw = 0; cnt++;
		}
		else if(lw > P) {
			lw = 0; cnt++; i--;
		}
	}
	if(lw > 0) cnt++;
	if(cnt <= q) return true;
	return false;
}

int main() {
	cin >> n >> q;
	int sum = 0;
	for(int i=0; i<n; i++) {
		cin >> w[i];
		maxW = (w[i] > maxW) ? w[i] : maxW;
		sum += w[i];
	}

//	bruteForce(-1, q-1, 0);
	int l = maxW;
	int r = sum + 1;
	minP = sum;
	while(l < r) {
		int mid = (l + r) / 2;
		if(greedyPuck(mid)) {
			minP = mid;
			r = mid;
		}
		else {
			l = mid + 1;
		}
	}

	cout << minP << endl;
}



Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwe
#define y1 onyetvwe
#define x2 onyette
#define y2 ugmewuben
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int nodes,root=1;
vector <int> node[100005];
int dfs(int now,int par=-1){
	int ret=0;
	for(auto v:node[now])
	{
		if(v==par)
			continue;
		ret^=dfs(v,now)+1;
	}
	return ret;
}
int main()
{
	scan(nodes);
	for(int i=1;i<=nodes-1;i++)
	{
		int u,v;
		scan(u,v);
		node[u].pb(v);
		node[v].pb(u);
	}
	if(dfs(root)==0)
		cout<<"Bob"<<endl;
	else
		cout<<"Alice"<<endl;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


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

ll bit[200010];
ll m = 200010;
void add(int x, ll a) {
	for (int i = x; i <= m; i += i & -i) bit[i] = (bit[i] + a) % MOD;
}
ll sum(ll x) {
	ll ret = 0;
	for (int i = x; i > 0; i -= i & -i) ret += bit[i];
	return ret % MOD;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	vi v(n);
	REP(i, n)cin >> v[i];
	add(1, 1);
	REP(i, n) {
		//REP(j, k)cout << sum(i + 1) << " ";
		//cout << endl;
		RREP(j, k + 1) {
			ll l = max(0ll, j - v[i]);
			//cout << sum(j) << " " << sum(l) << endl;
			ll t = (sum(j) - sum(l) + MOD) % MOD;
			add(j + 1, t);
		}
	}
	cout << (sum(k + 1) - sum(k) + MOD) % MOD << endl;
}

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

int main(){
  ll n, m; cin >> n >> m;
  ll dest = pow(2,m)*((n-m)*100 + m*1900);
  cout << dest;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N;
	cin >> N;
	vector<ll> W(N);
	rep(i, N) cin >> W[i];

	ll ans = 100000;
	rep(i, N) {
		ll a = 0;
		ll b= 0;
		for(ll j = 0; j <= i; j++) {
			a += W[j];
		}
		for(ll j = i + 1; j < N; j++) {
			b += W[j];
		}
		ans = min(ans, abs(a - b));
	}
	cout << ans << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define lli long long int
#define d double
using namespace std;
 
int main() {
	FIO;
	int n;
	cin>>n;
	vector<vector<int>> dp(n,vector<int>(3));
	cin>>dp[0][0]>>dp[0][1]>>dp[0][2];
	for(int i=1;i<n;i++){
		int x,y,z;
		cin>>x>>y>>z;
		dp[i][0]=x+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=y+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=z+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

Measured memory_bytes: 5760
n = int(input())
l = []

for i in range(n):
  a = input()
  l.append(a)

print("AC x " + str(l.count("AC")))
print("WA x " + str(l.count("WA")))
print("TLE x " + str(l.count("TLE")))
print("RE x " + str(l.count("RE")))



Measured memory_bytes: 16164
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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


int a, b;
string s;
bool solve() {
  if(s.length() != a+b+1) return false;
  rep(i, s.length()) {
    if(i == a) {
      if(s[i]!='-') return false;
    }
    else if(!('0'<=s[i] && s[i]<='9')) return false;
  }
  return true;
}

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

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

  return 0;
}

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

using namespace std;
typedef long long ll;
const int N = 310;
string s[N];
int res[N][N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int h, w, k;
  memset(res, 0, sizeof res);
  cin >> h >> w >> k;
  int no = 0;
  vector<pair<int, int>> pos;
  for(int i = 0; i < h; ++i) {
    cin >> s[i];
    for(int j = 0; j < w; ++j) {
      if(s[i][j] == '#') {
        pos.emplace_back(i, j);
        res[i][j] = ++no;
      }
    } 
  }
  for(auto x: pos) {
    int l = x.second - 1, r = x.second + 1;
    int c = res[x.first][x.second];
    while(l >= 0 && res[x.first][l] == 0) {
      res[x.first][l] = c;
      l--;
    }
    while(r < w && res[x.first][r] == 0) {
      res[x.first][r] = c;
      r++;
    }
  }
  for(int i = h - 2; i >= 0; --i) {
    for(int j = 0; j < w; ++j) {
      if(res[i][j] == 0) res[i][j] = res[i + 1][j];
    } 
  }
  for(int i = 1; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      if(res[i][j] == 0) res[i][j] = res[i - 1][j];
    } 
  }
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      assert(res[i][j] != 0);
      cout << res[i][j] << ' ';
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 2036
#include <iostream>
using namespace std;
static const int N = 100;

int main(void)  {
  int M[N][N];
  int n, u, k, v;
  
  cin >> n;
  
  for (int i = 0; i < n; i++)  {
    for (int j = 0; j < n; j ++)  
      M[i][j] = 0;
  }
  
  for (int i = 0; i < n; i++)  {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j ++)  {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  
  for (int i = 0; i < n; i++)  {
    for (int j = 0; j < n; j++)  {
      if (j) 
        cout << " ";
     cout << M[i][j];
    }
    cout << endl;
  }
  return 0;
}
   

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

int T, card[16];

int win();

int main() {
  cin >> T;
  for (int t=0; t<T; ++t) {
    for (int i=0; i<9; ++i) {
      cin >> card[i];
	}
    string color;
    for (int i=0; i<9; ++i) {
      cin >> color;
      if (color == "G") card[i] += 10;
      else if (color == "B") card[i] += 20;
	}
    cout << win() << endl;
  }
  return 0;
}

bool is_same_number(int a, int b, int c) {
  if (a == b && b == c) return true;
  else return false;
}

bool is_sequence(int a, int b, int c) {
  if (a+2 == c && b+1 == c) return true;
  else return false;
}

bool is_good_set(int a, int b, int c) {
  return is_same_number(a, b, c) || is_sequence(a, b, c);
}

bool is_all_good_set() {
  return is_good_set(card[0],card[1],card[2]) && is_good_set(card[3],card[4],card[5]) && is_good_set(card[6],card[7],card[8]);
}

int win() {
  sort(card, card+9);
  do {
      if ( is_all_good_set() )
	return 1;
  } while (next_permutation(card, card+9));
  return 0;
}

Measured memory_bytes: 1224
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <utility>
#include <memory>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
//#include "Othello.h"
using namespace std;
typedef long long int ll; typedef pair <ll, ll> P; typedef vector <int> vecint; typedef pair<int, P> P1; typedef pair<P1, int> P2;
const int inf = 1000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int main()
{
	int n; cin >> n;
	vecint a; a.resize(n);
	rep(i, n)
		cin >> a[i];
	int res = abs(a[0]);
	for (int i = 1; i < n; i++)
		res += abs(a[i] - a[i - 1]);
	res += abs(a[n - 1]);
	if (a[0] * a[1] < 0) cout << res - abs(a[0]) * 2 << endl;
	else if (abs(a[0]) > abs(a[1])) cout << res - (abs(a[0]) - abs(a[1])) * 2 << endl;
	else cout << res << endl;
	for(int i = 1; i < n - 1; i++)
	{
		if (a[i] >= a[i - 1] && a[i + 1] >= a[i])
			cout << res << endl;
		else if (a[i] <= a[i - 1] && a[i + 1] <= a[i])
			cout << res << endl;
		else
		{
			int sub = min(abs(a[i + 1] - a[i]), abs(a[i] - a[i - 1]));
			cout << res - sub * 2 << endl;
		}
	}
	if (n > 1)
	{
		if (a[n - 1] * a[n - 2] < 0)
		{
			cout << res - abs(a[n - 1]) * 2 << endl;
		}
		else if (abs(a[n - 1]) > abs(a[n - 2]))
			cout << res - 2 * (abs(a[n - 1]) - abs(a[n - 2])) << endl;
		else cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
'use strict'

function main(s) {

  s = s.split('\n');

  const w = Number(s[0].split(' ')[1]);

  const top = [...Array(w + 2)].fill('#').join('');
  const mid = s.slice(1, -1).map(n => '#' + n + '#');
  const btm = [...Array(w + 2)].fill('#').join('');

  const ans = [top, ...mid, btm];

  console.log(ans.join('\n'));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append((a,b))
l.sort(key=lambda x:x[1])
tmp=0
for i in range(n):
    tmp+=l[i][0]
    if tmp>l[i][1]:
        print("No")
        exit()
print("Yes")

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

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;

  if (A + B >= C) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int a, b;
	cin >> a >> b;

	if (a > 9 || b > 9) {
		cout << -1 << "\n";
	}
	else {
		cout << a * b << "\n";
	}

}


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

#define MOD 998244353
long long power(long long x, long long y) 
{ 
    long long res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % MOD; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % MOD;  // Change x to x^2 
    } 
    return res; 
}


int main() {
    // oh hi mark
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,a,b; cin >> n >> a >> b;

    if((-a + b) % 2 == 0) {
        cout << (b-a) / 2 << endl;
    }else{
        cout << min( a-1, n - b) + (b - a)/2 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		long A = Integer.parseInt(ST.nextToken()), B = Integer.parseInt(ST.nextToken()), C = Integer.parseInt(ST.nextToken()), X = Integer.parseInt(ST.nextToken()), Y = Integer.parseInt(ST.nextToken());
		//he buys a and b pizzas:
		long costAB = A * X + B * Y;
		long Same = Math.min(X, Y);
		X -= Same; Y -= Same;
		long costCombine = Same * 2 * C + A * X + B * Y;
		long totalCost = Same * 2 * C + Math.max(X, Y) * 2 * C;
		long Best = Math.min(costAB, costCombine);
		Best = Math.min(Best, totalCost);
		System.out.println(Best);
	}
}


Measured memory_bytes: 32724