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

using namespace std;
typedef long long LL;

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

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

typedef vector<int> V;
typedef vector<V> VV;
int N;
VV g;
int sz[5123];
VV branch;
void dfs(int v = 0, int p = -1) {
	sz[v] = 1;
	branch[v].push_back(N - 1);
	for (int u : g[v]) {
		if (p == u)continue;
		dfs(u, v);
		sz[v] += sz[u];
		branch[v].push_back(sz[u]);
		branch[v].front() -= sz[u];
	}
}
constexpr int mod = 1e9 + 7;
// mを法とするaの逆元
// O(log a)
inline LL invMod(LL a, LL m = mod) {
	LL b = m, u = 1, v = 0;
	while (b) {
		LL t = a / b;
		swap(a -= t * b, b);
		swap(u -= t * v, v);
	}
	return (u % m + m) % m;
}

// 階乗
// O(n)
constexpr int SZ = 112345;
LL fact[SZ];
LL rfact[SZ];
struct fact_ {
	fact_() {
		fact[0] = 1;
		for (int i = 1; i<SZ; i++)
			fact[i] = fact[i - 1] * i%mod;
		rfact[SZ - 1] = invMod(fact[SZ - 1]);
		for (int i = SZ - 1; i>0; i--) {
			rfact[i - 1] = rfact[i] * i%mod;
		}
	}
}fact_init;
// O(1)
LL Comb(LL n, LL k) {
	LL u = fact[n];
	LL d = (rfact[k] * rfact[n - k]) % mod;
	return u * d%mod;
}

//O(1)
LL Perm(LL n, LL k) {
	LL u = fact[n];
	LL d = rfact[n - k] % mod;
	return u * d%mod;
}

LL dp[5123];
LL f(int v) {
	for (int i : range(N)) {
		dp[i] = 0;
	}
	dp[0] = 1;
	int ub = 1;
	for (auto cnt : branch[v]) {
		ub += cnt;
		for (int i = ub - 1; i >= 0; i--) {
			for (int j = 1; j <= min(i, cnt); j++) {
				LL c = Comb(cnt, j) * Perm(cnt, j) % mod;
				dp[i] += dp[i - j] * c %mod;
			}
			dp[i] %= mod;
		}
	}
	LL ret = 0;
	for (int i : range(N)) {
		if (i & 1) {
			ret += mod - dp[i] * fact[N - i] % mod;
		}
		else {
			ret += dp[i] * fact[N - i] % mod;
		}
	}
	return ret % mod;
}

