akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <cstdlib>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void exawizards2019_b(vector<vector<string>> v) {

    int n = atoi(v[0][0].c_str());
    string s = v[1][0];

    int cnt = 0;

    for (int i = 0; i < n; i++) {

        if (s.substr(i, 1) == "R") {
            cnt += 1;
        }
    }


    cout << (cnt * 2 > n ? "Yes" : "No");


}

int main() {

    vector<vector < string>> vec_arr_result;
    //    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata();

    exawizards2019_b(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;

ll dp[2000 + 100][2000 + 100];

int main() {
	ll N; cin >> N;
	vector<pair<int, int>> A(N);
	for (ll i = 0; i < N; i++) {
		cin >> A[i].first;
		A[i].second = i;
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	for (ll x = 0; x < N; x++) {
		for (ll y = 0; y < N; y++) {
			if (x + y >= N)continue;
			ll a = A[x + y].first, i = A[x + y].second;
			dp[x + 1][y] = max(dp[x + 1][y], dp[x][y] + a * (i - x));
			dp[x][y + 1] = max(dp[x][y + 1], dp[x][y] + a * (N - 1 - y - i));
		}
	}
	ll ans = 0;
	for (int x = 0; x <= N; x++) {
		ans = max(ans, dp[x][N - x]);
	}
	cout << ans << endl;
}

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

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

    int mn = *min_element(a.begin(), a.end());
    int mx = *max_element(a.begin(), a.end());

    int ans = 99999999;
    for(int i=mn; i<=mx; ++i){
        int st=0; 
        for(int j=0; j<n; ++j){
            st += (a[j]-i) * (a[j]-i);
        }
        ans = min(ans, st);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3564
n,T=map(int,input().split( ))
ct=[]

for i in range(n):
   ct +=  list(map(int,input().split( )))

c=ct[0::2]
t = ct[1::2]
c_min=[]
for i in range(n):
    if t[i]<=T:
        c_min.append(c[i])


if len(c_min)>0:
    print(min(c_min))
else:
    print('TLE')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

vector<ll> A;

void Primefactor(ll n){
  A = vector<ll>();
  ll a = n;
  for(ll i = 2;i * i <= n;i++){
    while(a % i == 0){
      A.push_back(i);
      a /= i;
    }
    if(a == 1){
      break;
    }
  }
  if(a != 1){
    A.push_back(a);
  }
  return;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> B(110);
  FOR(i,1,N+1){
    Primefactor(i);
    rep(j,A.size()){
      B[A[j]]++;
    }
  }
  ll ans = 0;
  FOR(i,2,110) FOR(j,i+1,110) FOR(k,j+1,110){
    if(B[i] >= 2 && B[j] >= 4 && B[k] >= 4) ans++;
    if(B[i] >= 4 && B[j] >= 4 && B[k] >= 2) ans++;
    if(B[i] >= 4 && B[j] >= 2 && B[k] >= 4) ans++;
  }
  FOR(i,2,110) FOR(j,i+1,110){
    if(B[i] >= 14 && B[j] >= 4) ans++;
    if(B[i] >= 4 && B[j] >= 14) ans++;
  }
  FOR(i,2,110) FOR(j,i+1,110){
    if(B[i] >= 24 && B[j] >= 2) ans++;
    if(B[i] >= 2 && B[j] >= 24) ans++;
  }
  FOR(i,2,110){
    if(B[i] >= 74) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF (1LL << 63)
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef __int128 LL;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

map<LL,int> mp;
int n,m;
vs s;

ostream& operator<<(ostream& os, const LL& v)
{
    if (v == 0) { return (os << "0"); }
    LL num = v;
    if (v < 0) {
        os << '-';
        num = -num;
    }
    string s;
    for (; num > 0; num /= 10) { s.push_back((char)(num % 10) + '0'); }
    reverse(s.begin(), s.end());
    return (os << s);
}

int dfs(int nw,LL p)
{
    if(mp.find(p) != mp.end()) return mp[p];
    int ct = 0;
    rep(i,n){
        if(p >> i & (LL)1){
            ct++;
        }
    }
    if(ct == 1) return 0;
    int res = m+1;
    rep(id,m){
        if(!(nw >> id & 1)){
            LL a = 0, b = 0;
            rep(i,n){
                if(p >> i & (LL)1){
                    if(s[i][id] & 1){
                        a |= (LL)1 << i;
                    }else{
                        b |= (LL)1 << i;
                    }
                }
            }
            if(a != 0 && b != 0){
                cmn(res,max(dfs(nw^(1 << id),a),dfs(nw^(1 << id),b))+1);
            }
        }
    }
    mp[p] = res;
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        cin >> m >> n;
        if(m == 0) break;
        s.resize(n);
        mp.clear();
        rep(i,n){
            cin >> s[i];
        }
        LL hoge = 0;
        rep(i,n){
            hoge |= (LL)1 << i;
        }
        cout << dfs(0,hoge) << "\n";
    }
    return 0;
}



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

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }
};

int main(){
    long int N,M;
    cin >> N >> M;

    UnionFind UF(N);
    rep(i,M) {
        int A,B;
        cin >> A >> B;
        A -= 1;
        B -= 1;
        UF.unite(A,B);
    }

    set<int> Set;
    rep(i,N) {
        Set.insert(UF.root(i));
    }

    cout << Set.size()-1 << endl;

}

Measured memory_bytes: 7488
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,d=0;
  cin>>a;
  int b[a];
  int c[a];
  lp(i,a-1){
    cin>>b[i];
  }
  b[a-1]=INT_MAX;
  d+=b[0];
  lp(i,a-1){
    d+=min(b[i],b[i+1]);
  }
  cout<<d;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
signed main(){
    int n,k;cin>>n>>k;
    vector<int> v;
    rep(i,0,n){
        int a;cin>>a;
        v.ps(a);
    }sort(v.begin(),v.end());
    int mini=inf;
    rep(i,0,n-k+1){
        mini=min(mini,v[i+k-1]-v[i]);
    }cout<<mini<<endl;return 0;
}


Measured memory_bytes: 1400
import math
from fractions import gcd

a, b = map(int, input().split())
cd = set()
ans = set()

'''
g = gcd(a, b)

for i in range(1, g+1):
    if a % i == 0 and b % i == 0:
        cd.add(i)
        '''

i =  1
a_set = set()

for i in range(1, int(math.sqrt(a)) + 1):
    if a % i == 0:
        a_set.add(i)
        a_set.add(a // i)
    i += 1

i = 1
b_set = set()

for i in range(1, int(math.sqrt(b)) + 1):
    if b % i == 0:
        b_set.add(i)
        b_set.add(b // i)
    i += 1

cd = set(a_set) & set(b_set)

for s in sorted(list(cd)):
    if s == 1:
        ans.add(s)
    else:
        for t in sorted(list(ans)):
            if t == 1:
                continue
            elif s % t == 0:
                break
        else:
            ans.add(s)

print(len(ans))


Measured memory_bytes: 7592
from collections import defaultdict, deque

N, M = map(int, input().split())
E = defaultdict(list)
for _ in range(M):
    u, v = map(int, input().split())
    E[u].append(v+N)
    E[u+N].append(v+2*N)
    E[u+2*N].append(v)
S, T = map(int, input().split())
R = [-1 for _ in range(3*N)]
R[S-1] = 0

q = deque()
q.append(S)
while q:
    n = q.popleft()
    if n == T:
        break
    for t in E[n]:
        if R[t-1] < 0:
            R[t-1] = R[n-1] + 1
            q.append(t)
print(-1 if R[T-1] < 0 else R[T-1] // 3)

Measured memory_bytes: 79640
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int a,b;
	cin>>a>>b;
	if(a>0&&b>0){
		cout<<"Positive"<<endl;
	}
	else if(a<=0&&b>=0){
		cout<<"Zero"<<endl;
	}
	else if(a<0&&b<0){
		if(abs(abs(a)-abs(b)+1)%2==0){
			cout<<"Positive"<<endl;
		}
		else {
			cout<<"Negative"<<endl;
		}
	}
	
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }

  val map = mutableMapOf<Int, Int>()
  for (ai in a) {
    val tmp = map.getOrElse(ai) { 0 }
    map.put(ai, tmp + 1)
  }

  val min = a.min()!!
  val max = a.max()!!

  var sumMax = 0
  // var index = min
  for (i in min..max) {
    var sum = map.getOrElse(i) { 0 }
    sum += map.getOrElse(i+1) { 0 }
    sum += map.getOrElse(i+2) { 0 }

    if (sum >= sumMax) {
      sumMax = sum
      // index = i
    }
  }

  println(sumMax)

}


Measured memory_bytes: 62632
class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.TOP = top
        self.BOTTOM = bottom
        self.FRONT = front
        self.BACK = back
        self.LEFT = left
        self.RIGHT = right
    
    def move(self, direction):
        if direction == "N":
            self.move_N()
        elif direction == "E":
            self.move_E()
        elif direction == "S":
            self.move_S()
        elif direction == "W":
            self.move_W()
        elif direction == "SIDE":
            self.move_SIDE()
        else:
            raise Exception
    
    def move_N(self):
        tmp = self.TOP
        self.TOP = self.FRONT
        self.FRONT = self.BOTTOM
        self.BOTTOM = self.BACK
        self.BACK = tmp

    def move_S(self):
        tmp = self.TOP
        self.TOP = self.BACK
        self.BACK = self.BOTTOM
        self.BOTTOM = self.FRONT
        self.FRONT = tmp
        
    def move_W(self):
        tmp = self.TOP
        self.TOP = self.RIGHT
        self.RIGHT = self.BOTTOM
        self.BOTTOM = self.LEFT
        self.LEFT = tmp

    def move_E(self):
        tmp = self.TOP
        self.TOP = self.LEFT
        self.LEFT = self.BOTTOM
        self.BOTTOM = self.RIGHT
        self.RIGHT = tmp
    
    def move_SIDE(self):
        tmp = self.FRONT
        self.FRONT = self.RIGHT
        self.RIGHT = self.BACK
        self.BACK = self.LEFT
        self.LEFT = tmp

def get_right(t, f):
    dice = Dice(top, front, right, left, back, bottom)
    has_top = False
    for _ in range(4):
        dice.move("N")
        if dice.TOP == t:
            has_top = True
            break
    if not has_top:
        for _ in range(4):
            dice.move("E")
            if dice.TOP == t:
                has_top = True
                break
    for _ in range(4):
        dice.move("SIDE")
        if dice.FRONT == f:
            return dice.RIGHT
    
top, front, right, left, back, bottom = map(int,input().split())
dice = Dice(top, front, right, left, back, bottom)
n = int(input())
for _ in range(n):
    t, f = map(int, input().split())
    l = None
    if top == t and front == f:
        r = right
    else:
        r = get_right(t, f)
    print(r)
    


Measured memory_bytes: 5616
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end

exit if $0 != __FILE__

require 'prime'

n, p = cin
pds = Prime.prime_division(p)
x = 1
pds.each do |pd|
  x *= pd[0] ** (pd[1] / n) if pd[1] >= n
end

puts x

Measured memory_bytes: 2428
#include <iostream>
#include <vector>

using namespace std;

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

    if(x==1 || x == 2*N-1){
        cout << "No" << endl;
        return 0;
    }

    if(N==2){
        if(x != 2){
            cout << "No" << endl;
            return 0;
        }else{
            cout << "Yes" << endl;
            cout << 1 << endl;
            cout << 2 << endl;
            cout << 3 << endl;
            return 0;
        }
    }

    vector<int> vec(2*N, -1); // 1-origin
    vector<bool> used(2*N, false); // 1-origin
    if(x==2){
        vec[N-1] = x+1;
        vec[N  ] = x;
        vec[N+1] = x-1;
        vec[N+2] = x+2;
        used[x-1] = true;
        used[x  ] = true;
        used[x+1] = true;
        used[x+2] = true;
    }else{
        vec[N-1] = x-1;
        vec[N  ] = x;
        vec[N+1] = x+1;
        vec[N+2] = x-2;
        used[x-1] = true;
        used[x  ] = true;
        used[x+1] = true;
        used[x-2] = true;

    }

    int j = 1;
    for(int i=1;i<=2*N-1;i++){
        if(vec[i] == -1){
            while(used[j] && j<=2*N-1) j++;
            vec[i] = j;
            used[j] = true;
        }
    }

    cout << "Yes" << endl;
    for(int i=1;i<=2*N-1;i++){
        cout << vec[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
def main():
    n,m = map(int,input().split())
    s = n
    c = m
    scc = 0

    #sを全部使い切る
    take = min(s,c//2) #Sの個数とcを2で割った個数。小さい方を選んでSを使い切る
    scc += take
    s -= take
    c -= take * 2

    #残ったCでsccを作る（s=cが2個　cc=cが2個　合計4個必要）
    take = c // 4
    scc += take

    print(scc)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int A,B,N,sum;
		boolean isTrue = true;
		sum = 0;
		Scanner input = new Scanner(System.in);
		N = input.nextInt();
		A = input.nextInt();
		B = input.nextInt();
		
		for(int i = 0; i <= N; i++) {
			if(i<10 && i>=A && i<=B) {
				sum += i;
			}else {
				int tmp_sum = 0;
				int tmp = i;
				while(tmp!=0) {
					tmp_sum += tmp%10;
					tmp/=10;
				}
				if(tmp_sum>=A && tmp_sum<=B) {
					sum += i;
				}
			}
		}		
		System.out.println(sum);
	}

}


Measured memory_bytes: 23124
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}
template <class T>
inline string toString(T x)
{
	ostringstream sout;
	sout << x;
	return sout.str();
}

//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
					  << " " << __FILE__ << endl;

int main(void)
{
	int n;
	VI a;
	cin >> n;
	REP(i,n){
		int v = 0;
		cin >> v;
		a.push_back(v);
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	cout << a.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, L, A[200001];
	scanf("%d", &L);
	for (i = 1; i <= L; i++) scanf("%d", &(A[i]));
	
	int j;
	const long long sup = (long long)1 << 60;
	long long dp[2][5], tmp[5];
	for (j = 0; j < 5; j++) dp[0][j] = 0;
	for (i = 1; i <= L; i++) {
		for (j = 1; j < 5; j++) if (dp[1-i%2][j-1] < dp[1-i%2][j]) dp[1-i%2][j] = dp[1-i%2][j-1];
		dp[i%2][0] = dp[1-i%2][0] + A[i];
		dp[i%2][1] = dp[1-i%2][1] + ((A[i] == 0)? 2: A[i] % 2);
		dp[i%2][2] = dp[1-i%2][2] + 1 - A[i] % 2;
		dp[i%2][3] = dp[1-i%2][3] + ((A[i] == 0)? 2: A[i] % 2);
		dp[i%2][4] = dp[1-i%2][4] + A[i];
	}
	
	long long min = sup;
	for (j = 0; j < 5; j++) if (dp[1-i%2][j] < min) min = dp[1-i%2][j];
	printf("%lld\n", min);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2468
#include<bits/stdc++.h>
using namespace std;
int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int x=tx-sx;
  int y=ty-sy;
  string f;
  string b;
  for(int i=0;i<x;i++){
    f+='R';
    b+='L';
  }
  for(int i=0;i<y;i++){
    f+='U';
    b+='D';
  }
  cout<<f<<b<<"DR"<<f<<"ULUL"<<b<<"DR"<<endl;
}

Measured memory_bytes: 256
// ABC155
// a.cs

using System;

class A
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');

        int A = int.Parse(str[0]);
        int B = int.Parse(str[1]);
        int C = int.Parse(str[2]);

        if (A == B && B != C)
        {
            Console.WriteLine("Yes");
        }
        else if (B == C && C != A)
        {
            Console.WriteLine("Yes");
        }
        else if (C == A && A != B)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
n,m=input().split()
h_list = list(map(int,input().split()))
result =[]
count = 0
for i in range(int(n)):
    result.append(True)
for i in range(int(m)):
    temp1,temp2=input().split()
    if h_list[int(temp1)-1] < h_list[int(temp2)-1]:
        result[int(temp1)-1] = False
    elif h_list[int(temp1)-1] == h_list[int(temp2)-1]:
        result[int(temp1) - 1] = False
        result[int(temp2) - 1] = False
    else:
        result[int(temp2)-1] = False
for i in range(int(n)):
    if(result[i]==True):
        count += 1
    else:
        pass
print(count)

Measured memory_bytes: 20056
t1, n1 = map(int,input().split())
t2, n2 = map(int,input().split())
t3, n3 = map(int,input().split())
t4, n4 = map(int,input().split())
def f(x,y):
    if x == 1 :
        print(int(6000*y))
    if x == 2 :
        print(int(4000*y))
    if x == 3 :
        print(int(3000*y))
    if x == 4 :
        print(int(2000*y))
f(t1,n1)
f(t2,n2)
f(t3,n3)
f(t4,n4)


Measured memory_bytes: 5596
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 


int main(){
    int n,m;
    cin>>n>>m;

    int cnt[100]={};
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int a;
            cin>>a;
            cnt[a]++;
        }
    }

    int res=0;
    for(int i=0;i<100;i++){
        res+=(cnt[i]==n);
    }

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
/*
Problem Source : agc-034F
Author : oier_hzy
Time : Nov 24 2019
*/

/*
f[i]: i -> 0
f[0] = 0
f[i] = 1 + ∑ f[j] * p[i^j]
<f> * <p> = <?, f[i] - 1>

∑<p> = 1, so ∑<f> = ∑<?, f[i] - 1>
? = f[0] + 2^n - 1;

<f> * <p> = <f[0] + 2^n - 1, f[i] - 1>
<f> * <p[0] - 1, p[i]> = <2^n - 1, -1, -1, ...>

ifwt

square up : ? * 0 = 0
? = 0 / 0 is not feasible

but we know that f[0] = 0, so not to consider the issue, calculate a[0]' out
then modify <f> to eliminate the bias to make a[0] = 0
*/

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

template <typename _tp> inline void read(_tp&x) {
	char ch = getchar(), sgn = 0; x = 0;
	while(ch != '-' and !isdigit(ch)) ch = getchar(); if(ch == '-') ch = getchar(), sgn = 1;
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); if(sgn) x = -x;
}

const int mod = 998244353, inv2 = mod + 1 >> 1;

inline int qm(const int x) {return x < mod ? x : x - mod;}
inline int qpow(int A, int B) {
	int r = 1;
	for(; B; A = (ll)A * A%mod, B >>= 1)
		if(B&1) r = (ll)r * A%mod;
	return r;
}

void fwt(int*a, int n) {
	for(int i = 1; i < n; i <<= 1)
	for(int j = 0; j < n; j += (i << 1))
	for(int k = 0; k < i; ++ k) {
		const int x = a[j+k], y = a[j+k+i];
		a[j+k] = qm(x + y), a[j+k+i] = qm(x - y+mod);
	}
}

void ifwt(int*a, int n) {
	for(int i = 1; i < n; i <<= 1)
	for(int j = 0; j < n; j += (i << 1))
	for(int k = 0; k < i; ++ k) {
		const int x = a[j+k], y = a[j+k+i];
		a[j+k] = (ll)qm(x + y) * inv2%mod;
		a[j+k+i] = (ll)qm(x - y+mod) * inv2%mod;
	}
}

const int N = 1 << 18 | 3;
int p[N], f[N];
int n;

int main() {
	read(n), n = 1 << n;
	int sum = 0;
	for(int i = 0; i < n; ++ i) read(p[i]), sum += p[i];
	sum = qpow(sum, mod-2);
	for(int i = 0; i < n; ++ i) p[i] = (ll)p[i] * sum%mod;
	p[0] = qm(p[0] - 1+mod);
	
	for(int i = 1; i < n; ++ i) f[i] = mod - 1;
	f[0] = n - 1;
	
	fwt(f, n), fwt(p, n);
	for(int i = 0; i < n; ++ i) f[i] = (ll)f[i] * qpow(p[i], mod-2)%mod;
	ifwt(f, n);
	
	if(f[0]) {
		int bias = (ll)(mod - f[0]) * n%mod;
		fwt(f, n);
		for(int i = 0; i < n; ++ i)
			if(!p[i]) {
				f[i] = bias;
				break;
			}
		ifwt(f, n);
	}
	
	for(int i = 0; i < n; ++ i)
		printf("%d\n", f[i]);
	return 0;
}

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

int main(){
  string S ;
  string a,b,c ;
  a = "Sunny" ;
  b = "Cloudy" ;
  c = "Rainy" ;
  
  cin >> S ;
  
  if(S == a) cout << b ;
  else if(S == b) cout << c;
  else if(S == c) cout << a ;
  
  
}

Measured memory_bytes: 888
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin >> x;
  if (x == 7 || x == 5 || x == 3)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
solve :: [Int] -> [Int]
solve (n:as) = 
    take n $ zipWith (+) res1 res2
    where 
        func1 s a = (-1) * s + a    
        res1 = scanl func1 0 as
        func2 a s = (-1) * s + a    
        res2 = scanr func2 0 as

main = interact $ unwords.map show.solve.map read.words




Measured memory_bytes: 75900
#include<bits/stdc++.h>
#define rep(i, x, y) for (int i = (x); i <= (y); i ++)
#define down(i, x, y) for (int i = (x); i >= (y); i --)
#define mid ((l+r)/2)
#define lc (o<<1)
#define rc (o<<1|1)
#define pb push_back
#define mp make_pair
#define PII pair<int, int>
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long LL;
//head

const int N = 55;
int n;
LL a[N], opt[N<<1][2];

int main()
{
	scanf("%d", &n);
	int mx = 1, mi = 1, cnt = 0;
	rep(i, 1, n){
		scanf("%lld", &a[i]);
		if (a[i] < a[mi]) mi = i;
		if (a[i] > a[mx]) mx = i;
	}
	if (abs(a[mi]) > abs(a[mx])){
		down(i, n-1, 1)
			while (a[i] > a[i+1]){
				a[i] += a[mi];
				opt[++ cnt][0] = mi; opt[cnt][1] = i;
				if (a[i] < a[mi]) mi = i;
			}
	} else {
		rep(i, 1, n-1)
			while (a[i] > a[i+1]){
				a[i+1] += a[mx];
				opt[++ cnt][0] = mx; opt[cnt][1] = i+1;
				if (a[i+1] > a[mx]) mx = i+1;
			}
	} printf("%d\n", cnt);
	rep(i, 1, cnt) printf("%d %d\n", opt[i][0], opt[i][1]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

ll gcd(ll a, ll b) {
	ll temp;
	while (a % b != 0)
	{
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int k;
	cin >> k;
	string s;
	cin >> s;

	if (s[k - 1] == 'A') {
		s[k - 1] = 'a';
	}
	else if (s[k - 1] == 'B') {
		s[k - 1] = 'b';
	}
	else {
		s[k - 1] = 'c';
	}
	cout << s << endl;

	return 0;
}



Measured memory_bytes: 256
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;

int main()
{
    std::ios::sync_with_stdio(false);
    LL a,b;
    char ch;
    cin >> a >> ch >> b;
    if(ch=='+') cout << a+b << endl;
    else cout << a-b << endl;
    //system("pause");
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

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

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] >= k) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 1
 * All of them are independent and the last state only matters
 * If we have only 2 states we should try fixing the button as the 2nd state
 * Say if we have 3 states
 * 1 3 10 -> 10
 * 1 3 4 -> 3
 * 2 4 9 . 3 5 8 9 . 1 2 7
 * We'll traverse the sequence and if cur > prev
 * 1 2 3 4 5 6 7 8
 * - 1 - - 1
 * add 1 to c[prev + 1] and -1 to c[cur + 1] and -(cur - prev) to A[cur + 1]
 * if cur < prev
 * add 1 to c[prev + 1] and add (m - prev + 1) to A[1] 
 * and 1 to c[1] and -1 to c[cur + 1] and -dist(prev, cur) to A[cur + 1]
 */
int main() {
	int n, m;
	cin >> n >> m;
	int prev = -1;
	vector <ll> A(m + 2), c(m + 2);
	ll total = 0;
	for (int i = 1; i <= n; i++) {
		int cur;
		cin >> cur;
		if (i > 1) {
			if (cur > prev) {
				c[prev + 1] += 1;
				c[cur + 1] -= 1;
				A[cur + 1] -= (cur - prev);
				total += (cur - prev);
			}
			else {
				c[prev + 1] += 1;
				A[1] += (m - prev);
				c[1] += 1;
				c[cur + 1] -= 1;
				A[cur + 1] -= (m - prev) + cur;
				total += (m - prev) + cur;
			}
		}
		prev = cur; 
	}
	for (int i = 1; i <= m; i++) {
		c[i] += c[i - 1];
		A[i] += (A[i - 1] + c[i]);
		//cout << A[i] << " ";
	}
	ll mx = 0;
	for (int i = 1; i <= m; i++) {
		mx = max(mx, A[i] - c[i]);
	}
	cout << total - mx;
}


Measured memory_bytes: 1792
import java.util.*;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int length = sc.nextInt();
      String string1 = sc.next();
      String string2 = sc.next();
      char[] moji1 = new char[length];
      char[] moji2 = new char[length];
      moji1 = string1.toCharArray();
      moji2 = string2.toCharArray();

      String result = "";

      for (int i=0; i < length; i++){
        result = result + moji1[i] + moji2[i];
      }
      System.out.println(result);
    }
}

Measured memory_bytes: 22740
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-18 03:46:57
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

constexpr int INF = 1e9;

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

  int n; cin >> n;
  vector<int> cnt(26, INF);

  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    map<int, int> mp;
    for (char c : s) {
      ++mp[c - 'a'];
    }
    for (int j = 0; j < 26; ++j) {
      cnt[j] = min(cnt[j], mp[j]);
    }
  }

  debug(cnt);

  string ans = "";
  for (int i = 0; i < 26; ++i) {
    if (cnt[i] == INF) continue;
    for (int j = 0; j < cnt[i]; ++j) {
      ans += (char)(i + 'a');
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if(b == 1)
  {
    cout << 0;
    return 0;
  }
  int sum = 0;
  int cnt = 0;
  while(sum < b)
  {
    if(sum)
      sum--;
    sum += a;
    cnt++;
  }
  cout << cnt;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

ll n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  cin >> n >> m;
  if (n < 0 && m > 0) cout << "Zero";
  if (n < 0 && m < 0 && ((m - n) + 1) % 2 != 0) cout << "Negative";
  if (n < 0 && m < 0 && ((m - n) + 1) % 2 == 0) cout << "Positive";
  if (n > 0 && m > 0) cout << "Positive";

  return 0;
}



Measured memory_bytes: 3572
L = [int(input()) for i in range(5)]
longmenuindex=0
for i in range(len(L)):
    if(L[i]%10<L[longmenuindex]%10 and L[i]%10!=0):
        longmenuindex = i
time=0
for i in range(len(L)):
    if(i != longmenuindex):
        if(L[i]%10!=0):
            time += (L[i]+(10-L[i]%10))
        else:
            time += L[i]
print(time+L[longmenuindex])


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int arr[n][3];
    
    for(int i=0;i<n;i++)
        cin>>arr[i][0],cin>>arr[i][1],cin>>arr[i][2];
    
    int dp[3];
    int m[3];
    
    dp[0] = arr[0][0];
    dp[1] = arr[0][1];
    dp[2] = arr[0][2];
    
    
    for(int i=1;i<n;i++)
    {
        memset(m,0,sizeof(m));
        
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                m[j] = arr[i][j] + max(dp[1],dp[2]);
            }
            
            if(j==1)
            {
                m[j] = arr[i][j] + max(dp[0],dp[2]);
            }
            
            if(j==2)
            {
                m[j] = arr[i][j] + max(dp[1],dp[0]);
            }
        }
        
        for(int i=0;i<3;i++)
            dp[i] = m[i];
    }
    
    int tot = 0;
    tot = max(dp[0],max(dp[1],dp[2]));
    
    cout<<tot;
    
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
#endif

  ll n,m;
  cin>>n>>m;
  vector<ll> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    a[i]=a[i]/2;
  }

  ll lcm=a[0];

  ll prev;

  for(int i=1;i<n;i++)
  {
    prev=lcm;
    lcm=(lcm*a[i])/(__gcd(lcm,a[i]));
    if(lcm<prev)
    {
      cout<<0<<endl;
      return 0;
    }
    if((lcm/a[i])%2==0)
    {
      cout<<0<<endl;
      return 0;
    }

  }




  ll ans=(m/(lcm));

  long double div=2;

  ans=ceil(ans/div);

  cout<<ans;
  
  

  return 0;
}

