akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n;
    cin >> n;
    vector<double> p(n);
    rep(i, n){
        cin >> p[i];
    }

    vector<vector<double> > dp(n+1, vector<double>(n+1));
    dp[0][0] = 1;
    rep2(i, 1, n+1){
        rep(j, i+1){
            dp[i][j] = dp[i-1][j] * (1-p[i-1]) + dp[i-1][j-1] * p[i-1];
        }
    }

    double ans = 0;
    rep2(i, n/2+1, n+1){
        ans += dp[n][i];
    }

    printf("%.10lf\n", ans);
    
    return 0;
}


Measured memory_bytes: 71040
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    int n, m;
    cin >> n >> m;
    using tpl = tuple<int, int, int>;
    vector<tpl> x(m + 1);
    x[0] = tpl(-1, -1, -1);
    vector<P> number(m);
    rep(i, m) {
        int p, y;
        cin >> p >> y;
        x.at(i + 1) = tpl(p, y, i);
    }
    sort(x.begin(), x.end());
    
    int num = 1;
    rep(i, m) {
        int p, y, nm;
        tie(p, y, nm) = x.at(i + 1);
        if (get<0>(x.at(i)) != p) num = 1;
        else num++;
        number.at(nm) = P(p, num);
    }
    
    rep(i, m) {
        int p = number.at(i).first, nm = number.at(i).second;
        printf("%06d%06d\n", p, nm);
    }
}

Measured memory_bytes: 3456
N, M, X = map(int, input().split())
A = []
for i in range(N):
  A.append(list(map(int, input().split())))
min = -1
for i in range(1, 2**N):
  x = []
  for j in range(M):
    x.append(0)
  c = 0
  chk = True
  for j in range(N):
    b = bin(i & 2**j)
    if b[2] == "1":
      c += A[j][0]
      for k in range(M):
        x[k] += A[j][k+1]
  for l in range(M):
    if x[l] < X:
      chk = False
      break
  if chk == False:
    continue
  if min == -1:
    min = c
  elif c < min:
    min = c
print(min)

Measured memory_bytes: 9244
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

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

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"####"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    string s;

    cin>>s;
    n = s.size()-1;
    if(s[n]=='3') cout<<"bon"<<NL;
    else if(s[n]=='0' || s[n]=='1' || s[n]=='6' || s[n]=='8'){
    	cout<<"pon"<<NL;
    }
    else{
    	cout<<"hon"<<NL;
    }
    


    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

ll a[101010] = {0};

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    scn(n, a);
    //a[n] = 0;
    ll res = a[0] / 2, now = a[0] % 2;
    rep1(i, n){
      if(a[i] == 0){
        now = 0;
      }else{
        a[i] += now;
        now = 0;
        res += a[i] / 2;
        now = a[i] % 2;
      }
      //pri2(i, res);
    }
    pri(res);


/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <vector> 
using namespace std;

int main()
{
	char a,b,c;
	scanf("%c%c%c",&a,&b,&c);
	if(a==c) printf("H\n");
	else printf("D\n");
}

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

int main() {
    int n,k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end(), greater<int>());
    lint ans = 0;
    for (int i=k; i<n; i++) {
        ans += h[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4044
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean j = true;
		String a[] = new String[n];

		for(int i=0;i<n;i++) {
			a[i] = sc.next();
			for(int k=0;k<i;k++) {
				if(a[i].equals(a[k])) {
					j = false;
				}
			}
		}

		int t=0;
		String s;

		for(int i=0;i<n-1;i++) {
			t=a[i].length();
			s = a[i].substring(t-1, t);
			if(s.equals(a[i+1].substring(0, 1))) {

			}else {
				j = false;
			}
		}

		if(j) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}




	}
}

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

using namespace std;

int main() {
    long long n;
    cin >> n;
    int a[n]; 

    for (int  i = 0; i < n; i++){ 
        cin >> a[i];
        if (a[i] % 2 == 0){
            //cout << a[i] << endl;
            
            if ((a[i] % 3 !=0) && (a[i] % 5 !=0)) {
                cout << "DENIED" << endl;
                return 0;
            }

        }
    }
    cout << "APPROVED" << endl;
    //sort(a, a+n);
    /*
    for (int i = 0; i < n-1; i++){
        //cout << a[i] << a[i+1] << "\n";
        if (a[i+1] == a[i]){
            //cout << "No" << "\n";
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    */

    
    return 0;
}


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

