akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;
vector<vector<int>> costs;
int main() {
	int h, w, d, a, inverse[300 * 300];
	scanf("%d %d %d", &h, &w, &d);
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			scanf("%d", &a);
			inverse[a - 1] = (i << 16) + j;
		}

	costs.resize(d);
	int px, py, x, y;
	for (int i = 0; i < d; i++) {
		costs[i].push_back(0);
		px = inverse[i] >> 16, py = inverse[i] & 0xffff;
		for (int j = i + d; j < h * w; j += d) {
			x = inverse[j] >> 16, y = inverse[j] & 0xffff;
			costs[i].push_back(costs[i].back() + abs(x - px) + abs(y - py));
			px = x, py = y;
		}
	}

	int q, l, r, res;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d %d", &l, &r);
		l--, r--;
		res = costs[r % d][r / d] - costs[l % d][l / d];
		printf("%d\n", res);
	}
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
 string arr;
 int len;
 const int  mod = 1e9+7;
long long dp[100001][14][2];

long long back(int in, int num , bool flag  ){
	
 	if(in> len) {   if(num%13==5) return 1; else return 0; }
 	
 	if(dp[in][num][flag]!=-1)	return dp[in][num][flag];
 	
 	long long res=0;
 	
 	
 	if(arr[in-1]!='?')  res=back(in+1, ( num*10 + (arr[in-1]-'0') )%13 ,flag)%mod;
 	
 	else {
	 	 int limit = 9;
	 	 
	 	for(int i=0; i<=limit; ++i){
	 	res+= (back(in+1, (10*num + i)%13, flag || i<limit)%mod);		
	 	res%=mod;
	 	}
 	}
 	return dp[in][num][flag] = res%mod;
 }
 
 
 
int main() {
	

	cin>>arr;
	len = arr.size();
	memset(dp, -1, sizeof dp);
	 
	 long long c= back(1,0,false)%mod + mod;
	 c%=mod;
	 cout<<  c <<'\n'; 
	return 0;
}


Measured memory_bytes: 35012
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <set>

using namespace std;
typedef long long ll;

int N;
vector<int> v;
vector<int> arr;
vector<int> num;
multiset<int> mst;
ll M;

struct SEG{
	SEG(int l, int r, int sum) : l(l), r(r), sum(sum) {}
	int l, r;
	int sum;
};
vector<SEG> seg;

void update(int idx, int s, int e, int x, int y){
	seg[idx].sum+=y;
	if(s==e)	return;
	if(x<=(s+e)/2){
		if(seg[idx].l==-1){
			seg[idx].l = seg.size(); seg.push_back({-1, -1, 0});
		}
		update(seg[idx].l, s, (s+e)/2, x, y);
	}else{
		if(seg[idx].r==-1){
			seg[idx].r = seg.size(); seg.push_back({-1, -1, 0});
		}
		update(seg[idx].r, (s+e)/2+1, e, x, y);
	}
}

int sum(int idx, int s, int e, int x, int y){
	if(idx==-1)	return 0;
	if(x<=s && e<=y)	return seg[idx].sum;
	if(s>y || e<x)	return 0;
	return sum(seg[idx].l, s, (s+e)/2, x, y)+sum(seg[idx].r, (s+e)/2+1, e, x, y);
}



int main(){
	scanf("%d", &N);
	seg.push_back({-1, -1, 0});
	M = ((ll)N * (ll)(N+1))/2;
	for(int i=0; i<N; i++){
		int x; scanf("%d", &x); arr.push_back(x); v.push_back(x); num.push_back(x);
	}sort(num.begin(), num.end());
	int s = 0, e = N-1, m;
	ll cnt;
	while(s<e){
		m = (s+e)/2;
		cnt = 0;
		int now = num[m];
		//cout<<now<<endl;
		for(int i=0; i<v.size(); i++){
			if(arr[i]<=now)	v[i] = 1;
			else v[i] = -1;
		}
		int t = 0;
		update(0, 0, N*2, N, 1);
		for(int i=0; i<v.size(); i++){
			t += v[i];
			cnt += (ll)sum(0, 0, N*2, 0, N+t-1);
			//cout<<t<<' '<<i<<' '<<sum(0, 0, N*2, 0, N+t-1)<<endl;
			update(0, 0, N*2, N+t, 1);
		}
		t = 0;
		update(0, 0, N*2, N, -1);
		for(int i=0; i<v.size(); i++){
			t+=v[i];
			update(0, 0, N*2, N+t, -1);
		}
		if(cnt>=M/2+1){
			e = m;
		}else{
			s = m+1;
		}
	}
	printf("%d", num[s]);

}

