akhauriyash/Code-Regression huggingface dataset:
#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() {
  string s;
  cin >> s;
  vector<int> cnt(256);
  for (int i = 0; i < s.size(); i++) {
    cnt[s[i]]++;
  }
  for (int i = 'a'; i <= 'z'; i++) {
    if (cnt[i] == 0) {
      cout << (char) i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
from collections import deque

def bfs(li,f,n):
    queue = deque([1])
    f[1] = 1
    count = 0
    ans = [0 for i in range(n+1)]
    while queue:
        point = queue.popleft()
        # print(point)
        for i in li[point]:
            if f[i[0]] == -1:
                f[i[0]] = 1
                if ans[point] == 0 and i[1]%2 != 0:
                    ans[i[0]] = 1
                elif ans[point] == 1 and i[1]%2 == 0:
                    ans[i[0]] = 1
                queue.append(i[0])
    for i in ans[1:]:
        print(i)


n=int(input())
li=[[] for i in range(n+1)]
for i in range(n-1):
    f,t,w = map(int,input().split())
    li[f].append((t,w))
    li[t].append((f,w))
f=[-1 for i in range(n+1)]
bfs(li,f,n)

Measured memory_bytes: 40708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] answer = new int[26];
		try(Scanner scanner = new Scanner(System.in)) {
			while(scanner.hasNextLine()) {
				String S = scanner.nextLine();
				S = S.toLowerCase();
				for(int i=0;i<S.length();i++) {
					if ('a'<=S.charAt(i)&&S.charAt(i)<='z') {
						answer[S.charAt(i)-'a']++;
					}
				}
			}
		}
		for(int i=0;i<26;i++) {
			System.out.println((char)(i+'a') + " : " + answer[i]);
		}
	}
}


Measured memory_bytes: 26120
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(ll i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };


struct unionfind {
    vector<int> dat;

    unionfind(int n) : dat(n, -1) {}