Measured memory_bytes: 3976
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeSearch(Node u, int k){
  while(u != NIL && u->key != k){
  if( u->key > k)u = u->left;
  else u = u->right;
  }
  return u;
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right;
  }
 
  z->parent = y;
  if(y == NIL) {
    root = z;  
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else y->right = z;
}
 
 
void inorder(Node u){
  if(u->left != NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right != NIL){
    inorder(u->right);
  }
 
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!= NIL){
    preorder(u->left);
  }
  if(u->right!= NIL){
    preorder(u->right);
  }
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }
  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 1000001;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =  1e9+7;

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

int n,l;
cin>>n>>l;
int arr[n];
int sum=0;
int x=INT_MAX;
bool b=false;
rep(i,0,n)
{
	arr[i]=l+i;
	if(abs(arr[i])<x)
	{
		x=(abs(arr[i]));
		if(arr[i]<0)
		b=true;
	}
	sum+=arr[i];
}
if(b==true)
{
	cout<<sum+x;
}
else
cout<<sum-x;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  ll katamari = 1;
  ll ans = 0;
  ll j = 0;
  for(ll i=1;i<N;i++){
    if(S[i-1] == S[i]){
      j++;
    }else{
      katamari++;
      ans += j;
      j=0;
    }
  }
  ans += j;
  //cout << katamari << "," << ans << endl;
  if(katamari/2 <= K) cout << N-1;
  else cout << ans + 2*K;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}
 
