akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.range;
import std.math;

void main() {
    while (true) {
        int n, m;
        readf("%d %d\n", &n, &m);
        if (!(n||m)) break;

        int[] taro = new int[n];
        int[] hanako = new int[m];

        foreach (i; 0..n) {
            taro[i] = readln.chomp.to!int;
        }

        foreach (i; 0..m) {
            hanako[i] = readln.chomp.to!int;
        }

        if ((taro.reduce!("a + b") - hanako.reduce!("a + b")) % 2 != 0) {
            (-1).writeln;
            continue;
        }

        int diff = (taro.reduce!("a + b") - hanako.reduce!("a + b")) / 2;

        int[][] answers;

        foreach (t; taro) {
            foreach (h; hanako) {
                if (t - h == diff) {
                    answers ~= [t, h];
                }
            }
        }

        if (answers.empty) {
            (-1).writeln;
            continue;
        }

        int[] ans = answers[0];
        foreach (a; answers) {
            if (ans[0] + ans[1] > a[0] + a[1]) {
                ans = a;
            }
        }

        writefln("%d %d", ans[0], ans[1]);
    }
}

Measured memory_bytes: 1256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/16/2018
 
 10:55-11:15 analysis
 
 
 
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N,M,S,T;
//LL A[MAX_N];
vector<LL> W[2][MAX_N];
vector<int> E[MAX_N];

const long long Inf=1e17;
const int MAX_V=MAX_N;
long long D[2][MAX_V];
void dijkstra(int V, int st, int cur) {
  for(int i=0; i<V; ++i) D[cur][i]=Inf;
  set<pair<long long,int>> Q; Q.emplace(0,st); D[cur][st]=0;
  while(Q.size()>0) {
    auto it=Q.begin(); Q.erase(it);
    int u; long long d;
    tie(d,u)=*it;
    REP(i,SZ(E[u])) {
      int v=E[u][i];
      LL w=W[cur][u][i];
      if(d+w<D[cur][v]) {
        auto it2=Q.find({D[cur][v],v});
        if(it2!=Q.end()) Q.erase(it2);
        D[cur][v]=d+w; Q.emplace(d+w,v);
      }
    }
  }
//  REP(i,V) dump2(i,D[cur][i]);
}