Measured memory_bytes: 6372
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			int t = sc.nextInt();
			int l = sc.nextInt();
			int b = sc.nextInt();
			if(n == 0 && t == 0 && l == 0 && b == 0)break;
			else calc(n,t,l,b);
			
		}
	}
	
	public void calc(int n, int t, int l, int b){
		int[] masu = new int[n+1];
		for(int i = 0; i < l; i++){
			masu[sc.nextInt()] = 1;
		}
		for(int i = 0; i < b; i ++){
			masu[sc.nextInt()] = -1;
		}
		
		double[][] dp = new double[105][105];
		dp[0][0] = 1;
		
		for(int tt = 0; tt < t+1; tt++){
			for(int nn = 0; nn < n; nn++){
				for(int k = 1; k < 7; k++){
					int next = nn + k;
					if(next > n) next = n - next + n;
					if(masu[next] == -1) next = 0;
					
					if(masu[next] == 1)	 dp[tt+2][next] += dp[tt][nn] / 6;
					else dp[tt+1][next] += dp[tt][nn] / 6;
				}
				nn = nn;
			}
		}
		
		double ans = 0;
		for(int i = 0; i < t+1; i++){
			ans += dp[i][n];
		}
		System.out.printf("%.7f\n", ans);
	}
	
	public void calc2(int n, int t, int l, int b){
		int[] masu = new int[n+1];
		for(int i = 0; i < l; i++){
			masu[sc.nextInt()] = 1;
		}
		for(int i = 0; i < b; i ++){
			masu[sc.nextInt()] = -1;
		}
		double ans = 0;
		int[] nowList = new int[n+1];
		int[] nowMachi = new int[n+1];
		nowList[0] = 1;
		for(int a = 0; a < t; a++){
			int sum = 0;
			int[] nextList = new int[n+1];
			int[] nextMachi = new int[n+1];
			for(int i = 0; i < n+1; i++){
				int nowNum = nowList[i];
				
				if(nowNum > 0){
					for(int k = 1; k < 7; k++){
						int next = i + k;
						if(next > n) next = n - (next - n);
						
						if(next == n) sum+=nowNum;
						else if(masu[next] == -1) nextList[0] += nowNum;
						else if(masu[next] == 1) nextMachi[next] += nowNum;
						else nextList[next] += nowNum;
					}
				}
			}
			for(int i = 0; i < n+1; i++){
				nextList[i] += nowMachi[i];
			}
			nowList = nextList;
			nowMachi = nextMachi;
			ans += ((double)sum) / Math.pow(6, (a+1));
		}
		System.out.printf("%.7f\n", ans);
	}
	

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 24216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string bans(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  vector<int> abc(3);
  rep(i,3){
    cin>>abc[i];
  }
  sort(all(abc));
  int k;cin>>k;
  k=pow(2,k);
  int ans=abc[0]+abc[1]+abc[2]*k;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        n: usize,
        m: usize,
        ab: [[usize; 2]; m],
    }
    let mut ad = vec![vec![]; n];
    for i in 0..m {
        ad[ab[i][0]-1].push(ab[i][1]);
        ad[ab[i][1]-1].push(ab[i][0]);
    }
    let mut ans = vec![0; n];
    let mut q = std::collections::VecDeque::new();
    q.push_back(0);
    let mut d = vec![0; n];
    while let Some(node) = q.pop_front() {
        for iter in &ad[node] {
            if d[iter-1] <= d[node] && ans[iter-1] == 0 {
                d[iter-1] = d[node] + 1;
            ans[iter-1] = node+1;
            q.push_back(*iter-1);
            }
        }
    }
    println!("Yes");
    for iter in ans.iter().skip(1) {
        println!("{}", iter);
    }    
}


Measured memory_bytes: 25512
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define N (int) 200
using namespace std;
int n, m;
struct Edge {
	int v, w, nxt;
} edge[N*N];
int fst[N*N], ecnt;
void add_edge (int u, int v, int w) {
	edge[ecnt].v = v, edge[ecnt].w = w, edge[ecnt].nxt = fst[u], fst[u] = ecnt ++;
}
void init_e () {
	memset (fst, -1, sizeof (fst));
}

char c[N][N];

int calc (int x, int y) {
	return (x - 1) * m + y;
}

