akhauriyash/Code-Regression huggingface dataset:
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<ii, ii>> vii;

const int MAXN = (int)1e5 + 5;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n;
    cin >> n;
    long long ans = 0;
    int mn = INT_MAX;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        if (a == b)
            ++cnt;
        ans += a;
        if (a > b) {
            mn = min(mn, b);
        }
    }

    if (cnt == n) {
        cout << 0 << '\n';
        return 0;
    }
    if (mn == INT_MAX)
        mn = 0;
    cout << ans - mn << '\n';

    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int x = 0, y = 0;
    int n; cin >> n;
    int v[21], c[21];
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    
    for (int i = 0; i < n; i++) {
        if (v[i] > c[i]) {
            x += v[i];
            y += c[i];
        }
    }
    
    cout << x - y << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	int n;
	cin >> n;
	
	map<string, int> u;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		u[s]++;
	}
	
	cout << "AC x " << u["AC"] << endl;
	cout << "WA x " << u["WA"] << endl;
	cout << "TLE x " << u["TLE"] << endl;
	cout << "RE x " << u["RE"] << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String i1[]=br.readLine().split(" ");
		int n=Integer.parseInt(i1[0]);
		int k=Integer.parseInt(i1[1]);
		
		long a[]=new long[n+1];
		int count=0;
		String line = br.readLine();
		while ( line != null  &&  !line.equals("")) {
		    
	    	int snack=Integer.parseInt(line);
			String users[]=br.readLine().split(" ");
			for(int i=0;i<users.length;i++)
			{
				a[Integer.parseInt(users[i])-1]++;
			}
			
			line=br.readLine();
		}
		for(int i=0;i<n;i++)
		{
			if(a[i]==0)
			{
				count++;
			}
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 33488
x,y = map(int,input().split())
if abs(x) == abs(y):
  print(0 if x == y else 1)
elif x < y:
  print(min(y - x,abs(y + x) + 1))
else:
  print(min(abs(y+x),abs(y-x))+ 1 if x * y <= 0 else min(abs(y+x),abs(y-x))+ 2)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


ll mod=1000000007;
ll vis[212345]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}


