akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#define N 50005
#define inf 2147483640
using namespace std;
int vis[3100];
int main(){
	int a, b, c, d, e, f, i, j, k, nowa, nowb;
   	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
   	for(i = 0; i <= 3000; ++i)
   	{
   		for(j = 0; j <= 3000; ++j)
        {
            if(i * c + j * d <= 3000)
                vis[i * c + j * d] = 1;
        }
   	}
   	nowa = 0;
   	nowb = a * 100;
   	for(i = 0; i <= 30; ++i)
   	{
   		for(j = 0; j <= 30; ++j)
   		{
   			for(k = 1; k <= 3000; ++k)
   			{
   				if(!vis[k]) continue;
   				if(i * 100 * a + j * 100 * b + k > f) continue;
   				if(k * (100 + e) > e * (i * 100 * a + j * 100 * b + k)) continue;
   				if(k * nowb > nowa * (i * 100 * a + j * 100 * b + k))
   				{
   					nowa = k;
   					nowb = i * 100 * a + j * 100 * b + k;
   				}
   			}
   		}
   	}
   	printf("%d %d\n", nowb, nowa);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int t = 0;
		int n = 0;
		int y = 0;
		for(int i=1;i<=4;i++){
			 t = scan.nextInt();
			 n = scan.nextInt();
			 if(t == 1){
			 	y = n * 6000;
			 }else
			 if(t == 2){
			 	y = n * 4000;
			 }else
			 if(t == 3){
			 	y = n * 3000;
			 }else
			 if(t == 4){
			 	y = n * 2000;
			 }
			 System.out.println(y);
		}
	}
}

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

#define N 1000000000000000000

int main() {
  string S;
  cin >> S;
  long long K;
  cin >> K;

  // 1123みたいな最初に1が2つ以上連続する場合の考慮が足りない.
  for(long long i = 0; i <= N; i++) {
    char s = S[i];
    if( K == i+1 ) {
      cout << s << endl;
      return 0;
    }

    if( s != '1' ) {
      cout << s << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int n = 0;
        while(a != 0){
            n++;
            System.out.println("Case " + n + ": "+a);
            a = scanner.nextInt();
        }
    }
}



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

void hit(int &score,int &base){
    base <<= 1;
    score += 1 & base>>3;
    base |= 1;
}

void homerun(int &score,int &base){
    for(int i=0;i<3;i++){
        score += base>>i & 1;
        base &= ~(1<<i);
    }
    score++;
}

int main(){
    int score,base,out_c,n;
    string s;

    cin>>n;
    cin.ignore();

    while(n--){
        score=0;
        base=0;
        out_c=0;
        while(out_c<3){
            getline(cin,s);
            if(s=="HIT"){
                hit(score,base);
            }else if(s=="HOMERUN"){
                homerun(score,base);
            }else{
                out_c++;
            }
        }

        cout<<score<<endl;
    }

    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n=0,m=0;
    int a[100000];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int  i=0;i<n;i++){
        if(i+1==a[a[i]-1]) m+=1;
    }
cout<<m/2<<endl;
return 0;
}

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



const int N = 105;


int n, a[N];

