akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

char choco[11][1001];
int sum[11][1001];

int getwhite(int y2, int x2, int y1, int x1){
	return sum[y2][x2] - sum[y1][x2] - sum[y2][x1] + sum[y1][x1];
}

int main(){
	int h, w, lim, ans = MOD;
	cin >> h >> w >> lim;
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			cin >> choco[i][j];
		}
	}

	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
			if (choco[i][j] == '1'){
				sum[i][j]++;
			}
			//cout << sum[i][j];
		}
		//cout << endl;
	}

	for (int i = 0; i < (1<<h); i++){
		vector<int> divide;
		divide.push_back(0);
		int tmpans = 0;
		for (int j = 0; j < h; j++){
			if (i & (1<<j)){
				//cout << "1 ";
				divide.push_back(j+1);
				tmpans++;
			}else{
				//cout << "0 ";
			}
		}
		//cout << endl;
		divide.push_back(h);
		/*
		for (int j = 0; j < divide.size()-1; j++){
			cout << divide[j+1] << " " << w << " " << divide[j] << " " << 0 << endl;
 			cout << getwhite(divide[j+1], w, divide[j], 0) << endl;
		}
		*/
		bool flg = true;
		int tate = 0;
		for (int j = 0; j < w; j++){
			for (int k = 0; k < divide.size()-1; k++){
				//cout << getwhite(divide[k+1], j+1, divide[k], tate) << endl;
				if (getwhite(divide[k+1], j+1, divide[k], tate) > lim){
					if (tate == j){
						j = MOD, k = MOD;
						flg = false;
					}else{
						tate = j;
						tmpans++;
					}
				}
			}
		}
		if (flg){
			ans = min(ans, tmpans);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var (
	reader io.Reader = os.Stdin
	writer io.Writer = os.Stdout
)

func main() {
	run()
}

func run() {
	scanner := bufio.NewScanner(reader)
	scanner.Scan()
	N, _ := strconv.Atoi(scanner.Text())

	nums := make([]int, 0, N)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		nums = append(nums, num)
	}

	sort.Ints(nums)
	count := 1

	for i := 1; i < N; i++ {
		if nums[i] > nums[i-1] {
			count++
		}
	}

	fmt.Fprintln(writer, count)
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////


void solve() {
	int N, S;
	cin >> N >> S;
	vector<LL> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	vector<vector<LL>>dp(N + 1, vector<LL>(S + 1,0));
	dp[0][0] = 1;
	const LL mod = 998244353;
	for (LL i = 0; i < N; ++i) {
		for (LL s = 0; s <= S; ++s) {
			if (dp[i][s] == 0)continue;

			//使わない
			dp[i + 1][s] += dp[i][s];//
			dp[i + 1][s] %= mod;

			//使う
			LL ter = s + A[i];
			if (ter > S)continue;
			LL add = dp[i][s];
			if (s == 0) {
				add = (add*(i+1))%mod;
			}
			if(ter == S){
				add = (add * (N-i)) % mod;
			}
			dp[i + 1][ter] += add;
		}
	}
	LL ans = dp[N][S];
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int MOD = 1000000007;

int n, a, b, c, res;

// rozwiązuje równanie ax=1(%MOD), gdy MOD pierwsze
int inverse(int a, int n = MOD - 2) {
	int r = 1;
	while (n) {
		if (n % 2) r = (r * 1LL * a) % MOD;
		a = (a * 1LL * a) % MOD;
		n >>= 1;
	}
	return r;
}

void go(int a, int b) {
	int l1, l2, k1, k2, w1, w2, i, licz, mian;
	l1 = 1;
	l2 = 1;
	for (i=1;i<=n;i++) {
		l1 = (l1 * 1LL * a) % MOD;
		l2 = (l2 * 1LL * (a + b)) % MOD;
	}
	k1 = 1;
	k2 = 1;
	w1 = 1;
	w2 = 1;
	for (i=0;i<n;i++) {
		licz = (((((l1 * 1LL * k1) % MOD) * w1) % MOD) * (n + i)) % MOD;
		mian = (((l2 * 1LL * k2) % MOD) * w2) % MOD;
		res = (res + ((inverse(mian) * 1LL * licz) % MOD)) % MOD;
		k1 = (k1 * 1LL * b) % MOD;
		k2 = (k2 * 1LL * (a + b)) % MOD;
		w1 = (w1 * 1LL * (n + i)) % MOD;
		w2 = (w2 * 1LL * (i + 1)) % MOD;
	}
}

int main() {
srand(time(0));
scanf("%d %d %d %d", &n, &a, &b, &c);
res = 0;
if (a > 0) go(a, b);
if (b > 0) go(b, a);
if (c > 0) res = (((res * 1LL * inverse(100 - c)) % MOD) * 100LL) % MOD;
printf("%d\n", res);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;

    int v1x=x2-x1;
    int v1y=y2-y1;
    int v2x=-v1y;
    int v2y=v1x;
    cout<<x2+v2x<<" "<<y2+v2y<<" "<<x1+v2x<<" "<<y1+v2y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin,(x).end()

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A1(N), A2(N);
    REP(i,0,N) cin >> A1[i];
    REP(i,0,N) cin >> A2[i];

    ll sum = A1[0];
    REP(i,0,N) sum += A2[i];

    ll m = sum;
    REP(i,1,N) {
        sum = sum - A2[i-1] + A1[i];
        m = MAX(m,sum);
    }

    PR(m);

    return 0;
}

/*



*/

Measured memory_bytes: 3616
#include <algorithm>
#include <cstdio>
#include <map>
#include <numeric>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;

template <typename Monoid>
struct binary_indexed_tree { // on monoid
    typedef typename Monoid::underlying_type underlying_type;
    vector<underlying_type> data;
    Monoid mon;
    binary_indexed_tree(size_t n, Monoid const & a_mon = Monoid()) : mon(a_mon) {
        data.resize(n, mon.unit());
    }
    void point_append(size_t i, underlying_type z) { // data[i] += z
        for (size_t j = i + 1; j <= data.size(); j += j & -j) data[j - 1] = mon.append(data[j - 1], z);
    }
    underlying_type initial_range_concat(size_t i) { // sum [0, i)
        underlying_type acc = mon.unit();
        for (size_t j = i; 0 < j; j -= j & -j) acc = mon.append(data[j - 1], acc);
        return acc;
    }
    underlying_type range_concat(size_t l, size_t r) {
        return mon.append(initial_range_concat(r), mon.invert(initial_range_concat(l)));
    }
};
template <int mod>
struct modplus_t {
    typedef int underlying_type;
    int unit() const { return 0; }
    int append(int a, int b) const { int c = a + b; return c < mod ? c : c - mod; }
    int invert(int a) const { return a ? mod - a : 0; }
};

template <typename T>
map<T,int> coordinate_compression_map(vector<T> const & xs) {
    int n = xs.size();
    vector<int> ys(n);
    whole(iota, ys, 0);
    whole(sort, ys, [&](int i, int j) { return xs[i] < xs[j]; });
    map<T,int> f;
    for (int i : ys) {
        if (not f.count(xs[i])) { // make unique
            int j = f.size();
            f[xs[i]] = j; // f[xs[i]] has a side effect, increasing the f.size()
        }
    }
    return f;
}
template <typename T>
vector<int> apply_compression(map<T,int> const & f, vector<T> const & xs) {
    int n = xs.size();
    vector<int> ys(n);
    repeat (i,n) ys[i] = f.at(xs[i]);
    return ys;
}
void sort_with_pair(int n, vector<int> & a, vector<int> & b) {
    vector<pair<int, int> > c(n);
    repeat (i, n) {
        c[i] = { a[i], b[i] };
    }
    whole(sort, c);
    repeat (i, n) {
        tie(a[i], b[i]) = c[i];
    }
}

constexpr int mod = 1e9+7;
int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> x(n), v(n); repeat (i, n) scanf("%d%d", &x[i], &v[i]);
    x = apply_compression(coordinate_compression_map(x), x);
    v = apply_compression(coordinate_compression_map(v), v);
    // solve
    sort_with_pair(n, x, v);
    vector<int> l(n); // [l, r)
    l[n - 1] = v[n - 1];
    repeat_reverse (i, n - 1) {
        l[i] = min(l[i + 1], v[i]);
    }
    vector<int> r(n);
    r[0] = v[0] + 1;
    repeat (i, n - 1) {
        r[i + 1] = max(r[i], v[i + 1] + 1);
    }
    binary_indexed_tree<modplus_t<mod> > dp(n + 1);
    dp.point_append(0, 1);
    repeat (i, n) {
        dp.point_append(r[i], dp.range_concat(l[i], r[i] + 1));
    }
    // output
    printf("%d\n", dp.range_concat(n, n + 1));
    return 0;
}


Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
char g[10][10];
int h,w;
int getbit(int x,int pos){
    return (x >> pos) & 1;
}
int fun(int row,int col){
    int cnt = 0;
    for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
        if(g[i][j] == '#'){
            if(getbit(row,i) == 0 && getbit(col,j) == 0 ){
                cnt++;
            }
        }
    }
  }

    return cnt;
}
int main() {
  int k,ans = 0;
  cin >> h >> w >> k;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
        cin >> g[i][j];
    }
  }
  for(int i = 0; i < (1 << h); i++){
    for(int j = 0; j < (1 << w); j++){
        if(fun(i,j) == k)
            ans++;
    }
  }
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3508
#include <cstdio>
#include <map>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
const int Max = 2e5;

