akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

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 int MOD = 1e9 + 7;
const ll INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 100020;


int x[505];
bool used[300030];
int ans[300030];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	vector<P>v;
	REP(i, N) {
		cin >> x[i];
		used[x[i]] = true;
		ans[x[i]] = i + 1;
		v.push_back({ x[i],i+1 });
	}
	VSORT(v);
	int pos = 1;
	REP(i, N) {
		int idx = v[i].first;
		int rem = v[i].second - 1;
		//pe(idx)print(rem);
		while (rem > 0) {
			if (pos >= idx) {
				print("No"); return 0;
			}
			if (used[pos]) {
				pos++;
			}
			else {
				rem--;
				ans[pos] = v[i].second;
				used[pos] = true;
			}
		}
	}
	pos = N * N;
	REPR(i, N - 1) {
		int idx = v[i].first;
		int rem = N - v[i].second;
		while (rem > 0) {
			if (pos <= idx) {
				print("No"); return 0;
			}
			if (used[pos]) {
				pos--;
			}
			else {
				rem--;
				ans[pos] = v[i].second;
				used[pos] = true;
			}
		}
	}
	print("Yes");
	for (int i = 1; i <= N * N; i++) {
		if (i == N * N)print(ans[i]) else pe(ans[i]);
	}
}



Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#define mod 998244853 
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	double x, r=0, r1;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
	    cin >> x;
	    r = r+ 1.0/x;
	}
	r1 = 1.0/r;
	cout << r1 << '\n';
}


Measured memory_bytes: 256
# coding:utf-8

INF = float('inf')


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


N, M = inpl()

X = []
Y = []
Z = []
for i in range(N):
    x, y, z = inpl()
    X.append(x)
    Y.append(y)
    Z.append(z)

ans = -INF
sign = [-1, 1]
for a in sign:
    for b in sign:
        for c in sign:
            score = []
            for i in range(N):
                tmp = a * X[i] + b * Y[i] + c * Z[i]
                score.append(tmp)
            score.sort()
            score.reverse()
            ans = max(ans, sum(score[:M]))

print(ans)

Measured memory_bytes: 3188
def solve():
    n = int(input())
    a = map(int, input().split())

    dp = [[-1] * 2 for _ in range(n + 1)]
    dp[0][False] = 0
    # dp[idx][マイナスをかける必要があるか]:=総和の最大値

    for j, x in enumerate(a):
        if dp[j][True] == -1:
            dp[j + 1][False] = dp[j][False] + x
            dp[j + 1][True] = dp[j][False] - x
        else:
            dp[j + 1][False] = max(dp[j][False] + x, dp[j][True] - x)
            dp[j + 1][True] = max(dp[j][False] - x, dp[j][True] + x)
    return dp[n][False]


if __name__ == '__main__':
    print(solve())


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

