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

int main() {

  int a,b,c,d,sum;
  string s,t;
  cin>>a>>b>>c;
  vector<vector<int>> vecA(a,vector<int>(b));
  vector<int> vecB(b);
  
  d=0;
  
  for(int i=0;i<b;i++){
  	cin>>vecB.at(i);
  }
  
  for(int i=0;i<a;i++){
  	for(int k=0;k<b;k++){
    	cin>>vecA.at(i).at(k);
    }
  }
  
  for(int i=0;i<a;i++){
    sum=0;
  	for(int k=0;k<b;k++){
    	sum += vecA.at(i).at(k)*vecB.at(k);
    }
    sum +=c;
    if(sum>0)d++;
  }

  cout<<d<<endl;
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split(" ");
  var a = input[0];
  var b = input[1];
  var ans = "";
  for(var i=0;i<Math.max(a,b);i++){
    ans+=Math.min(a,b);
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
if __name__ == '__main__':
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    cnt = 0
    for i in range(A+1):
        for j in range(B+1):
            for k in range(C+1):
                if 500*i+100*j+50*k==X:
                    cnt += 1
    print(cnt)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define repr(i, n) for(int i=(n-1); 0<=i; i--)
#define repr2(i, from, to) for(int i=(from-1); (int)(to)<=i; i--)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };


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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	ll n, k; cin >> n >> k;
	vector<int> a(n);
	rep(i, n){
		cin >> a[i];
	}


	ll rate1 = (k*(k+1))/2;
	rate1 %= MOD;

	ll rate2 = ((k-1)*k)/2;
	rate2 %= MOD;

	ll ans = 0;
	rep(i, n){
		int count = 0;
		rep2(j, i+1 , n){
			if(a[i] > a[j]) count++;
		}
		ans += count*rate1;
		ans %= MOD;

		count = 0;
		rep2(j, 0, i){
			if(a[i] > a[j]) count++;
		}
		ans += count*rate2;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m,d;
  cin>>n>>m>>d;
  ll k;
  if(d==0)k=n;
  else k=2*(n-d);
  cout<<to_string(((double)(m-1)*k)/((double)n*n))<<endl;
}
                  

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  int n; 
  cin >> n ;
  int even=0;
  rep(i,n){
    int a; cin >> a; 
    if(a % 2 == 0 ) even ++;
  }
  cout<<pow(3,n)-pow(2,even)<<endl;
}



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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int N;
    cin >> N;
    vector<int> B(N-1);
    rep(i, N-1)
    {
        cin >> B[i];
    }
    int ans = 0;
    for(int i=1; i<N-1; i++){
        ans += min(B[i-1], B[i]);
    }
    ans = ans + B[0]+B[N-2];
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

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

using namespace std;

int n;
string s;
int q;
set<int> occ[26];

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

	cin >> n >> s >> q;
	for (int i = 0; i < n; i++)
        occ[(int)s[i] - (int)'a'].insert(i + 1);

	for (int _ = 0; _ < q; _++)
    {
        int type;
        cin >> type;

        if (type == 1)
        {
            int x;
            char y;
            cin >> x >> y;
            if (s[x - 1] != y)
            {
                occ[(int)s[x - 1] - (int)'a'].erase(x);
                occ[(int)y - (int)'a'].insert(x);
                s[x - 1] = y;
            }
        }
        else
        {
            int x, y;
            cin >> x >> y;
            int ans = 0;
            for (int i = 0; i < 26; i++)
            {
                auto l = occ[i].lower_bound(x);
                if (l != occ[i].end() && *l <= y)
                    ans++;

            }
            cout << ans << "\n";
        }
    }

	return 0;
}


Measured memory_bytes: 24348
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int H, W;
vector<string> s;
vector<string> m;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

void paint(const int y, const int x)
{
  REP(i, 4) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
    if (m[ny][nx] == '#') {
      s[y][x] = '.';
      s[ny][nx] = '.';
    }
  }
}

bool check()
{
  REP(i, H) {
    // cout << s[i] << endl;
    REP(k, W) {
      if (s[i][k] == '#')
        return false;
    }
  }
  return true;
}