int d[Max + 5], t[Max + 5];
map <int, int>cnt;
map <int, int>tot;

int main()
{
	int n, m;
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++){
		scanf ("%d", &d[i]);
		cnt[d[i]]++;
	}
	scanf ("%d", &m);
	for (int i = 1; i <= m; i++){
		scanf ("%d", &t[i]);
		tot[t[i]]++;
	}
	if (m > n){
		printf ("NO\n");
		return 0;
	}
	for (int i = 1; i <= m; i++){
		if (tot[t[i]] > cnt[t[i]]){
			printf ("NO\n");
			return 0;
		}
	}
	printf ("YES\n");
}

Measured memory_bytes: 22528
H,W,K = [int(hoge) for hoge in input().split()]
Hbit = 2**H
Wbit = 2**W
ans = 0
C = [input() for c in range(H)]
for i in range(Hbit):
    Xselected = [1&(i>>x) for x in range(H)]
    for j in range(Wbit):
        Yseledted = [1&(j>>y) for y in range(W)]
        k = 0
        for m,x in enumerate(Xselected):
            for n,y in enumerate(Yseledted):
                if (x==1 and y==1) and (C[m][n]=="#"):
                    k += 1
        if k==K:
            ans += 1
print(ans)

Measured memory_bytes: 9212
from collections import OrderedDict
n, x, y = map(int, input().split())
x = x-1
y = y-1
dist_hist = OrderedDict({i: 0 for i in range(1, n)})
for i in range(n-1):
  for j in range(i+1, n):
    if i<=x and j>=y:
      dist = j-i + 1 - (y-x)
    elif i<=x and x<j<y:
      dist = min(j-i, x-i + 1 + y-j)
    elif x<i<y and y<=j:
      dist = min(i-x + 1 + j-y, j-i)
    elif x<i<y and x<j<y:
      dist = min(j-i, i-x + 1 + y-j)
    else:
      dist = j - i
    dist_hist[dist] += 1
