akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

template <typename T>
class BIT
{
  private:
    vector<T> array;
    int N;

  public:
    BIT(int size) : array(size + 1, 0), N(size) {}

    T sum(int i)
    {
        T sum = 0;
        while (i > 0)
        {
            sum += array[i];
            i -= i & -i;
        }

        return sum;
    }

    T sum(int l, int r)
    {
        T res_l = sum(l - 1);
        T res_r = sum(r);

        return res_r - res_l;
    }

    void add(int i, T x)
    {
        while (i <= N)
        {
            array[i] += x;
            i += i & -i;
        }
    }

    int lower_bound(int w)
    {
        if (w <= 0)
        {
            return 0;
        }        

        int init = 1;
        while(init < N)
        {
            init *= 2;
        }

        int x = 0;
        for(int k = init; k > 0; k /= 2)
        {
            if(x + k <= N && array[x + k] < w)
            {
                w -= array[x + k];
                x += k;
            }
        }
        
        return x + 1;
    }
};

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

    int N, Q;
    cin >> N >> Q;
    BIT<int> bit(N);

    REP(i, Q)
    {
        int com, x, y;
        cin >> com >> x >> y;

        if(com == 0)
        {
            bit.add(x, y);
        }
        else
        {
            Cout(bit.sum(x, y));
        }
    }    

    return 0;
}


Measured memory_bytes: 3340
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	int64_t ans = 0;
	int64_t v = -1;
	FOR_LT(i, 0, n) {
		int64_t a; cin >> a;
		ans += max(v - a, (int64_t)0);
		v = max(v, a);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
char ma[7][7];
ll h,w,k;
ll ran(ll cn)
{
	ll a[6]={0},b[6]={0};
	for(ll i=0;i<h;i++)
	{
		if((1<<i)&cn) a[i]=1;
	}
	for(ll i=0;i<w;i++)
	{
		if((1<<(i+h))&cn) b[i]=1;
	}
	bool m[7][7];
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			if(ma[i][j]=='.') m[i][j]=false;
			else m[i][j]=true;
		}
	}
	for(ll i=0;i<h;i++)
	{
		if(a[i])
		{
			for(ll j=0;j<w;j++) m[i][j]=false;
		}
	}
	for(ll i=0;i<w;i++)
	{
		if(b[i])
		{
			for(ll j=0;j<h;j++) m[j][i]=false;
		}
	}
	ll sum=0;
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++) sum+=m[i][j];
	}
	if(sum==k) return 1;
	else return 0;
}
int main(void)
{
	scanf("%lld%lld%lld",&h,&w,&k);
	for(ll i=0;i<h;i++)
	{
		scanf(" %s",ma[i]);
	}
	ll ans=0;
	for(ll i=0;i<(1<<(h+w));i++)
	{
		ans+=ran(i);
	}
	printf("%lld",ans);
}

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