void solve() {
  dijkstra(N,S,0),dijkstra(N,T,1);
  priority_queue<pair<LL,int>, vector<pair<LL,int>>, greater<pair<LL,int>>> Q;
  REP(u,N) {
    LL x=D[0][u]+D[1][u];
    Q.emplace(x,u);
  }
  REP(u,N) {
    while(SZ(Q)&&Q.top().second<u) Q.pop();
    assert(SZ(Q));
//    dump3(u,Q.top().first,Q.top().second);
    LL res=1e15-Q.top().first;
    cout<<res<<endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>M>>S>>T;
  --S,--T;
  REP(i,M) {
    int u,v; LL a,b; cin>>u>>v>>a>>b;
    --u,--v;
    E[u].push_back(v),E[v].push_back(u);
    W[0][u].push_back(a),W[0][v].push_back(a);
    W[1][u].push_back(b),W[1][v].push_back(b);
  }
  solve();
  return 0;
}


Measured memory_bytes: 22548
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<tuple>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

const int MAX=510000;

int main()
{
    
    int n,x;
    cin>>n>>x;
    int count=1;
    int l[n];
    rep(i,n)
    {
        cin>>l[i];
    }

    int d=0;
    rep(i,n)
    {
        d+=l[i];
        if(d>x)
        {
            cout<<count<<endl;
            return 0;
        }
        else
        {
            count++;
        }
        
    }
    cout<<count<<endl;
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k, s = 0;
    cin >> n >> k;
    vi v(n);
    FOR(i,0,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    for(int i = n-1; i >= n-k; i--){
        s += v[i];
    }
    cout << s;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007

using namespace std;
int main()
{
 	speed_up
    ll l,r;cin>>l>>r;
    ll out=MAX;
    for(ll i=l;i<r&&out;i++)
    {
    	for(ll j=i+1;j<=r&&out;j++)
    	out=min(out,(i%2019*j%2019)%2019);
	}
	cout<<out;
   
	
	
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(n<1200)
	{
		printf("ABC");
	}
	else if(n<2800)
	{
		printf("ARC");
	}
	else
	{
		printf("AGC");
	}
	return 0;
} 

Measured memory_bytes: 256
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& v) {
    return is >> v.first >> v.second;
}

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& v) {
    for (T& i: v) is >> i;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << v.first << " " << v.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    int n = (int) v.size();
    for (int i = 0; i < n; ++i) os << v[i] << (i == n - 1 ? "" : " ");
    return os;
}

template <typename X>
void in(X& x) {
    std::cin >> x;
}

template <typename X, typename Y>
void in(X& x, Y& y) {
    in(x); in(y);
}

template <typename X, typename Y, typename Z>
void in(X& x, Y& y, Z& z) {
    in(x); in(y, z);
}

template <typename X, typename Y, typename Z, typename W>
void in(X& x, Y& y, Z& z, W& w) {
    in(x); in(y, z, w);
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>; //try not to use this
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    int h, w, a, b; in(h, w, a, b);
    std::string s;
    rep(i, a) s += '1';
    rep(i, w - a) s += '0';
    rep(i, b) out(s), nl;

    rep(i, a) s[i] = '0';
    rep(i, w - a) s[i + a] = '1';
    rep(i, h - b) out(s), nl;
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	multiset<int> st;
	for(int i=0; i<n; ++i){
		int x;
		cin >> x;
		auto it = st.upper_bound(-x);
		if(it==st.end()){
			st.insert(-x);
		}
		else{
			st.erase(it);
			st.insert(-x);
		}
	}
	cout << len(st) << endl;
}


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

using i64 = long long int;

int main(){
    int n;
    cin >> n;
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    i64 tmp = n*(v[0]%2), m = n-1, j = v[0];
    for(int i=1;i<n;++i){
        if(v[i] > v[i-1]){
            tmp ^= m * ((v[i]-j)%2);
            j = v[i];
        }
        m--;
    }

    if(tmp == 0)cout << "second" << endl;
    else cout << "first" << endl;

    return 0;
}


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

S = []

for i in range(N):
    S.append(int(input()))

L = [0] * N
R = [0] * N
l = 0
r = 0

for i in range(1,N):
    l = max(l, S[i-1])
    L[i] = l

for i in range(1,N):
    r = max(r, S[N-i])
    R[N-i-1] = r

for i in range(N):
    print(max(L[i], R[i]))
    


Measured memory_bytes: 15652
import java.util.Scanner;

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

		// 整数の入力
		int N = sc.nextInt();

		int A[] = new int[N+1];
		int B[] = new int[N];
		
		for(int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		
		long  num = 0;
		
		/*
		for(int i = 0; i < N; i++) {
			if(B[i] >= A[i]) {
				num += A[i];
				B[i] -= A[i];
			} else {
				num += B[i];
				B[i] = 0;
			}
			
			if(B[i] >= A[i+1]) {
				num += A[i+1];
				A[i+1] = 0;
			} else {
				num += B[i];
				A[i+1] -= B[i];
			}
		}
		*/
		
		for(int i = N; i >= 0; i--) {
			
			if(i != N) {
				if(A[i] <= B[i]) {
					num += A[i];
					A[i] = 0;
				} else {
					num += B[i];
					A[i] -= B[i];
				}
			}
			
			if(i == 0) break;
			
			if(A[i] <= B[i-1]) {
				num += A[i];
				B[i-1] -= A[i];
			} else {
				num += B[i-1];
				B[i-1] = 0;
			}
		}
		
		
		System.out.println(num);

        sc.close();
	}
}

Measured memory_bytes: 81116
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
 