int main()
{
  cin >> H >> W;
  REP(i, H) {
    string str;
    cin >> str;
    s.push_back(str);
    m.push_back(str);
  }
  REP(i, H) {
    REP(k, W) {
      if (m[i][k] == '#')
        paint(i, k);
    }
  }
  if (check())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	char c; cin >> c;
	if ('A' <= c && c <= 'Z') {
		cout << "A" << "\n";
	}
	else {
		cout << "a" << "\n";
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//int t; cin >> t; rep(i, t)
		solve();
	stop
		return 0;
}


Measured memory_bytes: 20016
#include<bits/stdc++.h>
using namespace std;
bool ifprime(int n)
{
  for(int i=2;i*i<=n;i++)
  {
    if(n%i==0)
      return false;
  }
  return true;
}
int main()
{
  int a=17,n,b[55];
  bool correct=false;
  cin>>n;
  b[0]=a;
  for(int i=1;i<n;i++)
  {
    b[i]=b[i-1]+10;
	  correct=false;
    while(true)
      {
      correct=ifprime(b[i]);
		  if(correct==true)
			  break;
      b[i]+=10;
      }
  }
  for(int i=0;i<n;i++)
    {
      cout<<b[i]<<' ';
    }
  return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

s = gets.chomp
T = gets.chomp

ans = T.size
(0..(s.size - T.size)).each do |s_start|
  diff = 0
  (0..(T.size - 1)).each do |t_start|
    diff += 1 if T[t_start] != s[s_start + t_start]
  end
  ans = [ans, diff].min
end

puts ans


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

int func(int y, int k) {
  int f = 0;
  if (y < k) {
    f = min((y - 0) * 2, (k - y) * 2);
  }else {
    f = min((y - 0) * 2, (y - k) * 2);
  }
  return f;
}

int main() {
  int N, K;
  cin >> N >> K;
  int x;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> x;
    ans += func(x, K);
  }
  cout << ans << endl;
}

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

struct P{
  int h,w;
  int get(){
    return h*h+w*w;
  }
  bool operator < (const P& p)const{
    if( h*h+w*w == p.h*p.h+p.w*p.w ) return h<p.h;
    return  h*h+w*w < p.h*p.h+p.w*p.w;
  }
};

int h,w;
vector<P> t;
void make_table(){
  t.clear();
  P a;
  for(int i=1;i<=150;i++){
    for(int j=i+1;j<=150;j++){
      a.h=i,a.w=j;
      t.push_back(a);
    }
  }
  sort(t.begin(),t.end());


}

int main(){  
  int h,w;
  make_table();
  while(cin>>h>>w&&h&&w){
    for(int i=0;i<(int)t.size();i++){
      if(h*h+w*w<t[i].get() || (h*h+w*w==t[i].get() && h<t[i].h)){
	cout<<t[i].h<<' '<<t[i].w<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1344
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>


using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


// double c(double x)
// {
//   double X = x;
//   X = int(X) % 10;
//   return X;
// }

int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0;i < n;i++)
  {
    cin >> a[i];
  }
  int min = 1;
  for(int i = 0;i < n;i++)
  {
    if(min == a[i])
    {
      min++;
    }
  }
  // cout << min << endl;
  if(min == 1)
  {
    cout << -1 << endl;
    return 0;
  }
  cout << n-min+1 << endl;
}

Measured memory_bytes: 1792
package main

import "fmt"

var fac [10000]int
var finv [10000]int
var inv [10000]int
var m int = 1000000007

func com_init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < 10000; i++ {
		fac[i] = fac[i-1] * i % m
		inv[i] = m - inv[m%i]*(m/i)%m
		finv[i] = finv[i-1] * inv[i] % m
	}
}

func com(n, k int) int {
	if n < k {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % m) % m

}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	com_init()
	for i := 1; i <= k; i++ {
		fmt.Println(com(n-k+1, i) * com(k-1, i-1) % m)
	}
}


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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

int main()
{
	LL a, b;
	in(a); in(b);
	LL now = a, tot = 0;
	while (now <= b) now = now * 2, tot++;
	printf("%lld\n", tot);
	return 0;
}


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

using namespace std;

int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    int ct =0;
    for(int i = 0 ;i < (int)s1.length();++i)
    {
        if(s1[i] == s2[i])
            ct++;
    }
    cout << ct;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

const std::size_t SIZE = 2000 + 10;
ll dp_buf[3 * SIZE][6 * SIZE];
using dp_type = decltype(dp_buf[0] + 3 * SIZE);
dp_type dp[3 * SIZE];
ll mod;

ll solve() {
    for (ll i = 0; i < 3 * SIZE; i++) dp[i] = dp_buf[i] + 3 * SIZE;

    ll n, m;
    std::cin >> n >> m;
    mod = m;

    auto add_f = [&](ll &a, ll b) {
        a = (a + b) % mod;
    };

    dp[0][0] = 1;
    for (ll i = 0; i < 3 * n; i++) for (ll j = -3 * n; j <= 3 * n; j++) {
        if (1 <= i + 1) add_f(dp[i + 1][j + 1], dp[i][j]);
        if (2 <= i + 1) add_f(dp[i + 1][j - 1], dp[i - 1][j] * i % mod);
        if (3 <= i + 1) add_f(dp[i + 1][j], dp[i - 2][j] * i * (i - 1) % mod);
    }

    ll ans = 0;
    for (ll i = 0; i <= 3 * n; i++) add_f(ans, dp[3 * n][i]);
    return ans;
}

int main() {
    std::cout << solve() << '\n';
    return 0;
}


Measured memory_bytes: 567424
import sys
input = sys.stdin.readline

N,K = map(int, input().split())
ITEM = []
for _ in range(N):
  a,b = map(int, input().split())
  ITEM.append((a,b))

# 桁DPのような形で、KをMAX数十パターン試す
# Kが1010101のとき
# K= 1010101, 1010011, 1001111, 0111111をためせばよい。
# 1を0に置き換えて、あとは1連発。
# 値は貪欲にとってよい。論理和をとって変化しなければOK
# 6 | 2 == 6 -> True, 6 | 3 == 6 -> False
def solve(X):
  res = 0
  for a,b in ITEM:
    if a | X == X:
      res += b
  #print(X,res)
  return res

wk = 1
ans = solve(K)
for i in range(1,32):
  if (K // wk) % 2 == 1:
    ans = max(ans, solve((K // (2*wk)) * 2* wk + wk-1))
  else:
    pass
  wk *= 2
  
print(ans)

Measured memory_bytes: 22504
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a[100005],n;
    cin>>n;
    rep(i,0,n){
        cin>>a[i];
    }
    int ans = 1;
    int d = 0,tmp;
    rep(i,1,n){
        tmp = a[i]-a[i-1];
        if(tmp == 0){continue;}
        tmp = tmp>0?1:-1;
        if(d==0){
            d = tmp;
        }
        else if(d!=tmp){
            d=0;ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,j=0;
  int x[]={111,222,333,444,555,666,777,888,999};
  cin>>n;

  while(x[j]<n){
    j++;
  }
  cout<<x[j]<<'\n';

  return 0;
}


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

#define ll long long int

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

    ll dp[n+1][n+1][2];
    for(int i=0; i<=n; i++) dp[i][0][0] = dp[i][0][1] = 0;
    for(int l=1; l<=n; l++) {
        for(int i=0; i+l<=n; i++) {
            dp[i][l][0] = min(dp[i+1][l-1][1] - a[i], dp[i][l-1][1] - a[i+l-1]);
            dp[i][l][1] = max(dp[i+1][l-1][0] + a[i], dp[i][l-1][0] + a[i+l-1]);
        }
    }
    cout<< dp[0][n][1] <<endl;
    return 0;
}


Measured memory_bytes: 140672
#include <bits/stdc++.h>
//#define TASK "file"

#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long i64;
typedef long double dbl;
const dbl PI = acos(-1.0L);
const dbl EPS = 1e-12L;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

namespace task {
const i64 MOD = 1000000007;
const int N = 4000004;
i64 f[N];
i64 r[N];
int r1, c1, r2, c2;

i64 c(int x, int y) {
  return (((f[x + y + 2] * r[x + 1]) % MOD * r[y + 1]) % MOD + MOD - 1) % MOD;
}

template <typename T>
T inverse(T a, T m) {
  T u = 0, v = 1;
  while (a != 0) {
    T t = m / a;
    m -= t * a; swap(a, m);
    u -= t * v; swap(u, v);
  }
  assert(m == 1);
  return u;
}

int main() {
  f[0] = r[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = (f[i - 1] * i) % MOD;
    r[i] = inverse(f[i], MOD);
  }
  cin >> r1 >> c1 >> r2 >> c2;
  cout << (4 * MOD + c(r2, c2) - c(r1 - 1, c2) - c(r2, c1 - 1) + c(r1 - 1, c1 - 1)) % MOD;
  return 0;
}
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#elif defined(TASK)
  freopen(TASK".in", "r", stdin);
  freopen(TASK".out", "w", stdout);
#endif
  return task::main();
}


Measured memory_bytes: 62720
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long unsigned int

int main(void)
{
    int i, j, n, k;
    double *p;

    int pp;
    double ans = 0.0;
    double s = 0.0;
    double e = 0.0;
    j = 0;
    scanf("%d", &n);
    scanf("%d", &k);

    p = (double *)malloc(sizeof(double) * (k + 1));

    for (i = 0; i < k; i++)
    {
        scanf("%d", &pp);
        //p[i] = pp;
        p[i] = ((double)((1 + pp) * pp) / 2) / pp;
        ans += p[i];
    }
    double max = ans;
    //printf("%f\n", ans);

    for (i = k; i < n; i++)
    {
        scanf("%d", &pp);
        e = ((double)((1 + pp) * pp) / 2) / pp;

        ans -= p[j];
        ans += e;
        //printf("%f\n", ans);

        p[j] = e;
        j++;
        j = j % k;
        if (max < ans)
            max = ans;
    }
    printf("%f\n", max);
    return 0;
}

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

int main(void){
    int n,i,j,max,min,mind,a,b,x;
    cin>>n;
    vector<int> vec,vec2(n);
    for(i=0;i<n;i++){
        cin>>vec2[i];
        if(i==0)min=vec2[i];
        vec.push_back(vec2[i]-min);
        if(vec2[i]<min)min=vec2[i];
        if(i==1){
            max=vec2[i]-vec2[i-1];
        }
        if(i>=2){
            x=vec2[i]-vec2[i-1];
            if(x>max)max=x;
        }
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    if(vec[0]>0)cout<<vec[0]<<endl;
    else cout<<max<<endl;
}


Measured memory_bytes: 4700
#include <stdio.h>

#define Num 200

int s[100];
int n, res;

int solve (int i, int m) {
    if (m==0) {
        return 1;
    }
    if (i>=n) {
        return 0;
    }
    res = solve(i+1, m) || solve(i+1, m - s[i]);

    return res;
}

int main(void){

    int t[Num];
    int q, i;

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &s[i]);
    }

    scanf("%d", &q);
    for (i=0; i<q; i++) {
        scanf("%d", &t[i]);
    }

    for (i=0; i<q; i++) {
        if (solve(0, t[i])) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }

  return 0;
}


Measured memory_bytes: 2116
def main():
	r = [0]*5
	r[0] = int(input())
	r[1] = int(input())
	r[2] = int(input())
	r[3] = int(input())
	r[4] = int(input())

	total = 0
	mod_min = 10

	for x in r:
		div = x//10
		total += div*10
		mod = x%10
		if mod != 0:
			if mod < mod_min:
				mod_min = mod
			total+=10
	total = total - 10 + mod_min
	print(total)


if __name__ == '__main__':
    main()

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    i64 k;
    cin >> k;
    cout << A[k-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0;
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0)
using namespace std;
vector<int>V,L;
vector<string>Ans;
map<int,int>M;
set<ll>S;
set<char>:: iterator it;
ll n,m,a,b,c,d,e,f,x,y,z,t,l=100,r,ans,cnt,score;
string   s,winner,temp,p;
ll   arr[1001][1001];
bool xy=0;
char bd;
float ans1;
int main()
{
    TIME;
    for (int i =0;i <5; i ++ )
    {
        cin>>a;
        if (a==0)
        {
            cout<<i+1;
            r_0;
        }
    }
}


Measured memory_bytes: 3588
function main() {
    var
        nq = input[0].split(' ').map(Number),
        queue = [], process,
        total;
    input.slice(1, nq[0] + 1).forEach(function (process) {
        process = process.split(' ');
        process[1] = Number(process[1]);
        queue.push(process);
    });

    total = 0;
    while (queue.length !== 0) {
        process = queue.shift();
        if (process[1] > nq[1]) {
            process[1] -= nq[1];
            total += nq[1];
            queue.push(process);
        } else {
            total += process[1];
            console.log(process[0] + ' ' + total);
        }
    }
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    input += chunk;
});
process.stdin.on('end', function () {
    input = input.split('\n');
    main();
});

Measured memory_bytes: 42640
#include<bits/stdc++.h>
#define ll long long
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
}



Measured memory_bytes: 3636
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
    
using namespace std;

typedef long long ll;

int main() {
    int h[100];
    int n;
    cin >> n;
    for (int i = 0; i<n; i++) cin >> h[i];
    
    ll ans = h[0];
    for (int i = 0; i<n-1; i++) {
        if (h[i+1] > h[i]) {
            ans += h[i+1] -h[i];
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] L = new int[m];
        int[] R = new int[m];
        int maxL = 0;
        int minR = Integer.MAX_VALUE;
        for (int i = 0; i < m; i++) {
            L[i] = sc.nextInt();
            R[i] = sc.nextInt();
            maxL = Math.max(maxL, L[i]);
            minR = Math.min(minR, R[i]);
        }
        System.out.println(Math.max(minR - maxL + 1, 0));

    }
}


Measured memory_bytes: 64968
#include <bits/stdc++.h>
#define i64 long long
#define N (int)(1e5)
using namespace std;
int main() {
	// your code goes here
	string s; cin>>s;
	int n = s.size();
	printf("%c%d%c\n",s[0],n-2,s[n-1]);
	return 0;
}

Measured memory_bytes: 256
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input);
            
            string[] a = Console.ReadLine().Split(' ');
            string[] b = Console.ReadLine().Split(' ');
            string[] c = Console.ReadLine().Split(' ');
            long sum = 0;

           
            for(int i = 0;i < n;i++)
            {
                long ai = long.Parse(a[i]);
                sum += long.Parse(b[ai - 1]);
                if(i > 0)
                    if(long.Parse(a[i - 1]) + 1 == long.Parse(a[i]))
                        sum += long.Parse(c[ai - 2]);

            }

            Console.WriteLine(sum);
        }
    }