void solve() {
	g = VV(N);
	branch = VV(N);
	for (int i : range(N - 1)) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs();
	if (N % 2==0) {
		for (int v : range(N)) {
			if (sz[v] == N / 2) {
				cout << fact[N / 2] * fact[N / 2] % mod << endl;
				return;
			}
		}
	}
	for (int v : range(N)) {
		bool isCentroid = true;
		for (auto cnt : branch[v])isCentroid &= (cnt <= N / 2);
		if (isCentroid) {
			cout << f(v) << endl;
			return;
		}
	}

}
int main() {
	while (cin >> N) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 2944
main() {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if (0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 2112
n=int(input())
a=list(map(int,input().split()))
b=[]
import math
for i in range(math.ceil(n/2)):
	b.append(a[n-1-2*i])
if n%2==0:
	for i in range(n//2):
		b.append(a[2*i])
else:
	for i in range(n//2):
		b.append(a[2*i+1])
print(*b)

Measured memory_bytes: 26180
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,X;
	cin >> N >> X;
	int s = 0;
	int ans = 0;
	rep(i,N){
		int l;
		cin >> l;
		s += l;
		if(s<=X) ans++;
	}
	cout << ans+1<<endl;
}


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

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#define fi first
#define se second
#define x first
#define y second
#define pb push_back
#define last(s) (s)[(s).size()-1]
#define all(a) (a).begin(),(a).end()
#define elif else if
#define left asdasd
#define next zaza
#define prev azaz
#define cclear cout<<flush;
#define x0 kerker
#define time chas
#define y0 lolik
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define files freopen("little.in", "r", stdin);freopen("little.out", "w", stdout);

using namespace std;

using llong = long long;
using ld = long double;
using itn = int;
using ii = pair<int,int>;\
using ull = unsigned long long;
using pll = pair<llong, llong>;
using psi = pair<string, int>;
using ll = pair<llong, llong>;

const llong over999 = 1e9;
const ld over999ld = 1e18+1;
const llong md = 1e9+7;
const ld eps = 1e-9;
const ld Pi = acos(-1);
const llong nich = 0;
const int mnogo = 300;

/**/

llong n;
set<char> st;
int32_t main() {
    kchay;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        char c;
        cin >> c;
        st.insert(c);
    }
    
    if(st.size() == 3){
        cout << "Three";
    } else {
        cout << "Four";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}
int main() {
  int a;
  cin >> a;
  string s;
  cin >> s;
  int x=s.size();
  if(x>a){
    for(int i=0;i<a;i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }else{
    cout << s << endl;
  }
}

Measured memory_bytes: 3756
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

S =  list(sys.stdin.readline().rstrip())
T =  list(sys.stdin.readline().rstrip())

cnt = 0

for i in range(len(S)):
    if(S[i] == T[i]):
        cnt += 1

print(cnt)


Measured memory_bytes: 5588
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

    vector<int> r(n);

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

    int MAX = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (r[i] >= MAX) {
            ans++;
        }
        MAX = max(MAX, r[i]);
    }

    cout << ans << endl;

    return 0;
}   

Measured memory_bytes: 256
#include<stdio.h>
typedef long long LL;
const int e[40]={0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,
                 5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8};
LL IN(void)
{
  LL x=0;short f=0,c=getchar();
  while(c<48||c>57)f^=c==45,c=getchar();
  while(c>47&&c<58)x=x*10+c-48,c=getchar();
  return f?-x:x;
}
int main(void)
{
  int x=0;LL a=0,p=7,q=11,N=IN();
  while(N%2==0){x++;N/=2;}a+=e[x],x=0;
  while(N%3==0){x++;N/=3;}a+=e[x],x=0;
  while(N%5==0){x++;N/=5;}a+=e[x];
  while(q*q<=N)
  {
    x=0;while(!(N%p)){x++;N/=p;}a+=e[x];
    x=0;while(!(N%q)){x++;N/=q;}a+=e[x];
    p+=6,q+=6;
  }
  if(N>1)a++;
  return printf("%lld\n",a),0;
}

Measured memory_bytes: 1604
"""
can do it by subproblems. for a given i, the only information you need from the previous values
is the min value of previous values.
the first i=0 is guaranteed to satisfy the constraint. (counting from zero).
"""
import sys


def count_low_elements(N, P):
    count = 0
    min_so_far = sys.maxsize
    for val in P:
        if val <= min_so_far:
            count += 1
            min_so_far = val
    return count


if __name__ == "__main__":
    test1 = \
"""5
4 2 5 1 3"""
    test2 = \
"""4
4 3 2 1"""
    test3 = \
"""6
1 2 3 4 5 6"""
    test4 = \
"""8
5 7 4 2 6 8 1 3"""
    test5 = \
"""1
1"""
    test = test5
    # N, P_string = test.split("\n")
    # P = list(map(int, P_string.split()))
    N = int(input())
    P = list(map(int, input().split()))
    print(count_low_elements(N, P))

Measured memory_bytes: 24744
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i, n) cin >> s[i];

  sort(s.begin(), s.end());
  int ans = 0;
  rep(i, n) ans += s[i];
  if (ans % 10 == 0) {
    rep(i, n + 1) {
      if (i == n) ans = 0;
      else if (s[i] % 10 != 0) {
        ans -= s[i];
        break;
      }
    }
  }
  cout << ans << endl;


  
  return 0;
}

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

public class Main {
	
	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int date=0;
            while ((line = br.readLine()) != null) {
	            date=Integer.parseInt(line);
	            int kok_all=Integer.parseInt(br.readLine());
	            int san_all=Integer.parseInt(br.readLine());
	            int kok_max=Integer.parseInt(br.readLine());
	            int san_max=Integer.parseInt(br.readLine());
	            int store_kok,store_san;
	            store_kok=kok_all/kok_max;
	            store_san=san_all/san_max;
	            if(kok_all%kok_max!=0){
	            	store_kok++;
	            }
	            if(san_all%san_max!=0){
	            	store_san++;
	            }
	            System.out.println(date-Integer.max(store_kok, store_san));
	            break;
            }
            
        }
    }

}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<ll,ll> p;

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

vector<vector<bool> > canDraw;
vector<ll> used;
ll N;

#define MAX_V 100010
struct edge {ll to, cost;};
ll V;
vector<edge> G[MAX_V];
vector<ll> pre;
ll d[MAX_V];

void dijkstra(ll s){
    priority_queue<p,vector<p>, greater<p> > que;
    fill(d,d+V, INF);
    d[s]=0;
    que.push(p(0,s));
    while(!que.empty()){
        p pi = que.top(); que.pop();
        ll v = pi.second;
        if(d[v] < pi.first) continue;
        REP(i,G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                pre[e.to] = v;
                que.push(p(d[e.to],e.to));
            }
        }
    }
}

void dfn(int s) {
    for(auto x: G[s]) {
        if(used[x.to] == 0) {
            used[x.to] = 1;
            dfn(x.to);
        }
    }
}