int main(){
	char s[201],p[101],sl,pl,i,j,flag,ch;
	
	flag=0;
	
	cin >> s;
	cin >> p;
	
	sl=strlen(s);
	pl=strlen(p);
	
	for(i=0;i<sl;i++){
		s[sl+i]=s[i];
	}
	s[sl+sl]='\0';
	
	for(i=0;i<sl;i++){
		ch=0;
		for(j=0;j<pl;j++){
			if ( s[i+j]==p[j] ) {
				ch++;
			}
		}
		if ( ch == pl ) {
			flag=1;
		}
	}
	
	if (flag==1) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	
   return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MOD 1000000007
int N;
int a[100100];
map<int,int> m;
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		m[a[i]]++;
	}
	map<int,int>::iterator it;
	int ans = 0;
	for(it=m.begin();it!=m.end();it++){
		if(it->fi > it->sec)ans+=it->sec;
		else ans += it->sec-it->fi;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5120
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int h, w, n, cx, cy;
    cin >> h >> w >> n >> cy >> cx;
    string s, t;
    cin >> s >> t;
    int xmin = 1, xmax = w, ymin = 1, ymax = h;
    for (int i=n-1; i>=0; i--) {
        char c = t.at(i);
        if (c == 'L' && xmax < w) xmax++;
        else if (c == 'R' && xmin > 1) xmin--;
        else if (c == 'U' && ymax < h) ymax++;
        else if (c == 'D' && ymin > 1) ymin--;
        c = s.at(i);
        if (c == 'L') xmin++;
        else if (c == 'R') xmax--;
        else if (c == 'U') ymin++;
        else if (c == 'D') ymax--;
        if (xmin > xmax || ymin > ymax) break;
    }
    if (xmin <= cx && cx <= xmax && ymin <= cy && cy <= ymax) cout << "YES" << "\n";
    else cout << "NO" << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 920
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func main() {
	n := nextInt()
	a := make([]int, 0, n)
	b := make(map[int]int, n)
	c := make(map[int]int, n-1)

	for index := 0; index < n; index++ {
		a = append(a, nextInt())
	}
	for index := 1; index < n+1; index++ {
		b[index] = nextInt()
	}
	for index := 1; index < n; index++ {
		c[index] = nextInt()
	}

	var re int
	first := a[0]
	re += b[first]
	a = a[1:]
	for _, item := range a {
		re += b[item]
		if item-first == 1 {
			re += c[first]
		}
		first = item
	}

	fmt.Println(re)
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h, w;
        while(true){
            h = sc.nextInt();
            w = sc.nextInt();
            if(h == 0 && w == 0) break;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(i%2 == 0){
                        if(j%2 == 0){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }else{
                        if(j%2 == 0){
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 35708
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;

template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
    is >> p.first >> p.second;
    return is;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
    os << "{";
    for (auto& e : s) os << e << ", ";
    os << "}";
    return os;
}

struct Event {
    int t, v, d, c;

    Event(): t(-1) {}

    Event(int t, int v, int d, int c): t(t), v(v), d(d), c(c) {}

    Event step(int u) const {
        return {t, u, d - 1, c};
    }

    bool operator < (const Event& e) const {
        return tie(t, d, c, v) > tie(e.t, e.d, e.c, e.v);
    }

    friend ostream& operator << (ostream& os, const Event& e) {
        return os << "(" << e.t << ", " << e.d << ", " << e.c << ")";
    }
};

void update_coloring(int v, vector<set<Event>>& coloring, const Event& new_e) {
    // cout << "! " << v << " " << new_e << endl;
    // cout << "!! " << coloring[v] << endl;
    if (new_e.d < 0) return;
    vector<Event> to_remove;
    for (auto cur_e : coloring[v]) {
        if (new_e.t >= cur_e.t && new_e.d >= cur_e.d) to_remove.push_back(cur_e);
        if (new_e.t <= cur_e.t && new_e.d <= cur_e.d) return;
    }
    for (auto e : to_remove) coloring[v].erase(e);
    coloring[v].insert(new_e);
    // cout << "!! " << coloring[v] << endl;
}

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    vector<vector<int>> e(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    int q;
    cin >> q;
    vector<Event> qs(q);
    vector<set<Event>> cur_coloring(n);
    for (int i = 0; i < n; ++i) {
        cur_coloring[i].insert({-1, i, 0, 0});
    }
    for (int i = 0; i < q; ++i) {
        qs[i].t = i;
        cin >> qs[i].v >> qs[i].d >> qs[i].c;
        --qs[i].v;
        update_coloring(qs[i].v, cur_coloring, qs[i]);
    }

    for (int i = 0; i < 11; ++i) {
        auto new_coloring = cur_coloring;
        for (int u = 0; u < n; ++u) {
            for (int v : e[u]) {
                for (auto e : cur_coloring[u]) {
                    update_coloring(v, new_coloring, e.step(v));
                }
            }
        }
        cur_coloring = new_coloring;
    }

    for (int i = 0; i < n; ++i) {
        /*
           for (auto& e : cur_coloring[i]) {
           cout << e;
           }
         */
        // cout << endl;
        cout << cur_coloring[i].begin()->c << "\n";
    }

}


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


long Gcd(long m, long n){
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}
long Lcm(long m, long n){
	return m * n / Gcd(m,n); 
}

int main()
{
  int a,b;
   cin >> a;
   cin >> b;
   
   long y = Lcm(a, b);
   
   cout << y << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <map>
using namespace std;

vector<long long> a, b;

int main()
{
   int n, m;
   long long k;

   cin >> n >> m >> k;

   a.resize(n);
   b.resize(m);

   long long atotal = 0, btotal = 0;

   for (int i = 0; i < n; i++)
   {
      cin >> a[i];
      atotal += a[i];
   }

   for (int i = 0; i < m; i++)
   {
      cin >> b[i];
   }


   int j = 0;

   int ans = 0;
   for (int i = n - 1; i >= -1; i--)
   {
      long long rem = k - atotal;

      if (rem >= 0)
      {
         ans = max(ans, i + 1);
         for (; j < m && btotal + b[j] <= rem; j++)
         {
            btotal += b[j];
            ans = max(ans, i + j + 2);
         }
      }

      if (i >= 0)
      {
         atotal -= a[i];
      }
   }

   cout << ans;

   return 0;
}

Measured memory_bytes: 6272
#include "bits/stdc++.h"
using namespace std;
const long long int inf=1e18L+7;
int main(){
    int n;
    cin>>n;
    long long int W;
    cin>>W;
    vector<long long int> wt(n);
    vector<int>val(n);
    int sum_value=0;
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
        sum_value+=val[i];
    }
    vector<long long int>dp(sum_value+1,inf);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int v=sum_value-val[i];v>=0;v--) {
            dp[v+val[i]]=min(dp[v+val[i]],dp[v]+wt[i]);
        }
    }
    long long int ans=0;
    for(int i=0;i<=sum_value;i++){
        if(dp[i]<=W){
            ans=max(ans,(long long)i);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3904
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 0;
    for(int i = 0;i<s.length()-1;i++){
      if(s.substring(i,i+2).equals("BW")||s.substring(i,i+2).equals("WB")){
        ans++;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 48244
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

priority_queue< P, vector<P>, greater<P> > pq;

bool ishaiku(int x, int y, int z){
	return ((x == 5) && (y == 7) && (z == 5));
}

int main(void){
	int n,l,i;
	string s[123];
	cin >> n >> l;
	for(i=0; i<n; ++i){
		cin >> s[i];
	}
	sort(s,s+n);
	for(i=0; i<n; i++){
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>fl(N + 2);
  for (int i = 1; i <= N; i ++) cin >> fl[i];
  fl[0] = fl[N+1] = 0;
  int ans = 0;
  for (int i = 0; i < 100; i ++) {
    int kj = 0;
    for (int j = 1; j < N + 2; j ++) {
      if (fl[j - 1] <= 0 && fl[j] > 0) {
        kj ++;
      }
    }
    ans += kj;
    for (int j = 1; j <= N; j ++) fl[j] --;
  }
  cout << ans << endl;
}


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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n;
    cin >> n;
    vector<pair<string, ll>> arr(n), cpy;
    REP(i, 0, n)
        cin >> arr[i].first >> arr[i].second;
    cpy = arr;
    sort(all(arr), [](pair<string, ll> a, pair<string, ll> b) {
        if (a.first < b.first)
            return true;
        else if (a.first == b.first) {
            if (a.second > b.second)
                return true;
            return false;
        }
        return false;
    });
    REP(i, 0, n) {
        REP(j, 0, n)
            if (arr[i] == cpy[j]) {
                cout << j + 1 << endl;
                break;
            }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
typedef long long int ll;

int n, k;
int dp[2][100005];
bool find(bool curr, int arr[], int rem) {
	if (rem < 0)
		return curr;
	if (dp[curr][rem] != -1)
		return dp[curr][rem];
	bool ok = false;
	for (int j = 0; j < n; j++) {
		bool flag = find(!curr, arr, rem - arr[j]);
		if (flag == curr) {
			ok = true;
			break;
		}
	}
	if (ok)
		return dp[curr][rem] = curr;
	return dp[curr][rem] = !curr;
}


int main() {
	fastio;

	cin >> n >> k;
	memset(dp, -1, sizeof dp);
	int arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];

	if (find(true, arr, k))
		cout << "First";
	else
		cout << "Second";
	return 0;
}

Measured memory_bytes: 13756
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ForYellow
{
    class AGC020_C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            BitArray bitArray = new BitArray(2000 * 2001);
            BitArray bitArray2 = new BitArray(2000 * 2001);

            bitArray.Set(0, true);
            bitArray2.Set(0, true);
            for (int i = 0; i < n; i++)
            {
                bitArray.Or(bitArray2.LeftShift(array[i]));
                bitArray2.Or(bitArray);
            }

            int sum = array.Sum();
            int res = sum;
            int cnt = 0;
            foreach (bool val in bitArray)
            {
                if (val && cnt * 2 >= sum)
                {
                    res = Min(res, cnt);
                }
                cnt++;
                //WriteLine(cnt + " " + val);
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 48180
#include <stdio.h>

int main() {
    int n, a, min = 1000000, max = -1000000;
    long long sum = 0;
    scanf("%d", &n);
    while (n--) {
        scanf("%d", &a);
        if (a < min) {
            min = a;
        }
        if (a > max) {
            max = a;
        }
        sum += a;
    }
    printf("%d %d %lld\n", min , max, sum);
    return 0;
}

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

using namespace std;

int sx, sy, tx, ty;

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

    cin >> sx >> sy >> tx >> ty;

    for (int i = sx; i < tx; i++) {
        cout << 'R';
    }

    for (int i = sy; i < ty; i++) {
        cout << 'U';
    }

    for (int i = tx; i > sx; i--) {
        cout << 'L';
    }

    for (int i = ty; i > sy; i--) {
        cout << 'D';
    }

    cout << 'D';

    for (int i = sx; i <= tx; i++) {
        cout << 'R';
    }

    for (int i = sy; i <= ty; i++) {
        cout << 'U';
    }

    cout << 'L';

    cout << 'U';

    for (int i = tx; i >= sx; i--) {
        cout << 'L';
    }

    for (int i = ty; i >= sy; i--) {
        cout << 'D';
    }

    cout << 'R';

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    ll n,m,x,s=0;
    cin >>n>>x>>m;
    vector<Pl>memo(m);
    for (ll i=0; i <n; ++i) {
        if(memo[x].first){
            auto t=i-memo[x].first,c=(n-1-i)/t;
            i+=t*c;
            s+=(s-memo[x].second)*c;
        }
        else {
            memo[x]={i,s};
        }
        s+=x;
        x*=x;x%=m;
    }
    cout <<s<<endl;
}

Measured memory_bytes: 4840
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
string s;
bool b;
int main()
{
	fast;
	cin>>s;
	for (int i=0;i<=s.size();i++)
	   if (s[i]=='C')
	      b=true;
	   else if (s[i]=='F' && b)
	   {
	   	  cout<<"Yes"<<endl;
	   	  return 0;
	   }
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
#include <cassert>
#include <map>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N, M) for (ll i = N; i < M; ++i)
#define rrep(i, N, M) for (ll i = N; i < M; --i)
#define pb push_back


typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef priority_queue<pll, vector<pll>> pqpll;
typedef priority_queue<ll, vll, greater<ll>> pqll_greater;
typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll_greater;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>
#define _CRT_SECURE_NO_WARNINGS

template<class T, class S>
T atbit(T n, S i) {
	return (n >> i) % i;
}

template<class T>
T getbit(T i) {
	return 1LL << i;
}

//#define TRANSFORM(v,w,func) decltype(v) w ; transform((v).begin(),(v).end(),back_inserter(w),func);

using namespace std;


int main() {
	ll N, K;
	cin >> N >> K;
	vll x(N);
	rep(i, 0, N) {
		cin >> x[i];
	}
	ll np = count_if(x.begin(), x.end(), [](ll a) {return a >= 0; });
	ll np_ = count_if(x.begin(), x.end(), [](ll a) {return a > 0; });
	ll nm = count_if(x.begin(), x.end(), [](ll a) {return a <= 0; });
	ll nm_ = count_if(x.begin(), x.end(), [](ll a) {return a < 0; });

	auto get_cost = [&](ll idx,char flag) {//
		if (flag=='R') {
			return *(lower_bound(x.begin(), x.end(), 0) + (idx-1));
		}
		else {
			return - *(upper_bound(x.begin(), x.end(), 0) - idx);
		}
	};

	
	vll cost;// ( cost , i)
	if (np >= K) {
		cost.push_back(get_cost(K,'R'));
	}
	if (nm >= K) {
		cost.push_back(get_cost(K, 'L'));
	}

	rep(i, 0, N) {
		if (x[i] < 0 && (K-(nm_ -(i))<= np)) {
			//strategy LR
			cost.push_back( get_cost(K - (nm_ - (i)),'R')- 2LL*x[i] );
		}
		else if(x[i]>0 && (K <=i+1)){//K - (i - nm)<=nm
			//strategy RL
			cost.push_back(get_cost(K - (i+1-nm), 'L')+ 2LL * x[i]);
		}
		
	}

	cout << *min_element(cost.begin(),cost.end());
}


Measured memory_bytes: 2168
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String s = sc.next();
		if(Integer.valueOf(a)>=3200)
		System.out.println(s);
		else 
		System.out.println("red");
	}
}

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

int vacation(vector<vector<int>> &v,vector<vector<int>> &dp,int i,int j,int n){
    if(i==n) return 0;
    
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    
    int ans = INT_MIN;
    for(int k = 0;k<3;k++){
        if(k!=j){
            ans = max(ans,vacation(v,dp,i+1,k,n));
        }
    }
    ans += v[i][j];
    
    return dp[i][j] = ans;
}

int main() {
    int n;
    cin>>n;
    vector<vector<int>> v(n,vector<int>(3,0));
    vector<vector<int>> dp(n,vector<int>(3,-1));
    for(int i=0;i<n;i++){
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    cout<<max({vacation(v,dp,0,0,n),vacation(v,dp,0,1,n),vacation(v,dp,0,2,n)});
	return 0;
}

Measured memory_bytes: 18944
D = int(input())
c = list(map(int,input().split()))
s = [[0 for i in range(26)] for j in range(D)]
for i in range(D):
  s[i] = list(map(int,input().split()))
for i in range(D):
  M = max(s[i])
  for j in range(26):
    if s[i][j] == M:
      ans = j+1
  print(ans)
  

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

const int MAXN = 524289;
int n, V, xs[MAXN];
int ls[MAXN], rs[MAXN], bak;
int L[32][MAXN], R[32][MAXN];
int pre[MAXN], suc[MAXN];
void getmax(int & x, int y) { x < y ? x = y : 0; }
void getmin(int & x, int y) { x > y ? x = y : 0; }
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> V;
	for (int i = 1; i <= n; ++i) std::cin >> xs[i];
	int T = 0;
	for (; ; ++T, V >>= 1) {
		int lst = 1;
		for (int i = 2; i <= n + 1; ++i)
			if (xs[i] - xs[i - 1] > V || i == n + 1) {
				int l = lst, r = i - 1;
				if (!T) ls[++bak] = l, rs[bak] = r;
				else for (int j = l; j <= r; ++j)
					L[T - 1][j] = l, R[T - 1][j] = r;
				lst = i;
			}
		if (!V) break;
	}
	const int U = 1 << T;
	for (int i = 0; i != U; ++i) suc[i] = n + 1;
	for (int i = 0; i != U; ++i)
		for (int j = 0; j != T; ++j)
			if (~i >> j & 1) {
				getmax(pre[i | 1 << j], R[j][pre[i] + 1]);
				getmin(suc[i | 1 << j], L[j][suc[i] - 1]);
			}
	for (int i = 1; i <= bak; ++i) {
		bool can = false;
		if (bak <= 40) {
			for (int j = 0; j != U; ++j)
				if (pre[j] >= ls[i] - 1 && suc[U - j - 1] <= rs[i] + 1) {
					can = true;
					break;
				}
		}
		for (int j = ls[i]; j <= rs[i]; ++j)
			std::cout << (can ? "Possible\n" : "Impossible\n");
	}
	return 0;
}


Measured memory_bytes: 85376
#include <bits/stdc++.h>
using namespace std;
 
 
 
 
int main() {
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
   
    int n,x;
    cin>>x>>n;
    int a[n],i,num=0,min=INT_MAX;
    set<int> s;
    for(i=0;i<n;++i)
       { cin>>a[i];
         s.insert(a[i]);
       }
    
    if(n==0)
      cout<<x;
      
    else
    {
        for(i=-100;i<=101;++i)
          {
              if(s.count(i)==0)
               {
                   if(min>abs(x-i))
                      { min=abs(x-i);
                        num=i;
                      }
               }
          }
          
          cout<<num;
    }
     
   
 
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,m;cin>>n>>m;
    vector<ll> f(10,1);
    rep(i,9) f[i+1]=f[i]*2;
    ll res=(100*n + 1800*m)*f[m];
    cout<<res<<endl;
}

Measured memory_bytes: 3620
fn getline() -> String{
	let mut __ret=String::new();
	std::io::stdin().read_line(&mut __ret).ok();
	return __ret;
}

fn main(){
	let s=getline();
	let abc:Vec<_>=s.trim().split(' ').collect();
	let a:i32=abc[0].parse().unwrap();
	let b:i32=abc[1].parse().unwrap();
	let c:i32=abc[2].parse().unwrap();
	
	let mut ans = -1;

	if(a == b && b == c){
		ans = 1;
	}else if(a !=b && b!=c && c!=a){
		ans = 3;
	}else{
		ans = 2;
	}

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

Measured memory_bytes: 4352
import sys
input()
ac,wa={*()},{}
nc=np=0
for ln in sys.stdin:
    p,S=ln.split()
    if p in ac:
        continue
    if p not in wa:
        wa[p]=0
    if S=='AC':
        ac.add(p)
        nc+=1
        np+=wa[p]
    else:
        wa[p]+=1

print(nc,np)


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

int main() {
	long long N, M;
	priority_queue<double> PQ;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		double a;
		cin >> a;
		PQ.push(a);
	}
	for (int i = 0; i < M; i++) {
		double x = PQ.top();
		PQ.pop();
		x /= 2.0;
		PQ.push(x);
	}
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		ans += (long long ) PQ.top();
		PQ.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, s);
  if (sz(s) == 3) reverse(all(s));

  puts(s.c_str());

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long long  n;
	cin>>n;
	long long  a[n+1];
	for(int i=1;i<=n;i++)
	a[i]=i;
	for(long long i=1;i<=n;i++)
	{
		if(a[i]%3==0||a[i]%5==0)
		a[i]=0;
	}
	long long sum=0;
	for(long long i=1;i<=n;i++)
	sum+=a[i];
	cout<<sum;
}

Measured memory_bytes: 11388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 i_7-2
#define N 2000004
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0){
		return 1;
	}else if(p==1){
		return mod(i);
	}else if(p%2==0){
		return po(mod(mod(i)*mod(i)),p/2);
	}else{
		return mod(mod(i)*po(i,p-1));
	}
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    for(ll i=1;i<=N-1;i++){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k){
		return 0;
	}else if(n==0){
		return 1;
	}else{
		return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
	}
}
ll bunbo(ll n){
    return po(n,i_5);
}
int main(){   
    calc();    
    ll x,y;cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;
		return 0;
    }
    ll n=(x+y)/3;
    x-=n;
    y-=n;
    if(x<0||y<0){
        cout<<0<<endl;
		return 0;
    }
    cout<<comb(x+y,x)<<endl;
    return 0;
}

Measured memory_bytes: 31488
//14:07:00 

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;



int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<int> v(n*3);
	for(auto &i:v) cin>>i;
	priority_queue<int,vector<int>,greater<int>> pqs;
	vector<int> pre; int now=0;
	For(i,0,n-1)
	{
		now+=v[i];
		pqs.emplace(v[i]);
	} pre.emplace_back(now);
	For(i,n,n*2-1)
	{
		pqs.emplace(v[i]);
		now+=v[i];
		now-=pqs.top();
		pqs.pop();
		pre.emplace_back(now);
	}
	priority_queue<int> pqb;
	vector<int> suf; now=0;
	for(int i=n*3-1;i>=n*2;i--)
	{
		now+=v[i];
		pqb.emplace(v[i]);
	} suf.emplace_back(now);
	for(int i=n*2-1;i>=n;i--)
	{
		pqb.emplace(v[i]);
		now+=v[i];
		now-=pqb.top();
		pqb.pop();
		suf.emplace_back(now);
	}
	int mx=-1e17;
	For(i,0,sz(pre)-1)
		mx=max(mx,pre[i]-suf[sz(suf)-i-1]);
	cout<<mx<<"\n";
	//for(auto i:pre) cout<<i<<" "; cout<<"\n";
	//for(auto i:suf) cout<<i<<" "; cout<<"\n";
	return 0;
}











Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
long long k,s,sum=0,m;
int main()
{
    scanf("%lld%lld",&k,&s);
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++){
            m=s-i-j;
            if(m<=k&&m>=0)
				sum++;
		}
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)
using namespace std;

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

    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<ll>> train(N, vector<ll>(N, 0));
    REP (i, M) {
        ll l, r;
        cin >> l >> r;
        l--; r--;
        train[l][r]++;
    }

    vector<vector<ll>> s(N+1, vector<ll>(N+1, 0));
    REP (i, N) {
        REP (j, N) {
            s[i+1][j+1] = s[i][j+1] + s[i+1][j] - s[i][j] + train[i][j];
        }
    }

    REP (i, Q) {
        ll p, q;
        cin >> p >> q;
        p--; q;
        cout << s[q][q] - s[p][q] - s[q][p] + s[p][p] << "\n";
    }
}

Measured memory_bytes: 4864
#include<stdio.h>
int main(){
  int i,N,j;
  int a[100];
  scanf("%d",&N);
  for(i=N-1;i>=0;i--){
    scanf("%d",&a[i]);
  }
  for(j=0;j<=N-1;j++){
  if(j == N - 1) {
    printf("%d\n",a[j]);
  }
  else{
    printf("%d ", a[j]);
  }
  }
     return 0;
}

Measured memory_bytes: 2584
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int64> a(n+1);
    vector<int64> b(n+1);
    vector<int64> c(n+1);

    for (int64 i=1; i<=n; i++) cin >> a[i] >> b[i] >> c[i];

    vector<vector<int64>> dp(3, vector<int64> (n+1, 0));

    dp[0][0] = 0;
    dp[1][0] = 0;
    dp[2][0] = 0;

    for (int64 i=1; i<=n; i++) {
        dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1], dp[1][i-1]);
    }

    int64 ans;
    ans = max(dp[0][n], dp[1][n]);
    ans = max(ans, dp[2][n]);

    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include<vector>