Measured memory_bytes: 11092
var
	S:String;
	N,Q,l,r,i:Longint;
	sum:Array[1..100000]of Longint;
begin
	readln(N,Q);
	readln(S);
	for i:=2 to length(S)do begin
		sum[i]:=sum[i-1];
		if(S[i-1]='A')and(S[i]='C')then inc(sum[i]);
	end;
	for i:=1 to Q do begin
		read(l,r);
		writeln(sum[r]-sum[l]);
	end;
end.


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int x = A;
  int y = B;
  
  int ans = 0;
  for (int i = 0; i < B - A + 1; i++) {
    int x1 = x % 10;
    int x2 = (x / 10) % 10;
    int x4 = (x / 1000) % 10;
    int x5 = x / 10000;
    
    if (x1 == x5 && x2 == x4) {
      ans++;
    }
    
    x++;
  }
  
  cout << ans << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	int i;
	int ans=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(i%2==0 && a[i]%2==1)
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3648
#!/usr/bin/env python3
# Based on ...
# https://en.wikipedia.org/wiki/Ford???Fulkerson_algorithm
# http://algoogle.hadrori.jp/algorithm/ford-fulkerson.html

import collections
import sys


REC_LIMIT = 10000
INF = 10 ** 8


class Edge(object):

    def __init__(self, source, sink, capacity):
        self.source = source
        self.sink = sink
        self.capacity = capacity
        self.rev_edge = None

    def __str__(self):
        return "Edge {} -> {} : {}".format(self.source,
                                           self.sink, self.capacity)