int main(void){
    int NMOD=0;
    string strN;
    cin >> strN;
    for(char C: strN){
        NMOD = (NMOD + (C - '0')) % 9;
    }
    if(NMOD == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3748
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define MAX (int)1e+6

int main(void)
{

  int i,j;
  int a[181],b[46];
  int n;
  int dp1[MAX],dp2[MAX];

  b[0] = 0;
  j = 1;
  for(i=0;i<181;i++){
    a[i] = i * (i+1) * (i+2) / 6;
    if(a[i]%2){
      b[j] = a[i];
      j++;
    }
  }

  for(i=0;i<MAX;i++){
    dp1[i] = 6;
    dp2[i] = 1000000;
  }

  for(i=0;i<MAX;i++){
    for(j=0;j<181;j++){
      if(i>a[j]){
	if(dp1[i] > dp1[i-a[j]]+1){
	  dp1[i] = dp1[i-a[j]]+1;
	}
      }else if(i==a[j]){
	dp1[i]=1;
      }else break;
    }
  }
  
  for(i=0;i<MAX;i++){
    for(j=0;j<46;j++){
      if(i>b[j]){
	if(dp2[i] > dp2[i-b[j]]+1){
	  dp2[i] = dp2[i-b[j]]+1;
	}
      }else if(i==b[j]){
	dp2[i]=1;
      }else break;
    }
  }


  while(1){
    scanf("%d",&n);
    if(!n)break;

    printf("%d %d\n",dp1[n],dp2[n]);

   
  }

  return 0;

}

Measured memory_bytes: 8092
M[100][100][2],Z=100,l=100000;main(w,h,i,j){
for(M[0][0][0]=M[0][0][1]=M[1][1][0]=M[1][1][1]=j=1;j<Z;j++)M[0][j][0]=0,M[0][j][1]=M[0][j-1][1];
for(i=1;i<Z;i++)for(M[i][0][0]=M[i-1][0][0],M[i][0][1]=0,j=1;j<Z;j++)M[i][j][0]=(M[i-1][j][0]+M[i-1][j-1][1])%l,M[i][j][1]=(M[i][j-1][1]+M[i-1][j-1][0])%l;
for(;scanf("%d%d",&w,&h),w;)printf("%d\n",(M[h-1][w-1][0]+M[h-1][w-1][1])%l);exit(0);
}

Measured memory_bytes: 676
#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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

ll f(ll c, ll x) {
   if (c < 0) return 0;
   return c / x + 1;
}
int main() {
   ll a, b, x;
   cin >> a >> b >> x;
   hr();
   ll ans = f(b, x) - f(a - 1, x);
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),a=sc.nextInt(),b=sc.nextInt();

		if(a==b && b==n) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
	public static int floor(int n) {
		return (int)Math.floor((n*n + 4.0)/8.0);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll n; cin >> n;
    if(n<1000) puts("ABC");
    else puts("ABD");
}


Measured memory_bytes: 256
N,A,B,C = map(int ,input().split())
l = [int(input()) for i in range(N)]
INF = 10**9

def dfs(res, a, b, c):
	if res == N:
		if a != 0 and b != 0 and c != 0:
			return abs(a-A) + abs(b-B) + abs(c-C) -30
		else:
			return INF
	else:
		ret0 = dfs(res+1,a,b,c)
		ret1 = dfs(res+1,a+l[res],b,c) + 10
		ret2 = dfs(res+1,a,b+l[res],c) + 10
		ret3 = dfs(res+1,a,b,c+l[res]) + 10
		return min(ret0,ret1,ret2,ret3)

print (dfs(0,0,0,0))

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

//Combination
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<long long> kosu;//ありえる素因数のmaxを入れる

void divisor(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if(n % i == 0){  
      kosu.push_back(0); 
    }
    while(n % i == 0){
      kosu[kosu.size()-1]++;
      n /= i;
    }
  }
  if(n != 1){
    kosu.push_back(1);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  long long N, M;
  cin >> N >> M;
  COMinit();
  if(M == 1){  
    cout << 1 <<endl;
    return 0;
  }
  else divisor(M);
  long long ans = 1;
  for(auto x: kosu){  
    ans *= COM(N + x - 1, N - 1); 
    ans %= MOD;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 15604
/**
 *    author:  math2do
 *    created: 18.01.2020 02:59:16
**/

#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "1" : "0");
}
string to_string(const char &ch) {
  return string(1, ch);
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  reverse(res.begin(), res.end());
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

//..import matrix, queue, stack

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  #ifdef LOCAL
    freopen("C_vacation.in", "rt", stdin);
  #endif
  int n;
  cin >> n;
  vector <int> old_dp(3);
  for (int d = 0; d < n; d++) {
    vector <int> new_dp(3, 0);
    vector <int> arr(3);
    for (int i = 0; i < 3; i++) {
      cin >> arr[i];
    }
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (i != j) {
          new_dp[j] = max(new_dp[j], old_dp[i] + arr[i]);
        }
      }
    }
    old_dp = new_dp;
  }
 
  debug(old_dp);

  cout << max(old_dp[0], max(old_dp[1], old_dp[2])) << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	string a;
	cin>>a;
	a[3]='8';
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    
    map<string,int> M;
    
    
    rep(i,N){
        string s;
        cin >> s;
        M[s]++;
    }
    
    ve<string> a = {"AC", "WA", "TLE", "RE"};
    
    rep(i,4){
        cout << a[i] csp "x" csp M[a[i]] << endl;
    }
    
    

    return 0;
}


Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
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 unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
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; }

