akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){

    int jenny[] = {1,2,1,2,1,4,1,4,1,2,1,2,1,4,1,4};
    int ans[8];
    int customer[8];

    while(true){

        int best = 60000;

        for(int i=0; i<8; i++){
            cin >> customer[i];

            if(cin.eof()){
                return 0;
            }
        }

        for(int i=0; i<8; i++){

            int thisBest = 0;

            for(int j=0; j<8; j++){
                if(customer[j] > jenny[j+i]){
                    thisBest += (customer[j] - jenny[j+i]);
                }
            }

            if(best >= thisBest){

                bool flag = false;

                if(best == thisBest){
                    for(int j=0; j<8; j++){
                        if(ans[j] < jenny[j+i]){
                            flag = true;
                            break;
                        }
                        if(ans[j] > jenny[j+i]){
                            break;
                        }
                    }
                }

                if(flag){
                    continue;
                }

                best = thisBest;

                for(int j=0; j<8; j++){
                    ans[j] = jenny[j+i];
                }
            }

        }

        for(int i=0; i<8; i++){
            cout << ans[i];
            cout << ((i == 7) ? '\n' : ' ');
        }

    }

    return 0;
}

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

using namespace std;

int main(void) {
  int a, b;
  cin >> a >> b;
  if(a == 1 || b == 1) {
    if(a == 1 && b == 1) {
      cout << "Draw" << endl;
    }
    else if(b == 1) {
      cout << "Bob" << endl;
    }
    else {
      cout << "Alice" << endl;
    }
  }
  else if(a < b) {
    cout << "Bob" << endl;
  }
  else if(a > b) {
    cout << "Alice" << endl;
  }
  else {
    cout << "Draw" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    char c; cin >> c;

    cout << (char)(c+1) << ln;
    return 0;
}

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

using namespace std;

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main() {
	int n;
	while (cin >> n, n) {
		cin.ignore();
		
		map<string, int> m;
		REP(i, n) {
			string str; getline(cin, str);
			stringstream ss(str);
			
			int cnt = count(ALL(str), ' ') + 1;
			REP(j, cnt) {
				ss >> str;
				m[str]++;
			}
			
		}
		
		vector<pair<int, string> > v[26];
		for (map<string, int>::iterator it = m.begin(); it != m.end(); ++it)
			v[it->fi[0] - 'a'].push_back(make_pair(-it->se, it->fi));
		
		string K; cin >> K;
		int k = K[0] - 'a';
		
		
		sort(ALL(v[k]));
		
		vector<string> ans;
		REP(i, min<int>(5, v[k].size())) ans.push_back(v[k][i].se);
		
		if (ans.empty()) puts("NA");
		else REP(i, ans.size()) cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');
				
	}
	return 0;
}

Measured memory_bytes: 3196
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll r,c,k;cin>>r>>c>>k;
    vector<vector<ll>> item(r,vector<ll>(c,0));
    REP(i,k){
        ll x,y,z;cin>>x>>y>>z;
        item[x-1][y-1]=z;
    }
    vector<vector<vector<ll>>> dp(r,vector<vector<ll>>(c,vector<ll>(4,0)));
    if(item[0][0]>0)dp[0][0][1]=item[0][0];
    REP(i,r){
        REP(j,c){
            REP(l,4){
                if(l<3){
                    if(i!=r-1){
                        dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][l]);
                        if(item[i+1][j]>0)dp[i+1][j][1]=max(dp[i+1][j][0],dp[i][j][l])+item[i+1][j];
                    }
                    if(j!=c-1){
                        dp[i][j+1][l]=max(dp[i][j+1][l],dp[i][j][l]);
                        if(item[i][j+1]>0)dp[i][j+1][l+1]=max(dp[i][j+1][l+1],dp[i][j][l]+item[i][j+1]);
                    }
                }else{
                    if(i!=r-1){
                        dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][l]);
                        if(item[i+1][j]>0)dp[i+1][j][1]=max(dp[i+1][j][0],dp[i][j][l])+item[i+1][j];
                    }
                    if(j!=c-1){
                        dp[i][j+1][l]=max(dp[i][j+1][l],dp[i][j][l]);
                    }
                }
            }
        }
    }
    cout<<*max_element(ALL(dp[r-1][c-1]))<<endl;
}