int main() {
 int64_t L,R;
 cin>>L>>R;
 int a=min(R,L+4038);
 int ans=2018;
 for(int64_t i=L;i<=a;i++){
   for(int64_t j=i+1;j<=a;j++){
     int x=i*j%2019;
     ans=min(x,ans);
   }
 }
 cout<<ans<<endl;
 return 0;
}

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

int main()
{
	int A[100];
	int N,j,v;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}

	for (int i = 0; i < N; ++i)
	{
		if (i != N-1)
		{
			cout << A[i] << " ";
		}
		else
		{
			cout << A[i] << "\n";
		}
	}
	for (int i = 1; i < N; ++i)
	{
		v = A[i];
		j = i-1;
		while((j >= 0)&&(A[j] > v))
		{
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;

		for (int o = 0; o < N; ++o)
		{
			if (o != N-1)
			{
				cout << A[o] << " ";
			}
			else
			{
				cout << A[o] << "\n";
			}
		}

	}
	return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int get_similarities(vector<int> &occs_a, vector<int> &occs_b) {
	int c = 0;
	for (int i = 0; i < 26; ++i) {
		if (occs_b[i] && occs_a[i]) {
			++c;
		}
	}

	return c;
}

int main() {

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	vector<int> occs_a(26), occs_b(26);
	++occs_a[s[0] - 'a'];
	for (int i = 1; i < n; ++i) {
		++occs_b[s[i] - 'a'];
	} 

	int largest = get_similarities(occs_a, occs_b);
	for (int i = 1; i < n - 1; ++i) {
		++occs_a[s[i] - 'a'];
		--occs_b[s[i] - 'a'];
		largest = max(largest, get_similarities(occs_a, occs_b));
	}

	cout << largest << "\n";

	return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		char[] line = scanner.next().toCharArray();

		Deque<Character> q = new ArrayDeque<Character>();

		for (int i = 0; i < line.length; i++) {
			if (line[i] == '0') {
				q.addLast('0');
			} else if(line[i] == '1'){
				q.addLast('1');
			} else if(line[i] == 'B'){
				if (q.size() != 0) {
					q.removeLast();
				} 
			}
		}

		for (Character character : q) {
			System.out.print(character);
		}

		System.out.println();

		scanner.close();
	}

}


Measured memory_bytes: 27016
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 4 * 1e18;
/* -- template -- */
int cnt[100001];
int main() {
    int N; cin >> N;
    int a;rep(i, N){
        cin >> a;
        if(a - 1 >= 0)
            ++cnt[a - 1];
        ++cnt[a];
        if(a + 1 <= 100000)
            ++cnt[a + 1];
    }
    int maxv = 0;
    rep(i, 100001)
        maxv = max(maxv, cnt[i]);
    cout << maxv << endl;
}


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

int main() {
  int x,t;
  cin>>x>>t;
  if(x>=t)cout <<x-t<<endl;
  else cout<<0<<endl;
  return 0;  
    

}


Measured memory_bytes: 256