int main() {
    string S, T;
    cin >> S;
    cin >> T;
    int lenS = S.size();
    int lenT = T.size();

    int ans = -1;
    for (int i=0; i<(lenS - lenT + 1); ++i) {
        string cand = S.substr(i, i+lenT);
        bool can = true;
        for (int t=0; t<lenT; ++t) {
            if (T[t] != cand[t] && cand[t] != '?') {
                can = false;
                break;
            } 
        }
        if (can) ans = i;
    }
    if (ans < 0) cout << "UNRESTORABLE" << endl;
    else {
        for (int i=0; i<lenS; ++i) {
            if (i >= ans && i<ans+lenT) cout << T[i-ans];
            else if (S[i] == '?') cout << 'a';
            else cout << S[i];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n=input()
n=int(n)
z=map(int,input().split())
z=list(z)
def cost(a,b):
    c=0
    for i in range(n):
        c=c+(b[i]-a)**2
    return c
l=[]
for i in range(min(z),max(z)+1):
    l.append(cost(i,z))
print(min(l))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define SANKOU(n, a, b) cout << ((n) ? (#a) : (#b)) << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
//#define S set<int>

int N, S[200010];

void solve()
{
    int ans = INF;
    int l = 0;
    int r = 0;
    FOR(i, 0, N)
    {
        r += !S[i];
    }
    S[N + 1] = 1;
    FOR(i, 0, N + 1)
    {
        int a = l + r;
        ans = min(ans, a);
        l += S[i];
        r -= !S[i];
    }
    cout << ans << endl;
}

signed main()
{
    cin >> N;
    FOR(i, 0, N)
    {
        char x;
        cin >> x;
        if (x == '#')
            S[i]++;
    }
    solve();
    return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string s, t;
    cin >> s >> t;
    t.pop_back();
    cout << (s == t ? "Yes" : "No") << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3612
N = int(input())
S = [input() for i in range(N)]

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

condition = lambda maxium: lambda item: item[1] == maximum
answer = filter(condition(maximum), table.items())
answer = dict(answer)
answer = list(answer.keys())
answer.sort()
answer = "\n".join(answer)

print(answer)


Measured memory_bytes: 53516
def insert(arr, key)
  $h += 1
  arr[$h] = - 1.0/0
  heap_increase_key(arr, $h, key)
end

def heap_increase_key(arr, i, key)
  if key < arr[i]
    raise "NEW_KEY_SMALLER_THAN_CURRENT_KEY"
  end
  arr[i] = key
  while i > 1 && arr[parent(i)] < arr[i] do
    arr[i], arr[parent(i)] = arr[parent(i)], arr[i]
    i = parent(i)
  end
end

def heap_extract_max(arr)
  if $h < 1
    raise "HEAP_UNDERFLOW"
  end
  max = arr[1]
  arr[1] = arr.pop
  $h -= 1
  max_heapify(arr, 1)
  max
end

def parent(i)
  ( i / 2 ).ceil
end

def right(i)
  2 * i + 1
end

def left(i)
  2 * i
end

def max_heapify(arr, i)
  l = left(i)
  r = right(i)
  h = arr.size - 1

  # puts "i : #{i}, l : #{l}, r : #{r}, h : #{h} arr[r] : #{arr[r]}, arr : #{arr}"

  largest = nil
  if l <= h && arr[l] > arr[i]
    largest = l
  else
    largest = i
  end
  if r <= h && arr[r] > arr[largest]
    largest = r
  end

  if largest != i
    arr[i], arr[largest] = arr[largest], arr[i]
    max_heapify(arr, largest)
  end
end

$h = 0
arr = [nil]
while true do
  order, key = gets.split
  key = key.to_i
  case order
  when "end"
    break
  when "insert"
    insert(arr, key)
  when "extract"
    max = heap_extract_max(arr)
    puts max
  end
  # puts "array : #{arr.join(' ')}"
end


Measured memory_bytes: 16396
#include <iostream>
using namespace std;
int main(void){
    int day[100] = {0};
    int n, q;
    while (cin >> n >> q && n) {
        fill(day, day + 100, 0);
        for (int i = 0; i < n; ++i) {
            int m;
            cin >> m;
            for (int j = 0; j < m; ++j) {
                int d;
                cin >> d;
                ++day[d];
            }
        }
        int date = 0, menbers = 0;
        for (int i = 0; i < 100; ++i) {
            if (day[i] >= q && day[i] > menbers) {
                menbers = day[i];
                date = i;
            }
        }
        cout << date << endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define il inline
#define rg register
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define rep(i,st,ed) for(rg int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(rg int i=(ed);i>=(st);--i)
#define rep0(i,n) for(rg int i=0;i<(n);++i)
#define per0(i,n) for(rg int i=(n)-1;i>=0;--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &x,const T &y){return x<y?x:y;}
template<typename T> il T qmax(const T &x,const T &y){return x>y?x:y;}
template<typename T> il void getmin(T &x,const T &y){if(y<x) x=y;}
template<typename T> il void getmax(T &x,const T &y){if(y>x) x=y;}
il void fileio(const string &s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e18+7;
const int N=16;
const int mod=(int)1e9+7;

int a[N],g[1<<N],f[N][1<<N],n,m;
ll fac[1<<N],inv[1<<N];

il void inc(int &x,const int &y){
	if((x+=y)>=mod) x-=mod;
}

il void dec(int &x,const int &y){
	if((x-=y)<0) x+=mod;
}

il ll qpow(ll x,int y){
	ll ans=1;
	while(y){
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return ans;
}

il ll C(const int &n,const int &k){
	if(k>n) return 0;
	return fac[n]*inv[k]%mod*inv[n-k]%mod;
}

int main(){
//	fileio("test");
	fac[0]=1,inv[0]=1;
	rep(i,1,(1<<N)-1){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=qpow(fac[i],mod-2);
	}
	scanf("%d%d",&n,&m);
	int all=(1<<n)-1;
	rep0(i,m) scanf("%d",a+i);
	f[m][0]=1;
	per0(i,m){
		rep0(comb,1<<n){
			int &cur=f[i][comb];
			cur=f[i+1][comb];
			rep0(j,n) if(comb>>j&1){
				inc(cur,C((1<<n)-a[i]-comb+(1<<j),(1<<j)-1)*f[i+1][comb^(1<<j)]%mod);
			}
		}
	}
	rep0(comb,1<<n){
		ll cur=fac[all-comb]*f[0][comb]%mod;
		for(int i=comb;i;i^=i&-i) cur=cur*fac[i&-i]%mod;
		g[comb]=cur;
	}
	int ans=0;
	rep0(i,1<<n){
		if(__builtin_popcount(i)&1) dec(ans,g[i]);
		else inc(ans,g[i]);
	}
	printf("%d\n",(1ll<<n)*ans%mod);
	return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static const long long MOD_NUM = 1000000007LL;

static void C_task();

int main()
{
	C_task();
	fflush(stdout);
	return 0;
}

static void C_task()
{
	int N, K;
	get2int(N, K);

	std::vector<LLONG> enemy(N, 0);
	for (int i = 0; i < N; i++) {
		LLONG tmp;
		get1int<LLONG>(tmp);
		enemy[i] = tmp;
	}

	std::sort(enemy.begin(), enemy.end(), std::greater<LLONG>());

	LLONG cnt = 0;
	for (int i = K; i < N; i++) {
		cnt += enemy[i];
	}
	printf("%lld\n", cnt);
}


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

#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;

template <class T>
inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int hoge[3] = {1, 6, 9};
    vector<int> dp(N + 1, INT_MAX);
    dp[0] = 0;
    for(int i = 0; i <= N; i++) {
        // cout << "from " << i << endl;
        for(int j = 0; j < 3; j++) {
            int k = 1;
            while((i + int(pow(hoge[j], k)) <= N) && !(j == 0 && k == 2)) {
                // cout << "using " << hoge[j] << "^" << k << "=" << pow(hoge[j], k) << endl;
                if(i + pow(hoge[j], k) == N) {
                    // cout << "to " << i + pow(hoge[j], k) << " ... " << dp[i + pow(hoge[j], k)] << "vs " << dp[i] << "+" << 1 << "=" << dp[i] + 1 << endl;
                }
                chmin(dp[i + pow(hoge[j], k)], dp[i] + 1);
                k++;
            }
        }
    }
    // for(int i = 0; i <= N; i++) {
    // cout << i << ":" << dp[i] << endl;
    // }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 4084
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
//set<int, Comparator> S;

struct Vec{
    double v[2];
    string to_s(){
        return "("+to_string(v[0])+","+to_string(v[1])+")";
    }
    double& operator[](int t){
        return v[t];
    }
    Vec operator+(Vec t) {
        return {v[0]+t[0],v[1]+t[1]};
    }
    Vec& operator+=(Vec t) {
        v[0]+=t[0];v[1]+=t[1];
        return *this;
    }
    Vec operator-(Vec t) {
        return {v[0]-t[0],v[1]-t[1]};
    }
    Vec& operator-=(Vec t) {
        v[0]-=t[0];v[1]-=t[1];
        return *this;
    }
    Vec operator*(double t) {
        return {v[0]*t,v[1]*t};
    }
    Vec& operator*=(double t) {
        v[0]*=t;v[1]*=t;
        return *this;
    }
    double operator*(Vec t) {
        return v[0]*t[0]+v[1]*t[1];
    }
    Vec operator-(){
        return {-v[0],-v[1]};
    }
    static Vec Z;
};
Vec Vec::Z={0,0};

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef vector<P> VP;
typedef pair<ll,ll> RP;
int main() {
    ll H,W,N;
    cin >> H >> W>> N;
    cout << (N+max(H,W)-1)/max(H,W)  << endl;

    return 0;
}


Measured memory_bytes: 256
S = input()
P = list(set(S))
ANS = []
for i in range(len(P)) :
    T = list(S.split(P[i]))
    U = []
    for j in range(len(T)) :
        U.append(len(T[j]))
    ANS.append(max(U))
print(min(ANS))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

#define NUM 1000000
bool prime[NUM];

int main()
{
	REP(i, NUM)
	{
		prime[i] = true;
	}
	prime[0] = prime[1] = false;
	for (ll i = 2; i * i < NUM; i++) {
		if (prime[i]) {
			for (ll j = 2; i * j < NUM; j++) {
				prime[i*j] = false;
			}
		}
	}

	vi P;
	FOR(i, 2, NUM)
	{
		if (prime[i]) {
			P.push_back(i);
		}
	}

	while (1) {
		ll p;
		cin >> n >> p;
		if (n == -1 && p == -1) {
			return 0;
		} else {
			ll index = 0;
			REP(i, P.size())
			{
				if (n < P[i]) {
					index = i;
					break;
				}
			}
			vi Q;
			REP(i, p + 1)
			{
				FOR(j, i, p + 1)
				{
					Q.push_back(P[index + i] + P[index + j]);
				}
			}
			sort(ALL(Q));
			cout << Q[p - 1] << endl;
		}
	}
}

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

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

using namespace std;

int main() {
	int N;
	int64_t K;

	vector<int> A;

	cin >> N >> K;

	rep(i, N) {
		int a;
		cin >> a;
		A.push_back(a-1);
	}

	vector<bool> f(N, false);
	int step = 0;
	int P =0;//roopする町
	f[0] = true;
	for (; step < K; step++)
	{
		P = A[P];
		if (f[P])break;
		f[P] = true;
		if (step == K -1) {
			cout << P+1;
			return 0;
		}
	}
	step++;

	int p = P;
	int ropN = 1;//いくつでループするか
	for (; ropN < N; ropN++) {

		p = A[p];
		if (p == P)break;
	}

	int ans = 0;
	if (step > K) {

		for (int i = 0; i < K; i++)
		{
			ans = A[ans];
		}
	}
	else {
		ans = P;
		for (int i = 0; i < (K-step)%ropN; i++)
		{
			ans = A[ans];
		}
	}

	//cout << step << " " << ropN << " ";

	cout << ans+1;

	//cin >> N;

	return 0;
}

Measured memory_bytes: 4312
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <math.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define printV(vec) for(int i = 0; i < SZ(vec); i++){cout << vec[i];if (i==SZ(vec)-1){cout<<endl;}else{cout << " ";}}
#define printA(arr,n) for(int i = 0; i < n; i++){cout << arr[i];if (i==n-1){cout<<endl;}else{cout << " ";}}
typedef long long ll;


int main()
{
  int N;

  cin >> N;
  string S;
  cin >> S;

  ll w[N];
  ll e[N];
  e[0] = (S[0]=='E');

  for(int i=1;i<N;i++){
    e[i] = e[i-1] + (S[i]=='E');
  }


  w[N-1] = (S[N-1]=='W');

  for(int i=N-2;i>=0;i--){
    w[i] = w[i+1] + (S[i]=='W');
  }

  ll maxi = max(w[1],e[N-2]);
  for(int i=1;i<N-1;i++){
    maxi = max(e[i-1]+w[i+1],maxi);
  }

  cout << N-1-maxi << endl;

  return 0;
}


Measured memory_bytes: 5380
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    long long n, a, b;
    cin >> n >> a >> b;
    if (n == 1)
    {
        if (a == b)
        {
            cout << '1' << endl;
        }
        else
        {
            cout << '0' << endl;
        }
    }
    else if (a > b)
    {
        cout << '0' << endl;
    }
    else
    {
        cout << (b * (n - 1) + a) - (a * (n - 1) + b) + 1 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int h,w,i,j;
    while(scanf("%d %d",&h,&w)){
            if(h==0 && w==0)
            break;
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            printf("#");}
            printf("\n");
    }
    printf("\n");
    }
return 0;
}



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

int main(){
    char c[3][3];
    for (int i = 0; i < 3; i ++){
        for (int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

Measured memory_bytes: 256
//abc097a.java
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int a = sc.nextInt();
       int b = sc.nextInt();
       int c = sc.nextInt();
       int d = sc.nextInt();
       sc.close();

       if (a - c <= d && a - c >= -d) {
            System.out.println("Yes");
            return;
       }else if((a-b <= d && a-b >= -d) && (b-c <= d && b-c >= -d)) {
           System.out.println("Yes");
           return;
       }else System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int n;
ll a[409], dp[409][409];

ll f(int l, int r) {
    if(l == r) return 0;
    if(dp[l][r] == 0) {
        dp[l][r] = 1e18;
        FOR(i, l, r) chmin(dp[l][r], f(l, i) + f(i + 1, r));
        dp[l][r] += a[r] - a[l - 1];
    }
    return dp[l][r];
}

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

    cin >> n;
    FOR(i, 1, n + 1) {
        cin >> a[i];
        a[i] += a[i - 1];
    }

    cout << f(1, n) << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  vector<vector<ll>>g(n);
  vector<double>e(n,0);
  vector<ll>kouho(n,-1);
  rep(i,m){
    ll a,b;cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    //g[a].push_back(b);
  }
  rrep(i,n-1){
    double ma=-1;
    ll id=-1;
    ll sz=g[i].size();
    for(auto nv:g[i]){
      e[i]+=e[nv]+1;
      if(chmax(ma,e[nv]+1)){
        id=nv;
      }
    }
    e[i]/=sz;
    if(sz>1)kouho[i]=id;
  }
  double res=e[0];
  rep(j,n){
    if(kouho[j]==-1)continue;
    //cout<<j<<" "<<kouho[j]<<endl;
    e.assign(n,0);
    
    rrep(i,n-1){
      ll sz=g[i].size();
      for(auto nv:g[i]){
        if(i==j&&nv==kouho[j]){sz--;continue;}
        e[i]+=e[nv]+1;
      }
      e[i]/=sz;
    }
    chmin(res,e[0]);
  }
  cout<<setprecision(12)<<res<<endl;


  return 0;

}


Measured memory_bytes: 2560
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int h = scan.nextInt();

		int[] a = new int[h + 1];

		for (int i = 1; i <= h; i++)
			a[i] = scan.nextInt();

		for (int i = h / 2; i > 0; i--)
			maxHeap(a, i);

		for (int i = 1; i <= h; i++)
			System.out.print(" " + a[i]);
		System.out.print("\n");
		
		// for (int i = 1; i <= h; i++)
		// print(a, i);

		scan.close();
		System.exit(0);
	}

	private static void maxHeap(int[] a, int i) {
		int l = i * 2;
		int r = i * 2 + 1;
		int max = i;
		if (l < a.length && a[l] > a[i])
			max = l;
		if (r < a.length && a[r] > a[max])
			max = r;
		if (max != i) {
			int tmp = a[i];
			a[i] = a[max];
			a[max] = tmp;
			maxHeap(a, max);
		}
	}

	private static void print(int[] a, int i) {
		System.out.print("node " + i + ": ");
		System.out.print("key = " + a[i] + ", ");
		if (i > 1)
			System.out.print("parent key = " + a[i / 2] + ", ");
		if (i * 2 < a.length)
			System.out.print("left key = " + a[i * 2] + ", ");
		if (i * 2 + 1 < a.length)
			System.out.print("right key = " + a[i * 2 + 1] + ", ");
		System.out.print("\n");
	}
}

Measured memory_bytes: 165692
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        int max = (N -1) * (N - 2) / 2;
        
        if ( max < K ) {
            System.out.println(-1);
            return;
        }
        
        Node[] nodes = new Node[N];
        for(int i = 0; i < N; i++){
            nodes[i] = new Node(i);
            
            if (i > 0){
                nodes[0].adjacents.add(nodes[i]);
                nodes[i].adjacents.add(nodes[0]);
            }
        }
        
        int countGoal = max - K;
        int count = 0;

        loop1: for(int i = 1; i < N - 1; i++){
            for(int j = i + 1; j < N; j++){
                if ( count++ == countGoal ) break loop1;
                nodes[i].adjacents.add(nodes[j]);
                nodes[j].adjacents.add(nodes[i]);
            }
        }
        
        int M = 0;
        
        loop2: for(int i = 0; i < N - 1; i++){
            for(int j = i + 1; j < N; j++){
                if ( nodes[i].adjacents.contains(nodes[j]) ){
                    M++;
                } else {
                    break loop2;
                }
            }
        }
        
        System.out.println(M);
        
        loop3: for(int i = 0; i < N - 1; i++){
            for(int j = i + 1; j < N; j++){
                if ( nodes[i].adjacents.contains(nodes[j]) ){
                    System.out.println( (i + 1) + " " + (j + 1) );
                } else {
                    break loop3;
                }
            }
        }
        
    }
    
    static class Node{
        int id;
        
        public Node(int id){
            this.id = id;
        }
        
        List<Node> adjacents = new LinkedList<>();
    }
}


Measured memory_bytes: 24404
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func main() {
	HP := readInt()
	cHP, MonsterCount, Result := HP, 1, 0

	for cHP != 1 {
		Result += MonsterCount
		cHP = cHP / 2
		MonsterCount = MonsterCount * 2
	}

	fmt.Println(Result + MonsterCount)
}

func readInt() int {
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	return t
}


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

using namespace std;

double ans;
int n,i;

int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		double temp;
		scanf("%lf",&temp);
		ans+=1.0/temp;
	}
	printf("%lf",1.0/ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
 
class Graph{
	private:
	int n;
	vvp g;
	public:
	int DIJ(int s,int t){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
        if (d[t] == inf){
            return -3;
        }
		return d[t];
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
	}
};
 
int n,m;
vi a,b;
 
int f(int s, int t){
	Graph g(n*3);
	for(int i=0;i<m;i++){
        g.add_edge(a[i]-1,b[i]-1+n,1);
        // g.add_edge(b[i]-1,a[i]-1+n,1);
        g.add_edge(a[i]-1+n,b[i]-1+2*n,1);
        // g.add_edge(b[i]-1+n,a[i]-1+2*n,1);
        g.add_edge(a[i]-1+2*n,b[i]-1,1);
        // g.add_edge(b[i]-1+2*n,a[i]-1,1);

    }
	return g.DIJ(s,t)/3;
}
 
int main(){
    int s,t;

	cin>>n>>m;
	a=b=vi(m);
	for(int i=0;i<m;i++) cin>>a[i]>>b[i];
	cin>>s>>t;
	cout<<f(s-1,t-1)<<endl;
}


Measured memory_bytes: 18560
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if((a > b && a > c) && (a == b + c))
			System.out.println("Yes");
		else if((b > a && b > c) && (b == a + c))
			System.out.println("Yes");
		else if((c > a && c > b) && (c == a + b))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n,i;
    scanf("%d",&n);
    int *p;
    p=malloc(n*sizeof(int));
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    int flag=1;
    for(i=0;i<n;i++){
        flag=p[flag-1];
        if(flag==2){
            printf("%d\n",i+1);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}


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

#define pb      push_back
#define all(v)  v.begin(),v.end()
#define endl    "\n"
#define FAST    ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long     ll;
typedef long double   ld;
typedef pair<int,int> ii;

const int    inf = 2e9;
const ll     INF = 4e17;
const int    mod = 1e9+7;
const double eps = 1e-9;

int main() {
	FAST
	int a, b;
	string s;
	cin >> a >> b >> s;
	int len = s.size();
	if(len != a+b+1) { cout << "No"; return 0; }
	int cnt = 0;
	for(int i = 0; i < len; i++)
		if(s[i] == '-') cnt++;
	if(cnt != 1) { cout << "No"; return 0; }
	if(s[a] == '-') { cout << "Yes"; return 0; }
	cout << "No";
	return 0;
}



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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
  int y1,m1,d1,y2,m2,d2;
  while(cin>>y1 >>m1 >>d1 >>y2 >>m2 >>d2){
    if(y1<0 || m1<0 ||  d1<0 ||  y2<0 || m2<0 ||  d2<0) break;
    long long int total1=0,total2=0;
    for(int i=0;i<y1;i++){
      if(i%400==0 || (i%100!=0 && i%4==0)){
	total1+=366;
	 
      }else {
	total1+=365;
      }
    }

    for(int i=0;i<y2;i++){
      if(i%400==0 || (i%100!=0 && i%4==0)){
	total2+=366;
	  
      }else {
	total2+=365;
      }
    }

    for(int i=1;i<m1;i++){
      if(i==2){
	if(y1%400==0 || ( y1%100!=0 && y1%4==0)){
	  total1+=29;
	  
	}
	else total1+=28;
      }
      else if(i==4 || i==6 || i==9 || i==11){
	total1+=30;
      }
      else total1+=31;
    }
    
    for(int i=1;i<m2;i++){
      if(i==2){
	if(y2%400==0 || ( y2%100!=0 && y2%4==0)){
	    total2+=29;
	  
	}
	else total2+=28;
      }
      else if(i==4 || i==6 || i==9 || i==11){
	total2+=30;
      }
      else total2+=31;
    }

    total1+=d1;
    total2+=d2;
    cout<< total2-total1<< endl;
  }
}

Measured memory_bytes: 1156
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))

N, Q = inpl()
S = input()
T = []
D = []
for i in range(Q):
    t,d = input().split()
    T.append(t)
    D.append(d)

finalposmem = defaultdict(lambda: None)
def finalpos(i):
    if i < 0:
        return -1
    elif i >= N:
        return 1

    for q in range(Q):
        if S[i] == T[q]:
            if D[q] == 'L':
                i -= 1
            else:
                i += 1
            if i < 0:
                return -1
            elif i >= N:
                return 1
    return 0

def finalpos_withmem(i):
    mem = finalposmem[i]
    if mem is None:
        z = finalpos(i)
        finalposmem[i] = z
        return z
    else:
        return mem

def bisect_left_withkey(a, x, key=lambda x: x):
    right = len(a)
    left = 0
    kx = key(x)
    while left + 1 < right:
        new = (left + right)//2
        kn = key(a[new])
        if kx <= kn:
            right = new
        else:
            left = new
    return right

def bisect_right_withkey(a, x, key=lambda x: x):
    right = len(a)
    left = 0
    kx = key(x)
    while left + 1 < right:
        new = (left + right)//2
        kn = key(a[new])
        if kx < kn:
            right = new
        else:
            left = new
    return right

right_bound = bisect_left_withkey(range(N),N,key=finalpos_withmem)
left_bound = bisect_right_withkey(range(N),-1,key=finalpos_withmem)
right_killed = N - right_bound
left_killed = left_bound
killed = left_killed + right_killed
ans = N - killed

print(ans)

Measured memory_bytes: 6928
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
dp = [[0]*3 for _ in range(n)]
lst1 = list(map(int,readline().split()))
for i in range(3):
	dp[0][i] = lst1[i]
for i in range(n-1):
	lst1 = list(map(int,readline().split()))
	dp[i+1][0] = max(dp[i][1]+lst1[0],dp[i][2]+lst1[0])
	dp[i+1][1] = max(dp[i][0]+lst1[1],dp[i][2]+lst1[1])
	dp[i+1][2] = max(dp[i][0]+lst1[2],dp[i][1]+lst1[2])

print(max(dp[-1]))

Measured memory_bytes: 54380
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	string ans = "";
	for(int i = 0; i < n; ++i) {
		ans += s[i];
		ans += t[i];
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int N = sc.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }

        int startx = 0;
        int endx = W;
        int starty = 0;
        int endy = H;
        for(int i = 0; i < N; i++){
            if(endx - startx <= 0 || endy - starty <= 0) break;
            else if(a[i] == 1 && startx < x[i]){
                startx = x[i];
            }
            else if(a[i] == 2 && endx > x[i]){
                endx = x[i];
            }
            else if(a[i] == 3 && starty < y[i]){
                starty = y[i];
            }
            else if(a[i] == 4 && endy > y[i]){
                endy = y[i];
            }
        }

        if(endx - startx <= 0 || endy - starty <= 0) System.out.println("0");
        else System.out.println((endx - startx) * (endy - starty));
        
    }
}


Measured memory_bytes: 22740
#include<iostream>
using namespace std;
#define df 0
int main(){
  int m,d; cin >> m >> d;
  int cnt=0;
  for(int i=1;i<=m;i++){
    for(int d1=2;d1<10;d1++){
      if(i%d1)continue;
      if(i==d1)continue;
      int d10=i/d1;
      if(d10*10+d1<=d){cnt++;
	if(df) printf("%d/%d%d\n",i,d10,d1);}
    }
  }
  cout << cnt;
}


Measured memory_bytes: 256
class Node:
    def __init__(self, key=None, parent=None, left=None, right=None):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right

def insert(key):
    global root
    # The first node
    if root.key is None:
        root.key = key
        return
    # The second note and so forth
    else:
        newNode = Node(key)
        x = root
        while x is not None:
            tmpParent = x
            if newNode.key < x.key:
                x = x.left
            else:
                x = x.right
        newNode.parent = tmpParent
        if newNode.key < tmpParent.key:
            tmpParent.left = newNode
        else:
            tmpParent.right = newNode

def inorder(node, result):
    if node is None:
        return
    inorder(node.left, result)
    result.append(node.key)
    inorder(node.right, result)

def preorder(node, result):
    if node is None:
        return
    result.append(node.key)
    preorder(node.left, result)
    preorder(node.right, result)

def printOrderedResult(node, orderFunction):
    result = []
    orderFunction(node, result)
    result = [i for i in map(str, result)]
    print(' ', end='')
    print(' '.join(result))
    

root = Node()
n = int(input())

for i in range(n):
    command = input()
    try:
        command, key = command.split()
        key = int(key)
        insert(key)
    except ValueError:
        printOrderedResult(root, inorder)
        printOrderedResult(root, preorder)


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

struct UnionFind {
  vector<int> parent;
  vector<int> size;

  UnionFind(int n) : parent(n, -1), size(n, 1) {}

  int find(int i) {
    if (parent[i] == -1) {
      return i;
    }
    return parent[i] = find(parent[i]);
  }

  void unite(int i, int j) {
    i = find(i);
    j = find(j);
    if (i == j) {
      return;
    }
    if (size[i] < size[j]) {
      parent[i] = j;
      size[j] += size[i];
    } else {
      parent[j] = i;
      size[i] += size[j];
    }
  }
};

int main() {
  int n, m;
  cin>>n>>m;
  int p[n+1];
  for (int i=0; i<n; i++) cin>>p[i+1];
  UnionFind uf(n+1);
  for (int i=0; i<m; i++) {
    int x, y;
    cin>>x>>y;
    uf.unite(x, y);
  }
  int cnt = 0;
  for (int i=1; i<=n; i++) {
    if (uf.find(i) == uf.find(p[i])) {
      ++cnt;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int mx=0,sum=0,n;
    cin>>n;
    while(n--){
        int a;
        cin>>a;
        mx=max(mx,a);
        sum+=a;
    }
    sum-=mx;
    if(mx<sum)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


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

int main(){
  char a,b;
  cin >> a >> b;
  
  if (a =='H') cout << b << endl;
  if (a == 'D'){
    if(b == 'D') cout << 'H' << endl;
    else cout << 'D' << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char Nyu[101];
    int  For,Mo;
    
    scanf("%s",Nyu);
    
    Mo = strlen(Nyu);
    
    for(For=0;For<Mo;For++)
        Nyu[For] = 'x';
        
    printf("%s",Nyu);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <bitset>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define RPA(i,s,e) for(int i=s; i<=e; i++)
#define RPD(i,s,e) for(int i=s; i>=e; i--)
#define PB(a) push_back(a)
#define MP(i,s) make_pair(i,s)
#define ALL(a) (a).begin(), (a).end()
#define PRT(a) cout << (a) << endl

typedef pair<int,int> P;

int M[12][12];
bool F[12][12];
char line[16];

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

void bfs(int y, int x) {
	queue<P> que;
	que.push(MP(y, x));
	F[y][x] = true;

	while(!que.empty()) {
		P p = que.front();
		que.pop();
		
		REP(k,4) {
			int xx = p.second + dx[k];
			int yy = p.first + dy[k];
			if(xx >= 0 && yy >= 0 && xx < 12 && yy < 12) {
				if(!F[yy][xx] && M[yy][xx] == 1) {
					F[yy][xx] = true;
					que.push(MP(yy, xx));
				}
			}
		}
	}
}

int solve() {
	memset(F, 0, sizeof(F));
	int cnt = 0;
	REP(i,12) {
		REP(j,12) {
			if(M[i][j] == 1 && !F[i][j]) {
				cnt++;
				bfs(i, j);
			}
		}
	}
	return cnt;
}

void coding() {
	while(scanf("%s", line) != EOF) {
		REP(j,12) {
			M[0][j] = line[j] - '0';
		}

		REP(i,11) {
			scanf("%s", line);
			REP(j,12) {
				M[i+1][j] = line[j] - '0';
			}
		}
		printf("%d\n", solve());
	}
}

//#define _LOCAL_TEST

int main() {
#ifdef _LOCAL_TEST
	freopen("a.in", "r", stdin);
#endif

	coding();

#ifdef _LOCAL_TEST
	cout << endl;
	cout << "This is local test" << endl;
	cout << "Do not forget to comment out _LOCAL_TEST" << endl;
#endif
}

Measured memory_bytes: 1172