using namespace std;

int n;

int a[100005];

int check[100005];

long long int M = 1000000007;

long long int INV(long long int m, long long int p) {
	vector<int> bit; // 2^0, 2^1, 2^2, 2^3, 
	long long int u = p-2;
	while (u > 0) {
		bit.push_back(u % 2); u /= 2;
	}

	vector<long long int> W;
	long long int TMP = m;
	for (int i = 0; i < (int)bit.size(); i++) {
		TMP %= p;
		W.push_back(TMP);
		TMP *= TMP;
	}

	long long int ret = 1;

	for (int i = 0; i<(int)bit.size(); i++) {
		if (bit[i] == 1) { ret *= W[i];  ret %= p; }
	}


/*	for (int i = 0; i <(int) bit.size(); i++) {
		cout << "bit[" << i << "]= " << bit[i] <<"   W= " <<W[i]<< endl;
	}*/


	return ret;
};

long long int A[100005], B[100005];

int p, q;

void CALC_A(void) {

	A[0] = 1;
	for (int i = 1; i <= n + 1; i++) { A[i] = (long long int)( ((n - i + 2)*A[i - 1] +M) %M) *INV(i,M); 
	A[i]=(A[i]+M) % M;
	                                   }

};

void CALC_B(void) {

	B[0] = 1;
	for (int i = 1; i <= n + p-q; i++) {
		B[i] = (long long int)(((n+p-q - i + 1)*B[i - 1] + M) % M) *INV(i, M);
		B[i] = (B[i] + M) % M;
	}

};