    int find(int x) {
        if (dat[x] < 0) return x;
        return dat[x] = find(dat[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (dat[x] > dat[y]) swap(x, y);
        dat[x] += dat[y];
        dat[y] = x;
    }

    int size(int x) {
        return -dat[find(x)];
    }
};


int main() {
    int n, m, k;
    cin >> n >> m >> k;
    unionfind uni(n);
    vi fr(n);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        uni.unite(x, y);
        fr[x]++;
        fr[y]++;
    }
    vvi g(n);
    rep(i, k) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    rep(i, n) {
        int ans = uni.size(i) - fr[i] - 1;
        for (int x : g[i]) {
            if (uni.find(x) == uni.find(i))ans--;
        }
        cout << ans << " ";
    }
}

Measured memory_bytes: 6784
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INS(x) string (s); cin >> s
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  IN(n);
  VIN(p, n);
  bool done = false;
  REP(i,n){
    if(p[i]!=i+1){
      if (done){
	cout<<"NO";
	return 0;
	}
      else{
	int val = p[i];
	if(p[val-1]==i+1){
	  p[val-1]=val;
	  done=true;
	}
	else{
	  cout<<"NO";
	  return 0;
	}
      }
    }
  }
    cout<<"YES";
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 100000;

int n, m;
vector<int> adj[MAXN];

bool done[MAXN];
int lsz, rsz, compsz[MAXN], ncomps;

pair<int, int> dfs(int at) {
	done[at] = true; pair<int, int> ret = MP(1, 0);
	REPSZ(i, adj[at]) {
		int to = adj[at][i];
		if (done[to]) { ++ret.second; continue; }
		pair<int, int> cur = dfs(to); ret.first += cur.first, ret.second += cur.second + 1;
	}
	return ret;
}

void run() {
	scanf("%d%d", &n, &m); REP(i, m) { int a, b; scanf("%d%d", &a, &b); --a, --b; adj[a].PB(b); adj[b].PB(a); }

	ll ret = 0; ncomps = 0;
	REP(i, n) done[i] = false;
	REP(i, n) if (!done[i]) {
		pair<int, int> cur = dfs(i);
		ll incomp = (ll)cur.first*(cur.first - 1) / 2;
		//printf("%d: (%d,%d) [%lld->%lld]\n", i, cur.first, cur.second, incomp, incomp - cur.second / 2);
		ret += incomp - cur.second / 2;
		if (i == 0) lsz = cur.first; else if (i == 1) rsz = cur.first; else compsz[ncomps++] = cur.first;
	}
	int sz = max(lsz, rsz);
	REP(i, ncomps) {
		ret += (ll)sz*compsz[i];
		sz += compsz[i];
	}
	printf("%lld\n", ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 12032
x1, y1, x2, y2 = map(int, input().split())

dx1 = x2 - x1
dy1 = y2 - y1

dx2 = -dy1
dy2 = dx1

x3 = x2 + dx2
y3 = y2 + dy2
x4 = x3 - dx1
y4 = y3 - dy1

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i,n) cin >> s[i];
  bool ok = false;
  rep(i,n){
    if(s[i]%10!=0) ok = true;
  }
  int sum = 0;
  if(ok){
    rep(i,n){
      sum += s[i];
    }
    if(sum%10!=0) cout << sum << endl;
    else{
      int maxx = 0;
      rep(i,n){
        if((sum-s[i])%10!=0){
          maxx = max(maxx, sum-s[i]);
        }
      }
      cout << maxx << endl;
    }
  }
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;

const int MAX = 100001;
const int NIL = -1;
struct Node {
	int parent, sibling, left, right, depth, height, degree;
};
struct Node T[MAX];

void setDepth(int u, int p)
{
	T[u].depth = p;
	if (T[u].right != NIL)
		setDepth(T[u].right, p + 1);
	if (T[u].left != NIL)
		setDepth(T[u].left, p + 1);
}

int setHeight(int u)
{
	int h1, h2;
	h1 = h2 = 0;
	if (T[u].right != NIL)
		h1 = setHeight(T[u].right) + 1;
	if (T[u].left != NIL)
		h2 = setHeight(T[u].left) + 1;
	return T[u].height = max(h1, h2);
}

void printChildren(int u)
{
	int c = T[u].left;
	cout << "[";
	while (c != NIL) {
		cout << c;
		c = T[c].right;
		if (c != NIL)
			cout << ", ";
		else
			break;
	}
	cout << "]";
}

int main(void)
{
	int n, L, R, child, node;
	cin >> n;
	for (int i = 0; i < n; i++) {
		T[i].parent = T[i].left = T[i].right = T[i].sibling = NIL;
	}
	for (int i = 0; i < n; i++) {
		cin >> node >> L >> R;
		if (L != NIL) {
			T[node].left = L;
			T[L].parent = node;
			T[L].sibling = R;
			T[node].degree++;
		}
		if (R != NIL) {
			T[node].right = R;
			T[R].parent = node;
			T[R].sibling = L;
			T[node].degree++;
		}
	}
	for (int i = 0; i < n; i++) {
		if (T[i].parent == NIL) {
			setDepth(i, 0);
			setHeight(i);
			break;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << T[i].parent << ", sibling = " << T[i].sibling << ", degree = " << T[i].degree;
		cout << ", depth = " << T[i].depth << ", height = " << T[i].height << ", ";
		if (T[i].parent == NIL)
			cout << "root";
		else if (T[i].left == NIL && T[i].right == NIL)
			cout << "leaf";
		else
			cout << "internal node";
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
// AOJ DPL_3_C Largest Rectangle in a Histogram
// 2018.5.12 bal4u
 
#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
 
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}

typedef struct { int lp, h; } STACK;
STACK *stack; int top;

long long maxRectInHistogram(int n, int *h)
{
	int i;
	long long s, ans;
	
	stack = malloc(sizeof(STACK) * (n+5));
	h[n] = 0;
	ans = 0, top = -1;
	stack[++top].lp = -1, stack[top].h = -1;
	for (i = 0; i <= n; i++) {
		if (h[i] == stack[top].h) continue;
		if (h[i] > stack[top].h) {
			stack[++top].lp = i, stack[top].h = h[i];
		} else {
			while (h[i] < stack[top].h) {
				s = (long long)stack[top].h*(i-stack[top].lp);
				top--;
				if (s > ans) ans = s;
			}
			stack[++top].h = h[i];
		}
	}
	free(stack);
	return ans;
}

int h[100002];

int main()
{
	int N, i;
	long long ans;

	N = in();
	for (i = 0; i < N; i++) h[i] = in();

	printf("%lld\n", maxRectInHistogram(N, h));
	return 0;
}



Measured memory_bytes: 2456
N, K = map(int, input().split())
A = []

for i in range(N):
    A.append(0)

for i in range(K):
    d = int(input())
    AA = list(map(int, input().split()))
    for j in range(d):
        A[AA[j] - 1] = 1

n = 0
for i in range(N):
    if A[i] == 0:
        n += 1
print(n)

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

int main()
{
  int n, k;
  cin >> n >> k;

  for (int i = 0; i < k; i++){
    int a, b;
    cin >> a >> b;
    int mini = min(min(a, n - a + 1), min(b, n - b + 1)) % 3;
    cout << (mini ? mini : 3) << endl;
  }
}

Measured memory_bytes: 3068
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int string_size;
  int total_queries;
  while(~scanf("%d %d",&string_size,&total_queries)){
    string str;
    cin >> str;
    
    unsigned long long B = 100000007ULL;
    unsigned long long h[300001];
    unsigned long long t[300001];
    h[0] = 0;
    t[0] = 1;
    for(int i=1; i <= str.size(); i++){
      t[i] = t[i-1] * B;
      h[i] = h[i-1] * B + str[i - 1];
    }

    int left[300001];
    int right[300001];
    memset(left,0,sizeof(left));
    memset(right,0,sizeof(right));
    left[0] = 1;
    right[0] = 1;
    set<unsigned long long> visited;

    for(int query_idx = 1; query_idx <= total_queries; query_idx++){
      string query;
      cin >> query;
      if(query == "L--"){
	left[query_idx]=left[query_idx-1] - 1;
	right[query_idx]=right[query_idx-1];
      }
      else if(query == "L++"){
	left[query_idx]=left[query_idx-1] + 1;
	right[query_idx]=right[query_idx-1];
      }
      if(query == "R--"){
	left[query_idx]=left[query_idx-1];
	right[query_idx]=right[query_idx-1] - 1;
      }
      else if(query == "R++"){
	left[query_idx]=left[query_idx-1];
	right[query_idx]=right[query_idx-1] + 1;
      }

      visited.insert(h[right[query_idx]] - h[left[query_idx] - 1] * t[right[query_idx] - left[query_idx] + 1]);
    }
    printf("%d\n",visited.size());
  }
}

Measured memory_bytes: 22488
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
LL a[N],b[N];
int n,m,k;
int find(int x)
{
    int l=1,r=n;
    while(l<r)
    {
        int mid=l+r>>1;
        if(a[mid]==x) return mid;
        else if(a[mid]>x) r=mid-1;
        else l=mid+1;
    }
    if(a[l]>x) return l-1;
    return l;
}
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),a[i]+=a[i-1];
    int res=0;
    for(int i=1;i<=m;i++)
        scanf("%d",&b[i]),b[i]+=b[i-1];
    for(int i=0;i<=m;i++)
        if(k>=b[i])
        {
            int ans=find(k-b[i]);
            res=max(ans+i,res);
        }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 6896
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

const int N = 2e5 + 5;
int a[N];

void solve() {
	int n;
    sc(n);
    fr(i, 0, n - 1) {
        sc(a[i]);
        a[i] = i - a[i];
        debug(a[i]);
    }
    if(a[0] != 0) {
        cout << -1;
        return;
    }
    fr(i, 0, n - 2) {
        if(a[i] > a[i + 1]) {
            cout << -1;
            return;
        }
    }
    ll ans = n - 1 - a[n - 1];
    rf(i, n - 1, 1) {
        if(a[i] != a[i - 1]) { ans += i - 1 - a[i - 1]; debug(i - 1, ans); }
    }
    cout << ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 4292
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/











int N, A[303], C[3];
double dp[303][303][303];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) C[A[i] - 1]++;

    rep(c2, 0, N + 1) rep(c1, 0, N + 1) rep(c0, 0, N + 1) {
        int sm = c0 + c1 + c2;
        if (N < sm) continue;
        if (sm == 0) continue;

        dp[c0][c1][c2] = 1.0 * N / sm;
        if (c0) dp[c0][c1][c2] += dp[c0 - 1][c1][c2] * c0 / sm;
        if (c1) dp[c0][c1][c2] += dp[c0 + 1][c1 - 1][c2] * c1 / sm;
        if (c2) dp[c0][c1][c2] += dp[c0][c1 + 1][c2 - 1] * c2 / sm;
    }

    printf("%.10f\n", dp[C[0]][C[1]][C[2]]);
}


Measured memory_bytes: 217344
n, m = map(int, input().split())

dwa = {}
dac = {}
ansac = 0
answa = 0

for m in range(m):
  p, s = map(str, input().split())
  p = int(p)
  if s == 'WA':
    if p in dwa:
      dwa[p] += 1
    else:
      dwa[p] = 1
  if s == 'AC' and p not in dac:
    ansac += 1
    dac[p] = 1
    if p in dwa:
      answa += dwa[p]
    
print(ansac, answa)

Measured memory_bytes: 55768
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

const int MAX_N = 2e5 + 10, MOD = 1e9 + 7;
int n, m, A, B, ans;
int F[MAX_N];
int Fdiv[MAX_N];

int _sum (int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;

	return c;
}

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	return c;
}

