akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;

    int H, W, D;
    void solve()
    {
        H = cin.nextint;
        W = cin.nextint;
        D = cin.nextint;
        var B = new int[D, H * W / D + 1];
        var C = new pair[H * W];
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                C[cin.nextint - 1] = new pair(i, j);
            }
        }
        for (int i = 0; i < D; i++)
        {
            for (int j = i + D; j < H * W; j += D)
            {
                B[i, j / D] = B[i, j / D - 1] + Math.Abs(C[j - D].f - C[j].f) + Math.Abs(C[j - D].s - C[j].s);
            }

        }
        //for (int i = 0; i < H * W; i++)
        //{
        //    WriteLine(C[i].ToString());
        //}

        int Q = cin.nextint;
        for (int i = 0; i < Q; i++)
        {
            int l = cin.nextint - 1;
            int r = cin.nextint - 1;
            WriteLine(B[l % D, r / D] - B[l % D, l / D]);
        }

    }

}

class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
    public T f;
    public U s;
    public Pair(T f, U s)
    {
        this.f = f;
        this.s = s;
    }
    public int CompareTo(Pair<T, U> a)
    {
        return f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);
    }
    public override string ToString()
    {
        return f + " " + s;
    }
}
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 21188
N = int(input())

ms = set([1])
i = 1
while True:
    m = 6**i
    if m > N:
        break
    ms.add(m)
    i += 1
i = 1
while True:
    m = 9**i
    if m > N:
        break
    ms.add(m)
    i += 1

dp = [0] * (N+1)
dp[0] = 0
for i in range(1, N+1):
    dp[i] = min(dp[i-m] for m in ms if i-m >= 0) + 1