class FlowNetwork(object):

    def __init__(self):
        self.adj_edges = collections.defaultdict(list)
        self.flow = dict()
        self.used_edge = None

    def get_edges_from(self, vertex):
        return self.adj_edges[vertex]

    def add_edge(self, source, sink, capacity):
        assert source != sink
        f_edge = Edge(source, sink, capacity)
        b_edge = Edge(sink, source, 0)
        f_edge.rev_edge = b_edge
        b_edge.rev_edge = f_edge
        self.adj_edges[source].append(f_edge)
        self.adj_edges[sink].append(b_edge)
        self.flow[f_edge] = 0
        self.flow[b_edge] = 0

    def dfs(self, source, sink, flow):
        if source == sink:
            return flow
        self.used_edge[source] = True
        for edge in self.get_edges_from(source):
            residual = edge.capacity - self.flow[edge]
            if self.used_edge[edge.sink] or residual <= 0:
                continue
            d = self.dfs(edge.sink, sink, min(flow, residual))
            if d > 0:
                self.flow[edge] += d
                self.flow[edge.rev_edge] -= d
                return d
        return 0

    def ford_fulkerson(self, source, sink):
        max_flow = 0
        while True:
            self.used_edge = collections.defaultdict(bool)
            df = self.dfs(source, sink, INF)
            if df == 0:
                return max_flow
            else:
                max_flow += df