int dis[N*N], vis[N*N];
void dij () {
	priority_queue <pair <int, int> > pq;
	memset (dis, INF, sizeof (dis));
	memset (vis, 0, sizeof (vis));
	dis[1] = c[1][1] == '#';
	pq.push (make_pair (-dis[1], 1));
	while (! pq.empty ()) {
		int h = pq.top ().second; pq.pop ();
		if (vis[h]) continue;
		vis[h] = true;
		for (int e = fst[h]; e != -1; e = edge[e].nxt) {
			int v = edge[e].v, w = edge[e].w;
			if (vis[v]) continue;
			if (dis[v] > dis[h] + w) dis[v] = dis[h] + w, pq.push (make_pair (-dis[v], v));
		}
	}
}

int main () {
	init_e ();
	
	cin >> n >> m;
	for (int i = 1; i <= n; i ++) for (int j = 1; j <= m; j ++) cin >> c[i][j];
	
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= m; j ++) {
			int cur = calc (i, j), rgh = calc (i, j+1), dwn = calc (i+1, j);
			if (c[i][j] == '.' && c[i][j+1] == '#') add_edge (cur, rgh, 1); else add_edge (cur, rgh, 0);
			if (c[i][j] == '.' && c[i+1][j] == '#') add_edge (cur, dwn, 1); else add_edge (cur, dwn, 0);
		}
	}
	
	dij ();
	
	cout << dis[calc (n, m)] << endl;
	
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
public class Main {
  public static void main(String[] args) {
    Main m = new Main();
    m.run();
  }
  private void run() {
    int n = 0;
    long[] a = new long[0];
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
      n = Integer.parseInt(br.readLine());
      a = Arrays.stream(br.readLine().split("\\s+"))
        .mapToLong(Long::parseLong).toArray();
    } catch (IOException e) {
      e.printStackTrace();
    }
    Arrays.sort(a);
    int idx = 0;
    long s = 0L;
    for (int i=0;i<n-1;i++) {
      s += a[i];
      if (2L*s < a[i+1]) idx = i+1;
    }
    System.out.println(n-idx);
  }
}

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

typedef long long int ll;
typedef unsigned long long int ull;

ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*  
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int csrand(int l=0, int r=1e9)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define PR(x) cout<<#x<<" : "<<x<<"\n";
#define PR1(x,y) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"  |  "<<#z<<" : "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first       
#define S               second 
#define mod             1000000007
#define trav(x,y)       for(auto x:y)

const int N=2e5+99;

ll lp[N],rp[N];
ll ls[N],rs[N];

int32_t main()
{       
    IO
    int n;
    cin>>n;

    vector<pll> v(n);

    fr(n) cin>>v[i].F>>v[i].S;

    sort(all(v));


    lp[0]=INT_MIN;
    rp [0]=INT_MAX;

    for(int i=1;i<=n;i++)
        lp[i]=max(lp[i-1],v[i-1].F),
        rp[i]=min(rp[i-1],v[i-1].S);

    ls[n+1]=INT_MIN;
    rs [n+1]=INT_MAX;

    for(int i=n;i>=1;i--)
        ls[i]=max(ls[i+1],v[i-1].F),
        rs[i]=min(rs[i+1],v[i-1].S);


    ll lt=INT_MIN,rt=INT_MAX;


    ll ans=0;
    for(int i=n;i>1;i--)
    {
        lt=max(lt,v[i-1].F);
        rt=min(rt,v[i-1].S);
        // PR1(lp[i-1],rp[i-1])
        // PR1(lt,rt)
        // if(lt>rt  || rp[i-1]<lp[i-1])
        //     continue;

        ll tmp=max(rt-lt+1,0LL)+max(rp[i-1]-lp[i-1]+1,0LL);
        // PR(ans)ED
        ans=max(ans,tmp);
    }

    for(int i=2;i<n;i++)
    {
        ll lt=max(lp[i-1],ls[i+1]),rt=min(rp[i-1],rs[i+1]);
        ll tt=max(rt-lt+1,0LL);
        
        ans=max(ans,tt+v[i-1].S-v[i-1].F+1);

    }



    cout<<ans<<endl;


}


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

#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MP make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N= 2e5;

int p[N], fa[N],n,m;
int father(int u){ return fa[u] ==u ? u : fa[u]= father(fa[u]);}

