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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()

int get_int(){int x;scanf("%d",&x);return x;}

typedef long long ll;

const int mod = 998244353;
inline int mul(int x,int y){return 1ll*x*y%mod;}
int add(int x,int y) {return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y) {return x-y>=0?x-y:x-y+mod;}
int sq(int x){return 1ll*x*x%mod;}
int pows(int a,int b){return b == 0?1:(b&1?mul(a,sq(pows(a,b/2))):sq(pows(a,b/2)));}


const int maxn = 305;
int cnt[maxn*maxn];
int cnt2[maxn*maxn];

int sum;
int N;





void cal(int n,vector<int> &vi){
    cnt[0] = 1;
    cnt2[0] = 1;
    _for(i,0,N){
        int l = vi[i];
        for(int j = sum;j>=0;j--){
            cnt2[j] = add(cnt2[j],cnt2[j]);
            if(j-l >= 0) {
                cnt[j] = add(cnt[j],cnt[j-l]);
                cnt2[j] = add(cnt2[j],cnt2[j-l]);
            }
        }
    }
}

int main()
{
    vector<int> vi;
    N = get_int();
    _for(i,0,N){
        int num = get_int();
        sum += num;
        vi.push_back(num);
    }
    sort(ALL(vi));

    int ans = pows(3,N);
    //printf("all:%d\n",ans);

    cal(N,vi);
    //_rep(i,0,sum) printf("%d\n",cnt2[i]);

    _rep(i,(sum+1)/2,sum){
        ans = sub(ans,mul(3,cnt2[i]));
        //printf("%d\n",cnt2[i]);
    }

    if(!(sum&1)){
        ans = add(ans,mul(cnt[sum/2],3));
    }

     printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

double gets(double x, double h){
    return 2 * x * sqrt( x * x / 4 + h * h) + x * x;
}

int main(){
    int x, h;
    cout << fixed << setprecision(10);
    while(true){
        cin >> x;
        cin >> h;
        if(x == 0 && h == 0) break;
        cout << gets(x, h) << endl;
    }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll cnt = 0;
    while(b <= a) {
        ++cnt;
        b *= 2;
    }
    while(c <= b) {
        ++cnt;
        c *= 2;
    }
    if(cnt <= k) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    ll N, M;
    cin >> N >> M;
    // ll ans = (M - 2 * N) / 4;
    // if(ans < 0) cout << M / 2 << endl;
    // else{
    //     ll a1 = min(N + ans, M / 2 - ans);
    //     ans++;
    //     ll a2 = min(N + ans, M / 2 - ans);
    //     cout << max(a1, a2) << endl;
    // }
    if(N > M / 2) cout << M / 2 << endl;
    else cout << N + (M - 2 * N) / 4 << endl;
}

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

typedef struct node{
	int key;
	struct node *parent,*left,*right;
}Node;

Node *root,*NIL;

void insert(int k);
Node* find(int k);
void delete(int k);
void inOrder(Node *x);
void preOrder(Node *x);

int main(){
	int i,n,x;	scanf("%d",&n);
	char com[10];

	for(i=0;i<n;i++){
		scanf("%s",com);
		if(com[0]=='i'){
			scanf("%d",&x);
			insert(x);

		}else if(com[0]=='p'){
			inOrder(root);
			printf("\n");
			preOrder(root);
			printf("\n");
		}else if(com[0]=='f'){
			scanf("%d",&x);
			if(find(x)!=NIL)printf("yes\n");
			else printf("no\n");
		}else{
			scanf("%d",&x);
			delete(x);
		}
	}
	return 0;
}

void insert(int k){
	Node *y=NIL, *x=root, *z;

	z=(Node*)malloc(sizeof(Node));

	z->key=k;	z->left=NIL;	z->right=NIL;

	while(x!=NIL){
		y=x;
		if(k < x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	z->parent=y;

	if(y==NIL)root=z;
	else{
		if(k < y->key){
			y->left = z;
		}else{
			y->right=z;
		}
	}
}

Node* find(int k){
	Node* p=root;

	while(p!=NIL){
		if(p->key==k){
			return p;
		}

		if(k < p->key)p=p->left;
		else p=p->right;
	}

	return NIL;
}

void delete(int k){
	Node *tgt=find(k),*del,*ch;

	if(tgt->left==NIL || tgt->right==NIL){
		del=tgt;
	}else{
		del=tgt->right;
		while(del->left!=NIL)del=del->left;
	}

	if(del->left!=NIL){
		ch=del->left;
	}else{
		ch=del->right;
	}
	if(ch!=NIL)	ch->parent=del->parent;

	if(del->parent==NIL){
		root=ch;
	}else{
		if(del==del->parent->left){
			del->parent->left=ch;
		}else{
			del->parent->right=ch;
		}
	}

	if(del!=tgt)tgt->key=del->key;

	free(del);
	return;
}

void inOrder(Node* x){
	if(x==NIL)return;
	inOrder(x->left);
	printf(" %d",x->key);
	inOrder(x->right);
}
void preOrder(Node* x){
	if(x==NIL)return;
	printf(" %d",x->key);
	preOrder(x->left);
	preOrder(x->right);
}



Measured memory_bytes: 20488
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    A = [list(input().rstrip()) for _ in range(N)]
    B = [list(input().rstrip()) for _ in range(M)]
    mv = N - M + 1
    for i in range(mv):
        for j in range(mv):
            sub_A = [r[j:j+M] for r in A[i:i+M]]
            if sub_A == B:
                print("Yes")
                exit()
    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 70588
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
a = int(input())
b = make_divisors(a)
b_len = len(b)
if b_len % 2 == 0:
    print(b[b_len//2-1] + b[b_len//2] - 2)
else:
    print(2 * b[b_len//2 ] - 2)

Measured memory_bytes: 3272
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
const int maxn=100010;
struct Edge{int y,c,w;};
struct Que{int id,w,u,v;};
int n,q,tot;
vector<Edge>G[maxn],e[maxn];
vector<Que>qs[maxn];
int a[maxn],ans[maxn];
int fa[maxn],dep[maxn];
int sz[maxn],Head[maxn],dfn[maxn];//hld
int rk[maxn];
int cnt[maxn],sum[maxn];
int pre(int x,int pr,int d){
	dep[x]=d,sz[x]=1;
	for(auto e:G[x])if(e.y!=pr){
		sz[x]+=pre(e.y,x,d+e.w);
		fa[e.y]=x;
		if(sz[e.y]>sz[a[x]])a[x]=e.y;
	}
	return sz[x];
}
void dfs(int x,int hd){
	Head[x]=hd,dfn[x]=++tot,rk[tot]=x;
	if(a[x]>0){
		dfs(a[x],hd);
		for(auto &e:G[x])if(e.y!=fa[x]&&e.y!=a[x]){
			dfs(e.y,e.y);
		}
	}
}
int lca(int x,int y){
	while(Head[x]!=Head[y]){
		if(dep[Head[x]]>dep[Head[y]])x=fa[Head[x]];
		else y=fa[Head[y]];
	}
	if(dep[x]<dep[y])return x;
	else return y;
}
int get(int bit[],int pos){
	int ret=0;
	while(pos>0){
		ret+=bit[pos];
		pos-=(pos&(-pos));
	}
	return ret;
}
void add(int bit[],int pos,int val){
	while(pos<=n){
		bit[pos]+=val;
		pos+=(pos&(-pos));
	}
}
int calc(int bit[],int u,int v){
	int ret=0;
	while(Head[u]!=Head[v]){
		if(dep[Head[u]]>dep[Head[v]]){
			ret+=get(bit,dfn[u])-get(bit,dfn[Head[u]]-1);
			u=fa[Head[u]];
		}else{
			ret+=get(bit,dfn[v])-get(bit,dfn[Head[v]]-1);
			v=fa[Head[v]];
		}
	}
	ret+=get(bit,max(dfn[u],dfn[v]))-get(bit,min(dfn[u],dfn[v]));
	return ret;
}
inline int dis(const int &x,const int &y){
	return dep[x]+dep[y]-(dep[lca(x,y)]<<1);
}
void solve(){
	for(int col=1;col<n;col++){
		for(int i=0;i<e[col].size();i++){
			Edge &ce=e[col][i];
			if(dep[ce.y]>dep[ce.c]){
				add(sum,dfn[ce.y],ce.w);
				add(cnt,dfn[ce.y],1);
			}else{
				add(sum,dfn[ce.c],ce.w);
				add(cnt,dfn[ce.c],1);
			}
		}
		for(int i=0;i<qs[col].size();i++){
			Que &q=qs[col][i];
			ans[q.id]=dis(q.u,q.v)+q.w*calc(cnt,q.u,q.v)-calc(sum,q.u,q.v);
		}
		for(int i=0;i<e[col].size();i++){
			Edge &ce=e[col][i];
			if(dep[ce.y]>dep[ce.c]){
				add(sum,dfn[ce.y],-ce.w);
				add(cnt,dfn[ce.y],-1);
			}else{
				add(sum,dfn[ce.c],-ce.w);
				add(cnt,dfn[ce.c],-1);
			}
		}
	}
}
int main(){
	cin>>n>>q;
	for(int i=1,x,y,c,w;i<n;i++){
		cin>>x>>y>>c>>w;
		G[x].pb((Edge){y,c,w});
		G[y].pb((Edge){x,c,w});
		e[c].pb((Edge){x,y,w});
	}
	pre(1,-1,0);
	dfs(1,1);
	for(int i=1,x,y,u,v;i<=q;i++){
		cin>>x>>y>>u>>v;
		qs[x].pb(Que{i,y,u,v});
	}
	solve();
	for(int i=1;i<=q;i++)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 25056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a, b, c, count = 3;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		if(a == b && a == c)count = 1;
		else if(a == b && a != c)count = 2;
		else if(a == c && a != b)count = 2;
		else if(b == c && a != b)count = 2;
		
		System.out.println(count);
		
		sc.close();
	}

}


Measured memory_bytes: 20820
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main(){
	int a,b,c=1,ans=0;
	cin>>a>>b;
	while(1){
		if(c>=b){
			break;
		}
		c+=a-1;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"575
" => r"Yes",

r"123
" => r"No",

r"812
" => r"No"
}

use std::cmp;
use std::cmp::{max, min};
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: String,
    }

    if n.chars().rev().collect::<String>() == n {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
// Custom Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)
#define LF          '\n'

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '\0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}}

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

    int H, W;
    cin >> H >> W;

    int cnt = 0;
    rep(i, H) {
        string s; cin >> s;
        cnt += count(all(s), '#');
    }

    puts(cnt == H + W - 1 ? "Possible" : "Impossible");

    return 0;
}



Measured memory_bytes: 256
a,b,c = map(int,input().split())
d = 0
lis = [a,b]
for i in range(c):
    g = d % 2
    if lis[g]%2 == 1:
        lis[g] -= 1
    w = lis[g] / 2
    p = (d+1) % 2
    lis[g] = int(lis[g]/2)
    lis[p] += int(w)  

    d += 1

print(lis[0],lis[1])



Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

int main() {
	int n, m;
	cin >> n >> m;
	bool a = true;
	int b = 0;
	rep(i, m) {
		if (n % 2 == 0) {
			if (m == 1) {
				cout << 1 << " " << 2 << endl;
				return 0;
			}
			if (n/2-1<=b)a = false;
			if (a) {

				cout << i + 1 << " " << n - i << endl;
			}
			else {
				cout<< i + 1 << " " << n - i - 1 << endl;
			}
			b += 2;
		}
		else {
			cout << i + 1 << " " << n - i << endl;
		}
	}
}


Measured memory_bytes: 3168
N = list(input())
N = int(N[-1])

if N == 2 :
    print('hon')
elif N == 4 :
    print('hon') 
elif N == 5 :
    print('hon')
elif N == 7 :
    print('hon')
elif N == 9 :
    print('hon')
elif N == 0 :
    print('pon')
elif N== 1 :
    print('pon')
elif N== 6 :
    print('pon')
elif N== 8 :
    print('pon')
else :
    print('bon')


Measured memory_bytes: 9068
n = int(input())

import collections

s = []
for _ in range(n):
  s.append(input())

sc = collections.Counter(s)
m = sc.most_common()

cc = m[0][1]
r = []
for v, c in m:
  if c != cc:
    continue
  r.append(v)
  
for v in sorted(r):
  print(v)


Measured memory_bytes: 120144
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a(3*n);
    rep(i, 3*n){cin >> a[i];}
    sort(a.begin(), a.end(), greater<int>());

    ll ans = 0;
    rep(i, n){
        ans += a[2*i+1];
    }
    cout << ans << endl;
}



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

int main() {
    int n; scanf("%d", &n);
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v; scanf("%d%d", &u, &v);
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    vector<int> dep(n), fa(n);
    function<void(int, int)> Dfs = [&](int x, int p) {
        dep[x] = ~p ? dep[p] + 1 : 0;
        fa[x] = p;
        for (int u : g[x]) {
            if (u == p) continue;
            Dfs(u, x);
        }
    };

    Dfs(0, -1);
    int x = max_element(dep.begin(), dep.end()) - dep.begin();
    Dfs(x, -1);
    int y = max_element(dep.begin(), dep.end()) - dep.begin();
    int z = y, cnt = 0;
    while (z != -1) {
        cnt += g[z].size();
        z = fa[z];
    }
    cnt -= dep[y] - 1;
    if (cnt != n) {
        puts("-1");
        return 0;
    }

    vector<int> v;
    function<void(int, int, int)> Solve = [&](int x, int p, int k) {
        int ch = 0;
        for (int u : g[x]) ch += (u != p);
        for (int i = 1; i <= ch - 1; ++i) v.push_back(k + i);
        v.push_back(k);
        int cc = 0;
        for (int u : g[x]) {
            if (u == p) continue;
            if (g[u].size() > 1) {
                assert(cc++ == 0);
                Solve(u, x, k + ch);
            }
        }
        if (cc == 0) v.push_back(k + ch);
    };

    Solve(x, -1, 1);
    auto ans = v;
    v.clear();
    Solve(y, -1, 1);
    ans = min(ans, v);
    for (int u : ans) printf("%d ", u);
    puts("");
}


Measured memory_bytes: 17400
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s = sc.chars();
    let n = s.len();
    let mut is_valid: bool = true;
    for i in 0..n {
        if s[i] != s[n - 1 - i] {
            is_valid = false;
        }
    }
    for i in 0..(n - 1) / 2 {
        if s[i] != s[(n - 1) / 2 - 1 - i] {
            is_valid = false;
        }
    }
    if is_valid {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    C = [1]*N
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A-1] < H[B-1]:
            C[A-1] = 0
        elif H[A-1] == H[B-1]:
            C[A-1] = 0
            C[B-1] = 0
        else:
            C[B-1] = 0
    
    print(C.count(1))


if __name__ == '__main__':
    main()

Measured memory_bytes: 85632
N, M = list(map(int,input().split()))

Nmin = 1
Nmax = N

for i in range(M):
    L, R = list(map(int,input().split()))
    Nmin = max(L,Nmin)
    Nmax = min(R,Nmax)

print(max(Nmax-Nmin+1,0))

Measured memory_bytes: 3060
#include <stdio.h>
int main(){


int i;
int y;
int temp;
int h;
int a;
int b;
int c;
int d;
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a*b>=c*d){
	printf("%d",a*b);
	
}
else if(a*b<=c*d){
	printf("%d",c*d);
	
}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main( )
{
	string a;
	cin>>a; 
	if(a=="SUN")
	{
		cout<<7;
	 } 
	 else if(a=="SAT")
	 {
	 	cout<<1;
	 }
	 else if(a=="FRI")
	 {
	 	cout<<2;
	
	 }
	 else if(a=="THU")
	 {
	 	cout<<3;
	 }
	 else if(a=="WED")
	 {
	 	cout<<4;
	 }
	 else if(a=="TUE")
	 {
	 	cout<<5;
	 }
	 else
	 {
	 	cout<<6;
	 }
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    int x[N];
    REP(i,N) cin >> x[i];
    int maxv = INF;
    for(int i = 0; i <= N-K;++i){
        if(x[i+K-1] >= 0 && x[i] >= 0) maxv = min(maxv,abs(x[i+K-1]));
        else if(x[i+K-1] <= 0 && x[i] <= 0) maxv = min(maxv,abs(x[i]));
        else if(x[i+K-1] >= 0 && x[i] <= 0) maxv = min(maxv,2*min(abs(x[i+K-1]),abs(x[i])) + max(abs(x[i+K-1]),abs(x[i])) );
    }
    cout << maxv << endl;
}

Measured memory_bytes: 640
typedef long long ll;

#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int w = getInt();
  const int h = getInt();

  vector<int> p(w);
  vector<int> q(h);

  REP(i,w) p[i] = getInt();
  REP(i,h) q[i] = getInt();

  int wc = 0;
  int hc = 0;

  vector<pair<int, int> > v;
  REP(i,w) v.push_back(make_pair(p[i], 0));
  REP(i,h) v.push_back(make_pair(q[i], 1));

  sort(v.begin(), v.end());

  ll ans = 0;
  REP(i,w+h){
    const pair<int, int> c = v[i];
    const ll cost = c.first;
    const int t = c.second;
    if(t == 0){
      ans += cost * (1 + h - hc);
      wc++;
    }else{
      ans += cost * (1 + w - wc);
      hc++;
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 3188
//#include <bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;

int n;
string s;
string ans;
int cnt[150];
int c[150];
int main(){
    //printf("%d",'z');
    cin>>n;
    REP(i,140)cnt[i]=1000000;
    REP(i,n){
        cin>>s;
        REP(j,150)c[j]=0;
        REP(j,s.size()){
            c[s[j]]++;
        }
        for(int j='a';j<='z';j++){
            cnt[j]=min(cnt[j],c[j]);
        }
        
        
    }
    for(int j='a';j<='z';j++){
        REP(k,cnt[j])ans+=j;
    }
    cout<<ans;
    

    return 0;
}

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

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

string wall[9];

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

inline int iswall(int cx,int cy,int d){
	switch(d){
		case 0:
			cy=2*cy;
			cx=cx;
			break;
		case 1:
			cy=2*cy+1;
			cx=cx;
			break;
		case 2:
			cy=2*cy;
			cx=cx-1;
			break;
		case 3:
			cy=2*cy-1;
			cx=cx;
			break;
	}
	if(cy<0||9<=cy||cx<0||5<=cx) return 0;
	return wall[cy][cx]=='1';
}

int main(void){
	rep(i,9){
		cin >> wall[i];
		if(wall[i].size()==4) wall[i]+="0";
	}
	cout << 'R';
	int cx=1,cy=0,cd=0;
	map<int,char> dir;
	dir[0]='R',dir[1]='D',dir[2]='L',dir[3]='U';
	while(1){
		rep(i,4){
			int nd=(cd+i+3)%4;
			if(iswall(cx,cy,nd)){
				cout << dir[nd];
				cy+=dy[nd],cx+=dx[nd],cd=nd;
				break;
			}
		}
		if(cx==0&&cy==0) break;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1188
n=int(input())
l=list(map(int,input().split()))
r=[]
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i]==l[j]==l[k] or l[i]==l[j] or l[j]==l[k] or l[i]==l[k]:
        continue
      a=l[i]+l[j]
      b=l[j]+l[k]
      c=l[i]+l[k]
      if a>l[k] and b>l[i] and c>l[j]:
        r.append([l[i],l[j],l[k]])
print(len(r))

Measured memory_bytes: 25368
#include <bits/stdc++.h>
using namespace std;
    long long n,m,s;
int main()
{
  cin>>n>>m;
  if ((n==1&&m==1)||(n==1&&m==2)||(n==2&&m==1)) s=1;
  else 
  if (n==1||m==1) s=max(n-2,m-2);
  else
  s=(n-2)*(m-2);
  cout<<s;
  return 0;
}


Measured memory_bytes: 256
import sys

MAX = 999999

def is_prime(n):
  if n == 2:return True
  if n % 2 == 0:return False
  for i in range(3,int(n**0.5)+1,2):
    if n % i == 0:return False
  return True

def prime_list(n):
  result = []
  if n >= 2:result.append(2)
  for i in range(3,n+1,2):
    if is_prime(i):result.append(i)
  return result

L = prime_list(int(MAX**0.5))

def is_prime_2(n):
  a = int(n ** 0.5)
  for i in L:
    if i > a:return True
    if n % i == 0:return False
  return True

def prime_count(n):
  result = 0
  if n >= 2:result+=1
  for i in range(3,n+1,2):
    if is_prime_2(i):result+=1
  return result

L2 = prime_list(MAX)

def prime_count_2(n):
  for i,v in enumerate(L2):
    if v > n:return i
  return len(L2)

for n in sys.stdin:
  print(prime_count_2(int(n)))

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

#define pb push_back
using namespace std;
 
int main()
{
 
 	
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

 	
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y; 	


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  int a[100010];
  vector<ll>ans;
  for ( int i = 0; i < N; i++ ) cin >> a[i];
  sort(a,a+N,greater<int>());
  int tmp = a[0];
  int cnt = 1;
  for ( int i = 1; i < N; i++ ) {
    if ( tmp == a[i] ) {
      cnt++;
      if( cnt == 2 ) ans.push_back(a[i]);
      else if ( cnt == 4 ) ans.push_back(a[i]);

      if ( ans.size() == 2 ) break;
      
    } else {
      tmp = a[i];
      cnt = 1;
    }
  }
  //  cout << ans.size() << endl;
  if ( ans.size() == 0 ) cout << 0 << endl;
  else if ( ans.size() == 2 ) cout << ans[0]*ans[1] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
	string a;
	cin >> a;
	if(a[0] == a[1] && a[1] == a[2]){
		cout << "Yes" << endl;
	}
	else if(a[1] == a[2] && a[2] == a[3]){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import std.stdio;
import std.math;
import std.string;
import std.conv;
import std.algorithm;

ulong n;
double length;
double[13] r;
double[13][13] cost;
double[1 << 13][13] memo;

void main(){
	string s;
	while (s = readln(), s) {
		string[] tmp = split(s);
		length = to!int(tmp[0]);
		for (int i = 1; i < tmp.length; i++) {
			r[i-1] = to!int(tmp[i]);
		}
		n = tmp.length- 1;
		for (int i = 0; i < n; i++) {
			memo[i] = -1;
			cost[i][n] = cost[n][i] = r[i];
			for (int j = 0; j < n; j++) {
				cost[i][j] = distance(r[i], r[j]);
			}
		}
		memo[n] = -1;
		n++;
		double ans = tsp(0,1);
		if (length < ans) writeln("NA");
		else writeln("OK");
	}
}

double distance(double r1, double r2){
	return 2.0*sqrt(r1*r2);
}

double tsp(int v, int b){
	if (memo[v][b] != -1) return memo[v][b];
	if (b == (1 << n) -1) return cost[v][0];

	double res = double.max;
	for (int w = 0; w < n; w++) {
		if (!(b & (1 << w))) res = min(res, cost[v][w] + tsp(w, b | (1 << w)));
	}
	return memo[v][b] = res;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

ll memo[1000];
ll fib(ll n) {
  if(n == 0) return 2;
  else if(n == 1) return 1;
  else if(memo[n]) return memo[n];
  else return memo[n] = fib(n-1) + fib(n-2);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  map<string, int> mp;
  int n; cin >> n;
  for(int i=0;i<n;++i) {
    string s; cin >> s;
    mp[s]++;
  }
  int m; cin >> m;
  for(int i=0;i<m;++i) {
    string s; cin >> s;
    mp[s]--;
  }
  int ans = 0;
  for(auto &e: mp) {
    //cout << e.first << ":" << e.second << endl;
    ans = max(ans, e.second);
  }
  cout << ans << endl;
}


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

int main(){

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m, 0));

    for (int i = 0; i < n;++i){
        cin >> c[i];
        for (int j = 0; j < m;++j){
            cin >> a[i][j];
        }
    }

    int cost = 0;
    int min_cost = 100000000;
    for (int bit = 0; bit < (1 << n); ++bit)
    {
        cost = 0;
        vector<int> udnerstand(m, 0);

        for (int i = 0; i < n; ++i)
        {
            if (bit & (1 << i))
            {
                cost += c[i];
                for (int j = 0; j < m;++j){
                    udnerstand[j] += a[i][j];
                }
            }
        }

        //check
        bool isOK = true;
        for (int i = 0; i < m;++i){
            if(udnerstand[i]<x){
                isOK = false;
            }
        }

        if(isOK && cost< min_cost){
            min_cost = cost;
        }
    }

    if(min_cost==100000000){
        min_cost = -1;
    }

    cout << min_cost << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
int main(){
    int a[5];
    int b[5];
    int c[5];
    for(int i = 0;i<5;i++){
        cin >> a[i];
        b[i] = a[i] % 10;
        c[i] = (a[i] / 10)*10 + 10;
        if(b[i] == 0){
            b[i] = 10;
            c[i] = c[i] - 10;
        }
    }
    int ans = 0;
    for(int i= 0;i<5;i++){
            ans = ans + c[i];
    }
    ans = ans -10;
    sort(b,b+5);
    cout << ans + b[0] << endl;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
         
    using namespace std;
                 
    #define pb push_back
    #define ll long long
    #define mp make_pair
    #define MOD 1000000007
    #define MAX 100000000
    #define MIN -1000000000
    #define LLINF 0x3f3f3f3f3f3f    
    #define INF 0x3f3f3f3f
    #define MAXN  100100

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int n, k;
        cin >> n >> k;
        vector<int> v(n + 1);
        for(int i = 1; i <= n; ++i){ 
            cin >> v[i];
        }
        vector<int> dp(n + 1, INF);
        dp[1] = 0;
        for(int i = 2; i <= n; ++i){   
            for(int j = 1; j <= min(k, i - 1); ++j){    
                dp[i] = min(dp[i], dp[i - j] + abs(v[i] - v[i - j]));
            }
        }
        cout << dp[n] << endl;
        return 0;
    }

Measured memory_bytes: 3996
import itertools,copy
H,W,K=map(int,input().split())
c=[]
for i in range(H):
    c.append(list(input()))
tmp=copy.deepcopy(c)
ans=0
for i in itertools.product([0,1], repeat=H+W):
    c=copy.deepcopy(tmp)
    for j in range(H):
        if(i[j]==0):
            for k in range(W):
                c[j][k]="R"
    for j in range(H,H+W):
        if(i[j]==0):
            for k in range(H):
                c[k][j-H]="R"
    s=0
    for i in range(H):
        s+=c[i].count("#")
    if(s==K):
        ans+=1
print(ans)

Measured memory_bytes: 9352
//package AtCoder;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[2*n];
		for(int i=0;i<2*n;i++)
			a[i]=sc.nextInt();
		Arrays.sort(a);
		
		int sum=0;
		for(int i=0;i<2*n;i=i+2)
		{
			sum=sum+a[i];
		}
		System.out.println(sum);

	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    ll n, ans=inf;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a.at(i);
    ll acu = accumulate(all(a), 0LL), sum=0;
    rep(i, n){
        sum += a.at(i);
        ll sum2 = acu-sum;
        ans = min(ans, abs(sum2-sum));
    }
    cout << ans;
}   

Measured memory_bytes: 1792
class Factorial():
    def __init__(self, mod=10**9 + 7):
        self.mod = mod
        self._factorial = [1]
        self._size = 1
        self._factorial_inv = [1]
        self._size_inv = 1
    
    def __call__(self, n):
        '''n! % mod '''
        return self.fact(n)
    
    def fact(self, n):
        '''n! % mod '''
        if n >= self.mod:
            return 0
        self.make(n)
        return self._factorial[n]
    
    def fact_inv(self, n):
        '''n!^-1 % mod '''
        if n >= self.mod:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        self.make_inv(n)
        return self._factorial_inv[n]
    
    def comb(self, n, r):
        ''' nCr % mod '''
        if r > n:
            return 0
        t = self.fact_inv(n-r)*self.fact_inv(r) % self.mod
        return self(n)*t % self.mod
    
    def comb_with_repetition(self, n, r):
        ''' nHr % mod '''
        t = self.fact_inv(n-1)*self.fact_inv(r) % self.mod
        return self(n+r-1)*t % self.mod
    
    def perm(self, n, r):
        ''' nPr % mod '''
        if r > n:
            return 0
        return self(n)*self.fact_inv(n-r) % self.mod
    
    def modinv(self, n):
        ''' n^-1 (mod p)'''
        n %= self.mod
        if n == 0:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        ## TODO better than extend_gcd
        return pow(n, self.mod-2, self.mod)
    
    def make(self, n):
        if n >= self.mod:
            n = self.mod
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1
    
    def make_inv(self, n):
        if n >= self.mod:
            n = self.mod
        self.make(n)
        if self._size_inv < n+1:
            for i in range(self._size_inv, n+1):
                self._factorial_inv.append(self.modinv(self._factorial[i]))
            self._size_inv = n+1


n, m, k = map(int, input().split())
mod = 998244353
comb = Factorial(mod).comb
s = 0
for i in range(k+1, n):
    t = comb(n-1, i) * m
    t %= mod
    t *= pow(m-1, n-1-i, mod)
    t %= mod
    s += t
    s %= mod
ans = pow(m, n, mod) - s
ans %= mod
print(ans)

Measured memory_bytes: 24988
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
#define ll long long
using namespace std;

int w[200005],r;
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n;
    cin>>n;

    for(int i=1; i<=n; ++i){
        char c;
        cin>>c;
        if(c=='W'){
            w[i] = w[i-1]+1;
        }
        else if(c=='R'){
            r++;
            w[i] = w[i-1];
        }
    }
    int ans = w[r];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4360
#include<stdio.h>
#include<math.h>
int main(){
 
  int i,n,score[1001],sum;
  double ave,sig,v;
 
   
  while(1){
 
    scanf("%d", &n );
    if ( n == 0 ) break;
     
    for ( i  = 0 ; i < n ; i++ ){
      scanf("%d", &score[i] );
    }
 
    sum = 0;
     
    for ( i = 0 ; i < n ; i++ ){
      sum = sum + score[i];
    }
     
    ave = 1.0 * sum / n;
 
    sig = 0;
     
    for ( i = 0 ; i < n ; i++ ){
      sig = sig + ( score[i] - ave ) * ( score[i] - ave );
    }
 
    v = sqrt( sig / n );
 
    printf("%.8lf\n", v );
 
  }
   
  return 0;
     
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

ll op(ll a, ll b) {
    return max(a, b);
}

const long long INF = 1e18;

ll e() {
    return -INF;
}
ll X, V;

bool f(ll S) {
    return S < V;
}

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

//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    atcoder::segtree<ll, op, e> seg(A);
    for(int q = 0; q < Q; q++) {
        ll T;
        cin >> T;
        if(T == 1) {
            ll X, V;
            cin >> X >> V;
            X--;
            seg.set(X, V);
        }
        if(T == 2) {
            ll L, R;
            cin >> L >> R;
            L--;
            cout << seg.prod(L, R) << endl;
        }
        if(T == 3) {
            cin >> X >> V;
            X--;
            cout << seg.max_right<f>(X) + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8972
import sys
input = sys.stdin.readline
S = list(input())[: -1]
s = 0
t = 0
res = len(S)
if S[0] == "S": s += 1
for i in range(1, len(S)):
  if S[i] == "S":
    s += 1
  else:
    if s > 0:
      res -= 2
      s -= 1
      t = 1
print(res)

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

int main() {
    
	int n; cin >> n;
	const int p = 2;
	vector<vector<int>> a(p, vector<int>(n));
	for (int i = 0; i < p; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for (int k = 0; k < n; k++) {
		int tmp = 0;
		for (int j = 0; j <= k; j++) {
			tmp += a[0][j];
		}
		for (int j = k; j < n; j++) {
			tmp += a[1][j];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
using namespace std;
int n, x, y;

int get_dist(int a, int b) {
	if(b <= x || a >= y) return b - a;
	else if(a >= x && b <= y) return min(b - a, (a - x) + (y - b) + 1);
	else if(a <= x && b >= y) return b - a - (y-x) + 1;
	else if(a <= x && b <= y) return min(b - a, y - b + x - a + 1);
	else if(a >= x && a <= y && b >= y) return min(b - a, a - x + b - y + 1);
}

int cnt(int k) {
	set<pair<int,int> > st;
	for(int i=1;i<=n;i++) {
		if(i + k <= n && get_dist(i, i+k) == k) st.insert(mp(i, i+k));

		if(i <= x && x - i < k){
			int moves = k - (x - i) - 1;
			int yl = y - moves;
			int yr = y + moves;

			//cout<<i<<": "<<yl<<", "<<yr<<" - "<<get_dist(i, yl)<<"\n";

			if(get_dist(i, yl) == k && i <= yl && yl <= n) st.insert(mp(i, yl));
			if(get_dist(i, yr) == k && i <= yr && yr <= n) st.insert(mp(i, yr));
		}
		else if(i > x && i < y) {
			int moves = k - (i - x) - 1;
			int yr = y + moves;
			int yl = y - moves;

			if(get_dist(i, yr) == k && i <= yr && yr <= n) st.insert(mp(i, yr));
			if(get_dist(i, yl) == k && i <= yl && yl <= n) st.insert(mp(i, yl));
		}
	}

	//for(auto i:st) cout<<i.first<<", "<<i.second<<"\n";

	return sz(st);
}

int main() {
	cin>>n>>x>>y;

	for(int i=1;i<n;i++) {
		cout<<cnt(i)<<"\n";
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

using ll = long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n) for(ll i=0;i<(n);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//static const ll MOD = 1000000007;
//static const ll INF = 1000000000;
//#define PI 3.14159265359

int main() {
    // input
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    // process
    rep(i, K) {
        ll max_i = max(A, B);

        if (C <= max_i) {
            C *= 2;
        } else if (B <= A) {
            B *= 2;
        }

        if (C > B && B > A) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3128
N = int(input())
A = [0] + [int(a) for a in input().split()] + [0]
s = sum([abs(A[i+1] - A[i]) for i in range(N+1)])
for i in range(1, N+1):
    print(s+abs(A[i+1]-A[i-1])-abs(A[i+1]-A[i])-abs(A[i]-A[i-1]))

Measured memory_bytes: 14048
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
        int ans_int = 0;
        String ans = "";
//        double ans_dob = 0;
        if(int1 > int2 && int2 !=1){
            ans = "Alice";
        }else if(int2 > int1 && int1 !=1){
            ans = "Bob";
        }else{
            ans = "Draw";
        }

        if(int1 == 1 && int2 !=1){
            ans = "Alice";
        }else if(int2 == 1 && int1 !=1){
            ans = "Bob";
        }


        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>

const int maxv = 105;
const long long int inf = 107374182400;

long long int dp[maxv][maxv];

int main ()
{
  int V, E;
  std::cin >> V >> E;

  for (int i=0; i<maxv; ++i)
    for (int j=0; j<maxv; ++j)
      {
        if (i==j)
          dp[i][j] = 0;
        else
          dp[i][j] = inf;
      }

  int s, t, d;
  for (int i=0; i<E; ++i)
    {
      std::cin >> s >> t >> d;
      dp[s][t] = d;
    }

  for (int k=0; k<V; ++k)
    {
      for (int i=0; i<V; ++i)
        {
          for (int j=0; j<V; ++j)
            {
              if (dp[i][k] != inf && dp[k][j] != inf)
                dp[i][j] = std::min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

  for (int i=0; i<V; ++i)
    {
      if (dp[i][i] < 0)
        {
          std::cout << "NEGATIVE CYCLE\n";
          return 0;
        }
    }

  for (int i=0; i<V; ++i)
    {
      for (int j=0; j<V; ++j)
        {
          if (dp[i][j] == inf)
            std::cout << "INF";
          else
            std::cout << dp[i][j];
          if (j<V-1) std::cout << ' ';
        }
      std::cout << std::endl;
    }

  return 0;
}



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

typedef long long ll;

int main() {
  ll nums[200009], min_v = 1e9;
  int N;
  cin >> N;

  memset(nums, 0, sizeof(nums));

  ll v;
  for (int i = 1; i <= N; i++) {
    cin >> v;
    nums[i] += nums[i - 1] + v;
  }

  int l = 1, m = 2, r = 3;
  ll sum1, sum2, sum3, sum4;

  for (; m <= N; m++) {
    sum1 = nums[l];
    sum2 = nums[m] - nums[l];
    sum3 = nums[r] - nums[m];
    sum4 = nums[N] - nums[r];

    while (abs(sum4 - sum3) > abs((nums[N] - nums[r + 1]) - (nums[r + 1] - nums[m]))) {
      r++;
      sum3 = nums[r] - nums[m];
      sum4 = nums[N] - nums[r];
    }

    while (abs(sum2 - sum1) > abs((nums[m] - nums[l + 1]) - (nums[l + 1]))) {
      l++;
      sum1 = nums[l];
      sum2 = nums[m] - nums[l];
    }

    min_v = min(min_v, max({sum1, sum2, sum3, sum4}) - min({sum1, sum2, sum3, sum4}));
  }
  cout << min_v << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#define nMax 100000
#define qMax 50000

int binarySearch(int key,int S[],int n){
  int left,right,mid;
  left=0;
  right=n;
  while(left<right){
    mid = (left+right)/2;
    if(S[mid] == key){
      return mid;
    }
    else if(key<S[mid]){
      right = mid;
    }
    else left = mid+1;
    
  }
  return 0;
}
  
int main(){

  int n,i,j,q,z,count=0;
  int S[nMax],T[qMax];

  scanf("%d",&n);

  if(n <= nMax){
    for(i=0;i<n;i++){
      scanf("%d",&S[i]);
    }
  }
  else printf("Not found\n");
  
    scanf("%d",&q);

    if(q <= qMax){
      for(j=0;j<q;j++){
	scanf("%d",&T[j]);
	if(binarySearch(T[j],S,n))
	  count++;	  
      }
    }
    else printf("Not found\n");

   

    printf("%d\n",count);

    return 0;
}



Measured memory_bytes: 2292
#include <stdio.h>
int main(void)
{
  int w,n,i,t,a,b;
  scanf("%d",&w);
  int ans[w+1];
  for(i=1;i<=w;i++)
    ans[i]=i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d,%d",&a,&b);
    t=ans[a];
    ans[a]=ans[b];
    ans[b]=t;
  }
  for(i=1;i<=w;i++)
    printf("%d\n",ans[i]);
  return 0;
}

Measured memory_bytes: 592
num=int(raw_input().strip())

lst=map(int,raw_input().strip().split())
def sort(lst,idx):
    tmp=lst[idx]
    idx-=1
    while idx>=0 and lst[idx]>tmp:
        lst[idx+1]=lst[idx]
        idx-=1
    lst[idx+1]=tmp

for ii in xrange(num):
    sort(lst,ii)
    print " ".join(str(i) for i in lst)


Measured memory_bytes: 4644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        long a = std.nextLong();
        long b = std.nextLong();
        long k = std.nextLong();

        long restA = Math.max(0, a - k);
        long restB = b;
        if (a - k < 0) {
            long count = k - a;
            restB =  Math.max(b - count, 0);
        }

        String res = restA + " " + restB;
        System.out.println(res);
    }
}


Measured memory_bytes: 21460