def main():
    sys.setrecursionlimit(REC_LIMIT)
    v, e = map(int, input().split())
    network = FlowNetwork()
    for _ in range(e):
        network.add_edge(*map(int, input().split()))
    mf = network.ford_fulkerson(0, v - 1)
    print(mf)


if __name__ == '__main__':
    main()

Measured memory_bytes: 8740
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,c,k;
cin>>n>>c>>k;
int cnt=0;

vector<int> v;
int a;
for(int i=0;i<n;i++){
cin>>a;v.push_back(a);
}
sort(v.begin(),v.end());
int latest=0;int tm=0;
for(int i=0;i<n;i++){
if(v[i]>latest) cnt++,latest=v[i]+k,tm=1;
else tm++;
if(tm==c) tm=0,latest=0;
}
cout<<cnt<<"\n";
}

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

s = [0]*n
p = [0]*n

list_2d = [[] for _ in range(n)]

for i in range(n):
    s, p = input().split()
    list_2d[i].append(s)
    list_2d[i].append(p)
list_2d_sorted = sorted(list_2d, key = lambda x: (x[0],-int(x[1])))
for i in range(n):
    print(list_2d.index(list_2d_sorted[i])+1)

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

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(len(A)):
    if i != 0:
        if A[i] == A[i-1]+1:
            ans += B[A[i]-1]
            ans += C[A[i-1]-1]
        else:
            ans += B[A[i]-1]
    else:
        ans +=B[A[i]-1]

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    ll n;
    vector<ll> a(5);
    cin >> n;
    for (ll i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    sort(a.begin(), a.end());
    ans = (n + a[0] - 1) / a[0] + 4;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;

int main () {
	char a[3], b[3];
	scanf("%s%s", &a, &b);
	if (a[0] != b[2]) {
		printf("NO\n");
		return 0;
	}
	if (a[1] != b[1]) {
		printf("NO\n");
		return 0;
	}
	if (a[2] != b[0]) {
		printf("NO\n");
		return 0;
	}
	printf("YES");
	return 0;
}

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

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

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

ll count_two(ll x){
    ll i=0;
    while(x%2==0){
        i++;
        x=x/2;
    }
    return i;
}

ll power(ll c){
    ll i=1;
    rep(j,c){
        i*=2;
    }
    return i;
}

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    bool odd=true;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==1)odd=false;

    }
    if(!odd){
        cout<<0<<endl;
        return 0;
    }

    ll b = count_two(a[0]);
    a[0]=a[0]/power(b);
    rep2(1,i,n){
        int c = count_two(a[i]);
        a[i]=a[i]/power(c);
        if(c!=b){
            odd=false;
            break;
        }
    }
    if(!odd){
        cout<<0<<endl;
        return 0;
    }
    ll min=1;
    rep(i,n){
        min=lcm(min,a[i]);
    }

    ll ans=0;
    ans=(2*m)/(power(b)*min);
    ans=(ans+1)/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979
