akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};


ll dp[1001][1001];


const ll MaxN=201001;

ll f[MaxN], rf[MaxN];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    REP(i, 1, MaxN) f[i] = (f[i - 1] * i) % mod;
    REP(i, 0, MaxN) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll Com(ll n, ll k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

int main(){
    ll N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    init();
    dp[A-1][0]=1;
    REP(i,A,B+1) rep(k,N+1){
        for(ll j=0; k+j*i<=N; j++) {
            if(j==0) dp[i][k+j*i]=(dp[i][k+j*i]+dp[i-1][k])%mod;
            if(j>=C && j<=D) {
                ll ret=1;
                rep(h,j) ret=(ret*Com(N-k-h*i,i)%mod);
                ret=(ret*rf[j])%mod;
                dp[i][k+j*i]=(dp[i][k+j*i]+dp[i-1][k]*ret)%mod;
            }
        }
    }
    ll ans=0;
    /*REP(i,A-1,B+1) {
        cout<<i<<':';
        rep(j,N+1) cout<<dp[i][j]<<' ';
        cout<<endl;
    }*/
    cout<<dp[B][N]<<endl;
}

Measured memory_bytes: 11264
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

typedef long long int64;

int main() {
    int n, q; scanf("%d%d", &n, &q);
    vector<vector<int>> adj(n + 1);
    for (int i = 1; i < n; i++) {
        int f, t; scanf("%d%d", &f, &t);
        adj[f].push_back(t);
        adj[t].push_back(f);
    }
    vector<int64> sum(n + 1);
    for (int i = 0; i < q; i++) {
        int p, x;
        scanf("%d%d", &p, &x);
        sum[p] += x;
    }

    vector<bool> visited(n + 1);
    visited[1] = true;
    queue<int> qq;
    qq.push(1);
    while (!qq.empty()) {
        int now = qq.front(); qq.pop();
        for (int next : adj[now]) {
            if (!visited[next]) {
                visited[next] = true;
                sum[next] += sum[now];
                qq.push(next);
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        printf("%lld", sum[i]);
        printf(i == n ? "\n" : " ");
    }
    return 0;
}

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

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = (int)(n); i>=1; --i)
#define fored(i, a, b) for(int i = (int)(b); i >= (int)(a); --i)
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define clr(v) memset(v, 0, sizeof(v))
#define clr1(v) memset(v, 0xFF, sizeof(v))
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef vector<ld> vld;

typedef vector<i64> vi64;

template<class T> bool uax(T&a, const T& b) { if( a < b ) { a = b; return true; } return false; }
template<class T> bool uin(T&a, const T& b) { if( a > b ) { a = b; return true; } return false; }

const i64 M = 1000000000;

void solve() {
  int n;
  cin >> n;
  vector<i64> a(n);
  forn(i, n) cin >> a[i];
  unordered_map<i64, pair<i64, int> > M;
  unordered_map<i64, int> S;
  for(i64 x: a) S[x] += 1;
  for (const auto& e: S) {
    i64 x = e.fi;
    i64 ca = 1, cb = 1;
    // cerr << x << ": ";
    for (i64 j = 2; j * j * j <= x; ++j) {
      if (x % j == 0) {
        int i = 0;
        while (x % j == 0) { x /= j; i += 1; }
        i %= 3;
        forn(t, i) ca *= j;
        if (i > 0) forn(t, 3 - i) cb *= j;
      }
    }
    if (x > 1) {
      i64 sx = sqrtl((ld)x + 0.5);
      if (sx * sx == x) {
        ca *= x;
        cb *= sx;
      } else {
        ca *= x;
        cb *= x * x;
      }
    }
    // cerr << ca << " " << cb << '\n';
    M[ca].fi = cb;
    M[ca].se += e.se;
    M[cb].fi = ca;
  }
  int r = 0;
  for (const auto& e: M) if (e.fi != 1) {
    // cerr << e.fi << ':' << e.se.fi << ' ' << e.se.se << '\n';
    r += max(e.se.se, M[e.se.fi].se);
    // cerr << r << '\n';
  }
  r /= 2;
  r += min(1, M[1].se);
  cout << r << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed; cout.precision(15);
  cerr << fixed; cerr.precision(15);
#ifdef HOME
  freopen("input.txt", "r", stdin);
#endif
  solve();
  return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  string s, t;
  cin >> n >> s >> t;
  rep(i, 2*n) {
    if(i%2==0) cout << s[i/2];
    else cout << t[i/2];
  }
  cout << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
    double a,b,c,p=3.14159265;
    cin >>a >>b >>c;
    printf("%.5f\n",a*b*sin(c*p/180)/2);
    printf("%.5f\n",sqrt(a*a+b*b-2*a*b*cos(c*p/180))+a+b);
    printf("%.5f\n",b*sin(c*p/180));
    return 0;
}


Measured memory_bytes: 3376
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vl T(N);
    ll sum=0;
    rep(i,N){
        cin >> T[i];
        sum+=T[i];
    }
    int M;
    cin >> M;
    rep(i,M){
        ll p,x;
        cin >> p >> x;
        p--;
        ll res=sum;
        res+=x;
        res-=T[p];
        cout << res << endl;
    }
}

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;



int main(void) {
    LL N, D;
    int res=0;
    std::cin >> N >> D;

    for(int i=0;i<N;i++){
        LL X, Y;
        std::cin >> X >> Y;
        if(X*X+Y*Y<=D*D) res++;
    }
    std::cout << res << std::endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <set>

using namespace std;

bool solve(bool first) {
    int N;
    if(!(cin >> N)) return false;
    set<string> s;
    for(int i = 0; i < N; ++i) {
        string cmd, str;
        cin >> cmd >> str;
        if(cmd == "insert") {
            s.insert(str);
        } else {
            cout << (s.count(str) ? "yes" : "no") << endl;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    while(solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 27056
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    ll N , M;
    cin >> N >> M;
    if(N * 2 >= M){
        cout << M / 2 << endl;
    }
    else{
        cout << N + (M - N * 2) / 4 << endl;
    }
}

Measured memory_bytes: 3640
#include<stdio.h>
using namespace std;

int main() {
	int a[101];
	int i, num;
	scanf("%d",&num);
	for (i = 0; i < num; i++)
	{
		scanf("%d", &a[i]);
	}
	for (i = num-1; i > 0; i--)
	{
		printf("%d ", a[i]);
	}
	printf("%d\n", a[0]);

}


Measured memory_bytes: 2696
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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 INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin>>N>>S;
  if(N%2==0 && S.substr(0,N/2)==S.substr(N/2,N/2)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
######################################################
#                                                    #
#                                                    # 
#                                                    # 
#                                                    # 
#               Coded by Prathyaksh                  # 
#                  on 12/09/2020                     # 
#                                                    #   
#                                                    # 
#                                                    # 
#                                                    #      #                                                    # 
######################################################
#Ada matrix
import math
import collections

#referenced this link for gcd functions its just a template
#https://www.geeksforgeeks.org/program-to-find-lcm-of-two-numbers/

#lol to get rid of plagiarism
def gcd(a,b):
  if a==0:
    return b
  return gcd(b%a,a)

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

def min(a,b):
  if a<b:
    return a
  else:
    return b

def sw(a,b):
  a,b=b,a

#logic starts here
n=int(input())
#l=list(map(int,input().split()))
if n==0:
  print("1")
else:
  print("0")

Measured memory_bytes: 9460
#include<iostream>
#include<vector>
#include<string>

int main() {
	int N;
	long long int max = 1;
	long long int min = 1000000000;

	std::cin >> N;
	for (int i = 0; i < N; i++) {
		long long int a;
		std::cin >> a;
		if (a > max) {
			max = a;
		}

		if (a < min) {
			min = a;
		}
	}

	std::cout << max - min << std::endl;

	return 0;
}

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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint choose(int n, int a){
    mint x = 1, y = 1;
    rep(i, a){
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    mint ans, now1(1), now2 = choose(h+w-b-2, h-1);
    for(int i = 0; i < h-a; i++){
        ans += now1*now2;
        now1 *= b+i;
        now1 = now1/(i+1);
        now2 = now2/(h+w-b-2-i);
        now2 *= h-i-1;
    }
    cout << ans << endl;
    return 0;

    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
template <class Arg1, class... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* sep = strchr(names + 1, ',');
    cerr.write(names, sep - names) << " : " << arg1 << "  ";
    __f(sep + 1, args...);
}
 
 
const int N = 1e5 + 5;


void solve()
{
	map<string, int> mp;
	int t;
	cin >> t;
	while(t--)
	{
		string input;
		cin >> input;
		sort(all(input));
		mp[input]++;
	}
	int ret = 0;
	for(auto x : mp)
	{
		ret += (x.second * (x.second - 1)) / 2;
	}
	cout << ret << endl;
}
 
 
int32_t main()
{	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif*/
	int t = 1;
	// cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 11264
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    d = (10**8)*4
    result = 0
    for j in range(m):
        if abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) < d:
            d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
            result = j+1
    print(result)


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

int main(){
  int a[70000];
  for(int i=1; i<=100; i++){
  	for(int j=1; j<=100; j++){
      for(int k=1; k<=100; k++){
      	a[i*i+j*j+k*k+i*j+j*k+k*i]++;
      }
  	}
  }
  int n; cin >> n;
  for(int i=1; i<=n; i++) cout << a[i] << endl;
}


Measured memory_bytes: 3800
using System;
class Program
{
    static void Main()
    {
        for (int i = 0; i < 4; i++)
        {
            int[] tickets = { 6000, 4000, 3000, 2000 };
            var strs = Console.ReadLine().Split(' ');
            Console.WriteLine(tickets[Int32.Parse(strs[0]) - 1] * Int32.Parse(strs[1]));
        }
    }
}

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

using namespace std;

int main(){
	char str[100];
	char str2[100];
	int i = 0;

	cin >> str >> str2;

	while(str[i] != 0){
		if(str[i] != str2[i]){
			cout << "No";
			return 0;
		}
		i++;
	}
	cout << "Yes";

	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long fact[15100];
long long finv[15100];
long long inv[15100];
long long C(int a,int b){
	if(b<0||a<b)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
vector<int>g[5100];
long long dp[5100][5100][2];
long long dp2[5100][5100][2];
int sz[5100];
long long ks[5100];

void dfs(int a,int b){
	int n=0;
	sz[a]++;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		dfs(g[a][i],a);
		sz[a]+=sz[g[a][i]];
		n++;
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<5100;j++){
			dp2[i][j][0]=dp2[i][j][1]=0;
		}
	}
	dp2[0][0][0]=1;
	int cz=0;
	n=0;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		int ch=g[a][i];
		for(int j=0;j<=cz;j++){
			for(int k=0;k<=sz[ch];k++){
				for(int l=0;l<2;l++){
					for(int m=0;m<2;m++){
						dp2[n+1][j+k][(l+m)%2]=(dp2[n+1][j+k][(l+m)%2]+dp2[n][j][l]*dp[ch][k][m])%mod;
					}
				}
			}
		}
		cz+=sz[ch];
		n++;
	}
	for(int i=0;i<=cz;i++){
		for(int j=0;j<2;j++){
		//	if(dp2[n][i][j])printf("%d %d %d: %lld\n",a,i,j,dp2[n][i][j]);
			dp[a][i+1][j]=(dp[a][i+1][j]+dp2[n][i][j])%mod;
			if(i%2==1)dp[a][0][!j]=(dp[a][0][!j]+dp2[n][i][j]*ks[(i+1)/2])%mod;
		}
	}

}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		b/=2;
		a=a*a%mod;
	}
	return ret;
}
int main(){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<15100;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<15100;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
	for(int i=0;i<5100;i++){
		ks[i]=fact[i*2]*pw(d2,i)%mod*finv[i]%mod;
	}
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;g[p].push_back(q);g[q].push_back(p);
	}
	dfs(0,-1);
	long long ret=0;
	//printf("%lld\n",ret);
	for(int i=1;i<=a;i++){
		ret=(ret+dp[0][i][1]*ks[i/2])%mod;
		ret=(ret+mod-dp[0][i][0]*ks[i/2]%mod)%mod;
		
	}
	printf("%lld\n",(mod-ret)%mod);
}


//1234
// o o


Measured memory_bytes: 801536
#include "bits/stdc++.h"
using namespace std;
using ll = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

ll N;
string S;
ll pc;
ll x;
ll rankarr[201010];

ll f(ll n) {
  ll ans = 0;
  while (n > 0) {
    bitset<64> bs(n);
    n %= bs.count();
    ++ans;
  }
  return ans;
}

int main() {
  //
  cin >> N;
  cin >> S;
  for (auto c : S) {
    if (c == '1') {
      ++pc;
    }
  }

  ll pci = pc + 1;
  ll pce = pc;
  ll pcd = pc - 1;

  ll mod;
  if (pcd == 0) {
    mod = pci;
  } else {
   mod = pci * pcd;
  }


  ll rank = 1;
  for (int i = S.size() - 1; i >= 0; --i) {
    if (S[i] == '1') {
      x += rank;
      x %= mod;
    }
    rankarr[i] = rank;

    rank *= 2;
    rank %= mod;
  }


    for (int i = 0; i < S.size(); ++i) {
      ll xi;
      if (S[i] == '0') {
        xi = (x + rankarr[i]) % mod;
        xi %= pci;
      } else {
        xi = (x + mod - rankarr[i]) % mod;

        if (pcd == 0) {

          cout << 0 << "\n";
          continue;
        } else 
                  xi %= pcd;
      }
      cout << f(xi) + 1 << "\n";
    }

}


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

using namespace std;

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

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

    if(a + b + c >= 22)
        cout << "bust";
    else
        cout << "win";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int N;
    cin>>N;
    int V[N];
  int C[N];
 int m=0; 

  for(int i=0;i<N;i++){
    cin>>V[i];
  }
    for(int i=0;i<N;i++){
    cin>>C[i];
  }

  for(int i=0; i<N; i++){
  if(V[i]-C[i]>0)
  m=m+(V[i]-C[i]);
  }
 cout<<m<<endl;
 
return 0;
}

Measured memory_bytes: 256
import sys
import fractions

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    A.sort()

    g = A[0]

    for a in A:
        g = fractions.gcd(g, a)

    for a in A:
        if a >= K:
            if (a - K) % g == 0:
                print("POSSIBLE")
                return
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


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

int main (){
  int N;
  int A = 0;
  cin >> N ;
  int x = N;
  for(int i=0; i<8; i++){
    A += x % 10 ;
    x = x / 10 ;
  }
  if(N % A == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    
    

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

using namespace std;

int main(){
	
	
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		int p[n];
		for(int i=0;i<n;i++) cin >> p[i];
		
		sort(p,p+n);
		
		int dif,ma=10000000;
		for(int i=0;i<n-1;i++){
			dif=p[i+1]-p[i];
			ma=min(dif,ma);
		}
		cout << ma <<endl;
	}
	
	
	
	return 0;
}


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

public class Main {

	public static final int MAX = 500000;
	public static final int SENTINAL = 1000000001;
	public static int[] L = new int[MAX / 2 + 2];
	public static int[] R = new int[MAX / 2 + 2];
	public static int count = 0;

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String tmparray[] = br.readLine().split(" ");
		int s[] = new int[n];

		for(int i = 0 ; i < n ; i++){
			s[i] =Integer.parseInt(tmparray[i]);
		}

		mergeSort(s,0,n);
		StringBuffer sb = new StringBuffer();
		for(int i = 0 ; i < n ; i++){
			sb.append(s[i]);
			sb.append(" ");
		}

		System.out.println(sb.toString().trim());
		System.out.println(count);

	}

	public static void mergeSort(int[] s,int left, int right){

		if(right - left == 1){
			return;
		}
		int mid = (right + left) / 2;
		mergeSort(s,left,mid);
		mergeSort(s,mid,right);
 		merge(s,left,mid,right);
	}


	private static void merge(int[] s,int left, int mid, int right){

		int li = 0;
		int ri = 0;
		for(int i = left ; i < mid ; i++) L[li++] = s[i];
		L[li] = SENTINAL;
		for(int i = mid ; i < right ; i++) R[ri++] = s[i];
		R[ri] = SENTINAL;

		li = ri = 0;

		for(int i = left ; i < right ; i++){
			count++;
			if(L[li] < R[ri]){
				s[i] = L[li++];
			}else{
				s[i] = R[ri++];
			}
		}
	}
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(b - a) <= d && abs(c - b) <= d) {
		cout << "Yes" << endl;
	}
	else if (abs(c - a) <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
N,C,K = map(int,input().split())
T = sorted([int(input()) for x in range(N)])

ans = 0
it = 0
while it < N:
  start = T[it]
  occupancy = 0
  while it < N and occupancy < C and T[it] <= start + K:
    occupancy += 1
    it += 1
  ans += 1
print(ans)

Measured memory_bytes: 8280
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	t := getString()

	ok := true
	for i := 0; i < len(t); i++ {
		if t[0] != t[i] {
			ok = false
			break
		}
	}
	if ok {
		out(0)
		return
	}

	N := len(t)
	cnt := 1
	a := make([]byte, 0)
	a = append(a, t[N-1])
	N--
LOOP:
	for i := 0; i < len(t); i++ {
		a = append(a, t[N-1])
		//out(i, N, "-------", string(a))
		for _, v := range a {
			ok = true
			for j := 0; j < N; j++ {
				check := false
				for k := 0; k <= cnt; k++ {
					//out(j, k, string(t[k]))
					if t[j+k] == v {
						check = true
						break
					}
				}
				if check == false {
					ok = false
					break
				}
			}
			if ok == true {
				break LOOP
			}
		}
		N--
		cnt++
	}

	out(cnt)
}


Measured memory_bytes: 640
from collections import defaultdict, deque
N, M = map(int, input().split())
A = [[0] * M for _ in range(N)]
B = [[0] * M for _ in range(N)]
C = [[0] * M for _ in range(N)]

G = defaultdict(lambda: defaultdict(int))
F = defaultdict(lambda: defaultdict(int))

rows = [0] * (N * M + 1)

for i in range(N):
    A_list = list(map(int, input().split()))
    A[i] = A_list
    for a in A_list:
        G[i + 1][N + (a + M - 1) // M] += 1
        G[N + (a + M - 1) // M][i + 1] = 0



# dfs
for t1 in range(M):

    for i in range(1, N + 1):
        G[0][i] = 1
        F[0][i] = 0
        G[N + i][2 * N + 1] = 1
        F[N + i][2 * N + 1] = 0

    for t2 in range(N):
        queue = deque([0])
        searched = [0] * (2 * N + 2)
        searched[0] = 1
        parent = [0] * (2 * N + 2)

        while len(queue) > 0:
            p = queue.pop()
            for q in G[p].keys():
                if (G[p][q] > 0 or F[q][p] > 0) and searched[q] == 0:
                    parent[q] = p
                    searched[q] = 1
                    queue.append(q)
            if searched[2 * N + 1] == 1:
                break
        path = [2 * N + 1]
        while True:
            path.append(parent[path[-1]])
            if path[-1] == 0:
                break

        for i in range(len(path) - 1, 0, -1):
            p, q = path[i], path[i-1]
            if G[p][q] > 0:
                G[p][q] -= 1
                F[p][q] += 1
            elif F[q][p] > 0:
                F[q][p] -= 1
                G[q][p] += 1

    for i in range(1, N + 1):
        ji = 0
        for j in range(N + 1, 2 * N + 1):
            if F[i][j] == 1:
                ji = j
                break

        F[i][ji] -= 1
        for a in A[i - 1]:
            if N + (a + M - 1) // M == ji:
                A[i - 1].remove(a)
                B[i - 1][t1] = a
                break


for j in range(M):
    c_j = list(sorted([B[i][j] for i in range(N)]))
    for i in range(N):
        C[i][j] = c_j[i]
        
if __name__ == "__main__":
    for i in range(N):
        print(*B[i])
    for i in range(N):
        print(*C[i])


Measured memory_bytes: 59100
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
 
const int lim = 1e6 + 5;
const int Inf = 1000000007;
const long long mod = 1000000007;//998244353;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

map <long long, long long> M;
long long n, A, B, C, D;

long long f(long long a)
{
	if(M.count(a) == true)
	{
		return M[a];
	}
	long long temp1 = a % 2, temp2 = a % 3, temp3 = a % 5;
	long long te1 = (2 - temp1) % 2, te2 = (3 - temp2) % 3, te3 = (5 - temp3) % 5;
	long long ans = 1e18;
	ans = min(ans, f((a - temp1) / 2) + temp1 * D + A);
	ans = min(ans, f((a - temp2) / 3) + temp2 * D + B);
	ans = min(ans, f((a - temp3) / 5) + temp3 * D + C);
	ans = min(ans, f((a + te1) / 2) + te1 * D + A);
	ans = min(ans, f((a + te2) / 3) + te2 * D + B);
	ans = min(ans, f((a + te3) / 5) + te3 * D + C);
	if(D < 1000000000000000000 / a)
	{
		ans = min(ans, D * a);
	}
	return M[a] = ans;
}

int main()
{
	Fastio();
	int t;
	cin >> t;
	while(t--)
	{
		M.clear();
		cin >> n >> A >> B >> C >> D;
		M[1] = D;
		M[0] = 0;
		cout << f(n) << '\n';
	}	
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
ll mod=998244353;

int main(){
    std::ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    n--;
    ll ans=(n*(n+1))/2;
    cout<<ans;

    return 0;
}



Measured memory_bytes: 256
a = dict()
a['A'] = []
a['B'] = []
a['C'] = []
a['?'] = []

string = input()

for i in range(0, len(string)):
    temp = string[i]
    a[temp].append(i)
    
result = 0
dp = [0] * 4
MOD = 10**9 + 7
dp[0] = 1

for c in string:
    if c == '?':
        for i in range(3, 0, -1):
            dp[i] = dp[i]*3 + dp[i-1]
            dp[i] %= MOD
        dp[0] = dp[0]*3
        dp[0] %= MOD
    elif c == 'A':
        dp[1] += dp[0] % MOD
    elif c == 'B':
        dp[2] += dp[1] % MOD
    elif c == 'C':
        dp[3] += dp[2] % MOD
print (dp[3] % MOD)


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

using namespace std;

vector<int> adj[2000006];
int vis[2000006],mem[2000006];
vector<int> lis[1005];
int n;

bool ok(int x)
{
	//cout << x << " " << vis[x] << endl;
	if(vis[x]==1) return 0;
	if(vis[x]) return 1;
	vis[x]=1;
	int ans=1;
	for(int i:adj[x])
		ans&=ok(i);
	vis[x]=2;
	return ans;
}

int go(int x)
{
	if(mem[x]!=-1) return mem[x];
	mem[x]=1;
	for(int i:adj[x])
		mem[x]=max(mem[x],1+go(i));
	return mem[x];
}

int main()
{
	int mxid=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<n;j++)
		{
			int x;
			scanf("%d",&x);
			int mn=min(i,x),mx=max(i,x);
			mn--; mx++;
			lis[i].push_back(mn*n+mx);
			mxid=max(mxid,mn*n+mx);
		}
		for(int j=0;j+1<lis[i].size();j++)
			adj[lis[i][j]].push_back(lis[i][j+1]);
	}
	/*for(int i=0;i<=mxid;i++)
	{
		for(int j:adj[i])
			cout << i << " " << j << endl;
	}*/
	for(int i=0;i<=mxid;i++)
	{
		if(!ok(i))
		{
			cout << -1 << endl;
			return 0;
		}
	}
	memset(mem,-1,sizeof mem);
	int ans=0;

	for(int i=0;i<=mxid;i++) ans=max(ans,go(i));
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    int ans = 0;
    int total = 0;
    vi s(n);
    REP(i,n){
        cin>>s[i];
        total += s[i];
    }
    sort(ALL(s));

    if(total%10!=0){
        cout << total << endl;
        return 0;
    }

    ans = 0;
    REP(i,n){
        if(s[i]%10==0) continue; //意味がない
        
        ans = total-s[i];
        break;
    }

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

Measured memory_bytes: 256
#include <stdio.h>

void write(int A[], int n){
	int i;
	for (i = 0; i < n-1; ++i)
	{
		printf("%d ", A[i]);
	}
	printf("%d\n", A[n-1]);
}

void insertionSort(int A[], int n){
	int i,k,memo;
	for (i = 1; i < n; ++i)
	{
		memo = A[i]; 
		k = i-1;
		while(k >= 0 && A[k] > memo)
		{
			A[k+1] = A[k];
			k--;
		}
		A[k+1] = memo;

		write(A,n);
	}
}


int main()
{
	int n,A[100],memo,i,k;
	scanf("%d",&n);
	for(i = 0; i < n; ++i)
	{
		scanf("%d",&A[i]);
    }

    write(A,n);
    insertionSort(A,n);

	return 0;
}

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

def solve(a, b, c):
    X = [a, b, c]
    flag = False
    
    for i in range(1<<3):
        A = B = 0
        for j in range(3):
            if((i>>j)&1):
                A += X[j]
            else:
                B += X[j]
        if(A == B):
            flag = True
                
    print("Yes" if flag else "No")
    
if __name__ == '__main__':
    a, b, c = map(int, input().split())
    
    solve(a, b, c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mod 1000000007
#define rep(i,f,F) for(int i = f ; i < F ; i++)
#define inf 1e9+9

using namespace std;

const int maxn = 3e3 + 10;
int dp[maxn][maxn];

int main(){
	string s,d,t;
	cin >> s >> d;
	rep(i,0,s.size()+1){
		rep(j,0,d.size()+1){
			if(i == 0 or j == 0){
				dp[i][j] = 0;
			}
			else if(s[i-1] == d[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else{
				dp[i][j] = max(dp[i][j-1] , dp[i-1][j]);
			}
		}
	}
	if(dp[s.size()][d.size()] == 0){
		cout << ' ' << endl;
		return 0;
	}
	int i = s.size(), j = d.size();
    while (dp[i][j])
    {
        if (dp[i][j] == dp[i - 1][j])
            i--;
        else if (dp[i][j] == dp[i][j - 1])
            j--;
        else if (dp[i][j] > dp[i - 1][j - 1])
            i--, j--, t += s[i];
    }
    reverse(t.begin(), t.end());
    cout << t;
	
}
	



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

int main() {
  int N, A, B;
  string S;
  cin >> N >> A >> B;
  cin >> S;
  int count = 0;
  int bcount = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'a') {
      // 国内の学生
      if (A + B > count) {
        count ++;
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else if (S[i] == 'b') {
      if (A + B > count && bcount < B) {
        count ++;
        bcount++;
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
      // 海外の学生
    } else if (S[i] == 'c') {
      // 学生でない
	  cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int m = a.length();
	int n = b.length();
	for(int i=0;i<m;i++)
	{
		if(a[i]!=b[i])
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 998244353
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    string S;
    cin >> S;
    int L=S.length();
    int check[4]={};
    rep(i,L){
        if(S[i]=='N') check[0]++;
        if(S[i]=='W') check[1]++;
        if(S[i]=='S') check[2]++;
        if(S[i]=='E') check[3]++;
    }
    if(check[0]!=0 && check[1]!=0 && check[2]!=0 && check[3]!=0) cout << "Yes" << endl;
    else if(check[0]!=0 && check[1]==0 && check[2]!=0 && check[3]==0) cout << "Yes" << endl;
    else if(check[0]==0 && check[1]!=0 && check[2]==0 && check[3]!=0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  for (int i = 0; i < 20; i++) {
    if (N*i-i+1 >= M) {
      cout << i <<endl;
      break;
    }
  }
  
}


Measured memory_bytes: 256
import sys

n = input()

code_1 = ['+', '-']
code_2 = ['+', '-']
code_3 = ['+', '-']

answer = ''
flag = False
for i in range(2):
    for j in range(2):
        for k in range(2):
            sum_num = 0
            if code_1[i] == '+':
                sum_num += int(n[0]) + int(n[1])
            else:
                sum_num += int(n[0]) - int(n[1])
            if code_2[j] == '+':
                sum_num += int(n[2])
            else:
                sum_num -= int(n[2])
            if code_3[k] == '+':
                sum_num += int(n[3])
            else:
                sum_num -= int(n[3])
            if sum_num == 7:
                answer = n[0] + code_1[i] + n[1] + code_2[j] + n[2] + code_3[k] + n[3] + '=7'
                flag = True
            if flag:
                break

        if flag:
            break
    
    if flag:
        break


print(answer)



Measured memory_bytes: 3064
n,l = map(int, input().split())
a = list(map(int, input().split()))

for i in range(0,n-1):
    if a[i] + a[i+1] >= l:
        print('Possible')
        for j in range(1,i+1):
            print(j)
        for j in range(n-1,i,-1):
            print(j)
        break
else:
    print('Impossible')

Measured memory_bytes: 85876
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int first[100005];
int main()
{
	int ans = 0,num,i,n;
	scanf("%d",&n);
	first[0] = 0;
	first[n + 1] = 0;
	for(i = 1;i <= n; i++)
		scanf("%d",&first[i]);
	for(i = 0;i < n + 1; i++)
		ans += abs(first[i] - first[i + 1]);
	for(i = 1;i <= n; i++)
	{
		num = ans - abs(first[i - 1] - first[i]) - abs(first[i] - first[i + 1]) + abs(first[i - 1] - first[i + 1]);
	printf("%d\n",num);
	}
	return 0;
}




Measured memory_bytes: 1536
#include<iostream>
using namespace std;
typedef long long ll;
ll number[11];
int main(){
	int r, d, x;
	cin >> r >> d >> x;
	number[0] = x;
	for (int i = 1; i <= 10;i++){
		number[i] = r * number[i - 1] - d;
	}
	for (int i = 1; i <= 10;i++){
		cout << number[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;

#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};

#[allow(non_snake_case)]
#[allow(unused)]
fn main() {
    input! {
        S:Chars
    }

    let mut ma = 0;
    let mut cnt = 0;

    for c in S.iter() {
        if *c == 'R' {
            cnt += 1;
        } else {
            cnt = 0;
        }
        ma = max(ma, cnt);
    }

    println!("{}", ma);
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (i % 2 == 0 && a % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    A = input_number_list()
    limit = 10**18
    ans = 1
    if 0 in A:
        print(0)
    else:
        for i in A:
            ans *= i
            if ans > limit:
                print("-1")
                break
        else:
            print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 21580
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mt make_tuple
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
  int n ;
  cin >> n ;
  int a[n] , b[n] , su = 0;
  rep(i , n) cin >> a[i] >> b[i] , su += a[i];
  int ans = 0; 
  rep(i , n){
  	if(a[i] > b[i])
    	ans = max(ans , su - b[i]);
  }
  cout << ans; 
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


Measured memory_bytes: 640
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
  int a;
  cin>>a;
  cout<<a*800-200*(a/15)<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define MOD 10000000000　+　7    //10億　= 10^9になってる
#define juu 100000               //10万 10e5
#define hyaku 1000000            //100万　10e6
#define mINF -922337200085470000 //llのmax-1桁の小さい方
#define pINF 922337203600070000  //llのmax-1桁のデカい方
#define uINF 1844674407300000000 //ullのmax-1桁してる
#define pi 3.1415926535897932384
ll factor[300];
ll memory[300];
/*素朴法で計算
factorは必ずmemset(factor,0,sizeof(factor));
グローバルであるmemoryに個数を書き込む
memory配列の走査にはfactorの要素を使う*/
void primefac(ll num)
{
    int i = 0, kosuu = 0;
    while (*(factor + i) != 0)
    {
        while (num % *(factor + i) == 0)
        {
            num /= *(factor + i);
            memory[*(factor + i)] += 1;
        }
        if (num == 1)
            break;
        i++;
    }
}
/*グローバルにあるfactorに素数書き込む.個数を返すので配列は-1しろforは<*/
int elast(ll number)
{
    ll tmp = 0;
    int flag = 0;
    *factor = 2;
    for (int i = 3; i <= number; i++)
    {
        flag = 0;
        for (int j = 0; j <= tmp; j++)
        {
            if (i % (*(factor + j)) == 0)
            {
                flag = 1;
                break;
            }
        }
        if (flag)
            continue;
        tmp += 1;
        *(factor + tmp) = i;
    }
    return tmp + 2;
}
/*整数をqsortする為だけのもの*/
long long compare(const long long *a, const long long *b)
{
    if (*a < *b)
        return -1;
    else if (*a > *b)
        return 1;
    return 0;
}
/*intで収まる範囲であってくれ*/
ll nCr(int n, int r)
{
    ll val = 1;
    int i;
    if (r == 0)
        return 1;
    for (i = 0; i < n - r; i++)
    {
        val *= (n - i);
        val /= (i + 1);
    }
    return val;
}
/*intで収まる範囲であってくれ*/
ll nPr(int n, int r)
{
    ll val = 1;
    int i;
    for (i = 0; i < r; i++)
    {
        val *= (n - i);
    }
    return val;
}

void chmin(ll &a, ll b)
{
    if (a > b)
        a = b;
}
void chmax(ll &a, ll b)
{
    if (a < b)
        a = b;
}

/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これをコピペ
*/
ll mp;
vector<ll> l(8, 0);
ll N, A, B, C;

ll dfs(ll i, ll a, ll b, ll c)
{
    if (i == N)
    {
        if ((!a || !b || !c))
            return pINF;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }
    ll res = dfs(i + 1, a, b, c); //状態を変えずの段階に遷移する
    chmin(res, dfs(i + 1, a + l[i], b, c) + (a ? 10 : 0));
    chmin(res, dfs(i + 1, a, b + l[i], c) + (b ? 10 : 0));
    chmin(res, dfs(i + 1, a, b, c + l[i]) + (c ? 10 : 0));
    return res;
}

int main()
{
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}


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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main(void){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ans = min(b, d) - max(a, c);
    if(ans < 0){
        cout << 0 << "\n";
    }else{
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 3564