[print(value) for value in dist_hist.values()]

Measured memory_bytes: 69560
#include <iomanip>
#include <iostream>

typedef struct {
    int x;
    int y;
} point;

double calc_s(point p[], int length);
double calc_s_triangle(point p1, point p2, point p3);
double calc_s_triangle(point p1, point p2);

int main()
{
    point p[100];
    int number_point;
    int px,py;
    std::cin >> number_point;
    for (int i = 0; i < number_point; i++) {
        scanf("%d %d", &px, &py);
        p[i].x = px;
        p[i].y = py;
    }
    std::cout <<std::fixed << std::setprecision(1) << calc_s(p, number_point) << std::endl;
    return 0;
}

double calc_s(point p[], int length)
{
    double area = 0;
    for (int i = 1; i < length - 1; i++) {
        area += calc_s_triangle(p[0], p[i], p[i+1]);
    }
    return area;
}

double calc_s_triangle(point p1, point p2, point p3)
{
    //p3???????????????????§????
    p1.x -= p3.x;
    p1.y -= p3.y;
    p2.x -= p3.x;
    p2.y -= p3.y;
    return calc_s_triangle(p1, p2);
}

double calc_s_triangle(point p1, point p2) {
    double s = (p1.x * p2.y - p1.y * p2.x) / 2.0;
    return s;
}

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

int main() {
    int n;

    cin >> n;

    int* a = new int[n];

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

    for (int i = 0, light = 1; i < n; ++i) {
        light = a[light - 1];
        if (light == 2) {
            cout << (i + 1) << endl;
            delete a;
            return 0;
        }
    }
    cout << -1 << endl;

    delete a;
    return 0;
}


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

using std::cin;
using std::cout;
using std::cerr;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using std::sort;
using std::reverse;

using ll = long long;

#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())
#define endl '\n'

struct __init {
    __init() {
        cin.tie(nullptr);
        std::iostream::sync_with_stdio(false);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(5);
        std::mt19937 rand(300);
    }

    ~__init() {
        #ifdef SEREZHKA
            cerr << "Time elapsed: " << static_cast<double>(clock()) / CLOCKS_PER_SEC << endl;
        #endif
    }
} init;

const ll inf = (ll) 1e9 + 7ll;
const int maxn = (int) 1e3 + 17;

#define x1 fhdsk
#define x2 fsdlhsfs
#define y1 rsfks
#define y2 hjasaldkjgdfksl

int n;
int x1[maxn], y1[maxn], x2[maxn], y2[maxn], mt[maxn];
vector<int> g[maxn];
bool used[maxn];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> x1[i] >> y1[i];

    forn (i, n)
        cin >> x2[i] >> y2[i];

    return true;
}

bool dfs(int v) {
    if (used[v])
        return false;

    used[v] = true;

    for (auto to : g[v])
        if (mt[to] == -1 || dfs(mt[to])) {
            mt[to] = v;
            return true;
        }

    return false;
}

void solve() {
    int ans = 0;

    forn (i, n)
        forn (j, n)
            if (x1[i] < x2[j] && y1[i] < y2[j])
                g[i].push_back(j);

    memset(mt, -1, sizeof(mt));

    forn (i, n) {
        memset(used, false, sizeof(used));
        dfs(i);
    }

    forn (i, n)
        ans += (mt[i] != -1);

    cout << ans << endl;
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n; cin >> n;
  ll u=0,d=0;
  vector<vector<int>> data(2, vector<int>(n,0));
  rep(i,n){cin >> data[0][i];}
  u=data[0][0];
  rep(i,n){cin >> data[1][i]; d += data[1][i];}

  ll ans=u+d;
  for(int i=1; i<n; i++){
    u += data[0][i];
    d -= data[1][i-1];
    ans = max(ans, u+d);
  }
  

  cout << ans << endl;    
  return 0;
}