#define EPS 1e-8
#define mod  998244353
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define endl "\n"
#define NEG_INF -2e18
			 
const ll INF=1e15;	
const int N=2e5+50;
		 
 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(0);
		
	int is=0,cnt=0;
	ll t;
	cin>>t;
	while(t)
	{
		t--;
		ll a,b;
		cin>>a>>b;
		if(a==b)
		{
			cnt++;
		}
		else
			cnt=0;
		//cout<<cnt<<endl;
		if(cnt==3)
		{
			is=1;
		}
		
	}
	if(is)
		cout<<"Yes";
	else
		cout<<"No";
}


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


int main() {
  int n;
  int a;

  cin >> n;
  
  a = n;
  while (n > 2) {
    if (a % 2 == 0) {
      a++;
      continue;
    }
    int n1 = sqrt(a);
    int flag = 0;
    for (int i = 3; i <= n1; i += 2) {
      if (a % i == 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      break;
    }
    a++;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = [[] for _ in range(m)]
 
for i in range(n):
  a, b = map(int, input().split())
  if a <= m:
    l[a-1].append(b)

import heapq
a = []
ans = 0
heapq.heapify(a)
for i in range(m):
  for j in range(len(l[i])):
    heapq.heappush(a, (-1)*l[i][j])
  if len(a) != 0:
    ans += heapq.heappop(a)*(-1)
print(ans)



Measured memory_bytes: 18328
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String line = br.readLine();
			String[] tmp = line.split(" ");
			String lng = "a";
			int[][] cnt = new int[tmp.length][2];
			int max = 0, maxIndex = 0;
			for(int i=0; i<tmp.length; i++) {
				if(lng.length() < tmp[i].length()) {
					lng = tmp[i];
				}
				for(int j=0; j<=i; j++) {
					if(tmp[i].equals(tmp[j])) {
						cnt[i][1]++;
					}
				}
				cnt[i][0] = cnt[i][1];
				cnt[i][1] = 0;
				if(cnt[i][0] > max) {
					max = cnt[i][0];
					maxIndex = i;
				}
			}
			System.out.println(tmp[maxIndex] + " " + lng);
		} catch (Exception e) {
			
		}
	}

}

