akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int l,r;
int main()
{
	scanf("%d%d",&l,&r);
	if(r-l+1>=2020)
		printf("0");
	else
	{
		int ans=100000;
		for(int i=l;i<=r;i++)
			for(int j=l;j<i;j++)
				ans=min(ans,int(1ll*i*j%2019));
		printf("%d",ans);
	}
}


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

using namespace std;

int calc(vector<int> cup, int m)
{
    int cnt = 0;
    while (1) {
        int i = cnt%2, j = i+1;
        int p = 1;
        while (p <= max(cup[i], cup[j])) p <<= 1;
        p >>= 1;
        if (!p) break;
        cup[i] ^= p;
        cup[j] ^= p;
        cnt++;
        if (cnt > m) return cnt;
    }

    return cnt;
}

int main()
{
    while (1) {
        int n, m; cin >> n >> m;
        if (n == 0 && m == 0) break;
        vector<int> cup(3);
        loop (3, i) {
            int c; cin >> c;
            while (c--) {
                int v; cin >> v;
                cup[i] |= 1 << v+1;
            }
        }
        int ans = calc(cup, m);
        swap(cup[0], cup[2]);
        ans = min(ans, calc(cup, m));
        cout << (ans <= m ? ans : -1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}

Measured memory_bytes: 3648
fun main(args: Array<String>) {
    // 与えられた入力をスペースで区切った配列にする
    val inputs = readLine()!!.split(" ").map(String::toInt)
    // 1つめを取得
    var H = inputs[0]
    // 2つめを取得
    val A = inputs[1]

    var counter = 0
    do {
        H = H - A
        ++counter
    } while (H > 0)

    print(counter)
}

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

namespace y.miyoshi
{

    public class Queen8
    {
        static int Max = 8;
        static bool[] vertical;
        static bool[] diagonal1;
        static bool[] diagonal2;
        static Dictionary<byte, byte> queenDic;
        static byte[] skip;
        static bool finish;

        public static void Main()
        {
            var n = byte.Parse(Console.ReadLine());
            skip = new byte[n];
            queenDic = Enumerable.Range(0, n).Select(_ =>
            {
                var line = Console.ReadLine().Split();
                skip[_] = byte.Parse(line[0]);
                return new { x = byte.Parse(line[0]), y = byte.Parse(line[1])};
            }).ToDictionary(e => e.x, e=>e.y);

            Initialize();
            queenDic.ToList().ForEach(q => MarkBoad(q.Key, q.Value, true));

            Search8Queens(0);

        }

        public static void Search8Queens(byte x)
        {
            if (finish) return;

            if (x == Max)
            {
                Display();
                finish = true;
                return;
            }

            //?????????????????????????????????
            if (!skip.Contains(x))
            {
                for (byte i = 0; i < Max; i++)
                {
                    //????????????????
                    if (queenDic.ContainsKey(x)
                        || vertical[i] == true
                        || diagonal1[x + i] == true
                        || diagonal2[x - i + Max - 1] == true)
                        continue;

                    //??????
                    MarkBoad(x, i, true);
                    Search8Queens((byte)(x + 1));
                    //????????????
                    MarkBoad(x, i, false);
                }
            }
            else
            {
                Search8Queens((byte)(x + 1));
            }

        }

        public static void Display()
        {
            for (byte i = 0; i < Max; i++)
            {
                for (byte j = 0; j < Max; j++)
                {
                    if (queenDic[i] == j)
                        Console.Write('Q');
                    else
                        Console.Write('.');
                }
                Console.WriteLine();
            }
        }

        public static void MarkBoad(byte x, byte y, bool mark)
        {
            vertical[y] = mark;
            diagonal1[x + y] = mark;
            diagonal2[x - y + Max - 1] = mark;
            if (mark) queenDic[x] = y;
            else queenDic.Remove(x);
        }

        public static void Initialize()
        {
            vertical = new bool[Max];
            diagonal1 = new bool[2 * Max - 1];
            diagonal2 = new bool[2 * Max - 1];
        }
    }
}

Measured memory_bytes: 8764
let (a,b,c,x) = Scanf.scanf "%d\n%d\n%d\n%d\n" (fun a b c x ->a,b,c,x ) in

    let x' = if (x mod 50) = 0 then x/50 else 0 in


    let rec judge (x,a,b,c) =
      match x,a,b,c with
      | 0,_,_,_ -> 1
      | _,0,b,c ->
         begin
         match b,c with
         | 0,_ ->
            begin
            match c with
            | 0 -> 0
            | _ -> judge (x-1,0,0,c-1)
            end
         | _, _-> judge (x-2,0,b-1,c) + judge (x, 0, 0, c)
         end
        
      | _,a,b,c ->
         judge(x-10,a-1,b,c) + judge(x,0,b,c)
    in

    let ans = judge (x',a,b,c) in

    print_int ans
;;
  


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    SORT(a);
    SORT(b);
    if (n%2){
        PRINT(b[n/2]-a[n/2]+1);
    }
    else{
        ll ans = b[n/2-1]+b[n/2]-(a[n/2-1]+a[n/2])+1;
        PRINT(ans);
    }
}


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

    int main(void){
        int n; cin >> n;
        vector <int> v(n);
        for(int i=0; i<n; i++) cin >> v[i];
        sort(v.begin(), v.end());
        int sum=0;
        for(int i=0; i<n-1; i++)sum+=v[i];
        if(sum>v[n-1]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
const u32 P=1e9+7;
inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}
const int N=2e5+1;
int n, a[N], b[N], cnt[N], rank[N];
u32 bit[N], p[N], invp[N], q[N], invq[N], u[N], v[N];
u32 query(int x) {
	u32 ans=0;
	for(; x; x&=x-1) inc(ans, bit[x]);
	return ans;
}
u32 add(int x, u32 v) {
	for(; x<=n; x+=x&-x) inc(bit[x], v);
}
void clear(int x) {
	for(; x<=n; x+=x&-x) bit[x]=0;
}
int main() {
	n=rd();
	for(int i=1; i<=n; ++i) ++cnt[a[i]=rd()];
	for(int i=1; i<=n; ++i) cnt[i]+=cnt[i-1];
	for(int i=n; i>=1; --i) rank[cnt[a[i]]]=i, b[cnt[a[i]]--]=a[i];
	memset(cnt+1, 0, n*sizeof(int));
	p[0]=q[0]=1;
	for(int i=1; i<=n; ++i) p[i]=p[i-1]*(b[i]-i+1llu)%P;
	if(p[n]==0) puts("0"), exit(0);
	for(int i=1; i<=n; ++i) cnt[i]=cnt[i-1]+cmax(u[i]=b[i]-i, 1), q[i]=(u64)q[i-1]*u[i]%P;
	invp[n]=power(p[n], P-2), invq[n]=power(q[n], P-2);
	for(int i=n; i>=1; --i) invp[i-1]=invp[i]*(b[i]-i+1llu)%P;
	for(int i=n; i>=1; --i) invq[i-1]=(u64)invq[i]*u[i]%P;
	u64 invcnt=0;
	for(int i=1; i<=n; ++i) {
		for(int j=a[i]+1; j<=n; j+=j&-j) invcnt+=bit[j];
		for(int j=a[i]; j; j&=j-1) ++bit[j];
	}
	u32 ans=invcnt*2%P;
	memset(bit+1, 0, n*sizeof(int));
	for(int i=1; i<=n; ++i) u[i]=(u64)p[i-1]*invq[i-1]%P*(b[i]-i+1llu)%P;
	for(int i=1; i<=n; ++i) v[i]=(u64)q[i-1]*invp[i]%P;
	for(int i=1, j=0; i<=n; ++i) {
		if(i>1&&b[i-1]==i-1) {
			while(j<i-1) clear(rank[++j]);
		} else {
			ans=(ans+(2llu*query(rank[i]-1)+P-query(n))*v[i])%P;
		}
		add(rank[i], u[i]);
	}
	ans=(ans+(ans&1?P:0llu))/2*p[n]%P;
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 8832
#include <stdio.h>
#include <math.h>

int main()
{
	int i, N;
	int dp[100001];

	scanf("%d", &N);

	//dpの初期値
	dp[1] = 1;

	//dpループ
	for(i=2; i<=N; i++)
	{
		if(i>=59049)
		{
		dp[i] = fmin(dp[i-1], fmin(dp[i-6], fmin(dp[i-9], fmin(dp[i-36], fmin(dp[i-81], fmin(dp[i-216], fmin(dp[i-729], fmin(dp[i-1296], fmin(dp[i-6561], fmin(dp[i-7776], fmin(dp[i-46656], dp[i-59049]))))))))))) +1 ;
		}
		else if(i>=46656)
		{
		dp[i] = fmin(dp[i-1], fmin(dp[i-6], fmin(dp[i-9], fmin(dp[i-36], fmin(dp[i-81], fmin(dp[i-216], fmin(dp[i-729], fmin(dp[i-1296], fmin(dp[i-6561], fmin(dp[i-7776], dp[i-46656])))))))))) +1 ;
		}
		else if(i>=7776)
		{
		dp[i] = fmin(dp[i-1], fmin(dp[i-6], fmin(dp[i-9], fmin(dp[i-36], fmin(dp[i-81], fmin(dp[i-216], fmin(dp[i-729], fmin(dp[i-1296], fmin(dp[i-6561], dp[i-7776]))))))))) +1 ;
		}
		else if(i>=6561)
		{
		dp[i] = fmin(dp[i-1], fmin(dp[i-6], fmin(dp[i-9], fmin(dp[i-36], fmin(dp[i-81], fmin(dp[i-216], fmin(dp[i-729], fmin(dp[i-1296], dp[i-6561])))))))) +1 ;
		}
		else if(i>=1296)
		{
		dp[i] = fmin(dp[i-1], fmin(dp[i-6], fmin(dp[i-9], fmin(dp[i-36], fmin(dp[i-81], fmin(dp[i-216], fmin(dp[i-729], dp[i-1296]))))))) +1 ;
		}
		else if(i>=729)
		{
		dp[i] = fmin(dp[i-1], fmin(dp[i-6], fmin(dp[i-9], fmin(dp[i-36], fmin(dp[i-81], fmin(dp[i-216], dp[i-729])))))) +1 ;
		}
		else if(i>=216)
		{
		dp[i] = fmin(dp[i-1], fmin(dp[i-6], fmin(dp[i-9], fmin(dp[i-36], fmin(dp[i-81], dp[i-216]))))) +1 ;
		}
		else if(i>=81)
		{
		dp[i] = fmin(dp[i-1], fmin(dp[i-6], fmin(dp[i-9], fmin(dp[i-36], dp[i-81])))) +1 ;
		}
		else if(i>=36)
		{
		dp[i] = fmin(dp[i-1], fmin(dp[i-6], fmin(dp[i-9], dp[i-36]))) +1 ;
		}
		else if(i>=9)
		{
		dp[i] = fmin(dp[i-1], fmin(dp[i-6], dp[i-9])) +1 ;
		}
		else if(i>=6)
		{
		dp[i] = fmin(dp[i-1], dp[i-6]) +1 ;
		}
		else if(i>=1)
		{
		dp[i] = dp[i-1] +1 ;
		}					
	}

	printf("%d", dp[N]);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n,x,t;
  cin >> n >> x >> t;
  int a;
  a = n/x;
  if(n % x != 0)a++;
  cout << a*t << endl;
}

Measured memory_bytes: 3632
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"math"
)
 
func run() {

	var L int;
    L = nextInt();
    var R int;
    R = nextInt();
	solve(L, R);

}

func solve(L int, R int){
	min := 2019.0
	if R - L <= 4040 {
		for i := L ; i < int(R); i++ {
			for j := i+1; j <= int(R); j++ {
				min = math.Min(float64((i%2019 * j%2019) % 2019), float64(min))				
			}
		}
		Println(min)
		return
	}else {
		Println(0)
	}
}


// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}


type IntHeap []int
func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

/////数字と文字
// 基本クラス
type NS struct {
    Num int
    Str string
}

//////　数字と数字
// 基本クラス
type NN struct {
    Num1 int
    Num2 int
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}



Measured memory_bytes: 2816
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int a, b, ans, h, hh, m, mm, t, c, tt;
	const int v[8][8] = {
		{ 0,0,  0,  0,  0,  0,   0,  0 },
		{ 0,0,300,500,600,700,1350,1650 },
		{ 0,0,  0,350,450,600,1150,1500 },
		{ 0,0,  0,  0,250,400,1000,1350 },
		{ 0,0,  0,  0,  0,250, 850,1300 },
		{ 0,0,  0,  0,  0,  0, 600,1150 },
		{ 0,1,  0,  0,  0,  0,   0, 500 },
		{ 0,1,  1,  1,  0,  0,   0,   0 }
	};

	for (; ~fscanf(stdin, "%d", &a), a; P(d, ans)) {
		fscanf(stdin, "%d%d%d%d%d", &h, &m, &b, &hh, &mm);
		c = 0;
		if (a > b) t = a, a = b, b = t;
		t = h * 60 + m;
		tt = hh * 60 + mm;
		ans = v[a][b];
		c = v[b][a];
		if (((17 * 60 + 30 <= t&&t <= 19 * 60 + 30) || (17 * 60 + 30 <= tt&& tt <= 19 * 60 + 30)) && !c) {
			ans /= 2;
			ans = 50 * ((ans + 49) / 50);
		}
	}
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;
typedef long long ll;

// AtCoder Beginner Contest 142
int main(){

    int n;
    cin >> n;

    vector<int> a(n);
    rep(i, n)cin >> a[i];

    vector<int> ans(n);
    iota(all(ans), 0);
    sort(all(ans), [&](int i, int j){
        return a[i] < a[j];
    });

    rep(i, n){
        if(i)cout << ' ';
        cout << ans[i] + 1;
    }
    cout << endl;
    
}

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

const int MAX_N = 200100;
int A[MAX_N], B[MAX_N];
int N;

int main()
{
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) {
        scanf("%d", &A[i]);
        ++B[A[i]];
    }
    ll res = 0LL;
    for(int i = 1; i <= N; ++i) {
        res += ll(B[i])*ll(B[i]-1)/2LL;
    }
    for(int i = 1; i <= N; ++i) {
        printf("%lld\n", res - B[A[i]] + 1);
    }
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int rev(int a) {
    return (a & 1)? -1 : 1;
}

int main(void) {
    int n, m;
    cin >> n >> m;
    long long x[n], y[n], z[n];
    rep(i, n) cin >> x[i] >> y[i] >> z[i];

    long long ma = 0;
    rep(bit, 8) {
        long long c[n];
        rep(i, n) {
            c[i] = x[i] * rev(bit >> 2)
                 + y[i] * rev(bit >> 1)
                 + z[i] * rev(bit >> 0);
        }
        nth_element(c, c+m-1, c+n, [](const long long& a, const long long& b){ return a > b; });
        long long sum = 0;
        rep(i, m){ sum += c[i];}
        ma = max(ma, sum);
    }
    cout << ma << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 1000000010
#define INF   1000000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


ll binpow_mod(ll a, ll n, ll m) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % m;
    a = a * a % m;
    n = n >> 1;
  }
  return res;
}

ll comb_mod(ll n, ll r, ll m) {
  ll ans = 1;
  for (ll i = 0; i <= r-1 ; i++) ans = (ans * (n-i)) % m;
  for (int i = r; i >= 1 ; i--) {
    ll num = binpow_mod(i, m-2, m);
    ans = (ans * num) % m;
  }
  return ans;
}

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll m = 1000000007;
    ll total = binpow_mod(2, n, m);
    total--;
    total %= m;
    
    total -= comb_mod(n, a, m);
    if (total < 0) total += m;
    total %= m;
    
    total -= comb_mod(n, b, m);
    if (total < 0) total += m;
    total %= m;

    cout << total << endl;
    return 0;
}


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

using namespace std;

int main(){
    int r; cin >> r;
    if(r < 1200){
        cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1e9+7) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

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

const int INF = 1e18;

// idx, (未処理, 偶数左, 奇数, 偶数右)
const int VARI = 5;
int dp[200010][VARI];

signed main() {
  int N;
  cin >> N;
  vec<int> v(N);
  rep (i, N) {
    cin >> v[i];
  }

  // DP
  const int M1 = 0;
  const int M2 = 1;
  const int E1 = 2;
  const int E2 = 3;
  const int O = 4;
  fill(dp[0], dp[N+1], INF);
  dp[0][M1] = 0;
  rep (i, N) {
    // 未処理左
    chmin(dp[i+1][M1], dp[i][M1] + v[i]);

    // 偶数左
    int cost1 = (v[i] == 0 ? 2 : (v[i] % 2));
    chmin(dp[i+1][E1], min(dp[i][E1], dp[i][M1]) + cost1);

    // 偶数右
    int cost2 = (v[i] == 0 ? 2 : (v[i] % 2));
    chmin(dp[i+1][E2], min(dp[i][O], dp[i][E2]) + cost2);

    // 奇数
    int cost3 = 1 - (v[i] % 2);
    int mi = min({dp[i][E1], dp[i][O], dp[i][M1]});
    chmin(dp[i+1][O], mi + cost3);

    // 未処理右
    int mi2 = min({dp[i][E1], dp[i][E2], dp[i][O], dp[i][M2]});
    chmin(dp[i+1][M2], mi2 + v[i]);
  }

  int ans = INF;
  rep (i, VARI) {
    chmin(ans, dp[N][i]);
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;
typedef long long ll;

const int MAX_N = 55;

int n,a,x;
ll dp[MAX_N*MAX_N][MAX_N];

int main()
{
	cin >> n >> a;
	dp[0][0]=1;
	for (int i=1; i<=n; i++)
	{
		cin >> x;
		for (int k=n; k>=1; k--)
			for (int s=x; s<=n*a; s++)
				dp[s][k]+=dp[s-x][k-1];
	}
	ll ans=0;
	for (int k=1; k<=n; k++)
		ans+=dp[a*k][k];
	cout << ans;
	return 0;
}

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

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
    try{
      String S = sc.readLine();
      Deque<String> deq = new ArrayDeque<>();
      deq.add(S);
      int N = Integer.parseInt(sc.readLine());
      boolean f = true;
      for(int i = 0; i < N; i++){
        String[] T = sc.readLine().split(" ");
        int order = Integer.parseInt(T[0]);
        if(order == 1){
          f = !f;
        }else{
          int o2 = Integer.parseInt(T[1]);
          if(o2 == 1){
            if(f){
              deq.addFirst(T[2]);
            }else{
              deq.addLast(T[2]);
            }
          }else{
            if(f){
              deq.addLast(T[2]);
            }else{
              deq.addFirst(T[2]);
            }
          }
        }
      }
      StringBuilder sb = new StringBuilder();
      for(String s : deq){
        sb.append(s);
      }
      System.out.println(f ? sb.toString() : sb.reverse().toString());
    }catch(Exception e){
    }
  }
}


Measured memory_bytes: 71484
def func(i):
  ret_val=0
  while 0<i:
    ret_val+=i%10
    i//=10
  return ret_val

N=int(input())
ans=10**9
for i in range(1,N):
  j=N-i
  ans=min(ans,func(i)+func(j))
print(ans)


Measured memory_bytes: 9016
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int> PI;
#define MAX 99999999
char s[]={" "};
int main(){
    int y,m,d;
    while(cin>>y>>m>>d){
        if(y<1868||(y==1868&&m<9)||(y==1868&&m==9&&d<8))cout<<"pre-meiji"<<endl;
        else if((1868<=y&&y<1912)||(y==1912&&m<7)||(y==1912&&m==7&&d<=29))cout<<"meiji"<<" "<<(y-1868+1)<<s<<m<<s<<d<<endl;
        else if((1912<=y&&y<1926)||(y==1926&&m<12)||(y==1926&m==12&&d<=24))cout<<"taisho"<<s<<(y-1912+1)<<s<<m<<s<<d<<endl;
        else if((1926<=y&&y<1989)||(y==1989&&m<1)||(y==1989&&m==1&&d<=7))cout<<"showa"<<s<<(y-1926+1)<<s<<m<<s<<d<<endl;
        else
            cout<<"heisei"<<s<<(y-1989+1)<<s<<m<<s<<d<<endl;

    }
}

Measured memory_bytes: 3088
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))

