akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin>>n;
    double sum=0; double a;
    rep(i,0,n-1)
    {
      cin>>a;
      sum+=1/a;
    }
    sum=1/sum;
    cout<<fixed<<setprecision(14)<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 384
N,M,X,Y=map(int,input().split())
x_box=input().split()
y_box=input().split()

for a in range(len(x_box)):
    x_box[a]=int(x_box[a])
for a in range(len(y_box)):
    y_box[a]=int(y_box[a])

for i in range(X+1,Y+1):
    if max(x_box)< i <=min(y_box):
        print('No War')
        exit()
print('War')

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

double A, B, Al,Ar,Bl,Br, Ax, Bx;

int main()
{
    cin >> A >> B;

    Al = ceil(A / 0.08);
    Bl = ceil(B / 0.1);
    Ar = (A + 1) / 0.08;
    Br = (B + 1) / 0.1;
    
    
    if(Al <= Bl && Bl < Ar) cout << (int)Bl << endl;
    else if(Bl < Al && Al < Br) cout << (int)Al << endl;
    else cout << -1 << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <string>

const int N = (int) (2e5 + 10);

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

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    std::string str;
    int q, begLen = 0, endLen = 0;
    std::cin >> str >> q;
    char beg[N], end[N];
    bool backwards = false;
    while (q--) {
        int t;
        std::cin >> t;
        if (t == 1) {
            backwards = !backwards;
        } else {
            int f;
            char p;
            std::cin >> f >> p;
            if (((f == 1) && !backwards) || ((f == 2) && backwards)) {
                beg[begLen] = p;
                ++begLen;
            } else {
                end[endLen] = p;
                ++endLen;
            }
        }
    }
    beg[begLen] = end[endLen] = 0;
    if (!backwards) {
        for (int i = begLen - 1; i >= 0; --i) {
            std::cout << beg[i];
        }
        std::cout << str << end;
    } else {
        for (int i = endLen - 1; i >= 0; --i) {
            std::cout << end[i];
        }
        for (int i = (int) str.length() - 1; i >= 0; --i) {
            std::cout << str[i];
        }
        std::cout << beg;
    }
    std::cout << '\n';
    return 0;
}

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

int main(){

    int a,b,c;

    cin >> a  >> b >> c;

    int s[3] = {a,b,c};

    int fiveCount = 0;
    int sevenCount = 0;

    for(int i=0; i<sizeof(s); i++){
        if(s[i] == 5){
            fiveCount++;
        }
        if(s[i] == 7){
            sevenCount++;
        }
    }

    if(fiveCount == 2 && sevenCount == 1){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    

}

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

int main() {
   int n,l;
   cin >> n >> l;
   int sum=0,lmin=1e9;
   rep(i,n){
      int t=l+i;
      sum+=t;
      if(abs(t-0)<abs(lmin))
      lmin=t;
   }
   cout << sum-lmin << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());
    int Q = Integer.parseInt(sc.next());
    int[][] ab = new int[N][2];
    int[] p = new int[Q];
    int[] x = new int[Q];

    for (int i = 1; i < N; i++) {
      ab[i][0] = Integer.parseInt(sc.next());
      ab[i][1] = Integer.parseInt(sc.next());
    }

    for (int i = 0; i < Q; i++) {
      p[i] = Integer.parseInt(sc.next());
      x[i] = Integer.parseInt(sc.next());
    }

    sc.close();

    int[] v = new int[N+1];

    for (int i = 0; i < Q; i++) {
      v[p[i]] += x[i];
    }

    Arrays.sort(ab, (a,b) -> Integer.compare(a[0],b[0]));
    Arrays.sort(ab, (a,b) -> Integer.compare(a[1],b[1]));

    for (int i = 1; i < N; i++) {
      v[ab[i][1]] += v[ab[i][0]];
    }

    PrintWriter out = new PrintWriter(System.out);
    
    for (int i = 1; i < N+1; i++) {
      if (i != 1){
        out.print(" ");
      }
      out.print(v[i]);
    }
    
    out.println("");

    out.flush();
    
  }

}

Measured memory_bytes: 103784
#include "bits/stdc++.h"

using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

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

    size_t N, M;
    cin >> N >> M;

    vector<int> sw[M];
    for (size_t i = 0; i < M; ++i) {
        size_t k; cin >> k;
        for (size_t j = 0; j < k; ++j) {
            int s; cin >> s;
            sw[i].emplace_back(s - 1);
        }
    }

    vector<int> p(M);
    for (size_t i = 0; i < M; ++i) {
        cin >> p[i];
    }

    int res = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {
            int cnt = 0;
            for (auto &si : sw[i]) {
                if (bit & (1 << si)) {
                    cnt++;
                }
            }
            if (cnt % 2 != p[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ++res;
    }

    cout << res << "\n";

    return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    vector<ll> dp(N, 1LL << 60);
    dp[0] = 0;
    for(int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            if (i + j < N) {
                dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]));
            }
        }
    }
    cout << dp[N - 1] << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;


struct Problem {

	bool prime(UL n) {
		for (UL i = 2; i * i <= n; i++) {
			if (n%i == 0) return false;
		}
		return true;
	}