int _pow (int a, int b) {
	if (!b)
		return 1;

	int res = _pow(a, b >> 1);
	res = _mul(res, res);

	if (b & 1)
		res = _mul(res, a);

	return res;
}

int _choose (int a, int b) {
	if (min(a, b) < 0 || b < a)
		return 0;

	return _mul(F[b], _mul(Fdiv[a], Fdiv[b - a]));
}

void pre_process() {
	F[0] = Fdiv[0] = 1;
	for (int i = 1; i < MAX_N; i++) {
		F[i] = _mul(F[i - 1], i);
		Fdiv[i] = _pow(F[i], MOD - 2);
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	pre_process();
	cin >> n >> m >> A >> B;
	A = n - A;
	B = m - B;
	int x = A, y = m - B + 1;
	while (x && y <= m) {
		ans = _sum(ans, _mul(_choose(x - 1, x + y - 2), _choose(n - x, n - x + m - y)));
		x--;
		y++;
	}

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

Measured memory_bytes: 1792
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	long solve0(long l1, long r1, long l2, long r2) {
		long l = Math.max(l1, l2);
		long r = Math.min(r1, r2);
		if (l <= r) {
			long m = (l + r) / 2;
			return m * (l + r - m);
		}
		return l * r;
	}
	long solve1(long l1, long m1, long r1, long l2, long r2) {
		long p = m1 - l1;
		long q = r1 - m1;
		long sp = p == 0 ? 0 : solve0(l1, l1 + p - 1, r2 - p + 1, r2);
		long sq = q == 0 ? 0 : solve0(r1 - q + 1, r1, l2, l2 + q - 1);
		return Math.max(sp, sq);
	}
	long solve2(long l1, long m1, long r1, long l2, long m2, long r2) {
		if (l1 == m1)
			return solve1(l2, m2, r2, l1 + 1, r1);
		if (m1 == r1)
			return solve1(l2, m2, r2, l1, r1 - 1);
		if (l2 == m2)
			return solve1(l1, m1, r1, l2 + 1, r2);
		if (m2 == r2)
			return solve1(l1, m1, r1, l2, r2 - 1);
		long p = Math.min(m1 - l1, r2 - m2);
		long q = Math.min(r1 - m1, m2 - l2);
		long sp = p == 0 ? 0 : solve0(l1, l1 + p - 1, r2 - p + 1, r2);
		long sq = q == 0 ? 0 : solve0(r1 - q + 1, r1, l2, l2 + q - 1);
		long so = solve2(l1 + p, m1, r1 - q, l2 + q, m2, r2 - p);
		return Math.max(so, Math.max(sp, sq));
	}
	long solve(long n, int a, int b) {
		if (n < a && n < b)
			return solve0(1, n, 1, n);
		if (n >= a && n >= b)
			return solve2(1, a, n + 1, 1, b, n + 1);
		return solve1(1, Math.min(a, b), n + 1, 1, n);
	}
	void main() {
		int q = sc.nextInt();
		while (q-- > 0) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			long s = (long) a * b;
			long upper = 1;
			while (solve(upper, a, b) < s)
				upper *= 2;
			long lower = upper / 2;
			while (upper - lower > 1) {
				long n = (lower + upper) / 2;
				if (solve(n, a, b) < s)
					lower = n;
				else
					upper = n;
			}
			println(lower);
		}
	}
}


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