x, y = MI()
print(x+y//2)


Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 0;

string s, t;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> s >> t;
	ll n = s.size();
	ll m = t.size();
	ll ans = inf;
	for(ll i = m - 1; i < n; i++){
		ll cnt = 0;
		ll ret = 0;
		for(ll j = i - m + 1; j <= i; j++){
			if(s[j] != t[cnt]){
				ret++;
			}
			cnt++;
		}
		ans = min(ans, ret);
	}
	cout << ans << '\n';
}



Measured memory_bytes: 3644
#include<iostream>
#include<queue>

const static int MAX = 100000;
int color[MAX];
int group_color;
std::vector<int> A[MAX];

int search(int o){
    if(color[o] != 0){
	return 0;
    }
    std::queue<int> qu;
    qu.push(o);
    color[o] = group_color;
    while(!qu.empty()){
	int cur = qu.front();
	qu.pop();
	for(int i = 0; i < A[cur].size(); i++){
	    if(color[A[cur][i]] == 0){
		qu.push(A[cur][i]);
	    	color[A[cur][i]] = group_color;
	    }
	}
    }
    return 0;
}

int main(void){
    int n, m, s, t, q;

    std::cin >> n >> m;
    for(int i = 0; i < m; i++){
	std::cin >> s >> t;
	A[s].push_back(t);
	A[t].push_back(s);
    }
    for(int i = 0; i < n; i++){
        color[i] = 0;
    }
    group_color = 1;
    for(int i = 0; i < n; i++){
	search(i);
	group_color++;
    }

    std::cin >> q;
    for(int i = 0; i < q; i++){
	std::cin >> s >> t;
	if(color[s] == color[t]){
	    std::cout << "yes" << std::endl;
	}else{
	    std::cout << "no" << std::endl;
	}
    }

    return 0;
}