//extended euclidean algorithm( x is inverse of a wrt b onlt if gcd!=1)
ll gcd(ll a,ll b,ll &x,ll &y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1,y1;
	ll d=gcd(b,a%b,x1,y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;

}


int main()
{
speed
ll x,n,t;
cin>>n>>x>>t;
cout<<((n-1)/x+1)*t<<endl;

}



Measured memory_bytes: 8124
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (int i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
#define ld long double

int solve(){
	int n;
	cin>> n;
	set<string> s;
	rep(i, 0, n){
		string x;
		cin>> x;
		s.insert(x);
	}
	cout<< s.size();
	return 0;
}
 
int main()
{
	fast;
	int t = 1;
	//cin>> t;
	while(t--){  
		solve();
	}
	return 0;
}
//upper_bound returns an iterator pointing to the 
//first element in the range [first,last) which has a value greater than ‘val’

Measured memory_bytes: 19292
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	vector<int> l;
	for(int i=0;i<n;i++)
	{
		int k;cin>>k;
		l.push_back(k);
	}
	sort(l.begin(),l.end());
	int sum=0;
	for(int i=0;i<n-1;i++)
	{
		sum+=l[i];
	}
	if(l[n-1]<sum) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys

if __name__ == "__main__":
    para_list = list(map(int, input().split()))
    N = para_list[0]
    M = para_list[1]

    A = [[0]*2]*N
    for i in range(N):
        A[i] = list(map(int, input().split()))
    B = sorted(A,key=lambda l:l[0])

    price = 0
    k = 0
    while(M>0):
        if M<B[k][1]:
            price +=B[k][0]*M
        else:
            price +=B[k][0]*B[k][1]
        M -= B[k][1]
        k += 1
    print(price)

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここからコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


/////////////////////////
// Range Minimum Query //
/////////////////////////

class RangeMinimumQuery {
private:
	std::vector<int64_t> container_;
	const int64_t inf_{(1ll << 31) - 1};
	void build(const unsigned int array_size)
	{
		unsigned int length{1};
		while (length < array_size)
			length <<= 1;
		container_.resize(2 * length, inf_);
	}

public:
	RangeMinimumQuery(const unsigned int array_size) { build(array_size); }
	RangeMinimumQuery(const std::vector<int64_t> &array)
	{
		build(array.size());
		std::copy(array.begin(), array.end(), container_.begin() + (container_.size() >> 1));
		for (auto i{(container_.size() >> 1) - 1}; i > 0; i--)
			container_[i] = std::min(container_[2 * i], container_[2 * i + 1]);
	}
	// indexは0-indexed
	void update(const int index, const int64_t assigned)
	{
		auto update_place{(container_.size() >> 1) + index};
		container_[update_place] = assigned;
		while (update_place > 1)
		{
			update_place >>= 1;
			container_[update_place] = std::min(container_[2 * update_place], container_[2 * update_place + 1]);
		}
	}
	// left,rightは0-indexed、[left, right)の半開区間
	int64_t get(const int left, const int right) const
	{
		int64_t min{inf_};
		for (int left_i{std::max(0, left) + ((int)container_.size() >> 1)}, right_i{std::min((int)container_.size() >> 1, right) + ((int)container_.size() >> 1)};
			left_i < right_i; left_i >>= 1, right_i >>= 1
			)
		{
			if (left_i & 1)
			{
				min = std::min(min, container_[left_i]);
				left_i++;
			}
			if (right_i & 1)
			{
				right_i--;
				min = std::min(min, container_[right_i]);
			}
		}
		return min;
	}
};


//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここまでコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A
// この問題ではinf_を(1ll << 31) - 1に書き換える必要がある
int main()
{
	int n, q;
	scanf("%d%d", &n, &q);
	RangeMinimumQuery rmq(n);
	for (int i{}; i < q; i++)
	{
		int com, x, y;
		scanf("%d%d%d", &com, &x, &y);
		if (!com) rmq.update(x, y);
		else printf("%lld\n", rmq.get(x, y + 1));
	}
	return 0;
}



Measured memory_bytes: 4924
M=10**9+7
n,*a=$<.read.split.map &:to_i
a.sort!
if n.odd?
    ok=(a[0]==0)
    1.step(n-1, 2){|i| ok=false if a[i]!=a[i+1] or a[i]!=i+1}
    p (ok ? (1<<n/2)%M : 0)
else
    ok=true
    0.step(n-1, 2){|i| ok=false if a[i]!=a[i+1] or a[i]!=i+1}
    p (ok ? (1<<n/2)%M : 0)
end


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

using namespace std;

int main()
{
    long long int n,sum=0,y=0,m,diff,sum1=0;
    cin>>n;
    long long int a[n],x[n-1];
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
        if(i!=n-1)
        {
            x[i]=sum;
        }
        sum1=sum1+abs(a[i]);
    }
    m=sum1;
    for(long long int i=0;i<n-1;i++)
    {
        y=sum-x[i];
        //cout<<x<<" "<<y<<endl;
        diff=abs(x[i]-y);
        //cout<<diff<<endl;
        if(m>diff)
            m=diff;
    }
    cout << m;
    return 0;
}


Measured memory_bytes: 3328
from bisect import *
n, m, k = map(int, input().split())
A = [*map(int, input().split())]
B = [*map(int, input().split())]
tot = sum(B)
ans, j = 0, m
for i in range(n+1):
    while j > 0 and tot > k:
        j -= 1
        tot -= B[j]
    if tot > k: break
    if i < n: tot += A[i]
    ans = max(ans, i+j)
print(ans)


Measured memory_bytes: 40528
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
using static Atcoder.IO;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = RLong;
            var a = RSLong;

            Array.Sort(a);
            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                long l1 = a[i];
                long l2 = 0;
                long l3 = 0;
                for (int j = i + 1; j < N; j++)
                {
                    if (l1 != a[j])
                    {
                        l2 = a[j];
                        for (int k = j + 1; k < N; k++)
                        {
                            if (l2 != a[k])
                            {
                                l3 = a[k];
                                if (l1 + l2 > l3 && l1 + l3 > l2 && l2 + l3 > l1)
                                    ans++;
                            }
                        }
                    }
                }
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF INT_MAX

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

ll pac[52][52];

void  Comb() {
	rep(i, 51) {
		rep(j, i + 1) {
			if (j == 0 || j == i) pac[i][j] = 1;
			else pac[i][j] = pac[i - 1][j - 1] + pac[i - 1][j];
			//printf("%lld ", pac[i][j]);
		}
		//printf("\n");
	}
}

int main() {
	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);
	ll v[50];
	rep(i, N) scanf("%lld", &v[i]);
	Comb();
	sort(v, v + N);
	reverse(v, v + N);
	long double ans = 0;
	rep(i, A) ans += v[i];
	ans /= A;
	int cnt = 0, r = 0;
	rep(i, N) {
		if (v[i] == v[A - 1]) {
			++cnt;
			if (i < A) ++r;
		}
	}
	ll res = 0;
	if (v[0] != v[A - 1]) res += pac[cnt][r];
	else FOR(i, A, B + 1) res += pac[cnt][i];
	printf("%.7Lf\n%lld\n", ans, res);
	return 0;
}

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