//#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int n;
ll s;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i++)
		if (i % 5 && i % 3)
			s += i;
	cout << s << endl;

	return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W)), b(102, vector<char>(102));
  
  
  for (int i=0; i<102; i++){
    for (int j=0; j<102; j++){
      b.at(i).at(j) = '#';
    };
  };
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      cin >> a.at(i).at(j);
    };
  };
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      b.at(i+1).at(j+1) = a.at(i).at(j);
    };
  };
  for (int i=0; i<H+2; i++){
    for (int j=0; j<W+2; j++){
      if (j==W+1){
        cout<<b.at(i).at(j)<<endl;
      }else{
        cout<<b.at(i).at(j);
      }
    };
  };
  
}

Measured memory_bytes: 3616
#include<iostream>
#include<sstream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stack>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
ll n, a, s;
int main()
{	
	while (~scanf("%lld", &n))
	{
		s = 0;
		for (int i = 0; i < n; i++)
		{
			scanf("%lld", &a);
			s += a;
		}
		printf("%lld\n", s - n);
	}
}

Measured memory_bytes: 256
import sys

n, m = list(map(int, input().split()))

a = []
for _ in range(n):
    a.append(list(input()))
    
b = []
for _ in range(m):
    b.append(list(input()))

for i in range(n - m + 1):
    for j in range(n - m + 1):
        c = [a[k][i: i + m] for k in range(j, j + m)]
        if b == c:
            print("Yes")
            sys.exit()
            
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #include<boost/multiprecision/cpp_int.hpp>
// using boost ::multiprecision::cpp_int;
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
vector<ll>v;
int main()
{
    boost;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    ll dp[n+1];
    for(ll i=1;i<=n;i++)
    dp[i]=10000000000000;
    dp[0]= 0;
    for(ll i=1;i<n;i++)
    {
        ll j =i;
        ll cnt=0;
        while(j>0 && cnt < k)
        {
            j--;
            dp[i] = min(dp[i], dp[j]+ abs(a[i]-a[j]) );
            cnt++;
        }
    }
    cout<<dp[n-1]<<"\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}
/* AnsHuman_7 || Anshuman Gaur */

Measured memory_bytes: 1792
from collections import Counter
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+1000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,m=map(int, input().split())
mb=[]
while m>1:
    for i in range(2,int(m**0.5)+1):
        if m%i==0:
            mb.append(i)
            m//=i
            break
    else:
        mb.append(m)
        m//=m
mb2=Counter(mb)
    
mblist=list()
for i in mb2:
    a = cmb(mb2[i]+n-1,mb2[i],mod)
    mblist.append(a)
ans=1
for i in mblist:
    ans=(ans*i)%mod
print(ans)

Measured memory_bytes: 15564
sx, sy, tx, ty = map(int, input().rstrip().split())
dx = tx - sx
dy = ty - sy
ret = ""
ret += "R"*dx + "U"*dy
ret += "L"*dx + "D"*dy
ret += "D"
ret += "R"*dx + "R" + "U"*dy + "U"
ret += "L"
ret += "U"
ret += "L"*dx + "L" + "D"*dy + "D"
ret += "R"
print(ret)


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

namespace TPBC2019
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var k = int.Parse(Console.ReadLine());

            var c = s[k - 1];
            foreach (var x in s)
            {
                if (x == c)
                {
                    Console.Write(c);
                }
                else
                {
                    Console.Write('*');
                }
            }
            Console.WriteLine();

        }
    }
}


