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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    if(n == 0) break;
    vector<pii> bt(n);
    bool f = false;
    rep(i,n){
      cin >> bt[i].first >> bt[i].second ;
      if( bt[i].first > bt[i].se){
        f = true;
      }
    }
    if(!f){
      sort(all(bt),[](const pair<int,int> &a, const pair<int,int> &b){ return a.se < b.se;});
      int tr = 0;
      for(auto it = bt.begin() ; it != bt.end(); ++it){
        if(tr > it->se) f = true;
        else{
          tr += it->fi;
          if(tr > it->se) f = true;
        }
        if(f) break;
      }
    }
    if(f){
      cout << "No" << endl;
    }
    else cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 3136
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    input = sys.stdin.buffer.readline

    N, M = map(int, input().split())
    adj = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    seen = [0] * (N+1)
    single = 0
    bipartite = 0
    not_bipartite = 0
    for v0 in range(1, N+1):
        if seen[v0] != 0:
            continue
        flg = 1
        que = deque()
        que.append(v0)
        seen[v0] = 1
        cnt = 0
        while que:
            v = que.popleft()
            cnt += 1
            for u in adj[v]:
                if seen[u] == 0:
                    seen[u] = -seen[v]
                    que.append(u)
                else:
                    if seen[u] == seen[v]:
                        flg = 0
        if cnt == 1:
            single += 1
        else:
            if flg:
                bipartite += 1
            else:
                not_bipartite += 1
    ans = N ** 2 - (N - single) ** 2
    ans += (bipartite + not_bipartite) ** 2
    ans += bipartite ** 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 91116
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    ll n,m,x;

    cin>>n>>m>>x;
    ll ans = 999999999999;
    vector<ll> c(n);
    vector< vector<int> > a(n, vector<int>(m));


    rep(i,n)
    {
        cin>>c[i];
        rep(j,m)
        {
            cin>>a[i][j];
        }
    }

    //bitAllListup

     for (int bit = 0; bit < (1<<n); ++bit)
      {
            vector<int> S;
        for (int i = 0; i < n; ++i) 
        {
            if (bit & (1<<i)) 
            { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }

        ll nowyen =0;
        vector<ll> nowpra(m);

        for (int i = 0; i < (int)S.size(); ++i) 
        {
            nowyen += c[S[i]];

            for(ll h=0;h<m;h++)  nowpra[h] += a[S[i]][h];
        }

        bool check =true;
        rep(q,m)
        {
            if(nowpra[q]<x) check = false;
        }

        if(check) ans = min(ans,nowyen);
    }

    if(ans!=999999999999) cout<<ans<<endl;
    else cout<<-1<<endl;

}

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

typedef long long ll;

const int mod = 998244353;
const int Maxn = 300005;

int fac[Maxn], inv[Maxn];
int n;
ll a, b, k;
int res;

int toPower(int a, int p)
{
	int res = 1;
	while (p) {
		if (p & 1) res = ll(res) * a % mod;
		p >>= 1; a = ll(a) * a % mod;
	}
	return res;
}

int Inv(int x) { return toPower(x, mod - 2); }

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

int main()
{
	fac[0] = inv[0] = 1;
	for (int i = 1; i < Maxn; i++) {
		fac[i] = ll(i) * fac[i - 1] % mod;
		inv[i] = Inv(fac[i]);
	}
	cin >> n >> a >> b >> k;
	for (int i = 0; i <= n; i++) {
		ll lft = k - a * ll(i);
		if (lft >= 0 && lft % b == 0) {
			int nd = lft / b;
			if (nd > n) continue;
			res = (res + ll(C(n, i)) * C(n, nd)) % mod;
		}
	}
	printf("%d\n", res);
	return 0;
}

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

long long int a, b, c;

int main(){
	scanf("%lld%lld%lld", &a, &b, &c);
	if (a % 2 == 0LL || b % 2LL == 0LL || c % 2LL == 0LL){
		puts("0");
		return 0;
	}
	long long int ans = min(a*b, min(a*c, b*c));
	printf("%lld\n", ans);
	return 0;
}

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

int n;
const int MAX = 1000006;