int rec(int l, int r){
    if(l > r){
        return 0;
    }
    int mn = 2e9;
    for(int i = l; i <= r; i++){
        mn = min(mn, a[i]);
    }
    int ans = mn;
    vector < int > q;
    q.push_back(l - 1);
    for(int i = l; i <= r; i++){
        a[i] -= mn;
        if(a[i] == 0){
            q.push_back(i);
        }
    }
    q.push_back(r + 1);
    for(int i = 0; i + 1 < (int)q.size(); i++){
        ans += rec(q[i] + 1, q[i + 1] - 1);
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    cout << rec(1, n);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 2000, MAX_SUM = 4000000;
int N;
ll A[MAX_N];

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

  cin >> N;
  rep(i, N) cin >> A[i];
  
  ll sum = 0;
  rep(i, N) sum += A[i];
  ll mid = (sum+1)/2;

  bitset<MAX_SUM+1> bs;
  bs[0] = 1;
  for (int i = 0; i < N; ++i) {
      bitset<MAX_SUM+1> newBs = bs << A[i];
      bs |= newBs;
  }

  ll ans = 0;
  for (int i = mid; i <= sum; ++i) {
      if (bs[i]) {
          ans = i;
          break;
      }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	return b ? gcd(b,a%b) : a;
}



/*最小公倍数*/

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    long double a,b,c;
    cin>>a>>b>>c;
    c-=a;
    c-=b;
    c-=2*sqrt(a*b);
    //cout<<c<<endl;
    if(c>0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
   
    
    
}


Measured memory_bytes: 256
#!python3

# input
N = int(input())

alpha = [chr(i) for i in range(97, 97+26)]


def main():
    x = N
    ans = ""
    while x > 0:
        x -= 1
        ans += alpha[x % 26]
        x //= 26
    print(ans[::-1])
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 9144
#include <iostream>
using namespace std;
int main(){
    int n,i,S[100];
    cin >> n;
    for(i=0; i<n; i++){cin >> S[i];}
    for(i=n-1; i>=0; i--){
        if(i!=n-1){cout << " ";}
        cout << S[i];
    }
    cout << endl;
    return 0;
    
}


Measured memory_bytes: 3112
<?php

list($a, $b) = explode(' ', trim(fgets(STDIN)));

for ($price = 1; (int)floor($price * 0.08) <= $a; ++$price) {
    if ((int)floor($price * 0.08) === (int)$a && (int)floor($price * 0.1) === (int)$b) {
        echo $price;
        exit;
    }
}

echo '-1';


Measured memory_bytes: 4856
import java.util.Scanner;

public class Main {

    static private Scanner sc = new Scanner(System.in);
    static private int n, k;
    static private int[] w;

    public static void main(String[] args) {
        input();
        int p = solve();
        System.out.println(p);
    }

    private static int solve() {
        int l = 0;
        int r = 10000 * n / k + 10;

        int p;
        while (l < r) {
            p = (r + l) / 2;
            if (check(p)) {
                r = p;
            } else {
                l = p + 1;
            }
        }

        return l;
    }

    private static boolean check(int p) {
        int c = 0;
        int t = 1;
        for (int i = 0; i < n; i++) {
            if (w[i] > p) {
                return false;
            }

            if (c + w[i] <= p) {
                c += w[i];
            } else {
                t += 1;
                c = w[i];
            }
        }

        return t <= k;
    }

    private static void input() {
        n = sc.nextInt();
        k = sc.nextInt();
        w = new int[100000];

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

Measured memory_bytes: 71280
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll X, Y;
  cin >> X >> Y;
  cout << X + Y/2 << rt;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstring>
#include<math.h>
using namespace std;

int main(){
    string str,str_cp;
    int operatorNum=0;
    long long int sum = 0;
    cin>>str;
    str_cp = str;
    int len = str.length();
    for(int i = 0; i < pow(2,len-1);i++){
        str_cp = str;
        operatorNum = 0;
        for(int j = 0; j < len - 1; j++){
            if((i&(int)pow(2, j)) != 0){
                str_cp.insert(j + operatorNum + 1, "+");
                operatorNum++;
            }
        }

        istringstream iss(str_cp);
        
        string part;

        for(int j = 0; j < operatorNum + 1;j++){

            getline(iss, part, '+');
            sum += atoll(part.c_str());
        }

    }

    printf("%lld", sum);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <map>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

struct info{
    string name;
    int score;
    int order;
};

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

    int x, y; cin >> x >> y;

    vector<int> list = { 1,3,1,2,1,2,1,1,2,1,2,1 };
    if (list.at(x - 1) == list.at(y - 1)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

 	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> s(M),c(M);
    for(int i=0; i<M; i++){
        cin >> s.at(i) >> c.at(i);
    }
    vector<int> ans(N,-1);
    bool judge = true;
    for(int i=0; i<M; i++){
        if((ans.at(s.at(i)-1)!=-1 && ans.at(s.at(i)-1)!=c.at(i)) || (N!=1 && (s.at(i)==1 && c.at(i)==0))) judge = false;
        else ans.at(s.at(i)-1) = c.at(i);
    }
  	if(N==1 && M==0){
      	cout << 0 << endl;
    }else if(!judge){
        cout << -1 << endl;
    }else{
        if(N!=1 && (ans.at(0)==0 || ans.at(0)==-1)){
           ans.at(0)=1;
        }
        for(int i=1; i<N; i++){
            if(ans.at(i)==-1) ans.at(i)=0;          	
        }
        int answer=0;
        for(int i=0; i<N; i++){
            answer += ans.at(i)*pow(10,N-i-1);
        }
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define ALL(x) (x).begin(),(x).end()
using namespace std;
const int MAXN = 200005;

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    vector<int>A(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    int flag = 1;
    while(k--&&flag){
        flag = 0 ;
        vector<int>B(n);
        for(int i=0;i<n;i++){
            int l = max(0,i-A[i]);
            int r = min(i+A[i]+1,n);
            B[l]++;
            if(r<n)
                B[r]--;
        }
        for(int i=1;i<n;i++){
            B[i]+=B[i-1];
            if(B[i]!=n)
                flag=1;
        //    cout << B[i] <<" \n"[i=n-1];
        }
        if(B[0]!=n)
            flag = 1;
        A=B;
    }
    for(int i=0;i<n;i++)
    cout <<A[i]<<" ";
    return 0;
}


Measured memory_bytes: 4900
import java.util.Scanner

fun main(args:Array<String>){
    val cin = Scanner(System.`in`)
    val n = cin.nextInt()

    loop@ for(i in 1..n){
	
	var x = i

	if(x % 3 == 0){
	    print(" $i")
	    continue@loop
	}
	
	while(x != 0){
	    if(x % 10 == 3 ){
	        print(" $i")
	        continue@loop
	    }
	x /= 10
	}
    }
    println()
}



Measured memory_bytes: 29412
#include <atcoder/mincostflow>
#include <iostream>
#include <vector>
#include <string>
#include <queue>

namespace ac = atcoder;

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

const std::vector<std::pair<int, int>> dxys{{0, 1}, {1, 0}};

constexpr int M = 5000;

void solve() {
    int h, w;
    std::cin >> h >> w;

    auto enc = [&](int x, int y) { return x * w + y; };

    std::vector<std::string> ss(h);
    for (auto& s : ss) std::cin >> s;

    int s = h * w * 2, g = s + 1;
    ac::mcf_graph<int, int> graph(h * w * 2 + 2);

    int snum = 0;
    for (int x = 0; x < h; ++x) {
        for (int y = 0; y < w; ++y) {
            if (ss[x][y] == 'o') {
                graph.add_edge(s, enc(x, y), 1, 0);
                ++snum;
            }
            graph.add_edge(enc(x, y) + h * w, g, 1, 0);
        }
    }

    for (int sx = 0; sx < h; ++sx) {
        for (int sy = 0; sy < w; ++sy) {
            if (ss[sx][sy] != 'o') continue;

            auto dist = vec(h, vec(w, -1));
            dist[sx][sy] = 0;
            std::queue<std::pair<int, int>> que;
            que.emplace(sx, sy);

            while (!que.empty()) {
                auto [x, y] = que.front();
                que.pop();

                for (auto [dx, dy] : dxys) {
                    int nx = x + dx,
                        ny = y + dy;
                    if (nx < 0 || h <= nx ||
                        ny < 0 || w <= ny ||
                        ss[nx][ny] == '#' ||
                        dist[nx][ny] != -1) continue;

                    dist[nx][ny] = dist[x][y] + 1;
                    que.emplace(nx, ny);
                }
            }

            for (int x = 0; x < h; ++x) {
                for (int y = 0; y < w; ++y) {
                    if (dist[x][y] == -1) continue;
                    graph.add_edge(enc(sx, sy), enc(x, y) + h * w, 1, M - dist[x][y]);
                }
            }
        }
    }

    auto [f, c] = graph.flow(s, g, snum);
    std::cout << M * f - c << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 7288
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  string mon="RYGB";
  cin>>a>>b>>c;
  for(int i=0;i<a;++i){
    for(int j=0;j<b;++j){
      int m=((i+j)%(c*2)+(c*2))%(c*2)/c,n=((i-j)%(c*2)+(c*2))%(c*2)/c;
      cout<<mon[m*2+n];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
 
const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;
ll arr[305];
int main()
{
    FIO
    int n; cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>arr[i];
    }
    ll x = 0;
    for(int i = 2 ; i< n ; i++)
        x ^= arr[i];
    ll a = arr[0], b = arr[1];
    if((arr[0] ^ arr[1]) == x)
        cout<<0<<endl;
    else {
        if((a + b) - (x) < 0 || ((a + b) - (x))%2 )
        {
            return cout<<-1, 0;
        }
        ll d = ((a + b) - (x)) / 2;
        if( d > a)
            return cout<<-1,0;
        ll na = d;
        ll y = 0;
        ll cnt = 0;
        for(ll i = 40 ; i!= -1 ;i--)
        {
            ll tmp = (1LL<<i);
            if((d&tmp) && (x&tmp))
                cnt++;
        }
        if(cnt)
            return cout<<-1, 0;
        for(ll i = 40; i!= -1 ; i--)
        {
            if((x & (1LL << i)))
            {
                if(((y|(1LL<<i))^d)<=a)
                    y |= (1LL <<i); 
            }
        }
        // cout<<na<<" "<<y<<endl;
        if((d^y)!=0)
            cout<<a - (d^y);
        else
            cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int N,a,t,s;
    int ans=0;
    int max,max2;
    std::vector<int> A;

    cin >> N ;
    for (int i=0;i<N;i++){
        cin >> a;
        if(ans<a){
            ans = a;
            s = i;
        }
        A.push_back(a);
    }

    max = *max_element( A.begin(), A.end() );
    t=A[s];
    A.erase(A.begin()+s);
    max2 = *max_element( A.begin(), A.end() );
    A.insert(A.begin()+s,t);
    for (int i=0;i<N;i++){
        if(A[i]!=max){
            cout<<max<<endl;
        }
        else{
            cout<<max2<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2548
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    int n;
    cin>> n;
    vector<vector<int>> a(2,vector<int> (n));
    rep(i,2){
        rep(j,n){
            cin>> a[i][j];
        }
    }

    int ans = 0;
    rep(i,n){
        int cnt = 0;
        rep(j,i+1){
            cnt += a[0][j];
        }
        for(int k=i;k<n;k++){
            cnt+=a[1][k];
        }
        ans = max (ans,cnt);
    }

    cout << ans;

    return 0;
}

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





bool test=0;
void solve()
{
 
    ll n;
    cin>>n;
    ll a[n];
    map<ll,ll>m;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    ll ans=0;
    for(auto it:m){
    if(it.second>1)
    ans+=(it.second*(it.second-1))/2;
    }
    for(ll i=0;i<n;i++)
    {
        ll x=m[a[i]];
        cout<<ans-(x-1)<<endl;
    }
}



















int main() {
    int t=1;
	if(test)
	cin>>t;
	while(t--)
	{
	    solve();
	}
	return 0;
}

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

int main(){
  string S;
  cin>>S;
  if(
    (S=="AKIHABARA")||
    (S=="AKIHABAR")||
     (S=="AKIHABRA")||
     (S=="AKIHBARA")||
     (S=="KIHABARA")||
     (S=="AKIHABR")||
     (S=="AKIHBAR")||
     (S=="KIHABAR")||
     (S=="AKIHBRA")||
     (S=="KIHABRA")||
     (S=="KIHBARA")||
     (S=="AKIHBR")||
     (S=="KIHABR")||
     (S=="KIHBAR")||
     (S=="KIHBRA")||
     (S=="KIHBR")
    ){
    cout<<"YES"<<endl;
      return 0;
  }
  cout<<"NO"<<endl;
  return 0;
}

    
    

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

int main() {
  int x = 0;
  int ans = 0;
  rep (i, 3) {
    char s = 'x';
    cin >> s;
    if ('R' != s) {
      if (x > ans) {
        ans = x;
      }
      x = 0;
    } else {
      x++;
    }
  }
  if (x > ans) {
    ans = x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,cnt=0;
    char str[256];
    cin >> N;
//    vector<int> A(N);
    for (int i=0;i<N;i++){
        cin >> str[i] ;
    }
    for(int i=0;i<N;i++){
        if(str[i]=='A'){
            if(str[i+1]=='B'){
                if(str[i+2]=='C'){
                    i+=2;
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String s = scan.next();


		int n = s.length();

				if(s.substring(0,(n-1)/2).equals(s.substring((n+1)/2,n))) {

				System.out.println("Yes");

			}else {

			System.out.println("No");

			}

		scan.close();
	}

}

Measured memory_bytes: 23124
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int n;
    cin >> n;
    vector<P> hani(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        hani[i] = P(a+b, a-b);
    }

    sort(all(hani));
    int ans = 0;
    int now = INT_MIN;
    rep(i, n) {
        if(now <= hani[i].second) {
            ans++;
            now = hani[i].first;
        }
    }

    cout << ans << endl;
}

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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    string N;
    cin>>N;
    int count = 0;
    for(char c : N){
        if(c=='2') count++;
    }
    cout<<count<<endl;
    return 0;
}

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

namespace _3
{
    class Program
    {
        static void Main(string[] args)
        {
            var one = Console.ReadLine();
            int intone = one.Length;

            string flag = "0";

            string[] arrsplit = one.Split(' ');

            string strone = arrsplit[0];
            string strtwo = arrsplit[1];
            string strthree = arrsplit[2];

            if (strone == strtwo)
            {
                flag = "1";
                if(strone == strthree)
                {
                    flag = "0";
                }
            }
            if (strone == strthree)
            {
                flag = "1";
                if (strtwo == strthree)
                {
                    flag = "0";
                }
            }

            if(strtwo == strthree)
            {
                flag = "1";
                if (strone == strthree)
                {
                    flag = "0";
                }
            }


            if (flag == "1") {
                Console.WriteLine("Yes");

            }else
            {
                Console.WriteLine("No");
            }

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    cnt = 0
    for i in range(n):
        hh = h[i]
        for j in g[i]:
            if h[j] >= hh:
                break
        else:
            cnt += 1
    print(cnt)


main()


Measured memory_bytes: 49080
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n, k;
    cin >> n >> k;
    vector<lli> v;
    v.pb(0);
    for1(i, 0, n)
    {
        lli a;
        cin >> a;
        v.pb(a);
    }
    // where.pb(0);
    vector<lli> where;
    // where.pb(0);

    where.pb(1);
    map<lli, lli> m;
    m[1] = 0;
    lli u = v[1];
    lli count = 1;
    lli f;
    while (1)
    {
        if (m[u] || u == 1)
        {
            f = m[u];
            break;
        }
        else
        {
            where.pb(u);
            m[u] = count;
            u = v[u];
            count++;
        }
    }
    // cout << count << " " << f << endl;
    // for1(i, 0, count)
    // {
    //     cout << where[i] << " ";
    // }
    lli ans;
    if (k <= f)
    {
        ans = where[k];
    }
    else
    {
        k -= f;
        lli x = count - f;
        lli u = k % x;
        ans = where[f + u];
    }

    cout << ans << endl;
}

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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int t[n];
  for(int i=0;i<n;i++) cin >> t[i];
  if(n==1){
    cout << abs(t[0]-b) << endl;
  }
  else{
    cout << max(abs(t[n-1]-b),abs(t[n-1]-t[n-2])) << endl;
  }
}

Measured memory_bytes: 256
def FOA(a, count):
	b = [a.count(a[i]) for i in range(len(a))]
	if  b == a:
		print(count)
		print(" ".join(map(str, b)))
		return
	else:
		return FOA(b, count+1)

while True:
	n = int(input())
	if n == 0:
		break
	a = list(map(int, input().split()))
	FOA(a, 0)

Measured memory_bytes: 7608
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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









Measured memory_bytes: 256
while True:
    a, op, b = input().split()

    a = int(a)
    b = int(b)

    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    else:
        break


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a=0,b,cmp,data,m=0,h=0,w,x,y,yy,yyy,yyyy,yyyyy,xcmp,ycmp,sum=0,r=0,c=0;

string s;

vector<int> z;

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

       cin >> n;
       rep(i,n){
           cin >> s;
           if(s[0]=='M'){
               m++;
               y=1;
           }
           else if(s[0]=='A'){
               a++;
               yy=1;
           }
           else if(s[0]=='R'){
               r++;
               yyy=1;
           }
           else if(s[0]=='C'){
               c++;
               yyyy=1;
           }
           else if(s[0]=='H'){
               h++;
               yyyyy=1;
           }
       }
       cmp=y+yy+yyy+yyyy+yyyyy;
       //Cout(cmp);
       //Cout(m);
       //Cout(a);
       //Cout(r);
       //Cout(c);
       //Cout(h);
       if(cmp>=3){
       if(m!=0&&a!=0&&r!=0){
           ans+=m*a*r;
       }
       if(m!=0&&a!=0&&c!=0){
           ans+=m*a*c;
       }
       if(m!=0&&a!=0&&h!=0){
           ans+=m*a*h;
       }
       if(a!=0&&r!=0&&c!=0){
           ans+=a*r*c;
       }
       if(a!=0&&r!=0&&h!=0){
           ans+=a*r*h;
       }
       if(r!=0&&c!=0&&h!=0){
           ans+=r*c*h;
       }
       if(m!=0&&r!=0&&c!=0){
           ans+=m*r*c;
       }
       if(m!=0&&r!=0&&h!=0){
           ans+=m*r*h;
       }
       if(m!=0&&c!=0&&h!=0){
           ans+=m*c*h;
       }
       if(a!=0&&c!=0&&h!=0){
           ans+=a*c*h;
       }
       }
       else{
           Cout(0);
           return 0;
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define COUT(x) cout << #x << " = " << (x) << ", "
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  ll N,K;
  cin >> N >> K;
  ll tmp = N % K;
  ll ans = min(K - tmp, tmp);
  cout << ans << endl;
}


Measured memory_bytes: 256
S = list(input())
T = list(input())

l = []
for i in range(len(S) - len(T) + 1):
    tmp = 0
    for j in range(len(T)):
        if T[j] == S[i + j]:
            tmp += 1
    l.append(tmp)

print(len(T) - max(l))

Measured memory_bytes: 9048
#include <iostream>
using namespace std;
int main(void){
    
    int age;
    
    cin >> age;
    
    if(age == 1) cout << "Hello World" << endl;
    else{
    
    int A, B;
    
    cin >> A >> B;
    
    cout << A + B << endl;
    
    }
    
    return 0;
    
}

Measured memory_bytes: 256
# Alice: a to b
# Bob: c to d
a,b,c,d = map(int, input().split())

if b <= c or d <= a:
  print(0)
elif (c<= a<b <=d):
  print(b-a)
elif (a<= c<d <=b):
  print(d-c)
elif (a <= c < b <= d):
  print(b-c)
elif (c <= a < d <= b):
  print(d-a)
else:
  print(None)


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 1000000007;
// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int x, y;
    cin >> x >> y;
    if ((x+y)%3!=0) {
        cout << 0 << endl;
        return 0;
    }
    int m = (2*x-y)/3, n = (2*y-x)/3;
    if (m<0 || n<0) {
        cout << 0 << endl;
        return 0;
    }
    cout << combination(m+n)(m+n,n) << endl;
    return 0;
}


Measured memory_bytes: 13784
import numpy as np
import math
import copy
import sys

rl = sys.stdin.readline

n,m,q=map(int,rl().split())
x=[list(map(int,rl().split())) for i in range(q)]
#x.sort(key=lambda x:x[3],reverse=True)

def calc(lst):
  sum=0
  #print(lst)
  for a,b,c,d in x:
    if(lst[b]-lst[a]==c):
      sum+=d
      #print(a,b,c,d,sum)
  return sum
      
def dfs(n,lst,i):
  ans=0
  lst.append(i)
  if(n==0):
    ans=calc(lst)
  else:
    for j in range(i,m+1):
      tmp=copy.copy(lst)
      ans=max(ans,dfs(n-1,tmp,j))
  return ans

ans=0
for i in range(1,m+1):
  ans=max(ans,dfs(n+1,[],i))
print(ans)

Measured memory_bytes: 27068
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int n, m;
string A[110], B[110];
int main() {
  while (cin >> n >> m) {
	for (int i = 0; i < n; ++i) cin >> A[i];
	for (int i = 0; i < m; ++i) cin >> B[i];
	bool ok = false;
	for (int i = 0; i < n; ++i) {
	  if (i + m > n) continue;
	  for (int j = 0; j < n; ++j) {
		if (j + m > n) continue;
		bool tmp = true;
		for (int k = 0; k < m; ++k) {
		  for (int l = 0; l < m; ++l) {
			if (A[i+k][j+l] != B[k][l]) tmp = false;
		  }
		}
		if (tmp) ok = true;
	  }
	}
	if (ok) puts("Yes");
	else puts("No");
  }
}


Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    H,N = LI()
    A = LI()
    if sum(A) >= H:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 52444
#include <iostream>
#include <string>
#include <map>

#define UNITE(x,y) x+y*10000000000L
#define MAX(x,y) (x<y?y:x)
#define MIN(x,y) (x>y?y:x)
#define llint unsigned long long int

int main(void){

  std::map<llint, int> m;

  llint h,w,n;
  std::cin >> h >> w >> n;

  for(int i=0; i<n; i++){
    llint a,b;
    std::cin >> a >> b;
    for(int y=MAX(a-1,2); y<=MIN(a+1,h-1); y++){
      for(int x=MAX(b-1,2); x<=MIN(b+1,w-1); x++){
	if(m.find(UNITE(y,x)) == m.end()){
	  m[UNITE(y,x)] = 1;
	}else{
	  m[UNITE(y,x)]++;
	}
      }
    }
  }


  llint res[10] = {};
  res[0] = (h-2)*(w-2) - m.size();
  for(auto it=m.begin(); it!=m.end(); it++){
    res[it->second]++;
  }

  for(int i=0; i<10; i++){
    std::cout << res[i] << std::endl;
  }
}

Measured memory_bytes: 56448
s1,s2,s3 = map(str,input().split())
str1 = list('abcdefghijklmnopqrstuvwxyz')
str2 = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
s1 = str1.index(s1[0])
s2 = str1.index(s2[0])
s3 = str1.index(s3[0])
ans = str(str2[s1]) + str(str2[s2]) + str(str2[s3])
print(ans)


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

using Point = complex<long double>;

int main(){
  int A, B; cin >> A >> B;
  int H, M; cin >> H >> M;
  long double T = (long double)(H * 60 + M) / 12 / 60;
  const long double PI = acos(-1);
  Point Pa(sin(2 * PI * T), cos(2 * PI * T));
  Pa *= A;

  Point Pb(sin(2 * PI * T * 12), cos(2 * PI * T * 12));
  Pb *= B;

  cout << fixed << setprecision(10);
  cout << abs(Pa - Pb) << endl;
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  ll cn = abs(x) / d;
  ll now = x;
  if(abs(x) >= d){
    if(cn <= k){
      k -= cn;
      if(x > 0){
        now = x - (cn * d);
      }else{
        now = x + (cn * d);
      }
    }else{
      if(x > 0){
        cout << abs(x - (k * d)) << endl;
        return 0;
      }else{
        cout << abs(x + (k * d)) << endl;
        return 0;
      }
    }
  }
  if(k % 2 == 0){
    cout << abs(now) << endl;
  }else{
    cout << min(abs(now-d), abs(now + d)) << endl;
  }
}

Measured memory_bytes: 3620
s=list(input())
N=len(s)
now=s[0]
L=[]
AL=[0]*N
for i,c in enumerate(s):
    if now == 'R' and c=='L':
        L.append((i-1,i))
        now='L'
    elif c=='R':
        now='R'
a,b,c,d=0,0,L[0][0],L[0][1]
m=0
for i,p in enumerate(s):
    if i>d and p=='R':
        a,b=c,d
        m+=1
        c,d=L[m][0],L[m][1]
    if i<=c and p=='R':
        if (c-i)%2==0:AL[c]+=1
        else:AL[d]+=1
    elif i<c and p=='L':
        if (i-b)%2==0:AL[b]+=1
        else:AL[a]+=1
    elif d<=i:
        if (i-d)%2==0:AL[d]+=1
        else:AL[c]+=1
print(" ".join(map(str,AL)))

Measured memory_bytes: 17964
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <time.h>
#include <bits/stdc++.h>

#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
const int INF=1e9+5;
int main() {
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    IO;
    int n ,w;
    cin>>n>>w ;
    vector<ll>dp(w+2);
    int weight , value;
    for(int i = 0 ;i < n ; i ++){
        cin>>weight>>value;
        for(int j =w-weight ; j >=0; j --){
            dp[j+weight]=max(dp[j+weight],dp[j]+value);
        }
    }
    ll ans= 0;
    for(int i =0 ; i <=w; i++)ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

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

  map<int, int>ma, mb;
  for(auto c:a)ma[c]++;
  for(auto p: ma)if(p.second>1) { cout<<0<<endl; return 0; }
  for(auto c:b)mb[c]++;
  for(auto p: mb)if(p.second>1) { cout<<0<<endl; return 0; }

  vector<pi> sorted_a;
  rep(i, n)sorted_a.push_back( {a[i], i} );
  sort( sorted_a.begin(), sorted_a.end() );

  vector<int> counter_a(n*m+1);
  vector<int> counter_b(n*m+1);
  for(auto c: a)counter_a[c]++;
  for(auto c: b)counter_b[c]++;
  rrep1(i, n*m)counter_a[i-1] += counter_a[i];
  rrep1(i, n*m)counter_b[i-1] += counter_b[i];

//for(auto c:counter_a)cout<<c<<' ';cout<<endl;for(auto c:counter_b)cout<<c<<' ';cout<<endl;

  ll result=1;
  rrep1(c, n*m){
    ll cca = counter_a[c];
    ll ccb = counter_b[c];
    ll reduce = (n*m-c);
//cout<<c<<' '<<result<<' '<<cca<<' '<<ccb<<' '<<ma[c]<<' '<<mb[c]<<' '<<reduce<<endl;

    if(ma[c]>0 && mb[c]>0){
//cout<<'*'<<c<<endl;      continue;
    }else if(ma[c]>0){
      result = result*ccb%MOD;
    }else if(mb[c]>0){
      result = result*cca%MOD;
    }else{
      result = result*(cca*ccb-reduce)%MOD;
    }
  }

  cout<<result%MOD<<endl;

  return 0;
}


Measured memory_bytes: 101888
#include<bits/stdc++.h>
#define FF ios_base::sync_with_stdio(0);cin.tie(0)
#define binary(value, size) cout << bitset<size>(value) << '\n'
#define PI acos(-1.0)   //3.1416(180 degree to radian)
#define PIby2 asin(1)     //(3.1416/2) for angle(90 degree to radian)
#define eps 1e-67
#define pf printf
#define sf scanf
#define sz size()
#define rr read
#define ww write
#define clr(arr) memset((arr),0,(sizeof(arr)))
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define repb(i,a,b) for(long long int i=a;i>=b;i--)
#define repa(i,a,b,c) for(long long int i=a;i<b;i=i+c)
#define reps(i,a,b,c) for(long long int i=a;i>b;i=i-c)
#define asort(a) sort(a.begin(),a.end())
#define asort2(a,comp) sort(a.begin(),a.end(),comp)
#define arev(a) reverse(a.begin(),a.end())
#define all(v) (v).begin(),(v).end()
#define all2(v,a,b) (v).begin()+a,(v).end()-b
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define pbb pop_back
#define mp make_pair
#define mt make_tuple
#define BS(v,x) binary_search(v.begin(),v.end(),x) //return true /false
#define LB(v,x) lower_bound(v.begin(),v.end(),x) //found and that value and not found than greater value pos
#define UB(v,x) upper_bound(v.begin(),v.end(),x) //found and greater value pos && not found also greater pos
#define convertlower(c) towlower(c)
#define root(x) sqrt(x)
#define power(a,n) pow(a,n)
#define tu(c) towupper(c)
#define sq(a) ((a)*(a))
#define cube(a) ((a)*(a)*(a))
#define mx 1000
#define MX 100000
#define mod 1000000007
#define INF 2000000000
#define N 10000000
#define Ceil(n) (long long int)ceil(n)
#define Floor(n) (long long int)floor(n)
#define deb(x) std::cout << #x << " = " << x << std::endl;
#define out(ans) cout<<ans<<endl
#define outs(ans) cout<<ans<<" "<<endl
using namespace std;
typedef string str;
typedef long long int ll;
typedef double lf;
typedef long double llf;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef char ch;
typedef map<ll,ll> mpl;
const ll MZ=100000;
ll freq[MZ+1];
int main()
{
       ll n,k; cin>>n>>k;
       rep(i,0,n)
       {
           ll a,b;cin>>a>>b;
           freq[a]+=b;
       }
       rep(i,1,MX+1)
       {
           if(k<=freq[i])
           {
               cout<<i<<endl;
               return 0;
           }
           k-=freq[i];
       }
       return 0;
}


Measured memory_bytes: 4424
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, k;
llint a[1005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+n+1);
	
	llint ans = 0;
	for(int i = 1; i <= k; i++) ans += a[i];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main()
{
    int m, f, r;
    char C;
    
   while(1)
   {
        cin >> m >> f >> r;
        
        if(m == -1 && f == -1 && r == -1)
        {
            break;
        }
        else if(m == -1 || f == -1)
        {
            C = 'F';
            cout << C << endl;
        }
        else if(m + f >= 80)
        {
            C = 'A';
            cout << C << endl;
        }
        else if(m + f >= 65 && m + f < 80)
        {
            C = 'B';
            cout << C << endl;
        }
        else if(m + f >= 50 && m + f < 65)
        {
            C = 'C';
            cout << C << endl;
        }
        else if(m + f >= 30 && m + f < 50 && r < 50)
        {
            C = 'D';
            cout << C << endl;
        }
        else if(m + f >= 30 && m + f < 50 && r >= 50)
        {
            C = 'C';
            cout << C << endl;
        }
        else if(m < 30 && f < 30)
        {
            C = 'F';
            cout << C << endl;
        }
        
   
   }
   return 0;
}


Measured memory_bytes: 3108