akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int maze[110][110];
int f[110][110];
int w, h, xs, ys, xg, yg, res = 0;
int color;

void dfs(int cy, int cx){
	if(f[cy][cx]) return ;
	f[cy][cx] = 1;
	if(cy == yg && cx == xg){
		res = 1;
		return ;
	}
	for(int dx=-1; dx<=1; ++dx){
		for(int dy=-1; dy<=1; ++dy){
			if(abs(dx-dy) != 1) continue;
			int nx = cx + dx, ny = cy + dy;
			if(maze[ny][nx] == color){
				dfs(ny, nx);
			}
		}
	}
	return ;
}


int main(void){
	int n;
	while(cin >> w >> h){
		res = 0;
		if(w == 0 && h == 0) break;
		cin >> xs >> ys >> xg >> yg >> n;
		for(int i=0; i<110; ++i){
			for(int j=0; j<110; ++j){
				maze[i][j] = 6;
				f[i][j] = 6;
			}
		}
		for(int i=1; i<=h; ++i){
			for(int j=1; j<=w; ++j){
				maze[i][j] = 0;
				f[i][j] = 0;
			}
		}

		for(int i=0; i<n; ++i){
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			if(d == 0){
				for(int j=y; j<=y+1; ++j){
					for(int k=x; k<=x+3; ++k){
						maze[j][k] = c;
					}
				}
			}
			if(d == 1){
				for(int j=y; j<=y+3; ++j){
					for(int k=x; k<=x+1; ++k){
						maze[j][k] = c;
					}
				}
			}
		}

		color = maze[ys][xs];
		if(color == 0){
			cout << "NG" << endl;
			continue;
		}

		dfs(ys, xs);

		if(res){
			cout << "OK" << endl;
		} else {
			cout << "NG" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1252
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int N, M;
		cin >> N >> M;

		vector<set<int>> el( N+1 );
		for( int i = 0; i < M; ++i ) {
			int a, b;
			cin >> a >> b;
			el[a].insert( b );
			el[b].insert( a );
		}

		vector<int> sp( N+1, -1 );
		sp[1] = 0;
		queue<int> qu;
		qu.push(1);
		while( !qu.empty() ) {
			int x = qu.front();
			qu.pop();

			for( int v: el[x] ) {
				if( sp[v] == -1 ) {
					sp[v] = x;
					qu.push( v );
				}
			}
		}

		cout << "Yes" << '\n';
		for( int i = 2; i <= N; ++i ) {
			cout << sp[i] << '\n';
		}
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 27564
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	int n;
	cin>>n;
	int m=n;
	while(m>0) {
		if(m%4==0){cout<<"Yes";return;}
		m-=7;
	}
	while(n>0) {
		if(n%7==0){cout<<"Yes";return;}
		n-=4;
	}
	cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3580
import std.stdio,std.string,std.conv;

int dp[1001][1001];

int main()
{
	int W,n,ans;
	int w[1001];
	int v[1001];
	int count = 0;
	while((W = readln.chomp.to!int) != 0)
	{
		count++;
		n = readln.chomp.to!int;

		foreach(l;0..1001)
		{
			foreach(k;0..1001)
			{
				dp[l][k] = 0;
			}
		}

		foreach(i;0..n)
		{
			string[] s = readln.chomp.split(",");
			v[i] = s[0].to!int;
			w[i] = s[1].to!int;
		}
		foreach(i;0..n)
		{
			foreach(j;0..W+1)
			{
				if(j < w[i])
				{
					dp[i+1][j] = dp[i][j];
				}
				else
				{
					if(dp[i][j] > dp[i][j-w[i]] + v[i])
					{
						dp[i+1][j] = dp[i][j];
					}
					else
					{
						dp[i+1][j] = dp[i][j-w[i]] + v[i];
					}
				}
			}
		}

		foreach(j;0..W+1)
		{
			if(dp[n][j] == dp[n][W])
			{
				ans = j;
				break;
			}
		}

		writeln("Case ",count,":");
		dp[n][W].writeln;
		ans.writeln;
	}
	return 0;
}

Measured memory_bytes: 4988
n = gets.to_i
c = gets.chomp
ans = 0
l = 0
r = n - 1
while l < r
  while l < n && c[l] == 'R' do
    l += 1
  end
  while r >= 0 && c[r] == 'W' do
    r -= 1
  end
  if l < n && r >= 0 && l < r
    c[l], c[r] = c[r], c[l]
    ans += 1
  end
end
puts ans


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

using namespace std;

int main() {
    int n;
    cin >> n;
    priority_queue <double> pq;
    for (int i = 0; i < n; i++) {
        double x;
        cin >> x;
        pq.push(-x);
    }
    while (pq.size() > 1) {
        double top1 = pq.top();
        pq.pop();
        double top2 = pq.top();
        pq.pop();
        pq.push((top1 + top2) / 2.0);
    }
    cout << fixed << setprecision(9) << -pq.top();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <chrono>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    if (n < 0)return 0;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll merge_cnt(vector<ll>& a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin() + n / 2);
    vector<ll> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    while (ai < n) {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
            a[ai++] = b[bi++];
        }
        else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main() {
    string s;
    cin >> s;
    ll n = s.size();
    ll a = 0;
    ll b = 0;
    ll c = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a')a++;
        if (s[i] == 'b')b++;
        if (s[i] == 'c')c++;
    }
    if (max({ a,b,c }) - min({ a,b,c }) > 1)cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,li[310][310],pos[310][310];
ll s=0;
 
int main(){
	cin >> n;
	REP(i,0,n) REP(j,0,n) cin >> li[i][j],pos[i][j]=li[i][j];
	REP(k,0,n) REP(i,0,n) REP(j,0,n) pos[i][j]=min(pos[i][j], pos[i][k]+pos[k][j]);
	REP(i,0,n) REP(j,0,n) if(li[i][j]!=pos[i][j]){cout << -1 << endl; return 0;}
	REP(i,0,n){
		REP(j,i+1,n){
			bool f=true;
			REP(k,0,n) if(k!=i and k!=j and li[i][k]+li[k][j]==li[i][j]) f=false;
			if(f) s+=li[i][j];
		}
	}
	
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
int x;
cin>>x;
if(x==0){
    cout<<1<<endl;
    return 0;
}
cout<<0<<endl;








return 0;
}


Measured memory_bytes: 3556
var h,qh:array[0..100000] of int64;
     i,n:longint;
function min(a,b:longint):longint;
begin
    if a<b then exit(a) else exit(b);
end;
begin
   readln(n);
   qh[0]:=0;
   qh[1]:=0;
   for i :=1 to n do read(h[i]);
   qh[2]:=abs(h[1]-h[2]);
   for i:=3 to n do
          qh[i]:=min(abs(h[i]-h[i-1])+qh[i-1],abs(h[i]-h[i-2])+qh[i-2]);
      writeln(qh[n]);
end.


Measured memory_bytes: 1664
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e6 + 5;


int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int n = 0;
	cin >> n;
	vector<int> array;
	int number = 0;
	int scoreA = 0, scoreB = 0;
	for(int i = 0; i < n; ++i){
		cin >> number;
		array.push_back(number);
	}
	sort(array.rbegin(), array.rend());
	for(int i = 0; i < n; ++i){
		if(i % 2 == 0){
			scoreA+=array[i];
		}
		else{
			scoreB+=array[i];
		}
	}
	cout << scoreA - scoreB << endl;

    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int dp[N];
int w[110],v[110];
int main(){
	int n, sumw;
	cin>>n>>sumw;
	int sum = 0;
	for (int i = 1; i <= n; i++){
		cin>>w[i]>>v[i];
		sum += v[i];
	}
	memset(dp, 0x3f3f3f3f, sizeof(dp));
	dp[0] = 0;
	for (int i = 1; i <= n; i++){
		for (int j = sum; j >= v[i]; j--){
			dp[j] = min(dp[j],dp[j - v[i]] + w[i]);
		}
	}
	for (int i = sum; i >= 0; i--){
		if (dp[i] <= sumw){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 640
N = int(input())
c = [2] + [1] + [0] * (N - 1)
if N <= 1:
    print(c[N])
else:
    for i in range(2, N + 1):
        # print(c[i-1],c[i-2])
        c[i] = c[i - 1] + c[i - 2]
    print(c[N])


Measured memory_bytes: 2940
N=int(input())
XL=[list(map(int,input().split())) for i in range(N)]

R=[]
for i in range(N):
    a=max(0,XL[i][0]-XL[i][1])
    b=XL[i][1]+XL[i][0]
    R.append([b,a])
R.sort()

ans=0
con_l=0
for i in range(N):
    if con_l <= R[i][1]:
        ans += 1
        con_l = R[i][0]
print(ans)

'''
①入力
N=int(input())
XL=[list(map(int,input().split())) for i in range(N)]
Nはロボットの個数
XLは座標Xと腕の長さLのリスト

②リストの編集
ロボットの腕の始点(a)と終点(b)を保存するリスト(R)を作成する

R=[]
for i in range(N):
    a=max(0,XL[i][0]-XL[i][1])
    b=XL[i][1]+XL[i][0]
    R.append([b,a])
R.sort()
リストRは終点昇順でソートしておく

③区間スケジューリング＆出力
ans=0
con_l=0
for i in range(N):
    if con_l <= R[i][1]:
        ans += 1
        con_l = R[i][0]
print(ans)
ansは選んだロボットの個数
con_lは最後に選んだロボットの腕の終点

forループ内の処理は最後に選んだロボットの終点(con_l)より大きい始点(R[i][1])を持つロボットを貪欲的に探索するようになっている
Rは終点昇順でソートしてあるため、探索していく中で最小の終点のものを常に選択するようになっている
見つかるたびにansに+1してcon_lを更新する
出力して終了
'''

Measured memory_bytes: 41440
#include<iostream>
using namespace std;
#include<stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d%d",&a,&b);
	if(a==0){
		if(b>1988){
			printf("H%d\n",b-1988);
		}
		else if(b>1925){
			printf("S%d\n",b-1925);
		}
		else if(b>1911){
			printf("T%d\n",b-1911);
		}
		else{
			printf("M%d\n",b-1867);
		}
	}
	if(a==1){
		printf("%d\n",b+1867);
	}
	if(a==2){
		printf("%d\n",b+1911);
	}
	if(a==3){
		printf("%d\n",b+1925);
	}
	if(a==4){
		printf("%d\n",b+1988);
	}
	return 0;
}

Measured memory_bytes: 3232
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD 1000000007
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
ll mod(ll x){return x+MOD;}

ll modpow(ll a,ll n){
    ll res=1;
    while(n>0){
        if(n&1){res*=a;res%=MOD;}
        a*=a;a%=MOD;
        n>>=1;
    }
    return res;
}   
ll nCr(ll n,ll r){
    ll res,x,y;
    res=x=y=1;
    for(int i=0;i<r;i++){
        x*=(n-i);x%=MOD;
        y*=(r-i);y%=MOD;
    }
    res=modpow(y,MOD-2)%MOD;
    res=(res*x)%MOD;
    return res;
}


int main(){
    ll n,a,b;scanf("%lld %lld %lld",&n,&a,&b);

    ll x=modpow(2,n)-1;
    ll y=nCr(n,a)+nCr(n,b);
    y%=MOD;
    printf("%lld\n",mod(modpow(2,n)-1-y)%MOD);
    
      
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

func setBit(d, n int) int {
	t := 1 << uint(n)
	return d | t
}

func intAbs(n int) int {
	return int(math.Abs(float64(n)))
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
	line := nextLine()
	spl := intSprit(line)

	D := spl[0]
	G := spl[1]

	p := make([]int, D+1)
	c := make([]int, D+1)

	for i := 0; i < D; i++ {
		s := intSprit(nextLine())
		p[i] = s[0]
		c[i] = s[1]
	}

	res := 1 << 30
	for b := 0; b < (1 << uint(D)); b++ {
		s := 0
		cnt := 0
		rm := -1
		for i := 0; i < D; i++ {
			if bitExist(b, i) {
				s += 100*(i+1)*p[i] + c[i]
				cnt += p[i]
			} else {
				rm = i
			}
		}
		if s < G {
			st := 100 * (rm + 1)
			tc := (G - s + st - 1) / st
			if tc >= p[rm] {
				continue
			}
			cnt += tc
		}
		if res > cnt {
			res = cnt
		}
	}
	fmt.Println(res)

}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    int dishes[5];
    for(int i = 0; i < 5; i++) {
        cin >> dishes[i];
    }

    // 下一桁が0でない且つなるべく小さい料理を探す
    // その料理を最後に提供する
    int last_order_index = -1;
    for(int i = 0; i < 5; i++) {
        int last_digit = dishes[i] % 10;
        if(last_digit != 0) {
            if(last_order_index == -1) {
                last_order_index = i;
            } else {
                if((dishes[last_order_index] % 10) > last_digit) {
                    last_order_index = i;
                }
            }
        }
    }

    // 結果足し算
    int min_order_time = 0;
    for(int i = 0; i < 5; i++) {
        if(last_order_index != i) {
            min_order_time += dishes[i];
            if(dishes[i] % 10 != 0) {
                min_order_time += 10 - (dishes[i] % 10);
            }
        }
    }
    if(last_order_index != -1) {
        min_order_time += dishes[last_order_index];
    }

    cout << min_order_time << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 2e5 + 100;

ll A[N] , B[N];

int main(){
	fio; cout<<fixed<<setprecision(25);	
	
	ll n , m , k; cin >> n >> m >> k;
	for(int i = 1;i <= n ; ++i){
		cin >> A[i];
		A[i] += A[i-1];
	}
	for(int i = 1;i <= m ; ++i){
		cin >> B[i];
		B[i] += B[i-1];
	}
	ll mx = 0;

	for(ll i = 0;i <= n ; ++i){
		if(A[i] > k) break;
		ll lft = (k-A[i]);
		ll lo = 0 , hi = m , ans = lo;
		while(lo <= hi){
			int mid = (lo+hi)>>1;
			if(B[mid] <= lft){
				ans = mid;
				lo = mid+1;
			}
			else{
				hi = mid-1;
			}
		}
		mx = max(mx , i+ans);
	}
	cout << mx << endl;





	return 0;
}


Measured memory_bytes: 6772
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;
 
typedef long long LL;
typedef pair <int, int> pii;
 
inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}
 
const int MAXN = 405;
const int mod = 1e9 + 7;
 
int n, m, a[MAXN], b[MAXN], c[MAXN], d[MAXN], e[MAXN][MAXN], f[MAXN][MAXN], g[MAXN][MAXN][MAXN];
 
int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = n / 3;
	for (int i = 1; i <= n; i ++)
		a[i] = Read();
	for (int i = 1; i <= n; i ++)
		b[i] = Read();
	f[0][0] = g[0][0][0] = 1;
	for (int i = 0; i <= m; i ++)
		for (int j = 0; j <= m << 1; j ++)
		{
			f[i + 1][j] = (f[i + 1][j] + f[i][j]) % mod;
			if (j < i << 1)
				f[i][j + 1] = (f[i][j + 1] + 1LL * ((i << 1) - j) * f[i][j]) % mod;
		}
	for (int i = 1; i <= n; i ++)
	{
		c[a[i]] = 1, mcpy(d, c);
		int cur = i;
		for (int j = 1; j <= n; j ++)
		{
			if (!d[b[j]])
				cur ++;
			d[b[j]] ++;
			if (d[a[i]] == 1 && d[b[j]] == 1)
				e[i][j] = cur;
		}
	}
	for (int i = 0; i <= n; i ++)
		for (int j = 0; j <= n; j ++)
			if (i || j)
				for (int k = 0; k <= m; k ++)
				{
					if (i && j)
						g[i][j][k] = ((g[i - 1][j][k] + g[i][j - 1][k] - g[i - 1][j - 1][k]) % mod + mod) % mod;
					else if (i)
						g[i][j][k] = g[i - 1][j][k];
					else
						g[i][j][k] = g[i][j - 1][k];
					if (i && j && k && e[i][j])
						g[i][j][k] = (1LL * g[i - 1][j - 1][k - 1] * (n - 3 * (m - k) - e[i][j]) + g[i][j][k]) % mod;
				}
	return printf("%lld\n",( 1LL * g[n][n][m] * f[m][m << 1]%mod+mod)%mod), 0;
}

Measured memory_bytes: 260992
strength = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]

def f(A, B):
    i = strength.index(A)
    j = strength.index(B)
    if i > j:
        return 'Alice'
    if i < j:
        return 'Bob'
    return 'Draw'

A, B = input().split()
A = int(A)
B = int(B)
print(f(A, B))

Measured memory_bytes: 3064
// Created by abhay
#include <bits/stdc++.h>
#define sz(a) 			int((a).size())
#define pb 				push_back
#define all(c) 			c.begin(),c.end()
#define tr(c,i) 		for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 	(c.find(x) != c.end())
#define cpresent(c,x) 	(find(allc,x) != c.end())
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define int 		 	long long
#define w(tc)           int tc; cin>>tc; while(tc--)
#define ff              first
#define se              second
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define ne              "\n"

using namespace std;

int32_t main()

{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	int k;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}

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


int main() {
  int a,b,c,d,sum,ans;
  string s;
  cin>>s;
  ans=0;
  a=0;b=0;c=0;
  vector<int> vecV(a);
  vector<int> vecC(a);
  
  for(int i=0;i<s.size();i++){
  	if(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T'){
    	a++;
    }
    else{
    	a=0;
    }
    ans = max(a,ans);
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MOD 1000000007
using namespace std;
#define fr(i,n) for (long long int i = 0; i < n; i++)
#define MAX_CHAR 26
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
int dp[100000]={0};
int jump(ll a[],int n,int i){
  //std::cout << i << '\n';
  if(dp[i]!=-1){
    return dp[i];
  }else{
    if(i+1==n-1){
      dp[i]= abs(a[n-1]-a[i]);
      return dp[i];
    }else if(i+2==n-1){
      dp[i]=min(abs(a[n-1]-a[i]),abs(a[n-1]-a[i+1])+abs(a[i+1]-a[i]));
      return dp[i];
    }else{
      dp[i]=min(abs(a[i]-a[i+1])+jump(a,n,i+1),abs(a[i]-a[i+2])+jump(a,n,i+2));
      return dp[i];
    }
  }
}
void io(){
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}

void solve(){
  //io();
  int n;
  cin>>n;
  ll b[n];
  fr(i,n){
    cin>>b[i];
    dp[i]=-1;
  }
  std::cout <<jump(b,n,0) << '\n';

}
int main(){
  std::ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 5376
using System;

namespace Volumen0
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i <= 9; i++)
            {
                for (int j =1;j<=9;j++)
                {
                    Console.WriteLine("{0}x{1}={2}",i,j,i*j);
                }
            }
        }
    }
}



Measured memory_bytes: 13612
#include <bits/stdc++.h>
using namespace std;
long long f[200+10];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>f[i];
    }
    int ans=0;
    for(int ans=0;1;ans++){
        for(int j=1;j<=n;j++){
            if(f[j]%2==1){
                cout<<ans;
                return 0;
            }
            else{
                f[j]/=2;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < W; i++) printf("#");
		printf("\n");

		for(int i = 1; i < H-1; i++){
			printf("#");
			for(int j = 1; j < W-1; j++) printf(".");
			printf("#\n");
		}

		if(H > 1){
			for(int i = 0; i < W; i++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) {
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") {
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int ans=0;
    cin>>s;
    if(s[0]=='1'){ans++;}
    if(s[1]=='1'){ans++;}
    if(s[2]=='1'){ans++;}
    cout<<ans<<endl;
}


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

#define INF 100100100
#define MOD 1000000007

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

using namespace std;
using ll = long long;
using ull = unsigned long long ;

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   string S;
   cin >> S;
   vector<int>s;
   FOR(i,S.size()){
      s.emplace_back(S[i] - '0');
   }
   vector<ll> bit (1 << (S.size()-1));
   ll ans = 0;
   ll stack;
   for(ll i=0;i<(1 << (S.size()-1));i++){
      stack = s[0];
      for(ll j=1;j<S.size();j++){
         if(i & (1 << (j-1))){
            ans += stack;
            stack = s[j];
         }
         else{
            stack = stack*10 + s[j];
         }
      }
      ans += stack;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a,b,c,x,y,z,A;
int main()
{
	cin>>a>>b>>c;
	if(a%2==0&&a==b&&b==c)
	{
		cout<<-1;
		return 0;
	}
	while(a%2==0&&b%2==0&&c%2==0)
		x=(b+c)/2,y=(c+a)/2,z=(a+b)/2,a=x,b=y,c=z,A++;
	cout<<A; 
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef long double ldbl;

unordered_map<int, int> c;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    c[a]++;
  }

  int ans = 0;
  for (auto t : c) {
    if (t.first != t.second) {
      if (t.second > t.first) {
        ans += t.second - t.first;
      } else {
        ans += t.second;
      }
    }
  }
  printf("%d", ans);

  return 0;
}

Measured memory_bytes: 4260
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=1e9,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const long long llinf=1e18;
long long n,ans;
int main(){
	cin>>n;
	if(n%2==0)
		cout<<n;
	else
		cout<<2ll*n;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
MOD=10**9+7

dif_x=[(X[i+1]-X[i])*(i+1)*(n-i-1) for i in range(n-1)]
dif_y=[(Y[i+1]-Y[i])*(i+1)*(m-i-1) for i in range(m-1)]    

print(sum(dif_x)*sum(dif_y)%MOD)

Measured memory_bytes: 19700
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>

using namespace std;
int main() {
	int n,x=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		x+=i;
	}
	cout<<x;
}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	l := nextInt()
	r := nextInt()
	ans := math.MaxInt32
	for i := l; i <= r; i++ {
		for j := i + 1; j <= r; j++ {
			ans = min(ans, (i*j)%2019)
			if ans == 0 {
				fmt.Println(ans)
				return
			}
		}
	}
	fmt.Println(ans)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	long a, b, tmp, i;
	
	while (scanf("%ld %ld", &a, &b) != EOF){
		if (a < b){
			tmp = a;
			a = b;
			b = tmp;
		}
		
		tmp = a * b;
		
		i = a % b;
		while (i != 0){
			a = b;
			b = i;
			i = a % b;
		}
		
		printf("%ld %ld\n", b, tmp / b);
	}
	
	return (0);
}

Measured memory_bytes: 1688
# For taking integer inputs.
def inp():
    return(int(input()))


N = inp()
A = []
i1, i2 = 0, 0

for i in range(N):
    A.append(inp())

srt = sorted(A)
m1 = srt[-1]
m2 = srt[-2]

for i in range(N):
    if A[i] == m1:
        print(m2)
    else:
        print(m1)


Measured memory_bytes: 14128
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){
  int n;
  int a[100010] = {};
  int i = 0;
  int kaburi = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(int),cmp);
  for(i=0;i<n-1;i++){
    if(a[i] == a[i+1]){
      kaburi++;
    }
  }
  if(kaburi % 2 == 1){
    printf("%d",n-kaburi-1);
  }else{
    printf("%d",n-kaburi);
  }
  return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <utility>
using namespace std;
#define ll unsigned long long
const int N=2e5+5;
int n,a[N];
ll k;
int vis[N];
int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	ll stlen=0,len=0;
	int cur=1,pre=1;vis[1]=1;
	for(ll i=1;i<=k;++i){
		cur=a[cur];
		if(vis[cur]){
			stlen=vis[cur];
			len=vis[pre]-vis[cur]+1;
			break;
		}
		vis[cur]=i+1;
		pre=cur;
	}
	if(!len){
		printf("%d\n",pre);
		return 0;
	}
	//printf("Debug:stlen:%lld,len:%lld\n",stlen,len);
	k=(k-stlen+2)%len;cur=pre;
	for(ll i=1;i<=k;++i){
		cur=a[cur];
	}
	printf("%d\n",cur);
	return 0;
}

Measured memory_bytes: 3292
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
#include <limits>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
bool debug_enabled = false;
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

// }}}

// bin {{{
template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

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

template<class T>
void sort(T& arr) { // {{{
  std::sort(arr.begin(), arr.end());
} // }}}
template<class T, class By>
void sort_by(T& arr, By by) { // {{{
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
} // }}}

template<class T>
void reverse(T& arr) { // {{{
  std::reverse(arr.begin(), arr.end());
} // }}}

class Random { // {{{
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
}; // }}}

template <class A>
ostream& out_vec(const vector<A>& x, const string& sep) { // {{{
  rep(i, x.size()) {
    cout << x[i];
    if(i < x.size() - 1)
      cout << sep;
  }
  return cout;
} // }}}
// }}}

// modulo {{{
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modplus(ll a, ll b, ll mod) {
  ll x = ((a % mod) + (b % mod)) % mod;
  if(x < 0) x += mod;
  return x;
}

ll modminus(ll a, ll b, ll mod) {
  return modplus(a, -b, mod);
}

// }}}

// main {{{
void solve();
int main() {
  cout << setprecision(20);
  solve();
}
// }}}

void solve() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) cin >> d[i];
  int ans = 0;
  rep(i, N) {
    rep2(j, i + 1, N) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
import sys
readline = sys.stdin.readline
writelines = sys.stdout.writelines
write = sys.stdout.write

from collections import deque
from heapq import heappush, heappop

INF = 10**30
def Johnson(G):
    h = [0]*N

    update = 1
    for i in range(N):
        update = 0
        for v in range(N):
            d = h[v]
            for w, c in G[v]:
                if c + d < h[w]:
                    h[w] = d + c
                    update = 1
        if not update:
            break
    else:
        return None

    for v in range(N):
        d = h[v]
        g = G[v]
        for j, (w, c) in enumerate(g):
            g[j] = (w, c + d - h[w])

    D = []
    for i in range(N):
        dst = [INF]*N
        dst[i] = 0
        que = [(0, i)]
        while que:
            cost, v = heappop(que)
            if dst[v] < cost:
                continue
            for w, c in G[v]:
                if cost + c < dst[w]:
                    dst[w] = r = cost + c
                    heappush(que, (r, w))
        v = h[i]
        for j in range(N):
            if dst[j] == INF:
                dst[j] = INF
            else:
                dst[j] -= v - h[j]
        D.append(dst)

    return D


N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    s, t, d = map(int, input().split())
    G[s].append((t, d))

D = Johnson(G)
if D:
    ans = []
    for i in range(N):
        ans.append(" ".join(str(v) if v < INF else "INF" for v in D[i]))
        ans.append("\n")
    writelines(ans)
else:
    write("NEGATIVE CYCLE\n")



Measured memory_bytes: 7460
n,k=map(int,raw_input().split())
arr=map(int,raw_input().split())
na=[0 for i in range(n)]
for i in range(1,n):
    m=999999999
    for j in range(max(i-k,0),i):
        m=min(m,na[j]+abs(arr[i]-arr[j]))
    na[i]=m
print na[-1]



Measured memory_bytes: 42348
#include<iostream>
#include<cstdio>
#include<vector>
const int N=2e5+5;
std::vector<int> g[N];
int ans[N],n,q;
void dfs(int u,int fa,int x) {
    ans[u]+=x;
    for(int v:g[u]) if(v!=fa) dfs(v,u,ans[u]);
}
int main() {
    scanf("%d%d",&n,&q);
    for(int i=1,x,y;i<n;i++) {
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int x,y;q--;) {
        scanf("%d%d",&x,&y);
        ans[x]+=y;
    }
    dfs(1,1,0);
    for(int i=1;i<=n;i++) printf("%d%c",ans[i]," \n"[i==n]);
    return 0;
}

Measured memory_bytes: 23424
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;

bool isprime[10000001];

void sieve(ll N){
  
  fill(isprime,isprime+10000001,true);
  isprime[0]=isprime[1]=false;
  
  for(ll i=2;i*i<=N;i++){
    if(isprime[i]){
      for(ll j=i*2;j<=N;j+=i){
	isprime[j]=false;
      }
    }
  }
}

int main(void){

  sieve(10000000);

  int res[10001];
  fill(res,res+10001,0);
  res[1]=2;
  for(int i=2,j=0;j<10001;i++)
    if(isprime[i])res[j+1]=res[j++]+i;

  int a;
  while(cin >> a,a){
    cout << res[a] << endl;
  }

  return 0;
}

Measured memory_bytes: 10964
#include<cstdio>
#include<algorithm>

int w(int);
int w10(int);
int y(int,int);
int main(void){
  int c50[8192],c10[8192],c5[8192],c1[8192];
  int i,j,k=0;
      int s,a50,a10,a5,a1;
  while(true){
    //??\???
    scanf("%d",&s);
    if(s == 0) break;

    scanf("%d%d%d%d",&a1,&a5,&a10,&a50);
      
    //  if(s%10!=0){
    //      s = s + 10 - s%10;
    //  }
    //  printf("%d\n",s);
    s=s/10;
  

    //?????????
      if(a1<w(s)){
          c1[k] = 0;
      } else {
          c1[k] = w(s) + y((a1 - w(s)),5)*5;
      }
      
    s=s-c1[k];
    if(w(s)!=0){
      s=s+5-w(s);
    }
      
    //?????????
    if (a5 == 0) {
      c5[k] = 0;
    } else if (w10(s) ==  5){
        c5[k] = 1+(a5-1)/2*2;
    } else {
        c5[k] = a5/2*2;
    }


    s=s - c5[k]*5;
    if(w10(s)==5){
      s=s+5;
    }
     
    
      s=s/10;
      //printf("s=%d\n",s);

    //?????????
   if (a10 < w(s)){
      c10[k] =0;
    }else {
        c10[k] = w(s) + y(a10 - w(s),5)*5;
    }

    s=s-c10[k];
    if(w(s)!=0){
      s=s+5-w(s);
    }

 //printf("s=%d\n",s);
    //50??????
      if(s>0){
        c50[k] = y(s,5);
      }
    k++;
  }


    //??????
    for(i=0;i<k-1;i++){
      if(c1[i]!=0){
	printf("10 %d\n",c1[i]);
      }
      if(c5[i]!=0){
	printf("50 %d\n",c5[i]);
      }
      if(c10[i]!=0){
	printf("100 %d\n",c10[i]);
      }
      if(c50[i]!=0){
	printf("500 %d\n",c50[i]);
      }
      printf("\n");
    }
    if(c1[k-1]!=0){
	printf("10 %d\n",c1[k-1]);
      }
      if(c5[k-1]!=0){
	printf("50 %d\n",c5[k-1]);
      }
      if(c10[k-1]!=0){
	printf("100 %d\n",c10[k-1]);
      }
      if(c50[k-1]!=0){
	printf("500 %d\n",c50[k-1]);
      }
      return 0;
}

 
int w(int n){
    int m;
    if(n>0){
        return n%5;
    }else if(n == 0){
        return 0;
    }else{
        m = -n;
        m = m % 5;
        if(m==0){
            return 0;
        } else {
            return 5-m;
        }
        
    }
}
int w10(int n){
    if(n>=0){
        return n%10;
        
    }else{
        return (-n)%10;
    }
}

int y(int a, int b){
    if(a>=0){
        return a/b;
    }else {
        if((-a)%b==0){
            return -((-a)/b);
        }else {
            return -((-a)/b + 1);
        }
        
    }
}
      

    

    
  

Measured memory_bytes: 2776
//***********************
//Author:kibi11
//Quarantine Days
//***********************

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fr(i, n) for(int i = 0; i < n; i++)
#define fr1(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,k) for(int i=a;i>=k;i--)
#define same int t;cin>>t;while(t--)
#define check(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define f first
#define s second
#define XOX

//////////////////////////////////////////////////////////////////////////
/////////////////DEBUGING ZONE//////////////////////////////

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
///////////////////////////////////////////////////////////////////////////
 
ll powermod(ll base, ll exp, ll mod) {
	ll result = 1;
	while (exp != 0) {
		if ((exp % 2) == 1) {
			result = (result * base) % mod;
		}
		base = (base * base) % mod;
		exp /= 2;
	}
	return result;
}

///////////////////////////////////////////////////////////////////////////
//Fuctions if any:





///////////////////////////////////////////////////////////////////////////
int main() 
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = clock();
//ios_base& scientific (ios_base& str);
	// #ifndef ONLINE_JUDGE
	// 	freopen("C:\\Users\\arpan\\Documents\\prog c++\\IN.txt","r",stdin);
	// 	freopen("C:\\Users\\arpan\\Documents\\prog c++\\OUT.txt","w",stdout);
	// 	freopen("C:\\Users\\arpan\\Documents\\prog c++\\Error.txt","w",stderr);
	// #endif
int n;
cin>>n;
int a[n];
int dp[n];
memset(dp,0,sizeof(dp));
fr(i,n)
cin>>a[i];
fr1(i,1,n)
{
	dp[i]=INT_MAX;
	// check(dp[i]);
	fr(j,2)
	{
		// debug(j);
		if((i-j-1)>=0)
		{

			
			dp[i]=min({dp[i-j-1]+abs(a[i]-a[i-j-1]),dp[i]});
			// check(dp[i]);
			

		}
	}

}
// fr(i,n)
// cout<<dp[i]<<" ";
cout<<dp[n-1]<<endl;
cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] A = new int[N];

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

    sc.close();

    int[] d = new int[N];

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

    Arrays.sort(d);

    int d_ = 0;
    
    d_ = N/2;

    long min = 0;

    for (int i = 0; i < N; i++) {
      min += Math.abs(i + 1 - A[i] - d[d_]);
    }

    System.out.println(min);

  }

}

Measured memory_bytes: 63380
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i+j)%2 == 0) printf("#");
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

int s(ll n) {
    ll ans = 0;
    while (n != 0) {
        ans += (n % 10);
        n /= 10;
    }
    return ans;
}

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

    cout << (n % s(n) == 0 ? "Yes" : "No") << endl;

}




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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    int n;
    cin >> n;
    map<int,int> m;
    rep(i,1,n)
    {
        int x;
        cin >> x;
        m[x]++;
    }
    rep(i,1,n+1)
    {
        cout << m[i] << endl;
    }
}

int main()
{
    //ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


Measured memory_bytes: 12976