Measured memory_bytes: 706664
#include <iostream>
#include <math.h>
using namespace std;
int main( void )
{
	int sum_of_price = 0;
	int sum_of_number = 0;
	int price, number;
	char tmp;
	int count = 0;
	while ( cin >> price >> tmp >> number )
	{
		sum_of_price += price * number;
		sum_of_number += number;
		count++;
	}
	cout << sum_of_price << endl;
	cout << (int)ceil( (double)sum_of_number/count ) << endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;


ll N;
ll A[81];
ll dp[81];


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

	cin >> N;

	ll min = 3000;
	ll money = 1000;

	FOR(i, 1,N+1) {
		cin >> A[i];
	}
	dp[1] = 1000;

	for (int i = 2; i <= N; i++) {//日
		for (int j = i - 1; j >= 1; j--) {
			if (A[i] > A[j]) {
				dp[i] = max(dp[i], dp[j] + (dp[j] / A[j])*(A[i] - A[j]));
			}
		}
		for (int j = i - 1; j >= 1; j--)dp[i] = max(dp[i], dp[j]);
	}
		cout << dp[N] << endl;
	



	return 0;
}

Measured memory_bytes: 3636
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define MAXN 100
#define N (1 << 20)

int f[N];

int main() {
	cout << fixed << setprecision(12);	
	int n;
	cin >> n;
	for (int i = 1; i <= MAXN; i++) {
		for (int j = 1; j <= MAXN; j++) {
			for (int k = 1; k <= MAXN; k++) {
				int sum = i * i + j * j + k * k + i * j + i * k + j * k;
				f[sum]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << f[i] << endl;
	}
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

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

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define vint vector<signed>
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define yn(a) cout<<((a)?"Yes":"No")<<endl;
#define YN(a) cout<<((a)?"YES":"NO")<<endl;
#define call(a) for(auto i:(a))cout<<i<<" ";cout<<endl;
#define ENDL printf("\n");

int res,n;
bool check(int a);
void dfs(int a){
  if(a>n)return;
  if(check(a))res++;
  dfs(a*10+3);
  dfs(a*10+5);
  dfs(a*10+7);
}
bool check(int a){
  str s=to_string(a);
  bool l=false,j=false,k=false;
  rep(i,s.length()){
    if(s[i]=='3')l=true;
    if(s[i]=='5')j=true;
    if(s[i]=='7')k=true;
  }
  return (l&&j&&k);
}

signed main(){
  cin>>n;
  dfs(0);
  cout<<(res);

  return 0;
}


Measured memory_bytes: 256
//
// Created on 2020/05/02.
//


#include <iostream> // cout, endl, cin
#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
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans = 0;
    ll x;
    cin>>x;
    ll now = 100;

    while(now  < x){
        ans ++;
        now += now * 0.01;
    }

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define N 
#define mod 2019
using namespace std;
int L,R;
inline void Rd(int &res){
	char c;res=0;
	while(c=getchar(),c<48);
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>47);
	return;
}
int main(){
	Rd(L);Rd(R);
	if(R-L>=2018)puts("0");
	else{
		int ans=2e9;
		for(int i=L;i<R;i++){
			for(int j=i+1;j<=R;j++){
				long long x=1ll*i*j%mod;
				ans=min(ans,(int)(x));
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int r = sc.nextInt();

		PrintWriter out = new PrintWriter(System.out);
		out.println(3 * r * r);
		out.flush();
	}

	public static int gcd(int a, int b) {
	    if (b == 0) return Math.abs(a);
	    return gcd(b, a % b);
	}
}

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: 22612
n = int(input())
a = [int(i) for i in input().split()]
c = list(range(min(a), max(a) + 1))
d = []
for c_ in c:
    ans = int(sum([((a_ - c_) ** 2) for a_ in a]))
    d.append(ans)
print(min(d))

Measured memory_bytes: 3060
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val q = sc.nextInt()
    val lr = (0 until q).map { sc.next().toInt() to sc.next().toInt() }
    println(problem084d(q, lr))
}

fun problem084d(q: Int, lr: List<Pair<Int, Int>>): String {
    /**
     * 素数判定
     */
    fun isPrime(num: Int): Boolean {
        if (num < 2) return false
        if (num == 2) return true
        if (num % 2 == 0) return false

        val sqrtNum = Math.sqrt(num.toDouble()).toInt()
        for (i in 3..sqrtNum step 2) {
            if (num % i == 0) return false
        }
        return true
    }

    fun sieveOfEratosthenes(n: Int): List<Int> {
        val primes = IntArray(n) { 0 }
        for (i in 2..n) {
            if (isPrime(i)) {
                primes[i] = i
                for (j in i * 2 until n step i) {
                    primes[j] = 0
                }
            }
        }
        return primes.filter { it != 0 }
    }
    val primes = sieveOfEratosthenes(Math.pow(10.toDouble(), 5.toDouble()).toInt())
    val a = mutableListOf<Int>()
    for (i in 0 until Math.pow(10.toDouble(), 5.toDouble()).toInt()) {
        a.add(if (primes.contains(i) && primes.contains((i + 1) / 2)) 1 else 0)
    }
    a.add(0)
    val s = IntArray(Math.pow(10.toDouble(), 5.toDouble()).toInt() + 1) { 0 }
    for (i in 0 until Math.pow(10.toDouble(), 5.toDouble()).toInt()) {
        s[i + 1] = s[i] + a[i]
    }
    val ans = mutableListOf<Int>()
    for (i in 0 until q) {
        val (l, r) = lr[i]
        ans.add(s[r + 1] - s[l])
    }
    return ans.joinToString("\n")
}

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

int A, B, C, D;

int main() {
    cin >> A >> B >> C >> D;
    string ans = "Balanced";
    if (A + B > C + D) {
        ans = "Left";
    } else if (A + B < C + D) {
        ans = "Right";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

ll X[100010];
ll P[100010];
ll T[100010];
ll N, S;
vector<ll> dom;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> S;
    for (int i = 1;i <= N;i++) cin >> X[i] >> P[i];
	X[0] = 0;
    X[N + 1] = X[N] + 1;
    T[0] = 0;
    for (int i = 1;i <= N;i++) T[i] = T[i - 1] + P[i];
    if (S > X[N]) {
    	cout << S - X[1] << endl;
    	return 0;
    }
    if (S < X[1]) {
    	cout << X[N] - S << endl;
    	return 0;
    }
    ll l = 1, r = N;
    ll l_s = 0, r_s = 0;
    int crt = -1; // Negative
    if (P[1] >= P[N]) {
    	l_s = P[1];
    	dom.push_back(r);
    	dom.push_back(l);
    	l++;
    }
    else {
    	crt = 1;
    	r_s = P[N];
    	dom.push_back(l);
    	dom.push_back(r);
    	r--;
    }
    while (X[l - 1] < S && X[r + 1] > S) {
    	if (crt == -1) {
    		if (P[r] > l_s) {
    			dom.push_back(r);
    			r_s = l_s + P[r];
    			l_s = 0;
    			crt = 1;
    		} else {
    			l_s += P[r];
    		}
    		r--;
    	} else {
    		if (P[l] >= r_s) {
    			dom.push_back(l);
    			l_s = r_s + P[l];
    			r_s = 0;
    			crt = -1;
    		} else {
    			r_s += P[l];
    		}
    		l++;
    	}
    }
    // Calculate
    ll sol = 0;
    ll pos = S;
    for (int i = dom.size() - 1;i >= 0;i--) {
    	sol += abs(pos - X[dom[i]]);
    	pos = X[dom[i]];
    }
    cout << sol << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int N = 0;
    int M = 0;
    cin >> N >> M;

    int A[M] = {0};
    for (int i=0; i<N; i++) {
        int K = 0;
        cin >> K;
        for (int j=0; j<K; j++) {
            int temp;
            cin >> temp;
            ++A[temp-1];
        }
    }

    int result = 0;
    for (int i=0; i<M; i++) {
        if (A[i] == N) {
            ++result;
        }
    }
    cout << result;

    return 0;
};


Measured memory_bytes: 256
/*
AizuOnline A1275
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int m,n,k;
int st[10000];
//
init()
{
        int i;
        for(i=0;i<n;i++)
                st[i]=1;
}
main()
{
    int i,j,ret,s;

    while(scanf("%d %d %d",&n,&k,&m) && (m||n||k))
    {
            s=n;
            init();
            i=m;
            if(i==n)i=0;
            do
            {
#ifdef DEBUG
                    printf("%d ",i);
                    printf("\n");
#endif
                    s--;
                    st[i]=0;
                    j=k;
                    j=(k % s);
                    if(j==0)
                            j=s;
                    while(j>0)
                    {
                            i++;
                            if(i>n-1)
                                    i=0;
                            if(st[i])
                                    j--;
                    }
            }
            while(s>1);
            if(i==0)i=n;
            printf("%d\n",i);
    }
return(0);
}

Measured memory_bytes: 636
#include<cstdio>
#include<cstring>
#define rep(i,n) for(int i=0;i<(n);i++)

int N,M,K;
int J[1000][1000]={},O[1000][1000]={},I[1000][1000]={};




int main(){
	scanf("%d%d%d",&M,&N,&K);
	rep(i,M){
		char C[1010];
		scanf("%s",C);
		rep(j,N){
			if(C[j]=='J')J[i][j]=1;
			if(C[j]=='O')O[i][j]=1;
			if(C[j]=='I')I[i][j]=1;
			if(j>0){
				J[i][j]+=J[i][j-1];
				O[i][j]+=O[i][j-1];
				I[i][j]+=I[i][j-1];
			}

		//	printf("%d,%d,%d/",J[i][j],O[i][j],I[i][j]);
		}
//		printf("\n");

	}
	rep(i,K){
		int a,b,c,d,aj=0,ao=0,ai=0;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		a--;b--;c--;d--;
		for(int j=a;j<=c;j++){

			if(b-1>=0){
				aj+=J[j][d]-J[j][b-1];
				ao+=O[j][d]-O[j][b-1];
				ai+=I[j][d]-I[j][b-1];
			}
			else{
				aj+=J[j][d];
				ao+=O[j][d];
				ai+=I[j][d];
			}

		}
		printf("%d %d %d\n",aj,ao,ai);
	}
return 0;
}

Measured memory_bytes: 12712
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

N = i_inpl()
L = []

for _ in range(N):
    ab = l_inpl()
    L.append(ab)

L.sort(key=lambda x:x[0])
L.sort(key=lambda x:x[1])

t = 0
flag = True
for a, b in L:
    t += a
    if t > b:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 54344
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int f[102][10];
    int i, j;
    for (i = 0; i < n; i++)
        for (j = 0; j < 10; j++)
            scanf("%d", &f[i][j]);
    int p[102][11];
    for (i = 0; i < n; i++)
        for (j = 0; j < 11; j++)
            scanf("%d", &p[i][j]);
    int k, m, c;
    k = 1;
    long long int ans = 0, x;
    for (i = 0; i < n; i++)
    {
        m = k;
        c = 0;
        for (j = 0; j < 10; j++)
        {
            if (m % 2 == 1)
            {
                if (f[i][j] == 1)
                    c++;
            }
            m /= 2;
        }
        ans += (long long int)p[i][c];
    }
    for (k = 1; k < 1024; k++)
    {
        x = 0;
        for (i = 0; i < n; i++)
        {
            m = k;
            c = 0;
            for (j = 0; j < 10; j++)
            {
                if (m % 2 == 1)
                {
                    if (f[i][j] == 1)
                        c++;
                }
                m /= 2;
            }
            x += (long long int)p[i][c];
        }
        if (ans < x)
            ans = x;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main()
{
	int N;
	cin >> N;

	int donut = 0;

	for(donut = 0; donut*7 <= N; donut++) {
		if ((N - donut * 7) % 4 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, a;
  cin >> n >> a;
  n %= 500;
  if (a >= n) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;
typedef int64_t SI;
typedef uint64_t UI;

void read(SI& N, vector<SI>& V) {
  cin >> N;
  V.resize(N);
  for(size_t i=0; i<N; i++) {
    SI x;
    cin >> x;
    V[i] = x;
  }
}

int solve(const vector<SI>& V) {
  return 0;
}

void test() {
  {
    vector<UI> A = {4,6};
    vector<UI> B = {1,5};
    vector<UI> C = {3,8};
    UI K = 8;
    vector<SI> V = {0,1,2};
    assert(solve(V)==0);
  }
  cerr << "OK" << endl;
}

int main() {
  UI X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  vector<UI> A(X),B(Y),C(Z);
  for(SI i=0; i<X; i++) { cin >> A[i]; }
  for(SI i=0; i<Y; i++) { cin >> B[i]; }
  for(SI i=0; i<Z; i++) { cin >> C[i]; }

  vector<UI> AB(X*Y);
  for(size_t i=0; i<X; i++) {
    for(size_t j=0; j<Y; j++) {
      AB[i*Y+j] = A[i] + B[j];
    }
  }

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

  vector<UI> ABC;
  for(size_t i=0; i< min(K, (UI)AB.size()); i++) {
    for(size_t j=0; j<C.size(); j++) {
      ABC.push_back( AB[i]+C[j] );
    }
  }

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

  for(size_t i=0; i<K; i++) {
    cout << ABC[i] << std::endl;
  }

  return 0;
}



Measured memory_bytes: 42856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
  ll W;
  cin >> n >> W;
  int w[n];
  int v[n];
  ll sum = 0;
  for(int i = 0;i < n;i++){
    cin >> w[i] >> v[i];
    sum += v[i];
  }
  ll dp[n+1][sum+1];
  for(int i = 0;i <= n;i++){
    for(int j = 0;j <= sum;j++){
      dp[i][j] = 10000000000000;
    }
  }   
  dp[0][0] = 0;
  for(int i = 0;i < n;i++){
    for(int j = 0;j <= sum;j++){
      if(v[i] <= j){
        dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
      }else{
        dp[i+1][j] = dp[i][j];
      }
    }
  }
  ll ans;
  for(ll i = 0;i <= sum;i++){
    if(dp[n][i] <= W)ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
struct mon
{
	int x,h;
	bool operator<(const mon k)const
	{
		return x<k.x;
	}
}a[N];
int n,d,t,p,las,ans;
vector<pair<int,int>>v;
main()
{
	scanf("%lld%lld%lld",&n,&d,&t);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&a[i].x,&a[i].h);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		while(las<v.size()&&v[las].first<a[i].x)
		{
			p-=v[las].second;
			las++;
		}
		int k=(a[i].h+t-1)/t-p;
		if(k<=0)
			continue;
		p+=k;
		ans+=k;
		v.push_back(make_pair(a[i].x+2*d,k));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8560
#include <iostream>
#include <string>
using namespace std;
const int inf = 1<<23;
int main() {
  int h, w;
  while(cin >> h >> w && (h|w)) {
    string M[500];
    int dp[500][500] = {{}};
    
    for(int i=0; i<h; i++)
      cin >> M[i];
    
    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
	if(M[i][j] == '.') {
	  if(j) dp[i][j] = dp[i][j-1] + 1;
	  else dp[i][j] = 1;
	} else dp[i][j] = 0;
      }
    }

    int ans = 0;
    for(int j=0; j<w; j++)
      for(int i=0; i<h; i++) {
	int a = 0;
	int mn = inf;
	for(int k=i; k<h; k++) {
	  mn = min(mn, dp[k][j]);
	  a ++;
	  ans = max(ans, a * mn);
	}
      }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
	while(1){
		int x,y,s;
		cin >> x >> y >> s;
		if(x==0)break;
		int ans=0;
		for(int i=1;i<s;i++){
			for(int j=s-i;j>0;j--){
				if(i*(100+x)/100+j*(100+x)/100==s){
					ans = max(ans,i*(100+y)/100+j*(100+y)/100);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2960
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

#define ll long long

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	if (a%b == 0)return b;
	return gcd(b, a%b);

}
//最大公約数

ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}
//最小公倍数

int main() {

	ll X, Y;
	cin >> X >> Y;

	if (X%Y == 0)cout << -1 << endl;
	else if (Y%X == 0)cout << Y + X << endl;
	else cout << X << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int A,B,m;
	while(~scanf("%d%d",&A,&B))
	{
		if(A-2*B>0)
		m=A-2*B;
		else
		m=0;
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
sd = []
cp = []

for i in range(n):
  sd.append([int(j) for j in input().split()])
for i in range(m):
  cp.append([int(j) for j in input().split()])  
  
dist = [[0 for i in range(m)] for j in range(n)]

for i in range(n):
  for j in range(m):
    dist[i][j] = abs(sd[i][0] - cp[j][0]) + abs(sd[i][1] - cp[j][1])
    
for i in range(n):
  print(dist[i].index(min(dist[i]))+1)

Measured memory_bytes: 9104
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
x=int(input())
dp=[0]*(max(x+1,200))
dp[100]=1
dp[101]=1
dp[102]=1
dp[103]=1
dp[104]=1
dp[105]=1
if x<=199:
    print(dp[x])
    exit()
for i in range(200,x+1):
    if dp[i-100]==1 or dp[i-101]==1 or dp[i-102]==1 or dp[i-103]==1 or dp[i-104]==1 or dp[i-105]==1:
        dp[i]=1
print(dp[x])

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

int main()
{
  int N;
  cin >> N;
  // string w;
  map<string,int> mp;
  rep(i,N) {
    string w;
    cin >> w;
    sort(w.begin(),w.end());
    mp[w]++;
  }
  ll ans=0;
  for(auto& p : mp){
    ll count = p.second;
    ans += count * (count-1) / 2;  //ACになる
 // ans +=(ll) (count * (count-1))/2;  //WAになる
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 11136
import java.util.*;
public class Main {

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

        int x=scan.nextInt();
        int a=scan.nextInt();
        int b=scan.nextInt();
        String ans;
        if(a>=b){
            ans="delicious";
        }
        else if(a+x>=b){
            ans="safe";
        }
        else {
            ans="dangerous";
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 23892
def main():
    N = int(input())
    d1 = []
    d2 = []
    for _ in range(N):
        x, y = map(int, input().split())
        d1.append(x+y)
        d2.append(x-y)
    d1_dist = max(d1) - min(d1)
    d2_dist = max(d2) - min(d2)
    print(max([d1_dist, d2_dist]))

if __name__ == '__main__':
    main()


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

using namespace std;
int n,m,r,b[9],x,y,z,d[201][201],c[9],res=INT_MAX;
typedef pair<int,int>ii;
vector<ii>a[1001];
priority_queue<ii>qu;
void dijisktra(int u){
    qu.push(ii(0,u));
    d[u][u]=0;
    while(qu.size()){
        int u1=qu.top().second,du=qu.top().first;qu.pop();
        if(du!=d[u][u1])continue;
        for(int i=0;int v=a[u1][i].first;++i){
            int uv=a[u1][i].second;
            if(d[u][v]>du+uv){
                d[u][v]=du+uv;
                qu.push(ii(d[u][v],v));
            }
        }
    }
}
bool kt[9];
void kiemtra(){
    int tam=0;
    //for(int i=1;i<=r;++i)cout<<c[i]<< " ";cout<<endl;
    for(int i=2;i<=r;++i)tam+=d[c[i-1]][c[i]];
    //cout<<tam<<endl;
    res=min(res,tam);
}
void sinhdaynhiphan(int k){
    for(int i=1;i<=r;++i)if(!kt[i]){
        kt[i]=true;
        c[k]=b[i];
        if(k==r)kiemtra();
        else sinhdaynhiphan(k+1);
        kt[i]=false;
    }
}
int main()
{
    //freopen("main.inp","r",stdin);
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


    cin>>n>>m>>r;
    for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)d[i][j]=INT_MAX;
    for(int i=1;i<=r;++i)cin>>b[i];
    //for(int i=1;i<=r;++i)cout<<b[i]<<" ";
    //for(int i=1;i<=n;++i){cout<<i<<":  ";for(int j=1;j<=n;++j)cout<<d[i][j]<<" ";cout<<endl;}
    for(int i=1;i<=m;++i){
        cin>>x>>y>>z;
        a[x].push_back(ii(y,z));
        a[y].push_back(ii(x,z));
    }
    for(int i=1;i<=n;++i)a[i].push_back(ii(0,0));
    for(int i=1;i<=n;++i)dijisktra(i);
    //for(int i=1;i<=n;++i){cout<<i<<":  ";for(int j=1;j<=n;++j)cout<<d[i][j]<<" ";cout<<endl;}
    sinhdaynhiphan(1);
    cout<<res;
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  double N, K;
  cin>>N>>K;
  double ans=0;
  double tmpans;
  int tmp;
  for(int i=1;i<=N;++i) {
    if(i>=K) ans += 1/N;
    else {
      tmpans = 1/N;
      tmp = i;
      while(tmp<K) {
        tmpans /= 2;
        tmp *= 2;
      }
      ans += tmpans;
    }
  }
  cout<<setprecision(20)<<ans<<endl;
}



Measured memory_bytes: 3752
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    int a = A;
    int b = B;
    int c = C;
    for(int i = 0; i < K; i++){
      a *= 2;
      b *= 2;
      c *= 2;
    }
    
    System.out.println(Math.max(a+B+C, Math.max(A+b+C, A+B+c)));
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

using namespace std;

int main()
{
	string s;
	while(cin >> s)
	{
		if(s == "0") break;

		int pa = 0,pb = 0;

		REP(i,1,s.size())
		{
			if(s[i] == 'A') pa++;
			if(s[i] == 'B') pb++;
		}

		if(pa > pb) pa++;
		else pb++;

		cout << pa << " " << pb << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
import bisect

n = int(input())
L = list(map(int, input().split()))
L = sorted(L)
ans = 0
for a in range(n-2):
    for b in range(a+1, n-1):
        ab = L[a] + L[b]
        r = bisect.bisect_left(L, ab)
        l = b + 1
        ans += r - l
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<cmath>
template<typename T>
bool calcMin(T& a,T b){
    if(a>b){
        a=b;
        return true;
    }
    else{
        return false;
    }
}
int main(){
    int N,K;
    std::cin>>N>>K;
    std::vector<int>h(N);
    std::vector<unsigned long long>dp(N,1e10);
    for(int i=0;i<N;++i){
        std::cin>>h[i];
    }
    dp[0]=0;
    for(int i=0;i<N;++i){
        for(int j=i+1;j<=std::min(i+K,N-1);++j){
            calcMin(dp[j],dp[i]+(unsigned long long)(std::abs(h[i]-h[j])));
        }
    }
    std::cout<<dp[N-1]<<std::endl;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

int main()
{
    int d, t, s;
    cin >> d >> t >> s;

    string ans = s * t >= d ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

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

    if(s.size() <= k){
        cout << s;
    } else {
        REP(i,k){
        cout << s[i];
        }
        cout << "...";
    }
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
from itertools import combinations
from operator import contains

def readlines(n):
    for _ in range(n):
        x, y = input().split()
        yield int(x)-1, y=="1"

def main():
    n = int(input())
    asserts = []

    for _ in range(n):
        a = int(input())
        asserts.append(list(readlines(a)))

    def check(comb):
        for i in comb:
            for x, y in asserts[i]:
                mujun = contains if not y else lambda a, b: b not in a
                if mujun(comb, x):
                    return -1
        
        return len(comb)

    for i in range(n+1):
        for comb in combinations(range(n), i):
            yield check(set(comb))

    yield 0

print(max(main()))

Measured memory_bytes: 3064
readint()=parse.(Int,readline())
S=readint()

MOD = 10^9+7
NMax = S+(S÷3)
fac=ones(Int,NMax)#factorial_mod
for i in 2:NMax
    fac[i]=fac[i-1]*i%MOD
end

function CMOD(a,b)#binominal_mod
    fac[a]*invmod(fac[b],MOD)%MOD*invmod(fac[a-b],MOD)%MOD
end

function pp_d(S)
    maxD = S ÷ 3
    allP = 0
    for i in 2:maxD
        nokori=S-3*i
        if nokori==0
            allP=mod(allP+1,MOD)
        else
            allP+=mod(CMOD(nokori+(i-1),(i-1)),MOD)
        end
    end
    if S > 2 
        allP=mod(allP+1,MOD)
    end
    allP
end

print(pp_d(S))

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

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
//        int int1 = Integer.parseInt(scan.next());
//        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        int int4 = Integer.parseInt(scan.next());
        int ans_int = 0;
        String ans = "";
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        double ans_dob = 0;
        if(str1.equals("Sunny")){
            ans = "Cloudy";
        }else if(str1.equals("Cloudy")){
            ans = "Rainy";
        }else{
            ans = "Sunny";
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 24148
#include <iostream>
#include <numeric>
int main(){
  int n,u[101],l[101],a=0;
  std::cin>>n;
  for(int i=0;i!=n;++i)std::cin>>u[i];
  for(int i=0;i!=n;++i)std::cin>>l[i];
  for(int i=1;i!=n+1;++i){
    a = (a<std::accumulate(u, u+i, std::accumulate(l+i-1, l+n, 0))?std::accumulate(u, u+i, std::accumulate(l+i-1, l+n, 0)):a);
  }
  std::cout<<a<<"\n";
}

Measured memory_bytes: 256
//Fennec vs Monster

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int N, K;cin >> N >> K;
    vector<ll> H(N);
    rep(i,0,N)cin >> H[i];
    sort(range(H),greater<int>());
    for(int i = 0;i<min(N,K);i++)H[i]=0;
    cout << accumulate(range(H),0LL) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int solve(int n)
{
	if(n==2)return 1;
	int n1=n-1;

	set<int>sett;
	for(int i=1;i*i<=n1;i++)
	{
		if(n1%i==0)
		{
			sett.insert(i);
			sett.insert(n1/i);
		}
	}
	sett.insert(n);
	for(int i=2;i*i<=n;i++)
	{

		int num=n;
		while(num%i==0)num/=i;
		if(num%i==1)sett.insert(i);
	}
	return sz(sett)-1;
	// return  0;

}
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	int n;cin>>n;
	cout<<solve(n);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
    int k,n;
    cin >> k >> n;
    vector<int>v;
    while(n--){
        int c;
        cin >> c;
        v.push_back(c);
    }
    sort(v.begin(),v.end());
    int mx = 0;
    for(int i =1;i < v.size();i++){
        mx = max(v[i] - v[i - 1],mx);
    }
    mx = max((k - (v[v.size() - 1] - v[0])),mx);
    cout <<  k - mx << endl;
}


Measured memory_bytes: 4328
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
map<pair<ll,ll>,ll> mp;

ll func(ll s,ll x){
//    if(s==0 && x == 0){
//        return 1;
//    }else if(s == 1 && x == 1){
//        return 2;
//    }else if(s == 2 && x == 0){
//        return 2;
//    }else if(s < 0 || x < 0){
//        return 0;
//    }
    if(s == 0 && x == 0){
        return 1;
    }else if(x < 0 || s < 0){
        return 0;
    }
    if(mp.find(make_pair(s,x)) != mp.end() ){
        return mp[make_pair(s,x)];
    }
//    ll ret = (func(s/2,x/2) + func((s-1)/2,(x-1)/2) + func((s-2)/2,x/2)) % MOD;
    ll  ret = func(s/2,x/2);
    ret %= MOD;
    if(s > 0 && x > 0) ret += func((s-1)/2,(x-1)/2);
    ret %= MOD;
    if(s > 1) ret += func((s-2)/2,x/2);
    ret %= MOD;

    mp[make_pair(s,x)] = ret;
    return ret;
}

int main() {
    ll N;
    cin >> N;
    cout << func(N,N) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	vi a(3);
	rep(i, 3) cin >> a[i];
	sort(all(a));
	int sum = 0;
	repn(i, 1, 3) sum += (a[i] - a[i - 1]);
	cout << sum << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N,M;
  cin>>N>>M;

  vector<int> a(N+1,-1);
  for(int i=0;i<M;i++){
    int x;
    cin>>x;
    a.at(x)=0;
  }

  a.at(0)=1;
  if(a.at(1)!=0) a.at(1)=1;

  for(int i=2;i<N+1;i++){
    if(a.at(i)!=0){
      a.at(i)=a.at(i-1)+a.at(i-2);
    }
    a.at(i)%=MOD;
  }
  cout<<a.at(N)<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<n+1;i++)

using namespace std;
using std::swap;

vector<long long int> v;
vector<long long int> w;



int main() {
	long long int N, T, F, FT, ANS;
	cin >> N;

	T = N / 3;
	F = N / 5;
	FT = N / 15;
	ANS = (1 + N)*N / 2;
	ANS = ANS - (T * 3 + 3)*T / 2 - (F * 5 + 5)*F / 2 + (FT * 15 + 15)*FT / 2;
	cout << ANS << "\n";
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	int i,i2,afront,bfront;
	char a[10],b[10],c[10];
	cin>>a>>b>>c;
	afront=(strlen(a))-1;
	bfront=(strlen(b))-1;
	if(a[afront]==b[0]&&b[bfront]==c[0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char S,T;
  cin >> S;
  if(S == 'A'){
    T = 'T';
  }else if(S == 'T'){
    T = 'A';
  }else if(S == 'G'){
    T = 'C';
  }else{
    T = 'G';
  }
  cout << T << endl;
}


Measured memory_bytes: 256