Measured memory_bytes: 8988
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

typedef complex<double> P;

struct L : public vector<P>{//??´???
  L(const P &a, const P &b){
    push_back(a);push_back(b);
  }
};

struct C{//???
  P c; double r;
  C(const P &c,double r): c(c),r(r){}
};

namespace std{//??????????????????
  bool operator < (const P& a,const P& b){
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b){
    return a.real()==b.real()&&a.imag()==b.imag();
  }
}

double dot(P a,P b){
  return real(conj(a)*b);
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c){
  b-=a;c-=a;
  if(cross(b,c)>0)   return +1;// counter clockwise 
  if(cross(b,c)<0)   return -1;// clockwise 
  if(dot(b,c)<0)     return +2;// c-a-b on line
  if(norm(b)<norm(c))return -2;// a-b-c on line
  return 0;                    // a-c-b on lone
}

int main()
{
  double xp1,yp1,xp2,yp2;
  int q;
  int i,j;

  cin>>xp1>>yp1>>xp2>>yp2;
  cin>>q;

  P p1(xp1,yp1),p2(xp2,yp2);

  rep(i,q){
    double xp,yp;
    cin>>xp>>yp;
    P p(xp,yp);

    switch(ccw(p1,p2,p)){

    case +1:cout<<"COUNTER_CLOCKWISE"<<endl;break;
    case -1:cout<<"CLOCKWISE"<<endl;break;
    case +2:cout<<"ONLINE_BACK"<<endl;break;
    case -2:cout<<"ONLINE_FRONT"<<endl;break;
    case 0 :cout<<"ON_SEGMENT"<<endl;break;

    }
  }

}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}
const int maxn = 100000+5;