Measured memory_bytes: 384
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 
using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

multiset<int> S;

int output = 0 ;

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		S.insert(x);
	}
	while(m--){
		auto it = S.end();
		it--;
		int x = *it/2;
		S.erase(it);
		S.insert(x);
	}
	for(int it:S){
		output+=it;
	}
	cout<<output;
	return 0;
}


Measured memory_bytes: 4992
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	d := make([]int, N)
	for i := 0; i < N; i++ {
		d[i] = sc.NextInt()
	}
	sort.Ints(d)

	c := 0
	ans := 0
	for i := 0; i < N; i++ {
		if c < d[i] {
			c = d[i]
			ans++
		}
	}
	fmt.Println(ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	int r, g, b;
	cin >> r >> g >> b;
	cout << ((100 * r + 10 * g + b) % 4 == 0 ? "YES" : "NO") << endl;
	return 0;
}

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

#define int long long
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 
#define LL_MAX 9223372036854775807
#define MOD 1000000007

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

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

    int n,k;

    cin >> n >> k;

    int sum = 0;

    rap(i,k,n+2) {
        sum = (sum + i*n - i*(i-1) + 1)%MOD;
    }

    cout << sum << '\n';



    return 0;
    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}


Measured memory_bytes: 3600
n = int(input())
ans = 0
num_list = sorted([ int(v) for v in input().split() ],reverse = True)

a, b = -1, -1
d = 0

for i in range(n-1):
	if num_list[i] != num_list[i+1]:
		d = 0
	else:
		if a != -1 and d == 0:
			b = num_list[i]
			ans = a*b
			break
		else:
			d += 1
			a = num_list[i]
			if d == 3:
				ans = a**2
				break

print(ans)

Measured memory_bytes: 14668
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			Set<Integer> set = new HashSet<Integer>();
			
			for(int i = 1; i < n; i++){
				set.add((i*i) % n);
			}
			
			int[] count = new int[(n-1/2)];
			final int elems = set.size();
			final Integer[] array = set.toArray(new Integer[0]);
			
			for(int i = 0; i < elems; i++){
				for(int j = 0; j < elems; j++){
					if(i == j){
						continue;
					}
					
					int tmp = array[i] - array[j];
					if(tmp < 0){
						tmp += n;
					}
					if(tmp > (n-1)/2){
						tmp = n - tmp;
					}
					
					count[tmp-1]++;
				}
			}
			
			for(int i = 0; i < (n-1)/2; i++){
				System.out.println(count[i]);
			}
		}
		
	}
	
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  int n, k;
  cin >> n >> k;

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

  for (int i = 0; i < n; ++i) {
    int x; cin >> x;

    if (pq.size() < k) pq.push(x);
    else if (pq.size() >= k && x > pq.top()) {
      pq.pop();
      pq.push(x);
    }
  }

  int res = 0;
  while (!pq.empty()) {
    res += pq.top(); pq.pop();
  }

  cout << res << "\n";
}


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

const int N=2e3+20;

int n,x,y,dp[N],ans[N];
vector <int> adj[N];
bool vis[N];
queue <int> q;

void reset()
{
	for(int i=1;i<=n;i++) dp[i]=INT_MAX;
}

void add(int node,int dist)
{
	q.push(node);
	dp[node]=dist;
}

void bfs(int node)
{
	reset();
	add(node,0);
	while(not q.empty())
	{
		node=q.front();
		q.pop();
		ans[dp[node]]++;
		for(auto child:adj[node])
			if(dp[child]==INT_MAX) add(child,dp[node]+1);
	}
}

int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<n;i++)
	{
		adj[i].push_back(i+1);
		adj[i+1].push_back(i);
	}
	adj[x].push_back(y);
	adj[y].push_back(x);

	for(int i=1;i<=n;i++) bfs(i);
	for(int i=1;i<=n-1;i++) printf("%d\n",ans[i]>>1);
}

Measured memory_bytes: 384
S = input()
T = ''.join(list(reversed(S)))
N = len(S)
T1 = "".join(list(reversed(S[:int((N-1)/2)])))
T2 = ''.join( list( reversed( S[int((N+3)/2)-1:] ) ) )

Ans = "Yes"

if S != T or S[:int((N-1)/2)] != T1 or S[int((N+3)/2)-1:] != T2:
    Ans = "No"

