akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MOD = 998244353;

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int j = 0; j < m; ++j) {
        cin >> b[j];
    }
    
    int ans = 0;
    int st = 0;
    int ca = 0, cb = 0;
    while (ca < n && st + a[ca] <= k) {
        st += a[ca];
        ++ca;
    }
    while (cb < m && st + b[cb] <= k) {
        st += b[cb];
        ++cb;
    }
    ans = ca + cb;
    
    while (ca > 0) {
        --ca;
        st -= a[ca];
        while (cb < m && st + b[cb] <= k) {
            st += b[cb];
            ++cb;
        }
        ans = max(ans, ca + cb);
    }
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 4788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        long a=s.nextLong();
        long b=s.nextLong();
        long n=s.nextLong();
        System.out.println((a*Math.min(n,b-1))/b);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 25348
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int ans = 0;
    for (int i=0;i<N;i++){
      int h = sc.nextInt();
      if (h>=K){ ans++; }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 48380
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

char aaa[50];
int32_t a, b, c, d;
#define beet(x,y,z) if(a x b y c z d==7){out<<a<<#x<<b<<#y<<c<<#z<<d<< "=7\n";return 0;}
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> aaa;
	a = aaa[0] - '0';
	b = aaa[1] - '0';
	c = aaa[2] - '0';
	d = aaa[3] - '0';
	if (a + b + c + d== 7) { out << a << '+' << b << '+' << c << '+' << d << "=7\n"; return 0; }
	if (a + b + c - d== 7) { out << a << '+' << b << '+' << c << '-' << d << "=7\n"; return 0; }
	if (a + b - c + d== 7) { out << a << '+' << b << '-' << c << '+' << d << "=7\n"; return 0; }
	if (a + b - c - d== 7) { out << a << '+' << b << '-' << c << '-' << d << "=7\n"; return 0; }
	if (a - b + c + d== 7) { out << a << '-' << b << '+' << c << '+' << d << "=7\n"; return 0; }
	if (a - b + c - d== 7) { out << a << '-' << b << '+' << c << '-' << d << "=7\n"; return 0; }
	if (a - b - c + d== 7) { out << a << '-' << b << '-' << c << '+' << d << "=7\n"; return 0; }
	if (a - b - c - d== 7) { out << a << '-' << b << '-' << c << '-' << d << "=7\n"; return 0; }

	return 0;
}
#endif

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)
#define int long long

using namespace std;
typedef pair<int, int> pii;

int n,a[3][100010]={0};
int dp[3][100010]={0};

signed main() {
	cin>>n;
    rep(i,n){
        cin>>a[0][i]>>a[1][i]>>a[2][i];
    }
    rep(i,n){
        rep(j,3){
            dp[j][i+1]=max(dp[(j+1)%3][i],dp[(j+2)%3][i])+a[j][i];
        }
    }
    int ans=-1;
    rep(i,3){
        ans=max(ans,dp[i][n]);
    }
	
    cout<<ans<<endl;
	
	return 0;
}


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