int A[101];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N, sum;
    cin >> N >> sum;
    
    for(int i=1; i<=N; i++)
        cin >> A[i];
    
    sort(A+1, A+1+N);
    
    for(int i=1; i<=N; i++)
    {
        sum -= A[i];
        
        if(sum < 0)
        {
            cout << i-1 << "\n";
            return 0;
        }
    }
    
    cout << N - (sum > 0) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1001][1001],b[1001][1001];
int main()
{
  string n,m;
  cin>>n;
  if(n[0]=='Y'&&n[1]=='A'&&n[2]=='K'&&n[3]=='I')
        cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;     
  return 0;	
}

Measured memory_bytes: 256
n = int(input())

ac=0
wa=0
tle=0
re=0

for i in range(n):
  result = input()
  if result == "AC":
    ac += 1
  elif result == "WA":
    wa += 1
  elif result == "TLE":
    tle += 1
  else:
    re += 1

print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))


Measured memory_bytes: 9192
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

void main() {
    int n = readint();
    string s = readln.chomp;
    
    int ans;
    foreach (i; 1..n) {
        auto a = s[0..i];
        auto b = s[i..n].dup.array.sort().release.uniq;
        int cnt = b.filter!(c => count(a, c) > 0)
            .array
            .length
            .to!int;
        ans = max(ans, cnt);
    }
    writeln(ans);

    string _ = readln;
}


Measured memory_bytes: 316
from collections import Counter
from itertools import permutations

def main():
    N, C = map(int, input().split())
    D = tuple(tuple(map(int, input().split())) for _ in range(C))

    cnt = [Counter() for _ in range(3)]

    for i in range(N):
        c = [int(x)-1 for x in input().split()]
        for j in range(3):
            cnt[j].update(c[(3-(i+2)+j)%3::3])

    ans = 1000*500*500+5
    for p in permutations(range(C), 3):
        s = 0
        for j in range(3):
            s += sum(D[k][p[j]] * v for k, v in cnt[j].items())
        if s < ans: ans = s
    print(ans)

main()


Measured memory_bytes: 3436
#include <stdio.h>

int main(){
    int a, i;
    
    scanf("%d", &a);

    if (a == 1 || a == 2 || a == 4){
        printf("%d", 4);
    }
    
    else
    {
        for (i = 1; i < 1000000; i++){
        if (a % 2 == 0)
            a = a / 2;
        else
            a = 3 * a + 1;
        if (a == 4){
            printf("%d", i + 4);
            break;
            }
        }
    }
    
    

    return 0;
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int p = 1e9+7;
const int N = 2e5+4;
vector<int >fact(N);
//vector<int >invf(N);
int add(int a,int b){
    int s=(a+b);
    if(s>=p)s-=p;
    return s;
}
int sub(int a,int b){
    int s=(a+p-b);
    if(s>=p)s-=p;
    return s;
}
int mul(int a,int b){
    return (1LL*a*b)%p;
}
int po(int a,int deg){
    
    if(deg==0)return 1;
    int temp = po(a,deg/2);
    temp = mul(temp,temp);
    if(deg%2!=0)temp=mul(temp,a);
    return temp;
    
}
int inv(int n){
    return po(n,p-2);
}
int main(){
    fact[0]=1;
    for(int i=1;i<N;i++)fact[i] = mul(fact[i-1],i);
    //invf[N-1]=inv(fact[N-1]);
    //for(int i=N-2;i>=0;i--)invf[i] = mul(invf[i+1],i+1);
	int n,x,y;cin>>n>>x>>y;
	int temp1=1,temp2=1;
	for(int i=0;i<x;i++)temp1 = mul(temp1,n-i);
	for(int i=0;i<y;i++)temp2 = mul(temp2,n-i);
	int onechan = mul(temp1,inv(fact[x]));
	int dochan = mul(temp2,inv(fact[y]));
    cout<<sub(po(2,n),add(1,add(onechan,dochan)));
}

Measured memory_bytes: 3852
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3, x4, y3, y4; 
  x3 = x2 - (y2 - y1);
  y3 = y2 + (x2 - x1);
  x4 = x1 - (y2 - y1);
  y4 = y1 + (x2 - x1);
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)
*/