Measured memory_bytes: 16904
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8 = { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 },
			{ 1, 1 } };
	static int[][] directions4 = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {

			int n = sc.nextInt();
			int m = sc.nextInt();
			int p = sc.nextInt();

			if ((n | m | p) == 0) {
				break;
			}
			// 各競技者の投票数
			int[] x = new int[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				// 
				x[i] = sc.nextInt();
				sum += x[i];
			}
			if (x[m - 1] == 0) {
				ans = 0;
			} else {
				ans = sum * 100 * (100 - p) / 100 / x[m - 1];
			}
			System.out.println(ans);

		}

	}

	// BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for (int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	// //二分探索
	// k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray) {
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedArray[mid] <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// 二分探索
	// k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList) {
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedList.get(mid) <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}



Measured memory_bytes: 36864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            char[] atcoder = new char[4] { 'A', 'C', 'G', 'T' };

            int succ = 0;

            int ans = 0;

            for (int i = 0; i < S.Length; i++) {
                if (atcoder.Contains(S[i])) {
                    succ++;
                    ans = Math.Max(ans, succ);
                } else {
                    succ = 0;
                }

            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
#include <stdio.h>
int n, m, x, t, e, o, f, ans;
int c[12];
int b[12];
int y[12];
int a[12][12];
int main() {
	scanf("%d%d%d", &n, &m, &x);
	t = 1;
	ans = 2000000;
	for (int i = 0; i < n; i++) {
		scanf("%d", c + i);
		for (int j = 0; j < m; j++) {
			scanf("%d", a[i] + j);
		}
		t *= 2;
	}
	for (int i = 0; i < t; i++) {
		e = i;
		o = 0;
		for (int j = 0; j < n; j++) {
			b[j] = e % 2;
			e /= 2;
			if (b[j])o += c[j];
		}
		for (int j = 0; j < m; j++) {
			y[j] = 0;
		}
		for (int j = 0; j < n; j++) {
			if (b[j]) {
				for (int k = 0; k < m; k++) {
					y[k] += a[j][k];
				}
			}
		}
		f = 1;
		for (int j = 0; j < m; j++) {
			if (y[j] < x)f = 0;
		}
		if (f && o < ans)ans = o;
	}
	if (ans == 2000000)printf("-1\n");
	else printf("%d\n", ans);
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int dp[200100];
int main(){
 int N; cin >> N; 
  for(int i = 0; i < 200100; i++){ dp[i] = 0;}
  for(int i = 0; i < N; i++){
    int p; cin >> p; //最後がpの部分列の最長長さをdp[p]とする
    dp[p] = dp[p-1] + 1 ;}
  int res = 0;
  for(int i = 0; i < 200100; i++){ res = max(res, dp[i]);}
  
  cout << N - res << endl; return 0;}

Measured memory_bytes: 1024
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    S = input()
    S = S.replace("LR", "L,R")
    S = S.split(",")
    answer = []
    for s in S:
        ans = []
        s = s.replace("RL", "R,L")
        s = s.split(",")
        len_r = len(s[0])
        len_l = len(s[1])
        if (len_r + len_l) % 2 == 0:
            ans = (
                [0 for _ in range(len_r - 1)]
                + [(len_r + len_l) // 2, (len_r + len_l) // 2]
                + [0 for _ in range(len_l - 1)]
            )
        elif len_r % 2 == 1:
            ans = (
                [0 for _ in range(len_r - 1)]
                + [(len_r + len_l) // 2 + 1, (len_r + len_l) // 2]
                + [0 for _ in range(len_l - 1)]
            )
        else:
            ans = (
                [0 for _ in range(len_r - 1)]
                + [(len_r + len_l) // 2, (len_r + len_l) // 2 + 1]
                + [0 for _ in range(len_l - 1)]
            )
        answer += ans
    print(*answer, sep=" ")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9400
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 0 && b >= 0) {
    cout << "Zero" << endl;
  } else if (b < 0) {
    if ((b - a) % 2 == 1) {
      cout << "Positive" << endl;
    } else {
      cout << "Negative" << endl;
    }
  } else {
    cout << "Positive" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
const int INF = 10000000;
int wf[101][101];

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

	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			wf[i][j] = i == j ? 0 : INF;
		}
	}
	for(int i = 0; i < n; i++) {
		int a, t;
		cin >> a >> t;
		while(t--) {
			int b;
			cin >> b;
			wf[a][b] = 1;
		}
	}

	for(int k = 1; k <= n; k++)
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);

	int q;
	cin >> q;
	while(q--) {
		int s, d, v;
		cin >> s >> d >> v;
		if(wf[s][d] >= v) {
			cout << "NA" << endl;
		}
		else {
			cout << wf[s][d] + 1 << endl;
		}
	}
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000,mod=1000000007,n;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,m;
    cin>>n>>m;
    n=((n)*(n-1))/2;
    m=((m)*(m-1))/2;
    cout<<n+m<<endl;
}


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

int main() {
  int x, y;
  cin >> x >> y;
  cout << (x-1)*(y-1) << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<random>
using namespace std;


int main()
{
	vector<int> ans;
	while (1) {
		int N, M;
		cin >> N >> M;
		if (N == 0) break;
		int d, v;
		vector<priority_queue<int>> m(M);
		for (int i = 0; i < N; ++i) {
			cin >> d >> v;
			m[d - 1].push(v);
		}
		int A = 0;
		for (const auto& l : m) {
			A += l.top();
		}
		ans.push_back(A);
	}
	for (const auto& a : ans) {
		cout << a << endl;
	}
	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

int main() {
    ll n;
    cin >> n;
    ll cnt = 0;
    for(ll r = 1; r*r < n; ++r) {
        if (n%r == 0) {
            ll m = n/r - 1;
            if (m > r) cnt += m;
        }
    } 
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    std::vector<string> s(n); rep(i,n) cin >> s[i];

    std::map<string, int> mp;
    std::vector<string> v(n);

    rep(i,n) mp[s[i]]++;

    int val = 0;

    for(const auto &p : mp){

        if(val < p.second){
            v = vector<string>(0); v.push_back(p.first);
            val = p.second;
        } else if (val==p.second){
            v.push_back(p.first);
        }
    }

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

    rep(i,v.size()) cout << v[i] << endl;

    return 0;
}

Measured memory_bytes: 29028
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int arr[upperlimit];
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	int n,x=0;
	sd(n);
	for(int i = 1; i <= n; i++){
		sd(arr[i]);
		x^=arr[i];
	}
	for(int i = 1; i <= n; i++) pds(x^arr[i]);
	return 0;
}

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
const string space=" ";
int main()
{
    string s,m,k;
    ll n,t,sum=0;
    bool fg=0,mg=0;
    cin>>s>>m;
   soja(i,0,m.size()-2)
   {
       k+=m[i];
   }
    if(k==s)
        cout<<"Yes"<<endl;
    else
     cout<<"No"<<endl;
}


Measured memory_bytes: 3600