Measured memory_bytes: 13140
a, b = map(int, input().split())
i = 1
found = False
while True:
    if int(i * 0.08) > a + 1 or int(i * 0.1) > b:
        break
    if int(i * 0.08) == a and int(i * 0.1) == b:
        print(i)
        found = True
        break
    i = i + 1
if not found:
    print(-1)

Measured memory_bytes: 3060
import java.util.*;
import java.math.*;

class Main {
	static Scanner sc = new Scanner(System.in);

	void solve() {
		try {
			long a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
			long r1 = Math.max(a * c, a * d);
			long r2 = Math.max(b * c, b * d);
			System.out.println(Math.max(r1, r2));
		} catch (Exception e) {
			return;
		}
	}

	public static void main(String[] args) {
		Main ob = new Main();
		ob.solve();
	}
}

Measured memory_bytes: 35672
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    ll N,P;
    cin >> N >> P;
    vector<pair<ll,ll>> p;
    for(ll a = 2; a * a <= P; ++a){
        if(P % a != 0) continue;
        ll ex = 0;
        while(P % a == 0){
            ++ex;
            P /= a;
        }
        p.push_back({a,ex});
    }
    if(P != 1) p.push_back({P,1});
    ll ans = 1;
    for(auto m : p){
        if(m.second < N) continue;
        ll cnt = m.second / N;
        for(ll i = 0; i < cnt; i++){
            ans *= m.first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
n,k=map(int,input().split())
l=list(map(int,input().split()))
INF=10**9+7
if 0 in l:k=k-1
lm=[0]+[i for i in l if i<0][::-1]
if len(lm)<k+1:
    lm=lm+[-INF]*(k+1-len(lm))
lp=[0]+[i for i in l if i>0]
if len(lp)<k+1:
    lp=lp+[INF]*(k+1-len(lp))
ans=INF*10
for i in range(k+1):
    tmp=min(2*lp[i]-lm[k-i],lp[i]-2*lm[k-i])
    if tmp<ans:ans=tmp
print(ans)

Measured memory_bytes: 14532
//https://atcoder.jp/contests/abc125/tasks/abc125_b
#include<bits/stdc++.h>
using namespace std;
#define TEMPLATE
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
template<typename T>inline T& unused_var(T& v){return v;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};
using LL = long long;

int v[51],c[51];
int main(){
    int N;
    cin>>N;
    int ret=0;
    for(int i:range(N))cin>>v[i];
    for(int i:range(N))cin>>c[i];
    for(int i:range(N)){
        if(v[i]>c[i]){
            ret+=v[i]-c[i];
        }
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    string s,t;cin >> s >> t;
    int ans = INF;
    for (int i = 0; i + t.length() <= s.length(); i++) {
        int tmp = 0;
        for (int j = 0; j < t.length(); j++) {
            tmp += s[i + j] != t[j];
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}



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

struct D{
  int t,s;
};

vector<vector<D>> data;
void init(){
  data.clear();
}
int q;
void print(){
  for(int i=0;i<data.size();i++){
    //cerr<<"m="<<i<<":";
    for(int j=0;j+1<data[i].size();j+=2){
      //cerr<<"("<<data[i][j].t<<"-"<<data[i][j+1].t<<")";
    }//cerr<<endl;
  }
}
bool input(){
  int n,m;
  cin>>n>>m;
  if(n==0&&m==0)return false;
  //cerr<<"input"<<endl;
  int r;
  cin>>r;
  data.resize(m+10);
  vector<int> login(m+10,0);
  for(int i=0;i<r;i++){
    int t,n,m,s;
    cin>>t>>n>>m>>s;
    if(s==1){
      login[m]++;
    }else{
      login[m]--;
    }
    //cerr<<login[m]<<" "<<s<<endl;
    if(login[m]==s){
      data[m].push_back(D{t,s});
    }else if(data[m].size()>0&&data[m][data[m].size()-1].s==0){
      int pre_t = data[m][data[m].size()-1].t;
      data[m][data[m].size()-1].t = max(pre_t,t);
    }
  }
  cin>>q;
  return true;
}
int solve(){
  int s,e,m;
  cin>>s>>e>>m;
  //cerr<<"solve::"<<s<<" "<<e<<" "<<m<<endl;
  const vector<D> l = data[m];
  int ans = 0;
  for(int i=0;i<(int)l.size()-1;i++){
    if(l[i].s==1&&(s<l[i+1].t)&&l[i].t<=e){
      ans += l[i+1].t - max(s,l[i].t);
      if(e<=l[i+1].t){
        ans -= l[i+1].t - e;
      }
    }
  }
  return ans;
}

int main(){
  while(init(),input()){
    print();
    for(int i=0;i<q;i++){
      int ans = solve();
      //cerr<<"ans::"<<ans<<endl;
      cout<<ans<<endl;
    }
  }
}

Measured memory_bytes: 1496
S = gets.to_i
K = gets.to_i
 
ret = 0
idx = 0
S.to_s.split('').each do |s|
  ret = s
  hoge = s.to_i**(5*(10**15)) 
  idx += hoge
  if Math.log(idx) >= Math.log(K)
    break
  end
end
p ret.to_i

Measured memory_bytes: 3836
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll t=modexp(a,n/2); return modmul(t,t);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll a){return modexp(a%MOD,MOD-2);}
ll modnCr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i)
{numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


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

    ll ans = modexp(2, n);
    ans = modadd(ans, -modnCr(n, a));
    ans = modadd(ans, -modnCr(n, b));
    ans = modadd(ans, -1);

    cout << ans << endl;

}





//              g++ -std=c++1z


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int x[101];
	string y;
	int q;
	cin >> q;
	x[0] = 0;
	cin >> y;
	int max = 0;
	for (int z = 0; z < q; z++) {
		if (y[z] == 'I') { x[z + 1] = x[z] + 1; }
		else {
			x[z + 1] = x[z] - 1;
	}
		if (x[z + 1] > max)max = x[z + 1];
	}
	cout << max << endl;
	/*sort(x, x + 101);
	cout << x[100];*/
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

template <class T>
class SegTree {
    using F = function<T(T, T)>;
    int n;
    vector<T> data;
    const F f;
    const T e;

public:
    SegTree(const vector<T>& as, const F f, const T& e) : f(f), e(e) {
        n = 1;
        while (n < as.size()) n <<= 1;
        data.assign(2 * n, e);
        for (int i = 0; i < as.size(); i++) {
            data[n + i] = as[i];
        }
        for (int i = n - 1; i > 0; i--) {
            data[i] = f(data[2 * i], data[2 * i + 1]);
        }
    }

    void update(int k, const T& x) {
        k += n;
        data[k] = x;
        while (k >>= 1) {
            data[k] = f(data[2 * k], data[2 * k + 1]);
        }
    }

    T query(int a, int b) {
        T L = e, R = e;
        for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
            if (a & 1) {
                L = f(L, data[a++]);
            }
            if (b & 1) {
                R = f(data[--b], R);
            }
        }
        return f(L, R);
    }
};

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

    SegTree<i64> s1(as, [](i64 a, i64 b){return min(a, b);}, 1e18);
    SegTree<i64> s2(as, [](i64 a, i64 b){return max(a, b);}, -1e18);

    int q;
    cin >> q;
    while (q--) {
        int c;
        cin >> c;
        int a, b;
        cin >> a >> b;
        if (c) {
            cout << s2.query(a, b) << endl;
        } else {
            cout << s1.query(a, b) << endl;
        }
    }
}


Measured memory_bytes: 3136
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        ABC139d pro = new ABC139d(sc);
        out.println(pro.solve());

        out.flush();
    }

}