f(T, [A, B, C, _, _, _, _, _, _]) :- rb_lookup(A, _, T), rb_lookup(B, _, T), rb_lookup(C, _, T).
f(T, [_, _, _, A, B, C, _, _, _]) :- rb_lookup(A, _, T), rb_lookup(B, _, T), rb_lookup(C, _, T).
f(T, [_, _, _, _, _, _, A, B, C]) :- rb_lookup(A, _, T), rb_lookup(B, _, T), rb_lookup(C, _, T).
f(T, [A, _, _, B, _, _, C, _, _]) :- rb_lookup(A, _, T), rb_lookup(B, _, T), rb_lookup(C, _, T).
f(T, [_, A, _, _, B, _, _, C, _]) :- rb_lookup(A, _, T), rb_lookup(B, _, T), rb_lookup(C, _, T).
f(T, [_, _, A, _, _, B, _, _, C]) :- rb_lookup(A, _, T), rb_lookup(B, _, T), rb_lookup(C, _, T).
f(T, [A, _, _, _, B, _, _, _, C]) :- rb_lookup(A, _, T), rb_lookup(B, _, T), rb_lookup(C, _, T).
f(T, [_, _, A, _, B, _, C, _, _]) :- rb_lookup(A, _, T), rb_lookup(B, _, T), rb_lookup(C, _, T).

g(N, T) :- rb_empty(T2), g(N, T2, T).
g(0, T, T).
g(N, T, T2) :-
    get_number(X),
    rb_insert(T, X, 0, T3),
    N2 is N - 1,
    g(N2, T3, T2).

main :-
    get_numbers(9, Xs),
    get_number(N),
    g(N, T),
    f(T, Xs) -> writeln("Yes") ; writeln("No").

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8156
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int MAXN = 100005;
 
ll cnt;
ll dcnt[MAXN];
ll x[MAXN];
ll y[MAXN];
int esum[MAXN];
int edif[MAXN];
bool visited[MAXN];
vector<ll> g[MAXN];
map <ll, vector <pair <ll, int> > > msum, mdif;
 
void dfs(int v)
{
    visited[v] = true;
    cnt += dcnt[v];
    for (int i = 0; i < g[v].size(); i++)
    {
        if (!visited[g[v][i]])
        {
            dfs(g[v][i]);
        }
    }
}
 
void edgeToLine(int v, auto *vect, ll lx, ll rx, auto *e)
{
    auto l = lower_bound(vect->begin(), vect->end(), mp(lx, -228));
    auto r = upper_bound(vect->begin(), vect->end(), mp(rx, MAXN))-1;
    if (r<l) return;
    dcnt[v] += max(int(r - l) + 1, 0);
    
    int lv = l->second;
    int rv = r->second;
    
    g[v].pb(lv);
    g[lv].pb(v);
 
    if (e[v] == 0 || x[e[lv]] < x[rv])
    {
        e[v] = rv;
    }
}
 
void realEdges(auto *m, auto *e)
{
    for (auto it = m.begin(); it != m.end(); it++)
    {
        auto vect = it->second;
 
        int r = 0;
        for (int i = 0; i < vect.size()-1; i++)
        {
            int v = vect[i]->second;
            int next = vect[i+1]->second;
            int to = e[v];
            if (to != 0 && (r == 0 || (x[r] < x[to])))
            {
                r = to;
            }
            if (x[r] >= x[next])
            {
                g[v].pb(next);
                g[next].pb(v);
            }
        }
    }
}
 