	void Solve() {
		UL x; cin >> x;
		while (!prime(x)) { x++; }
		cout << x << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,ans=0,ra=0;
  cin>>a>>b>>c>>d>>e;
  if(a<0){
    while(1){
      ans+=c;
      a++;
      if(a==0) break;
    }
  }
  if(a==0){
    ans+=d;
  }
  while(1){
    if(b==a) break;
    a++;
    ans+=e;
  }
  cout<<ans<<endl;
    
  return 0;
}



Measured memory_bytes: 3096
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Measured memory_bytes: 7716
#include <iostream>
#include <set>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<bool> Vb;
typedef vector<int> Vi;

vector<vector<int>> g;
Vb visiting, done;
int n, m;

void init()
{
	cin >> n >> m;
	g.resize(n);

	visiting.resize(n, false);
	done.resize(n, false);

	REP(i, m)
	{
		int a, b; cin >> a >> b; --a; --b;
		g[a].push_back(b);
	}
}

bool check(int v, const Vi& path)
{
	set<int> vertices(ALL(path));

	for (int v_inPath : path)
	{
		int cnt = 0;
		for (int u : g[v_inPath])
			if (vertices.count(u))
				++cnt;

		if (cnt > 1)
			return false;
	}
	return true;
}

vector<int> dfs(int v, Vi& path)
{
	Vi ret;

	if (g[v].empty())
		return ret;

	if (visiting[v])
	{
		auto it = path.begin();
		while (*it != v)
			++it;

		Vi loopPath(it, path.end());

		if (check(v, loopPath))
			return loopPath;
		else
			return ret;
	}

	path.push_back(v);
	visiting[v] = true;

	for (int adj : g[v])
	{
		ret = dfs(adj, path);
		if (!ret.empty())
			return ret;
	}

	path.pop_back();
	visiting[v] = false;
	done[v] = true;
	return ret;
}


int main()
{
	init();
	Vi v;

	REP(i, n)
	{
		if (done[i])
			continue;

		v.clear();
		Vi res = dfs(i, v);
		if (!res.empty())
		{
			cout << res.size() << endl;
			REP(j, res.size())
				cout << res[j] + 1 << endl;
			return 0;
		}
	}

	cout << -1 << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
typedef long long ll;

ll n, h;
ll a[100005];
ll b[100005];

ll a_max = 0;

ll ans;

int cmp(const void *x, const void *y);

int main()
{
    scanf("%lld %lld", &n, &h);
    for (int i = 0; i < n; i++) {
        scanf("%lld %lld", &a[i], &b[i]);

        a_max = max(a_max, a[i]);
    }

    qsort(b, n, sizeof(ll), cmp);
    int b_i = 0;

    while (h > 0) {
        if (b_i < n && b[b_i] > a_max) {
            h -= b[b_i];
            b_i++;
            ans++;
        }
        else {
            ans += h / a_max;
            h %= a_max;

            if (h) {
                ans++;
                h = 0;
            }
        }
    }

    printf("%lld\n", ans);

    return 0;
}
        
int cmp(const void *x, const void *y)
{
    if (*(ll *)x > *(ll *)y) {
        return -1;
    } else if (*(ll *)x == *(ll *)y) {
        return 0;
    } else {
        return 1;
    }
}


Measured memory_bytes: 2556
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = tuple(input())
    r = 0
    s_len = len(s)
    for i1 in range(s_len):
        for i2 in range(1, s_len - i1 + 1):
            if all([c in ('A', 'T', 'C', 'G') for c in s[i1:i1+i2]]):
                r = max(r, i2)
    print(r)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  queue<int>A[N];
  rep(i,N) rep(j,N-1) {
    int tmpa; cin >> tmpa; tmpa--;
    A[i].push(tmpa);
  }
  int count = 0;
  bool flg = true;
  int c[N]={};
  while (flg) {
    flg = false;
    rep(i,N) {
      if (A[i].empty()) continue;
      int op = A[i].front();
      if (A[op].front()==i) {
        flg = true; count++;
        int tmpc = max(c[i], c[op]);
        c[i] = tmpc+1; A[i].pop();
        c[op] = tmpc+1; A[op].pop();
      }
    }
    if (!flg&&count!=N*(N-1)/2) { cout << -1 << endl; return 0; }
  }
  int result = 0; rep(i,N) result = max(result, c[i]);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4736
N = int( input() )
s = [ int(input()) for _ in range(N)]


sum = sum( s )
if sum % 10 == 0:
    tmp = 100
    isAppeared = False
    for si in s:
        if si % 10 != 0:
            tmp = min( tmp, si )
            isAppeared = True
    if isAppeared: sum -= tmp
    else: sum = 0
        
print( sum )

Measured memory_bytes: 3060
/**
 * File              : a.cpp
 * Author            : recurze
 * Date              : 21:53 18.01.2019
 * Last Modified Date: 21:53 18.01.2019
 */
#include <stdio.h>

void readInput();
void solve();
void printAns();

int main() {
    int t = 1;
    //scanf("%d", &t);

    for (int tc = 1; tc <= t; ++tc) {
        readInput();
        solve();
        printAns();
    }
}

const int N = 1010101;

int n = 0;
void readInput() {
    scanf("%d", &n);
}

bool ans = 0;
void solve() {
    ans = (n == 5 || n == 3 || n == 7);
}

void printAns() {
    if (ans) puts("YES");
    else puts("NO");
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
const int MaxN = 100;
using namespace std;
char s[MaxN + 5];
int main() 
{
	while(~scanf("%s", s + 1)) {
		int len = strlen(s + 1);
		for (int i = 1; i <= len - 8; i++) printf("%c", s[i]);
		printf("\n");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

ll N, M;
ll H[200005];
ll b[100005];

int main()
{
    cin >> N >> M;
    for(int i = 0;i < N;i++)
    {
        cin >> H[i];
    }
    for(int i = 0;i < M;i++)
    {
        ll A, B;
        cin >> A >> B;
        A--;
        B--;
        if(H[A] < H[B])
        {
            b[A] = 1;
        }
        else if(H[B] < H[A])
        {
            b[B] = 1;
        }
        else
        {
            b[A] = 1;
            b[B] = 1;
        }
    }
    ll ans = 0;
    for(int i = 0;i < N;i++)
    {
        if(b[i] == 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;

template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; }
template <class C> C& maxi(C& a, C b) { if (a < b) a = b; return a; }

using namespace std;

template <typename T> void read(T& x) { x.read(); }
template <typename T> void read(vector<T>& v) { for (T& x: v) read(x); }
template <typename X, typename Y> void read(pair<X, Y>& p) { read(p.first); read(p.second); }
template <> void read(int& x) { scanf("%d", &x); }
template <> void read(unsigned int& x) { scanf("%u", &x); }
template <> void read(long long& x) { scanf("%lld", &x); }
template <> void read(unsigned long long& x) { scanf("%llu", &x); }
template <typename T> void read(int& N, vector<T>& v) { read(N); v.resize(N); read(v); }

int main(int argc, const char* argv[]) {
	int N; VI A;
	read(N, A);

	int l = 0;
	int r = 1;
	ll ret = 0;
	int s = A[0];
	while (l < A.size()) {
		while (r < A.size() && s + A[r] == (s ^ A[r])) {
			s ^= A[r];
			r++;
		}
		ret += (r - l);
		s ^= A[l];
		l++;
	}
	printf("%lld\n", ret);
	return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


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

    // 尺取法
    V<int> nums;
    int cnt = 1;
    if(s[0] == '0') nums.push_back(0);
    for(int i = 0; i < n; i++){
        if(s[i] == s[i + 1]) cnt++;
        else{
            nums.push_back(cnt);
            cnt = 1;
        }
    }
    if(s[n - 1] == '0') nums.push_back(0);

    int m = nums.size();
    int left = 0, right = 0;
    int ans = 0, tmp = 0;
    for(int i = 0; i < m; i+=2){
        int nleft = i;
        int nright = min(i + 2 * k + 1, m);
        while(nleft > left){
            tmp -= nums[left];
            left++;
        }
        while(nright > right){
            tmp += nums[right];
            right++;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;


    return 0;
}


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

int main() {
    int n, x, ans = 0;
    cin >> n >> x;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a+n);
    for(int i = 0; i < n; ++i) {
        x -= a[i];
        if(x < 0) break;
        ans++;
    }
    if(x > 0) ans += x/a[0];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
	int a[3];
	int x=0,y=0;
	for(int i=0;i<3;i++){
		scanf("%d",&a[i]);
		if(a[i]==5)x++;
		if(a[i]==7)y++;
	}
	if(x==2&&y==1)
		printf("YES\n");
	else 
		printf("NO\n");
		return 0;
} 

Measured memory_bytes: 128
a = (raw_input())
b = (raw_input())
c = (raw_input())
t = 'a'
while True:
	if t == 'a':
		if len(a) == 0:
			print("A")
			exit()
		t = a[0]
		a = a[1:]
	if t == 'b':
		if len(b) == 0:
			print("B")
			exit()
		t = b[0]
		b = b[1:]
	if t == 'c':
		if len(c) == 0:
			print("C")
			exit()
		t = c[0]
		c = c[1:]

Measured memory_bytes: 2692
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<stack>
using namespace std;
const int N = 1e5;


int main()
{
	map<string,int> mp;
    int n;
    cin>>n;
    mp["AC"]=0;
    mp["WA"]=0;
    mp["TLE"]=0;
    mp["RE"]=0;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;

    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;




    int ab;
    cin>>ab;
} 

Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
  att = min(a[i], b[i])
  a[i] -= att
  b[i] -= att
  ans += att
  att = min(a[i + 1], b[i])
  a[i + 1] -= att
  b[i] -= att
  ans += att
print(ans)

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

int main()
{
  ll n; cin >> n;
  ll sum = 0;
  for (int i=1; i<=n; i++) {
    if (i%3 != 0 && i%5 != 0) sum += i;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
int main(){
    int N;
    std::cin >> N;
    std::vector<std::vector<long long>> A(N, std::vector<long long> (N));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) std::cin >> A[i][j];
    }
    std::vector<std::vector<int>> flag(N, std::vector<int> (N, 0));
    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                if(A[i][j] > A[i][k] + A[k][j]){
                    std::cout << -1 << std::endl;
                    return 0;
                }
                if(A[i][j] == A[i][k] + A[k][j] && i != k && k != j){
                    flag[i][j] = 1;
                }
            }
        }
    }
    long long ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(flag[i][j] == 0) ans += A[i][j];
        }
    }
    std::cout << ans / 2 << std::endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int x[17][17];
int y[17][17];
int z[17];

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

    int a[17];
    for(int i = 1;i <= N;i ++)
    {
        cin>>a[i];
        for(int j = 0;j < a[i]; j++)
        {
            cin>>x[i][j]>>y[i][j];
        }
    }
    int ans = 0;
    int maxn = pow(2,N);
    for(int con = 0;con < maxn;con ++)
    {
        int tmp = con;
        int i = 1;
        bool conflict = false;
        int ret =0;
        for(int i = 1;i <=N;i ++)
            z[i] = -1;
        while(i<=N)
        {
            if(tmp&1)//x[i][...] is true
            {
                ret ++;
                if(z[i] == -1 || z[i] == 1)
                {
                    z[i] = 1;
                }else
                {
                    conflict = true;
                    break;
                }
                for(int j = 0;j < a[i];j ++)
                {
                    if(z[x[i][j]] == -1 || y[i][j] == z[x[i][j]])
                    {
                        z[x[i][j]] = y[i][j];
                    }else
                    {
                        conflict = true;
                        break;
                    }
                }
            }
            if(conflict)
            {
                ret = 0;
               break;
            }
            i ++;
            tmp = tmp >> 1;
        }
        tmp = con;
        //cout<<tmp<<":";
        for(int k = 1;k <= N;k ++)
        {
            //cout<<"("<<z[k]<<","<<(tmp&1)<<")";
            if(z[k] == 1-(tmp&1))
            {
             //   cout<<"*";
                conflict = true;
                break;
            }
            tmp = tmp >> 1;
        }
        if(!conflict)
        {
         //   cout<<"√";
            ans = max(ans,ret);
        }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C,D;
  str N;
  cin>>A>>B;
  if((A+B)%2==1)cout<<(A+B)/2+1<<endl;
  else cout<<(A+B)/2<<endl;
}


Measured memory_bytes: 256
import math
L, R = map(int, input().split())

if (R - L) >= 2019:
    print(0)
else:
    ans = math.inf
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, ((i%2019)*(j%2019))%2019)
    print(ans)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
typedef complex<double> P;
double dot(P const& a, P const& b) {
  return real(conj(a)*b);
}
double cross(P const& a, P const& b) {
  return imag(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a, c -= a;
  if(cross(b, c) > 0) return +1; // counter clockwise
  if(cross(b, c) < 0) return -1;  // clockwise
  if(dot(b, c) < 0) return +2;    // c-a-b
  if(norm(b) < norm(c)) return -2;  // a-b-c
  return 0; // on segment
}
int main () {
  P ps[4];
  while(1) {
    rep(i, 4) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    if(cin.eof()) break;
    int sum = 0;
    rep(i, 3) {
      sum += ccw(ps[i], ps[(i+1)%3], ps[3]);
    }
    if(sum == 3 || sum == -3) cout << "YES\n";
    else cout << "NO\n";
  }
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
 using namespace std;
  int n,i,k,minn;
  int a[100005];
  int main()
  {
   cin>>n>>k;
   for(i=0;i<n;++i) cin>>a[i];
   sort(a,a+n);
   minn=a[k-1]-a[0];
   for(i=0;i<n-k+1;++i) minn=min(minn,a[i+k-1]-a[i]);
   cout<<minn<<endl;
   return 0;
  }

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

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int M;
	cin >> M;
	ll N = 0,ans = 0,cnt=0;
	vector<ll> d(M),c(M);
	rep(i,M){
		cin >> d[i] >> c[i];
		ans += c[i];
		N += d[i]*c[i];
	}
	while(N>=10){
		cnt += N/10;
		N = N/10 + N%10;
	}	
	cout << ans - 1 + cnt << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if(c > a && b > c) cout << "Yes" << endl;
    else if(c < a && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
	int n,k;
	string s;
	cin>>n>>k>>s;
	vector<pair<int,int> >a;
	int c=0;
	a.push_back(make_pair(s[0]-48,1));
	for(int i=1;i<n;i++)
	{
		if(s[i]==s[i-1])a[c].second++;
		else c++,a.push_back(make_pair(s[i]-48,1));
	}
	int l,r;
	for(int i=0;i<a.size();i++)
	{
		if(a[i].first==1)
		{
			l=i;
			r=i+k*2;
			break;
		}
		else if(i==a.size()-1)
		{
			cout<<n<<endl;
			return 0;
		}
	}
	//cout<<l<<" "<<r<<endl;
	int ss=0;
	for(int i=l;i<=min(r,(int)a.size()-1);i++)ss+=a[i].second;
	int m=ss;
	for(;r<a.size();)
	{
		l+=2;
		r+=2;
		if(r==a.size())
		{
			r=a.size()-1;
			ss+=a[r].second-a[l-2].second-a[l-1].second;
		}
		else
		{
			ss+=a[r].second+a[r-1].second-a[l-2].second-a[l-1].second;
		}
		m=max(m,ss);
		//cout<<l<<" "<<r<<" "<<ss<<endl;
	}
	if(a[0].first==0)
	{
		l=-1;
		r=l+k*2;
		ss=0;
		for(int i=0;i<=min(r,(int)a.size()-1);i++)ss+=a[i].second;
	}
	m=max(m,ss);
	cout<<m<<endl;
	//for(int i=0;i<a.size();i++)cout<<a[i].first<<" "<<a[i].second<<endl;
	return 0;
}

Measured memory_bytes: 1528
import java.io.*;
import java.util.*;

public class Main {
	private static BufferedReader br = null;
	
	public static void main(String[] args) {
		int k = Integer.parseInt(read(1)[0]);
		
		System.out.println(((k + 1) / 2) * (k / 2));
		
		close();
	}
	
	private static String[] read(int len) {
		List<String> strList = new ArrayList<>();
		
		try {
			if (br == null) {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			
			for (int i = 0; i < len; i++) {
				strList.add(br.readLine());
			}
		} catch (IOException e) {
		}
		
		return strList.toArray(new String[0]);
	}
	
	private static void close() {
		try {
			if (br != null) {
				br.close();
			}
		} catch (IOException e) {
		}
	}
}


Measured memory_bytes: 23124
module Point = struct

  type t = { x : float; y : float }

  let make x y = { x; y }

  let equal_p a b = abs_float (a.x -. b.x) < 1e-10 && abs_float (a.y -. b.y) < 1e-10

  let sum a b = { x = a.x +. b.x; y = a.y +. b.y }

  let diff a b = { x = a.x -. b.x; y = a.y -. b.y }

  let multi p k = { x = p.x *. k; y = p.y *. k }

  let div p k = { x = p.x /. k; y = p.y /. k }

  let norm p = p.x *. p.x +. p.y *. p.y

  let abs p = norm p |> sqrt

  let dot a b = a.x *. b.x +. a.y *. b.y

  let cross a b = a.x *. b.y -. a.y *. b.x

  let project p1 p2 p =
    let base = diff p2 p1 in
    dot (diff p p1) base /. norm base |> multi base |> sum p1

  let reflect p1 p2 p = multi (diff (project p1 p2 p) p) 2. |> sum p

  let orthogonal_p (p0, p1) (p2, p3) = dot (diff p0 p1) (diff p2 p3) = 0.

  let parallel_p (p0, p1) (p2, p3) = cross (diff p0 p1) (diff p2 p3) = 0.

  let ccw p0 p1 p2 =
    let eps = 1e-10 in
    let a = diff p1 p0 in
    let b = diff p2 p0 in
    let c = cross a b in
    if c > eps then 1 (* COUNTER_CLOCKWISE *)
    else if c < (-. eps) then (-1) (* CLOCKWISE *)
    else if dot a b < (-. eps) then 2 (* ONLINE_BACK *)
    else if norm a < norm b then (-2) (* ONLINE_FRONT *)
    else 0 (* ON_SEGMENT *)

  let intersect_p (p0, p1) (p2, p3) =
    ccw p0 p1 p2 * ccw p0 p1 p3 <= 0 && ccw p2 p3 p0 * ccw p2 p3 p1 <= 0

  let cross_point (p0, p1) (p2, p3) =
    let base = diff p3 p2 in
    let d1 = diff p0 p2 |> cross base |> abs_float in
    let d2 = diff p1 p2 |> cross base |> abs_float in
    d1 /. (d1 +. d2) |> multi (diff p1 p0) |> sum p0

end

module IO = struct

  (* @since 4.04.0 *)
  let split_on_char sep s =
    let open String in
    let r = ref [] in
    let j = ref (length s) in
    for i = length s - 1 downto 0 do
      if get s i = sep then begin
        r := sub s (i + 1) (!j - i - 1) :: !r;
        j := i
      end
    done;
    sub s 0 !j :: !r

  let read_fs () = read_line () |> split_on_char ' ' |> List.map float_of_string

end

open Point

let () =
  let q = read_int () in
  for _ = 0 to q - 1 do
    match IO.read_fs () with
    | x0 :: y0 :: x1 :: y1 :: x2 :: y2 :: x3 :: y3 :: _ ->
      let s = (make x0 y0, make x1 y1) in
      let t = (make x2 y2, make x3 y3) in
      let p = cross_point s t in
      Printf.printf "%.10f %.10f\n" p.x p.y
    | _ -> assert false
  done

Measured memory_bytes: 3916
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int test[123][123], uiop[123][123];
signed main() {
	int n, m; char s, t; cin >> n >> m;
	for (int h = 0; h < n; h++) {
		for (int i = 0; i < n; i++) {
			cin >> s; test[h][i] = s;
		}
	}
	for (int h = 0; h < m; h++) {
		for (int i = 0; i < m; i++) {
			cin >> t; uiop[h][i] = t;
		}
	}
	for (int h = 0; h < n - m + 1; h++) {
		for (int i = 0; i < n - m + 1; i++) {
			int a = 0;
			for (int j = h; j < h + m; j++) {
				for (int k = i; k < i + m; k++) {
					if (test[j][k] != uiop[j - h][k - i]) {
						a = 1;
					}
				}
			}
			if (a == 0) {
				cout << "Yes" << endl; return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen ("input.txt", "r", stdin);
  freopen ("output.txt", "w", stdout);
#endif 
  long long n, k;
  cin >> n >> k;
  long long t = n / k;
  long long ans = min(abs(n - t * k), abs(n - (t + 1LL) * k));
  cout << ans;
}

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

int main(int argc, char *argv[]){
  int N;
  cin>>N;
  vector<int> a(N),aabs(N);
  int minus=0;
  int plus=0;
  int zero=0;
  int total=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    aabs[i]=abs(a[i]);
    total+=aabs[i];
    if(a[i]==0) zero++;
    if(a[i]<0) minus++;
  }
  
  plus=N-minus-zero;
  sort(a.rbegin(),a.rend());
  sort(aabs.begin(),aabs.end());
  deque<int> dq;
  for(int i=0;i<N;i++){
    dq.push_back(a[i]);
  }
  if(plus==0||minus==0){
    cout<<total-aabs[0]*2<<endl;
  }else{
    cout<<total<<endl;
  }

  if(minus==0&&zero>0) minus+=zero;
  else plus+=zero;

  while(dq.size()>2){
    int dai=dq.front(),syo=dq.back();
    dq.pop_back(); dq.pop_front();
    if(dai<0) minus--; else plus--;
    if(syo<0) minus--; else plus++;
    int tmp=dai-syo;
    if(minus<plus){
      dq.push_back(-tmp);
      cout<<syo<<" "<<dai<<endl;
      minus++;
    }else{
      dq.push_front(tmp);
      cout<<dai<<" "<<syo<<endl;
      plus++;
    }
  }
  cout<<dq.front()<<" "<<dq.back()<<endl;

  return 0;
}



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

bool isp(string s){
    for(int i=0;i<s.size()-i-1;i++){
        if(s[i]!=s[s.size()-i-1])return false;
    }
    return true;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin>>s;
    if(isp(s)&&isp(s.substr(0,s.size()/2))&&isp(s.substr(s.size()/2+1,s.size()/2)))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;

class main
{
    static void Main(string[] args)
    {
        ArrayList list = new ArrayList();
        ArrayList lista = new ArrayList();
        string s;
        while ((s = Console.ReadLine()) != null)
            if (s == "0")
            {
                lista.Add(list[list.Count - 1]);
                list.RemoveAt(list.Count - 1);
            }
            else
            {
                list.Add(s);
            }
        for (int i = 0; i < lista.Count; ++i)
            Console.WriteLine(lista[i]);
    }
}

Measured memory_bytes: 5288
#include<stdio.h>
int main(void){
  int i,k=0;
 char a[4];
  scanf("%s",a);
  for(i=1;i<4;i++){
     if(a[i-1]==a[i])k++; 
}  
  if(k==0) printf("Good");
  else printf("Bad");
  return 0;
}

Measured memory_bytes: 128
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 2e+5+5;
int BIG = 1e+18+3;
int mod = 1e+9+7;

vector<int>gr[N];
bool vis[N];

int memoized[N];

int ans = 0;


int dp(int src)
{

    if (memoized[src]!=-1)
        return memoized[src];

    memoized[src] = 0;    

    for (auto it : gr[src])
        memoized[src] = max(dp(it)+1,memoized[src]);
    
    ans = max(ans,memoized[src]);
    return memoized[src];

}

signed main()
{
    IOS;
    
    int n,m; cin>>n>>m;

    memset(vis,false,sizeof(vis));

    repa(i,0,N-1)
        memoized[i] = -1;

    repa(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        gr[u].pb(v);
    }   

    repa(i,1,n)
        int buffer = dp(i);

    cout<< ans <<endl;
}

Measured memory_bytes: 11264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k = Integer.parseInt(sc.next());
		String s = sc.next();
		
		if(s.length() <= k) {
			System.out.println(s);
		} else {
			System.out.println(s.substring(0, k) + "...");
		}
	}

}


Measured memory_bytes: 38592
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 1; i < n; i++)
using namespace std;
static const int MAX = 151;

class Rect {
public:
  int h, w;
  Rect(int _h, int _w) {
    h = _h;
    w = _w;
  }

  int length() { return h * h + w * w; }

  bool operator<(Rect r) {
    return make_pair(length(), h) < make_pair(r.length(), r.h);
  }
};

int main() {
  vector<Rect> r;
  int h, w;
  REP(x, MAX) {
    REP(y, x) { r.push_back(Rect(y, x)); }
  }
  sort(r.begin(), r.end());

  while (cin >> h >> w, h) {
    for (int i = 0; i < r.size(); i++) {
      if (r[i].h == h && r[i].w == w)
        cout << r[i + 1].h << " " << r[i + 1].w << endl;
    }
  }
}


Measured memory_bytes: 3180
#include <iostream>

using namespace std;

int recursive(int n, int s, int lower)
{
	if(s < 0 || lower > 9)
		return 0;

	if(n == 1)
	{
		if(s < lower || 9 < s)
			return 0;

		return 1;
	}

	int count = 0;
	for(int i = lower; i <= 9; i++)
		count += recursive(n - 1, s - i, i + 1);
	
	return count;
}

int main()
{
	int n, s;
	while(cin >> n >> s)
	{
		if(n == 0 && s == 0)
			break;

		cout << recursive(n, s, 0) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n;
  cin>>n;
  int cnt=0;
  pair<int,int>P[n];
  rep(i,n) {
    int a,b;
    cin>>a>>b;
    P[i].F=a;
    P[i].S=b;
  }
  for(int i=n-1;i>=0;i--) {
    int a=P[i].F;
    int b=P[i].S;
    if((a+cnt)%b==0) continue;
    cnt+=b-(a+cnt)%b;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 2300
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

int main(int argc, char *argv[]) {
#ifdef VLAD_LOCAL
    ifstream in("in.txt");
#else
    istream &in = cin;
#endif
    int n, k;
    in >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        in >> a[i];
    int done = 0;
    bool lessN = true;
    vector<int> plus(n);
    while (done < k && lessN) {
        std::fill_n(plus.data(), n, 0);
        for (int i = 0; i < n; i++) {
            int x = max(i - a[i], 0);
            plus[x]++;
            int y = i + a[i] + 1;
            if (y < n)
                plus[y]--;
        }
        int cur = 0;
        lessN = false;
        for (int i = 0; i < n; i++) {
            cur += plus[i];
            a[i] = cur;
            if (a[i] < n)
                lessN = true;
        }
        done++;
    }
    for (int i = 0; i < n; i++) {
        printf("%d ", a[i]);
    }
	return 0;
}


Measured memory_bytes: 4804
#include <stdio.h>

int main()
{
    int n, m, k;
    int i,j;

    scanf("%d%d%d", &n, &m, &k);

    for (i = 0; i <= n; i++)
    {
        //printf("i:%d\n",i);
        for (j = 0; j <= m; j++)
        {
            //printf("j:%d\n",j);
            if (n * j + m * i - 2 * i * j == k)
            {
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    return 0;
}

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

using namespace std;

int main(void) {
    int x, n;
    int sm = -1;
    int la = -1;
    //vector<int> p;
    vector<vector<int>> ab(2, vector<int>(101, 101));
    cin >> x >> n;
    if(n == 0){
        for(int i = 0; i < n; i++){
            int tmp;
            cin >> tmp;
        }
        cout << x << endl;
    }
    else{
        // cout << "aa" << endl;
        // for(int i = 0; i <= 100; i++){
        //     cout << "bb" << endl;
        //     ab[i][0] = 101;
        //     ab[i][1] = 101;
        // }
        // cout << "ab[0][0] = " << ab[0][0] << " ab[0][1] = " << ab[0][1] << " ab[1][0] = " << ab[1][0] << " ab[1][1] = " << ab[1][1] << endl;
        // cout << "x = " << x << " n = " << n << endl;
        for(int i = 1; i <= n; i++){
            // cout << "cc" << endl;
            int tmp;
            cin >> tmp;
            //p[i] = tmp;
            // cout << "dd" << endl;
            // cout << "tmp = " << tmp << " x - tmp = " << x - tmp << endl;
            if(x - tmp > 0){
                // cout << "tmp = " << tmp << " ab[0][abs(x - tmp)] = " << ab[0][abs(x - tmp)] << endl;
                // cout << "tmp = " << tmp << " ab[1][abs(x - tmp)] = " << ab[1][abs(x - tmp)] << endl;
                ab[0][abs(x - tmp)] = 0;
            }
            else if(x - tmp < 0){
                // cout << "tmp = " << tmp << " ab[0][abs(x - tmp)] = " << ab[0][abs(x - tmp)] << endl;
                // cout << "tmp = " << tmp << " ab[1][abs(x - tmp)] = " << ab[1][abs(x - tmp)] << endl;
                ab[1][abs(x - tmp)] = 0;
            }
            else{
                // cout << "tmp = " << tmp << " ab[0][abs(x - tmp)] = " << ab[0][abs(x - tmp)] << endl;
                // cout << "tmp = " << tmp << " ab[1][abs(x - tmp)] = " << ab[1][abs(x - tmp)] << endl;
                ab[0][abs(x - tmp)] = 0;
                ab[1][abs(x - tmp)] = 0;
            }
        }

        for(int i = 0; i <=100; i++){
            if(ab[0][i] != 0){
                sm = i;
                break;
            }
        }
        for(int i = 0; i <= 100; i++){
            if(ab[1][i] != 0){
                la = i;
                break;
            }
        }

        if(sm <= la){
            cout << x - sm << endl;
        }
        else{
            cout << x + la << endl;
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
char c;
cin >> c;
if(c=='A') cout<<'T'<<endl;
else if ( c=='G')cout<<'C'<<endl;
 else if( c=='T')cout<<'A'<<endl;
else cout<<'G'<<endl;
}

Measured memory_bytes: 3476
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;

    ll K; cin >> K;
    ll A[N], B[M]; F0R(i, N) cin >> A[i];
    F0R(i, M) cin >> B[i];

    ll as = 0; F0R(i, N) as += A[i];
    ll bs = 0;
    int bp = 0;
    int ans = 0;
    F0Rd(i, N+1) {
        if (i < N) as -= A[i];
        if (as <= K) {
            while (bp < M && as + bs + B[bp] <= K) {
                 bs += B[bp]; bp++;
            }
            ckmax(ans, i + bp);
        }
//        cout << as << " " << bs << " " << bp << nl;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;

    vector<pair<pair<string,int>,int>>data(n);

    for(int i=0;i<n;i++) {
        string a;
        int b;

        cin >>a>>b;
        data[i] = make_pair(make_pair(a,-b),i+1);
    }

    sort(data.begin(),data.end());

    for(int i=0;i<n;i++) {
        cout <<data[i].second <<endl;
    }
}


Measured memory_bytes: 256
package main

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

func main() {
	A := nextInt()
	B := nextInt()
	C := nextInt()

	fmt.Println(C - min(A-B, C))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

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

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
package main

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

func main() {
	ts := getIntSlice(3)

	fmt.Println(sum(ts...) - max(ts...))
}

func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include<stdio.h>
int a[100010];
int main(){
	int n,x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		a[x]=i;
	}
	for(int i=1;i<n;i++)
		printf("%d ",a[i]);
	printf("%d\n",a[n]);
	return 0;
} 

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

#define INF 1000000000

int altura[100010],dp[100010];

int solve(int n,int k){
  if(dp[n]!=-1) return dp[n];
  int cont=INF;
  for(int i=1;i<=k;i++){
    if(n-i>=1) cont=min(cont,abs(altura[n]-altura[n-i])+solve(n-i,k));
  }
  return dp[n]=cont;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp,-1,sizeof(dp));
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++) cin>>altura[i];
  dp[1]=0;
  dp[2]=abs(altura[2]-altura[1]);
  cout<<solve(n,k)<<"\n";
  return 0;
}

Measured memory_bytes: 7296
//Getting Difference

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,k;cin>>n>>k;
    vecrep(n,a,int);
    if(*max_element(range(a))<k){
        cout<<"IMPOSSIBLE"<<nnn;
        return 0;
    }
    int c = inf;
    sort(range(a),greater<int>());
    rep(i,0,n-1){
        if(a[i]==a[i+1])continue;
        c=min(c,a[i]-a[i+1]);
    }
    rep(i,0,n){
        if(abs(k-a[i])%c==0||k==a[i]){
            cout<<"POSSIBLE"<<nnn;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<nnn;
    return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;



int main() {
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    ll sum = 0;
    rep (i,n) cin >> a[i];
    rep (i,n) {
        cin >> b[i];
        sum += b[i];
    }
    rep (i,n-1) cin >> c[i];
    rep (i,n){
        if(a[i+1]-a[i]==1){
            sum += c[a[i]-1];
        }
    }
    cout << sum << endl;

}



Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

b = [0] * N
for i in range(N-1, -1, -1):
    s = 0
    k = i + (i+1)
    while k < N:
        s += b[k]
        k += (i+1)

    if s % 2 == a[i]:
        b[i] = 0
    else:
        b[i] = 1

print(b.count(1))
bv = []
for i in range(N):
    if b[i] == 1:
        bv.append(i+1)
if bv:
    print(' '.join(map(str, bv)))


Measured memory_bytes: 79848
raw = input()
nums = [] * 4
for i in range(0, 4):
    nums.append(int(raw[i]))

# op = ['+', '-']
# ops = [op] * 3
# print(ops)

for i in range(0, 8):
    sum = nums[0]
    result = str(nums[0])
    for op in range(0,3):
        if (i >> op) & 1:
            sum += nums[op + 1]
            result += '+'
        else:
            sum -= nums[op + 1]
            result += '-'
        result += str(nums[op + 1])

    if sum == 7:
        result += '=7'
        print(result)
        break


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int w,a,b,x=0;
	cin>>w>>a>>b;
	if(a>b)
	{
		x=a-(b+w);
		cout<<x;
		
	}
	else{
		if(a+w>=b)
		{
			cout<<"0";
		}
		else
		{
			x=b-(a+w);
			cout<<x;
		}
	}
}

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

unsigned long long dp[102][22];

int main(void){
	int n;
	cin>>n;
	int t[n];

	for(int i=0;i<n;i++){
		cin>>t[i];
	}
	memset(dp,0,sizeof(dp));
	dp[1][t[0]] = 1;

	for(int i=1;i<n-1;i++){
		for(int j=0;j<=20;j++){
			if(dp[i][j] > 0){
				int plus = j + t[i];
				int minus = j - t[i];

				if(plus>=0 && plus<=20){
					dp[i+1][plus] += dp[i][j];
				}
				if(minus>=0 && minus<=20){
					dp[i+1][minus] += dp[i][j];
				}
			}
		}
	}
	cout<<dp[n-1][t[n-1]]<<endl;

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long N,h[100001];
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>h[i];
	}
	h[0]=INT_MAX;
	long long DP[100001];
	DP[1]=0;
	DP[0]=0;
	for(int i=2;i<=N;i++)
	{
		DP[i]=min(DP[i-1]+abs(h[i]-h[i-1]),DP[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<DP[N]<<endl;
}

Measured memory_bytes: 1792