int main(void) {

	cin >> n;
	int tmp;

	int x;
	for (int i = 1; i <= n+1; i++) {
		cin >> tmp; a[i] = tmp; 
		if (check[tmp] == 0) { check[tmp]++; }
		else { x = tmp; }
	}

	//cout << "x= " << x << endl;

	p = 0;  q = 0;
	for (int i = 1; i <= n + 1; i++) {
		if (a[i] == x) { p = q; q = i; }
	}
	//cout << "p= " << p << "  q= " << q << endl;

	CALC_A();
	CALC_B();

	/*for (int i = 0; i <= n + p-q; i++) {
		cout << "B[" << i<<"]= " << B[i] << endl;
	}*/

	for (int k = 1; k <= n + 1; k++) {
		long long int ans;
		ans = A[k];
		if (n + p - q >= k - 1) { ans -= B[k - 1]; }
		ans = (ans + M) % M;
		cout << ans << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 3584
#include <cstdio>
int main(){
	int N,M;
	scanf("%d %d",&N,&M);
	int A[1000];
	int Ai;
	int Bj;
	int count[1000];
	for(int i=0;i<N;i++){
		scanf("%d",&Ai);
		A[i]=Ai;
		count[i]=0;
	}
	for(int j=0;j<M;j++){
		scanf("%d",&Bj);
		for(int i=0;i<N;i++){
			if(A[i]<=Bj){count[i]++;break;}
		}
	}
	int max_count=0;
	int max_game=-1;
	for(int i=0;i<N;i++){
		if(max_count<count[i]){
			max_count=count[i];
			max_game=i;
		}
	}

	printf("%d\r\n",max_game+1);
}

Measured memory_bytes: 1032
import sys
def f(s,d,g,c):
	if d>3:return c
	for n in xrange(10):
		if s+n==g:return c+1
		elif s+n>g:return c
		else:c=f(s+n,d+1,g,c)
	return c
for l in sys.stdin:
	print f(0,0,int(l),0)

Measured memory_bytes: 4200
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn =2e5+10;
int a[maxn],b[maxn];
int main(){
    int n;
    while(~scanf("%d",&n)){
    for(int i=1;i<=n+1;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    long long sum=0;
    for(int i=1;i<=n;i++){
        //if(b[i]!=0){
            //if(a[i]>0||a[i+1]>0){
                    int t1=min(a[i],b[i]);
                    sum+=t1;
                    b[i]-=t1;
                    a[i]-=t1;
                if(b[i]>0){
                    int t=min(a[i+1],b[i]);
                    sum+=t;
                    b[i]-=t;
                    a[i+1]-=t;
                }
            //}
        //}
    }
        printf("%lld\n",sum);
    }
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> V(N),C(N),A(N);
  for(int i=0;i<N;i++){
    cin>>V.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>C.at(i);
  }
  for(int i=0;i<N;i++){
    A.at(i)=V.at(i)-C.at(i);
  }

  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int ans=0;
  for(int i=0;i<N;i++){
    if(A.at(i)<0){
      break;
    }
    ans+=A.at(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[];j=0
 for l in L:
  while j<len(R)and R[j]<l:T+=[R[j]];j+=1
  T+=[l]
 while j<len(R):T+=[R[j]];j+=1
 return T
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:])) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 63384
n,m=map(int,input().split())
l=list(map(int,input().split()))
d=dict()
for i in range(m):
  a,b=map(int,input().split())
  if b in d:
    d[b]+=a
  else:
    d[b]=a
x=sorted(d.keys())[::-1]
now=0
for y in x:
  now+=d[y]
  l+=[y]*min(n,d[y])
  if now>n:
    break
print(sum(sorted(l)[::-1][:n]))

Measured memory_bytes: 27376
def main():
    A = list(input())
    B = list(input())
    if A == B:
        print("EQUAL")
    elif len(A) > len(B):
        print("GREATER")
    elif len(A) < len(B):
        print("LESS")
    else:
        for a, b in zip(A, B):
            if a > b:
                print("GREATER")
                break
            elif a < b:
                print("LESS")
                break


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060