akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())

g = []
cnt = 0
for _ in range(h):
    a = input() + "?"
    cnt += a.count("#")
    g.append(list(a))

if cnt != h+w-1:
    print("Impossible")
    exit()

g.append(["?"]*w)

y, x = 0, 0

for _ in range(h+w-2):
    if g[y+1][x] == "#" and g[y][x+1] != "#":
        y += 1
    elif g[y][x+1] == "#" and g[y+1][x] != "#":
        x += 1
    else:
        print("Impossible")
        exit()
print("Possible")

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

int main()
{
    string s;
    cin >> s;

    string string_without_x;
    vector<int> index_without_x;
    for (int i = 0; i < s.size(); i++)
    {
        char current = s[i];
        if (current != 'x')
        {
            string_without_x.push_back(current);
            index_without_x.push_back(i);
        }
    }

    for (int i = 0; i < string_without_x.size() / 2; i++)
    {
        if (string_without_x[i] != string_without_x[string_without_x.size() - 1 - i])
        {
            cout << -1 << endl;
            return 0;
        }
    }

    if (index_without_x.size() == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    int right, left;
    if (index_without_x.size() % 2 == 0)
    {
        right = index_without_x.size() / 2;
        left = right - 1;
    }
    else
    {
        right = index_without_x.size() / 2;
        left = right;
    }

    right = index_without_x[right];
    left = index_without_x[left];
    int ans = 0;
    // while (right != s.size() - 1 || left != 0)
    // {
    //     if (s[left] == s[right])
    //     {
    //         left--;
    //         right++;
    //     }
    //     else
    //     {
    //         ans++;

    //         if (s[left] == 'x')
    //         {
    //             left--;
    //         }
    //         if (s[right] == 'x')
    //         {
    //             right++;
    //         }
    //     }
    //     left = max(0, left);
    //     right = min((int)s.size() - 1, right);
    // }
    // if (s[left] != s[right])
    // {
    //     ans++;
    // }
    while (right < s.size() && left >= 0)
    {
        // cout << left << " " << right << endl;
        if (s[left] == s[right])
        {
            left--;
            right++;
        }
        else
        {
            ans++;
            if (s[left] == 'x')
            {
                left--;
            }
            if (s[right] == 'x')
            {
                right++;
            }
        }
    }
    // cout << left << " " << right << endl;
    // cout << left << " " << (int)(s.size() - 1) - right << endl;
    ans += left + 1;
    ans += s.size() - right;

    cout << ans << endl;
}


Measured memory_bytes: 1148
#include<iostream>
#include<string>

int main(){
    
    size_t n;
    std::string s;

    std::cin >> n >> s;

    size_t ans = n;

    for(size_t i = 0; i < n - 1; i++){
        if(s[i] == s[i + 1]){
            ans--;
        }
    }

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


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int N, T, c[1001], t[1001], x = 2000;

	cin >> N >> T;

	rep(i, N){
		cin >> c[i] >> t[i];
		if(t[i] <= T && c[i] < x){
			x = c[i];
		}
	}

	if(x == 2000){
		cout << "TLE" << endl;
	}else{
		cout << x << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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() {
  int n, k;
  cin >> n >> k;
  int d, a, ans[n]={};
  rep(i, k){
	cin >> d;
    rep(j, d){
      cin >> a;
      ans[a-1] += 1;
    }
  }
  int count = 0;
  rep(i, n) {
    if(ans[i] == 0) ++count;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
using namespace std;
int a,b,c;
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>a>>b>>c;
    if(a+b>=c)
    {
        cout<<b+c<<'\n';
        return 0;
    }
    cout<<a+b+b+1;
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var m = parseInt(input[0].split(" ")[1]);
  ans=0;
  if(n!=1){
  for(i=Math.ceil(m/n);i>0;i--){
    if(m%i==0&&n*i<=m){
      ans=i;
      break;
    }
  }
}else{
  ans=m;
}
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int a, b ;
  cin >> a >> b ;
  if ((a+b)%2==0) {
    cout << (a+b)/2 << endl;
  }
  else {
    cout << (a+b)/2+1 << endl;
  }
}


Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())

a = list(map(int, input().split()))
a = [-ai for ai in a]
heapq.heapify(a)

for i in range(m):
    v = heapq.heappop(a) / 2
    heapq.heappush(a, v)
    
for i in range(n):
    a[i] = int(a[i])
print(-(sum(a)))

Measured memory_bytes: 14184
#include <stdio.h>

int main(void){
  
  int A1;
  int A2;
  int A3;
  
  scanf("%d %d %d",&A1,&A2,&A3);

  
  
  if(A1 <= A2 && A2 <= A3){
    printf("%d",(A2 - A1) + (A3 - A2));
  }
  else if(A1 <= A3 && A3 <= A2){
    printf("%d",(A3 - A1) + (A2 - A3));
  }
  else if(A2 <= A1 && A1 <= A3){
    printf("%d",(A1 - A2) + (A3 - A1));
  }
  else if(A2 <= A3 && A3 <= A1){
    printf("%d",(A3 - A2) + (A1 - A3));
  }
  else if(A3 <= A1 && A1 <= A2){
    printf("%d",(A1 - A3) + (A2 - A1));
  }
  else{
    printf("%d",(A2 - A3) + (A1 - A2));
  }
  return 0;
}


Measured memory_bytes: 128
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a % b)

input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

temp = A[0]
for i in range(1,N):
	temp = gcd(temp,A[i])

if K <= max(A) and K % temp == 0:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef unordered_map<ll, ll> ump;

const ll mod = 1e9+7;

ll max(ll a, ll b){
	if (a > b) return a;
	else return b;
}

unsigned getDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

ll pow(ll a, ll b){
	ll dst = 1;
	REP(i, b){
		dst *= a;
	}
	return dst;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	ll digit = getDigit(b);
	ll c = a*pow(10, digit) + b;
	REP(i, 320){
		ll d = i*i;
		if (c == d){
			cout << "Yes" << endl; return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class Combination {
    vector<ll> factorial;
    vector<ll> fact_inverse;
    vector<ll> inverse;
    int mod;

    void init(int size) {
        factorial[0] = 1;
        factorial[1] = 1;
        fact_inverse[0] = 1;
        fact_inverse[1] = 1;
        inverse[1] = 1;

        for (int i = 2; i < size; i++) {
            factorial[i] = factorial[i - 1] * i % mod;
            inverse[i] = mod - inverse[mod % i] * (mod / i) % mod;
            fact_inverse[i] = fact_inverse[i - 1] * inverse[i] % mod;
        }
    }

    public:
        Combination(int size, int m) {
           factorial = vector<ll>(size);
           fact_inverse = vector<ll>(size);
           inverse = vector<ll>(size);
           mod = m;
           init(size);
        }
    
        ll calc(int n, int k) {
            if (n < k) {
                return 0;
            }
            if (n < 0 || k < 0) {
                return 0;
            }
            return factorial[n] * (fact_inverse[k] * fact_inverse[n - k] % mod) % mod;
        }

        // i.e. nHk
        ll with_repetition(int n, int k) {
            return calc(n + k - 1, k);
        }
};

vector<vector<ll>> pascals_triangle(int n) {
    vector<vector<ll>> combi(n + 1, vector<ll>(n + 1));
    REP(i, n + 1) REP(j, i + 1) {
        if (j == 0 || j == i) combi[i][j] = 1LL;
        else combi[i][j] = combi[i - 1][j - 1] + combi[i - 1][j];
    }
    return combi;
}

void solve() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (k % 2 == 0 ? a - b : b - a) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define END puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     return p.first>q.first;
//     return p.first<q.first;
//     return p.second>q.second;
//     return p.second<q.second;
// }

// bool cmp(int p,int q) {
//     return p>q;
//     return p<q;
// }

int main() {

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

    return 0;
}
int clue() {

    int n;
    cin>>n;
    cout<<n+n*n+n*n*n<<endl;

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

ll solve()
{
    ll N;
    cin >> N;
    ll c = 1;
    for1(i,64) {
        if (N < c) {
            return c / 2;
        }
        c *= 2;
    }
    return 0;
}

int main()
{
    do {
        cout << solve() << endl;
    } while (DEBUG);
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
import java.io.*;

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

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] in1 = br.readLine().split(" ");
    int N = Integer.parseInt(in1[0]);

    in1 = br.readLine().split(" ");
    int[] A = Stream.of(in1).mapToInt(Integer::parseInt).toArray();
    br.close();

    int[] B = new int[N];
    for(int i = 0; i < N; i++){
      B[A[i] - 1] = i;
    }

    TreeSet<Integer> ts = new TreeSet<>();
    long ans = 0L;
    for(int i = 0; i < N; i++){
      ts.add(B[i]);
      
      int right = ts.higher(B[i]) == null ? N : ts.higher(B[i]);
      int left = ts.lower(B[i]) == null ? -1 : ts.lower(B[i]);
      
      ans += (long)(i + 1) * (long)(B[i] - left) * (long)(right - B[i]);
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 56600
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n, m;
  cin >> n >> m;
  vecint a(n);
  for (auto& e : a) cin >> e;
  sort(all(a));
  vector<pair<int, int>> b(m);
  for (auto& e : b) {
    cin >> e.second >> e.first;
  }
  sort(all(b), greater<pair<int, int>>());
  // for (auto& e : a) cout << setw(4) << e;
  // cout << endl;
  int r = 0;
  REP(i, m) {
    // cout << "r = " << r << endl;
    for (int j = 0; j < b[i].second; j++) {
      if (r + j >= n || a[r + j] >= b[i].first) break;
      a[r + j] = b[i].first;
    }
    r += b[i].second;
    if (r >= n) break;
  }
  ll ans = 0;
  // sort(all(a));
  // for (auto& e : a) cout << setw(4) << e;
  // cout << endl;
  REP(i, n) {
    // cout << a[i] << endl;
    ans += a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, h, a[1000];
vector<int> vi;

int main(){
	while (cin >> n&&n){
		cin >> h;
		int o = h, ans, sa;
		int f = 2;
		REP(i, n)cin >> a[i];
		REP(i, n){
			if (i == 0)sa = a[i] - h;
			else{
				if (sa != a[i] - h){
					if (f == 2){
						ans = a[i];
						f--;
					}
					else if (f > 0){
						f--;
					}
					else{
						if (a[n - 1] - a[n - 2] == a[1] - a[0])	ans = o;
						else ans = a[0];
					}
				}
			}
			h = a[i];
		}
		cout << ans << endl;
	}
}

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

using namespace std;

int main()
{
	int N;
	long long ans = 0;
	cin >> N;

	vector<int> A(N);
	vector<int> B(N);

	for (int i = 0; i < N; i++)
	{
		cin >> A[i] >> B[i];
	}

	for (int i = N - 1; i >= 0; i--)
	{
		if ((A[i] + ans) % B[i] != 0)
		{
			if (A[i] + ans > B[i])
				ans += B[i] - ((A[i] + ans) % B[i]);
			else
				ans += B[i] - (A[i] + ans);
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    int n; cin>>n;
    vector<long long> a(3*n);
    for(int i=0;i<3*n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    long long ans=0;
    for(int i=1;i<2*n;i+=2){
        ans+=a[i];
    }
    cout<<ans<<endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
}

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

void inorder(Node u){
    if (u->left != NIL) inorder(u->left);
    printf(" %d",u->key);
    if (u->right!=NIL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL) preorder(u->left);
  if(u->right!=NIL) preorder(u->right);
}


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

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24040
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=1e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/
int vis[N],n,k,r,s,p,ans;
char S[N];
int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	cin>>n>>k>>r>>s>>p>>S+1;
	for(int i=1;i<=n;i++){
		if(i>k&&vis[i-k]&&S[i]==S[i-k]) continue;
		ans+=(S[i]=='r')?p:((S[i]=='s')?r:s);
		vis[i]=1;
	}
	cout<<ans<<endl;
	return 0;
}


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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;

const double PI = 3.14159;

using namespace std;

//vector<ll> memo(1000007, INF);

int main() {

    ll n, k;
    cin >> n >> k;

    ll h[n];
    rep(i, n)
        cin >> h[i];

    sort(h, h+n);

    ll ans = 0;
    ll j = n - k;
    if (j < 0) k = 0;
    rep(i, j) {
        ans += h[i];
    }

    AA(ans);
}

Measured memory_bytes: 5160
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 999999999
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define Rrep(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=a;i<n;i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)

int main() {

	int a;
	string s;

	cin >> a;
	cin >> s;

	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

vector<long int> sieve(long int n){
    long int arr[n+1];
    for(long int i = 0; i <= n;++i){
        arr[i] = 1;
    }
    arr[0] = 0;
    arr[1] = 0;
    long int p= 2;
    while(p <= n){
        if(arr[p]){
            for(long int i = p*2; i <=n; i+=p){
                arr[i] = 0;
            }
        }
        p++;
    }
    vector<long int> ans;
    for(long int i = 2; i < n ; i++){
        if(arr[i]){
            ans.push_back(i);
        }
    }
    return ans;
    }
int main(){
    int a,b,c,k, ans=  0;
    cin>>a>>b>>c>>k;
    if(k > 0){
        int val = min(a,k);
        ans+=val;
        k-=val;
    }
    if(k > 0){
        int val = min(b, k);
        k-=val;
    }
    if(k >0){
        int val = min(c,k);
        k-=val;
        ans-=val;
    }
    cout<<ans<<endl;
}

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

int main(){
    ll H, W, N; cin >> H >> W >> N;
    vector<P> point(N);
    rep(i, N) cin >> point[i].first >> point[i].second;

    vector<ll> ans(10);
    map<pair<ll, ll>, ll> mp;
    rep(i, N){
        rep(j, 3){
            rep(k, 3){
                if(point[i].first - j >= 1 && point[i].first - j <= H - 2 && point[i].second - k >= 1 && point[i].second - k <= W - 2){
                    mp[{point[i].first - j , point[i].second - k}]++;
                }
            }
        }
    }
    for(auto e: mp){
        //cout << e.first.first << " " << e.first.second << " " << e.second << endl;
        ans[e.second]++;
    }
    ans[0] = (H - 2) * (W - 2);
    for(int i = 1; i < 10; i++) ans[0] -= ans[i];

    rep(i, 10){
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 58112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i <= int(n); i++)
#define mod 1000000007
 
int main()
{
	int A, B, C, X;
	cin >> A >> B >> C >>X;
	int cnt = 0;
	for(int i = 0; i <= A; i++){
		for(int j = 0; j <= B; j++){
			for(int k = 0; k <= C; k++){
				int sum = (i*500)+(j*100)+(k*50);
				if(sum == X){
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
def factorial(n):
    ans = 1
    for i in range(1, n+1):
        ans = ans * i

    return ans

def combination(n, r):
    #print(factorial(n) // (factorial(n-r) * factorial(r)))
    return factorial(n) // (factorial(n-r) * factorial(r))

def get_ans(N, K, i):
    if N-K+1<i:
        return 0
    else:
        return(combination(N-K+1, i) * combination(K-1, i-1))

N, K = tuple(map(int, input().split()))
for i in range(1, K+1):
    ans = get_ans(N, K, i)
    print(ans%(10**9+7))


Measured memory_bytes: 3316
N = int(input())
W = list(map(int,input().split()))
list = []
for n in range(N):
  a = 1
  b = n + 1
  Down = 0
  Up = 0
  while a <= n:
    Down += W[a - 1]
    a += 1
  while b <= N:
    Up += W[b - 1]
    b += 1
  list.append(abs(Down - Up))
list.sort()
print(list[0])

Measured memory_bytes: 38768
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int a, b; cin >> a >> b;
  cout << a * b << endl;
  return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  if(k % 2==0){
    long long int count1 = 0 ;
    long long int count0 = 0 ;
    int x = k/2 ;
    for(int i=1; i<=n; i++){
       if(i % k == 0)
         count0++ ;
       else if(i%k == x)
         count1++ ;
    }
    cout << count1*count1*count1 + count0*count0*count0 << endl;
  }
  else{
       long long int count = 0;
       for(int i=1; i<=n ; i++){
          if(i%k==0)
            count++;
       }
       cout << count*count*count << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,a[N],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			for(int k=j+1;k<=n;k++)
				if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k])
					ans++;
	printf("%d\n",ans);
	return 0;
}

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

const int max_N = 2000 + 21;

int n,k,t,dis[max_N],q[max_N],ans=-1;

std::vector<int>vec[max_N];

int bfs(){
	int tmp=0;
	for(int i=1;i<=t;++i){
		int u=q[i];
		for(auto&v:vec[u])
			if(dis[v]==-1){
				dis[v]=dis[u]+1;
				q[++t]=v;
			}
		if(dis[u]>k/2)++tmp;
	}
	return tmp;
}

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1,a,b;i<n;++i){
		scanf("%d%d",&a,&b);
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	if(k&1){
		for(int x=1;x<=n;++x)
			for(auto&y:vec[x])if(x<y){
				memset(dis+1,-1,sizeof(int)*n);
				t=2,q[1]=x,q[2]=y,dis[x]=dis[y]=0;
				int tmp=bfs();
				if(ans==-1||ans>tmp)ans=tmp;
			}
	}
	else{
		for(int x=1;x<=n;++x){
			memset(dis+1,-1,sizeof(int)*n);
			t=1,q[1]=x,dis[x]=0;
			int tmp=bfs();
			if(ans==-1||ans>tmp)ans=tmp;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		int[] t = new int[sc.nextInt()];

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

		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			int p = sc.nextInt(), x = sc.nextInt();
			int sum = 0;
			for (int j = 0; j < t.length; j++) {
				sum += j == p - 1 ? x : t[j];
			}
			System.out.println(sum);
		}
		sc.close();
	}
}

Measured memory_bytes: 23764
#include <stdio.h>
int main(){
    int c[3][3];
    int x, y;

    for(y = 0; y < 3; ++y){
        for(x = 0; x < 3; ++x){
            scanf("%d", &c[x][y]);
        }
    }
    char judge = 1;
    for(x = 0; x < 2; ++x){
        for(y = 0; y < 2; ++y){
            judge &= ((c[x][y] - c[x][y + 1]) == (c[x + 1][y] - c[x + 1][y + 1]));
            judge &= ((c[x][y] - c[x + 1][y]) == (c[x][y + 1] - c[x + 1][y + 1]));
        }
    }

    if(judge){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

int main() {

    int d, e;
    while (cin >> d >> e and (d or e)) {

        double ans = 1e8;
        for (int y=0; y<=100; ++y) {
            for (int x=0; x<=100; ++x) {
                if (x+y == d) {
                    ans = min(abs(sqrt((x*x)+(y*y))-e), ans);
                }
            }
        }

        printf("%.10f\n", ans);

    }
}

Measured memory_bytes: 3124
hp_t, atk_t, hp_a, atk_a = map(int, input().split(" "))
while hp_t > 0:
    hp_a += -atk_t
    if hp_a <= 0:
        print("Yes")
        break
    else:
        hp_t += -atk_a
        if hp_t <= 0:
            print("No")
            break

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

int main(void){
    long long int a,b,k;
    cin >> a >> b >> k;
    if(k-a >= 0){
        cout << 0 << " ";
        if(k-a >= b)cout << 0;
        else cout << b - (k-a);
    }
    else cout << a-k << " " << b;
}

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

int main() {
    long long x, k, d;
    cin >> x >> k >> d;
    x = (x < 0 ? -x : x);

    /*
    long long y, tmp;
    tmp = x / d;
    if (k - tmp <= 0) {
        cout << x - k * d << endl;
        return 0;
    }
    y = x - tmp * d;
    if ((k - tmp) % 2 == 0) {
        cout << abs(y) << endl;
    } else {
        cout << abs(y-d) << endl;
    }
    */

    long long tmp, min1, min2;
    if ((k - x / d) <= 0) {
        cout << abs(x - k * d) << endl;
        return 0;
    }
    tmp = x / d;
    min1 = x - tmp * d;
    min2 = x - (tmp+1) * d;

    if ((k - x / d) % 2 == 0) {
        cout << abs(min1) << endl;
    } else {
        cout << abs(min2) << endl;
    }

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
#include <queue>

using namespace std;

long long int gcd(long long int a, long long int b) {
    if(a<b) {
        long long int tmp=a;
        a=b;
        b=tmp;
    }
    
    if(b==0) {
        return a;
    }
    
    long long int r=a%b;
    return gcd(b, r);
}

int main() {
    long long int A, B;
    cin >> A >> B;
    
    long long int ggg=gcd(A, B);
    vector<long long int> vec;
    vec.push_back(1);
    for(int i=2; i<sqrt(ggg); i++) {
        bool flag=false;
        while(ggg%i==0) {
            ggg/=i;
            flag=true;
        }
        bool flagvec=true;
        if(flag) {
            for(int j=0; j<vec.size(); j++) {
                if(vec[j]==i) {
                    flagvec=false;
                    break;
                }
            }
            if(flagvec) {
                vec.push_back(i);
            }
        }
    }
    if(ggg!=1) {
        vec.push_back(ggg);
    }

    cout << vec.size() << endl;
    
    return 0;
    
}

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

namespace ConsoleApp1
{
	class Program5
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var vn = Console.ReadLine().Split(' ');
			var cn = Console.ReadLine().Split(' ');

			int max = 0;
			for (int i = 0; i < n; i++)
			{
				int x = int.Parse(vn[i]) - int.Parse(cn[i]);
				if (x > 0)
				{
					max += x;
				}
			}

			Console.Write(max.ToString() + "\n");
			//Console.ReadLine();
		}
	}
}


Measured memory_bytes: 11092
#include <cstdio>
#include <algorithm>
using namespace std;
const long long mod = 1000000007;
int main() {
	int N;
	scanf("%d", &N);
	long long C[N], pow2[N + 1], ans = 0, sbits = 0;
	pow2[0] = 1;
	for (int i = 0; i < N; ++i) scanf("%lld", &C[i]);
	sort(C, C + N);
	for (int i = 1; i <= N; ++i) pow2[i] = pow2[i - 1] * 4 % mod;
	for (int i = 0; i < N; ++i) {
		ans += (sbits * 2 + 2 * pow2[i]) * pow2[N - i - 1] % mod * C[N - i - 1] % mod;
		ans %= mod;
		sbits = (sbits * 4 + pow2[i] * 2) % mod;

	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3328
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m;
    cin>>n>>m;
    vector<int> h(n);
        rep(i,n) cin>>h.at(i);
    vector<vector<int>> a(n,vector<int>(0));
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x --,y --;
        a[x].emplace_back(y);
        a[y].emplace_back(x);
    }
    vector<bool> isgood(n,true);
    rep(i,n){
        if(!isgood[i]) continue;
        for(auto x:a[i]){
            if(h[i]<=h[x]){
                isgood[i]=false;
                break;
            }
            else{
                isgood[x]=false;
            }
        }
    }
    int cnt=0;
    rep(i,n){
        cnt +=isgood[i];
    }
    cout<<cnt<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 8744
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <math.h>
#include <cmath>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
 string s;
 cin >> s;
  int n;
  n=s.length();
  s += 'R';
  int kids[n];
  rep(p,n){
    kids[p] = 0;
  }
  char now = 'R';
  int count = 0;
  int mem;
  rep(i,n+1){
    if(now == 'R'){
      if(s[i] == 'R'){
        count++;
      } else {
        kids[i-1] += (count+1)/2;
        kids[i] += count/2;
        now = 'L';
        mem = i;
        count = 1;
      }
    } else {
      if(s[i] == 'L'){
        count++;
      } else {
        kids[mem] += (count+1)/2;
        kids[mem-1] += count/2;
        now ='R';
        count =1;
      }
    }
  }
  rep(j,n){
    cout << kids[j] << " ";
  }
 return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

		final Scanner stdin = new Scanner( System.in );

		while ( true ) {

			final int n = stdin.nextInt();
			final int r = stdin.nextInt();
			if ( n == 0 && r == 0 ) break;

			final int[] deck = new int[ n ];
			for ( int i = 0; i < n; i++ ) {
				deck[ n - 1 - i ] = i + 1;
			}
			int[] tmp = new int[ n ];
			for ( int i = 0; i < r; i++ ) {
				final int p = stdin.nextInt();
				final int c = stdin.nextInt();
				
				System.arraycopy( deck, 0, tmp, 0, p - 1 );
				for ( int j = 0; j < c; j++ ) {
					deck[ j ] = deck[ j + p - 1 ];
				}
				System.arraycopy( tmp, 0, deck, c, p - 1 );
			}
			System.out.println( deck[ 0 ] );
		}	
    }    
}

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

int main() {
    long long a,b,c;
    cin >> a >> b >> c;
    long long x,y;
    cin >> x >> y;
    if(x<y){
        swap(a,b);
        swap(x,y);
    }
   
    cout << y*min(a+b,2*c)+(x-y)*min(a,2*c) << endl;

}

Measured memory_bytes: 256
'use strict'
function Main(input) {
    input = input.split("\n")[0]
    const numbers = input.split(' ').map(i => {
      return parseInt(i, 10)
    })

    const a = numbers[0]
    const b = numbers[1]
    let result = 0

    if(a > b) {
      result = 2*a - 1
    } else if (b > a) {
      result = 2*b - 1  
    } else {
      result = 2 * a
    }
    
    console.log(result)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
//using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		// 入力フェーズ
				int N = int.Parse(Console.ReadLine());
        string[] height = Console.ReadLine().Split(' ');
        List<int> arr = new List<int>();
        for(int i=0; i<height.Length; i++)
        {
          int h = int.Parse(height[i]);
          arr.Add(h);
        }

        // arrの中の最小値まで順番に育てる
        int step = 0;
        while(true)
        {
          int min = getMinExceptZero(arr);
          if(min > 100) break; // 最小値が0の場合、全て育てきったのでループを抜ける
          bool isSuccessive = false;

          for(int i=0; i<arr.Count; i++)
          {
            int h = arr[i];
            if(h>= min)
            {
              // minだけ花を育てる
              arr[i] = h - min;
              if(!isSuccessive)
              {
                // 一回途切れてたら
                step += min;
                isSuccessive = true;
              }
            }
            else if(h == 0)
            {
              // 0だと1回で水やりできないので
              isSuccessive = false;
            }
          }
        }

        Console.WriteLine(step);
    }
    static private int getMinExceptZero(List<int> arr)
    {
      // 0以外で最小値を見つける
      int min = 101;
      for(int i=0;i<arr.Count; i++)
      {
          int h = arr[i];
          if(h > 0 && h < min)
            min = h;
      }

      return min;
    }
}


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

string t = "abcdefghijklmnopqrstuvwxyz";
int search_str(string a, string b);

int main() {
    string s;
    int n, max_count = 0, tmp;

    cin >> n >> s;

    for (int i = 1; i < n - 2; ++i) {
        tmp = search_str(s.substr(0, i), s.substr(i, n-i));
        if(tmp > max_count) max_count = tmp;
    }
    
    cout << max_count << endl;

    return 0;
}

int search_str(string a, string b) {
    int count = 0;
    for (int i = 0; i < t.size(); ++i) {
        if(a.find(t[i]) != string::npos && b.find(t[i]) != string::npos) count++;
    }
    return count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "Yes\n";
#define no cout << "No\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

map<ll, ll> req;

ll solve(ll n) {
    if (n == 1)
        return 1;
    // if (req[n] != 0) {
    //     return req[n];
    // }

    ll ans = solve(n / 2);
    // req[n / 2] = ans;
    return 2 * ans + 1;
}

void solve() {
    ll n, d, a;
    cin >> n >> d >> a;

    vpll coords(n);
    for (ll i = 0; i < n; i++) {
        cin >> coords[i].first >> coords[i].second;
    }

    sort(all(coords));
    deque<pll> damages;
    ll sofar = 0;
    ll ans = 0;

    for (auto c : coords) {
        while (!damages.empty() && damages.front().first < c.first - d) {
            sofar -= a * damages.front().second;
            damages.pop_front();
        }

        if (c.second <= sofar) {
            continue;
        }
        c.second -= sofar;

        ll amt = ce(c.second, a);
        damages.push_back({c.first + d, amt});
        ans += amt;
        sofar += amt * a;
    }

    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

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

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int dp[2][100];
int a[2][100];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	REP(i, 2) REP(j, n) cin >> dp[i][j];
	REP(i, 2){
		REP(j, n){
			int val = 0;
			if(i != 0) val = max(val, dp[i - 1][j]);
			if(j != 0) val = max(val, dp[i][j - 1]);
			dp[i][j] += val;
		}
	}
	cout << dp[1][n - 1] << "\n";
	return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (0 < a && 0 < c) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }

        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}


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

using i64 = int64_t;

i64 calc_f(i64 x, const vector<i64> &v){
    i64 f = 0;
    for(auto e: v){
        f += e ^ x;
    }
    return f;
}

i64 calc_msb(i64 x){
    i64 res = 0;
    while(x > 0){
        x >>= 1ll;
        res++;
    }
    return res;
}

int main(){
    int n;
    i64 k;
    cin >> n >> k;
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        v.push_back(a);
    }
    i64 msb = calc_msb(k);
    i64 mask = -1;
    i64 ans = calc_f(k, v), f0 = calc_f(0, v);
//    i64 maxx = k;
    for(i64 i=0;i<msb;++i){
        if((k & (1ll << i)) == 0)continue;
        i64 x = k & (mask ^ (1ll << i));
        for(i64 j=0;j<i;++j){
            i64 bit = 1ll << j;
            if(f0 > calc_f(bit, v)){
                x &= mask ^ bit;
            }else{
                x |= bit;
            }
        }
        i64 f = calc_f(x, v);
        /*if(f > ans){
            ans = f;
            maxx = x;
        }*/
        ans = max(ans, calc_f(x, v));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1400
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int a = input.nextInt();
    int b = input.nextInt();

    if((a + b) % 2 == 0){
      System.out.println((a + b) / 2);
    }
    else
      System.out.println("IMPOSSIBLE");
  }
}


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

int main(){
	string s;
	cin>>s;
	
	int a=0,b=0,c=0;
	for(int i=0;i<3;i++){
		if(s[i]=='a') a=1;
		else if(s[i]=='b') b=1;
		else c=1;
	}
	
	cout<<((a&&b&&c)?"Yes":"No")<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int ban[5010][5];
int d,p,q;

void clear(int h){
	int i,j;
	bool no;
	for(i=0;i<(d==1?1:p);i++){
		no=true;
		for(j=0;j<5;j++){
			if(ban[h+i][j]==0)no=false;
		}
		if(no){
			int k;
			for(k=h+i+1;k<5010;k++){
				for(j=0;j<5;j++){
					ban[k-1][j]=ban[k][j];
				}
			}
			i--;
		}
	}
}

int fall(){
	int i,j;
	if(d==2){
		for(i=5005;i>=0;i--){
			if(ban[i][q])break;
		}
		i++;
		for(j=0;j<p;j++){
			ban[i+j][q]=1;
		}
	}else{
		for(i=5005;i>=0;i--){
			for(j=0;j<p;j++){
				if(ban[i][q+j])goto aaa;
			}
		}
		aaa:;
		i++;
		for(j=0;j<p;j++){
			ban[i][q+j]=1;
		}		
	}
	return i;
}

int main() {
	int n;
	while(n=in()){
		memset(ban,0,sizeof(ban));
		int i;
		for(i=0;i<n;i++){
			cin>>d>>p>>q;
			q--;
			clear(fall());
//			int x,y;
//			for(y=10;y>=0;y--){
//				for(x=0;x<5;x++){
//					cout<<ban[y][x];
//				}
//				cout<<endl;
//			}
//			cout<<endl;
		}
		int j;
		int res=0;
		for(i=0;i<5010;i++){
			for(j=0;j<5;j++){
				if(ban[i][j])res++;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.util.*;

public class Main {
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj0102().doIt();
	}
	class aoj0102{
		void doIt() {
			while(true){
				int n = sc.nextInt();
				if(n == 0)break;
				int a[][] = new int [n+1][n+1];
				for(int i = 0;i < n;i++){
					for(int j = 0;j < n;j++){
						a[i][j] = sc.nextInt();
						a[n][j] = a[n][j] + a[i][j];
						a[i][n] = a[i][n] + a[i][j];
					}
					a[n][n] = a[n][n] + a[i][n];
				}
				for(int i = 0;i < n+1;i++){
					for(int j = 0;j < n+1;j++){
						System.out.printf("%5d",a[i][j]);
					}
					System.out.println();
				}
			}
		}
	}
}

Measured memory_bytes: 23820