vector<pair<ll, ll>> p2n;

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    int n, m;
    cin >> n>>m;
    for(int i = 0; i < n; ++i){
        ll a, b;cin >> a>>b;
        p2n.push_back({a,b});
    }
    sort(p2n.begin(), p2n.end());

    ll ans = 0;
    for(auto itr = p2n.begin(); itr != p2n.end(); ++itr){
        ll t = (itr->sd <= m) ? itr->sd : m;
        ans += t * itr->ft;
        m -= t;
        if(!m) break;
    }

    cout<< ans<<endl;

    return 0;
}


Measured memory_bytes: 2420
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
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String s = in.next(), t = in.next();
            int cnt = 0, min = Integer.MAX_VALUE;
            for (int i = 0; i < s.length() - t.length() + 1; ++i) {
                for (int j = 0; j < t.length(); ++j) {
                    if (t.charAt(j) != s.charAt(i + j)) cnt++;
                }
                min = Math.min(cnt, min);
                cnt = 0;
            }
            out.println(min);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32620
<?php
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));

$ans = 0;
for($i = 0; $i < $n; $i++) {
    $ans += 1 / $a[$i];
}
$ans = 1 / $ans;
echo $ans . PHP_EOL;

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

const int mod = 1e9+7;
const int INF = 2000000;
const double PI = acos(-1.0);