print(Ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >>N;
  string color="Three";
  for(int i=0;i<N;i++){
    cin>>S;
    if (S=="Y"){
      color="Four";
      break;
    }else{
      continue;
    }
  }
  cout<<color<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  cin>>vec.at(0);
  for(ll i=1;i<a;i++){
    ll b;
    cin>>b;
    vec.at(i)=vec.at(i-1)+b;
  }
  ll c=vec.at(a-1)/2.0;
  ll d,e;
  for(ll i=0;i<a-1;i++){
    if(vec.at(i)<=c&&vec.at(i+1)>=c){
      d=vec.at(i);
      e=vec.at(i+1);
    }
  }
  cout<<min(abs(vec.at(a-1)-2*e),abs(vec.at(a-1)-2*d));
  return 0;
  
    
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include<queue>
using namespace std;
int main () {
  int H, W, K;
  cin >> H >> W >> K;
  int cake[500][500];
  queue<int>qi;
  queue<int>qj;
  for (int i = 0; i < H; i ++) {
    for (int j = 0; j < W; j ++) {
      cake[i][j] = 0;
      char c;
      cin >> c;
      if (c == '#') {
        cake[i][j] = K;
        K --;
        qi.push(i);
        qj.push(j);
      }
    }
  }
  while (!qi.empty()) {
    int i = qi.front();
    int j = qj.front();
    if (i < H - 1 && cake[i + 1][j] == 0) {
      cake[i + 1][j] = cake[i][j];
      qi.push(i + 1);
      qj.push(j);
    }
    if (i > 0 && cake[i - 1][j] == 0) {
      cake[i - 1][j] = cake[i][j];
      qi.push(i - 1);
      qj.push(j);
    }
    qi.pop();
    qj.pop();
  }
  for (int i = 0; i < H; i ++) {
    for (int j = 1; j < W; j ++) {
      if (cake[i][j] == 0) cake[i][j] = cake[i][j - 1];
    }
  }
  for (int i = 0; i < H; i ++) {
    for (int j = W - 1; j > 0; j --) {
      if (cake[i][j - 1] == 0) cake[i][j - 1] = cake[i][j];
    }
  }
  for (int i = 0; i < H; i ++) {
    for (int j = 0; j < W; j ++) {
      cout << cake[i][j];
      if (j < W - 1) cout << ' ';
    }
    cout << endl;
  }
}


Measured memory_bytes: 2048
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    ll ans=1;
    ll mod = 1000000007;
    if(abs(n-m)>1){
        ans = 0;
    }else{
        for(int i=1; i<=n; i++){
            ans = ans*i%mod;
            //cout << ans << endl;
        }
        for(int i=1; i<=m; i++){
            ans = ans*i%mod;
            //cout << ans << endl;
        }
        if(n==m){
            ans = ans*2%mod;
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

#define MAX_SQRT_B 1000005
#define MAX_L 1000005

typedef long long ll;

bool is_prime[MAX_L];
bool is_prime_small[MAX_SQRT_B];

int main(){
    while(1){
        ll n;
        ll p=0;
        scanf("%lld",&n);
        if(n==0){
            break;
        }
        for (int i = 0; (ll)i*i <= 2*n; i++) is_prime_small[i] = true;
        for (int i = 0; i <= n; i++) is_prime[i] = true;

        for(int i= 2; (ll)i*i <= 2*n;i++){
            if(is_prime_small[i]){
                for (int j = 2*i; (ll)j*j <= 2*n ; j+= i) is_prime_small[j] = false;
                for(ll j = max(2LL,(n+i-1)/i)*i;j <= 2*n;j+= i)is_prime[j-n] = false;
            }
        }
        for (ll i = n+1; i <= 2*n; i++){
            if(is_prime[i-n]){
                p++;
            }
        }
        printf("%lld\n",p);

    }

}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main()
{
  int n,k;
  cin>>n>>k;
  
  int a[n];
  vector<long long int> b(n);
  
  for(int i=0;i<n;i++)
  {
  	cin>>a[i];
  }
  
  b[1]=fabs(a[1]-a[0]);
  
  for(int i=2;i<n;i++)
  {
  	long long int x=1000000000;
  	
  	for(int j=1;j<=k && i-j>=0;j++)
  	{
	    if(x>(b[i-j] + fabs(a[i-j]-a[i])))
	    x=b[i-j] + fabs(a[i-j]-a[i]);
	}
	
	b[i]=x;
  }

  cout<<b[n-1];
  
  return 0;
}

Measured memory_bytes: 1408
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, x = inpl()
A = inpl()

min_index = A.index(min(A))
B = A[min_index:] + A[:min_index]

cost = [B[i] for i in range(N)]

ans = INF
for magic in range(N):
    for i in range(N):
        if i - magic >= 0:
            cost[i] = min(cost[i], B[i - magic])

    ans = min(ans, sum(cost) + x * magic)

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
int main(){
  int N,ans=0,digit=0;
  std::cin>>N;
  int temp=N;
  while(temp!=0){
    temp/=10;
    digit++;
  }
  for(int i=1;i<=digit;i++){
    if(i!=digit){
      if(i%2==1){
        ans+=std::pow(10,i-1)*9;
      }
  	}else{
      if(i%2==1){
        ans+=N-std::pow(10,i-1)+1;
      }
    }
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var q = Partation(a, 0, a.Length - 1);

        Console.WriteLine(string.Join(" ", a.Select((elem, ind) => ind == q ? $"[{elem}]" : elem.ToString())));
    }

    static int Partation(int[] a, int p, int r)
    {
        var x = a[r];
        int i = p - 1;
        for (int j = p; j < r; j++)
        {
            if (a[j] <= x)
            {
                i++;
                { var tmp = a[i]; a[i] = a[j]; a[j] = tmp; }
            }
        }
        i++;
        { var tmp = a[r]; a[r] = a[i]; a[i] = tmp; }
        return i;
    }
}



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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    if((a & 1) != (b & 1))
        cout << "IMPOSSIBLE";
    else
        cout << (a + b) / 2;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include<algorithm>

using namespace std;

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

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

  //累積わ
  vector<long long > b(n);
  b[0] = a[0];
  for(int i = 1; i < n; i++) {
    b[i] = a[i] + b[i-1];
    //cout << "i: " << i <<" " << b[i]  << endl;
  }

  int cnt =0;
  for(int i = n-2; i >= 0; i--) {
    if(b[i] * 2>= a[i+1]) {
      cnt++;
    }else {
      //cout << b[i] <<" " << a[i+1] << endl;
      break;
    }
  }

  cout << cnt + 1 << endl;

  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    string s; cin >> s;
    int x1=0, x2=0, z=0;
    for(auto c:s) {
        if(z==0){
            if (c=='1') ++x1;
            else ++x2;
        } else {
            if (c=='0') ++x1;
            else ++x2;
        }
        z=1-z;
    }
    cout << min(x1,x2) << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		int enda = 0, startb = 0, startbenda = 0;
		for(int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			for(int j = 0; j < s.length-1; j++) {
				if(s[j] == 'A' && s[j+1] == 'B')
					ans++;
			}
			if(s[0] == 'B' && s[s.length-1] == 'A')
				startbenda++;
			if(s[0] == 'B')
				startb++;
			if(s[s.length-1] == 'A')
				enda++;			
		}
		ans += Math.min(enda, startb);
		if(enda == startbenda && startb == startbenda && startbenda != 0)
			ans--;
		System.out.println(ans);

	}

}

Measured memory_bytes: 29956
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;


typedef int Weight;
struct Edge {
  int src, dst;
 
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
 
typedef pair<int,int> pii;
map<pii, int> se;
vector<pii> ans;
 
#define RESIDUE(s,t) (capacity[s][t]-flow[s][t])
Weight edmonds_karp(Graph &g, int s, int t) {
  int n = g.size();
  Matrix flow(n, Array(n)), capacity(n, Array(n));
  REP(u,n) FOR(e,g[u]) capacity[e->src][e->dst] += e->weight;
   
  Weight total = 0;
  while(1) {
    queue<int> Q; Q.push(s);
    vector<int> prev(n, -1); prev[s] = s;
    while(!Q.empty() && prev[t] < 0) {
      int u = Q.front(); Q.pop();
      REP(v, n) if (prev[v] < 0 && RESIDUE(u, v) > 0) {
        prev[v] = u;
        Q.push(v);
      }
    }
    if (prev[t] < 0) break;
    Weight inc = INF;
    for (int j=t; prev[j]!=j; j=prev[j])
      inc = min(inc, RESIDUE(prev[j], j));
    for (int j=t; prev[j]!=j; j=prev[j])
      flow[prev[j]][j] += inc, flow[j][prev[j]] -= inc; 
    total += inc;
  }
  REP(i,n) {
    REP(j,n) {
      if (flow[i][j] > 0) {
        if (se.count(pii(i,j)) == 0) {
          ans.push_back(pii(i,j));
        }
      }
    }
  }
  return total;
}
 
int main() {
  int n,m;
  cin >> n >> m;
  Graph g(n);
  int s,t;
  REP(i,m) {
    int x,y;
    cin >> x >>y;
    x--;y--;
    g[x].push_back(Edge(x,y,1));
    g[y].push_back(Edge(y,x,1));
    se[pii(x,y)] = i+1;
  }
  cin >> s >> t;
  s--;t--;
  cout << edmonds_karp(g, s, t) << endl;
  cout << ans.size() << endl;
  vector<int> v;
  FOR(it, ans) {
    v.push_back(se[pii(it->second, it->first)]);
  }
  sort(ALL(v));
  FOR(it,v)
    cout << *it << endl;
}

Measured memory_bytes: 1804
#include<stdio.h>   //AA06

int main()
{
    int A, B, i, N[1002], sum = 0, j = 0;
    double X;
    scanf("%d%d", &A, &B);

    X = 1.0/(4.0 * B);

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

    for(i = 0; i < A; i++) {
        sum = sum + N[i];
    }

    for(i = 0; i < A; i++) {
        if(N[i] >= (X * sum) ) {
            j++;
        }
    }

    if(j >= B) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
import Control.Monad.State
import Control.Monad.Reader
import Data.Array.IArray
import Data.Array.IO

data Direction = R | L | U | D  deriving (Eq, Show)
type Field = Array (Int, Int) [Direction]
type IOField = IOArray (Int, Int) [Direction]
type Walk a = StateT Direction (StateT (Int, Int) (ReaderT Field IO)) a

main = do
  field <- getField
  flip runReaderT field $ flip evalStateT (0,0) $ evalStateT walkStep R

modifyArray arr ix f = do
  e <- readArray arr ix
  writeArray arr ix (f e)

getField :: IO Field
getField = do
  field <- newArray ((0,0), (4,4)) []
  e <- getAssocs field
  input <- replicateM 9 getLine
  forM_ [0..3] $ \i -> do
    let i' = i*2
    horizonFill i (input !! i') field
    verticalFill i (input !! (i'+1)) field
  horizonFill 4 (input !! 8) field
  freeze field

horizonFill :: Int -> String -> IOField -> IO ()
horizonFill i flags field = do
  forM_ [0..3] $ \j -> do
    if flags !! j == '1'
       then modifyArray field (i,j) (R :) >> modifyArray field (i, j+1) (L:)
       else return ()

verticalFill :: Int -> String -> IOField -> IO ()
verticalFill i flags field = forM_ [0..4] $ \j -> do
  if flags !! j == '1'
     then modifyArray field (i,j) (D:) >> modifyArray field (i+1 ,j) (U:)
     else return ()

walkStep :: Walk ()
walkStep = do
  direction <- getDirection
  walkTo direction
  goal <- isGoalNow
  if goal then endStep
          else walkStep

getDirection :: Walk Direction
getDirection = do
  pos <- lift $ get
  field <- lift $ ask
  dir <- get
  return $ gd dir pos field

gd :: Direction -> (Int, Int) -> Field -> Direction
gd d (x,y) field = gd' priorityList walls
  where walls = field ! (x,y)
        priorityList = case d of
                            L -> [D, L, U, R]
                            R -> [U, R, D, L]
                            U -> [L, U, R, D]
                            D -> [R, D, L, U]

gd' :: [Direction] -> [Direction] -> Direction
gd' [] nextDs = error "invalid field"
gd' (d:ds) nextDs
  | d `elem` nextDs = d
  | otherwise = gd' ds nextDs


walkTo :: Direction -> Walk ()
walkTo d = printdir d >> (lift $ modify nextpos) >> put d
  where nextpos
            | d == L = \(x,y) -> (x,y-1)
            | d == R = \(x,y) -> (x,y+1)
            | d == U = \(x,y) -> (x-1,y)
            | d == D = \(x,y) -> (x+1,y)

printdir :: Direction -> Walk ()
printdir d = lift . lift . lift $ putStr.show $ d

isGoalNow :: Walk Bool
isGoalNow = do
  (x,y) <- lift get
  return $ x == 0 && y == 0

endStep :: Walk ()
endStep = lift.lift.lift $ putStrLn ""



Measured memory_bytes: 3980
N,X = map(int,input().split())
L = list(map(int,input().split()))
count = 0
Sum = 0
for i in range(N):
  if Sum <= X:
    Sum += L[i]
    count += 1
  else:
    break
if sum(L) <= X:
  print(count+1)
else:
  print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323846

int main(void) {
	
	int N;
	scanf("%d", &N);
	long long int a = 1;

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

	a=	a *i%(1000000000+7);
	}

	printf("%lld", a );


	return 0;
}



Measured memory_bytes: 128
// EducationalDPContest.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//const int INF = 1 << 30;
const long long INF = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main()
{
	// E - Knapsack 2
	int n, w;
	cin >> n >> w;
	vector<int> weight(n), value(n);
	for (int i = 0; i < n; i++)	cin >> weight[i] >> value[i];

	vector<vector<long long>> dp(101, vector<long long>(100001, INF));
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int sum_v = 0; sum_v <= 100000; sum_v++) {
			// i+1番目を選んだ場合
			if(sum_v - value[i] >= 0) {
				chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
			}

			// i+1番目を選ばなかった場合
			chmin(dp[i + 1][sum_v], dp[i][sum_v]);
		}
	}

	long long ans = 0;
	for (int sum_v = 0; sum_v <= 100000; sum_v++) {
		if (dp[n][sum_v] <= w)	ans = sum_v;
	}
	cout << ans << endl;
}

Measured memory_bytes: 80256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var alist = nextIntArray();
	var blist = nextIntArray();
	var aSum = 0;
	var bSum = 0;
	for(var i = 0; i < N; i++){
		aSum += alist[i];
		bSum += blist[i];
	}
	var acount = 0;
	for(var i = 0; i < N; i++){
		if(alist[i] < blist[i]){
			acount += Math.floor((blist[i] - alist[i]) / 2);
		}else{
			acount -= alist[i] - blist[i];
		}
	}
	if(acount >= 0){
		myout("Yes");
	}else{
		myout("No");
	}
}


Measured memory_bytes: 34432
# 1-index
from sys import stdin
import numpy as np
N, C = [int(x) for x in stdin.readline().rstrip().split()]
imos = np.array([[0]*(10**5+1) for i in range(C+1)])

for i in range(N):
    s, t, c = [int(x) for x in stdin.readline().rstrip().split()]
    imos[c, s - 1:t] = 1

imos = np.array(imos)
# print(np.cumsum(imos,axis=1))
ans = max(imos.sum(axis=0))
print(ans)

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

int N;
long if_can_use;

int dp[55][55][55];

bool if_can_make_b(int now, int now_number, int goal){
    if(dp[now][now_number][goal] != -1){
        return dp[now][now_number][goal];
    }else if(!now){
        return dp[now][now_number][goal] = (now_number == goal);
    }else if((if_can_use >> now) & 1){
        return dp[now][now_number][goal] = if_can_make_b(now - 1, now_number, goal) || if_can_make_b(now - 1, now_number % now, goal);
    }else{
        return dp[now][now_number][goal] = if_can_make_b(now - 1, now_number, goal);
    }
}

int main(){
    cin >> N;
    int a[N], b[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        cin >> b[i];
    }
    if_can_use = (1l << 55) - 1;
    for(int i = 0; i < 55; i++){
        for(int j = 0; j < 55; j++){
            for(int k = 0; k < 55; k++){
                dp[i][j][k] = -1;
            }
        }
    }
    for(int i = 0; i < N; i++){
        if(!if_can_make_b(a[i], a[i], b[i])){
            cout << -1 << endl;
            return 0;
        }
    }
    long ans = 0;
    for(int i = 54; i >= 0; i--){
        for(int j = 0; j < 55; j++){
            for(int k = 0; k < 55; k++){
                for(int l = 0; l < 55; l++){
                    dp[j][k][l] = -1;
                }
            }
        }
        if_can_use &= ~(1l << i);
        for(int j = 0; j < N; j++){
            if(!if_can_make_b(a[j], a[j], b[j])){
                if_can_use |= (1l << i);
                ans += (1l << i);
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
#! //Users/daigofujiwara/anaconda3/bin python3

#h行で列和がyかy+1であるかどうかとサンプルを出力

input1=input()

K,X=input1.split(" ")
K,X=int(K),int(X)

if 500*K>=X:
    print("Yes")
else:
    print("No")


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

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  int B[M];
  for(int i = 0;i < M;i++){
    cin >> B[i];
  }
  int A[M][N];
  for(int i = 0;i < N;i++){
    for(int j = 0;j < M;j++){
      cin >> A[j][i];
    }
  }
  int cnt = 0;
  for(int i = 0;i < N;i++){
    int ans = C;
    for(int j = 0;j < M;j++){
      ans += A[j][i] * B[j]; 
    }
    if(ans > 0)
      cnt++;
  }
  cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
using namespace std;

int main() {
 
  int n;
  cin >>n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
  cin >> a.at(i);
}
  for (int i = 0; i < n; i++) {
   b[a[i]-1] = i+1;
    }
  for (int i = 0; i < n; i++) {
    cout<< b[i] <<endl;
  }
  return 0;
}

Measured memory_bytes: 1664
#!/usr/bin/env python
import bisect
from collections import defaultdict

def main():
    S = input().strip()

    first, last = int(S[:2]), int(S[2:])

    is_first_month = 0 < first and first <= 12
    is_last_month = 0 < last and last <= 12

    if is_first_month and is_last_month:
        print("AMBIGUOUS")
    if not is_first_month and not is_last_month:
        print("NA")
    if is_first_month and not is_last_month:
        print("MMYY")
    if not is_first_month and is_last_month:
        print("YYMM")



if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>

int main(void)
{
    long long int N,B,A,div,res,AB,sum;

    scanf("%lld %lld %lld",&N,&A,&B);

    AB = A+B;

    div = N/AB;
    res = N%AB;

    //青いボールが先に並ぶ
    sum = A*div;

    if(res < A){
        sum += res;
    } else {
        sum += A;
    }
    
    printf("%lld\n",sum);

    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 20:59:09 2020

@author: Kanaru Sato
"""

n = int(input())
sum = 0

for i in range(n+1):
    if i%3 != 0 and i%5 != 0:
        sum += i
        
print(sum)

Measured memory_bytes: 9104
times = int(input())
taro_s = 0
hanako_s = 0
for i in range(times):
    taro_a, hanako_a = input().split()
    if taro_a > hanako_a:
        taro_s += 3
    elif taro_a < hanako_a:
        hanako_s += 3
    else:
        hanako_s += 1
        taro_s += 1
print(taro_s, hanako_s)

Measured memory_bytes: 7688
#include <stdio.h>
int main(void)
{
    int W,H,i,j;
    for ( ; scanf("%d %d\n",&H,&W) != EOF; )
    {
    for (i = 1; i <= H; i++)
        {
        for (j = 1; j <= W; j++)
            if (i==1 || i==H || j==1 || j==W)
            putchar('#');
            else
            putchar('.');
            putchar('\n');
        }
    if (H==0 && W==0)
    break;
    putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2044