class BIT {
  int n,bit[MAX+2];
public:
  BIT( int n = MAX ): n(n){
    fill( bit, bit + MAX+1, 0 );
  }

  void add(int i,int x){
    while( i <= n ) {
      bit[i] += x;
      i += i&-i;
    }
  }
  int sum(int i){
    int s = 0;
    while( i > 0 ){
      s += bit[i];
      i-= i&-i;
    }
    return s;
  }
};

BIT used;
void view(){
  for(int i=1;i<10;i++)
    cout << used.sum(i)-used.sum(i-1) <<" ";
  cout << endl;
}

int main(){
  cin >> n;  
  int cnt = 0;
  for(int i=0;i<n;i++){
    int x; cin >> x; x++;
    int t = x;
    if( used.sum(1) ) {
      cout << "No" << endl;
    } else if( x > 1000000 ) {
      cout << "Yes" << endl;
    } else if( used.sum(x) == x-1 && used.sum(MAX) > x-1 ) 
      cout << "No" << endl;
    else {      
      cout << "Yes" << endl;
      while( used.sum(x)-used.sum(x-1) ) used.add(x--,-1);
      used.add(x,1);
    }
    //view();
  }
}

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

using namespace std;

int main(void){
    vector<int>list;
    while (true) {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
    
        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                if (j == i) continue;
    
                for (int k = j; k <= n; k++) {
                    if (k == i) continue;
                    if (k == j) continue;
    
                    if (i + j + k == x) {
                        count++;
                    }
                }
            }
        }
        
        list.push_back(count);
    }
    
    for (auto count : list) {
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 3084
const process = (a: string[]): number => {
		const aa = a.map((e) => parseInt(e))
		if (aa[0] >= aa[1] && aa[0] >= aa[2]) {
			return aa[0] * 10 + aa[1] + aa[2]
		}
		if (aa[1] >= aa[0] && aa[1] >= aa[2]) {
			return aa[0] + aa[1] * 10 + aa[2]
		}
		if (aa[2] >= aa[0] && aa[2] >= aa[1]) {
			return aa[0] + aa[1] + aa[2] * 10
		}
	}

	const Main = (input: string): void => {
		//const n: number = parseInt(input)
		const a: string[]  = input.split(" ")
		//const aa: string[][]  = input.split("\n").split(" ")
		const answer = process(a)
		console.log(answer)
	}

	/*
	// デバッグ用
	Main("1 5 2") // 53
	console.log()

	Main("9 9 9") // 108
	console.log()

	Main("6 6 7") // 82
	*/

	// 提出時はこちらをアクティブにする
	Main(require("fs").readFileSync("/dev/stdin", "utf8"))
}

Measured memory_bytes: 7500
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod = 1e9 + 7;
using namespace std;
void add(int& a , int b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
} 
int main()
{
	
	string k ; cin >> k;
	int d ; cin >> d;
	int n; n = k.size() ;
	vector<vector<int> > dp(d , vector<int>(2)) ;
	dp[0][0] = 1 ;
	for(int i = 0 ; i< n ; i++){
		vector<vector<int> > new_dp(d , vector<int> (2)) ;
		for(int sum = 0 ; sum < d; sum++){
			for(int sum_already = 0 ; sum_already < 2 ; ++sum_already){
				for(int digit = 0 ; digit < 10 ; ++digit){
					if(digit > k[i] - '0' && !sum_already) break ;
					add(new_dp[(sum + digit) % d][sum_already || digit < k[i] - '0'] , dp[sum][sum_already]) ;
				}
			}
		}
		dp = new_dp ;
	}
	add(dp[0][0] , dp[0][1]) ;
	dp[0][0] -= 1;
	if(dp[0][0] < 0 ) dp[0][0] += mod;
	cout << dp[0][0]  << "\n" ;
	
	return 0;
}
	



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