void dsn(int s) {
    for(auto x: G[s]) {
        if(used[x.to] == 0) {
            used[x.to] = 2;
            dsn(x.to);
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    V = N;
    pre.resize(N,0);
    REP(i, N-1) {
        ll a, b;
        cin >> a >> b;
        G[a-1].pb(edge{b-1, 1});
        G[b-1].pb(edge{a-1, 1});
    }
    dijkstra(0);
    vector<ll> ppath;
    set<ll> sn;
    set<ll> fn;
    used = vector<ll>(N);
    ll pr = N-1;
    ppath.pb(N-1);
    while(ppath[ppath.size()-1] != 0) {
        ppath.pb(pre[pr]);
        pr = pre[pr];
        // cout << pr << endl;
    }
    reverse(ppath.begin(), ppath.end());
    ll fnd = 1;
    ll snd = 2;
    ll cnt = 0;
    ll th = (ll)ppath.size()/2 + ppath.size()%2;
    ll fncnt = 0;
    ll sncnt = 0;
    for(auto x: ppath) {
        if (cnt+1 <= th) {
            used[x] = fnd;
        } else {
            used[x] = snd;
        }
        cnt++;
    }
    
    cnt = 0;
    for(auto x: used) {
        if(x == fnd) {
            dfn(cnt);
        } else if (x == snd) {
            dsn(cnt);
        }
        cnt++;
    }
    
    for(auto x: used) {
        if(x == fnd) {
            fncnt++;
        } else if (x == snd) {
            sncnt++;
        }
    }
    
    
//    cout << fncnt + sncnt << endl;
    
    if(sncnt < fncnt) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 10748
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<pair<int,long long> > v[100010];
long long d[100010];
void DFS(int x,long long r){
	if(d[x]<=r)return;
	d[x]=r;
	for(int i=0;i<v[x].size();i++){
		DFS(v[x][i].first,r+v[x][i].second);
	}
}
int main(){
	int n,q,k;cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;long long c;
		cin>>a>>b>>c;a--,b--;
		v[a].push_back(make_pair(b,c));
		v[b].push_back(make_pair(a,c));
	}
	for(int i=0;i<n;i++)d[i]=114514114514114514;
	cin>>q>>k;
	DFS(k-1,0);
	while(q--){
		int a,b;cin>>a>>b;a--,b--;
		cout<<d[a]+d[b]<<endl;
	}
	return 0;
}


Measured memory_bytes: 14336
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

def main():
    S = input()

    if S.endswith('s'):
        print(S + 'es')
    else:
        print(S + 's')





if __name__ == '__main__':
    main()


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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  set<int> r, g, b;
  
   rep(i, s.size()){
     if(s[i]=='R') r.insert(i);
     if(s[i]=='G') g.insert(i);
     if(s[i]=='B') b.insert(i);
   }
  ll uns = 0;
  for(int p : r){
    for(int q : g){
      int u, v, w;
      u = v = w = 0;
      u = 2*p - q;
      v = 2*q - p;
      if((p+q)%2==0) w = (p+q)/2;       
      if(b.count(u)) uns++;
      if(b.count(v)) uns++;
      if((p+q)%2==0 && b.count(w)) uns++;      
   }
  }
  
   ll ans = r.size()*g.size()*b.size() - uns;
   cout << ans << endl;   
  
  
  return 0;
}


Measured memory_bytes: 3704
h,w = map(int, input().split())
mod = 10**9+7
dp = [None]*(h+1)
dp[0] = [0]*(w+1)
for i in range(1,h+1):
  dp[i] = [0] + list(input())
dp[1][1] = 1
for i in range(1,h+1):
  for j in range(1,w+1):
    if i==j==1:
      continue
    if dp[i][j] == "#":
      dp[i][j] = 0
    else:
      dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod
print(dp[h][w])

Measured memory_bytes: 42588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=310;
const int mod=998244353;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

char str[N];
int k,f[N][N][N],sum[N],s[N],s1[N][N][N],s2[N][N][N],n;

int getf(int i,int j,int k);

int gets1(int i,int j,int k) {
	if(j<0||k<0) return 0;
	if(s1[i][j][k]!=-1) return s1[i][j][k];
	return s1[i][j][k]=(getf(i,j,k)+gets1(i,j-1,k-1))%mod;
}

int gets2(int i,int j,int k) {
	if(j<0||k<0) return 0;
	if(s2[i][j][k]!=-1) return s2[i][j][k];
	return s2[i][j][k]=(getf(i,j,k)+gets2(i,j-1,k))%mod;
}

int getf(int i,int j,int k) {
	if(f[i][j][k]!=-1) return f[i][j][k];
	if(!i) return j==0&&k==0;
	if(j<sum[i]) return 0;
	int ret=0;
	if(s[i]<=j) ret=gets1(i-1,j-s[i],k);
	if(s[i]>0) ret=(0ll+ret+gets2(i-1,j,k)-gets2(i-1,j-s[i],k)+mod)%mod;
	return f[i][j][k]=ret;
}

int main() {
	cin>>(str+1)>>k;n=strlen(str+1);
	memset(f,-1,sizeof(f));
	memset(s1,-1,sizeof(s1));
	memset(s2,-1,sizeof(s2));
	int len=0,tt=0;
	for(int i=1;i<=n;i++)
		if(str[i]=='0') s[++tt]=len,len=0;
		else ++len;
	s[++tt]=len;n=tt;
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+s[i];
	int ans=0;
	for(int i=0;i<N&&i<=k;i++) ans=(ans+getf(n,sum[n],i))%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 352820
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = list(map(int, input().split()))
B = [[A[i], i+1] for i in range(N)]

B = sorted(B)

for i in range(N):
    print(B[i][1], end= " ")


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

using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    int ten[n] = {0};
    int badten[n] = {0};
    for (int i=0; i<n; i++) {
        int h;
        cin >> h;
        ten[i] = h;
    }
    for (int j=0; j<m; j++) {
        int a,b;
        cin >> a >> b;
        if (ten[a-1] == ten[b-1]) {
            badten[a-1] = 1;
            badten[b-1] = 1;
            continue;
        };
        if (ten[a-1] < ten[b-1]) {
            badten[a-1] = 1;
        } else {
            badten[b-1] = 1;
        }
    }
    int count = 0;
    for (int ten : badten) count += ten;
    cout << (n-count) << endl;
    return 0;
}



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

// Problem https://atcoder.jp/contests/abc085/tasks/abc085_c

vector<int> solver(int allMoney,int needSum){
    vector<int> result(3,-1);
    for(int bill10000=0;bill10000<=allMoney;bill10000++){
        for(int bill5000=0;bill5000<=allMoney-bill10000;bill5000++){
            int bill1000=allMoney-bill10000-bill5000;
            int sum=bill10000*10000+bill5000*5000+bill1000*1000;
            if(sum == needSum){
                result.at(0) = bill10000;
                result.at(1) = bill5000;
                result.at(2) = bill1000;
                break;
            }
        }

    }
    return result;
}

int main(void){
    vector<int> answer(3,-1);
    int N,Y;
    cin >> N >> Y ;
    answer = solver(N,Y);
    cout << answer.at(0) << " " << answer.at(1) << " " << answer.at(2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
		if(s[i]=='A'&&s[i+1]=='C'){
			cout<<"Yes"<<endl;
		    return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

int n;
ll K;
ll A[SIZE];

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lld",&A[i]);
	int t=0,t0=0;
	ll u=0;
	ll ans=0;
	for(int s=0;s<n;s++){
		while((t<n && ((A[t]^u)==(A[t]+u))) || s==t){
			u += A[t++];
		}
		int f = max(t0,s);
		ans += (ll)((f-s+1)+(t-s))*(t-f)/2;
		t0=t;
		u -= A[s];
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 1664
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,mx,sum,p;
	scanf("%d",&n);
	mx=-1;	sum=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&p);
		sum+=p;
		mx=max(mx,p);
	}
	sum=sum-mx/2;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
def main():
    N, Q = [int(x) for x in input().split()]
    edges = [[] for x in range(N)]
    cnt = [0] * N
    for i in range(N-1):
        a, b = [int(x) for x in input().split()]
        edges[a - 1].append(b - 1)
    # print(edges)
    # print(Q)
    for i in range(Q):
        p, x = [int(y) for y in input().split()]
        cnt[p - 1] += x
    # print(cnt)

    stack = [0]
    while len(stack) > 0:
        node = stack.pop()
        for t in edges[node]:
            cnt[t] += cnt[node]
            stack.append(t)
        # print(",".join(map(str, stack)))
    print(" ".join(map(str, cnt)))
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 58948
// Example program
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{int S;
cin>>S;
int h;
int m;
int s;
int p;
h=S/3600;
p=S%3600;
m=p/60;
s=S-h*3600-m*60;

cout<<h<<":"<<m<<":"<<s<<endl;




 
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  
  else if (A + B > C + D) {
    cout << "Left" << endl;
  }

  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
 using namespace std;
 int main(){
int x1 , x2 , x3 , x4 , x5 ;
cin>>x1>>x2>>x3>>x4>>x5;
if(x1 == 0)
{
    cout<<'1'<<endl;
}
else if(x2 == 0)
{
    cout<<'2'<<endl;
}
else if(x3 == 0)
{
    cout<<'3'<<endl;
}
else if(x4 == 0)
{
    cout<<'4'<<endl;
}
else if(x5 == 0)
{
    cout<<'5'<<endl;
}
 return 0;}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
    int n,men[4][3][10]={},b,f,r,v;
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin>>b>>f>>r>>v;
        men[b-1][f-1][r-1]+=v;
    }
    for (int i=0; i<4; i++)
    {
        for (int j=0; j<3; j++)
        {
            for (int k=0; k<10; k++)
            {
                cout<<" "<<men[i][j][k];
            }
            cout<<'\n';
        }
        if (i!=3) cout<<"####################\n";
    }
    //cout<<'\n';
    return 0;
}



Measured memory_bytes: 3092
// file creato da gio il 2020-03-31 21:23:51.244436

#include <bits/stdc++.h>
#define FAST 

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define S second
#define F first
#define PB push_back
using namespace std;

int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif

	int N;
	int ris=0;
	cin >> N;
	ris=N/500*1000;
	ris+=(N%500)/5*5;
	cout <<ris;
}

Measured memory_bytes: 256
import sys

s = list(input())
t = list(input())

if len(s) < len(t):
    print("UNRESTORABLE")
    sys.exit()

ans = False
con = True

for i in range(len(s)):
    for j in range(len(t)):
        if i+j>len(s)-1:
            con = False
            break
        if s[i+j] == t[j] or s[i+j] =='?':
            if j == len(t)-1:
                ans = True
                memo1 = i
                
        else:
            break
        

    if not(con):
        break

if not(ans):
    print("UNRESTORABLE")
else:
    for i in range(len(t)):
        s[memo1+i] = t[i]
    for i in range(len(s)):
        if s[i] == "?":
            s[i] = "a"

    
    for i in range(len(s)):
        print(s[i],end = "")

print()


Measured memory_bytes: 3064
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL vmax(vi v, LL n) {
	int MAX = 0;
	f(i, 0, n) {
		MAX = max(MAX, v[i]);
	}
	return MAX;
}

LL vmin(vi v, LL n) {
	int MIN = LL_INF;
	f(i, 0, n) {
		MIN = min(MIN, v[i]);
	}
	return MIN;
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//エラトステネスの篩
void sieve(LL n) {
	vb s(n + 1, true);
	f(i, 2, n + 1) {
		for (int j = 2; i*j <= n; j++) {
			s[i*j] = false;
		}
	}
	cout << "2から" << n << "までの素数" << endl;
	f(i, 2, n + 1) {
		if (s[i]) {
			cout << i << " ";
		}
	}
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	int d, n;
	cin >> d >> n;
	int ans;
	if (d == 0)ans = 0;
	else {
		ans = pow(100, d);
		n--;
	}
	while (n > 0) {
		ans += pow(100, d);
		if (ans / pow(100, d) >= 100) {
			ans += pow(100, d);
		}
		n--;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
while True:
    a, c, b = input().split()
    a = int(a)
    b = int(b)
    if c == "?":
        break
    if c == "+":
        print(a + b)
    elif c == "-":
        print(a - b)
    elif c == "*":
        print(a * b)
    elif c == "/":
        print(a // b)


Measured memory_bytes: 5592
N = int(input())
A = [[[0] * 10, [0] * 10, [0] * 10], [[0] * 10, [0] * 10, [0] * 10], [[0] * 10, [0] * 10, [0] * 10], [[0] * 10, [0] * 10, [0] * 10]]

for i in range(N):
    b, f, r, v = [int(j) for j in input().split()]
    A[b-1][f-1][r-1] += v

for a, b in enumerate(A):
    for f in b:
        print(' ' + ' '.join([str(i) for i in f]))
    else:
        if a != len(A) - 1:
            print('#' * 20)

Measured memory_bytes: 7756
N = int(input())
A = list(map(int, input().split()))

l = []
d = {}

for addnum, record in enumerate(A):
    d[(addnum + 1)] = record

for i in  sorted(d.items(), key=lambda x:x[1]):
    l.append(i[0])


print(' '.join(map(str, l)))

Measured memory_bytes: 29404
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static List<Integer> grp1 = Arrays.asList(1, 3, 5, 7, 8, 10, 12);
	static List<Integer> grp2 = Arrays.asList(4, 6, 9, 11);
	static List<Integer> grp3 = Arrays.asList(2);

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[2];
		for (int i = 0; i < 2; i++) {
			int num = sc.nextInt();
			if(grp1.contains(num)) a[i] = 1;
			if(grp2.contains(num)) a[i] = 2;
			if(grp3.contains(num)) a[i] = 3;
		}
		if(a[0] == a[1]) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 23892
#include<iostream>
using namespace std;
class Cube{
    public:
    int f[6];
    Cube(){}
    void roll_z(){roll(1,2,4,3);}
    void roll_y(){roll(0,2,5,3);}
    void roll_x(){roll(0,1,5,4);}
    void roll(int i,int j,int k,int l){
        int t=f[i];
        f[i]=f[j];
        f[j]=f[k];
        f[k]=f[l];
        f[l]=t;
    }
};

int getRight(Cube c1,int f1,int f2){
    for(int i=0;i<6;i++){
        for(int j=0;j<4;j++){
            if(c1.f[0]==f1&&c1.f[1]==f2) return c1.f[2];
            c1.roll_z();
        }
        if(i%2==0)c1.roll_y();
        else c1.roll_x();
    }
    return -1;
}
int main(){
    Cube c;
    int f1,f2;
    for(int i=0;i<6;i++)cin>>c.f[i];
    int q;cin>>q;
    for(int i=0;i<q;i++){
        cin>>f1>>f2;
        cout<<getRight(c,f1,f2)<<endl;
    }
    return 0;
}


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


int main(){
	long long n, i, s = 0;
	cin >> n;
	vector<long long> a(n);
	for (i = 0; i < n; i++){
		cin >> a[i];
		s += a[i];
		a[i] *= 2;
	}
	long long x = s;
	for (i = 1; i < n; i += 2) x -= a[i];
	cout << x << " ";
	for (i = 0; i < n - 1; i++){
		x = a[i] - x;
		cout << x << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
#include<string.h>
int main(){
    int n;
    scanf("%d",&n);
    for(int j=0;j<n;j++){
        char pro[1000];
        scanf(" %s",pro);
        int num;
        num=strlen(pro);
        int a[1000]={};
        for(int i=0;pro[i]!='\0';i++){
            a[i]=pro[i]-'0';
        }
        int ans=0,count=0;
        for(int i=0;i<num;i++)ans+=a[i];
        while(ans>9){
            ans-=9;
            count++;
        }
        if((num-1+count)%2==0)printf("Audrey wins.\n");
        else printf("Fabre wins.\n");
    }
    return 0;
}

Measured memory_bytes: 2564
module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n @@ fun i -> Scanf.scanf "%d " @@ fun a -> i, a in
  Array.to_list as_
    |> List.sort (fun (_, a) (_, a') -> compare a a')
    |> List.fold_left (fun (acc, s) (j, a) ->
        let (lt, _, gt) = IntSet.split j s in
        let i = try IntSet.max_elt lt with Not_found -> -1 in
        let k = try IntSet.min_elt gt with Not_found -> n in
        (acc + (k - j) * (j - i) * a, IntSet.add j s)) (0, IntSet.empty)
    |> fst
    |> Printf.printf "%d\n"


Measured memory_bytes: 24960
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a >= 0 && c >= 0) cout << b*d << endl;
  else if(a >= 0 && c < 0 && d >= 0) cout << b*d;
  else if(a >= 0 && d < 0) cout << a*d << endl;

  else if(a < 0 && b >= 0 && c >= 0) cout << b*d << endl;
  else if(a < 0 && b >= 0 && c < 0 && d >= 0) { 
    if(a*c >= b*d) cout << a*c << endl;
    else cout << b*d << endl;
  }
  else if(a < 0 && b >= 0 && d < 0) cout << a*c << endl;
  
  else if(b < 0 && c >= 0 )cout << b*c << endl;
  else if(b < 0 && c < 0 && d >= 0) cout << a*c << endl; 
  else if(b < 0 && d < 0) cout << a*c << endl;
  return 0;
 }


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}



int main(){
	ll N, K;//計算に使うんでllにします
	cin >> N >> K;

	// a+b, b+c, c+a　のすべてが0 (mod K)になればよい
	//→ a, b, cがすべて0 (mod K) あるいは K/2 (mod K)となる場合のみを計算すればよい
	// K/2の方はKが偶数でないとa, b, cが整数でなくなる
	ll ans = (N / K) * (N / K) * (N / K);//()をつけないと左から計算されていき, 例えば2回目のKで割るときにおかしくなる
	if(K%2 == 0) ans += ((N+K/2)/K) * ((N+K/2)/K) * ((N+K/2)/K); 
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3604
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;

int gcd(int a, int b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}


ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int A, B;

int main() {
	cin >> A >> B;
	if (A > 8 || B > 8) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=101000;
int n,k;
char p[N];
pair<char,int> go[N];
string s,t,ans;
int main() {
	scanf("%d%d",&n,&k);
	scanf("%s",p);
	s=p; t=s; reverse(all(t));
	s=s+t;
	per(i,0,SZ(s)) {
		if (i==SZ(s)-1||s[i]!=s[i+1]) go[i]=mp(s[i],-1);
		else { go[i]=go[i+1]; go[i].se--; }
	}
	auto v=*min_element(go,go+n);
	--k;
	rep(i,0,n) if (go[i]==v) {
		if (k>=20||(-(ll)go[i].se*(1<<k)>=n)) {
			rep(j,0,n) printf("%c",s[i]); puts("");
			return 0;
		}
		string ss(-go[i].se*(1<<k),go[i].fi);
		int j=i-go[i].se;
		while (SZ(ss)<n) ss.pb(s[j++]);
		if (ans.empty()) ans=ss;
		ans=min(ans,ss);
	}
	printf("%s\n",ans.c_str());
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

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

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  map<string,ll> mp;
  string s;
  rep(i,n) {
    cin >> s;
    sort(ALL(s));
    ++mp[s];
  }
  ll ans = 0;
  for(auto v : mp) {
    if( v.second >= 2LL ) {
      ll x = v.second;
      ans += ( x * ( x - 1LL ) );
    }
  }
  assert( !( ans & 1LL ) );
  ans /= 2LL;
  cout << ans << endl;
  compute();
  return 0;
}


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

int main() {

    int n, a[3 * 100000];
    vector< long long > sum(3 * 1000001, 0),left(3 * 100000, 0), right(3 * 100000, 0);

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

    priority_queue< int, vector< int >, greater< int > > l;
    priority_queue< int > r;
    long long suml = 0;
    for(int i = 0; i < n; i++) {
        l.push(a[i]); suml += a[i];
    }
    left[n - 1] = suml;
    for(int i = n; i < 2 * n; i++) {
        l.push(a[i]); suml += a[i];
        suml -= l.top(); l.pop();
        left[i] = suml;
    }

    long long sumr = 0;
    for(int i = 3 * n - 1; i >= 2 * n; i--) {
        r.push(a[i]); sumr += a[i];
    }
    right[2 * n - 1] = sumr;
    for(int i = 2 * n - 1; i >= n; i--) {
        r.push(a[i]); sumr += a[i];
        sumr -= r.top(); r.pop();
        right[i - 1] = sumr;
    }

    long long ans = -100000000000000000;
    for(int i = n - 1; i < 2 * n; i++) {
        ans = max(ans, left[i] - right[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 30712
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<ll> x(n),y(n);
	set<int> st;
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i];
		st.insert(((x[i]+y[i])%2+2)%2);
	}
	if(st.size()==2){
		cout << -1 << endl;
		return 0;
	}
	vector<ll> d(35);
	vector<string> res(n);
	if((x[0]+y[0])%2){
		for(int i=0;i<35;i++){
			d[i]=(1LL<<i);
		}
		for(int i=0;i<n;i++){
			string ans="";
			for(int j=34;j>=0;j--){
				if(abs(x[i])>abs(y[i])){
					if(x[i]>=0){
						x[i]-=d[j];
						ans+='R';
					}else{
						x[i]+=d[j];
						ans+='L';
					}
				}
				else{
					if(y[i]>=0){
						y[i]-=d[j];
						ans+='U';
					}else{
						y[i]+=d[j];
						ans+='D';
					}
				}
			}
			reverse(ans.begin(),ans.end());
			res[i]=ans;
		}
	}else{
		for(int i=0;i<34;i++){
			d[i]=(1LL<<i);
		}
		d[34]=1;
		for(int i=0;i<n;i++){
			string ans="";
			x[i]--;
			ans+='R';
			for(int j=33;j>=0;j--){
				if(abs(x[i])>abs(y[i])){
					if(x[i]>=0){
						x[i]-=d[j];
						ans+='R';
					}else{
						x[i]+=d[j];
						ans+='L';
					}
				}
				else{
					if(y[i]>=0){
						y[i]-=d[j];
						ans+='U';
					}else{
						y[i]+=d[j];
						ans+='D';
					}
				}
			}
			reverse(ans.begin(),ans.end());
			res[i]=ans;
		}
	}
	cout << d.size() << endl;
	for(int i=0;i<d.size();i++){
		cout << d[i] << " ";
	}
	cout << endl;
	for(int i=0;i<n;i++){
		cout << res[i] << endl;
	}
}

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

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

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int a, b;
   cin >> a >> b;
   if (a + b == 15) {
      puts("+");
   } else if (a * b == 15) {
      puts("*");
   } else {
      puts("x");
   }

   return 0;
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int a, b, c;cin>>a>>b>>c;
    int m = max(a,b);
    m = max(m,c);
    if(a+b+c==2*m){
        cout << "Yes" << endl;
        return 0;
    }
        cout << "No" << endl;	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;
ll ans[N],h,w,a,b;
inline int lc(int x){return x<<1;}
inline int rc(int x){return x<<1|1;}

struct node{
  int l,r;
  ll segl = 0,segmin = 0,lazy = 0;
  bool flag = false;
}t[N<<2];

void build(int p,int l,int r){
  t[p].l = l;t[p].r = r;
  if(l == r) return;
  int mid = (l+r)>>1;
  build(lc(p),l,mid);build(rc(p),mid+1,r);
}

void push_down(int p){
  if(t[p].flag){
    for(int i = lc(p);i <= rc(p);i++){
      t[i].segl = t[i].segmin = t[p].segl + t[i].l - t[p].l;
      t[i].lazy = 0;t[i].flag = true;
    }
  }
  else if(t[p].lazy){
    for(int i = lc(p);i <= rc(p);i++){
      t[i].segl += t[p].lazy;
      t[i].segmin += t[p].lazy;
      t[i].lazy += t[p].lazy;
    }
  }
  t[p].flag = false;t[p].lazy = 0;
}

void update(int p,int l,int r,ll val){
  if(t[p].l >= l and t[p].r <= r){
    t[p].segl = t[p].segmin = val + t[p].l - l + 1;
    t[p].flag = true;t[p].lazy = 0;return;
  }
  push_down(p);
  int mid = (t[p].l + t[p].r)>>1;
  if(l <= mid) update(lc(p),l,r,val);
  if(mid + 1 <= r) update(rc(p),l,r,val);
  t[p].segl = t[lc(p)].segl;
  t[p].segmin = min(t[lc(p)].segmin,t[rc(p)].segmin);
}

void add(int p,int l,int r){
  if(t[p].l >= l and t[p].r <= r){
    t[p].lazy++;t[p].segl++;t[p].segmin++;return;
  }
  push_down(p);
  int mid = (t[p].l + t[p].r)>>1;
  if(l <= mid) add(lc(p),l,r);
  if(mid+1 <= r) add(rc(p),l,r);
  t[p].segl = t[lc(p)].segl;
  t[p].segmin = min(t[lc(p)].segmin,t[rc(p)].segmin);
}

ll query(int p,int l,int r){
  if(r < 1 or l > w) return inf;
  if(t[p].l >= l and t[p].r <= r) return t[p].segmin;
  push_down(p);
  ll ans = inf;
  int mid = (t[p].l + t[p].r)>>1;
  if(l <= mid) ans = min(ans,query(lc(p),l,r));
  if(mid+1 <= r) ans = min(ans,query(rc(p),l,r));
  return ans;
}


int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>h>>w;
  build(1,1,w);
  memset(ans,inf,sizeof(ans));
  for(int i = 1;i <= h;i++){
    cin>>a>>b;
    if(a > 1) add(1,1,a-1);
    if(b < w) add(1,b+1,w);
    ll L = query(1,a-1,a-1);
    update(1,a,b,L);
    ans[i] = min(ans[i],query(1,1,w));
    if(ans[i] > h+w) ans[i] = -1;
  }
  for(int i = 1;i <= h;i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}


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

typedef long long ll;
const int N = 2000006;

vector<pair<int,int> > adj[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	
	for(int i=0;i<n;i++){
		int m;
		cin>>m;
		for(int j=0;j<m;j++){
			int x,y;
			cin>>x>>y;
			adj[i].push_back({x-1,y});
		}
	}
	
	
	int ans = 0;
	for(int i=0;i<(1<<n);i++){
		//cout<<i<<" : "<<endl;
		bool OK = true;
		int cnt = 0;
		for(int j=0;j<n;j++){
			if(i & (1<<j)){
				//cout<<j<<endl;
				cnt++;
				for(auto p:adj[j]){
					int y = p.first, st = p.second;
					//cout<<y<<" "<<st<<" "<<(i&(1<<y))<<endl;
					if( bool(i&(1<<(y))) != st ){
						OK = false;
						break;
					}
				}
			}
			if(!OK)break;
		}
		if(OK){
			ans = max(ans,cnt);
		}
	}
	cout<<ans;
	
	return 0;
}


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

int main(void) {
  int n,k;
  cin >> n >> k;
  int d;
  int tmp;
  vector<int> sunuke(n);
  rep(i,k){
    cin >> d;
    rep(j,d){
      cin >> tmp;
      sunuke[tmp-1]=1;
    }
  }
  int counter=0;
  rep(l,n){
    if(sunuke[l]==0) counter++;
  }
  cout << counter;
  return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111
#define MOD 1000000007

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

ll fact[N] ;

int main() {
  fact[1] = 1 ;
  for(ll i = 2 ;i<=100005 ; i++)
    fact[i] = (fact[i-1]*i)%MOD ;

  ll n, m , ans ;
  scanf("%lld %lld", &n, &m) ;

  if(m>n) swap(n,m) ;
  if(n-1>m){
    printf("0") ;
    return 0 ;
  }
  ans = fact[n] ;

  for(int i = m ;i>(m-n+1) ; i--)
    ans = (ans*i)%MOD ;
 
  if(n==m) ans = (ans*2)%MOD ;
  printf("%lld", ans) ;
	
  return 0 ;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int mod = 998244353;
int n, s;
int a[3000];
int dp[3001][6001];

signed main() {
	int i, j;
	
	cin >> n >> s;
	rep(i, n) cin >> a[i];
	
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, s + 1) {
			(dp[i + 1][j] += 2 * dp[i][j]) %= mod;
			(dp[i + 1][j + a[i]] += dp[i][j]) %= mod;
		}
	}
	
	cout << dp[n][s] << endl;
	return 0;
}

Measured memory_bytes: 97636
#include<iostream>
int s[100]={0},f[100]={0},B[100][100]={0},A[100]={0},d[100],c[100]={0},cnt=1,tmp;
bool con(int A[],int n){
	for(int i=0;i<n;i++){
		if(A[i]==0){
			tmp=i;
			return true;
		}
	}
	return false;
}
void search(int v){
  A[v]=1;
  s[v]=cnt++;
  for(int i=0;i<d[v];i++){
    if(A[B[v][i]]==0){
      search(B[v][i]);
    }
  }
  f[v]=cnt++;
}
int main(){
  int n,num,flag;
  std::cin>>n;
  for(int i=0;i<n;i++){
    std::cin>>num>>d[i];
    for(int j=0;j<d[i];j++){
      std::cin>>flag;
      B[num-1][j]=flag-1;
    }
  }
  search(0);
	while(con(A,n)){
		search(tmp);
	}
  for(int i=0;i<n;i++){
    std::cout<<i+1<<" "<<s[i]<<" "<<f[i]<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3120