set<PII> b[N];
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%d%d",&n, &m);
	for (int i=1; i<=n; i++) scanf("%d", &p[i]), fa[i] = i;
	for (int i=0,u,v; i<m; i++){
		scanf("%d%d", &u, &v);
		fa[ father(u)] = father(v);
	}
	for (int i=1; i<=n; i++) b[ father(i)].insert( MP(i, p[i]));
	
	int ans=0 ;set<int> s;
	for (int i=1; i<=n; i++){
		s.clear();
		for (auto j:b[i])  s.insert(j.fi);
		for (auto j:b[i])  ans += s.count(j.se);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 20224
import java.util.*;

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

    int n = sc.nextInt();
    int ans = 0;

    for(int i = 1; i <= n; i++){
      String s = String.valueOf(i);
      if(s.length() % 2 == 1){
        ans += 1;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 25940
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

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

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n, x;
    cin >> n >> x;
    vector<lint> l(n);
    vector<lint> s(n+1, 0);
    REP(i, n){
        cin >> l[i];
    }
    REP(i, n){
        s[i+1] = s[i] + l[i];
        // cout << s[i] << endl;
    }
    lint ans = 0;
    REP(i, n+1){
        if(s[i] <= x){
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include<iostream>

using namespace std;
const int MAX = 10005, N_MAX = 2000005;
int n;
void counting_sort(unsigned short A[], unsigned short B[], int k){
    int C[MAX];
    for (int i = 0; i < k; i++)
    {
        C[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        C[A[i]]++;
    }
    for (int i = 0; i < MAX-1; i++)
    {
        C[i+1] = C[i+1] + C[i];
    }
    for (int i = n-1; i >= 0; i--)
    {
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }
}

int main(){
    cin >> n;
    unsigned short A[N_MAX], B[N_MAX];
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    counting_sort(A, B, MAX);
    cout << B[1];
    for (int i = 2; i < n+1; i++)
    {
        cout << " " << B[i];
    }
    cout << endl;
}


Measured memory_bytes: 10924
import sys
K=int(input())
A=[int(i) for i in input().split()]
B=A[::-1]
if B[0]!=2:
    print(-1)
    sys.exit()
a=2
b=3
for i in range(1,K):
    x=B[i]
    if a%x==0:
        c=a
    else:
        c=((a//x)+1)*x
    if a<=c<=b:
        a=c
        b=((b//x)+1)*x-1

    else:
        print(-1)
        sys.exit()
    #print(a,b,c,x)
print(a,b)

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	string S; cin >> S;

	vi RC (N + 1);
	vi GC (N + 1);
	vi BC (N + 1);

	R0F(i, N) {
		if (S[i] == 'R') {
			RC[i] = 1;
		} else if (S[i] == 'G') {
			GC[i] = 1;
		} else if (S[i] == 'B') {
			BC[i] = 1;
		}
		RC[i] += RC[i+1];
		GC[i] += GC[i+1];
		BC[i] += BC[i+1];
	}

	ll sum = 0;

	F0R(i, N) {
		FOR(j, i+1, N) {
			if (S[i] == S[j]) continue;
			char lo = min(S[i], S[j]);
			char hi = max(S[i], S[j]);
			if (lo == 'B' && hi == 'G') {
				sum += RC[j+1];
				if (j + (j - i) < N && S[j + j - i] == 'R') --sum;
			} else if (lo == 'B' && hi == 'R') {
				sum += GC[j+1];
				if (j + (j - i) < N && S[j + j - i] == 'G') --sum;
			} else if (lo == 'G' && hi == 'R') {
				sum += BC[j+1];
				if (j + (j - i) < N && S[j + j - i] == 'B') --sum;
			}
		}
	}
	print(sum);
}

Measured memory_bytes: 3664
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll h, w, n;
	cin>>h>>w>>n;
	map<P, int> d;
	rep(i, n){
		int a, b;
		cin>>a>>b;
		rep(j, 3) rep(k, 3){
			int a2 = a+j-1;
			int b2 = b+k-1;
			if(1<a2&&a2<h&&1<b2&&b2<w){
				++d[P(a2, b2)];
			}
		}
	}
	ll res[10] = {};
	cerr<<d.size()<<endl;
	for(auto &&x: d) res[x.second]++;
	res[0] = (h-2)*(w-2)-d.size();
	rep(i, 10) cout<<res[i]<<endl;
	return 0;
}


Measured memory_bytes: 56448
#include <stdio.h>
#include <iostream>

using namespace std;

#define BUF_SIZE 22

struct Node{
	Node(){
		left_child = right_child = 0;
		data = 0;
	}
	Node *left_child,*right_child;
	long long data;
};

class Tree{
public:
	Tree(){
		root = new Node();
		num_of_node = 0;
	}
	void insert(long long insert_data){
		if(num_of_node == 0){
			root->data = insert_data;
			num_of_node++;
		}else{
			Node* tmp = root;
			while(true){
				if(tmp->data < insert_data){
					if(tmp->right_child == 0){
						tmp->right_child = new Node();
						tmp->right_child->data = insert_data;
						num_of_node++;
						break;
					}else{
						tmp = tmp->right_child;
					}
				}else{
					if(tmp->left_child == 0){
						tmp->left_child = new Node();
						tmp->left_child->data = insert_data;
						num_of_node++;
						break;
					}else{
						tmp = tmp->left_child;
					}
				}
			}
		}
	}

	void print(){
		inORDER(root);
		printf("\n");
		preORDER(root);
		printf("\n");
	}

private:

	Node* root;
	int num_of_node;

private:
	void preORDER(Node* node){
		printf(" %lld",node->data);
		if(node->left_child != 0) preORDER(node->left_child);
		if(node->right_child != 0) preORDER(node->right_child);
	}

	void inORDER(Node* node){
		if(node->left_child != 0) inORDER(node->left_child);
		printf(" %lld",node->data);
		if(node->right_child != 0) inORDER(node->right_child);
	}
};


int main(){
	int m;
	long long insert_data;
	char buf[BUF_SIZE];
	Tree tree;

	scanf("%d",&m);
	getchar();

	for(int i = 0; i < m; i++){
		fgets(buf,BUF_SIZE,stdin);
		if(buf[0] == 'i'){
			insert_data = 0;
			for(int k = 0; buf[k] != '\0';k++){
				if(buf[k] >= '0' && buf[k] <= '9'){
					insert_data = 10*insert_data + (buf[k] - '0');
				}
			}
			tree.insert(insert_data);
		}else{
			tree.print();
		}
	}
}

Measured memory_bytes: 16824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    int a,z;
    cin >> s;
    a = 100000000;
    
    rep(i,s.length())
    {
        if (s[i] == 'A')
        {
            a = min(a, i);
        }
        if (s[i] == 'Z')
        {
            z = i;
        }
    }
    cout << z-a+1 << endl;
}


Measured memory_bytes: 720
s = input()
flag = 0
flag_2 = s[0:int((len(s)-1)/2)]
flag_3 = s[int((len(s)+3)/2)-1::]
if s == s[::-1]:
    flag += 1
if flag_2 == flag_2[::-1]:
    flag += 1
    
if flag_3 == flag_3[::-1]:
    flag += 1
if flag == 3:
    print('Yes')
else:
    print('No')

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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    string t;
    cin >> t;
    sort(t.begin(),t.end());
    s[i] = t;
  }
  map<string, ll> mp;
  rep(i,n) mp[s[i]] ++;
  ll ans = 0;
  for(auto p : mp){
    ans += p.second*(p.second-1)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 14068
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  vector<string> s(n);
  char temp;
  long long cnt[5]={};
  REP(i,n){
    cin>>s[i];
    temp = s[i][0];
    if(temp=='M'){
      cnt[0]++;
    }else if(temp=='A'){
      cnt[1]++;
    }else if(temp=='R'){
      cnt[2]++;
    }else if(temp=='C'){
      cnt[3]++;
    }else if(temp=='H'){
      cnt[4]++;
    }else{
      ;
    }
  }
  
  long long ans = 0;
  REP(i,5){
    REP(j,i){
      REP(k,j){
        ans += cnt[i]*cnt[j]*cnt[k];
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6144
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class RemainingTime {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println((a + b) % 24);
        }

    }

    static class InputReader {
        private static BufferedReader in;
        private static StringTokenizer tok;

        public InputReader(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
        }

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

        public String next() {
            try {
                while (tok == null || !tok.hasMoreTokens()) {
                    tok = new StringTokenizer(in.readLine());
                }
            } catch (IOException ex) {
                System.err.println("An IOException was caught :" + ex.getMessage());
            }
            return tok.nextToken();
        }

    }
}



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

bool my_compare(pair<int, int> a, pair<int, int> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
        // return a.first < b.first; // 昇順
        return a.first < b.first; // 降順
    }
}

int main(){
    vector<pair<int, int> > V;
    int n;
    cin>>n;
    vector <int> a(0);
    int k;
    for(int i=0;i<n;i++){
      cin>>k;
      a.push_back(k);
    }

    for(int i=0;i<n;i++){
      V.push_back(make_pair(a.at(i), i+1));
    }
    sort(V.begin(), V.end(), my_compare);

    for(int i=0; i<V.size(); i++){
        cout << V[i].second<<" " ;
    }
    cout<<endl;
}


Measured memory_bytes: 2164
import sys, math
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, = [int(num) for num in lines.pop(0).split(" ")]
d, x = [int(num) for num in lines.pop(0).split(" ")]
a_list = [int(line) for line in lines]
ans = x
for a in a_list:
    ans += math.ceil(d / a)
print(ans)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
const int MN = 2e5+9;
vector<int> s[MN],t[MN];
int X,Y,M,N,f[MN],g[MN],vis[MN],tag[MN];
int main(){
    scanf("%d%d",&N,&M);
    for(int i=1; i<=M; i++){
        scanf("%d%d",&X,&Y);
        s[Y].push_back(X);
        t[Y+1].push_back(X);
    }
    for(int i=1; i<=N; i++){
        sort(s[i].begin(),s[i].end());
        sort(t[i].begin(),t[i].end());
    }
    for(int i=1; i<=N; i++) f[i] = i;
    for(int i=1; i<=N; i++) g[i] = i;
    memset(vis,0,sizeof(vis));
    for(int i=1,j; i<=N; i++){
        if(s[i].size()==0) continue;
        int k = s[i][0];
        if(vis[k]) continue;
        for(j=i+1; j<=N; j++){
            auto o = lower_bound(s[j].begin(),s[j].end(),k);
            if(o==s[j].end()) break;
            if(vis[*o]) break;
            vis[*o] = 1; k = *o;
        }
        j = min(j,N);
        for(int l=i; l<=j; l++)
            f[l] = max(f[l],j);
    }
    memset(vis,0,sizeof(vis));
    for(int i=N,j; i; i--){
        if(t[i].size()==0) continue;
        int k = t[i][0];
        if(vis[k]) continue;
        for(j=i-1; j; j--){
            auto o = lower_bound(t[j].begin(),t[j].end(),k);
            if(o==t[j].end()) break;
            if(vis[*o]) break;
            vis[*o] = 1; k = *o;
        }
        j = max(j,1);
        for(int l=i; l>=j; l--)
            g[l] = min(g[l],j);
    }
    for(int i=1; i<=N; i++)
        tag[g[i]]++,tag[f[i]+1]--;
    for(int i=1,V=0; i<=N; i++){
        V += tag[i];
        printf("%d",V);
        if(i==N) printf("\n");
            else printf(" ");
    }
}

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

typedef long long ll;
int N,cnt;

void solve(ll now,bool c3,bool c5,bool c7){
    if(now > N) return;
    if(c3 && c5 && c7) cnt++;
    
    solve(now*10+3,true,c5,c7);
    solve(now*10+5,c3,true,c7);
    solve(now*10+7,c3,c5,true);
}

int main(){
    cin>>N;
    cnt = 0;
    solve(0,false,false,false);
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

struct BIT{
  int size;
  vector<ll> dat;
  void init(int n){
    size=n;
    dat.clear();
    dat.resize(n+1);
  }
  void add(int i,ll x){
    while(i<=size){
      dat[i]+=x;
      i +=i&-i;
    }
  }
  ll sum(int i){
    ll s=0;
    while(0<i){
      s +=dat[i];
      i -=i&-i;
    }
    return s;
  }
};
  
int main(){
    int n,q,c,s,t,x;
    cin>>n>>q;
    BIT b1,b2;
    b1.init(n);
    b2.init(n);
    rep(i,q){
        cin>>c;
        if(c==0){
            cin>>s>>t>>x;
            b1.add(s,x);
            b2.add(s,-x*(s-1));
            b1.add(t,-x);
            b2.add(t,x*t);
        }
        else{
            cin>>s>>t;
            ll ans;
            ans=b1.sum(t)*t+b2.sum(t)-b1.sum(s-1)*(s-1)-b2.sum(s-1);
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4392
#include<iostream>
#include<algorithm>
using namespace std; // 575

int main() {
	int a[3];
	for (int i = 0;i < 3;++ i) cin >> a[i];
	sort(a, a+3);
	cout << a[0] * a[1] / 2;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

斜辺は三角不等式より常に一番大きいので、つまりそれ以外の積/2
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	set<string> st;
	REP(i, n){
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
}

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


int main()
{
	int a, b;
	cin >> a >> b;
	int c = a * b;
	if (c % 2 == 0)
	{
		cout << "Even" << endl;
	}
	else
	{
		cout << "Odd" << endl;
	}
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int H,W;
    cin >> H>>W;
    string board[110];
    for(int i = 0;i < H;i++) cin >> board[i];
    vector<int> X(110,0);
    vector<int> Y(110,0);
    for(int i = 0 ;i < H;i++){
        for(int j = 0;j < W;j++){
            if(board[i][j] == '#'){
                X[j] = 1;
                Y[i] = 1; 
            }
        }
    }
    for(int i = 0;i < H;i++){
        if(Y[i]){
            for(int j = 0;j < W;j++){
                if(X[j]){
                    cout << board[i][j];
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const int N = 110;
const int S = 256;
const ll MOD = 1e9 + 7;

int main() {
  vector<ll> fact(N);
  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = i * fact[i - 1] % MOD;
  int n, k;
  while (cin >> n >> k) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    static ll dp[N][N][S];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= i; j++) {
        for (int x = 0; x < S; x++) {
          (dp[i + 1][j][x] += dp[i][j][x]) %= MOD;
          (dp[i + 1][j + 1][x ^ a[i]] += dp[i][j][x]) %= MOD;
        }
      }
    }
    ll res = 0;
    for (int j = 0; j <= n; j++) {
      res = (res + dp[n][j][k] * fact[j]) % MOD;
    }
    cout << res << endl;
  }
  return 0;
}


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

int main() {
  ll a, b, n; cin >> a >> b >> n;
  ll ans;

  if (b > n) {
    ans = a * n / b;
  } else {
    ans = a * (b-1) / b;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
void printAns(bool can);

/* main */
int main(){
    int q, option, num, num2; 
    set<int> S;
    cin >> q;
    for (int i  = 0; i < q; i++) {
        cin >> option >> num;
        switch(option) {
        case 0:
            // insert
            S.insert(num);
            cout << S.size() << '\n';
            break;
        case 1:
            // find
            cout << S.count(num) << '\n';
            break;
        case 2:
            // delete
            S.erase(num);
            break;
        case 3:
            cin >> num2;
            set<int>::iterator it = S.lower_bound(num);
            set<int>::iterator last = S.upper_bound(num2);
            for (; it != last ; it++)
                cout << *it << '\n';
        }
    }
}


void printAns(bool can) {
    if (can) cout << 1 << '\n';
    else cout << 0 << '\n';
}



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

int main() {
  long long n,k,ans,md;

  cin >> n >> k;

  if (n >= k) {
    md = n % k;
    ans = min(md,abs(md-k));
  } else
  {
    ans = min(n,abs(n-k));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;


/// https://beta.atcoder.jp/contests/arc090/tasks/arc090_a
fn main() {
    let n = read_one::<usize>();
    let mut an = Vec::new();
    for _ in 0..2 {
        an.push(read::<usize>());
    }
    let mut ans = 0;
    for i in 0..n {
        let mut cnt = 0;
        for j in 0..n + 1 {
            if j <= i { cnt += an[0][j]; }
            else { cnt += an[1][j - 1]; }
        }
        ans = cmp::max(ans, cnt);
    }

    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<stdio.h>

int main(void)
{
	int X;

	scanf("%d", &X);

	if (X >= 400 && X <= 599)
	{
		printf("8");
	}
	else if (X >= 600 && X <= 799)
	{
		printf("7");
	}
	else if (X >= 800 && X <= 999)
	{
		printf("6");
	}
	else if (X >= 1000 && X <= 1199)
	{
		printf("5");
	}
	else if (X >= 1200 && X <= 1399)
	{
		printf("4");
	}
	else if (X >= 1400 && X <= 1599)
	{
		printf("3");
	}
	else if (X >= 1600 && X <= 1799)
	{
		printf("2");
	}
	else if (X >= 1800 && X <= 1999)
	{
		printf("1");
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 1620
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
        int n;
        cin >> n;
        int march[20];
        for (int i = 0; i < 20; i++) {
                march[i] = 0;
        }
        for (int i = 0; i < n; i++) {
                string s;
                cin >> s;
                if(s[0] == 'M')march[0]++;
                else if(s[0] == 'A')march[1]++;
                else if(s[0] == 'R')march[2]++;
                else if(s[0] == 'C')march[3]++;
                else if(s[0] == 'H')march[4]++;
        }

        ll ans = 0;
        for (int i = 0; i < 3; i++) {
                for (int j = i + 1; j < 4; j++) {
                        for (int k = j + 1; k < 5; k++) {
                                ans += march[i]*march[j]*march[k];
                        }
                }
        }

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll H,N;
  cin>>H>>N;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A.at(i);
  int ans=0;
  for(int i=0;i<N;i++)ans+=A.at(i);
  if(ans>=H)cout<<"Yes";
  else cout<<"No";
}
  
  
  

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int month,day,n_day;
  int i,j,k;

  while(scanf("%d %d",&month,&day) && month  && day){
    n_day=day-1;
    for(i=1;i<month;i++){
      switch(i){
      case 2:
	n_day+=29;
	break;
      case 4:
      case 6:
      case 9:
      case 11:
	n_day+=30;
	break;
      default:
	n_day+=31;
      }
    }
    
    switch(n_day%7){
    case 0:
      puts("Thursday");
      break;
    case 1:
      puts("Friday");
      break;
    case 2:
      puts("Saturday");
      break;
    case 3:
      puts("Sunday");
      break;
    case 4:
      puts("Monday");
      break;
    case 5:
      puts("Tuesday");
      break;
    case 6:
      puts("Wednesday");
      break;
    }
  }
  return 0;
}

    

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <complex>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define int long long
#define INF 1e9
#define MOD 1e9 + 7
using namespace std;

template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

using P = complex<double>;
const double PI = acos(-1);
const double EPS = 1e-9;
// P p(a,b)=a+bi -> 点p(a,b)
namespace std {
  bool operator<(const P &a, const P &b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); }
  bool operator==(const P &a, const P &b) { return a.real() == b.real() && a.imag() == b.imag(); }
} // namespace std

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a);
    push_back(b);
  }
};
//内積
double dot(P a, P b) { return real(conj(a) * b); }
//外戚
double cross(P a, P b) { return imag(conj(a) * b); }

P crosspointSS(L a, L b) {
  double t1 = abs(cross(a[1] - a[0], b[0] - a[0]));
  double t2 = abs(cross(a[1] - a[0], b[1] - a[0]));
  return b[0] + (b[1] - b[0]) * t1 / (t1 + t2);
}

signed main() {
  int q;
  cin >> q;
  while (q--) {
    int a, b, c, d, e, f, g, h;
    cin >> a >> b >> c >> d >> e >> f >> g >> h;
    L l(P(a, b), P(c, d)), m(P(e, f), P(g, h));
    P ans = crosspointSS(l, m);
    printf("%.10lf %.10lf\n", ans.real(), ans.imag());
  }
  return 0;
}



Measured memory_bytes: 3216
using System;

namespace ConsoleApp27
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            switch(N % 10)
            {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    Console.WriteLine("hon");
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    Console.WriteLine("pon");
                    break;
                case 3:
                    Console.WriteLine("bon");
                    break;
            }
        }
    }
}


Measured memory_bytes: 27484
N=int(input())
a=[int(i) for i in input().split()]
data={}
for num in a:
        if num in data:
                data[num]+=1
        else:
                data[num]=1

ans=0
for key in data.keys():
        if data[key]<key:
                ans+=data[key]
        else:
                ans+=data[key]-key
print(ans)

Measured memory_bytes: 18172
using System;

    class AGC026A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            string[] input = Console.ReadLine().Split(' ');

            for(int i = 0; i < n; i++)
            {
                a[i] = int.Parse(input[i]);
            }

            int cnt = 0;

            for(int i = 0; i < n-1; i++)
            {
                if(a[i] == a[i + 1])
                {
                    cnt++;
                    i++; // 次の色のも考慮しなくてすむ
                }
            }

            Console.WriteLine(cnt);
        }
    }


Measured memory_bytes: 13140
import java.math.BigDecimal
import java.math.RoundingMode

fun main(args: Array<String>) {
    val result = readLine()!!.split(" ")
        .map { BigDecimal.valueOf(it.toDouble()) }
        .reduce { acc, bigDecimal -> acc.multiply(bigDecimal) }

    println(result.setScale(0, RoundingMode.DOWN).toPlainString())
}


Measured memory_bytes: 36876
//itp1_3-a
#include <iostream>
using namespace std;

int main(){
 int temp,i;
 i=0;
 while(true){
  cin>>temp;
  if(temp==0)
   break;
  else
   cout<<"Case "<<i+1<<": "<<temp<<endl;
  i++;
 }
 return 0;
}

Measured memory_bytes: 1160