akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int MOD = 1'000'000'007;

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

    int h, w;
    cin >> h >> w;

    vector<int> dp1(w);
    dp1[0] = 1;

    for (int i = 0; i < h; ++i) {
        string row;
        cin >> row;

        vector<int> dp2(w);
        if (row[0] == '.') dp2[0] = dp1[0];
        for (int j = 1; j < w; ++j) {
            if (row[j] == '.') dp2[j] = (dp2[j - 1] + dp1[j]) % MOD;
        }

        dp1 = move(dp2);
    }

    cout << dp1[w - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
x_sum = sum(A_list)
num_list = [x_sum-2*sum([A_list[i] for i in range(1,N,2)])]
print(num_list[-1])
for i in range(N-1):
  num_list.append(2*A_list[i]-num_list[-1])
  print(num_list[-1])

Measured memory_bytes: 14092
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a+c, min(a+d, min(b+c, b+d))) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc116/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int n;
    cin >> n;
    int h[n];
    rep(i, n){
        cin >> h[i];
    }

    int ans = 0;
    int flag = 0;
    while(flag == 0){
        rep(i, n){
            if(h[i] != 0) break;
            if(i == n - 1) flag = 1;
        }
        int tochu = 0;
        rep(i, n){
            if(i == n - 1){
                if(tochu){
                    if(h[i] != 0){
                        h[i]--;
                        ans++;
                        continue;
                    }else{
                        ans++;
                        continue;
                    }
                }else{
                    if(h[i] != 0){
                        h[i]--;
                        ans++;
                        continue;
                    }else{
                        continue;
                    }
                }
            }

            if(tochu){
                if(h[i] != 0){
                    h[i]--;
                    continue;
                }else{
                    tochu = 0;
                    ans++;
                    continue;
                }
            }else{
                if(h[i] != 0){
                    tochu = 1;
                    h[i]--;
                    continue;
                }else{
                    continue;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();

        if(n == 0) {
            System.out.println(x);
            System.exit(0);
        }

        int[] p = new int[n];

        for(int i=0; i<n; i++) {
            p[i] = sc.nextInt();
        }

        ArrayList<Integer> ep = new ArrayList<>();
        for(int i=0; i<=101; i++) {
            boolean isFound = false;
            for(int j=0; j<p.length; j++) {
                if(i == p[j]) isFound = true;
            }
            if(!isFound) ep.add(i);
        }

        int diff = 0;
        int comp = 0;
        int ans = 0;
        for(int i=0; i<ep.size(); i++) {
            diff = Math.abs(x-ep.get(i));
            if(i == 0) comp = diff;
            if(comp > diff) {
                comp = diff;
                ans = ep.get(i);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            Console.WriteLine(s == "ABC" ? "ARC" : "ABC");


        }
    }

    
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
int a[N];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i ++ ) cin >> a[i];
	
	int res = 0;
	for (int l = 0; l <= min(n, m); l ++ )
		for (int r = 0; r <= min(n - l, m - l); r ++ )
		{
			vector<int> t;
			for (int i = 1; i <= l; i ++ ) t.PB(a[i]);
			for (int i = n, j = r; j; j -- , i -- ) t.PB(a[i]);
			
			sort(t.begin(), t.end());
			int sum = 0, cnt = m - l - r;
			for (auto u : t)
				if (cnt && u < 0) cnt -- ;
				else sum += u;
			
			res = max(res, sum);
		}
		
	cout << res << endl;
    return 0;
}

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

int main() {

	string a;
	string b;

	int count = 0;

	cin >> a;

	while (cin >> b, b != "END_OF_TEXT") {
		transform(b.begin(), b.end(), b.begin(), ::tolower);
		//for (int i = 0; i < b.size(); i++) {
			//if (b.substr(i, a.size()) == a) {
			if(a == b){
				count++;
			}
		//}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3180
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T>
T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()
template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"Yes":"N1010o"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//variables
int n;
string s,str;
vec<int> nums;

void Main() {
    //code here
    int a = gi;
    int b = gi;
    int c = gi;
    int x = gi;
    int res = 0;
    REP(ia, a+1) {
        REP(ib, b+1) {
            int leftForC = x - ia*500 - ib*100;
            //print(leftForC);
            if ((leftForC)%50 == 0 && 0 <= leftForC && leftForC <= c*50) {
                res++;
                //print(to_string(ia) + " " + to_string(ib));
            }
        }
    }
    print(res);
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2e9;

int main(){
    int n; cin>>n;
    int f[110]={0};
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            int t; cin>>t;
            f[i]=(f[i]*2)+t;
        }
    }
    int p[110][15];
    for(int i=0;i<n;i++){
        for(int j=0;j<=10;j++){
            cin>>p[i][j];
        }
    }
    int ans=-INF;
    for(int i=1;i<(1<<10);i++){
        int sum=0;
        for(int j=0;j<n;j++){
            int c=0;
            int t=i&f[j];
            for(int k=0;k<10;k++){
                if(t&(1<<k))c++;
            }
            sum+=p[j][c];
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int k,i,j,x,y;
    for(k=0;;k++)
    {
    scanf("%d %d",&x,&y);
        if(x==0 && y==0)
            break;


        else {
            for(i=1;i<=x;i++)
            {
                for(j=1;j<=y;j++)
                {
                    if((j==1 ||j==y)||(i==1 || i==x))

                    printf("#");

                    else printf(".");
                }
                    printf("\n");

            }
            printf("\n");


        }

    }



    return 0;
}



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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define INF 1e9+2137
#define all(x) (x).begin(), (x).end()

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 1e5+2;
const int M = 1e9+7;

int n, W[100], val[100], w, dp[MAX], sum;

int main()
{
    _upgrade;
    cin>>n>>w;


    FOR(i, 0, n)
    {
        cin>>W[i]>>val[i];
        sum += val[i];
    }
    fill(dp, dp+sum+1, INF);
    dp[0] = 0;
    FOR(i, 0, n)
        for(int j = sum; j-val[i] >= 0; --j)
            if(dp[j-val[i]] != INF)
                dp[j] = min(dp[j], dp[j-val[i]] + W[i]);
    for(int i = sum; i >= 0; --i)
        if(dp[i] <= w)
        {
            cout<<i;
            break;
        }
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)


int main() {
	vi n(3);
	cin >> n[0] >> n[1] >> n[2];
	sort(n.begin(), n.end());
	if (n[0] == n[2])cout << "No" << endl;
	else if (n[0] != n[1] && n[1] != n[2])cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 888
N = int(input())
A, B = map(int, input().split())
P = [int(x) for x in input().split()]
C = [0, 0, 0]
for p in P:
  if p <= A:
    C[0] += 1
  elif p <= B:
    C[1] += 1
  else:
    C[2] += 1
print(min(C))

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


void solve(long long A, long long B, long long C, long long D){
    if (A + B > C + D)
        cout << "Left" << '\n';
    else if (A + B < C + D)
        cout << "Right" << '\n';
    else
        cout << "Balanced" << '\n';
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define Complex complex<double>
int dx[3]={1,0,-1};
int dy[3]={1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int h,w,n;
    cin >> h >> w >> n;
    map<pii,int> ma;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        for(auto x:dx){
            for(auto y:dy){
                ma[mp(a+x,b+y)]++;
            }
        }
    }
    ll sum[10]={};
    sum[0]=(ll)(h-2)*(ll)(w-2);
    for(auto x:ma){
        if(0<x.F.F && x.F.F<h-1 && 0<x.F.S && x.F.S<w-1){        
            sum[x.S]++;
            sum[0]--;
        }
    }
    rep(i,10){
        cout << sum[i] << endl;
    }

    
}

Measured memory_bytes: 56448
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>

#define endl '\n'
#define ll long long

using namespace std;

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

	int n, r = 0, g = 0, b = 0;
	string s;
	ll sum;

	cin >> n >> s;

	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'R') r++;
		else if (s[i] == 'G') g++;
		else b++;
	}

	sum = (ll)r * g * b;

	for (int d = 1; d < n - 1; d++)
	{
		for (int j = d; j < n - d; j++)
		{
			if (s[j - d] != s[j + d] && s[j] != s[j + d] && s[j - d] != s[j]) sum--;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main() {
	int n,m,p1=0,p2=0,sz=0,cnt=0;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i) {
		scanf("%d",a+i);
		cnt+=(a[i]&1);
	}
	if (cnt>2) return puts("Impossible")&&0;
	if (m==1) {
		if (n==1) puts("1\n1\n1\n");
		else printf("%d\n2\n%d %d\n",a[1],a[1]-1,1);
		return 0;
	}
	for (int i=2;i<=m;++i)
		if (a[i]&1) (a[1]&1) ? swap(a[m],a[i]) : swap(a[1],a[i]);
	if (a[1]>1) b[++sz]=a[1]-1;
	for (int i=2;i<m;++i) b[++sz]=a[i];
	b[++sz]=a[m]+1;
	for (int i=1;i<=m;++i) printf("%d ",a[i]); puts("");
	printf("%d\n",sz);
	for (int i=1;i<=sz;++i) printf("%d ",b[i]); puts("");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int m = 10000000;
  int M = -10000000;
  long long sum = 0;
  for (int i = 0; i < n; i++){
    int a;
    cin >> a;
    m = min(m, a);
    M = max(M, a);
    sum = sum + a;
  }
  cout << m << ' ' << M << ' ' << sum << endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

int main(void) {

  int n;
  cin >> n;
  for(int l=0; l<n; l++){
    vector<string> ans;
    string s;
    cin >> s;
    int p = s.size();
    for(int i=1; i<p; i++){
      string a = s.substr(0, i);
      string b = s.substr(i, p-i);
      string na = a;
      string nb = b;
      reverse(a.begin(), a.end());
      reverse(b.begin(), b.end());
      string ra = a;
      string rb = b;
      ans.push_back( na + nb );
      ans.push_back( na + rb );
      ans.push_back( ra + nb );
      ans.push_back( ra + rb );
      ans.push_back( nb + na );
      ans.push_back( nb + ra );
      ans.push_back( rb + na );
      ans.push_back( rb + ra );
    }
    sort(ans.begin(), ans.end());
    ans.push_back("");
    long long int cnt = 0;
    for(int i=0; i<ans.size()-1; i++){
      if( ans[i] != ans[i+1] ) cnt++;
    }
    cout << cnt << endl;
  }

  return 0;
}


// EOF

Measured memory_bytes: 3292
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;

        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    // 順列の計算
    mint p(int n, int k) { return fact[n] * ifact[n - k]; }
};

int main() {
    INIT;

    ll N, K;
    cin >> N >> K;

    combination comb(200005);
    mint ans = 0;

    reps(i, K, N + 2) {
        // ans += comb(N + 1, i);
        // cout << ((N - i + 1) + N) * i / 2 << ", " << (i - 1) * i / 2 << endl;
        ans += ((N - i + 1) + N) * i / 2 - (i - 1) * i / 2 + 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6348
import java.util.Scanner;

public class Main {

	static int r = 1000000007;
	static String s1, s2;
	static int n;

	public static long comb(long n, long r) {
		if (n <= 0)
			return 0;
		if (r == 0)
			return 1;
		long ans = 1;

		for (int i = 1; i <= r; ++i) {
			ans *= n - i + 1;
			ans /= i;
			ans %= r;
		}

		return ans;
	}

	public static long domino() {
		long ans = 3;
		long color = 0;// ドミノの向き： １：縦 ２；横

		for (int i = 0; i < n; ++i) {
			if (s1.charAt(i) == s2.charAt(i)) {
				if (color == 1) {
					ans *= 2;
					ans %= r;
				}
				
				color = 1;
			}
			if (i < n - 1) {
				if (s1.charAt(i) == s1.charAt(i + 1)) {
					if (color == 2) {
						ans *= 3;
						ans %= r;
					} else {
						ans *= 2;
						ans %= r;
					}

					color = 2;
					++i;
				}
			}
		}

		ans %= r;
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();
		s1 = sc.next();
		s2 = sc.next();
		sc.close();

		long ans = domino();
		System.out.println(ans);
	}

}


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

int main() {
    string s;
    cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0'; 
    int ans = a;
    vector<char> ops(3);

    for(int i=0; i<=1; i++){
        if(i==0){
            ans += b;
            ops[0] = '+';
        }else{
            ans -= b;
            ops[0] = '-';
        }
        for(int j=0; j<=1; j++){
            if(j==0){
                ans += c;
                ops[1] = '+';
            }else{
                ans -= c;
                ops[1] = '-';
            }
            for(int l=0; l<=1; l++){
                if(l==0){
                    ans += d;
                    ops[2] = '+';
                }else{
                    ans -= d;
                    ops[2] = '-';
                }
                if(ans == 7){
                    cout << a << ops[0] << b << ops[1] << c << ops[2] << d << "=7";
                    return 0;
                }else{
                    if(l==0){
                        ans -= d;
                    }else{
                        ans += d;
                    }
                }
            }
            if(j==0){
                ans -= c;
            }else{
                ans += c;
            }
        }
        if(i==0){
            ans -= b;
        }else{
            ans += b;
        }
    }

    return 0;
}

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

void Cont(){
    string x;
    cin >> x;
    if(x == "ABC")
        std::cout << "ARC" << "\n";
    else
        std::cout << "ABC" << "\n";
}

int main()
{
	std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Cont();
}

Measured memory_bytes: 3608
#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 = 1e9;

int main() {
  ll n, m, ans = 0;
  cin >> n >> m;
  if (n <= 1 && m <= 1) {
    cout << 0 << endl;
    return 0;
  }

  ans = n * (n - 1) / 2 + m * (m - 1) / 2;

  cout << ans << endl;
  return 0;
}


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

struct Point {double x,y;};

void koch(int n, Point a, Point b) {
    
    if (n == 0) {
        
        return ;
        
    }
    
    Point s,t,u;
    
    double th = M_PI * 60.0 / 180.0;
    
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    
    koch(n-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    
    koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    
    koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);

    koch(n-1, t, b);
    
}


int main() {
    
    Point a,b;
    int n;
    
    scanf("%d", &n);
    
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
    
    printf("%.8f %.8f\n", a.x, a.y);
    
    koch(n, a, b);
    
    printf("%.8f %.8f\n", b.x, b.y);
    
    return 0;
    
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int w,h;cin>>w>>h && w|h;){
		vi ps(w),qs(h);
		rep(i,w) cin>>ps[i];
		rep(i,h) cin>>qs[i];

		sort(all(ps));
		sort(all(qs));

		int i=0,j=0;
		ll res=0;
		while(i<w && j<h){
			if(ps[i]<qs[j]){
				res+=ll(h-j+1)*ps[i];
				i++;
			}
			else{
				res+=ll(w-i+1)*qs[j];
				j++;
			}
		}
		while(i<w){
			res+=ps[i];
			i++;
		}
		while(j<h){
			res+=qs[j];
			j++;
		}
		cout<<res<<endl;
	}
}


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

int main() {
    int n, y, a = -1, b = -1, c = -1;
    cin >> n >> y;
    rep(i, n + 1) rep(j, n + 1) {
        if(i + j > n) break;
        if(y == 1000 * i + 5000 * j + 10000 * (n - i - j)) {
            a = n - i - j;
            b = j;
            c = i;
        }
    }
    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhilash Mandaliya
 */
public class Main {
    public static void main (String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader( inputStream );
        PrintWriter out = new PrintWriter( outputStream );
        TaskB solver = new TaskB();
        solver.solve( 1, in, out );
        out.close();
    }

    static class TaskB {
        public void solve (int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            out.println( ( int ) Math.pow( 2, ( int ) ( Math.log( n ) / Math.log( 2 ) ) ) );
        }

    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar;
        private int snumChars;

        public InputReader (InputStream st) {
            this.stream = st;
        }

        public int read () {
            if ( snumChars == - 1 )
                throw new InputMismatchException();
            if ( curChar >= snumChars ) {
                curChar = 0;
                try {
                    snumChars = stream.read( buf );
                } catch ( IOException e ) {
                    throw new InputMismatchException();
                }
                if ( snumChars <= 0 )
                    return - 1;
            }
            return buf[curChar++];
        }

        public int nextInt () {
            int c = read();
            while ( isSpaceChar( c ) ) {
                c = read();
            }
            int sgn = 1;
            if ( c == '-' ) {
                sgn = - 1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while ( ! isSpaceChar( c ) );
            return res * sgn;
        }

        public boolean isSpaceChar (int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == - 1;
        }

    }
}



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

using lli = long long int;

int main() {
	vector<int> v; int n, min, max; lli sum; cin >> n; v.resize(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	min = *min_element(v.begin(), v.end());
	max = *max_element(v.begin(), v.end());
	sum = accumulate(v.begin(), v.end(), 0ll);
	cout << min << " " << max << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define F first
#define S second
#define mset(x,v) memset(x, v, sizeof(x))
#define left(x) 2*x
#define right(x) (2*x) + 1
#define ALL(t) (t).begin(),(t).end() 
#define ret return 0
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rev(s) reverse(s.begin(),s.end())
#define WL(t) while(t --)
#define MOD 1000000007
char mat[100][100];
int n,m;
int vis[100][100],dist[100][100];
int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};
bool isok(int x,int y)
{
      if(x<0 || x>n || y<0 || y>m)
      return false;
      return mat[x][y]=='.';
}
void bfs(int x,int y)
{
      vis[x][y]=1;
      dist[x][y]=0;
      queue<pii> q1;
      q1.push({x,y});
      while(!q1.empty())
      {
            int a=q1.front().F;
            int b=q1.front().S;
            q1.pop();
            for(int i=0;i<4;i++)
            {
                  int xx=a+dx[i];
                  int yy=b+dy[i];
                  if(vis[xx][yy]==0 && isok(xx,yy))
                  {
                        if(dist[xx][yy]>dist[a][b]+1)
                        {
                              dist[xx][yy]=dist[a][b]+1;
                              vis[xx][yy]=1;
                              q1.push({xx,yy});
                        }
                  }
            }
      }
}
int main()
{
      boost;
      cin>>n>>m;
      int cnt=0;
      forn(i,n)
      {
            forn(j,m)
            {
                  cin>>mat[i][j];
                  if(mat[i][j]=='.')
                  {
                        if(i==0 && j==0)
                        continue;
                        if(i==n-1 && j==m-1)
                        continue;
                        cnt++;
                  }
            }
      }
      mset(vis,0);
      mset(dist,9);
      int W=dist[n-1][m-1];
      bfs(0,0);
      if(dist[n-1][m-1]==W)
      {
            cout<<"-1"<<endl;
      }
      else
      {
      int x=dist[n-1][m-1]-1;
      int ans=abs(x-cnt);
      cout<<ans<<endl;
      }
}

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

int main(){
  char str[210];
  scanf("%s", str);
  int n = strlen(str);
  for(int i = n-2; i; i-=2){
    if(strncmp(str, str+i/2, i/2)==0){
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}

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

int main() {
  string s[2];
  cin >> s[0] >> s[1];
  if (s[0][0] == s[1][2] && s[0][1] == s[1][1] && s[0][2] == s[1][0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
L = 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
print(L[int(input())-1])

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
//typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n;
int a[100010], b[100010];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  REP(i,n) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b,b+n);

  int ans = 0;
  map<int,int> mp;
  REP(i,(n+1)/2) {
    mp[a[i*2]]++;
    mp[b[i*2]]++;
  }

  for (auto p:mp) {
    if (p.se == 1) ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}


Measured memory_bytes: 5760
N = int(input())
S = input()

R,G,B = 0,0,0

for i in range(0,N):
    char = S[i]
    if char == "R":
        R += 1
    elif char == "G":
        G += 1
    elif char == "B":
        B += 1

count = R * G * B

N2 = int(N/2 + 0.5)
for i in range(0,N):
    stri = S[i]
    for j in range(0, N2):
        j2 = 2 * j
        if i+j2 >= N:
            break
        strj = S[i+j]
        strk = S[i+j2]
        if stri != strj and strj != strk and stri != strk:
            count -= 1
print(count)

Measured memory_bytes: 9220
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
    s = input()
    if s == "AC":
        AC += 1
    if s == "WA":
        WA += 1
    if s == "TLE":
        TLE += 1
    if s == "RE":
        RE += 1
    
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 74816
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MOD 1000000007
#define MAX 510000

long int FAC[MAX],FINV[MAX],INVE[MAX];
long int SUM(long int a,long int b){return (a%MOD+b%MOD+MOD)%MOD;}//a+b
long int PROD(long int a,long int b){return a%MOD*(b%MOD)%MOD;}//a*b
long int POW(long int a,long int b){//a^b
  long int c=1;
  for(a%=MOD;b;a=PROD(a,a),b>>=1)if(b&1)c=PROD(a,c);
  return c;
}
long int INV(long int a){return a<MAX?INVE[a]:POW(a,MOD-2);}//a^-1
long int QUOT(long int a,long int b){return PROD(a,INV(b));}//a/b
void init_inv(long int a){//make inv list
  INVE[1]=1;
  for(long int i=2;i<=a;i++)INVE[i]=SUM(0,-PROD(INVE[MOD%i],MOD/i));
}
void init_com(long int a){//make fac and facinv list
  FAC[0]=FAC[1]=1;
  FINV[0]=FINV[1]=1;
  init_inv(a);
  for(long int i=2;i<=a;i++){
    FAC[i]=PROD(FAC[i-1],i);
    FINV[i]=PROD(FINV[i-1],INV(i));
  }
}
long int COM(long int a,long int b){return PROD(PROD(FAC[a],FINV[a-b]),FINV[b]);}

int main(){
  int abs[100000];
  int n,i,t;
  scanf("%d",&n);
  for(i=0;i<n;i++)abs[i]=0;
  for(i=0;i<n-1;i++){
    scanf("%d",&t);if((n-t)%2)abs[t]++;
    if(!((n-t)%2)||abs[t]>2||abs[0]>1){printf("0");return 0;}
  }
  printf("%ld",POW(2,n/2));
}


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

int main(){

  int n,m,ans,inc,outc;

  cin >> n >> m;

  ans = m;

  while(n--){

    cin >> inc >> outc;

    m += inc - outc;

    if(m<0){
      cout << 0 << endl;
      return 0;
    }

    ans = max(m,ans);

  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 3104
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


class TravelingPlan(object):

    def __init__(self):
        from collections import OrderedDict
        self._points = OrderedDict()

    def add_point(self, name: str):
        if name not in self._points:
            self._points[name] = Point()
        return self._points[name]

    def is_executable(self):
        for j in range(len(self._points) - 1):
            current_point = self._points[str(j + 1)]
            previous_point = self._points[str(j)]
            result = self._can_move(previous_point, current_point)

            if result is False:
                return False
        return True

    def _can_move(self, previous_point, current_point):
        delta_x = current_point.x - previous_point.x
        delta_y = current_point.y - previous_point.y
        delta_x_y = delta_x + delta_y
        delta_t = current_point.t - previous_point.t

        if delta_x_y == delta_t:
            return True
        elif delta_x_y < delta_t:
            return self._is_reachable(delta_x_y, delta_t)
        elif delta_x_y > delta_t:
            return False

    def _is_reachable(self, delta_x_y, delta_t):
        for i in range(delta_t + 1):
            if (1 * i + (-1) * (delta_t - i)) == delta_x_y:
                return True
        return False


class Point(object):

    def __init__(self):
        self._x = 0
        self._y = 0
        self._t = 0

    @property
    def x(self):
        return self._x

    @x.setter
    def x(self, value):
        self._x = value

    @property
    def y(self):
        return self._y

    @y.setter
    def y(self, value):
        self._y = value

    @property
    def t(self):
        return self._t

    @t.setter
    def t(self, value):
        self._t = value


if __name__ == '__main__':
    point_count = int(input())
    points = [list(map(int, input().split(" "))) for _ in range(point_count)]
    plan = TravelingPlan()
    origin = plan.add_point(str(0))

    for i in range(0, len(points)):
        point = plan.add_point(str(i + 1))
        point.t = points[i][0]
        point.x = points[i][1]
        point.y = points[i][2]

    if plan.is_executable() is True:
        print("Yes")
    else:
        print("No")


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

int main()
{
	long long n, k;
	cin >> n >> k;
	vector<long long> a(n), bit(40);
	for(int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; ++i){
		for(int j = 0; j < 40; j++){
			if(a[i] & (1LL << j)) bit[j]++;
		}
	}
	long long now = 0;
	for(int i = 39; i >= 0; i--){
		long long next = now + (1LL << i);
		if(next <= k && bit[i] * 2 < n) now = next;
	}
	long long ans = 0;
	for(int i = 0; i < n; i++) ans += now ^ a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4040
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define INF2 4611686018427387904
//#define MOD 1000000007
#define MOD 998244353
#define MAX_SIZE 1000000000

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { bool first = true; for (const auto& j: v) { if (!first) { os << " "; } first = false; os <<j; } os << "\n"; return os; }
template<typename T>
istream& operator>>(istream& is, vector<T>& v) { for (auto& elem : v) { is >> elem; } return is; }

vector<ll> f;
void set_f(int n) { f.resize(n+1); f[0] = 1; for (int i=1; i<= n; i++) { f[i] = (f[i-1] * i) % MOD;} }
ll nod(ll a, ll b) { if (b == 0) { return a; } else { return nod(b, a % b); } }
ll pw(ll x, ll n, ll m=MOD) { if (n == 0) { return 1;} if (n%2 == 0) { return pw((x*x) % m, n/2, m); } return (pw(x, n-1, m) * x) % m; }
ll dv(ll a, ll b) { return (a * pw(b, MOD - 2)) % MOD; }
ll c_n_k(int n, int k) { if (k > n) { return 0; } if (k < 0) { return 0; } return dv(dv(f[n], f[k]), f[n-k]); }


void solve() {
    ll k;
    cin >> k;

    ll x = 100;
    int i = 0;
    while (x < k) {
        x += x / 100;
        i++;
    }

    cout << i;
}


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

    if (0) {
        int tests;
        cin >> tests;
        for (int t = 1; t <= tests; t++) {
            //cout << "Case #" << t << ": ";
            solve();
            //cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    var(string, s);

    outn(s.front(), s.length() - 2, s.back());
    outl();

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
for i in range(1,n): a[i]+=a[i-1]
l,r,ans = 1,3,float("inf")
for i in range(2,n-1):
	num,num2 = abs(2*a[l-1]-a[i-1]),abs(2*a[r-1]-a[i-1]-a[n-1])
	while num>abs(2*a[l]-a[i-1]) and l<i-1: l,num = l+1,abs(2*a[l]-a[i-1])
	while num2>abs(2*a[r]-a[i-1]-a[-1]) and r<n-1: r,num2 = r+1,abs(2*a[r]-a[i-1]-a[-1])
	ans = min(ans,max(a[l-1],a[i-1]-a[l-1],a[r-1]-a[i-1],a[-1]-a[r-1])-min(a[l-1],a[i-1]-a[l-1],a[r-1]-a[i-1],a[-1]-a[r-1]))
print(ans)

Measured memory_bytes: 25672
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, dp[2][110];
    cin>>N;
    MEMSET(dp, 0);
    rep(i, N){
        ll A;
        cin>>A;
        if(i==0) dp[0][i]=A;
        else dp[0][i]=dp[0][i-1]+A;
    }
    rep(i, N){
        ll A;
        cin>>A;
        if(i==0) dp[1][i]=dp[0][i]+A;
        else{
            dp[1][i]=max(dp[1][i-1], dp[0][i])+A;
        }
    }
    cout<<dp[1][N-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    private def innerLoop(j: Int, p: Int): Unit = {
      notPrime(j)
      if(j + p <= top)innerLoop(j + p, p)
    }

    private def loop(i: Int): Unit = {
      val p = 2 * i + 3
      if(isPrime(i))innerLoop((p * p - 3) / 2, p)
      if(i < sqrtLimit)loop(i + 1)
    }

    private def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
      loop(0)
      if(n==2)Iterator.single(2)
      else Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) / 2)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 65356
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	var M int64
	scanner.Scan()
	M, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	H := make([]int64, N)
	for i := int64(0); i < N; i++ {
		scanner.Scan()
		H[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}
	A := make([]int64, M)
	B := make([]int64, M)
	for i := int64(0); i < M; i++ {
		scanner.Scan()
		A[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
		scanner.Scan()
		B[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}
	fmt.Println(solve(N, M, H, A, B))
}
func solve(N int64, M int64, H []int64, A []int64, B []int64) int {
	m := map[int64][]int64{}
	for i := int64(1); i <= N; i++ {
		m[i] = []int64{}
	}
	for i, a := range A {
		b := B[i]
		m[a] = append(m[a], b)
		m[b] = append(m[b], a)
	}
	good := 0
	for curN, neighbors := range m {
		curH := H[curN-1]
		isGood := true
		for _, neighbor := range neighbors {
			if H[neighbor-1] >= curH {
				isGood = false
				break
			}
		}
		if isGood {
			good++
		}
	}
	return good
}


Measured memory_bytes: 17900
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
#define lp(k,a) for(int k=1;k<=a;k++)
#define lp0(k,a) for(int k=0;k<a;k++)
#define lpn(k,n,a) for(int k=n;k<=a;k++)
#define lpd(k,n,a) for(int k=n;k>=a;k--)
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d %d",&a,&b)
#define ll long long
#define MAX 100000

using namespace std;

char str[100010];
ll a[100010];
int n,m;

int main()
{
   // freopen("in.txt","r",stdin);
    ll re=0;
    cin>>a[1]>>a[2]>>a[3]>>a[4];
    cin>>n;
    a[1]=a[1]*4;
    a[2]*=2;
    if(n%2 ==0)
    {
        re=a[1]*n;
        re=min(re,a[2]*n);
        re=min(re,a[3]*n);
        re=min(re,(ll)((n)/2*a[4]));
    }
    else
    {
        re=a[1]*n;
        re=min(re,a[2]*n);
        re=min(re,a[3]*n);

        re=min(re,(ll)((n-1)/2*a[4]+a[1]));
        re=min(re,(ll)((n-1)/2*a[4]+a[2]));
        re=min(re,(ll)((n-1)/2*a[4]+a[3]));
    }


    cout<<re<<endl;

    return 0;
}


Measured memory_bytes: 256
program ec12;
var 
	a,b,site:array[1..100001] of int64;
	j:int64;
	n,m,i,max,tot:longint;
procedure qsrt(l,r:longint);
var 
	s,v:int64;
	i,j:longint;
begin 
	i:=l; j:=r; v:=a[(l+r) div 2];
	repeat 
	while a[i]<v do inc(i);
	while a[j]>v do dec(j);
	if i<=j then 
	begin 
		s:=a[i];
		a[i]:=a[j];
		a[j]:=s;
		inc(i);
		dec(j);
	end;
	until i>=j;
	if l<j then qsrt(l,j);
	if i<r then qsrt(i,r);
end; 
begin 
	readln(n);
	for i:=1 to n do 
	read(a[i]);
	qsrt(1,n);
	m:=0;
	a[n+1]:=0;	
	for i:=n downto 1 do 
	begin
		if a[i]=a[i+1] then 
		begin 
			if m=0 then 
			begin 
				m:=1;
				j:=a[i];
				a[i]:=-1;
			end
			else
			begin 
				writeln(j*a[i]);
				halt;
			end;
		end;
	end;
	writeln(0);
end. 

Measured memory_bytes: 896
#include <bits/stdc++.h>
//#define DEBUG

using namespace std;
int n, a[137510];
struct node {
    int id, point;
} node[1<<20];

void add(int id, int x)
{
    id=n-1+id;
    node[id].point+=x;

    while (id>0) {
        id=(id-1)/2;
        int c1=2*id+1, c2=2*id+2;
        if (node[c1].point>=node[c2].point)
            node[id]=node[c1];
        else
            node[id]=node[c2];
    }
}

void print()
{
#ifdef DEBUG
    int k=1;
    int x=0;
    while (true) {
        for(int i=0;i<k;++i) printf("(%d %d)", node[x+i].id, node[x+i].point);
        puts("");
        x+=k;
        k<<=1;
        if (x>=n) break;
    }
    puts("");
#endif
}

int main()
{
    int m, r, l;
    scanf("%d%d%d", &m, &r, &l);
    n=1;
    while (n<m) n<<=1;
    for(int i=0;i<m;++i) node[n-1+i].id=i;

    int pt=0;
    for(int i=0;i<r;++i) {
        int d, t, x;
        scanf("%d%d%d", &d, &t, &x);

        if (pt<t) {
            int id=node[0].id;
            a[id]+=t-pt;
        }
        add(d-1, x);
        print();
        pt=t;
    }
    print();
    a[node[0].id]+=l-pt;
#ifdef DEBUG
    for(int i=0;i<n;++i) printf("%d ", a[i]); puts("");
#endif
    printf("%d\n", 1+(max_element(a, a+n)-a));
}

Measured memory_bytes: 3148