int main() {
    
	int x;
	cin >> x;
	for(int i=1;i<=x;++i){
		if(100*i > x) break;
		if(100*i <= x && x <= 100*i+5*i) {
			puts("1");
			return 0;
		}
		
	}
	puts("0");
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  if(N==1){
    cout << "Yes" << endl;
    return 0;
  }
  
  int H[N]; 
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  
  for(int i=N-1;0<i;i--){
    if((H[i-1]-H[i])>1){
      cout << "No" << endl;
      return 0;
    }
    else if((H[i-1]-H[i])==1){
      H[i-1]-=1;
    }
  }
  cout << "Yes" << endl;
  
}


Measured memory_bytes: 640
N, Q = map(int, input().split())
graph = [[] for i in range(N+1)]

for i in range(N-1):
    f, t = map(int, input().split())
    graph[f].append(t)
    graph[t].append(f)

px = [0] * (N+1)

for i in range(Q):
    p, x = map(int, input().split())
    px[p] += x

v = [0] * (N+1)
q = [[1, 0]]

while q:
    x, parent = q.pop()
    v[x] += v[parent]
    v[x] += px[x]
    for y in graph[x]:
        if y == parent:
            continue
        q.append([y, x])

ans = [str(i) for i in v[1:]]
print(' '.join(ans))