int main()
{
   // freopen("input.txt", "r", stdin);
    int n;
    ll a, b;
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i] >> y[i];
        msum[x[i]+y[i]].push_back({x[i], i});
        mdif[x[i]-y[i]].push_back({x[i], i});
    }
 
    for (auto it = msum.begin(); it != msum.end(); it++)
        sort(it->second.begin(), it->second.end());
    for (auto it = mdif.begin(); it != mdif.end(); it++)
        sort(it->second.begin(), it->second.end());
 
 
    ll d = max(x[a] - x[b], -(x[a] - x[b])) + max(y[a] - y[b], -(y[a] - y[b]));
 
    for (int i = 1; i <= n; i++)
    {
        ll line;
 
        line = x[i]+y[i]+d;
        if (msum.find(line) != msum.end())
        {
            edgeToLine(i, &msum[line], x[i], x[i]+d, esum);
        }
 
        line = x[i]+y[i]-d;
        if (msum.find(line) != msum.end())
        {
            edgeToLine(i, &msum[line], x[i]-d, x[i], esum);
        }
 
        line = x[i]-y[i]+d;
        if (mdif.find(line) != mdif.end())
        {
            edgeToLine(i, &mdif[line], x[i]+1, x[i]+d-1, edif);
        }
 
        line = x[i]-y[i]-d;
        if (mdif.find(line) != mdif.end())
        {
            edgeToLine(i, &mdif[line], x[i]-d+1, x[i]-1, edif);
        }
    }
 
 
 
    dfs(a);
    cout << cnt / 2;
 
    return 0;
}

Measured memory_bytes: 31744
import java.util.*;
import java.math.*;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		char op = sc.next().charAt(0);
		int b=sc.nextInt();
		
		if(op=='+') {
			System.out.println(a+b);
		}else {
			System.out.println(a-b);
		}
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string S;
    int w, i;

    cin >> S >> w;

    for(i=0; i<S.size(); i++){
        if(i % w == 0){
            cout << S.at(i);
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

int main()
{

  int  m,f,r;
  char s;

  for (;;)
  {

    scanf("%d %d %d\n", &m,&f,&r);
    if (m==-1 && f==-1 && r==-1)  break;

    if (m==-1 || f==-1)
    {
      s='F';
    }
    else
    {
        if (m+f>=80)
        {
          s='A';
        }

        if (m+f>=65 && m+f<80)
        {
          s='B';
        }

        if (m+f>=50 && m+f<65)
        {
          s='C';
        }

        if (m+f>=30 && m+f<50)
        {
          if (r>=50)
          {
            s='C';
          }
          else
          {
            s='D';
          }
        }

        if (m+f<30)
        {
          s='F';
        }

    }

    printf("%c\n",s );

  }






  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a > b)
    {
        cout << 2 * a - 1;
    }
    else if(a < b)
    {
        cout << 2 * b - 1;
    }
    else
    {
        cout << a + b;
    }
    
    return 0;
}

Measured memory_bytes: 256
package main

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

type runes []rune

func (a runes) Len() int           { return len(a) }
func (a runes) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a runes) Less(i, j int) bool { return a[i] < a[j] }

func main() {
	s := []rune(getString())

	sort.Sort(runes(s))

	ans := "No"
	if s[0] == s[1] && s[2] == s[3] && s[0] != s[2] {
		ans = "Yes"
	}

	fmt.Println(ans)
}

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

var scanner = wordScanner()

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

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

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

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


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define ceil_div(a,b) ((a+(b-1))/b)
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}


int main(){
    int n; string s; IN(n, s);
    int ans = 0;
    char old  = '-';
    rep(i, 0, n){
        if(s[i] != old) {
            ans++;
            old = s[i];
        }
    }
    cout << ans << el;
    return 0;
}