signed main(void)
{
	int t, x;
	cin >> t >> x;
	cout << fixed << setprecision(10) << (double) t / x << endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;
int main() {
	int n; cin >> n;

	vector <ll> a(n * 3);
	rep(i, n * 3)cin >> a[i];

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	ll ans = 0;

	for (int i = 1; i < n * 2; i++) {
		if (i % 2 == 1) {
			ans += a[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,arr[256],p=0,max=0,sum=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>arr[i];
    if(arr[i]>max) max=arr[i],p=i;
  }
  for(i=0;i<n;i++) if(i!=p) sum+=arr[i];
  if(max<sum) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/ruby
class TLLI
	def initialize
		@trianies=[nil,[0,0,0]]
	end
	def root_triany
		1
	end
	def allocate_triany
		siz=@trianies.size
		@trianies[siz]=[0,0,0]
		return siz
	end
	def set_a(id,value)
		return if !@trianies[id]
		@trianies[id][0]=value
	end
	def set_b(id,value)
		return if !@trianies[id]
		@trianies[id][1]=value
	end
	def set_c(id,value)
		return if !@trianies[id]
		@trianies[id][2]=value
	end
	def get_a(id)
		return if !@trianies[id]
		@trianies[id][0]
	end
	def get_b(id)
		return if !@trianies[id]
		@trianies[id][1]
	end
	def get_c(id)
		return if !@trianies[id]
		@trianies[id][2]
	end
end

$black={}
class SETI <TLLI # a=>key, b=>left, c=>right
	def set_entry(key)
		x=root_triany
		y=0
		while x!=0&&!(x==root_triany&&get_a(x)==0) #fixme
			y=x
			if key<get_a(x)
				x=get_b(x)
			else
				x=get_c(x)
			end
		end
		if y==0
			set_a(root_triany,key)
		else
			leaf=allocate_triany
			set_a(leaf,key)
			if key<get_a(y)
				set_b(y,leaf)
			else
				set_c(y,leaf)
			end
		end
	end
	def find_entry(key)
		t=root_triany
		loop{
			return true if key==get_a(t)
			if key<get_a(t)
				t=get_b(t)
				return false if t==0
			else
				t=get_c(t)
				return false if t==0
			end
		}
	end
	def delete_entry(key)
		t=root_triany
		loop{
			break if key==get_a(t)
			if key<get_a(t)
				t=get_b(t)
				return false if t==0
			else
				t=get_c(t)
				return false if t==0
			end
		}
	end
	def print_preorder(t)
		return if t==0
		Kernel.print " #{get_a(t)}"
		print_preorder(get_b(t))
		print_preorder(get_c(t))
	end
	def print_inorder(t)
		return if t==0
		print_inorder(get_b(t))
		Kernel.print " #{get_a(t)}"
		print_inorder(get_c(t))
	end
	def print_postorder(t)
		return if t==0
		print_postorder(get_b(t))
		print_postorder(get_c(t))
		Kernel.print " #{get_a(t)}"
	end
	def print
		print_inorder(root_triany);puts
		print_preorder(root_triany);puts
	end
end

seti=SETI.new
$<.drop(1).each{|l|
	a=l.split
	if a[0]=='insert'
		seti.set_entry(a[1].to_i)
	elsif a[0]=='find'
		puts seti.find_entry(a[1].to_i) ? :yes : :no
	elsif a[0]=='delete'
		seti.delete_entry(a[1].to_i)
	elsif a[0]=='print'
		seti.print
	end
}

Measured memory_bytes: 89980
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 5;
ll n, m, t, a[MAXN];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
	{
		ll ans = ll(1e13), len = ll(sqrt(n));
		for (ll i = 1; i <= len; ++i)
			if (n%i == 0)
				ans = min(ans, i + n / i - 2);
		cout << ans << endl;
	}
}
/*
10

50

10000000019
*/

Measured memory_bytes: 256
// 2017-5-27 20:02
// 2017-5-27 20:09
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n, a, b;

int main(){
	while(~scanf("%lld %lld %lld", &n, &a, &b)){
		LL cnt = b - a + 1;
		printf("%lld\n", max((n - 1) * b + a - ((n  - 1)* a + b) + 1, 0LL));
	}
	return 0;
}
		


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

char *rotation(char *str) {
    char hoge = str[0];
    int i;
    for (i=1; i<strlen(str); i++) {
        str[i-1] = str[i];
    }
    str[i-1] = hoge;
    return str;
}

int main(void) {
    char s[128], t[128];
    scanf("%s", s);
    scanf("%s", t);

    if (strlen(s) == strlen(t)) {
        int i;
        for (i=0; i<strlen(s); i++) {
            if (strcmp(s, t) == 0){
                break;
            }
            rotation(s);
        }

        if (i != strlen(s)) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll x,y,z;
    cin>>x>>y>>z;
    x-=z;
    cout<<x/(y+z)<<endl;


}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = []
for _ in range(n):
    s.append(input()[0])
import collections
c = collections.Counter(s)
lis = [c["M"],c["A"],c["R"],c["C"],c["H"]]
from itertools import *
ans=0
for tmp in combinations(lis,3):
    ans+=tmp[0]*tmp[1]*tmp[2]
print(ans)

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
 if(n-k==0){
   cout<<1<<endl;
 }
  else{
    int ans=0;
    if((n-k)%(k-1)!=0){
      ans=(n-k)/(k-1)+2;
    }
    else{
      ans=(n-k)/(k-1)+1;
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3784
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>
#include <random>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007ll
#define eps 1e-6
#define infi 1000000107
#define infll 1000000000000000000ll
#define MX 1000000
#define X real()
#define Y imag()
#define left(i) i<<1
#define right(i) (i<<1)|1
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
//#define rotate(a, theta) (a) * (polar(1.0, (theta) ))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c) cross(vec(a,b) , vec(a,c)) > eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 1000500001ll
#define mod2 1000300001ll
#define base1 137ll
#define base2 31ll
#define PI acos(-1.0l)
#define sz(a) (int) (a).size()
#define isbit(x,k)  ((x) & (1<<(k))) > 0


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef complex<ld> point;
typedef pair<point, point> line;
typedef pair<ld , point> Circle;
typedef pair<point, int> Point;


const int N = 1000005, A = 10000005;



int main(){
    string a;
    cin>>a;
    
    if(sz(a) == 2)
        cout<<a;
    else {
        reverse(all(a));
        cout<<a;
    }
    
    return 0;
}



/*
 */

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);

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

#include <bits/stdc++.h>

using namespace std;

class arc092_d {
private:
    int count(int start_num, int end_num, const vector<int> &b) {
        auto it_start = lower_bound(begin(b), end(b), start_num);
        auto it_end = lower_bound(begin(b), end(b), end_num);
        int cnt = it_end - it_start;
        return cnt;
    }
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> a(N), b(N);
        for (int i = 0; i < N; ++i) {
            in >> a[i];
        }
        for (int i = 0; i < N; ++i) {
            in >> b[i];
        }
        vector<int> res(29, 0);
        for (int j = 0; j < 29; ++j) {
            int T = (1 << j);
            vector<int> cur_b(N);
            for (int i = 0; i < N; ++i) {
                cur_b[i] = b[i] % (2 * T);
            }
            sort(begin(cur_b), end(cur_b));
            for (int i = 0; i < N; ++i) {
                res[j] += count(T - (a[i] % (2 * T)), 2 * T - (a[i] % (2 * T)), cur_b);
                res[j] += count(3 * T - (a[i] % (2 * T)), 4 * T - (a[i] % (2 * T)), cur_b);
            }
        }
        int ans = 0;
        for (int j = 0; j < 29; ++j) {
            if (res[j] % 2) {
                ans |= (1 << j);
            }
        }
        out << ans << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc092_d solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2672
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

/**
 * @author: pashka
 */

private fun solve() {
    var a = nextLong()
    var b = nextLong()
    var k = nextLong()

    var x = Math.min(a, k)

    a -= x
    k -= x
    x = Math.min(b, k)
    b -= x
    k -= x

    out.println("" + a + " " + b)
}

fun main(args: Array<String>) {
    solve()
    out.close()
}

private var br = BufferedReader(InputStreamReader(System.`in`))
private var st: StringTokenizer? = null
private var out = PrintWriter(System.out)

@Throws(IOException::class)
private fun next(): String {
    while (st == null || !st!!.hasMoreTokens()) {
        st = StringTokenizer(br.readLine())
    }
    return st!!.nextToken()
}

@Throws(IOException::class)
private fun nextInt(): Int {
    return next().toInt()
}

@Throws(IOException::class)
private fun nextLong(): Long {
    return next().toLong()
}


Measured memory_bytes: 31396
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

     String s = sc.next();
     char[] c = new char[4];
     int[] a = new int[4];

     for (int i = 0;i<4 ;i++ ) {
       c[i] = s.charAt(i);
     }

     for (int i = 0;i<4 ;i++ ) {
       String sn = String.valueOf(c[i]);
       a[i] =  Integer.parseInt(sn);
     }

     if (a[0]*10+a[1]<=12&&a[0]*10+a[1]>0) {
       if (a[2]*10+a[3]<=12&&a[2]*10+a[3]>0) {
         System.out.println("AMBIGUOUS");
         System.exit(0);
       }
     }

     if (a[2]*10+a[3]<=12&&a[2]*10+a[3]>0) {
        System.out.println("YYMM");
     }else if(a[0]*10+a[1]<=12&&a[0]*10+a[1]>0){
       System.out.println("MMYY");
     }else{
       System.out.println("NA");
     }


      }
    }


Measured memory_bytes: 21716
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;

use maplit::*;

use num::Integer;

use proconio::input;
use proconio::marker::*;
use proconio::fastout;

const INF: usize = 1_000_000_007;

#[fastout]
fn solve() {
  input! {
    n: usize, m: usize,
  };

  let mut g = vec![vec![]; n + 1];
  for _ in 0..m {
    input! {
      a: usize, b: usize,
    };
    g[a].push(b);
    g[b].push(a);
  }

  let mut q = VecDeque::new();
  q.push_back(1usize);
  let mut prev = vec![n + 1; n + 1];
  let mut visited = vec![false; n + 1];
  
  while let Some(u) = q.pop_front() {
    if visited[u] { continue; }
    
    visited[u] = true;
    for v in &g[u] {
      if *v != 1usize && prev[*v] == n + 1 {
        prev[*v] = u;
        q.push_back(*v);
      }
    }
  }

  if prev[2..=n].iter().any(|&p| p == n + 1 ) {
    println!("No");
  } else {
    println!("Yes");
    for i in 2..n {
      println!("{}", prev[i]);
    }
    print!("{}", prev[n]);
  }
}

fn main() {
  std::thread::Builder::new()
    .name("big stack size".into())
    .stack_size(32 * 1024 * 1024)
    .spawn(|| {
      solve();
    })
    .unwrap()
    .join()
    .unwrap();
}

Measured memory_bytes: 13224
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second

using namespace std;

vector<string> v;
string ans="";
int n,A,B,C;
set<vector<int>> vis;

bool run(int i){ 
	if(i == n) return true;
	if(vis.count({i,A,B,C})) return false;

	int &pri = v[i][0]=='A'?A:(v[i][0]=='B'?B:C);
	int &sec = v[i][1]=='A'?A:(v[i][1]=='B'?B:C);
 	
	if(pri - 1 >= 0){
		pri--;
		sec++;
		ans[i]=v[i][1];
		if(run(i+1))return true;
		ans[i]=' ';
		pri++;
		sec--;
	}
	
	if(sec - 1 >= 0){
		pri++;
		sec--;
		ans[i]=v[i][0];
		if(run(i+1))return true;
		ans[i]=' ';
		pri--;
		sec++;
	}
	vis.insert({i,A,B,C});
	return false;
}


//int t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//cin>>t;
	//while(t--){}
	cin>>n>>A>>B>>C;
	v = vector<string> (n);
	for(string &s:v){
		ans += " ";
		cin>>s;
	}
	if(run(0)){
		cout<<"Yes\n";
		for(char &c:ans)
			cout<<c<<"\n";
	}else
		cout<<"No\n";


	return 0;	
}



Measured memory_bytes: 18172
#include <iostream>

int main() {
 
  int num;
  long long sum = 0;
  std::cin >> num;
  for(int i = 1 ; i <= num ; i++) {
  	sum += (( i % 3 == 0 || i % 5 == 0) ? 0 : i);
  }
  std::cout << sum;
  
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
        int a,b,c;
        cin>>a>>b>>c;
        if (a<b)
        {
            int temp=a;
            a=b;
            b=temp;
        }
        if (b<c)
        {
            int temp=b;
            b=c;
            c=temp;
        }
        if (a<b)
        {
            int temp=a;
            a=b;
            b=temp;
        }
        int d = a-b,e = a-c;
        int b1=d/2,b2=d%2,c1=e/2,c2=e%2;
        int sum=b1+c1;
        if (b2 == 1&&c2 == 1)
            sum++;
        if ((b2 == 1&&c2 == 0)||(b2 == 0&&c2 == 1))
            sum+=2;
        cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N; cin>>N;
    vector<int> d(N);
    for (int i = 0; i < N; ++i) {
        cin>>d[i];
    }

    ll ans=0ll;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = 0, m = 0;
            in.next();
            for (char cc : in.next().toCharArray())
                m = Math.max(cc == 'I' ? ++n : --n, m);
            out.println(m);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    rep(i, k){
        if(a>=b) b *= 2;
        else if(b>=c) c *= 2;
    }

    if(a<b && b<c) pr("Yes");
    else pr("No");
    return 0;}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		System.out.println(toAlphabet(N));
	}

	public static String toAlphabet(long num){
		if (num <= 0) return "";
		long n = num % 26;
		n = (n == 0) ? 26 : n;
		char alphabet = 'a' - 1;
		for (long i = 0; i < n; i++) {
			alphabet++;
		}
		String s = String.valueOf(alphabet);
		if (num == n) return s;
		return toAlphabet((num - n) / 26) + s;
	}

}


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

int N,M,Q;
vector<int> a,b,c,d;
vector<int> A;
int pmax = 0;

// 点数計算
int point(vector<int> A,int Q){
    int p = 0;
    for ( int i = 0; i < Q; ++i){
        if ( A[b[i]] - A[a[i]] == c[i] ) p = p + d[i];
    }
    return p;
}

// i番目にxを代入する
void dfs(int i, int x) {
    A[i] = x;
    if ( i == N - 1 ){
        int p = point(A,Q);
        pmax = max(p,pmax);
        return;
    }
    for ( int y = x; y <= M; ++y){
        dfs(i+1,y);
    }
    return;
}

int main() {
    cin >> N >> M >> Q;
    a.assign(Q,0);
    b.assign(Q,0);
    c.assign(Q,0);
    d.assign(Q,0);
    for ( int i = 0; i < Q; ++i){
        int p,q;
        cin >> p >> q >> c.at(i) >> d.at(i);
        a.at(i) = p-1;
        b.at(i) = q-1;
    }
    
    A.assign(N,1);
    dfs(0,1);
    
    cout << pmax << endl;
    
    return 0;
}


Measured memory_bytes: 3588
K, N = map(int, input().split())
A = list(map(int, input().split()))

kyori = 0
for i in range(N-1):
  if kyori < A[i+1]-A[i]:
    kyori = A[i+1]-A[i]
if kyori < K - A[N-1] + A[0]:
  kyori = K - A[N-1] + A[0]
ans = K - kyori
print(ans)

Measured memory_bytes: 26436
using System;
using System.Collections.Generic;
using System.Linq;

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc064_c();
        }

        static void abc064_c()
        {
            // ABC064 C - Colorful Leaderboard
            int n = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            int ans_min;
            int ans_max;
            // 色(ランク)はレート400刻みなので400で切り捨て除算してランクを出す
            const int len_rank = 8;
            int[] color = new int[len_rank];
            int free = 0;
            for (int i=0; i<n; i++)
            {
                int rank = (int)(A[i] / 400);
                if (rank < len_rank) color[rank] += 1;
                else free += 1;
            }
            // 最小：色固定の人数(フリーは既存の色にする)、または、1(全員フリー)
            // 最大：全色の数(8)、または、色固定人数＋色フリー人数、の小さいほう
            int fix = color.Count(x => x > 0);
            ans_min = Math.Max(fix, 1);
            ans_max = fix + free;
            // 出力
            Console.WriteLine(String.Format("{0} {1}", ans_min, ans_max));
        }
    }
}