Measured memory_bytes: 148296
A, B, M = (int(x) for x in input().split())
a_s = [int(x) for x in input().split()]
b_s = [int(x) for x in input().split()]

minimum_price_with_discount = 0

for i in range(M):
    x, y, c = (int(x) for x in input().split())
    price_with_discount = a_s[x-1] + b_s[y-1] - c
    if i == 0:
        minimum_price_with_discount = price_with_discount
    else:
        if minimum_price_with_discount > price_with_discount:
            minimum_price_with_discount = price_with_discount
        else:
            continue

a_s.sort(), b_s.sort()
minimum_price_without_discount = a_s[0] + b_s[0]

if minimum_price_with_discount > minimum_price_without_discount:
    print(minimum_price_without_discount)
else:
    print(minimum_price_with_discount)


Measured memory_bytes: 18488
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;


int main() {

	
	string S, T;
	cin >> S >> T;

	int n = S.size();
	int m = T.size();

	ll s[MAX],t[MAX];

	rep(i,n) {
		s[i] = S[i]-96;
		s[n + i] = s[i]; }

	rep(i,m) {
		t[i] = T[i]-96;
		t[m + i] = t[i];
	}

	ll dis[100000][26];

	rep(i, n) {
		int j = n + i-1;
		while (1) {
			dis[j%n][s[i]] = n + i - j;
			if (s[i] == s[j]) { break; }
			j--;
		}
	}


	
	ll ans = 0;

	
	int suse[26] = {};
	rep(i, n) suse[s[i]] = 1;

	rep(i, m) { if (suse[t[i]] == 0) { ans = -1; } }

	if (ans == 0) {
		int si = n-1;
		rep(i,m){
			ans += dis[si][t[i]];
			si = (si + dis[si][t[i]]) % n;

		}

	}

	cout << ans;

	system("PAUSE");

}