class ABC139d {

    private final int N;

    ABC139d(FastScanner sc) {
        N = sc.nextInt();
    }

    long solve() {
        long sum = 0;
        for (int i = 0; i < N; i++) {
            sum += i;
        }
        return sum;
    }
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

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

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

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


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

using namespace std;

typedef long long ll;
const int maxn=2e5+10;
int mod=1e9+7;
int tree[maxn*4];
int n;
int a[maxn];

void pushup(int rt)
{
    tree[rt]=max(tree[rt<<1],tree[rt<<1|1]);
}
void build(int l,int r,int rt)
{
    if(l==r)
    {
        tree[rt]=a[l];
        return;
    }
    int mid=(l+r)>>1;
    build(l,mid,rt<<1);
    build(mid+1,r,rt<<1|1);
    pushup(rt);
}
int ask(int l,int r,int L,int R,int rt)
{
    int ans=0;

    if(l<=L&&R<=r)
    {
        return tree[rt];
    }
    int mid=(L+R)>>1;
    if(l<=mid)
        ans=max(ans,ask(l,r,L,mid,rt<<1));
    if(r>mid)
        ans=max(ans,ask(l,r,mid+1,R,rt<<1|1));
    return ans;
}
int findx(int l,int r,int x,int op,int ok)
{
    if(l>r)
        return -1;
    if(ok==0&&ask(l,r,1,n,1)<x)
        return -1;
    else ok=1;
    if(l==r)
        return l;
    int mid=(l+r)>>1;

    if(op==0)
    {
        int rnum=ask(mid+1,r,1,n,1);
        if(rnum>x)
            return findx(mid+1,r,x,op,ok);
        else
            return findx(l,mid,x,op,ok);
    }
    else if(op==1)
    {
        int rnum=ask(l,mid,1,n,1);
        if(rnum>x)
            return findx(l,mid,x,op,ok);
        else
            return findx(mid+1,r,x,op,ok);
    }

}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    build(1,n,1);
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        int ans[5];
        ans[1]=findx(1,i-1,a[i],0,0);
        ans[0]=findx(1,ans[1]-1,a[i],0,0);
        if(ans[0]==-1)
            ans[0]=0;
        if(ans[1]==-1)
            ans[1]=0;
        ans[2]=i;
        ans[3]=findx(i+1,n,a[i],1,0);
        if(ans[3]==-1)
            ans[3]=n+1;
        ans[4]=findx(ans[3]+1,n,a[i],1,0);
        if(ans[4]==-1)
            ans[4]=n+1;
        sum+=(ll)(ans[2]-ans[1])*(ans[4]-ans[3])*a[i];
        sum+=(ll)(ans[1]-ans[0])*(ans[3]-ans[2])*a[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1664
import sys
n = int(input())
INF = 10**18
ls = []
for i in range(n):
    x, l = [int(i) for i in sys.stdin.readline().split()]
    ls.append([x - l, x + l])
ls.sort(key=lambda x:x[1])
cnt = 0
_min = -INF
for l in ls:
    if l[0] >= _min:
        cnt += 1
        _min = l[1]
print(cnt)

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

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

            List<int> input = new List<int>();
            for (int i = 0; i < N; i++)
            {
                input.Add(int.Parse(Console.ReadLine()));
            }

            int max = input.Max();

            Console.WriteLine(input.Sum() - max + (max / 2));

        }
    }
}