int main() {

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;

	vector<int> red_all(a), green_all(b), colorless(c);

	for(int i = 0; i < a; i++) {
		int here; cin >> here;
		red_all[i] = here;
	}

	for(int i = 0; i < b; i++) {
		int here; cin >> here;
		green_all[i] = here;
	}

	for(int i = 0; i < c; i++) {
		int here; cin >> here;
		colorless[i] = here;
	}

	sort(red_all.begin(), red_all.end());
	reverse(red_all.begin(), red_all.end());
	sort(green_all.begin(), green_all.end());
	reverse(green_all.begin(), green_all.end());

	priority_queue<int> pq;
	ll ans = 0;

	for(int i = 0; i < x; i++) {
		pq.push(-red_all[i]);
		ans += red_all[i];
	}

	for(int i = 0; i < y; i++) {
		pq.push(-green_all[i]);
		ans += green_all[i];
	}

	sort(colorless.begin(), colorless.end());
	reverse(colorless.begin(), colorless.end());

	ll cnt_now = ans;
	for(int k = 0; k < c; k++) {
		int here = colorless[k];
		int worst = -pq.top(); 
		pq.pop();
		ans = max(ans, cnt_now - worst + here); 
		cnt_now -= (ll)worst; cnt_now += (ll)here;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 2552
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, a, b) = (v[0], v[1], v[2]);
    println!("{}", min(n * a, b));
}

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

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


Measured memory_bytes: 4352
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
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...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

main(){
	int n,m,ans=0;
	cin>>n>>m;
	int p[n];rep(i,n)cin>>p[i];
	UnionFind uf(111111);
	rep(i,m){
		int x,y;
		cin>>x>>y;
		uf.unite(x,y);
	}
	rep(i,n){
		if(uf.find(i+1)==uf.find(p[i]))ans++;
	}
	dans;
}


Measured memory_bytes: 1920
n=int(input())
a=[0]*n
for i in range(n):
    a[i]=int(input())