Measured memory_bytes: 28536
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

ll two[MAX];
int main() {
    // 前処理
    COMinit();

    ll B, W;
    cin >> B >> W;
    ll n = B + W;
    ll a[n+1], b[n+1], c[n+1], ans[n+1];
    a[0] = 1, b[0] = 0, c[0] = 0, ans[0] = 0;
    
    two[0] = 1;
    srep(i,1,MAX) two[i] = two[i-1] * 2 % MOD;

    srep(i,1,n+1){
        ans[i] = (a[i-1] * modinv(2, MOD) + b[i-1] * 0 + c[i-1] * 1) % MOD;
        b[i] = (b[i-1] + COM(i-1, B-1) * modinv(two[i], MOD)) % MOD;
        c[i] = (c[i-1] + COM(i-1, W-1) * modinv(two[i], MOD)) % MOD;
        a[i] = (1 - (b[i] + c[i]) + MOD * 10) % MOD;
    }

    srep(i,1,n+1)cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
int a[N];
int main () {
    int h,n;
    ll att=0;
    scanf("%d%d",&h,&n);
    for(int i=1;i<=n;++i) {
        scanf("%d",a+i);
        att+=a[i];
    }
    if(att>=h) cout << "Yes"<<endl;
    else cout <<"No"<<endl;
    return 0;
}

Measured memory_bytes: 640
/*****************************************************************\
    |     IN THE NAME OF ALLAH, MOST GRACIOUS AND MOST MERCIFUL       |
    |                                                                 |
    |     Author     : Mahabub Rahman                                 |
    |     Email      : mahabubrahman618@gmail.com                     |
    |     University : Comilla University, Bangladesh		          |
    |                  Department of Computer Science & Engineering   |
    \*****************************************************************/


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

    using namespace std;
    #define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
    #define       ll                  long long int
    #define       ull                  unsigned long long int
    #define       veci                 vector<int>
    #define       vecc                 vector<char>
    #define       vecs                 vector<string>
    #define       vecl                 vector<long long int>
    #define       vecp                 vector<  pair<int,int> >
    #define       mapstrint            map< string , int >
    #define       mapstrstr            map< string , string >
    #define       mapint               map< int, int >
    #define       pb                   push_back
    #define       pob                  pop_back
    #define       mp                   make_pair
    ////============ CONSTANT ===============////
    #define mx9   1000000009
    #define mx7   10000007
    #define mx6   1000006
    #define mx5   100005
    #define inf   1<<30                                           //infinity value
    #define eps   1e-9
    #define mx    (65540)
    #define mod   1000000007
    ////=====================================////

    long double PI = acosl(-1);
    bool compare_int(int a, int b) //This function is use for descending order.
    {
        return (a>b);
    }
    bool compare_string (string a, string b)
    {
        return a.size() < b.size();
    }
    bool compare_pair(const pair<int,int> &a,
                  const pair<int,int> &b)
    {
        if(a.second==b.second) return a.first>b.first;
        else return (a.second > b.second);
    }
    ll fact(ll n)
    {
        if(n==0 || n==1) return 1;
        else return n*fact(n-1);
    }

    ////======================================////
    /*bool check(int n)
    {
        for(int i=2; i<=sqrt(n); i++)
        {
            if(n%i==0)
            {
                return false;
            }
        }
        return true;
    }*/

    int32_t main()
    {
        FastIO;
        string s;
        cin >> s;
        if(s[0]==s[1] && s[1]==s[2])
        {
            cout << "No\n";
        }
        else cout << "Yes\n";
        
    }


Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine}
object Main extends App {
  val n = readInt
  val as = readLine.split(" ").map(_.toInt)
  if (as.size == 1) println("YES")
  else if (as.count(_ % 2 == 1) % 2 == 0) println("YES")
  else println("NO")
}


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