static uint MD = mod;
struct ModInt
{
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M &set_v(uint _v)
	{
		v = (_v < MD) ? _v : _v - MD;
		return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M &r) const { return M().set_v(v + r.v); }
	M operator-(const M &r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M &r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M &r) const { return *this * r.inv(); }
	M &operator+=(const M &r) { return *this = *this + r; }
	M &operator-=(const M &r) { return *this = *this - r; }
	M &operator*=(const M &r) { return *this = *this * r; }
	M &operator/=(const M &r) { return *this = *this / r; }
	bool operator==(const M &r) const { return v == r.v; }
	M pow(ll n) const
	{
		M x = *this, r = 1;
		while (n)
		{
			if (n & 1)
				r *= x;
			x *= x;
			n >>= 1;
		}
		return r;
	}
	M inv() const { return pow(MD - 2); }
	friend ostream &operator<<(ostream &os, const M &r) { return os << r.v; }
};
using Mint = ModInt;
//head
// cin >> t;
// for (int cas = 1; cas <= t; ++cas)
// {
// 	cout << "Case #" << cas << ": ";
// }
int vis[100005];
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	if(n&1) {
		int l=1;
		int r=n-1;
		rep(i,0,m) {
			cout<<l<<" "<<r<<endl;
			l++; r--;
		}
	}
	else {
		int l=1;
		int r=n;
		int t = (n-2)/2;
		t = t/2 + (t%2);
		bool fg=true;
		rep(i,0,m) {
			cout<<l<<" "<<r<<endl;
			l++; r--;
			if(l>t && fg) {
				r--;
				fg=false;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define lu long unsigned
#define ull unsigned long long

using namespace std;
bool sortbysec(const pair<string,int> &a,
              const pair<string,int> &b)
{
    return (a.second < b.second);
}
bool sortpair(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(a.first==b.first)
        return (a.second<b.second);
    else
        return(a.first>b.first);
}
bool s(const string &a, const string &b){
    bool ans;
    return (a.size()<b.size());
}
bool isPrime(int val){
    for(int i=2;i*i<=val;i++){
        if(val%i==0)
            return false;
    }
    return true;
}
ll int conc(ll int a,ll int b){
   stringstream ss;
   ss<<a<<b;
   ll int ans;
   ss>>ans;
   ss.clear();
   return ans;
}
ll int binexp(int a,int b){
    ll int res=1;
    while(b!=0){
        if(b&1){
            res*=a;
            b--;
        }else{
            a*=a;
            b/=2;
        }
    }
    return res;
}
int gcd(int a,int b){
    if(a%b==0){
        return b;
    }else{
        return gcd(a%b,b);
    }
}

void solve(){
    int h,w;
    cin>>h>>w;
    char b[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>b[i][j];
        }
    }
    for(int i=-1;i<=h;i++){
        for(int j=-1;j<=w;j++){
            if(i==-1||i==h||j==-1||j==w)
                cout<<"#";
            else
                cout<<b[i][j];
        }
        cout<<endl;
    }
}


int main(){
    /*int t;
    cin>>t;
    while(t--)*/
        solve();


    return 0;
}



































































//1-(3+5-2+(3+19-(3-1-4+(9-4-(4-(1+(3)-2)-5)+8-(3-5)-1)-4)-5)-4+3-9)-4-(3+2-5)-10




















Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 998244353;
const int Maxn = 3e3 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 21;

ll mul(ll a, ll b){
	return (a * b) % Mod;
}
ll bin_pow(ll b, ll p){
	ll res = 1;
	for(ll j = 1, pw = b; j <= p; j <<= 1, pw = mul(pw, pw))
		if(p & j) res = mul(res, pw);
	return res;
}
ll f[Maxn], iv[Maxn];
ll nCr(ll n, ll r){
	if((r < 0) || (n < r) || (n < 0)) return 0;
	return mul(f[n], mul(iv[r], iv[n - r]));
}


int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	f[0] = iv[0] = 1;
	for(int i = 1; i < Maxn; i++) f[i] = mul(f[i - 1], i), iv[i] = bin_pow(f[i], Mod - 2);
	
	ll n, x;
	cin >> n >> x;
	ll ans = 0;
	int c1, c2;
	for(int s = 0; s <= n + n; s++){
		for(int l = 0; l <= n; l++){
			c2 = s - l;
			c1 = s - (c2 + c2);
			if(min(c1, c2) < 0) continue;
			if(x == s) continue;
			if(x > s){
				ans += mul(nCr(n, n - l), nCr(l, c1));
				continue;
			}
			
			
			if((x % 2) == (c1 % 2)) continue;
			if(x < c1) continue;
			
			int l2 = c1 + ((x - c1) / 2);
			int l3 = l - l2;
			if(l3 >= l2){
				if(c1) continue;
				ans += nCr(n, n - l);
				continue;			
			}
			ans += mul(nCr(n, n - l), nCr(l2 - l3, c1));
		}
		//cerr << s << " : " << ans << '\n';
	}
	
	cout << ans % Mod;
	return 0;
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/



Measured memory_bytes: 256
import java.util.*;
 
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] v = new int[N];
		Arrays.setAll(v, i->sc.nextInt());
		Arrays.sort(v);
		double ans = v[0];
		for (int i=1; i<N; i++) {
			ans = (ans + v[i])/2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 26452
/*input
123456789012345678901234567890
234567890123456789012345678901
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//loops
#define f(i,s,n) for(ll i=(ll)s;i<(ll)n;i++)
#define rf(i,n,s) for(ll i=(ll)(n-1);i>=(ll)s;i--)
//reset
#define ms0(X) memset((X), 0, sizeof((X)))
#define ms1(X) memset((X), -1, sizeof((X)))
//IO
#define bio ios_base::sync_with_stdio;cin.tie(NULL)
//STL
#define pb push_back
#define pii pair<ll,ll>
#define vll vector<ll>
#define vpii vector<pii >
#define mll map<ll, ll>
#define mpii map<pii,ll> 
#define msll map<string, ll> 
#define sortv(v) sort(v.begin(),v.end())
#define F first
#define S second
//standard values
#define mod (ll)(1e9+7)
#define INF (ll)1e16
#define MAXN (ll)(1e5+5)
//comparator
bool cmp(pii a,pii b){
  if(a.F==b.F) return a.S<b.S;
  else return a.F<b.F;
}
ll exp(ll a,ll b){ll ans=1;while(b!=0){if(b%2==1)ans=ans*a;a=a*a;b/=2;}return ans;}
/********************************************************************************************************/
int main() 
{
  bio;
  string s1,s2;
  cin>>s1>>s2;
  if(s1.size()==s2.size()&&s1<s2||(s1.size()<s2.size())){
    cout<<"LESS"<<endl;
  }
  else if(s1.size()==s2.size()&&s1>s2||(s1.size()>s2.size())){
    cout<<"GREATER"<<endl;
  }
  else{
    cout<<"EQUAL"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
S = list(input())
l = len(S)-1
su = 0
for i in range(2**l):
    q = S[0]
    for j in range(l):
        if (i>>j) & 1:
            q += '+' + S[j+1]
        else:q += S[j+1]
    su += eval(q)
print(su)

Measured memory_bytes: 8776
#include <stdio.h> 

int main(void)
{
	int a,b,c, div = 0;
	scanf("%d %d %d",&a,&b,&c);
	for(int i=a; i<=b;i++)	
	{
		if(c % i == 0)
		{
			div++;
		}
	}
	printf("%d\n",div);
	    
		
	 
	return 0;
	
}


Measured memory_bytes: 2100
# coding: utf-8

from collections import Counter, defaultdict
import itertools


II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    cnt = Counter()
    N = II()
    for _ in range(N):
        cnt[input()[0]] += 1

    ans = 0
    for c1, c2, c3 in itertools.combinations("MARCH", 3):
        ans += cnt[c1] * cnt[c2] * cnt[c3]
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3316
#-*-coding:utf-8-*-

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    total1 = 0
    total2 = 0
    ans1 = 0
    ans2 = 0
    for i in range(n):
        total1 += a_list[i]
        if i % 2 != 0 and total1 <= 0:
            ans1 += abs(total1) + 1
            total1 = 1
        elif i % 2 == 0 and total1 >= 0:
            ans1 += total1 + 1
            total1 = -1
    for j in range(n):
        total2 += a_list[j]
        if j % 2 != 0 and total2 >= 0:
            ans2 += total2 + 1
            total2 = -1
        elif j % 2 == 0 and total2 <= 0:
            ans2 += abs(total2) + 1
            total2 = 1
    print(min(ans1, ans2))
            

if __name__ == '__main__':
    main()

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

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

using ll = int64_t;

using namespace std;

struct Sieve{

    // MAX : 1e7
    int n,p = 0;
    vector<int> prime;
    vector<bool> is_prime;

    Sieve(int n):n(n),is_prime(n+1,true){
        is_prime[0] = is_prime[1] = false;
        for(int i = 2;i <= n;i++){
            if(is_prime[i]){
                prime.push_back(i);
                p++;
                for(int j = 2 * i;j <= n;j += i) is_prime[j] = false;
            }
        }
    }

    map<int,int> prime_factor(int n){
        map<int,int> res;

        for(int i : prime){
            if(i > n) break;
            if(n % i == 0){
                int cnt = 0;
                while(n % i == 0){
                    cnt++;
                    n /= i;
                }
                res[i] = cnt;
            }
        }

        if(n != 1) res[n] = 1;

        return res;
    }

};


int main(void){
    
    int64_t n;cin >> n;
    int64_t ans = 0;
    for(int64_t i = 1;i <= n;i++){
        int64_t y = n / i;
        ans += i * (y*(y+1))/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int H,W,K; cin >> H >> W >> K;

  vector<int> A;
  for (int tmp = 0; tmp < (1 << (W-1)); tmp++) {
    bitset<7> s(tmp);
    bool flag = true;
    rep(i,(W-2)) if (s.test(i) && s.test(i+1)) flag = false;
    if (flag) A.emplace_back(tmp);
  }
  int N = A.size();

  vector<vector<int>> dp(H+1, vector<int>(W));
  vector<int> sum(W);
  dp[0][0] = 1;
  rep(i,H) {
    rep(j,N) {
      bitset<7> s(A[j]);
      rep(k,W) sum[k] = dp[i][k];
      rep(k,(W-1)) if (s.test(k)) swap(sum[k],sum[k+1]);
      rep(k,W) {
        dp[i+1][k] += sum[k];
        dp[i+1][k] %= MOD;
      } 
    }
  }
  if (W == 1) cout << 1 << endl;
  else cout << dp[H][K-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    string s;cin>>s;
    s[3]='8';
    cout<<s<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
 
using namespace std;

vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define MOD 1000000007
#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 2e5 + 5;

int arr[N];

void solve(){
  int n;
  cin >> n;
  int total = 0;
  for(int i = 0; i < n; i++) cin >> arr[i], total ^= arr[i];
  for(int i = 0; i < n; i++){
    cout << (total ^ arr[i]) << " ";
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 4376
#include <bits/stdc++.h>
#define REP(i, n) REPI(i, 0, n)
#define REPI(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)

#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vector{
    double x, y;
};
using namespace std;

int main()
{
    char str;

    cin >> str;
    if (isupper(str))
    {
        cout << "A" << endl;
    } else
    {
        cout << "a" << endl;
    }
    

    return 0;
}


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

const int _ = 3e5 + 7 , MOD = 1e9 + 7;
int N , dp[_][4][3]; char str[_];

int main(){
	scanf("%s" , str + 1); N = strlen(str + 1);
	dp[0][0][0] = 1;
	for(int i = 1 ; i <= N ; ++i){
		if(str[i] != '1')
			for(int j = 0 ; j <= 3 ; ++j)
				for(int k = 0 ; k < 3 ; ++k){
					if(dp[i - 1][j][k])
						dp[i][j][k == 2 ? 1 : k + 1] = (dp[i][j][k == 2 ? 1 : k + 1] + dp[i - 1][j][k]) % MOD;
				}
		if(str[i] != '0')
			for(int j = 0 ; j <= 3 ; ++j)
				for(int k = 0 ; k < 3 ; ++k)
					if(dp[i - 1][j][k])
						dp[i][min(j + (k == 0) , 3)][max(k - 1 , 0)] = (dp[i][min(j + (k == 0) , 3)][max(k - 1 , 0)] + dp[i - 1][j][k]) % MOD;
	}
	int sum = 0;
	for(int i = 0 ; i <= 3 ; ++i)
		for(int j = 0 ; j < i ; ++j)
			sum = (sum + dp[N][i][j]) % MOD;
	cout << sum; return 0;
}

Measured memory_bytes: 14592
/*
 * 競技プログラミング用テンプレート
 * by yuma140902
 * 2020/06/01
 * ver 0.3.1
 */
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef tuple<int, int> ii;
typedef tuple<int, int, int> iii;
const int INF = 900000;
const ll INFL = 9000000;

#define vi vector<int>
#define vii vector<vector<int> >
#define vi_def(n) vector<int>((n))
#define vii_def(n,m) vector<vector<int> >((n), vector<int>((m)))
#define vi_def_dflt(n, def) vector<int>((n), (def))
#define vii_def_dflt(n, m, def) vector<vector<int> >((n), vector<int>((m), (def)))

#define rep(i, n) for(int i=0; i < (n); ++i)
#define per(i, n) for(int i=(n)-1; i >= 0; --i)
#define range(i, begin, end) for(int i=(begin); i < (end); ++i)

#define ALL(vec) vec.begin(), vec.end()

#ifdef DBG_FLAG
#define pdbg(msg) cout << (msg)
#define dbg if(true)
#else
#define pdbg(msg) ;
#define dbg if(false)
#endif

int f(int x);

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

  double x = (double)N / 1.08;
  int X = floor(x);

  dbg{
    printf("N: %d\n", N);
    printf("x: %f\n", x);
  }

  if(x > 0){
    int tmp;
    while((tmp = f(X)) <= 0){
      if(tmp == 0){
        printf("%d\n", X);
        return 0;
      }
      ++X;
    }
  }
  printf(":(\n");
}

int f(int x){
  int n = floor((double)x * 1.08);
  if(n<N) return -1;
  else if(n==N) return 0;
  else return 1;
}

Measured memory_bytes: 384
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
bool p[233];
char s[1001];
int main()
{
	scanf("%s",s);
	for(int i=0;i<strlen(s);++i)
		p[s[i]]=1;
	puts(((p['N']^p['S'])|(p['E']^p['W']))?"No":"Yes");
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}
	ans := ((n - 1) + (k - 2)) / (k - 1)
	fmt.Println(ans)
}


Measured memory_bytes: 6300
import math
def solve():
  N = int(raw_input())
  yaks = []
  for n in range(1, int(math.sqrt(N)) + 1) :
    if(N % n == 0): yaks.append(n)
  #print yaks
  mind = 999
  for a in yaks:
    b = N / a
    #print(a, b)
    d = max(len(str(a)), len(str(b)))
    #print d
    if d < mind :
      mind = d
  return mind

if __name__ == '__main__':
  print solve()

Measured memory_bytes: 5764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll n,m;
//ld ;
// string s,t;
// char c;

int main() {
  cin >> n >> m;
  string ans = (n==m) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A , B;
    cin >> A >> B;
    int c , d , e;
    c = A + B;
    d = A - B;
    e = A * B;

    if ((c >= d) && (c >= e)) {cout <<c;}
    else if ((d >= c) && (d >= e)) {cout <<d;}
    else if ((e >= d) && (e >= c)) {cout <<e;}
    return 0;
}


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long power = 1;
        for(int i = 1; i <= N; i++){
            power = (power * i) % (long)(Math.pow(10, 9) + 7);
        } 
        System.out.println(power);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
  int N, neg=0, pos=0;// neg; 負のAiの個数 ,pos 正の．
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
      cin >> A[i];
      if(A[i]<0) neg++;
      else if(A[i]>0) pos++;
  }
  sort(A.begin(), A.end());

  vector<int> x(N-1), y(N-1);
  int start = 0;
  int tmp = 0;

  if(neg==N) { // 全て負の時
    x[0] = A[N-1]; 
    y[0] = A[N-2];
    tmp = x[0] - y[0];
    for(int i=1; i<N-1; i++) {
        x[i] = tmp;
        y[i] = A[N-i-2];
        tmp = x[i] - y[i];
    }
  } else if(pos==N) { // 全て正の時
    x[0] = A[0];
    y[0] = A[1];
    tmp = x[0] - y[0];
  
    for(int i=1; i<N-2; i++){ // small - big
      x[i] = tmp;
      y[i] = A[i+1];
      tmp = x[i] - y[i];
    }
    // 最後の一回は A[N-1] - tmp
    x[N-2] = A[N-1];
    y[N-2] = tmp;
    tmp = x[N-2] - y[N-2];
  }
  else { // 正，負がともにN個未満
    // 負の数字が1個になるまでA[N-1]から 0以下の数字を引く
    // 負の数字が0個のとき，正の数字がN個未満なので，0が1個以上のこる．
    int i = 0;
    for(; i<neg-1; i++) {
      x[i] = A[N-1];
      y[i] = A[i];
      A[N-1] = x[i] - y[i];
    } 
    if(i<N-2) {
      x[i] = A[i];
      y[i] = A[i+1];
      tmp = x[i] - y[i];
      i++;
      for(; i<N-2; i++) {
        x[i] = tmp;
        y[i] = A[i+1];
        tmp = x[i] - y[i];
      }
      // 最後の1回は  A[N-1] - tmp
      x[N-2] = A[N-1];
      y[N-2] = tmp;
      tmp = x[N-2] - y[N-2];
    }
    else { // i == N-2
      x[N-2] = A[N-1];
      y[N-2] = A[N-2];
      tmp = x[N-2] - y[N-2];
    }
  }
  
  cout << tmp << endl; // tmp = M 
  rep(i, N-1) {
      cout << x[i] << ' ' << y[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <stack>
#include <cstdlib>
using namespace std;

int _stoi(string s) {
    return atoi(s.c_str());
}

int popValue(stack<int> *S) {
    int retVal = S->top();
    S->pop();
    return retVal;
}

int main(int argc, const char * argv[]) {
    stack<int> S;
    string s;
    
    while(cin >> s){
        if (s[0] == '+') {
            S.push(popValue(&S) + popValue(&S));
        } else if (s[0] == '-') {
            S.push(popValue(&S) * -1);
            S.push(popValue(&S) + popValue(&S));
        } else if (s[0] == '*') {
            S.push(popValue(&S) * popValue(&S));
        } else {
            S.push(_stoi(s));
        }
    }

    cout << S.top() << endl;
    
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll ans = 0;
    if(x == 1){
        cout << 1 << endl;
        return 0;
    }
    for (ll b = 1; b <= x / 2 + 1; b++)
    {
        for (ll p = 2; p <= x / 2 + 1; p++)
        {
            ll tmp = pow(b, p);
            if(tmp <= x){
                ans = max(ans, tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define task "F"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 5e3 + 2, NN = 202;
int n, m, b[N][NN], mx[NN][N][13];
ll ans, a[N];
int queryMax(int j, int l, int r)
{
    int k = 31 - __builtin_clz(r - l + 1);
    return max(mx[j][l][k], mx[j][r - (1 << k) + 1][k]);
}
ll calInterval(int l, int r)
{
    ll res = 0;
    rep(j, 1, m) res += queryMax(j, l, r);
    return res - (a[r - 1] - a[l - 1]);
}
void cal(int l, int r, int optl, int optr)
{
    if (l > r) return;
    int mid = (l + r) >> 1, opt = optl;
    ll mxx = 0;
    rep(i, optl, min(mid, optr))
    {
        ll tmp = calInterval(i, mid);
        if (mxx < tmp)
        {
            mxx = tmp;
            opt = i;
        }
    }
    ans = max(ans, mxx);
    cal(l, mid - 1, optl, opt);
    cal(mid + 1, r, opt, optr);
}
int main()
{
#ifdef HynDuf
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cin >> n >> m;
    rep(i, 1, n - 1)
    {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    rep(i, 1, n) rep(j, 1, m) cin >> b[i][j];

    rep(j, 1, m) rep(i, 1, n) mx[j][i][0] = b[i][j];
    rep(k, 1, m) rep(i, 1, 12) for (int j = 1; j + (1 << i) - 1 <= n; j++) mx[k][j][i] = max(mx[k][j][i - 1], mx[k][j + (1 << (i - 1))][i - 1]);
    cal(1, n, 1, n);
    cout << ans;
    return 0;
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

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

    if (a >= b) {
        cout << "delicious" << endl;
    } else {
        if (b - a <= x) {
            cout << "safe" << endl;
        } else {
            cout << "dangerous" << endl;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>

using namespace std;

vector<int> ansbunsi;
vector<int>ansbunbo;
int main(){
	while(true){
		string str;
		cin >> str;
		if(str == "#") break;
		
		reverse(str.begin(),str.end());
		
		int bunbo = 1,bunsi = 0;
		int cur = 0;
		
		if(str[cur] == 'h'){
			bunsi = 0;
			cur += 5;
		}else{
			bunsi = 90;
			cur += 4;
		}
		
		while(cur < str.size()){
			bunbo *= 2;
			if(str[cur] == 'h'){
				bunsi = max(0,bunsi*2 - 90);
				cur += 5;
			}else{
				bunsi = min(bunbo*90,bunsi*2 + 90);
				cur += 4;
			}
		}
		
		while(bunsi % 2 == 0 && bunsi != 0 && bunbo % 2 == 0){
			bunsi /= 2;
			bunbo /= 2;
		}
		
		ansbunsi.push_back(bunsi);
		ansbunbo.push_back(bunbo);
	}
	
	for(int i = 0;i < ansbunsi.size();i++){
		if(ansbunbo[i] == 1){
			cout << ansbunsi[i] << endl;
		}else{
			cout << ansbunsi[i] << "/" << ansbunbo[i] << endl; 
		}
	}
	
	return 0;
}


Measured memory_bytes: 3048
H, W = map(int, input().split())
M = [input() for i in range(H)]
dp = [[0 for i in range(W)] for j in range(H)]
dp[0][0] = 1

for i in range(H):
  for j in range(W):
    if i+1 < H and M[i+1][j] == ".":
      dp[i+1][j] = dp[i][j]
    if j+1 < W and M[i][j+1] == ".":
      dp[i][j+1] += dp[i][j]

print(dp[H-1][W-1] % (10**9+7))


Measured memory_bytes: 158436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

bool a[9][9],vis[9];
ll ans,n,m;

void dep(ll now ,ll cnt){
	if(cnt==n){
		ans++;
		return;
	}
	for(int i=0;i<n;i++){
		if(a[now][i]==0){
			continue;
		}
		if(vis[i]==1){
			continue;
		}
		vis[i]=1;cnt++;
		dep(i,cnt);
		vis[i]=0;cnt--;
	}
}

int main() {
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		l--;r--;
		a[l][r]=a[r][l]=1;
	}
	vis[0]=1;
	dep(0,1);
	cout <<ans;
}

Measured memory_bytes: 256
import sys
from collections import ChainMap
input()
rp = sys.stdin.readlines()
cm = ChainMap()

for i in rp:
    if i[0] == 'i':
        cm[i[7:]] = 0
    else:
        if i[5:] in cm:
            print('yes')
        else:
            print('no')

Measured memory_bytes: 112472
//package atcoder.beginner_171;

import java.io.*;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {

    public static void main (String[] args) throws Exception {

        String s = "2\n" +
                "1 2\n" +
                "3\n" +
                "1 100\n" +
                "2 100\n" +
                "100 1000";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int N=nin();

        long sum=0;
        HashMap<Integer, Long> map = new HashMap<>();

        rl();
        for (int i=0; i<N; ++i) {
            int v=nin();
            if (map.containsKey(v)) {
                map.put(v, map.get(v)+1);
            } else {
                map.put(v,1l);
            }
            sum+=v;
        }

        rl(); int Q=nin();
        for (int i=0; i<Q; ++i) {
            rl(); int B=nin(), C=nin();
            if (map.containsKey(B)) {
                long D = map.remove(B);

                sum -= (D * B);
                sum += (D * C);
                if (map.containsKey(C)) {
                    long _D = map.get(C);
                    map.put(C, D + _D);
                } else {
                    map.put(C, D);
                }
            }
            bw.write(Long.toString(sum));
            bw.newLine();
        }

        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
int Add(int x, int y, int mod) {
    x += y;
    return x < mod ? x : x - mod;
}

int Sub(int x, int y, int mod) {
    x -= y;
    return x >= 0 ? x : x + mod;
}

int Mul(int x, int y, int mod) {
    return int(1LL * x * y % mod);
}

int FastPow(int x, int p, int mod) {
    int res = 1;
    while (p > 0) {
        if (p & 1) {
            res = Mul(res, x, mod);
        }
        p >>= 1;
        x = Mul(x, x, mod);
    }
    return res;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    string s;
    cin >> n >> s;
    reverse(all(s));
    int cnt1 = count(all(s), '1');
    int val1 = 0;
    int val2 = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '1') {
            if (cnt1 > 1) {
                val1 = Add(val1, FastPow(2, i, cnt1 - 1), cnt1 - 1);
            }
            val2 = Add(val2, FastPow(2, i, cnt1 + 1), cnt1 + 1);
        }
    }
    vector<int> ans(n);
    loop(n) {
        if (s[i] == '0') {
            int cur = Add(val2, FastPow(2, i, cnt1 + 1), cnt1 + 1);
            ++ans[i];
            while (cur > 0) {
                cur %= __builtin_popcount(cur);
                ++ans[i];
            }
        } else if (cnt1 > 1) {
            int cur = Sub(val1, FastPow(2, i, cnt1 - 1), cnt1 - 1);
            ++ans[i];
            while (cur > 0) {
                cur %= __builtin_popcount(cur);
                ++ans[i];
            }
        }
    }
    reverse(all(ans));
    outarr(all(ans), endl);

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    map<ll,ll> mp;
    ll n;cin>>n;
    for(ll i=0,x;i<n;i++)cin>>x,mp[x]++;
    ll ans = 0;
    for(auto &ele:mp){
        if(ele.second >= ele.first)ans+=ele.second-ele.first;
        else ans+=ele.second;
    }
    cout<<ans;
}




Measured memory_bytes: 6272