akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	ll H, W;
	ll ans = LINF;

	cin >> H >> W;

	for (ll h = 1; h <= H; h++) {
		ll s1 = h * W;
		ll s2 = (H-h) * (W/2);
		ll s3 = (H-h) * (W-W/2);
		ll t = max(max(s1, s2), s3) - min(min(s1,s2), s3);
		ans = min(ans, t);
	}

	for (ll h = 1; h <= H; h++) {
		ll s1 = h * W;
		ll s2 = (H-h)/2 * W;
		ll s3 = (H-h-(H-h)/2) * W;
		ll t = max(max(s1, s2), s3) - min(min(s1,s2), s3);
		ans = min(ans, t);
	}

	for (ll w = 1; w <= W; w++) {
		ll s1 = H * w;
		ll s2 = H/2 * (W-w);
		ll s3 = (H-H/2) * (W-w);
		ll t = max(max(s1, s2), s3) - min(min(s1,s2), s3);
		ans = min(ans, t);
	}

	for (ll w = 1; w <= W; w++) {
		ll s1 = H * w;
		ll s2 = H * ((W-w)/2);
		ll s3 = H * (W-w-(W-w)/2);
		ll t = max(max(s1, s2), s3) - min(min(s1,s2), s3);
		ans = min(ans, t);
	}

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


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, Read in, PrintWriter out) {
            int n = in.nextInt();
            boolean cd = true;
            int pt = 0, px = 0, py = 0, ct = 0, cy = 0, cx = 0;
            for (int i = 0; i < n; i++) {
                ct = in.nextInt();
                cx = in.nextInt();
                cy = in.nextInt();
                int p = Math.abs(cx - px) + Math.abs(cy - py);
                if (cd && ((p > (ct - pt)) || (p & 1) != ((ct - pt) & 1))) {
                    cd = false;
                }
                pt = ct;
                px = cx;
                py = cy;
            }
            if (cd) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class Read {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public Read(InputStream inputStream) {
            din = new DataInputStream(inputStream);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Read(String file_name) {
            try {
                din = new DataInputStream(new FileInputStream(file_name));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public int nextInt() {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() {
            try {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

    }
}



Measured memory_bytes: 21588
package main

import (
	"fmt"
)

const mod = 998244353

var ifac, fac []int

var pows map[int]map[int]int

func main() {
	fac = make([]int, 2e5+1)
	ifac = make([]int, 2e5+1)
	inv := make([]int, 2e5+1)
	fac[0], fac[1] = 1, 1
	ifac[0], ifac[1] = 1, 1
	inv[0], inv[1] = 1, 1
	for i := 2; i < 2e5+1; i++ {
		fac[i] = (fac[i-1] * i) % mod
		inv[i] = (mod - inv[mod%i]*(mod/i)) % mod
		if inv[i] < 0 {
			inv[i] += mod
		}
		ifac[i] = (ifac[i-1] * inv[i]) % mod
	}

	pows = make(map[int]map[int]int)
	var n, m, k int
	fmt.Scan(&n, &m, &k)
	var ans int
	for i := 0; i <= k; i++ {
		ans += (comb(n-1, i) * pow(m-1, n-1-i))
		ans %= mod
	}
	ans *= m
	ans %= mod
	fmt.Println(ans)
}

func comb(n, r int) int {
	if r > n {
		return 0
	} else if r == 0 || r == n {
		return 1
	}
	t := (ifac[n-r] * ifac[r]) % mod
	return (t * fac[n]) % mod
}

func pow(a, b int) int {
	if r, ok := pows[a][b]; ok {
		return r
	}
	if b == 0 {
		return 1
	}
	if b == 1 {
		return a
	}
	var r int
	if b%2 == 0 {
		r = pow(a, b/2) * pow(a, b/2)
		r %= mod
	} else {
		r = pow(a, b-1) * a
		r %= mod
	}
	if _, ok := pows[a]; !ok {
		pows[a] = make(map[int]int)
	}
	pows[a][b] = r
	return r
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

vector<long long> X( 100000, 0 );

int main()
{
int i;
int N;
int a;
int b;
long long K;
long long c;

	cin >> N;
	cin >> K;

	for( i = 0; i < N; i++ )
	{
		cin >> a;
		cin >> b;

		X[ a ] += b;
	}

	i = 0;
	c = K;
	while( c > 0 )
	{
		i++;
		c -= X[ i ];
	}

	cout << i << endl;

	return 0;
}






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

bool dp[100005];

int main() 
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(i,k+1) dp[i] = false;

    rep(i,k+1) {
        for (auto v : a) {
            if (i - v >= 0) dp[i] |= !dp[i-v];
        }
    }

    if(dp[k]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
import collections
n,k = map(int, input().split())
l=[]
for i in range(n):
    x = list(map(int, input().split()))
    l+=x[1:]
c = collections.Counter(l)
s=0
for i in c.most_common():
    #print(i)
    if n == i[1]:
        s+=1
print(s)

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

long long num(long long X,long long c,long long d){
    return X - X/c - X/d + X/(c*d/__gcd(c,d));
}

int main(){
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << num(B,C,D) - num(A-1,C,D) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
  lli n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  lli len = n * m / __gcd(n, m);
  map<int, set<char>> ma;
  rep(i, s.size()) { ma[(len / n) * (i) + 1].insert(s[i]); }
  rep(i, t.size()) { ma[(len / m) * (i) + 1].insert(t[i]); }
  for (auto s : ma) {
    if (s.second.size() != 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << len << endl;
}


Measured memory_bytes: 23808
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a) for(int i=0;i<a;i++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main() {
	int n, x, y;
	cin >> n >> x >> y;
	int mx = min(x, y);
	int mn = max(x + y - n, 0);
	cout << mx << " " << mn;
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, ll> P;
typedef pair<ll, P> Pa;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<Pa> PQ;

char x[1000][1000];
int J[1000][1000], O[1000][1000], I[1000][1000];
int m, n, k;

int main(){
	scanf("%d%d%d", &m, &n, &k);
	rep(i,m){
		rep(j,n) scanf(" %c", &x[i][j]);
	}
	if(x[0][0] == 'J') J[0][0] = 1;
	else if(x[0][0] == 'O') O[0][0] = 1;
	else I[0][0] = 1;
	for(int i = 1; i < m; i++){
		J[i][0] = J[i-1][0]+(x[i][0]=='J');
		O[i][0] = O[i-1][0]+(x[i][0]=='O');
		I[i][0] = I[i-1][0]+(x[i][0]=='I');
	}
	for(int i = 1; i < n; i++){
		J[0][i] = J[0][i-1]+(x[0][i]=='J');
		O[0][i] = O[0][i-1]+(x[0][i]=='O');
		I[0][i] = I[0][i-1]+(x[0][i]=='I');
	}
	for(int i = 1; i < m; i++){
		for(int j = 1; j < n; j++){
			J[i][j] = J[i-1][j]+J[i][j-1]-J[i-1][j-1]+(x[i][j]=='J');
			O[i][j] = O[i-1][j]+O[i][j-1]-O[i-1][j-1]+(x[i][j]=='O');
			I[i][j] = I[i-1][j]+I[i][j-1]-I[i-1][j-1]+(x[i][j]=='I');
		}
	}
	rep(i,k){
		int x, y, X, Y;
		scanf("%d%d%d%d", &x, &y, &X, &Y);
		x--; y--; X--; Y--;
		if(x==0&&y==0){
			printf("%d %d %d\n", J[X][Y], O[X][Y], I[X][Y]);
		} else if(x == 0){
			printf("%d %d %d\n", J[X][Y]-J[X][y-1], O[X][Y]-O[X][y-1], I[X][Y]-I[X][y-1]);
		} else if(y == 0){
			printf("%d %d %d\n", J[X][Y]-J[x-1][Y], O[X][Y]-O[x-1][Y], I[X][Y]-I[x-1][Y]);
		} else{
			printf("%d %d %d\n", J[X][Y]-J[x-1][Y]-J[X][y-1]+J[x-1][y-1], O[X][Y]-O[x-1][Y]-O[X][y-1]+O[x-1][y-1], I[X][Y]-I[x-1][Y]-I[X][y-1]+I[x-1][y-1]);
		}
	}
}

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

const int64_t MOD= 1000000007;
/* 剰余環 Z/nZ */
struct mint{ // Z/nZ に関する演算(n:素数の場合は除算も)をサポートする構造体
  int64_t rep; // 出力すべき代表元 rep \in {0,1,..,MOD- 1}
  mint(int64_t x=0): rep(((x%MOD)+ MOD)% MOD){}
  mint operator-() const { return mint(-rep);}
  mint& operator+=(const mint& x){
    rep+= x.rep; 
    if(rep>= MOD) rep-= MOD;
    return *this;
  }
  mint& operator-=(const mint& x){
    rep-= x.rep;
    if(rep< 0) rep+= MOD;
    return *this;
  }
  mint& operator*=(const mint& x){
    rep*= x.rep; rep%= MOD;
    return *this;
  }
  mint operator+(const mint x) const {
    mint ans(*this);
    ans+= x;
    return ans;
  }
  mint operator-(const mint x) const {
    mint ans(*this);
    ans-= x;
    return ans;
  }
  mint operator*(const mint x) const {
    mint ans(*this);
    ans*= x;
    return ans;
  }
  bool operator==(const mint x) const {
    return rep==x.rep;
  }
  bool operator!=(const mint x) const {
    return rep!=x.rep;
  }

  mint pow(int64_t d) const{ // d \geq 0
    if(d==0) return 1;
    else{
      mint ans= pow(d>>1);
      ans*= ans;
      if(d&1){ ans*= *this; }

      return ans;
    }
  }

  friend istream& operator >> (istream &is, mint& x) noexcept{
    int64_t a;
    is >> a;
    x= a;
    return is;
  }
  friend ostream& operator << (ostream &os, const mint& x) noexcept{
      return os << x.rep;
  }
  // MOD が素数(<=> Z/nZ が体)のとき
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint& x){
    *this *= x.inv();
    return *this;
  }
  mint operator/(const mint x) const {
    mint ans(*this);
    ans/= x;
    return ans;
  }
};
// ^^^ テンプレここまで ^^^

int main(){
  const mint TBD= 1;
  int N,M;
  cin >> N >> M;

  vector<mint> ans(N+1, TBD);
  int broken;
  for(int i=0; i<M; i++){
    cin >> broken;
    ans.at(broken)= 0;
  }
  
  for(int i=2; i<=N; i++){
    ans.at(i)= (ans.at(i)==TBD) ? ans.at(i-2)+ ans.at(i-1)
                                : 0;
  }

  cout << ans.at(N) << endl;
}

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

const int nmax = 101;

bool judge(int area[nmax][nmax]){
	int r[nmax];
	for(int i = 1; i < nmax; i++){
		int count = 0;
		for(int j = 1; j < nmax; j++){
			count += area[i][j];
		}
		r[i] = count;
	}
	if(r[1] % 2 == 0 || r[2] % 2 == 0) return false;
	for(int i = 3; i < nmax; i++){
		if(r[i] % 2) return false;
	}
	return true;
}

int main(){
	int area[nmax][nmax];
	int a, b;
	while(cin >> a >> b){
		for(int i = 1; i < nmax; i++){
			for(int j = 1; j < nmax; j++){
				area[i][j] = 0;
			}
		}
		do{
			if(a == 0 && b == 0) break;
			area[a][b]++;
			area[b][a]++;
		}while(cin >> a >> b);
		if(judge(area)) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n; cin >> n;
    vector<int> color(9,0);
    rep(i,n){
        int r; cin >> r;
        color[min(8,r/400)]++;
    }
    
    int min_color = 0;
    rep(i,8){
        min_color += !!color[i];
    }
    
    cout << max(1,min_color) << " " << min_color + color[8] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int a, b, h;
	cin >> a >> b >> h;

	cout << (a+b)*h/2<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int r = 0, b = 0;
    string s;
    cin>>s;
    REPALL(i,s) {
        if (s[i] == '1')
            b++;
        else
            r++;
    }
    cout<<min(b,r) * 2<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[10000];
signed main(){
  int n;
  scanf("%lld", &n);
  rep(i,n)scanf("%lld", &a[i]);
  sort(a, a+n);
  int sum = 0;
  rep(i,n-1)sum += a[i];
  printf("%s\n", a[n-1] < sum ? "Yes" : "No");
  return 0;
}






Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a, b, c, d, e;
	scanf("%d %d %d", &a, &b, &c);
	if(a>0 && b>0 && c>0 && a<=100 && b<=100 && c<=100){
	if(b-a==c-b){
		printf("YES\n");
	}
	else if(b-c==a-b){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	}
	return 0;	
}

Measured memory_bytes: 128
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(" ");
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
    int answer = a * b;
		//出力
		Console.Write(answer);
	}
}

Measured memory_bytes: 27440
open System

let a = match stdin.ReadLine() with
    | "SUN" -> 7
    | "MON" -> 6
    | "TUE" -> 5
    | "WED" -> 4
    | "THU" -> 3
    | "FRI" -> 2
    | "SAT" -> 1

printfn "%d" a



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

int main() {
	int a;
  	cin >> a;
    if (64 <= a){
      cout << 64;
    }else if (32 <= a) {
      cout << 32;
    }else if (16<=a){
      cout << 16;
    }else if (8 <=a){
      cout << 8;
    }else if (4 <= a ){
      cout << 4;
    }else if(2<=a){
      cout << 2;
    }else{
      cout << 1;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int N;
    cin >> N;
    vector<int> p(N);
    vector<bool> judge(N);
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        p.at(i) = x;
        if(x == i + 1){
            judge.at(i) = 1;
        }
        else{
            judge.at(i) = 0;
        }
    }
    
    vector<int> renzoku(N);
    for(int i = 0; i < N; i++){
        renzoku.at(i) = 0;
    }
    
    int soeji = 0;
    
    for(int i = 0; i < N; i++){
        
        if(judge.at(i) == 1){
            renzoku.at(soeji)++;
        }
        else{
            soeji++;
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans+= ( renzoku.at(i) + 1 ) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
int main() {
    ll n;
    cin>>n;
    vi a(n);
    REP(i,n)cin>>a[i];
    RFOR(i,1,n){
        if(i%2==(n-1)%2)cout<<a[i]<<" ";
    }
    cout<<a[0]<<" ";
    FOR(i,1,n){
        if(i%2!=(n-1)%2)cout<<a[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp_ITP1_6_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var allCards = new List<string>
            {"S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13",
             "H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13",
             "C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13",
             "D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13",};

            var searchedCardsList = new List<string> { };
            var n = Int32.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                searchedCardsList.Add(Console.ReadLine());
            }

            var resultList = allCards.Except(searchedCardsList);

            foreach(string result in resultList)
            {
                Console.WriteLine(result);
            }
        }
    }
}


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

using namespace std;

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

    vector<int> s(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }

    vector<int> t(m + 1, 0);
    for (int i = 1; i <= m; i++) {
        cin >> t[i];
    }

    long long mod = 1000000007;

    vector<vector<long long>> dp0(n + 1, vector<long long>(m + 1, 0));
    vector<vector<long long>> dp1(n + 1, vector<long long>(m + 1, 0));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i] == t[j]) {
                dp1[i][j] = (dp0[i - 1][j - 1] + 1) % mod;
            }
            dp0[i][j] = (dp1[i][j] + dp0[i][j - 1] + dp0[i - 1][j] - dp0[i - 1][j - 1] + mod) % mod;
        }
    }

    long long res = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            res += dp1[i][j];
            res %= mod;
        }
    }

    cout << res << endl;;
}


Measured memory_bytes: 62976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

using int128 = __int128_t;
using uint128 = __uint128_t;
ostream &operator<<(ostream &os, int128 value) {
    ostream::sentry s(os);
    if (s) {
        uint128 tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) --d, *d = '-';
        int len = end(buffer) - d;
        if (os.rdbuf()->sputn(d, len) != len) {
            os.setstate(ios_base::badbit);
        }
    }
    return os;
}
istream &operator>>(istream &is, int128 &val) {
    string s; is >> s;
    val = 0;
    REP(i, s.size()) if ('0' <= s[i] && s[i] <= '9') {
        val = 10 * val + s[i] - '0';
    }
    return is;
}

int main(void) {
    int128 t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    int128 p = (a1-b1)*t1, q = (a2-b2)*t2;
    if(p > 0) p *= -1, q *= -1;

    if(p + q < 0) {
        cout << 0 << endl;
        return 0;
    }
    if(p + q == 0) {
        cout << "infinity" << endl;
        return 0;
    }

    int128 x = (-p) / (p+q);
    int128 r = (-p) % (p+q);
    cout << x*2 + !!r << endl;
    return 0;

    auto check = [&](int128 mid) {
        int128 nowx = (mid+1)/2*t1*a1 + mid/2*t2*a2;
        int128 nowy = (mid+1)/2*t1*b1 + mid/2*t2*b2;
        int128 prex = mid/2*t1*a1 + (mid-1)/2*t2*a2;
        int128 prey = mid/2*t1*b1 + (mid-1)/2*t2*b2;

        bool iscross = false;
        iscross |= prex <= prey && prey <= nowx && prex <= nowy && nowy <= nowx;
        iscross |= prey <= prex && prex <= nowy && prey <= nowx && nowx <= nowy;
        return iscross;
    };

    // REP(i, 150) dump(i, check(i));

    int128 lb = 1, ub = 1e22;
    while(ub-lb > 1) {
        int128 mid = (lb+ub)/2;
        if(check(mid)) lb = mid;
        else ub = mid;
    }
    cout << lb-1 << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int A,B,C,k,sum=0;
	cin>>A>>B>>C>>k;
	if(k<=A){
		cout<<k<<" ";
	}
	else{
		sum+=A;
		k-=A;
		if(k<=B){
			cout<<sum<<" ";
		}
		else{
			k-=B;
			cout<<sum-k<<" ";
		}
	}
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 3652
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
	    Stack<String> stack = new Stack<String>();
	    while(line != null){
	        if("0".equals(line)){
	            System.out.println(stack.pop());
	        }else{
	            stack.push(line);
	        }
	        line = br.readLine();
	    }
	}
}

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

int ans;
int a[50], b[50], c[50], d[50];
int n, m, q;

void dfs(vector<int> A) {
    if (A.size() == n + 1) {
        int now = 0;
        rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    dfs(vector<int>(1, 1));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
L = int(input())
a = list(map(int, input().split()))
b = []
flag = 0
for i in range(L):
    if a[i] > 0:
        if a[i] in b:
            print(i+1)
            flag = 1
            break
        else:
            b.append(a[i])
    else:
        if len(b) > 0 and b[-1] == -a[i]:
            b.pop()
        else:
            print(i+1)
            flag = 1
            break
if flag == 0:
    print('OK')


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    int a[100010];
    rep(i,0,n){
        int p; scanf("%d",&p);
        a[p-1]=i;
    }
    set<int> st;
    rep(rot,0,2){st.insert(-1); st.insert(n);}
    ll ans=0;
    rrep(i,n-1,-1){
        auto r1=st.lower_bound(a[i]);
        auto r2=r1,l1=r1; r2++; l1--;
        auto l2=l1; l2--;
        if(*l1>=0)ans+=1LL*(i+1)*(*l1-*l2)*(*r1-a[i]);
        if(*r1<n)ans+=1LL*(i+1)*(a[i]-*l1)*(*r2-*r1);
        st.insert(a[i]);
        cerr<<ans<<endl;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(void) {
    int W,H;
    int x,y,r;
    
    scanf("%d%d%d%d%d", &W,&H,&x,&y,&r);
    
    if(r<= x && x+r <= W && r<=y && y+r <= H) {
        printf("Yes\n");
    }else {
        printf("No\n");
    }
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;

int main(){

    int n;

    cin >> n;

    vector<pair<ll,ll>> v;
    
    rep(i,n){
        ll tmpx, tmpl;

        cin >> tmpx >> tmpl;

        v.pback(mpair(tmpx, tmpl));

    }

    sort(ALL(v));

    int ans = 0;
    ll  right = LLONG_MIN;
    ll  left =  LLONG_MIN;

    rep(i,n){

        ll x = v[i].first;
        ll l = v[i].second;

        if(right <= x - l){
            ans++;
            left = x - l;
            right = x + l;
        }else{
            if(left <= x -l && x + l <= right){
                left = x - l;
                right = x + l;
            }
        }

    }

    cout << ans << endl;
    

    return 0;
}

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


int main(){

	int N;
	cin >> N;
	int sum = 0, max = 0;
	for (int i = 0;i < N;i++) {
		int p;
		cin >> p;
		sum += p;
		if (max < p)
			max = p;
}
	cout << sum - max / 2 << endl;

	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;

long long gcd(long long x,long long y){
    return y?gcd(y,x%y):x;
}
int main(){

    long long a,b;
    cin >> a >> b;
    long long n=gcd(a,b);
    vector<long long> num;
    for(long long i=2;i*i<=n;i++){
        if(n%i) continue;
        while(n%i == 0){
            n /= i;
        }
        num.push_back(i);
    }
    if(n != 1) num.push_back(n);
    cout << num.size()+1 <<endl;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=[[None for _ in [0]*n] for _ in [0]*n]

for i in range(n):
	m=a[i]
	for j in range(n):
		k=i-j
		if k<0:
			k+=n
		m=min(m,a[k])
		b[j][i]=m

m=10**15
for i,j in enumerate(b):
	m=min(m,sum(j)+x*i)
print(m)

Measured memory_bytes: 136156
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a%3==0||b%3==0||(a+b)%3==0)
		printf("Possible\n");
	else
		printf("Impossible\n");
	return 0;
 } 

Measured memory_bytes: 256
l = []
cnt = 0
for i in range(5):
    l.append(int(input()))
    
k = int(input())

for i in range(len(l)):
    for j in range(len(l)):
        if i < j and abs(l[i] - l[j]) <= k:
            cnt += 1
            
if cnt == 10:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 61852
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

LL lcm(LL a,LL b)
{
    return a*b/__gcd(a,b);
}

LL a[100005];

int main()
{
    NO_TLE
    int n;
    cin>>n;
//    rep(i,n)cin>>a[i];
//    LL l=a[0];
//    rer(i,1,n-1)
//    {
//        LL t=__gcd(l,a[i]);
//        l=l/t*a[i];
//    }
//    LL sum=0;
//    l--;
//    rep(i,n)sum+=l%a[i];
//    cout<<sum<<endl;
    LL sum=0,x;
    while(n--)
    {
        cin>>x;
        sum+=x-1;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<vector<int>> G(N,vector<int> (N));
    for(int i=1; i<N; i++){
        for(int j=1; j<N; j++){
            G[i][j] = min({i,j,N-1-i,N-1-j});
        }
    }
    ll ans = 0;
    // for(int i=0; i<N; i++){
    //     for(int j=0; j<N; j++){
    //         cout << G[i][j] << " \n"[j+1 == N];
    //     }
    // }
    vector<vector<bool>> ext(N,vector<bool> (N,true));
    for(int i=0; i<N*N; i++){
        int p;
        cin >> p;
        p--;
        int s = p/N;
        int t = p%N;
        ans += G[s][t];
        ext[s][t] = false;
        queue<P> que;
        que.emplace(s,t);
        while(que.size()){
            int y,x;
            tie(y,x) = que.front();
            que.pop();
            for(int k=0; k<4; k++){
                int ny = y + dy[k];
                int nx = x + dx[k];
                if(ny<0 or ny>=N or nx<0 or nx>=N) continue;
                if(G[ny][nx] > G[y][x] + (ext[y][x])){
                    G[ny][nx] = G[y][x] + (ext[y][x]);
                    que.emplace(ny,nx);
                }
            }
        }

    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4708
def main():
    days = int(input())
    falliness = [int(x) for x in input().split()]
    satisfactions = [0]  # Never use index 0.
    for _ in range(days):
        satisfactions.append([int(x) for x in input().split()])

    last = [0] * 26
    sat_pre = 0
    for date in range(1, days + 1):
        for typ in range(26):
            if typ == 0:
                # こうしないと，どれを選んでも満足度が下がる場合に
                # 対応できない。
                best = (sat_pre, last, typ)
            last_tmp = last[0:]
            sat = sat_pre
            last_tmp[typ] = date
            sat += satisfactions[date][typ]
            sat -= sum(falliness[i] * (date - last_tmp[i]) for i in range(26))
            if sat > best[0]:
                best = (sat, last_tmp, typ)
        last = last_tmp[0:]
        sat_pre = best[0]
        print(best[2] + 1)


if __name__ == '__main__':
    main()


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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<int,P>;
using PP = pair<P, P>;
constexpr int INF = 1<<29;
// constexpr ll MOD = ll(1e9)+7;
constexpr ll MOD = 100000;
constexpr int di[] = {0,1,0,-1};
constexpr int dj[] = {1,0,-1,0};

ll power(ll x, ll n){
    ll res = 1;
    while(n > 0){
        if(n&1) res = res*x%MOD;
        x = x*x%MOD;
        n >>= 1;
    }
    return res;
}

ll dp[2][3][1<<20];

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    vector<int> U;
    for(int S=0;S<1<<w;S++){
        bool ok = true;
        for(int i=0;i<w-1;i++){
            ok &= ((S>>i)&3) != 3;
        }
        if(ok) U.emplace_back(S);
    }
    int cnt = 0;
    dp[0][2][0] = 1;
    for(int k=0; k<h*w; k++){
        int i = k/w, j = k%w;
        bool flag = s[i][j] == '?';
        if(flag) cnt++;
        for(int l=0; l<3; l++){
            for(int S : U){
                ll x = dp[k&1][l][S];
                if(x > MOD) x %= MOD;
                if(s[i][j] == 'J' || flag){
                    dp[(k&1)^1][0][S>>1] += x;
                }
                if(s[i][j] == 'O' || flag){
                    dp[(k&1)^1][1][(S>>1)|((l==0)<<(w-2))] += x;
                }
                if(s[i][j] == 'I' || flag){
                    if(j==w-1 || (S&1)==0) dp[(k&1)^1][2][S>>1] += x;
                }
            }
            fill(dp[k&1][l], dp[k&1][l]+(1<<w), 0);
        }
    }
    ll ans = power(3, cnt);
    for(int i=0;i<3;i++){
        for(int S : U){
            ans = (ans - dp[(h*w)&1][i][S] + MOD) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 52488
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};
    int w, h;
    int cnt = 0;
    int sx, sy;
    vector<string> v;
    while(true){
        cnt = 0;
        string tmp;
        v.clear();
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        rep(i, h){
            cin >> tmp;
            v.push_back(tmp);
            if(tmp.find('@') != string::npos){
                sx = i;
                sy = tmp.find('@');
            }
        }
        
        queue<pair<int, int> > q;
        q.push({sx, sy});
        while(!q.empty()){
            pair<int, int> p = q.front();
            q.pop();
            // cout << "Now : " << p.first << " " << p.second << endl;
            if(p.first >= h
                || p.second >= w
                || p.first  < 0
                || p.second < 0
            )continue;
            if((v[p.first][p.second] == '.' || v[p.first][p.second] == '@')) {
                v[p.first][p.second] = '#';
                cnt++;
                rep(i, 4){
                    q.push({p.first + dx[i], p.second + dy[i]});
                }
            }
        }
        cout << cnt << endl;
    }
}





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

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
int A[2][110];
int main()
{
    cin >> N;
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> A[i][j];
        }
    }
    int result = 0;
    for (int i = 0; i < N; i++){
        int sum = 0;
        for (int j = 0; j <= i; j++){
            sum += A[0][j];
        }
        for (int j = i; j < N; j++){
            sum += A[1][j];
        }
        result = max(result, sum);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 888
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        int[] array = new int[210];
        int ans = 0;

        for (int i = 0; i < N; ++i) {
            array[i] = fs.nextInt();
        }

        boolean flag = true;
        while (flag) {
            for (int i = 0; i < array.length; ++i) {
                if (array[i] % 2 == 1) {
                    flag = false;
                    break;
                }
                array[i] /= 2;
            }
            if (!flag) break;
            ++ans;
        }

        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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




Measured memory_bytes: 32496
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
 
using namespace std;
int MOD = 1000000007;

signed main(){
    int a,b;
    cin >> a >> b;
    int x1 = 0;
    int x2 = 0;
    for(int i = 0;i < (a)%4;i++){
        x1 = x1^(a-1-i);
        //debug(x1);
    }
    for(int i = 0;i < (b+1)%4;i++){
        x2 = x2^(b-i);
        //debug(x2);
    }
    


    cout << (x1^x2) << endl;

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc121.contest.atcoder.jp/tasks/abc121_a
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    ans += min(A[i],B[i])
    B[i] = B[i] - min(A[i],B[i])
    ans += min(A[i+1],B[i])
    A[i+1] = A[i+1] - min(A[i+1],B[i])
print(ans)

Measured memory_bytes: 18476
#include<bits/stdc++.h>
using namespace std;
int main(){
  int S;
  cin >> S;
  int a= S/100;
  int b=S%100;
  string ans;
  if(a>0 && a<13 && b>0 && b<13){
    ans="AMBIGUOUS";
  }
  else if((a==0 || a>12) && b>0 && b<13){
    ans="YYMM";
  }
  else if(a>0 && a<13&&(b==0||b>12)){
    ans="MMYY";
  }
  else{
    ans="NA";
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
/* const int MOD = 1000000007; */
const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<int> fac, finv, inv;

void comb_init(int n) {
  fac  = vector<int>(n);
  finv = vector<int>(n);
  inv  = vector<int>(n);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < n; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
 
int comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
  int N, A, B, K;
  cin >> N >> A >> B >> K;

  comb_init(N+1);

  int ans = 0;
  REP(i, N+1){
    int now = A*i;
    if(now > K) break;
    if((K-now)%B != 0) continue;
    int j = (K-now)/B;

    (ans += (comb(N, i)*comb(N, j))%MOD) %= MOD;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 7296
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    for i in a:
        if i%2 == 0 and (i%3 != 0 and i%5 != 0):
            print("DENIED")
            return
    print("APPROVED")
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940