Measured memory_bytes: 11220
#include <iostream>
using namespace std;
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s, t;
    cin >> s >> t;

    int n = s.size();
    vector <vector<int>> next(n, vector<int>(26, -1));
    // next[i][j] : 文字jは、i番目以降でどこにでてくるか

    for (int j = 0; j < 26; j++) {
        int prev = -1;
        for (int i = 2 * n - 1; i >= 0; i--) {
            next[i % n][j] = prev;
            if (s[i % n] == 'a' + j) prev = i % n;
        }
    }

    int cur = next[n - 1][t[0] - 'a'];
    if (cur == -1) {
        cout << -1 << '\n';
        return 0;
    }

    ll ans = cur + 1;
    for (int i = 1; i < t.size(); i++) {
        int next_index = next[cur][t[i] - 'a'];
        if (next_index == -1) {
            cout << -1 << '\n';
            return 0;
        }

        if (next_index == cur) {
            ans += n;
        } else {
            ans += (next_index - cur + n) % n;
            cur = next_index;
        }
    }

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

Measured memory_bytes: 13696
#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>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


void solve(void)
{
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  int T = -1;
  int S = 0;
  for (int a = 0; a*100 <= F; a+=A)
  {
    for (int b = 0; (a+b)*100 <= F; b+=B)
    {
      for (int c = 0; (a+b)*100 + c <= F; c+=C)
      {
        for (int d = 0; (a+b)*100 + c + d <= F; d+=D)
        {
          int s = c + d;
          int t =(a+b)*100 + s;
          if(s <=(a+b)*E && t> 0 &&(T < 0 || S*t < s*T))
          {
            S = s;
            T = t;
          }
        }
        
      }
      
    }
    
  }
  cout<<T<<" "<<S<<endl;
  

  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int n;
    cin >> n;

    vector<int> a(n);

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

    int64_t r = (int64_t)1 << 60, t = s;
    for (int i = 0; i < n - 1; i++) {
        t -= a[i] * 2;
        r = min(r, abs(t));
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024