using ll = long long;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (ll i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (ll i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

template<typename T> using pop_max = std::priority_queue<T>;
template<typename T> using pop_min = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T> void LOG(const T& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T> void LOG(const vector<vector<T>>& a) { for (const auto& x : a) LOG(x); }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; }
ll gcd(ll a, ll b) { while (b != 0) { ll t = b; b = a % b; a = t; } return a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll gcd(const vector<ll>& v) { return accumulate(v.begin(), v.end(), 1LL, static_cast<ll(*)(ll, ll)>(gcd)); }
ll lcm(const vector<ll>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<ll(*)(ll, ll)>(lcm)); }
ll pow(ll x, ll y, ll z) { ll a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
ll inv(ll x, ll m) { return pow(x, m - 2, m); }

template<typename T> bool chmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<typename T> bool chmin(T& x, const T& y) { return x > y ? x = y, true : false; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_cpp;

const ll INF = inf<ll>;
using P = pair<ll, ll>;
//const ll M = 1000000007;
const ll M = 998244353;
signed main() {
    ll n;
    cin >> n;
    vector<P> xd(n);
    cin >> xd;
    sort(xd.begin(), xd.end());
    stack<P> st;
    st.push({xd[n - 1].first, 2});
    for (ll i = n - 2; i >= 0; i--) {
        ll s = 1;
        while (st.size()) {
            auto a = st.top();
            if (a.first < xd[i].first + xd[i].second) {
                s = (s * a.second) % M;
                st.pop();
            } else {
                break;
            }
        }
        s += 1;
        st.push({xd[i].first, s});
    }
    ll ans = 1;
    while (st.size()) {
        ans = (ans * st.top().second) % M;
        st.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdio>
#include <climits>
using namespace std;
#define rep(i,n) for(LL i=0;i<n;i++)
#define all(v)	(v).begin(),(v).end()
#define MOD  1000000007
const int INF = INT_MAX;
typedef long long LL;
int five[20001];
int main(){
	int n;
	
	int i = 5;
	while (i < 20001){
		for (int j = 1; j*i < 20001; j++){
			five[j*i]++;
		}
		i *= 5;
	}
	while (cin >> n){
		if (n == 0) break;
		int ans = 0;
		for (int j = 1; j <= n; j++){
			ans += five[j];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
n,A,B,C=map(int,input().split())

l=[int(input()) for _ in range(n)]



def dfs(count,a,b,c):
    if count==n:
        if min(a,b,c)>0:
            return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:
            return 10**9+1
    x = dfs(count+1, a, b, c)
    y = dfs(count+1, a+l[count], b, c)+10
    z = dfs(count+1, a, b+l[count], c)+10
    w = dfs(count+1, a, b, c+l[count])+10
    return min(x,y,z,w)



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

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

using namespace std;

int main(){
 int n;
  cin >> n;
 string a,b,c;
  cin >> a >> b >> c;
  
 long res=0;
  
  for(int i=0;i<n;i++){
   if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i]) res+=2;
   else if((a[i]==b[i]&&b[i]!=c[i])||(b[i]==c[i]&&c[i]!=a[i])||(c[i]==a[i]&&a[i]!=b[i])) res+=1;
  
  }
  
  
  cout << res << endl;
}

Measured memory_bytes: 256
def solve(c, sushis):
    cw_maxs, cw_rets = create_accs(sushis, c, True)
    ccw_maxs, ccw_rets = create_accs(reversed(sushis), c, False)
    cw_max = cw_maxs[-1]
    ccw_max = ccw_maxs[-1]
    cw_ccw_max = turn_max(cw_rets, ccw_maxs)
    ccw_cw_max = turn_max(ccw_rets, cw_maxs)
    return max(cw_max, ccw_max, cw_ccw_max, ccw_cw_max)


def turn_max(rets, maxs):
    m = 0
    for i, r in enumerate(rets):
        ind = len(maxs) - 2 - i
        add = maxs[ind] if ind >= 0 else 0
        v = r + add
        if m < v:
            m = v
    return m


def create_accs(sushis, c, cw):
    maxs, vs_ret = [], []
    v_sum, v_max = 0, 0
    for d, v in sushis:
        v_sum += v
        dist = d if cw else c - d
        v_cur = v_sum - dist
        if v_max < v_cur:
            v_max = v_cur
        maxs.append(v_max)
        vs_ret.append(v_sum - dist*2)
    return maxs, vs_ret


n, c = map(int, input().split())
sushis = []
for _ in range(n):
    sushis.append([int(x) for x in input().split()])
print(solve(c, sushis))


Measured memory_bytes: 37064
#include <stdio.h>
#include <math.h>

int main(){
	
	int n;
	scanf("%d", &n);
	int x[n],y[n];
	for(int i=0;i<n;i++)
		scanf("%d",&x[i]);
	for(int i=0;i<n;i++)
		scanf("%d",&y[i]);
		
	double p1=0;
	double p2=0;
	double p3=0;
	double p_infinity=-1;
	for(int i=0;i<n;i++){
		p1+=abs(x[i]-y[i]);
		p2+=((x[i]-y[i])*(x[i]-y[i]));
		p3+=abs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
	}
	p2 = pow(p2, 0.5);
	p3 = pow(p3, 0.333333333333333333333333333333333);
	printf("%.8lf\n%.8lf\n%.8lf\n%.8lf\n",p1, p2, p3, p_infinity);
	
	
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(n) begin(n), end(n)
#define dump(x) cerr << #x << " = " << x << endl
#define pb push_back

double a[510];
int n;

double solve(){
    vector<double> x;
    x.pb(a[0]);
    for(int i = 1; i < n; i++){
        double leftmost = a[i];
        rep(j,i){
            double p = a[i]+a[j];
            double q = a[i]-a[j];
            double dx = sqrt(p*p - q*q);
            // dump(dx);
            leftmost = max(leftmost, dx + x[j]);
        }
        x.push_back(leftmost);
    }
    double res = 0;
    rep(i,n){
        res = max(res, x[i]+a[i]);
    }
    return res;
}

int main(){
    while(cin >> n){
        rep(i,n) cin >> a[i];
        printf("%.10lf\n", solve());
    }
}

Measured memory_bytes: 3352
n = int(input())
A = list(map(int, input().split()))

def countingSort(A, B, k):
    C = [0] * k
    for j in range(0, n):
        C[A[j]]+=1

    for i in range(1, k):
        C[i] = C[i] + C[i - 1]

    for j in range(0, n)[::-1]:
        B[C[A[j]] - 1] = A[j]
        C[A[j]]-=1
    return B
        
print(' '.join(map(str, countingSort(A, [0] * n, 10000))))


Measured memory_bytes: 231272
#include <stdio.h>
#include <stdlib.h>

#define MAX_NUM_STACK_VALUES 100
#define STR_MAX_LENGTH 100

/*
 * Stack
 */

typedef struct {
    int top; // index of top
    int values[MAX_NUM_STACK_VALUES];
} Stack;

void printStack(Stack S) {
    for (int i = 1; i <= S.top; i++)
        printf("%d ", S.values[i]);
    printf("\n");
};

void push(Stack * p_stack, int value) {
    p_stack->top = p_stack->top + 1;
    p_stack->values[p_stack->top] = value;
};

int isEmpty(Stack stack) {
    return (stack.top == 0);
};

int pop(Stack * p_stack) {
    if (!isEmpty(*p_stack))
        p_stack->top = p_stack->top - 1;
    
    return p_stack->values[p_stack->top + 1];
};




int main(int argc, char** argv) {
    // init Stack
    Stack S;
    S.top = 0;
    
    // char
    char str[STR_MAX_LENGTH];
    int value, a, b;
    
    while (scanf("%s ", &str) != EOF) {
//        printf("scanned:%s\n",str);
        switch(str[0]) {
            case '+':
                b = pop(&S);
                a = pop(&S);
                value = a + b;
//                printf("%d+%d=%d\n",a,b,value);
                break;
            case '-':
                b = pop(&S);
                a = pop(&S);
                value = a - b;
//                printf("%d-%d=%d\n",a,b,value);
                break;
            case '*':
                b = pop(&S);
                a = pop(&S);
                value = a * b;
//                printf("%d*%d=%d\n",a,b,value);
                break;
            default:
                value = atoi(str);
        }
        push(&S, value);
//        printStack(S);
    }
    printf("%d\n", pop(&S));
    

    return (EXIT_SUCCESS);
}




Measured memory_bytes: 2088
R, C, K = map(int, input().split())
goods = [[0] * C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    goods[r-1][c-1] = v

dp = [[[0] * C for _ in range(4)] for _ in range(R)]
dp[0][1][0] = goods[0][0]
for i in range(R):
    for j in range(4):
        for k in range(C):
            if i < R - 1:
                dp[i+1][0][k] = max(dp[i+1][0][k], dp[i][j][k])
                dp[i+1][1][k] = max(dp[i+1][1][k], dp[i][j][k] + goods[i+1][k])
        
            if k < C - 1:
                dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k])
                if j < 3:
                    dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + goods[i][k+1])

res = 0
for i in range(4):
    res = max(res, dp[R-1][i][C-1])
print(res)

Measured memory_bytes: 430320
#include<bits/stdc++.h>
using namespace std;
int a[100];
int main()
{
	int d,n,x,s=0,i,j;
	scanf("%d\n%d %d",&n,&d,&x);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=1;i<=d;i++)
	{
		for(j=0;j<n;j++)
		{
			if((i-1)%a[j]==0)
			{
				s++;
			}
		}
	}
	printf("%d",s+x);
	return 0;
}

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

int64_t dp[101][101010];

int main() {
	int64_t n, W;
	cin >> n >> W;
	vector< int64_t > w(n), v(n);
	for (int i=0; i<n; ++i) cin >> w[i] >> v[i];

	for (int ni=0; ni<n; ++ni) {
		for (int wi=0; wi<=W; ++wi) {
			dp[ni+1][wi] = max(dp[ni][wi], dp[ni+1][wi]);
			if (wi+w[ni] > W) continue;
			dp[ni+1][wi+w[ni]] = max(dp[ni+1][wi+w[ni]], dp[ni][wi] + v[ni]);
		}
	}

	int64_t ans = 0;
	for (int i=0; i<=W; ++i) {
		ans = max(ans, dp[n][i]);
		
	}
	cout << ans << endl;
	/*
	for (int i=0; i<=n; ++i) {
		for (int wi=0; wi<=W; ++wi){
			cout << dp[i][wi] << " ";
		}
		cout << endl;
	}
	*/
  return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
    ll N, L; cin >> N >> L;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    sort(ALL(S));

    string ans = "";
    rep(i, N) ans += S[i];
    cout << ans << endl;
}

Measured memory_bytes: 3620
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
int n,first[maxn],nxt[maxn<<1],to[maxn<<1],e;
void AddEdge(int u,int v) {
	to[++e]=v;nxt[e]=first[u];first[u]=e;
	to[++e]=u;nxt[e]=first[v];first[v]=e;
}
int dfs(int x,int fa) {
	int res=0;
	for(int i=first[x];i;i=nxt[i]) if(to[i]!=fa) res^=dfs(to[i],x)+1;
	return res;
}
int main() {
	n=read();
	rep(i,2,n) AddEdge(read(),read());
	puts(dfs(1,0)?"Alice":"Bob");
	return 0;
}


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

int main() {
  int a,b;
  cin>>a>>b;
  int x=10000;
  int c,d;
  
  for(int i=0;i<a;i++){
    cin>>c>>d;
    if(d<=b){
      if(c<=x){
        x=c;
      }
    }
  }
  
  if(x==10000){
    cout<<"TLE"<<endl;
  }
  else{
    cout<<x<<endl;
  }
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

int main(){
    llong N;
    string S;
    llong temp=0;
    llong maxv=INF*-1;
    cin >> N >> S;
    for(int i=0; i<N; i++){
        if(S[i]=='I'){
            temp = temp + 1;
        }else{
            temp = temp - 1;
        }
        maxv = max(maxv, temp);
    }
    if(maxv<=0){
        cout << 0 << endl;
        exit(0);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;
vector<int> dx = {1,0};
vector<int> dy = {0,1};

int h,w;
int pass = 0;
void dfs(vector<string> s, int nx, int ny) {
    if(nx > w -1 || ny > h -1) return;
    if(s.at(ny).at(nx) == '.') return;
    
    s.at(ny).at(nx) = '/';
    bool flag = 1;
    if(nx == w - 1 && ny == h-1) {
        rep(i,h){
            rep(j,w){
               if(s.at(i).at(j) == '#') {
                    flag = 0;
                    return;
              }
            } 
        }
        pass++;
        return;
    }
    
    rep(i,2) {
            dfs(s, nx+dx.at(i), ny+dy.at(i));
    }
    s.at(ny).at(nx) = '/';
    return;
}

int main(){
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s.at(i);
    dfs(s,0,0);
    if(!pass) cout << "Impossible" << endl;
    else cout << "Possible" << endl;
}

Measured memory_bytes: 3548
#include <stdio.h>

int n, s, cnt;

void dfs(int i, int sum, int n){
    if(sum==s&&!n){
        cnt++;
        return;
    }
    if(i==10||!n) return;
    dfs(i+1,sum,n);
    dfs(i+1,sum+i,n-1);
}

int main(){
	while(1){
		scanf("%d%d",&n,&s);
		if(n==0&&s==0){
			break;
		}
		cnt=0;
		dfs(0,0,n);
		printf("%d\n",cnt);
	}

    return 0;
}

Measured memory_bytes: 2612
#include <bits/stdc++.h>
 
using namespace std;
 
int const N = 1234567;
 
vector<int> edges[N];
 
int dfs(int v, int pv) {
	int sum = 0;
	int zeros = 0;
	for (int to : edges[v]) {
		if (to == pv) continue;
		int got = dfs(to, v);
		if (got == 0) {
			zeros++;
		}
		sum += got;
	}
	if (zeros > 1) {
		sum += zeros - 1;
	}
	// cout << "v = " << v << ", sum = " << sum << '\n';
	return sum;
}
 
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int v, u;
		cin >> v >> u;
		edges[v].push_back(u);
		edges[u].push_back(v);
	}
	int v = 0;
	while (v < n && edges[v].size() <= 2) ++v;
	if (v == n) {
		puts("1");
		return 0;
	}
	cout << dfs(v, -1) << '\n';
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>  // This will work only for g++ compiler.
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forab(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define pb push_back
#define fi first
#define se second
#define __builtin_popcount(x) ones(x)
#define __builtin_popcountl(x) onesl(x)
#define __builtin_popcountll(x) onesll(x)// to be used with algorithms that processes a container Eg: find(all(c
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define InputOuput freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout);
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
ll inf = 1e9 +5;
int main(){
    //InputOuput;
    Fast;

    int n, k ; cin >> n >>k;
    int last = 1;
    vll h(n+1);
    for1(i,n) cin >> h[i];
    vll dp(n+1,inf);
    dp[1] = 0;
    for1(i,n){
        forab(j,i+1, i+k){
            if(j<=n){
                dp[j] = min(dp[i] + (ll)abs(h[i]-h[j]) , dp[j]);
            }
        }
    }
    cout << dp[n]<<'\n';
    return 0;

}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    if(k==0){
        cout << n*n << endl;
        return 0;
    }
    for(ll i=1; i<=n; i++){
        if(i-1 < k) continue;
        ans += n/i * (i-1-k+1);
        ans += max(0ll , n%i - k + 1 );
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <complex>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;
namespace std {
	bool operator< (const P& a, const P& b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b){
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}

int ccw(P a, P b, P c)
{
	b -= a; c -= a;
	if(cross(b, c) > 0)   return  1;	// ½vñè
	if(cross(b, c) < 0)   return -1;	// vñè
	if(dot(b, c) < 0)     return  2;	// c--b--a Æê¼üãÉÀñÅ¢é
	if(norm(b) < norm(c)) return -2;	// a--b--c Æê¼üãÉÀñÅ¢é
	return 0;							// bÆcÍ¯ê
}

vector<P> convex_hull(vector<P>& ps)
{
	int n = ps.size(), k = 0;
	sort(ps.begin(), ps.end());
	vector<P> ch(2*n);

	for(int i=0; i<n; ch[k++] = ps[i++]){
		while(2<=k && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
	}
	for(int i=n-2, t=k+1; i>=0; ch[k++] = ps[i--]){
		while(t<=k && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
	}

	ch.resize(k-1);
	return ch;
}

int main()
{
	int n;
	while(scanf("%d", &n), n){
		vector<P> p(n);
		rep(i, n)
			scanf("%lf,%lf", &p[i].real(), &p[i].imag());

		printf("%d\n", n-convex_hull(p).size());
	}
}

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

const int MUNE_NUM = 5;

int main() {
  int menu[MUNE_NUM];
  for (int i = 0; i < MUNE_NUM; i++) {
    scanf("%d", &menu[i]);
  }

  for (int i = 0; i < MUNE_NUM; i++) {
    for (int j = i + 1; j < MUNE_NUM; j++) {
      if ((menu[i] % 10) < (menu[j] % 10)) {
        swap(menu[i], menu[j]);
      }
    }
  }

  for (int i = MUNE_NUM - 1; i >= 0; i--) {
    for (int j = i - 1; j >= 0; j--) {
      if (menu[i] % 10 == 0) {
        swap(menu[i], menu[j]);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < MUNE_NUM; i++) {
    if (ans % 10 != 0) ans = (ans / 10 + 1) * 10;
    ans += menu[i];
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    ll Z, W; cin >> Z >> W;
    ll a[2020]; rep(i, N) cin >> a[i];
    if(N == 1) {
        cout << abs(a[0] - W) << endl; return 0;
    } else {
        cout << max(abs(a[N - 1] - a[N - 2]), abs(a[N - 1] - W)) << endl;
    }
	return 0;
}

Measured memory_bytes: 256
s = input()
plus_number = len(s) - 1

total_result = 0
for bit in range(1<<plus_number):
  buffer = s[0]
  for i in range(plus_number):
    if bit & (1 << i):
      # +を挿入する
      buffer += "+"
    buffer += s[i+1]
  total_result += sum(map(int, buffer.split('+')))
print(total_result)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<algorithm>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define is insert
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define mp make_pair
#define mh make_heap
#define F first
#define S second
//#define fin cin
//#define fout cout
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(long long i=0;i<n;i++)
#define rep(i,a,b) for(long long i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
#define lb lower_bound
#define ub uper_bound
#define bs lower_bound
//#define db(i) cout<<i<<endl;
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;

vi v[500000];
bool vis[500000];
void solve()
{   
    ll n,m,a,b;
    cin>>n>>m;
    fr(m)
    {
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }

    ll ans[n+1]={0};
    ans[1]=1;

    queue<int>q;
    q.push(1);vis[1]=1;
    while(!q.empty())
    {
        ll a=q.front();
        q.pop();
        //if(vis[a])continue;
        //vis[a]=1;
        for(int i=0;i<v[a].size();i++)
        {
            ll ch=v[a][i];
            if(!vis[ch])
            {
                vis[ch]=1;
                ans[ch]=a;
                q.push(ch);
            }
        }
    }
    for(int j=1;j<=n;j++)
    {
        if(ans[j]==0)
        {
            cout<<"No"<<endl;
            return ;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)
    {
        cout<<ans[i]<<endl;
    }
}
int main()
{
    fast;
    solve();
}

Measured memory_bytes: 22252
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main() {
	int n;
	int a[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	int alice = 0;
	int bob = 0;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			alice += a[i];
		}
		else {
			bob += a[i];
		}
	}
	cout << alice - bob << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

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

  if (N < 3) {
    cout << 0 << endl;
    return 0;
  }
  
  map<char, vector<int> > counts;
  counts['R'] = vector<int>(N);
  counts['G'] = vector<int>(N);
  counts['B'] = vector<int>(N);
  
  counts['R'][N - 1] = 0;
  counts['G'][N - 1] = 0;
  counts['B'][N - 1] = 0;
  counts[S[N - 1]][N - 1]++;
    
  for (int i = N - 2; i >= 0; --i) {
    counts['R'][i] = counts['R'][i + 1];
    counts['G'][i] = counts['G'][i + 1];
    counts['B'][i] = counts['B'][i + 1];
    counts[S[i]][i]++;
  }    

  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N - 1; ++j) {
      if (S[i] != S[j]) {
	char color;
	if (S[i] != 'R' and S[j] != 'R') color = 'R';
	if (S[i] != 'G' and S[j] != 'G') color = 'G';
	if (S[i] != 'B' and S[j] != 'B') color = 'B';
	ans += counts[color][j + 1];
	int k = j + (j - i);
	if (k < N and S[k] == color) --ans;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3216
centence=input()
str1="keyence"
a=0
if "keyence" in centence:
    print("YES")
else:
    for i in range(1,len(centence)):
        if (centence.startswith(str1[:i])) and (centence.endswith(str1[i:])):
            a=1
    if a==1:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3060
#include <cstdio>

int main(){
	bool f[30];
	for(int i=0;i<30;i++){
		f[i] = false;
	}
	int s;
	for(int i=0;i<28;i++){
		scanf("%d",&s);
		f[s - 1] = true;
	}
	for(int i=0;i<30;i++){
		if(f[i] == false){
			printf("%d\n",i + 1);
		}
	}
}

Measured memory_bytes: 0
n = int(input())

lst=[]
for i in range(n):
    s, r = input().split()
    r = int(r)-1
    if   s=="H":
        r += 13
    elif s=="C":
        r += 26
    elif s=="D":
        r += 39
    lst.append(r)

for i in range(52):
    if not (i in lst):
        ss = i // 13
        if   ss==0:
            print("S", i % 13 + 1)
        elif ss==1:
            print("H", i % 13 + 1)
        elif ss==2:
            print("C", i % 13 + 1)
        else:
            print("D", i % 13 + 1) 



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
int n,a[10001];
int main(){
	//freopen("1.out","w",stdout);
	cin>>n;
	for(int x=1;x*x<n;++x){
		for(int y=1;x*x+y*y+x*y<n;++y){
			for(int z=1;x*x+y*y+z*z+x*y+y*z+x*z<=n;++z){
				++a[x*x+y*y+z*z+x*y+y*z+x*z];
			}
		}
	}
	for(int i=1;i<=n;++i)cout<<a[i]<<endl;
} 

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

class UnionFind {
public:
    vector <int> par;  // 各元の親を表す配列
    vector <int> rank; // 素集合のランクを表す配列(0 で初期化)

    UnionFind(int n) : par(n), rank(n) {
        init(n);
    }

    void init(int n) {
        par.resize(n); for (int i = 0; i < n; ++i) par[i] = i;
        rank.assign(n, 0);
    }

    int root(int x) {
        if (par[x] == x) return x;
        else return root(par[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) {
            par[x] = y;
        }
        else { // rank[y] < rank[x]
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
        return true;
    }

    bool isSame(int x, int y) { // 連結判定
        return root(x) == root(y);
    }

    int getRank(int x) {        // 素集合のランク
        return rank[root(x)];
    }
};

int main() {

    // 頂点数と辺数
    int n, m; cin >> n >> m;
    UnionFind tree(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tree.unite(a, b);
    }
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        mp[tree.root(i)]++;
    }
    int ans = 0;
    for (auto u : mp) {
        ans = max(ans, u.second);
    }
     cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13844
#include <stdio.h>
#define MAX 10000
int main()
{
	int n = 0;
	char c[MAX];
	
	int i=0,ans = 0;
	
	for(n = 0;;n++){
		c[n]=getchar();
		if(c[n] == 'g'){
			if(i > 0){
				ans += 1;
				i -= 1;
			}else i +=1;
		}
		if(c[n] == 'p'){
			if(i > 0){
				
				i -= 1;
			}else i +=1,ans-=1;
		}
		if(c[n]=='\n'){
			break;
		}
	}
	printf("%d",ans);
		

	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
     	int katamuki = scan.nextInt();
      	int seppenn = scan.nextInt();
      	int shokichi = scan.nextInt();
      	int atai = shokichi;
      	for(int i = 0; i < 10; i++){
        	System.out.println(katamuki*atai - seppenn);
          	atai = katamuki*atai - seppenn;
        }
    }

}

Measured memory_bytes: 21844
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans[ohara], a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, sum, k, q;
V g[ohara];
map<P, ll> mp;

void dfs(ll now, ll dat) {
  rep(i, Size(g[now])) {
    ll to = g[now][i];
    cnt = 1;
    if (mp[{now, to}] == 0) {
      if (cnt == dat) cnt++;
      mp[{now, to}] = cnt;
      mp[{to, now}] = cnt;
      cnt++;
      dfs(to, mp[{now, to}]);
    }
  }
}

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

  cin >> n;
  rep(i, n - 1) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    g[a[i]].p_b(b[i]);
    g[b[i]].p_b(a[i]);
  }

  queue<P> que;
  que.push({0, -1});
  while (1) {
    if (que.empty()) break;
    P now = que.front();
    que.pop();
    cnt = 1;
    rep(i, Size(g[now.fi])) {
      ll to = g[now.fi][i];
      if (mp[{now.fi, to}] == 0) {
        if (cnt == now.se) cnt++;
        mp[{now.fi, to}] = cnt;
        mp[{to, now.fi}] = cnt;
        cnt++;
        que.push({to, mp[{now.fi, to}]});
      }
    }
  }
  rep(i, n - 1) tmp = max(tmp, mp[{a[i], b[i]}]);
  Cout(tmp);
  rep(i, n - 1) cout << mp[{a[i], b[i]}] << "\n";
  return 0;
}

Measured memory_bytes: 43392
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (ll ll i = a; i < n; i++)
#define ford(i, a, n) for (ll ll i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ", a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned ll ll
#define py puts("Yes")
#define pn puts("No")
#define pY puts("YES")
#define pN puts("NO")
#define re(i, a, b) for (int i = a; i <= b; ++i)
#define de(i, a, b) for (int i = a; i >= b; --i)
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int MAXN = 2e5 + 5;
template <class t>
inline void cmin(t &a, t b) { ((a > b) && (a = b)); }
template <class t>
inline void cmax(t &a, t b) { ((a < b) && (a = b)); }
const ll V = 1e6 + 5;
const ll E = 4e6 + 5;
const ll mode = 1e9 + 7;
ll weight[E], to[E], nex[E];
ll cnt = 0;
ll n, m, dis[V];
ll head[V];
bool vis[V];
ll gcd(ll a, ll b)
{
  return b == 0 ? a : gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

ll multi(ll a, ll b, ll p)
{ //快速乘法
  ll ret = 0;
  while (b)
  {
    if (b & 1)
      ret = (ret + a) % p;
    a = (a + a) % p;
    b >>= 1;
  }
  return ret;
}

ll Pow(ll a, ll b, ll mode)
{
  ll sum = 1;
  a = a % mode;
  while (b > 0)
  {
    if (b % 2 == 1) //判断是否是奇数，是奇数的话将多出来的数事先乘如sum
      sum = sum * a % mode;
    b >>= 1;
    a = a * a % mode; // 不断的两两合并再取模，减小a和b的规模
  }
  return sum;
}
void add(ll u, ll v, ll w)
{
  cnt++;
  to[cnt] = v;
  weight[cnt] = w;
  nex[cnt] = head[u];
  head[u] = cnt;
}
void init()
{
  cnt = 0;
  memset(head, -1, sizeof(head));
}
void SPFA(ll s)
{
  memset(dis, 0x3f3f3f3f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
  dis[s] = 0;
  vis[s] = 1;
  queue<ll> q;
  q.push(s);

  while (!q.empty())
  {
    ll now = q.front();

    q.pop();
    vis[now] = 0;
    for (int i = head[now]; i != -1; i = nex[i])
    {

      if (dis[to[i]] > dis[now] + weight[i])
      {
        dis[to[i]] = dis[now] + weight[i];
        if (!vis[to[i]])
        {
          q.push(to[i]);
          vis[to[i]] = 1;
        }
      }
    }
  }
}
const ll tem = 1e18;
ll t[MAXN];
int main()
{
  int n;
  si(n);
  ll sum = 1;
  double ans = 1;
  bool flag = 0;
  re(i, 1, n) sl(t[i]);
  sort(t + 1, t + 1 + n);
  re(i, 1, n)
  {
    sum *= t[i];
    ans *= (double)t[i];
    if (ans != sum || sum > tem)
    {
      puts("-1");
      return 0;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 4436
D = int(input())
c = list(map(int, input().split()))
sdi = [list(map(int, input().split())) for i in range(D)]


lastdi = [0 for i in range(26)]
ans_c = []

d = 0
while True:
  if d == D:
    break
  if d > D - 2:
    day_s = sdi[d]
    
    sloss = [day_s[i] + c[i]*(d - lastdi[i]) for i in range(26) ]
    ans = sloss.index(max(sloss))
    ans_c.append( ans+1 )
    
    lastdi[ans] = d
    d += 1
    
  else:
    
    a = [sdi[d][i] + sdi[d+1][i2] - sum([c[k]*( 2*d-lastdi[k]+1) for k in range(26) if (k!=i) & (k!=i2) ] ) -c[i] -c[i2]*(d-lastdi[i2]) for i in range(26) for i2 in range(26) ]
    idx = a.index(max(a))
    best_i2 = idx % 26 + 1
    best_i1 = (idx // 26) % 26 + 1
    
    ans_c.append(best_i1)
    ans_c.append(best_i2)
    lastdi[best_i1-1] = d
    lastdi[best_i2-1] = d+1
    
    d += 2

print("\n".join(str(a) for a in ans_c))

Measured memory_bytes: 9516
parseInt(x) = parse(Int, x)

function kaijou(n)
	k = 1
	for i in 1:n
		k = k*i%1000000007
	end
	k
end

function main()
	n,m = map(parseInt, split(readline()))
	if n == m
		println(kaijou(n)*kaijou(m)*2%1000000007)
	elseif abs(n-m) == 1
		println(kaijou(max(n,m))*kaijou(min(n,m))%1000000007)
	else
		println(0)
	end
end

main()

Measured memory_bytes: 169672
import itertools
n = int(input())
a = list(map(int,input().split()))
a_c = list(itertools.accumulate(a))
MOD = 10**9 + 7
cnt = 0

for i in range(n):
    temp = a[i] * (a_c[-1] - a_c[i])
    cnt += temp

print(cnt % MOD)


Measured memory_bytes: 31128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int d, n;
  cin >> d >> n;
  
  
  long long num = 1;
  for(int i=0; i<d; i++){
    num = num * 100;
  }
  
  if(n!=100){
  cout << num * n << endl;
  }
  else{
  cout << 101 * num << endl;
  }
}


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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 3, msz = 2, vsz = 5e3;

int n = 3, v[nsz + 5], w[nsz + 5], dat[nsz + 5][msz + 5];
num mxv, dp[vsz * vsz + 5], ans;

int main() {
    cin >> mxv;
    loop (j, msz) {
        cont (i, n) {
            cin >> dat[i][j];
        }
    }
    cont (i, n) {
        v[i] = dat[i][0];
        w[i] = dat[i][1];
    }
    num to = mxv;
    cont (i, to) {
        dp[i] = i;
        cont (j, n) {
            if (i < v[j])  continue;
            dp[i] = max(dp[i], dp[i - v[j]] + w[j]);
        }
        mxv = max(mxv, dp[i]);
    }
    cont (i, n) {
        v[i] = dat[i][1];
        w[i] = dat[i][0];
    }
    to = mxv;
    cont (i, to) {
        dp[i] = i;
        cont (j, n) {
            if (i < v[j])  continue;
            dp[i] = max(dp[i], dp[i - v[j]] + w[j]);
        }
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 195584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <queue>
#include <vector>

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

int main()
{
	int n=read();
	if (!(n&(n-1))) 
		puts("No");
	else
	{
		puts("Yes");
		puts("1 2");
		puts("2 3");
		cout << 3 << " " << n+1 << endl;
		cout << n+1 << " " << n+2 << endl;
		cout << n+2 << " " << n+3 << endl;
		for (int i=4;i+1<=n;i+=2)
		{
			int j=i+1;
			cout << 1 << " " << i << endl;
			cout << 1 << " " << j << endl;
			cout << i << " " << j+n << endl;
			cout << j << " " << i+n << endl;
		}
		if (n%2==0)
		{
			for (int i=4;i<=n;i++)
			{
				int j=n^i^1;
				if (j!=3 && j<n)
				{
					cout << i << " " << n << endl;
					cout << j << " " << 2*n << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;

int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n,k;cin>>n>>k;
        ll arr[n];
        for(ll i=0;i<n;i++)cin>>arr[i];
        sort(arr,arr+n);
        ll sum=0;
        for(ll i=0;i<k;i++)
        sum+=arr[i];
        cout<<sum;

}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
int main(){
    int n,m,t,a;
    int time[10100];
    memset(time,0,sizeof(time));
    cin>>n>>m>>t;
    REP(i,n){
        cin>>a;
        time[a-m]++;time[min(a+m,10010)]--;
    }
    REP(i,t)time[i+1]+=time[i];
    int ans=0;
    REP(i,t)if(time[i]==0)ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3140
i=list(map(int, input().split()))
if i[0]==i[1] and i[0]!=i[2]:
         print("Yes")
elif i[0]==i[2] and i[0]!=i[1]:
         print("Yes")
elif i[1]==i[2] and i[0]!=i[2]:
         print("Yes")   
else:
         print("No")

Measured memory_bytes: 3064
while True:
 m,f,r = map(int,input().split())
 if m == -1 and f == -1 and r == -1: break
 if m == -1 or f == -1: print('F')
 elif m+f >= 80: print('A')
 elif 65 <= m+f < 80: print('B')
 elif 50 <= m+f < 65 or (30 <= m+f < 50 and r >= 50): print('C')
 elif 30 <= m+f < 50: print('D')
 else: print('F')


Measured memory_bytes: 5596