int main(){
  int N;
  string s;
  cin >> N;
  cin >> s;
  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(s[i] == 'R'){
      cnt++;
    }
  }
  if(cnt > N - cnt){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define ll long long 
int main(){
	string s;
	cin>>s;
	ll num=s.size();
	ll ans=0;
	for (int i=0;i<s.size();i++){
		ans+=s[i]-'0';
	}
	ans=max(9*(num-1),ans);
	
	if (s[0]>'1'){
		ans=max(9*(num-1)+s[0]-'0'-1,ans);
	}
	
	
	
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  string S;
  cin >> S;
  int mask = 0;
  int n = S.size() - 1;
  vector<int> nums;
  ll ans = 0;
  while (mask < 1<<n) {
    int i = 0;
    long x = 0;
    while (i < n) {
      x = x * 10 + S[i] - '0';
      if (mask & 1<<i) {
        ans += x;
        x = 0;
      }
      ++i;
    }
    x = x * 10 + S[i] - '0';
    ans += x;
    ++mask;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int w[105];
    int sum[105];
    int n;
    cin >> n;
    sum[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> w[i];
        sum[i] = sum[i - 1] + w[i];
    }
    int ans = 0x3f3f3f3f;
    for (int i = 1; i <= n; i++)
    {
        ans = min(ans, abs(sum[n] - sum[i] - sum[i]));
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Sum of 4 Integers II
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int[][] dp = new int[4][4001];

		for (int i = 0; i <= 1000; i++) dp[0][i] = 1;

		for (int i = 1; i < 4; i++) {
			for (int j = 0; j <= 1000; j++) {
				for (int k = 4000; k >= 0; k--) {
					if (k - j >= 0) dp[i][k] += dp[i - 1][k - j];
				}
			}
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			System.out.println(dp[3][parseInt(line)]);
		} // end while
	} // end main
}

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

int main() {
  string s;
  cin >> s;
  if (s[0] != s[1] || s[1] != s[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 2000001
#define M 10000

int main()
{
  unsigned short *x,*y;
  int a[M+1];
  int s,i,j,k;

  scanf("%d",&s);

  x=malloc(sizeof(short)*s+1);
  y=malloc(sizeof(short)*s+1);

  for(i=0;i<=M;i++)a[i]=0;

  for(i=0;i<s;i++){
    scanf("%hu",&x[i+1]);
    a[x[i+1]]++;
  }
  for(i=1;i<=M;i++)a[i]=a[i]+a[i-1];

  for(j=1;j<=s;j++){
		      
    y[a[x[j]]]=x[j];
    a[x[j]]--;
  }
  for(i=1;i<=s;i++){
    if(i>1)printf(" ");
    printf("%d",y[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 9584