Measured memory_bytes: 3268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		int countOdd = 0;
		int countEven = 0;
		int fourTimes = 0;
		
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (a % 2 == 0) {
				countEven++;
				if (a % 4 == 0) {
					fourTimes++;
				}
			} else {
				countOdd++;
			}
		}
		sc.close();
		
		if (n % 2 == 0) {
			if (fourTimes >= countOdd) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			if (fourTimes >= countOdd - 1) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

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

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
         
        var primeFactors = PrimeFactors(n);
        //primeFactors.Dump();
         
        string output = primeFactors.Count() == 0 
                        ? n.ToString() 
                        : string.Join(" ", primeFactors.Select (f => f.ToString()).ToArray()); //AOJ??¨
                        //:string.Join(" ", primeFactors);
        Console.WriteLine("{0}: {1}", n, output);
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i <= n)
        {
            if(n % i == 0){
                n /= i;
                yield return i;
            }else{
                i++;
            }
             
            if(i > Math.Sqrt(tmp)){
                i = int.MaxValue; //???????????????
                yield return n;
            }
        }
    }
}

Measured memory_bytes: 20328
#include <cstdio>
#include <algorithm>
using namespace std;

constexpr int MAX_A = 2001;
constexpr int MOD = 1000000007;

int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	int A[N];
	int cnt[MAX_A];
	fill(cnt, cnt + MAX_A, 0);
	for(int i = 0; i < N; i++) {
		scanf("%d", A + i);
		cnt[A[i]]++;
	}

	long long ans = 0;
	int acc = 0;
	for(int i = 0; i < MAX_A; i++) {
		ans += cnt[i] * acc;
		ans %= MOD;
		acc += cnt[i];
	}
	ans *= ((long long)K * (K - 1) / 2) % MOD;
	ans %= MOD;

	for(int i = 0; i < N; i++) {
		for(int j = 0; j < i; j++) {
			if(A[j] > A[i]) {
				ans += K;
				ans %= MOD;
			}
		}
	}

	printf("%lld\n", ans);
	return 0;
}


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

class Main {
	public static void main(String[] args) throws IOException {
    	Scanner sc = new Scanner(System.in);
      	int n = Integer.parseInt(sc.next());
      	int k = Integer.parseInt(sc.next());
      	int enterCnt = 0; 
      
      	for (int i = 0; i < n; i++) {
        	int h = Integer.parseInt(sc.next());
          	if (k <= h) { enterCnt++; }
        }
      
      	System.out.println(enterCnt);
    }
}

Measured memory_bytes: 43236
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
// driver code 
int main() 
{ 
    int n,q;
    cin>>n>>q;
    int a[n+1];
    for(int i=0;i<n;i++)cin>>a[i];
    Query queries[q+1];
    for(int i=0;i<q;i++)
    {
        int x,y;
        cin>>x>>y;
        queries[i].l =x-1; 
        queries[i].r = y-1; 
        queries[i].idx = i; 
    } 
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-b*2)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX_N 100

int K[MAX_N];
int P[MAX_N];

int solve(int i){

    if(K[i] % P[i] == 0){
        return P[i];
    }else{
        return K[i] % P[i];
    }
}

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

    if(N>0){
        for(int i=0;i<N;++i){
            cin >> K[i] >> P[i];
        }
        for(int i=0;i<N;++i){
            cout << solve(i) << endl;
        }
    }
}

Measured memory_bytes: 1160
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}



fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let s: String = sc.read();
    let s: Vec<char> = s.chars().collect();
    let n = s.len();
    let mut ans = s.len();
    for i in 1..n {
        if s[i] != s[i - 1] {
            ans = min(ans, max(i, n - i));
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
int n;
vector<ll> a;
void FWT(vector<ll> &v){
	int m=v.size();
	for(int i=1; i<m; i<<=1){
		for(int j=0; j<m; j++){
			if((i&j)==0){
				ll x=v[j], y=v[j^i];
				v[j]=x+y, v[j^i]=x-y+MOD;
				if(v[j]>=MOD) v[j]-=MOD;
				if(v[j^i]>=MOD) v[j^i]-=MOD;
			}
		}
	}
}
int main()
{
	cin>>n;
	a.resize(1<<n);
	ll s=0;
	for(int i=0; i<(1<<n); i++){
		cin>>a[i];
		s+=a[i];
	}
	s=inv(s);
	for(int i=0; i<(1<<n); i++){
		a[i]=a[i]*s%MOD;
	}
	vector<ll> a1=a;
	FWT(a);
	vector<ll> ans(1<<n);
	ll t=0;
	for(int i=1; i<(1<<n); i++){
		ans[i]=inv((a[i]-1+MOD)%MOD);
		(t+=ans[i])%=MOD;
	}
	ans[0]=(MOD-t)%MOD;
	FWT(ans);
	for(int i=0; i<(1<<n); i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int card[4][13] = { {} };
	char a;
	int b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		switch (a) {
		case 'S':
			card[0][b - 1] = 1;
			break;
		case 'H':
			card[1][b - 1] = 1;
			break;
		case 'C':
			card[2][b - 1] = 1;
			break;
		case 'D':
			card[3][b - 1] = 1;
			break;
		}
	}
	for (int j = 0; j < 52; j++) {
		switch (j / 13) {
		case 0:
			if (card[0][j % 13] == 0) {
				cout << "S " << j + 1 << endl;
			}
			break;
		case 1:
			if (card[1][j % 13] == 0) {
				cout << "H " << j%13 + 1 << endl;
			}
			break;
		case 2:
			if (card[2][j % 13] == 0) {
				cout << "C " << j % 13 + 1 << endl;
			}
			break;
		case 3:
			if (card[3][j % 13] == 0) {
				cout << "D " << j % 13 + 1 << endl;
			}
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3084
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
const int MOD = (int)1e9 + 7;
const int MAX_N = 10000;  // 400MB
using namespace std;

long long nCr(int n,int r){/*
	if(r>n-r)r=n-r;
	if(r==0 || n==r){
		return 1;
	}
	return (nCr(n-1,r)+nCr(n-1,r-1))%MOD;*/
    static bool done[MAX_N + 1][MAX_N / 2 + 2];
    static long long dp[MAX_N + 1][MAX_N / 2 + 2];  // 400MB
    if (n < 0 || r < 0 || n < r) return 0;
    if (r == 0) return 1;
    if (r > n - r) r = n - r;
    long long &res = dp[n][r];
    if (done[n][r]) return res;
    done[n][r] = true;
    return res = (nCr(n - 1, r - 1) + nCr(n - 1, r)) % MOD;
}

int main(){
	int R=0,B=0;
	cin>>R>>B;
	R-=B;
	for(int i=1;i<=B;i++){
		if(R+1<i){
			cout<<"0"<<endl;
			continue;
		}
		int ans=1;
		ans=(nCr(B-1,i-1)*nCr(R+1,i))%MOD;
		cout<<ans<<endl;
	}
	return 0;
}


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

i64 dp[3005][6000];

int main()
{
  i64 n, t;
  cin >> n >> t;
  vector<pair<i64, i64>> d(n);
  for (i64 i = 0; i < n; i++)
    cin >> d[i].first >> d[i].second;
  sort(d.begin(), d.end());
  for (i64 i = 0; i < n; i++)
  {
    for (i64 j = 0; j < t; j++)
      dp[i + 1][j + d[i].first] = max(dp[i + 1][j + d[i].first], dp[i][j] + d[i].second);
    for (i64 j = 0; j < t + 3000; j++)
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
  }
  i64 ans = 0;
  for (i64 i = 0; i < t + 3000; i++)
    ans = max(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 140928
from sys import stdin

# n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
# data = [stdin.readline().rstrip().split() for _ in range(n)]

ans = len(s)
for c in range(ord('a'), ord('z')+1):
    cnt, cntMax = 0, 0
    for i in range(0, len(s)):
        if s[i] == chr(c):
            cntMax = max(cnt, cntMax)
            cnt = 0
            continue
        cnt += 1
    cntMax = max(cnt, cntMax)
    ans = min(ans, cntMax)
print(ans, '\n')
# print(*data, sep='\n')


Measured memory_bytes: 39856
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1)/*%mod*/;
  ll p = fastpow(nodess, num / 2);
 // p %= mod;
  p *= p;
 // p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return 
      abs(u.f - v.f)  + abs(u.se - v.se);
}



/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++; 
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 1e5 + 9;


int main()
{
    IO;
	int ans = 6;
	int a,b;
	cin>>a>>b;
	cout<<ans-a-b<<"\n";
	return 0;
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    vector<ll> lis(3, 0);
    ll k;
    cin >> lis[0] >> lis[1] >> lis[2] >> k;
    ll c, ans = 0;
    c = max(k - lis[0], 0LL);
    ans += abs(k-c);
    k = c;
    c = max(k-lis[1], 0LL);
    k = c;
    c = max(k-lis[2], 0LL);
    ans += (abs(k-c) * -1);
    cout << ans << endl;
}

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

int main(){
  int n, f, t = 0, h = 0;
  char c1[101], c2[101];
  scanf("%d", &n);
  while(n--){
    scanf("%s%s", c1, c2);
    f = strcmp(c1, c2);
    if(!f) t++,h++;
    else if(f > 0) t += 3;
    else if(f < 0) h += 3;
  }
  printf("%d %d\n", t, h);
  return 0;
}


Measured memory_bytes: 2132
fn input() -> String {
    let mut buf = String::new(); //A
    std::io::stdin().read_line(&mut buf).unwrap(); //B
    buf.trim().to_string() //C
}

fn main() {
    let line = &input();
    let seg: Vec<i32> = line
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    small_eq_large(seg);
}

fn small_eq_large(line: Vec<i32>) {
    match line[0] {
        d if d > line[1] => println!("a > b"),
        d if d == line[1] => println!("a == b"),
        d if d < line[1] => println!("a < b"),
        _ => (),
    }
}


Measured memory_bytes: 5024
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

out=0
XY = [0]*N
for i in range(N):
    XY[i] = V[i] - C[i]
    if XY[i]>0:
        out+=XY[i]

print(out)

Measured memory_bytes: 38256
function main()
  
  (A,B,K) = map(x -> parse(Int,x), split(readline()))
  
  check = Int[]
  
  for i in A:A+K-1
    if A <= i <= B
      println(i)
      push!(check,i)
    end
  end
  
  for i in B-K+1:B
    if A <= i <= B && in(i,check) == false
      println(i)
    end
  end
  
end

main()

Measured memory_bytes: 111980
package main

import "fmt"

func main() {
	var N int
	var ans int

	fmt.Scan(&N)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
		if (i+1)%2 != 0 && a[i]%2 != 0 {
			ans++
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 1772
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1e6+5;
int n,ans,res,sit,a[maxn],b[maxn];
int main()
{
	//ios::sync_with_stdio(false);
    //cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    for(int i=n;i>=1;i--)
		cin>>b[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[i])
		{
			bool flag=0;
			for(int j=1;j<=n;j++)
			{
				if(a[i]!=b[j]&&a[j]!=b[i])
				{
					swap(b[i],b[j]);
					flag=1;
					break;
				}
			}
			if(!flag)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;i++)
		cout<<b[i]<<" ";
	cout<<endl;
    return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 255;

int n, r[N];
long long f[N << 1][N], mod, ans = 0ll;
vector<pair<int, int> > vec;
int main () {
	scanf("%d%lld", &n, &mod);
	for (int i = 0; i < n; i++) {
		r[i] = min((n << 1) - 1, (int)sqrt(4 * n * n - i * i));
		vec.push_back(make_pair((int)sqrt(n * n - 1 - i * i), -i));
	}
	for (int i = n; i < (n << 1); i++) vec.push_back(make_pair((int)sqrt(4 * n * n - i * i), -i));
	sort(vec.begin(), vec.end());
	
	for (int i = 0; i < (n << 1); i++) vec[i].second *= -1;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= i; j++) f[0][j] = 0ll;
		f[0][0] = 1ll % mod;
		for (int j = 0, cnt = 0; j < vec.size(); j++) {
			if (vec[j].second >= n) {
				for (int k = 0; k <= i; k++) {
					f[j + 1][k] = f[j][k] * (vec[j].first + 1 - (j + k - cnt)) % mod;
				}
			}
			else {
				cnt++;
				for (int k = 0; k <= i; k++) {
					f[j + 1][k] = f[j][k] * (r[vec[j].second] + 1 - ((n << 1) - 1 - vec[j].second - k + i)) % mod;
					if (k) f[j + 1][k] = (f[j + 1][k] + f[j][k - 1] * (vec[j].first + 1 - (j + k - cnt))) % mod;
				}
			}
		}
		if (i & 1) ans = (ans + mod - f[n << 1][i]) % mod;
		else ans = (ans + f[n << 1][i]) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1280