ans=0
for i in range(n):
    if i==0:
        ans+=a[i]//2
        a[i]=a[i]-(a[i]//2)*2
    else:
        if a[i-1]==0:
            ans+=a[i]//2
            a[i]=a[i]-(a[i]//2)*2
        else:
            if a[i]>=1:
                ans+=1
                a[i-1]-=1
                a[i]-=1
            ans+=a[i]//2
            a[i]=a[i]-(a[i]//2)*2
print(ans)


Measured memory_bytes: 46340
#include<cstdio>
#include<algorithm>

using namespace std;

int N;
int A[100100];

void input(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%d", A + i);
}

int calc(){
	sort(A, A + N);
	int ans = 0;
	int prv = 0;
	for(int i = 0; i < N; ++i){
		int x = N - i;
		int dif = A[i] - prv;
		if(dif % 2 == 1) ans ^= x;
		prv = A[i];
	}
	return ans;
}

int main(){
	input();
	int val = calc();
	if(val != 0) printf("first\n");
	else printf("second\n");
	return 0;
}


Measured memory_bytes: 512
import math
n = int(input())
x = [0]*n
y = [0]*n
for i in range(n):
  x[i], y[i]=map(int, input().split())
total = 0
pat = math.factorial(n)
for i in range(n):
  for j in range(n-i):
    k = j+i
    l = math.sqrt((x[i]-x[k])**2+(y[i]-y[k])**2)
    total+= l
total  = total*(pat*(n-1)//((n*(n-1))/2))/pat
print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct Node{
    int left,right,parent;
    Node(){ left=right=parent=-1; }
};
Node tree[25];
void preprint(int n){
    printf(" %d",n);
    if(~tree[n].left) preprint(tree[n].left);
    if(~tree[n].right) preprint(tree[n].right);
}
void inprint(int n){
    if(~tree[n].left) inprint(tree[n].left);
    printf(" %d",n);
    if(~tree[n].right) inprint(tree[n].right);
}
void posprint(int n){
    if(~tree[n].left) posprint(tree[n].left);
    if(~tree[n].right) posprint(tree[n].right);
    printf(" %d",n);
}
int main(){
    int n;
    scanf("%d",&n);
    int id,lef,rig;
    for(int i=0;i<n;++i){
        scanf("%d%d%d",&id,&lef,&rig);
        tree[id].left=lef; tree[id].right=rig;
        if(~lef) tree[lef].parent=id;
        if(~rig) tree[rig].parent=id;
    }
    int root=0;
    while(~tree[root].parent){ root=tree[root].parent; }
    printf("Preorder\n");
    preprint(root);
    putchar('\n');
    printf("Inorder\n");
    inprint(root);
    putchar('\n');
    printf("Postorder\n");
    posprint(root);
    putchar('\n');
    return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    vector <ll> dp(n);
    for (int i = 1; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n - 1] << '\n';
}


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

int main(){
	int N, Y;
	cin >> N >> Y;
	
	int i, j, k;
	for(i=0; i<=N; i++){
		for(j=0; j<=N-i; j++){
			k=N-i-j;
			if(Y == i*10000+j*5000+k*1000){
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	
	cout << -1 << " " << -1 << " " << -1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<set>
using namespace std;
#define PI 3.14159265358979
#define rep(i,n) for(int i=0;i<n;i++)


int main(void)
{
int n;
cin >>n;
vector<int> top(n);
vector<int> btm(n);

rep(i,n)
{
    cin>>top[i];
}
rep(i,n)
{
    cin>>btm[i];
}

int ans =0;


rep(i,n)
{
    int sum =0;
    for(int j=0;j<=i;j++)
    {
        sum+=top[j];
    }

    for(int k =i;k<n;k++)
    {
        sum+=btm[k];
    }


    ans =max(ans,sum);
}


cout<<ans<<endl;
}






Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.rmi.server.ExportException;
import java.util.Arrays;
        import java.util.Scanner;

class Main {
    static Scanner sc;

    private static void nextArr(int[] h) {
        for(int i = 0; i < h.length; i++) h[i] = sc.nextInt();
    }

    private static int nextInt() {
        return sc.nextInt();
    }

    private static void print(Object... vals) {
        for(int i = 0; i < vals.length; i++) {
            if (i != vals.length - 1) {
                System.out.print(vals[i] + ",");
            } else {
                System.out.print(vals[i]);
            }
        }
        System.out.println();
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        int n = s.length();
        int m = t.length();

        int[][] dp = new int[n + 1][m + 1];
        int[][][] prev = new int[n + 1][m + 1][2];
        for(int i = 0; i <= n; i++) {
            for (int j = 0; j <= m; j++) {
                dp[i][j] = Integer.MIN_VALUE;
                dp[i][0] = 0;
                dp[0][j] = 0;
                prev[i][j][0] = -1;
                prev[i][j][1] = -1;
            }
        }

        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                char left = s.charAt(i - 1);
                char right = t.charAt(j - 1);
                if (left == right && dp[i - 1][j - 1] != Integer.MIN_VALUE) {
                    int val = dp[i - 1][j - 1] + 1;
                    if (val >= dp[i][j]) {
                        dp[i][j] = val;
                        prev[i][j][0] = i - 1;
                        prev[i][j][1] = j - 1;
                    }
                }
                if (left != right) {
                    if (dp[i][j - 1] != Integer.MIN_VALUE) {
                        int val = dp[i][j - 1];
                        if (val >= dp[i][j]) {
                            dp[i][j] = val;
                            prev[i][j][0] = i;
                            prev[i][j][1] = j - 1;
                        }
                    }
                    if (dp[i - 1][j] != Integer.MIN_VALUE) {
                        int val = dp[i - 1][j];
                        if (val >= dp[i][j]) {
                            dp[i][j] = val;
                            prev[i][j][0] = i - 1;
                            prev[i][j][1] = j;
                        }
                    }
                }
            }
        }
        int x = n;
        int y = m;
        StringBuffer ans = new StringBuffer();
        while(x > 0 && y > 0) {
            int px = x;
            int py = y;
            x = prev[px][py][0];
            y = prev[px][py][1];
            if (x >= 0 && y >= 0 && x == px - 1 && y == py - 1) {
                ans.append(s.charAt(px - 1));
            }
        }
        print(ans.reverse().toString());
    }
}


Measured memory_bytes: 387264
while True:
    n, x = [int(i) for i in input().split()]


    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s+1, n):
            for e in range(m+1, n+1):
                if x == sum([s, m, e]):
                    count += 1

    print(count)

Measured memory_bytes: 7668
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
N,K = inputlist()
ans = 0
if K == 0:
    print(N**2)
    exit()
for i in range(K+1,N+1):
    d = i-K
    l = N // i
    m = N % i
    ans += d*l
    ans += max(0,m-K+1)
print(ans)


Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n;
	ll m;
	while (scanf("%d%lld", &n, &m), n | m)
	{
		ll p[1024];
		for (int i = 0; i < n; ++i)
			scanf("%lld", p + i);
		p[n] = 0;
		vector<ll> two;
		for (int i = 0; i <= n; ++i)
			for (int j = i; j <= n; ++j)
				two.push_back(p[i] + p[j]);
		sort(all(two));

		ll res = 0;
		foreach (it, two)
		{
			int k = lower_bound(all(two), m - *it) - two.begin();
			--k;
			if (k >= 0)
				max_swap(res, *it + two[k]);
		}
		printf("%lld\n", res);
	}
}

Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
const ll INF=1e9+7;
const ll N = 100001;
ll a,b,c,ans=0;
ll aw,bw,cw;
int main(){
	cin>>a>>b>>c;
	if(a%2==0&&a==b&&b==c){
		cout<<-1<<endl;
		return 0;
	}
	while(1){
		if(a%2==1||b%2==1||c%2==1){
			break;
		}
		ans++;
		aw=(b/2+c/2);
		bw=(a+c)/2;
		cw=(a+b)/2;
		a=aw;
		b=bw;
		c=cw;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,s[200001],u[200001];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>s[i],u[i]=s[i];
	sort(s+1,s+n+1);
	for(int i=1;i<=n;i++)
	{
		if(s[n]==u[i])
			cout<<s[n-1]<<endl;
		else
			cout<<s[n]<<endl;
	}
	return 0;
}

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	ll a, b;

	cin >> a >> b;
	cout << (a * b) << endl;

	return 0;
}


Measured memory_bytes: 3628
from collections import deque

def main():
  n=int(input())
  a=[0]*n
  for i in range(n):
    a[i]=deque(list(map(lambda x:int(x)-1,input().split())))
  tmp=set()
  for p1,p in enumerate(a):
    p2=p[0]
    if p1==a[p2][0]:
      tmp.add(p1)
      tmp.add(p2)
  q=deque(tmp)
  for i in tmp:
    a[i].popleft()
  
  day=0
  while True:
    day+=1
    tmp=set()
    while q:
      p1=q.popleft()
      if len(a[p1])==0: continue;
      p2=a[p1][0]
      if p1==a[p2][0]:
        tmp.add(p1)
        tmp.add(p2)
    q=deque(tmp)
    for i in tmp:
      a[i].popleft()
    tmp=set()
    if len(q)==0: break;
    
  for i in a:
    if i:
      print(-1)
      exit()
  print(day)


if __name__=='__main__':
  main()

Measured memory_bytes: 42004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, k, a[200008];
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	map<ll, vector<ll>> mp;
	cin >> n >> k;
	rep(i, 1, n){cin >> a[i];}
	a[0] = 0;
	mp[0].push_back(0);
	rep(i, 1, n){
		a[i] += a[i-1]-1;
		a[i] += k;
		a[i] %= k;
		
		mp[a[i]].push_back(i);
	}
	
	ll ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		vector<ll> buf = (*itr).second;
		if(buf.size() > 1){
			//rep(r, 0, buf.size()-1){cout << buf[r] << " ";}cout << endl;
			ll l = 0;
			rep(r, 1, buf.size()-1){
				while(buf[r]-buf[l] >= k){
					l++;
				}
				ans += r-l;
			}
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 23680
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<set>
#include<stack>
#include<queue>

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}

int main(){
	string s;
	cin >> s;
	string u = "";
	int l = s.length();
	vi c;
	int cnt = 0;
	rep(i, l){
		if(s[i] != 'x'){
			u += s[i];
			c.pb(cnt);
			cnt = 0;
		}else cnt++;
	}
	c.pb(cnt);
	int si = c.size();
	int ans = 0;
	rep(i, si/2){
		ans += abs(c[i] - c[si - 1 - i]);
	}
	reverse(u.begin(), u.end());
	bool f = false;
	int ul = u.length();
	rep(i, ul/2){
		if (u[i] != u[ul - i - 1]) f = true;
	}
	if(f){ cout << "-1" << endl; return 0;}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1148
def gen_d_prim(n):
    D = [0] * (n+1)
    for i in range(2, n+1):
        if D[i] > 0: continue
        for j in range(i, n+1, i): D[j] = i
    return D

def is_pairwise(A):
    D = gen_d_prim(10**6)
    past = set()
    for a in A:
        now = set()
        while a != 1:
            # 素数 D[a]: 今回は未済 & 過去で済
            if not D[a] in now and D[a] in past: return False
            now.add(D[a])
            past.add(D[a])
            a //= D[a]
    return True

def gcd_all(A):
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    return g

def solve():
    if is_pairwise(A): return 0
    if gcd_all(A) == 1: return 1
    return 2

n = int(input())
A = [*map(int, input().split())]
print(['pairwise','setwise','not'][solve()], 'coprime')


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

/**
 * @author:26019
 */
public class Main {


    public static void main(String[] args) throws Exception {
        solve();
    }

    private static void solve() throws Exception {
        //BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("C:\\Users\\26019\\Downloads\\out.txt"))));
        FastScanner cin = new FastScanner();
//        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int[] arr = cin.readArray(n);
        if (n < 3) {
            System.out.println(0);
            return;
        }
        int res = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                for (int k = j + 1; k < n; k++) {
                    int a = arr[i], b = arr[j], c = arr[k];
                    if (a != b && b != c && a != c && a + b > c && a + c > b && b + c > a) res++;
                }
            }
        }
        System.out.println(res);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("C:\\Users\\26019\\Downloads\\P1190_9.in"))));
        StringTokenizer st = new StringTokenizer("");

        FastScanner() throws FileNotFoundException {
        }

        public String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public String nextLine() { // 读取带空格的字符串
            String res = null;
            try {
                res = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}



Measured memory_bytes: 33776
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int n = scanner.nextInt();
		    int a = scanner.nextInt();
		    int b = scanner.nextInt();
		    
		    int sum = 0;
		    
		    
		    for(int i = 1; i <= n; i++) 
		    {
		    	int countketa = 0;
		    	int x = i;
		    	while( x != 0 ) 
		    	{
		    		countketa = countketa + x % 10;
		    		x = x / 10;
		    	}
		    	if(a <= countketa && countketa <=b) 
		    	{
		    		sum = sum + i;
		    	}
		    }
		    System.out.println(sum);
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 23764
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int n;
  while(cin>>n){
    if(n==-1)break;
    double t=0;
    for(int i=1;i<n;i++){
      t+=atan(1/sqrt(i));
    }
    cout<<sqrt(n)*cos(t)<<endl<<sqrt(n)*sin(t)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<string>> A(H, vector<string>(W));
    rep(i, H) {
        string s;
        cin >> s;
        rep(j, W) {
            A[i][j] = s[j];
        }
    }
    vector<bool> h(H, false), w(W, false);
    rep(i, H) {
        rep(j, W) {
            if(A[i][j] == "#") {
                h[i] = true;
                break;
            }
        }
    }
    rep(i, W) {
        rep(j, H) {
            if(A[j][i] == "#") {
                w[i] = true;
                break;
            }
        }
    }
    rep(i, H) {
        if(h[i] == false) continue;
        rep(j, W) {
            if(w[j] == false) continue;
            cout << A[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

int main(){
    // string a;
    // float b;
    // cin >> a >> b;
    // ll ans = 0;
    // int n = a.size();
    // vector<ll> s(n);
    // rep(i,n-2){
    //     ans *= 10;
    //     ll digit = a[i] - '0';
    //     s[i] = b * 100*digit + 0.5; 
    //     ans += ll(s[i]);
    // }
    // ll addi = 0;
    // if(n-1 >= 1 ){
    //      addi = b*(10*(a[n-2] - '0') + a[n-1] - '0') + 0.001;
    //      //cout << addi << endl;
    // }else {
    //     addi = b*(a[n-1] - '0') + 0.001;
    //     //cout << addi << endl;
    // }
    // ans += addi;
    // cout << ans << endl;

    ll a;
    double b;
    cin >> a >> b;
    ll ib = b*100 + 0.5;
    ll ans = a*ib/100;
    cout << ans << endl;
}

Measured memory_bytes: 3716
n,m = map(int,input().split())
t = []
for i in range(m):
    p, y = map(int,input().split())
    t.append([i,p,y,0])
t.sort(key=lambda x:x[2])                 # yでソート
t.sort(key=lambda x:x[1])                 # pでソート
city = t[0][1]
city_num = 0
for i in range(m):                       # pでソート済みなのでこう書ける              
    if t[i][1] == city:
        city_num += 1
        t[i][3] += city_num
    else:
        city = t[i][1]
        t[i][3] = 1
        city_num = 1
t.sort()                                 # t.sort(key=lambda x:x[0])と同じ
for i in t:
    ans = "%06d" % i[1] + "%06d" % i[3]
    print(ans)

Measured memory_bytes: 29604
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld, lld> pi;
#define F first
#define S second
#define N 1000007
#define MOD 17868
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (lld i = a; i < b; i++)
lld r, j, l, m, n, s, q, i, k, t, p,z,timer,x,y;string s1, s2;
lld a[N],dp[N];
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>k;
  rep(i,1,n+1)cin>>a[i];
  rep(i,1,N)dp[i]=LLONG_MAX;
  dp[n]=0;
  for(i=n-1;i>=1;i--)
  {
  	p=LLONG_MAX;
  	for(j=i+1;j<=i+k&&j<=n;j++)p=min(p,dp[j]+abs(a[j]-a[i]));
  	dp[i]=p;
  }
  cout<<dp[1];
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int dijkstra(int s, int n, vector<vi> G) {
    vb used(n, false);
    vi d(n, INF);

    // sから1への最短経路
    d[s] = 0;
    while (true) {
        int v = -1;
        for (int u = 0; u < n; u++) {
            if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
        }

        if (v == -1) break;
        used[v] = true;
        for (int u = 0; u < n; u++) {
            d[u] = min(d[u], d[v] + G[v][u]);
        }
    }

    return d[1];
}

int main() {
    int H, W; cin >> H >> W;
    vector<vi> C(10, vi(10));
    rep(i, 10) { rep(j, 10) { cin >> C[i][j]; } }

    vector<vi> A(H, vi(W));
    rep(i, H) { rep(j, W) { cin >> A[i][j]; } }

    vi minl(10);

    for (int i = 0; i < 10; i++) {
        minl[i] = dijkstra(i, 10, C);
    }

    map<int, int> G;
    rep (i, H) {
        rep(j, W) {
            G[A[i][j]]++;
        }
    }

    int res = 0;
    for (auto x : G) {
        if (x.first == -1 || x.first == 1) continue;
        res += minl[x.first] * x.second;
    }
    cout << res << endl;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	char x;
	cin>>x;
	if(x>=65 && x<=90)
	cout<<"A"<<"\n";
	else if(x>=97 && x<=122)
	{
		cout<<"a"<<"\n";
	}
}

Measured memory_bytes: 3648
import java.util.*;

public class Main{

    public static List<Integer> P;
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Map<Integer, Integer> idorder = new HashMap<>();
        for(int i=1; i<=N; i++){ 
            int A = scanner.nextInt();
            idorder.put(A, i);
        }
        for(int i=1; i<=N; i++){
            System.out.print(idorder.get(i));
            System.out.print(" ");
        }
    }
}

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

int main()
{
  int mt[10];
  int high[3];

  for(int i=0;i<10;i++)
    {
      cin >> mt[i];
    }

  for(int i=0;i<3;i++)
    {
      high[i] = 0;
    }

  for(int i=0;i<10;i++)
    {
      if(mt[i]>high[0])
	{
	  high[2] = high[1];
	  high[1] = high[0];
	  high[0] = mt[i];
	}
      else if(mt[i]>high[1])
	{
	  high[2] = high[1];
	  high[1] = mt[i];
	}
      else if(mt[i]<=high[1] && mt[i]>high[2])
	{
	  high[2] = mt[i];
	}
    }

  for(int i=0;i<3;i++)
    {
      cout << high[i] << endl;
    }

  return 0;
}

Measured memory_bytes: 1160
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))
temp = float('inf')
for i in range(N):
  a = T-H[i]*0.006
  if abs(A-a) < temp:
    temp = abs(A-a)
    ans = i
    
print(ans+1)

Measured memory_bytes: 3060
//
// Created by inoue on 2019-09-28.
//

#include <iostream>
#include <vector>

using namespace std;

#define INF 0x3f3f3f3f

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

    vector<int> dp(1<<13, INF);


    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        int c = 0;
        for (int j=0; j<b; j++) {
            int t;
            cin >> t;
            t--;
            c += 1 << t;
        }

        dp[c] = min(dp[c], a);
    }

    for (int i=0; i<(1<<12); i++) {
        for (int j=0; j<i; j++) {
            dp[i|j] = min(dp[i|j], dp[i] + dp[j]);
        }
    }

    if (dp[(1<<n) - 1] == INF) {
        cout << -1 << endl;
    } else {
        cout << dp[(1<<n) - 1] << endl;
    }
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
    int a,b,c,d,i,j,l,p,s;
    scanf("%d",&l);
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    s=l;
    for(i=l;i>0;i--){
        a=a-c;
        if(a<=0){
                i=i-1;
            break;
        }
    }
    for(j=s;j>0;j--){
        b=b-d;
        if(b<=0){
            j=j-1;
            break;
        }
    }
    if(i<j){
    p=i;
    }else if(i>j){
    p=j;
    }else if(i==j){
    p=i;
    }
    printf("%d\n",p);
return 0;
}

Measured memory_bytes: 596
n,m,c=map(int,input().split())
count=0
B=list(map(int,input().split()))

for j in range(n):
  sum=0
  A=list(map(int,input().split()))
  
  for i in range(m):
    sum+=A[i]*B[i]
  
  sum+=c
  
  if sum>0:
    count+=1
    
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> P;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int a,b,c;
cin >> a >> b >> c;
if((a==b && a!=c)||(b==c && a!=b)||(a==c && a!=b))fin("Yes");else fin("No");

//////////////////////////////////////////////////////
return 0;}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int k,a,b;
  cin >> k;
  cin >> a >> b;
  
  if(a/k!=b/k) cout << "OK" << endl;
  else if(a%k==0||b%k==0) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3684
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
// 小大
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}
typedef struct{
    llint aa;
    llint bb;
}frequent;
// 小大
int cmp( const void *p, const void *q ) {
    return ((frequent*)p)->bb - ((frequent*)q)->bb;
}
/*[a]+1 ガウス+1*/
llint pgauss(ldouble a){llint b=a;return a==b?b:pgauss(b+1);}
/*2つのうち大きい数を返す*/
llint max2(llint a,llint b){return a>=b?a:b;}