print(dp[-1])


Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    map<ll, ll> mp;
    ll ans = 0;
    int N;
    cin >> N;
    for(int i=1; i<=N; i++){
        ll A;
        cin >> A;
        if(mp.count(i-A)>0){
            ans+=mp[i-A];
        }

        if(mp.count(i+A)>0){
            mp[i+A]++;
        }else{
            mp[i+A]=1;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 16096
N,K=map(int,input().split())
p=list(map(int,input().split()))
def P(x):
    return (x+1)/2
a=0
y=0
for i in range(N):
    y+=P(p[i])#区間内の期待値の和
    if i>=K:
        y-=P(p[i-K])
    if a<y:
        a=y
print(a)

Measured memory_bytes: 25060
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

int main(){
    int n;
    cin >> n;
    int cost_b = 0;
    int a_b = 0;
    int b_b = 0;
    
    bool ans = true;
    
    for(int i = 0; i < n; i++){
        int cost, a, b;
        cin >> cost >> a >> b;
        int new_cost = cost - cost_b;
        int new_a = abs(a - a_b);
        int new_b = abs(b - b_b);
        if(new_cost >= new_a + new_b && (new_cost - (new_a + new_b)) % 2 == 0){
            ans = true;
        }else{
            ans = false;
            break;
        }
        cost_b = cost;
        a_b = a;
        b_b = b;
    }
    if(ans){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if(abs(c-a) <= d || (abs(b-a) <= d && abs(b-c) <= d)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
s=input()
x,y=map(int,input().split())
h=[]
v=[]
num=0
m=1
for i in s:
    if i=='F':
        num+=1
    else:
        if num!=0:
            if m==1:
                h.append(num)
            else:
                v.append(num)
        m=-m
        num=0
if num!=0:
    if m==1:
        h.append(num)
    else:
        v.append(num)
if s[0]=='F':
    x=x-h[0]
    del h[0]
sumh=sum(h)
nh=len(h)
dph=[]
if nh!=0:
    for i in range(nh+1):
        sub_list=[False]*(1+2*sumh)
        dph.append(sub_list)
    dph[0][sumh]=True
    for i in range(1,nh+1):
        for j in range(1+2*sumh):
            if j-h[i-1]>=0:
                dph[i][j]=dph[i][j] or dph[i-1][j-h[i-1]]
            if j+h[i-1]<=2*sumh:
                dph[i][j]=dph[i][j] or dph[i-1][j+h[i-1]]
    if 0<=x+sumh<=2*sumh:
        sh=dph[nh][x+sumh]
    else:
        sh=False
else:
    if x==0:
        sh=True
    else:
        sh=False
sumv=sum(v)
nv=len(v)
dpv=[]
if nv!=0:
    for i in range(nv+1):
        sub_list=[False]*(1+2*sumv)
        dpv.append(sub_list)
    dpv[0][sumv]=True
    for i in range(1,nv+1):
        for j in range(1+2*sumv):
            if j-v[i-1]>=0:
                dpv[i][j]=dpv[i][j] or dpv[i-1][j-v[i-1]]
            if j+v[i-1]<=2*sumv:
                dpv[i][j]=dpv[i][j] or dpv[i-1][j+v[i-1]]
    if 0<=y+sumv<=2*sumv:
        sv=dpv[nv][y+sumv]
    else:
        sv=False
else:
    if y==0:
        sv=True
    else:
        sv=False
if sh and sv:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 168284
N,D = map(int, input().split())

# XY = []
ans = 0
D2=D**2

for i in range(N):
    # XY.append(list(map(int, input().split())))
    X,Y = map(int, input().split())
    if X**2+Y**2<=D2:
        ans+=1

print(ans)

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

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, x;
	cin >> n >> x;
	vector<int> cities(n);
	for (int i = 0; i < n; ++i) cin >> cities[i];
	int ans = abs(x - cities[0]);
	for (int i = 1; i < n; ++i) {
		ans = gcd(ans, abs(x - cities[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 1e6 + 5 ; 
char s[N] ; 
int f[N][2] ;
signed main()
{
	scanf("%s", s + 1 ) ;
	int n = strlen( s + 1 ), Ans = 0 ; s[0] = '0' ;
	f[n + 1][0] = 0, f[n + 1][1] = 100 ;
	for( re int i = n; i >= 0; -- i ) {
		int u = s[i] - '0' ; 
		f[i][1] = min( f[i + 1][1] - u - 1, f[i + 1][0] - u ) + 10 ;
		f[i][0] = min( f[i + 1][1] + u + 1, f[i + 1][0] + u ) ;
	}
	cout << f[0][0] << endl ;
	return 0 ;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int tmp = max(max(a,b),c);
  //int tmp2 = tmp;
  int k;
  cin >> k;
  cout << a+b+c-tmp+tmp*(int)(pow(2,k)) << endl;
}

Measured memory_bytes: 256
program main
    implicit none
    integer N, i, ans
    integer :: l(1010) = 0
    integer :: r(1010) = 0
    ans = 0
    read *, N
    do i = 1,N
        read *, l(i), r(i)
        ans = ans + r(i) - l(i) + 1
    end do

    print *, ans
end program main


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextLong();
        long[] al = new long[n];
        for(int i = 0; i < n; i++){
            al[i] = sc.nextLong();
        }
        long ans = 0;
        for(int i = 0; i < n-1; i++){
            long tmp = al[i] + al[i+1];
            if(tmp <= x){
                continue;
            }else if(tmp - x > al[i+1]){
                al[i+1] = 0;
                al[i] -= tmp - x - al[i+1];
            }else{
                al[i+1] -= (tmp-x);
            }
            ans += tmp-x;
        }
        System.out.println(ans);
    }
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pii pair<int, int>
#define vii vector<pii>
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vd vector<double>
#define vvi vector< vector<int> >
#define vvii vector< vector< pii > >
#define ld long double
#define mapii map<int, int>
#define mapsi map<string, int>
#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
//#define INF  LLONG_MAX
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define pie  acos(-1)
#define mod(n,m) ((n % m + m) % m)
#define eps (1e-8)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'
#define output freopen("output.txt", "w", stdout)
#define mp(x, y, z) {x, {y, z}}

int n, p, arr[52];

ull memo[5001][52];

ull solve(int i, int sum)
{
    if (i == n) return (sum%2 == p);
    if (memo[sum][i] != -1) return memo[sum][i];
    ull ret = 0;
    ret += solve(i+1, sum);
    ret += solve(i+1, sum + arr[i]);
    return memo[sum][i] = ret;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    reset(memo, -1);
    cin >> n >> p;
    rep(i, 0, n) cin >> arr[i];
    cout << solve(0, 0);
    return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<cmath>
using namespace std;

int main(void)
{
    int X, N;
    cin >> X >> N;

    vector<int> p(N);
    for (int i = 0; i < N; i++)
        cin >> p[i];

    vector<bool> v(102, true);
    for (int i = 0; i < N; i++)
        v[p[i]] = false;

    int ans = 1000;
    int d = abs(ans - X);

    for (int i = 0; i < 102; i++) {
        if (v[i] == false)
            continue;

        int dd = abs(i - X);
        if (dd < d) {
            ans = i;
            d = dd;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <map>
#include <bitset>
#include <queue>

//#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<char>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)

int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };
int main()
{
    // 行と列	
    int H, W;
    cin >> H >> W;
    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(H, vector<char>(W));
    int whitemass = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0;j < W;j++)
        {
            char a;
            cin >> a;
            if (a == '.')
            {
                // 白mass
                whitemass++;
            }
            G.at(i).at(j) = a;
        }
    }

    // BFS のためのデータ構造
    vector<vector<int>> dist(H, vector<int>(W, -1)); // マスを見訪問に設定
    queue<pair<int, int>> que; // 未訪問のマスを管理するするque

    // 初期条件 (Start地点 を初期ノードとする)
    dist[0][0] = 0;
    que.push(make_pair(1, 1)); // スタート地点を訪問済みにする

    int ans = 0;
    bool find = false;
    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty() && !find) {
        pair<int, int> current = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // 隣接頂点の検索
        for (int i = 0; i < 4; i++)
        {
            int y = current.first + dx[i];
            int x = current.second + dy[i];
            // ガード
            if (x < 1 || y < 1 || H < y || W < x) {
                continue;
            }
            if (G[y - 1][x - 1] == '#') {
                continue;
            }
            if (y == H && x == W) {
                ans = dist[current.first - 1][current.second - 1] + 1; // Goalならば終了する
                find = true;
                break;
            }

            if (dist[y - 1][x - 1] == -1)
            {
                // 進めるのでdistに順序を格納
                dist[y - 1][x - 1] = dist[current.first - 1][current.second - 1] + 1;
                // queに訪問済み情報の格納
                que.push(make_pair(y, x));
            }
        }
    }
    // 結果出力
	if (find)
	{
		cout << (whitemass - ans-1) << endl;
	}
	else
	{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1,0,1,0 }; const int dy[] = { 0,1,0,-1 };

int main() {
	int n, m;
	cin >> n >> m;
	vi num(n,0);
	REP(i, m*2) {
		int a;
		cin >> a;
		num[a - 1]++;
	}
	REP(i, n) {
		cout << num[i] << endl;
	}
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int> pq;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    pq.push(A);
  }
  for (int i = 0; i < M; i++) {
    int X = pq.top();
    pq.pop();
    pq.push(X / 2);
  }
  long long int ans = 0;
  while(!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
struct Union_Find{
    int d[SIZE],num[SIZE];
    void init(int n){
        REP(i,n)d[i]=i,num[i]=1;
    }
    int find(int x){return (x!=d[x])?(d[x]=find(d[x])):x;}
    bool is_root(int x){return d[x]==x;}
    bool uu(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return 0;
        if(num[x]>num[y])swap(x,y);
        num[y]+=num[x];
        d[x]=y;
        return 1;
    }
}U;
int main(){
    int N,M;
    R(N,M);
    U.init(N+1);
    VI p(N+1);
    FOR(i,1,N)R(p[i]);
    REP(i,M){
        int x,y; R(x,y);
        U.uu(x,y);
    }
    int an=0;
    FOR(i,1,N){
        if(U.find(p[i])==U.find(i))an++;
    }
    W(an);
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


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

  int n, k, q;
  cin >> n >> k >> q;
  vector <int> p (n, k-q);
  REP(i,q) {
    int a;
    cin >> a;
    --a;
    p [a] ++;
  }
  REP(i,n) {
    if (p [i] <= 0) puts ("No");
    else puts ("Yes");
  }
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,M,K;cin>>N>>M>>K;
  vector<long> A(N);
  vector<long> B(M);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<M;i++)cin>>B[i];
  long m=0;
  long sum=0;
  long bm=0;
  long b=-1,a=N;
  for(int i=0;i<N;i++){
    sum+=A[i];bm++;
  }
  while(true){
    //cout<<sum<<" "<<bm<<endl;
    if(sum<=K){
      m=max(m,bm);
      b++;
      if(b>=M)break;
      sum+=B[b];
      bm++;
    }else{
      a--;
      if(a<0)break;
      sum-=A[a];
      bm--;
    }
  }
  cout<<m<<endl;
}


Measured memory_bytes: 6424
//File Name: code_festival_2017_quala_a.cpp
  //Created Time: 2017年09月30日 星期六 21时14分21秒
                                   
#include <bits/stdc++.h>
using namespace std;

int main(){
	string str;
	cin >> str;
	if(str.length() >= 4 && str[0] == 'Y' && str[1] == 'A' && str[2] == 'K' && str[3] == 'I')
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
N = int(input())
D = [list(map(int,input().split())) for _ in range(N)]

count = 0
for d1, d2 in D:
  if d1 == d2:
    count += 1
  else:
    count = 0
  if count == 3:
    print("Yes")
    break
else:
  print("No")

Measured memory_bytes: 62544
import itertools
A, B, C, D, E, F = map(int, input().split())
U = F
water = [0]*(U+1)
water[0] = 1
for i in range(U+1):
    if water[i]:
        if i+100*A <= U:
            water[i+100*A] = 1
        if i+100*B <= U:
            water[i+100*B] = 1
water_val = [val for val in range(1, U+1) if water[val]]
suger = [0]*(U+1)
suger[0] = 1
for i in range(U+1):
    if suger[i]:
        if i+C <= U:
            suger[i+C] = 1
        if i+D <= U:
            suger[i+D] = 1

suger_val = [val for val in range(U+1) if suger[val]]
max_c = -1
for w, s in itertools.product(water_val, suger_val):
    if E*w < 100*s:
        continue
    if F < w+s:
        continue

    if max_c < 100*s/(w+s):
        max_c = 100*s/(w+s)
        ans = (w+s, s)

print(*ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << " " << *t++;
        // if(t != V.end()) cout << " ";
    }
    cout << endl;
};

class edge {
  public:
    int f;
    int t;
    int c;
    edge(int _f, int _t, int _c) {
        f = _f;
        t = _t;
        c = _c;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, u, k, v, c;
    cin >> n;
    vector<edge> edges;

    int d[n + 1];
    fill(d, d + n, INFINT);
    d[0] = 0;
    rep(i, n) {
        cin >> u >> k;
        rep(j, k) {
            cin >> v >> c;
            edge tmp(u, v, c);
            edges.push_back(tmp);
        }
    }

    rep(i, n) {
        for(auto e : edges) {
            if(d[e.t] > d[e.f] + e.c) {
                d[e.t] = d[e.f] + e.c;
            }
        }
    }

    rep(i, n) cout << i << " " << d[i] << "\n";
}



Measured memory_bytes: 3200
#include <iostream>
using namespace std;
int main()
{
  string S, T;
  cin >> S >> T;
  string ans = "No";
  for (int i = 0; i < S.length(); i++)
  {
    S = S.substr(S.length() - 1, 1) + S.substr(0, S.length() - 1);
    if (S == T)
      ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
T = [
    None,
    "',.!?",
    "abcABC",
    "defDEF",
    "ghiGHI",
    "jklJKL",
    "mnoMNO",
    "pqrsPQRS",
    "tuvTUV",
    "wxyzWXYZ",
]
try:
    while 1:
        ans = []
        *S, = map(int, input())
        S.append(0)
        prv = 0
        cur = -1
        for c in S:
            if c == prv:
                if c == 0:
                    ans.append(" ")
                    cur = 0
                else:
                    cur += 1
            else:
                if prv != 0:
                    t = T[int(prv)]
                    ans.append(t[cur%len(t)])
                cur = 0
            prv = c
        print(*ans, sep='')
except EOFError:
    ...



Measured memory_bytes: 5604
#include <stdio.h>
#include <string.h>
#define max(a, b) ((a)<(b) ? (b) : (a))

int main(){
  char s[11];  scanf("%s", s);
  int ans = 0;
  for(int i=0; i<strlen(s); i++){
    for(int j=i+1; j<=strlen(s); j++){
      for(int k=i; k<j; k++){
	if(!(s[k]=='A' || s[k]=='T' || s[k]=='C' || s[k]=='G')) break;
	if(k == j-1)
	  ans = max(ans, j-i);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	rep(i,4){
		if(s[i] == '+') ans+=1;
		else ans--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int char_to_int(char c){
  switch(c){
    case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
  }
}


int main(){
  ll N;
  cin >> N;
  
  vector <ll> L(N+1); L.at(0) = 2; L.at(1) = 1;
  
  rep(i, N-1){
    L.at(i+2) = L.at(i+1) + L.at(i);
  }
  
  //rep(i, N+1) cout << L.at(i) << endl;
  
  cout << L.at(N);
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

ans = 0
flag = True

while True:
    for i in range(n):
        if A[i] % 2 == 0:
            A[i] = A[i]/2
        else:
            flag = False
            break
    if flag:
        ans += 1
    else:
        break

print(ans)


Measured memory_bytes: 2940
# D - Gathering Children
import numpy as np

s = list(str(input()))
s = np.array(s)

# r
r = np.zeros(len(s), dtype=np.int)
r[s=='R'] = 1

for i in range(1, len(s)):
    if r[i]==1:
        r[i] += r[i-1]
        r[i-1] = 0

# l 
l = np.zeros(len(s), dtype=np.int)
l[s=='L'] = 1

for i in range(len(s)-1)[::-1]:
    if l[i]==1:
        l[i] += l[i+1]
        l[i+1] = 0

nums = l + r

for i in range(len(s)):
    if nums[i]!=0 and s[i]=='R':
        tmp = nums[i]+nums[i+1]
        if nums[i]%2==1:
            nums[i] = (tmp+1)//2
            nums[i+1] = tmp//2
        else:
            nums[i] = tmp//2
            nums[i+1] = (tmp+1)//2

print(' '.join(map(str, nums)))




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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u32 n;
  cin >> n;
  map<string, u32> ans;

  rep(i, n) {
    string s;
    cin >> s;
    ans[s] += 1;
  }

  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ans["AC"], ans["WA"],
         ans["TLE"], ans["RE"]);

  return 0;
}


Measured memory_bytes: 3724
def __main():
    n,k = map(int, input().split())
    P = list(map(int, input().split()))
    P = list(map(lambda x:(x+1)/2, P))

    cur = sum(P[:k])
    #print('first ', cur)
    ans = cur

    for i in range(1, n-k+1):
        cur += P[i+k-1] - P[i-1]
        if cur < ans: continue
        ans = cur

    print(ans)
__main()

Measured memory_bytes: 24804
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int k,t;
  cin>>k>>t;
  int total=0;
  int mx=0;
  rep(i,t){
    int d;
    scanf("%d", &d);
    total += d;
    mx =max(mx, d);
  }

  int others = total - mx;
  if(others < mx -1){
    cout << mx-others-1 << endl;
  } else {
    cout<<0<<endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
    int ac=0,wa=0,tle=0,re=0;
    int n;
    string s;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s;
        if(s == "AC"){
            ac++;
        }else if(s == "WA"){
            wa++;
        }else if(s == "TLE"){
            tle++;
        }else{
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

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

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

 int A[100];
 for (int i = 0; i < N; i++) {
cin>>A[i];
 }

 for (int i = 0; i < N; i++) {
 if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
 cout<<"DENIED"<<endl;
   return 0;

 }
 }
 cout<<"APPROVED"<<endl;
   return 0;
 
 }


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    long ans = Long.MAX_VALUE;
    for(int i = 0; i <= Math.max(x, y); i++){
      long temp = 2*i*c + a*Math.max(0,x-i) + b*Math.max(0,y-i);
      if(temp < ans){
        ans = temp;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23380
//https://atcoder.jp/contests/agc041/tasks/agc041_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    //std::ifstream in("./test/sample-3.in"); //input.txt
    std::ifstream in("./input.txt"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif    
    ll N,M,V,P; cin>>N>>M>>V>>P;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    sort(an.begin(),an.end(),greater<ll>());
    dump(an);

    auto check_func = [&](ll cur)->bool{
        ll P0 = P-1;
        if(cur<=P0) return true;
        ll ppoint=an[cur]+M;
        if (ppoint < an[P0]) return false;
        ll rest = M*V-M*P;
        for(ll i=an.size()-1;i>=P0;--i){
            if (i==cur) continue;
            auto subv = min(M,max(ppoint-an[i],0LL));
            //dump(i,subv);
            rest -= subv;
        }
        if (rest <= 0) return true;
        return false; //trueだと採用
    };
    REP(i,10){
        dump(i, check_func(i));
    }

    ll lb=0,ub=an.size();
    while(ub-lb>1){
        ll mid=(ub+lb)/2;
        auto ck = check_func(mid);
        if (ck){
            lb=mid;
        }else{
            ub=mid;
        }
        dump(mid,ck,lb,ub);
    }
    cout<<lb+1<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
#define lp(k,a) for(int k=1;k<=a;k++)
#define lp0(k,a) for(int k=0;k<a;k++)
#define lpn(k,n,a) for(int k=n;k<=a;k++)
#define lpd(k,n,a) for(int k=n;k>=a;k--)
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d %d",&a,&b)
#define ll long long
#define MAX 100000

using namespace std;

int n,m;
int a[100010];
int ha[100010];
char s[100010];

int main()
{
   // freopen("in.txt","r",stdin);
    cin>>n;
    int re=0;
   lp(i,n)
   {
       cin>>a[i];
   }
    lp(i,n)
    {
        if(a[i]==0)
        {
            ha[0]++;
            ha[1]++;
        }
        else
        {
            ha[a[i]]++;
            ha[a[i]+1]++;
            ha[a[i]-1]++;
        }
    }
    lpn(i,0,100000)
    {
        re=max(re,ha[i]);
    }
    cout<<re<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        for(int i = 0;i < s.length();i++){
            for(int j = i+1;j < s.length();j++){
                if(str[i] == str[j]){
                    System.out.println("no");
                    return;
                }
            }
        }
        System.out.println("yes");
    }
}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n, W;
    cin >> n >> W;
    vector<ll> w, v, tmp(W+1, 0);
    vector<vector<ll>> dp(n+1, tmp);
    rep(i, n){
        ll x, y;
        cin >> x >> y;
        w.push_back(x);
        v.push_back(y);
    }

    rep2(i, 1, n+1){
        rep2(j, 1, W+1){
            if(j-w[i-1]>=0){
                dp[i][j] = max(dp[i - 1][j - w[i-1]] + v[i-1], dp[i - 1][j]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 83068
import std.stdio : write, writef;
import std.array;
import std.range;

void main(){
	while(true){
		int n = next!int();
		if(n==0){ return; }
		
		int[][] map;
		for(int i=0; i<n; ++i){ map ~= repeat(0).take(n).array; }
		int count;
		
		int[2] ptr = [n/2, n/2+1];
		while(count<n*n){
			while(map[ptr[1]][ptr[0]]!=0){
				ptr[0] = (ptr[0] + n-1)%n;
				++ptr[1] %= n;
			}
			
			map[ptr[1]][ptr[0]] = ++count;

			++ptr[0] %= n;
			++ptr[1] %= n;
		}
		
		for(int y=0; y<n; ++y){
			for(int x=0; x<n; ++x){
				writef("%4d",map[y][x]);
			}
			"\n".write;
		}
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

Measured memory_bytes: 988
#include<stdio.h>
#include<string.h>
int main(){
    int i,n,j,k,cnt=0,cnt2=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=i;j=j+2)
        {
            if(i%j==0)cnt++;

        }
        if(cnt==8)
{
    cnt2++;
           }
        cnt=0;
    }
printf("%d\n",cnt2);
return 0;
}



Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    edge=[]
    for i in range(M):
        a,b=map(int1,input().split())
        edge.append((a,b))
    class UnionFind:
        def __init__(self,n):
            self.par=[i for i in range(n)]
            self.siz=[1]*n
            
        def root(self,x):
            while self.par[x]!=x:
                self.par[x]=self.par[self.par[x]]
                x=self.par[x]
            return x
        
        def unite(self,x,y):
            x=self.root(x)
            y=self.root(y)
            if x==y:
                return False
            if self.siz[x]<self.siz[y]:
                x,y=y,x
            self.siz[x]+=self.siz[y]
            self.par[y]=x
            return True
        
        def is_same(self,x,y):
            return self.root(x)==self.root(y)
        
        def size(self,x):
            return self.siz[self.root(x)]
    ans=0
    for i in range(M):
        u=UnionFind(N)
        for j in range(M):
            if i==j:
                continue
            u.unite(edge[j][0],edge[j][1])
        if u.size(0)<N:
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42204
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int A, B;
	cin >> A >> B;
	puts(max(0, A - 2 * B));

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;


void solve() {
  ll n,x,t;
  cin >> n >> x >> t;
  ll ans = ((n + x - 1) / x) * t;
  cout << ans << endl;
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


Measured memory_bytes: 3620
K = int(input())
S = input()
def result(K: int, S: str) -> str:
    s_len = len(S)
    if s_len <= K:
        return S
    else:
        answer = ''
        i = 0
        while i <= K-1:
            answer += S[i]
            i += 1
        answer += '...'
        return answer
print(result(K, S))


Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b; cin >> a >> b;
	int cnt = 0;
	for(int i = a; i <= b; i++){
		int i_10000, i_1000, i_100, i_10, i_1;
		i_10000 = i/10000;
		i_1000 = ( i % 10000 )/1000;
		i_100 = (i % 1000)/100;
		i_10 = (i % 100)/10;
		i_1 = (i % 10);
		if(i_10000 == i_1 && i_1000 == i_10)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main()
{
   int H,W;
   cin>>H;
   cin>>W;
   char Matrix[H+2][W+2];
   for (int i=0;i<=H+1;i++){
        for (int j=0;j<=W+1;j++){
            Matrix[i][j]='#';

        }
   }
   for (int i=1;i<H+1;i++){
        for (int j=1;j<W+1;j++){
            cin>>Matrix[i][j];
        }
   }
   for (int i=0;i<=H+1;i++){
        for (int j=0;j<=W+1;j++){
            cout<<Matrix[i][j];

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


Measured memory_bytes: 256
import itertools

n, m, q = map(int, input().split())
q_list = []
for i in range(q):
    q_list.append(list(map(int, input().split())))

l = [i for i in range(1, m+1)]
comb = itertools.combinations_with_replacement(l, n)

ans = 0
for v in comb:
    tmp = 0
    for d in q_list:
        if v[d[1]-1] - v[d[0]-1] == d[2]: tmp += d[3]
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 9212
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        
//      int n=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int k=sc.nextInt();
        
        if(k<=a)ret(k);
        k-=a+b;
        if(0<=k)ret(a-k);

        out.println(a);
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,c;long s;
//	P(int  x, int c, long s) {
//	  this.x=x;
//	  this.c=c;
//	  this.s=s;
//	}
//}


class P implements Comparable<P>{
	int x,c;long s;
	P(int  x, int c, long s) {
	  this.x=x;
	  this.c=c;
	  this.s=s;
	}

    public int compareTo(P p){
        return Long.signum(s-p.s);
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 33020
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
//{{{ read()
inline int read(){
	register int x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
//}}}
const int N=2e5+5;
int n,q,A,B,x;
ll sum;
struct each{
	ll a[N<2],la[N<<2];
	void add(int l,int r,int x,ll z,int rt){
		if(l==r){
			a[rt]=z;
			return ;
		}
		int mid=(l+r)>>1;
		if(x<=mid) add(l,mid,x,z,rt<<1);
		else add(++mid,r,x,z,rt<<1|1);
		a[rt]=min(a[rt<<1],a[rt<<1|1]);
	}
	ll query(int l,int r,int x,int y,int rt){
		if(x<=l&&y>=r)	return a[rt]+sum;
		int mid=(l+r)>>1;
		ll ans=1e18;
		if(x<=mid)	ans=query(l,mid,x,y,rt<<1);
		if(y>mid) ans=min(ans,query(++mid,r,x,y,rt<<1|1));
		return ans;
	}
	void build(int l,int r,int ty,int rt){
		if(l==r){
			a[rt]=min(abs(A-x)+abs(B-l),abs(A-l)+abs(B-x))+ty*l;
			return ;
		}
		int mid=(l+r)>>1;
		build(l,mid,ty,rt<<1);
		build(++mid,r,ty,rt<<1|1);
		a[rt]=min(a[rt<<1],a[rt<<1|1]);
	}
	ll pri(int l,int r,int rt){
		if(l==r) return a[rt]+l+sum;
		int mid=(l+r)>>1;
		return min(pri(l,mid,rt<<1),pri(mid+1,r,rt<<1|1));
	}
}t1,t2;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),q=read(),A=read(),B=read(),x=read();
	t1.build(1,n,-1,1),t2.build(1,n,1,1),B=x;
	while(--q){
		x=read();
		int dis=abs(B-x);
		ll k=min(t1.query(1,n,1,x,1)+x,t2.query(1,n,x,n,1)-x)-dis-sum;
		t1.add(1,n,B,k-B,1),t2.add(1,n,B,k+B,1),sum+=dis,B=x;
	}
	printf("%lld\n",t1.pri(1,n,1));
	return 0;
}


Measured memory_bytes: 12544
n= int(input())
List = list(map(int, input().split()))


ans = "Yes"
ma = -1
for i in range(n):
    if (ma < List[i]):
            ma = List[i] - 1
    elif (ma == List[i]):
        ma = List[i]
    else:
        ans = "No"
        break



print(ans)



Measured memory_bytes: 14396
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

namespace MorrisPratt{
    template <typename T>
    vector<int> init(T pat){
        int n = pat.size(), j = -1;
        vector<int> f(n+1, -1);
        for(int i=0;i<n;++i){
            while(j>=0 and pat[i]!=pat[j]) j = f[j];
            f[i+1] = ++j;
        }
        return f;
    }

    template <typename T>
    vector<int> search(T& source, T& pat, vector<int> f={}){
        if(f.empty()){
            f = init(pat);
        }
        int n = source.size(), m = pat.size(), j = 0;
        vector<int> res;
        for(int i=0;i+j<n;){
            while(i+j<n and j<m and source[i+j]==pat[j]){
                ++j;
            }
            if(j==m){
                res.pb(i);
            }
            i = i + j - f[j];
            if(j){
                j = f[j];
            }
        }
        return res;
    }
}

using namespace MorrisPratt;

class FXorShift {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> A(N), B(N), AA(N), BB(N);
        for(auto& a : A) in>>a;
        for(auto& b : B) in>>b;
        REP(i, N){
            AA[i] = A[i] ^ A[(i+1)%N];
            BB[i] = B[i] ^ B[(i+1)%N];
        }
        vc<int> f = init(BB), C(2*N-1);
        REP(i, N){
            C[i] = AA[i];
            if(i<N-1) C[i+N] = AA[i];
        }
        vc<int> ans = search(C, BB, f);
        for(auto& k : ans) out<<k<<' '<<(A[k]^B[0])<<'\n';
    }
};


int main() {
	FXorShift solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 11816