Measured memory_bytes: 11348
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES

using namespace std;



int main()
{
    int n,k;cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i=i+1){cin>>a[i];}
    sort(a,a+n);
    
    int sum = 0;
    for(int i=0;i<k;i=i+1)sum+=a[i];
    cout<<sum<<endl;
}




Measured memory_bytes: 3640
{-# LANGUAGE BangPatterns #-}

main :: IO ()
main = do
    cs <- getLine
    print $ solve $ map conv cs

conv 'S' = '('
conv 'T' = ')'
conv _ = undefined

solve :: String -> Int
solve cs = length $ go 0 0 cs
  where
    go open close (')':rest)
      | open > 0 = go (open-1) close rest
      | otherwise = go 0 (close+1) rest
    go open close ('(':rest) = replicate close ')' ++ go (open+1) 0 rest
    go open close [] = replicate close ')' ++ replicate open '('

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

using namespace std;

main(){
	int a,b,c,d,e,f,g,h,A,B;
	cin >> a >> b >> c >> d >> e >> f >> g >> h;
	A=a+b+c+d;
	B=e+f+g+h;
	if (A>B){
		printf("%d\n",A);
	}
	else if (A<B){
		printf("%d\n",B);
	}
	else {
		printf("%d\n",A=B);
	}
}


Measured memory_bytes: 3232
n, t = map(int, input().split())
a = list(map(int, input().split()))

vm = a[n - 1]#数列を右から見た時の最大値
d = dict()
for i in range(n - 2, -1, -1):
    if a[i] > vm:
        vm = a[i]
    else:
        df = vm - a[i]
        d[df] = d.get(df, 0) + 1

df_cnt = sorted(d.items(), key = lambda x:x[0], reverse = True)#差が大きい方から並べる

print(df_cnt[0][1])

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

int main(){
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int min, max, ans;
    if(n >= 1){
        rep(i, 101){
            int a = x - i;
            int b = x + i;
            int cnt = 0, mcnt = 0;;
            rep(j, n){
                if(a == p[j]){
                    cnt++;
                }
                if(b == p[j]){
                    mcnt++;
                }
            }
            if(cnt == 0 && mcnt == 0){
                ans = a;
                break;
            }else if(cnt == 0 && mcnt != 0){
                ans = a;
                break;
            }else if(cnt != 0 && mcnt == 0){
                ans = b;
                break;
            }
        }
    }
    else{
        ans = x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b,x;
char ch;
scanf("%lld %c %lld",&a,&ch,&b);
if(ch=='+'){
    x=a+b;
printf("%lld\n",x);

}
else if(ch=='-'){
       x=a-b;
printf("%lld\n",x);
}


return 0;

}


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

int main(){
	string s;
	cin >> s;
	int count = 0;
	rep(i,3){
		if(s[i] == 'A') count++;
	}
	if(count==0 || count==3){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>N;
    if(N == 1){
        cout<<1<<endl;
        cout<<0<<endl;
    }else if(N == 2){
        cout<<2<<endl;
        cout<<0<<endl;
        cout<<11<<endl;
    }else{
        cout<<N - 1<<endl;
        rep(i,N - 1){
            cout<<0;
            rep(j, i) cout<<1;
            cout<<0<<endl;
        }
    }
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct Info{
	Info(string arg_city,int arg_P,int arg_index){
		city = arg_city;
		P = arg_P;
		index = arg_index;
	}
	bool operator<(const struct Info &arg) const{

		if(city != arg.city){

			return city < arg.city;
		}else{

			return P > arg.P;
		}
	}
	string city;
	int P,index;
};

int main(){

	int N;
	scanf("%d",&N);

	vector<Info> V;

	for(int i = 1; i <= N; i++){

		string tmp_str;
		int P;

		cin >> tmp_str >> P;

		V.push_back(Info(tmp_str,P,i));
	}

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

	for(int i = 0; i < V.size(); i++){

		printf("%d\n",V[i].index);
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int ab = stdIn.nextInt();
        int bc = stdIn.nextInt();
        //int c = stdIn.nextInt();
        //int w = stdIn.nextInt();
        //int n = stdIn.nextInt();
        //int k = stdIn.nextInt();
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //boolean heisei = true;
        
        System.out.println(ab * bc / 2);
        
        //System.out.println();
        //System.out.print();
    }
}


Measured memory_bytes: 23636
#include<stdio.h>
int f(int x)
{
	int k=0;
	while(x%2==0)
	{
		x=x/2;
		k++;
	}
	return k;
}
int main(void)
{
	int n,m,k,i,x,y;
	scanf("%d",&n);
	m=0;
	for(i=1;i<=n;i++)
	{
		k=f(i);
		if(k>m)
		{
			m=k;
			x=i;
		}
	}
	if(n==1)
	x=1;
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define LL long long
#define pii pair<int,int>
#define MEM(x) memset(x,0,sizeof(x))
using namespace std;
void solve(){
    char c[2000005];
    scanf("%s",c);
    int ans=0;
    for(int i = 0;c[i]!=0;i++){
        ans+=c[i]-'0';
    }
    if(ans%9)printf("No\n");
    else printf("Yes\n");
}
int main()
{
    int t=1;
    //scanf("%d",&t);
    int T=1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef complex<long double> cmplx;
const long double pi = 3.14159265358979323846;
const int inf = (int)2e+9 + 2;
const int mod = 1'000'000'007;//998244353;
const long double eps = 1e-8;
const int N = 100'005;

int n, m;
int a[100];

void solve(int test)
{
  cin >> n;
  int s = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s += a[i];
  }
  int p = 0;
  for (int i = 1; i < n; ++i) {
    if (abs(s - a[p] * n) > abs(s - a[i] * n))
        p = i;
  }
  cout << p;
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
      solve(i);
  //cout << endl << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count();
  return 0;
}



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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
    char a;
    cin>>a;
     a++;
     cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll X,K,D;
    cin>>X>>K>>D;
    if(X<0)X=-X;
    ll count=X/D;
    if(count>K){
        cout<<X-K*D<<endl;
        return 0;
    }
    K-=count;
    X-=count*D;
    if(K%2){
        cout<<D-X<<endl;
    }else{
        cout<<X<<endl;
    }

}

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


int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;

	string ans = ":(";
	if (e - a <= k) {
		ans = "Yay!";
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>

#define mod 1000000007
#define MAX_N 100000

using namespace std;

char C[200001];

int main()
{
    int N, i, red, white, minimum, left_white, right_red;

    scanf("%d%s", &N, C);

    red = white = 0;
    for(i = 0; i < N; ++i)
        if(C[i] == 'R')
            ++red;
        else
            ++white;

    left_white = 0;
    for(i = 0; i < red; ++i)
        if(C[i] == 'W')
            ++left_white;
    right_red = 0;
    for(i = red; i < N; ++i)
        if(C[i] == 'R')
            ++right_red;

    minimum = min(left_white, right_red);
    left_white -= minimum;
    right_red -= minimum;
    minimum += left_white + right_red;

    printf("%d", minimum);

    return 0;
}


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

const ll MOD = 998244353;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> l(k), r(k);
    rep(i, k) cin >> l[i] >> r[i];
    vector<ll> dp(n + 1, 0), imos(n + 1, 0);
    imos[0] = 1;
    rep(i, n) {
        if (i > 0) imos[i] += imos[i - 1];
        imos[i] %= MOD;
        rep(j, k) {
            imos[min(i + l[j], n)] += imos[i];
            imos[min(i + l[j], n)] %= MOD;
            imos[min(i + r[j] + 1, n)] -= imos[i];
            imos[min(i + r[j] + 1, n)] %= MOD;
            if (imos[min(i + r[j] + 1, n)] < 0) imos[min(i + r[j] + 1, n)] += MOD;
        }
        imos[0] = 0;
    }
    cout << imos[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 6424
N,K = map(int,input().split())
A = []
for i in range(K):
    d1 = int(input())
    a = list(map(int,input().split()))
    A.append(a)
ans = {i:0 for i in range(1,N+1)}
for a in A:
    for d in a:
        ans[d] = 1
ans2 = 0
for j in ans.keys():
    if ans[j] == 0:
        ans2 += 1
print(ans2)

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

typedef long l;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int DX[] = {1, 0, -1, 0, 1, 1, -1, -1}, DY[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

  cin >> a >> b;
  int c = b - a;
  int r = 0;
  
  FOR(i, 1, c) {
    r += i;
  }

  cout << r - a << endl;

}



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

namespace CSharpSample01
{


    class Program
    {

        static long Solve(int N, int[,] a)
        {
            long[,] dp = new long[N + 1, 3];
            
            for(int j = 0; j < 3; j++)
            {
                dp[0, j] = 0;
            }
            
            for(int i = 1; i <= N; i++)
            {             
                for(int j = 0; j < 3; j++)
                {
                    for(int k = 0; k < 3; k++)
                    {
                        if (k == j) continue;
                        dp[i, j] = Math.Max(dp[i, j], dp[i - 1, k] + a[i - 1, j]);
                    }
                }

            }

            long max_happines = 0;
            for(int j = 0; j < 3; j++)
            {
                max_happines = Math.Max(max_happines, dp[N, j]);
            }

            return max_happines;
        }


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

            int[,] a = new int[N, 3];

            for(int i = 0; i < N; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                for(int j = 0; j < 3; j++)
                {
                    a[i, j] = int.Parse(input[j]);
                }
            }

            Console.WriteLine(Solve(N, a));
        }
    }
}

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

int main(void){
    int w, d;
    while(cin>>w>>d){
        if(w+d==0) break;
        int h1[21], h2[21];
        int num;
        fill(h1, h1+21, 0);
        fill(h2, h2+21, 0);
        for(int i=0; i<w; i++){
            cin >> num;
            h1[num]++;
        }
        for(int i=0; i<d; i++){
            cin >> num;
            h2[num]++;
        }
        int sum=0;
        for(int i=0; i<21; i++){
            sum+=max(h1[i]*i, h2[i]*i);
        }
        cout << sum << "\n";
    }
    
}



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

int main () {
    int a, b;
    cin >> a >> b;
    if (a >= 10) {
        cout << "-1";
    } else if (b >= 10) {
        cout << "-1";
    } else {
        int c = a*b;
        cout << c;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n, m, t[1000], p[1000], x[1000],count=0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> t[i];
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> x[i];
		for (int j = 0; j < n; j++) {
			if (j == p[i]-1)count += x[i];
			else count += t[j];
		}
		cout << count << endl;
		count = 0;
	}
	int z;
	cin >> z;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
int A, B, C, K;

void fastio() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

int main() {
  fastio();
  std::cin >> A >> B >> C >> K;
  std::cout << std::min(K, A) - std::min(std::max(K - A - B, 0), C) << '\n';
  return 0;
}

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


int main()
{
    string s;
    cin >> s;


    bool isAns = false;    
    for( int len = 0; len < s.size(); ++len ){
        if( s[len] == s[len+1] ){
            cout << len+1 << " " << len+2 << endl;
            isAns = true;
            break;
        }
        if( s[len] == s[len+2] ){
            cout << len+1 << " " << len+3 << endl;
            isAns = true;
            break;
        }
    }
    if( !isAns ) cout << -1 << " " << -1 << endl;

    return 0 ;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,dp[200005],num[200005],x,y,cnt;
vector<int> bi[200005];
int tr[800005];
struct segment_tree
{
    int l,r;
    int sum,add;
    void update(int x)
    {
        sum=max(sum,x);
        add=max(add,x);
    }
}c[400005];
void pushdown(int id)
{
    if (c[id].add)
    {
        c[id*2].update(c[id].add);
        c[id*2+1].update(c[id].add);
        c[id].add=0;
    }
}
void pushup(int id)
{
    c[id].sum=max(c[id*2].sum,c[id*2+1].sum);
}
void build(int id,int l,int r)
{
    c[id].l=l; 
	c[id].r=r;
    c[id].sum=0; 
	c[id].add=0;
    if(l==r) c[id].sum=-1<<30;
    else
    {
        int mid=l+(r-l)/2;
        build(id*2,l,mid);
        build(id*2+1,mid+1,r);
        pushup(id);
    }
}
void update(int id,int le,int ri,int x)
{
    if (le>c[id].r||ri<c[id].l) return;
    if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);
    else
    {
        pushdown(id);
        update(id*2,le,ri,x);
        update(id*2+1,le,ri,x);
        pushup(id);
    }
}
int query(int id,int le,int ri)
{
    if (ri<c[id].l||c[id].r<le) return -1<<30;
    if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;
    pushdown(id);
    return max(query(id*2,le,ri),query(id*2+1,le,ri));
}
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",num+i);
		if (num[i]==0) cnt++;
	}
	scanf("%d",&m);
	for (i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		bi[x].push_back(y);
	}
	build(1,0,n);
	update(1,0,0,0);
	for (i=1;i<=n;i++)
	{
		for (j=0;j<bi[i].size();j++)
		{
			update(1,bi[i][j],bi[i][j],query(1,i-1,bi[i][j]));
		}
		if (num[i]) update(1,i,i,query(1,i-1,i-1)-1);
			else update(1,i,i,query(1,i-1,i-1)+1);
	}
	cout<<cnt-query(1,n,n);
	return 0;
}

Measured memory_bytes: 19072
import numpy as np
import itertools
import sys
N,M,X=map(int, input().split())

i=0
lst = []
while i < N:
    m = map(int, input().split())
    lst.append(list(m))
    i+=1
arr = np.array(lst)

#Xに至らなかったとき
if np.min(np.sum(arr[:,1:], axis=0)) < X:
    print(-1)
    sys.exit()
data = arr[:,1:]
res = []
for i in range(1,N+1):
    for conbi in itertools.combinations(lst, i):
        arrx = np.array(conbi)
        if np.min(np.sum(arrx[:,1:], axis=0)) >= X:
            res.append(np.sum(arrx[:,0]))

print(min(res))


Measured memory_bytes: 27468
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}

std::vector<int> Factorial(5e6),Finverse(5e6);
void Cinit(){// limit is 5e6 /// write Cinit&pw /// this takes 792ms at AtCoder
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=Factorial[i-1]*i%MOD;
  for(int i=0;i<5e6;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 1;if(k<0)return 0;
  int res=Factorial[n];
  res*=Finverse[k];res%=MOD;
  res*=Finverse[n-k];res%=MOD;
  return res;
}

signed main(){
  Cinit();
  int x,y;cin>>x>>y;
  int ans=0;
  if(x>y)swap(x,y);
  int a=y-x;
  int sum=x+y;
  if(sum%3)fin(0);
  sum/=3;
  int t=sum-a;
  if(t&1)fin(0);
  if(t<0)fin(0);
  cout<<nCk(sum,t/2)<<endl;
}


Measured memory_bytes: 78464