int main(void){
    llint n,h,w,a;
    scanf("%lld%lld%lld",&h,&w,&n);
    a = n%max2(h,w)==0?n/max2(h,w):1+n/max2(h,w);
    printf("%lld\n",a);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const int _infinity = 1000000;
int A, B, C;
VEC(int) sticks;

int cost(int have, int need)
{
    if (have == 0)
        return _infinity;
    return abs(have - need);
}

int recurse(int i, int a, int b, int c)
{
    // Cost at this moment.
    int ret = cost(a, A) + cost(b, B) + cost(c, C);

    if (i == sticks.size())
    {
        return ret;
    }

    // leave out ith stick.
    ret = min(ret, recurse(i + 1, a, b, c));

    // join with one of a, b, c
    int s = sticks[i];
    ret = min(ret, (a == 0 ? 0 : 10) + recurse(i + 1, a + s, b, c));
    ret = min(ret, (b == 0 ? 0 : 10) + recurse(i + 1, a, b + s, c));
    ret = min(ret, (c == 0 ? 0 : 10) + recurse(i + 1, a, b, c + s));

    return ret;
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.

    int N;
    cin >> N >> A >> B >> C;
    sticks.resize(N);
    READVEC(sticks);
    int ret = recurse(0, 0, 0, 0);
    cout << ret << endl; 
    return 0;
};


Measured memory_bytes: 256