akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v, col, len;
} list;

void DFS(int u, list* adj[], list* memo[], int dep[], int count[], int sum[])
{
	list *p;
	for (p = memo[u]; p != NULL; p = p->next) p->len = sum[0] - sum[p->col] + p->len * count[p->col];
	for (p = adj[u]; p != NULL; p = p->next) {
		if (dep[p->v] < dep[u]) continue;
		count[p->col]++;
		sum[0] += p->len;
		sum[p->col] += p->len;
		DFS(p->v, adj, memo, dep, count, sum);
		count[p->col]--;
		sum[0] -= p->len;
		sum[p->col] -= p->len;
	}
}

int main()
{
	int i, N, Q, u, w, c, l;
	list *adj[100001] = {}, e[200001], *p;
	scanf("%d %d", &N, &Q);
	for (i = 0; i < N - 1; i++) {
		scanf("%d %d %d %d", &u, &w, &c, &l);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].col = c;
		e[i*2+1].col = c;
		e[i*2].len = l;
		e[i*2+1].len = l;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	
	int dep[100001] = {}, anc[100001][20] = {}, q[100001], head, tail;
	dep[1] = 1;
	q[0] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			if (dep[p->v] == 0) {
				dep[p->v] = dep[u] + 1;
				q[tail++] = p->v;
				for (i = 0, w = u, anc[p->v][0] = u; anc[w][i] != 0; w = anc[w][i++]) anc[p->v][i+1] = anc[w][i];
			}
		}
	}
	
	int x[100001], y[100001], s[100001], t[100001], lca[100001];
	list *memo[100001] = {}, d[300001];
	for (i = 1; i <= Q; i++) scanf("%d %d %d %d", &(x[i]), &(y[i]), &(s[i]), &(t[i]));
	for (i = Q; i >= 1; i--) {
		d[i*3-1].v = s[i];
		d[i*3-1].col = x[i];
		d[i*3-1].len = y[i];
		d[i*3-1].next = memo[s[i]];
		memo[s[i]] = &(d[i*3-1]);
		d[i*3-2].v = t[i];
		d[i*3-2].col = x[i];
		d[i*3-2].len = y[i];
		d[i*3-2].next = memo[t[i]];
		memo[t[i]] = &(d[i*3-2]);
		
		u = s[i];
		w = t[i];
		while (dep[u] > dep[w]) {
			for (l = 0; dep[anc[u][l+1]] >= dep[w]; l++);
			u = anc[u][l];
		}
		while (dep[w] > dep[u]) {
			for (l = 0; dep[anc[w][l+1]] >= dep[u]; l++);
			w = anc[w][l];
		}
		while (u != w) {
			for (l = 0; anc[u][l+1] != anc[w][l+1]; l++);
			u = anc[u][l];
			w = anc[w][l];
		}
		lca[i] = u;
		d[i*3].v = u;
		d[i*3].col = x[i];
		d[i*3].len = y[i];
		d[i*3].next = memo[u];
		memo[u] = &(d[i*3]);
	}
	
	int count[100001] = {}, sum[100001] = {};
	DFS(1, adj, memo, dep, count, sum);
	
	for (i = 1; i <= Q; i++) {
		printf("%d\n", memo[s[i]]->len + memo[t[i]]->len - memo[lca[i]]->len * 2);
		memo[s[i]] = memo[s[i]]->next;
		memo[t[i]] = memo[t[i]]->next;
		memo[lca[i]] = memo[lca[i]]->next;
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 31656
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)         cout << '>' << #x << ':' << x << endl;
#define  rep(i,n)         for(int i = 0; i < n; i++)
#define  reps(i,n)        for(int i = 1; i<=n ; i++)
#define  make_unique(v)   sort(all(v));v.erase(unique(all(v)), v.end());
#define  rot(v)           rotate(v.begin(), v.begin() + k, v.end());
#define  rmv(v,a)         v.erase(remove(v.begin(),v.end(), a), v.end());
#define  max(x,y)         ((x>y)?x:y)
#define  min(x,y)         ((x<y)?x:y)
#define  pb               push_back
#define  eb               emplace_back
#define  mp               make_pair
#define  endl             '\n'
#define  fi               first
#define  se               second
#define  ajs(a)           (a<0)?(-1*a):a
using namespace std;
typedef long long          ll;
// use count() instead of find() in sets.
const ll MOD = 1e9 + 7;
const double PI  = acos(-1.0);
const double EPS = (1e-10);
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = { -1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}


ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m ){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}




int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n ; cin>>n;

ll h[n+1];
h[0] = 0;
reps(i,n){cin>>h[i];}
ll dp[n+1];
dp[0] = 0;
dp[1] = 0;
dp[2] = abs(h[2] - h[1]);
for(ll i = 3; i<=n ; i++){
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2]));
}
cout<<dp[n];
}






Measured memory_bytes: 5200
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2 2");
            WillReturn.Add("*.");
            WillReturn.Add(".*");
            //*.
            //*.
            //.*
            //.*
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1 4");
            WillReturn.Add("***.");
            //***.
            //***.
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("9 20");
            WillReturn.Add(".....***....***.....");
            WillReturn.Add("....*...*..*...*....");
            WillReturn.Add("...*.....**.....*...");
            WillReturn.Add("...*.....*......*...");
            WillReturn.Add("....*.....*....*....");
            WillReturn.Add(".....**..*...**.....");
            WillReturn.Add(".......*..*.*.......");
            WillReturn.Add("........**.*........");
            WillReturn.Add(".........**.........");
            //.....***....***.....
            //.....***....***.....
            //....*...*..*...*....
            //....*...*..*...*....
            //...*.....**.....*...
            //...*.....**.....*...
            //...*.....*......*...
            //...*.....*......*...
            //....*.....*....*....
            //....*.....*....*....
            //.....**..*...**.....
            //.....**..*...**.....
            //.......*..*.*.......
            //.......*..*.*.......
            //........**.*........
            //........**.*........
            //.........**.........
            //.........**.........
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int H = wkArr[0];
        int W = wkArr[1];
        int UB_X = W - 1;
        int UB_Y = H - 1;

        char[,] CArr = new char[UB_X + 1, UB_Y + 1];
        for (int X = 0; X <= UB_X; X++) {
            for (int Y = 0; Y <= UB_Y; Y++) {
                CArr[X, Y] = InputList[Y + 1][X];
            }
        }

        var sb = new System.Text.StringBuilder();
        for (int Y = 0; Y <= H * 2 - 1; Y++) {
            for (int X = 0; X <= UB_X; X++) {
                sb.Append(CArr[X, Y / 2]);
            }
            sb.AppendLine();
        }
        Console.Write(sb.ToString());
    }
}


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

int dp[200001][2];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int n=s.size();
	s.insert(0," ");
	dp[1][0]=1;
	for(int i=2;i<s.size();i++){
		if(s[i]==s[i-1])
			dp[i][0]=dp[i-1][1]+1;
		else
			dp[i][0]=dp[i-1][0]+1;
		dp[i][1]=dp[i-2][0]+1;
	}
	cout<<max(dp[n][0],dp[n][1])<<endl;
}


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

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

//#define int long long //change int main to int32_t main


void solve()
{
	int n, k; cin >> n >> k;
	int h[n + 5];
	fr0(i, n) cin >> h[i + 1];
	ll dp[n + 5];
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	//dp[3] = abs(h[3] - h[1]);
	fr(i, 3, n + 1)
	{
		dp[i] = INT_MAX;
		//dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
		fr(j, 1, k + 1)
		{
			if (i - j < 1) break;
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n] << nl;


}





int main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




Measured memory_bytes: 4792
S=input()
bef = S[0]
result = 0
result_lst=[]
if bef == "R":
    result = 1


for i in range(1,3):
    if S[i] == "R":
        result +=1
    else:
        result_lst.append(result)
        result=0
result_lst.append(result)
print(max(result_lst))
    
    


Measured memory_bytes: 9052
n = int(input())
s = input()

s = list(s)
count = 0
if n >= 3:
    for i in range(n-2):
        if s[i] == 'A':
            if s[i + 1] == 'B' and s[i + 2] == 'C':
                count += 1
print(count)


Measured memory_bytes: 2940
from collections import deque
k = int(input())
num = ["null"] #数字リスト
for i in range(10):
    num.append(i)
catalog = [i for i in range(10)] #全探索の結果を格納するリスト
q = deque([i for i in range(1, 10)]) #キュー
def bfs(x: str)-> str:
    tmp = []
    ones = int(str(x)[-1]) #最下位桁
    for i in range(3):
        try:
            tmp.append(int(num[ones+i]) + x*10)
        except:
            pass
    return tmp

while len(catalog) <= k:
    node = q.popleft()
    tmp = bfs(node)
    for i in tmp:
        q.append(i)
        catalog.append(i)

print(catalog[k])


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

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

int vgcd(vector<int> a){
    int ans = a[0];
    for (int i = 0; i < a.size(); ++i) {
        ans = gcd(ans,a[i]);
    }
    return ans;
}

int main() {
    int n = 0;
    cin >> n;
    vector<int>monster;
    for (int i = 0; i < n; ++i) {
        int z = 0;
        cin >> z;
        monster.push_back(z);
    }
    int point = vgcd(monster);
    cout << point;
    return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<unordered_map>
#include<map>
#include<string>
#include<cstring>
#include<stack>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
	vector<int> arr;
	arr.push_back(0);
	int n;
	sfd(n);
	int m;
	bool f = true;
	for( int i=1; i<=n; i++ ) {
		sfd(m);
		if( m>i ) {
			f = false;
		}
		if( f ) {
			arr.insert(arr.begin()+m, m);
		}
	}
	if( f ) {
		for( int i=1; i<=n; i++ ) {
			pfd(arr[i]);
			pfn;
		}
	}else {
		pfd(-1);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin >> s;
	if(s=="ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
void swap(int *x,int *y){int tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
//next_permutation
//from https://qiita.com/Nikkely/items/0ddca51b3c0e60afbaab
int next_permutation(int *a,int n){
    int x=-1,y=-1;
    for(int i=n-2;i>=0;i--)if(a[i]<a[i+1]){x=i;break;}
    for(int i=n-1;x!=-1&&i>=0;i--)if(a[x]<a[i]){y=i;break;}
    if(x==-1||y==-1)return 1;
    swap(&a[x],&a[y]);
    qsort(&a[x+1],n-(x+1),sizeof(int),asc_cmp);
    return 0;
}

int factional(int x){
    int fact=1;
    for(int i=x;i>1;i--)fact*=i;
    return fact;
}

int main(){
    int n;scanf("%d",&n);
    int x[n],y[n];for(int i=0;i<n;i++)scanf("%d %d",&x[i],&y[i]);

    int a[n];for(int i=0;i<n;i++)a[i]=i;
    double sum=0,tmp,x_sub,y_sub;
    do{
        tmp=0;
        for(int i=1;i<n;i++){
            x_sub=x[a[i]]-x[a[i-1]];
            y_sub=y[a[i]]-y[a[i-1]];
            tmp+=sqrt(pow(x_sub,2.0)+pow(y_sub,2.0));
        }
        //printf("%lf\n",tmp);
        sum+=tmp;
    }while(!next_permutation(a,n));

    printf("%.12lf\n",sum/factional(n));
    return 0;
}

Measured memory_bytes: 128
from collections import defaultdict, deque
import sys
input=sys.stdin.readline


def solve():
    N, K = map(int, input().split())
    d = defaultdict(list)
    MOD = 10**9+7

    for _ in range(N-1):
        a, b = map(int, input().split())
        d[a].append(b)
        d[b].append(a)

    ans = K
    used = [0]*(N+1)
    used[1] = True
    q = deque([1])

    while q:
        a = q.popleft()
        s = 1 if a==1 else 2
        for b in d[a]:
            if used[b]:continue
            used[b] = True
            ans *= (K-s)
            s += 1
            q.append(b)
            ans %= MOD
    print(ans)

solve()

Measured memory_bytes: 71132
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
  vector<int>S(3) ;
  for(int i=0;i<3;i++){
      cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  cout<<S.at(0)<<" "<<S.at(1)<<" "<<S.at(2)<<endl;
}  




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


int main() 
{
    char S[3];
    for (size_t i = 0; i < 3; i++)
    {
        cin>>S[i];
    }
    int ans=0;
    if(S[0]=='R')
    {
        ++ans;
    }

    for (size_t i = 1; i < 3; i++)
    {
        if(S[i]=='R')
        {
            ++ans;
        }
        else if(ans==0)
        {
            continue;
        }
        else
        {
            break;
        }
        
    }

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

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
using namespace std;
typedef long long int ll;
const int MOD = 1000000007;
int main(){
    int ans = 0;
    int tmp = 0;
    int n;
    string s;   
    cin >> n >> s;
    for(int i=0; i<n; i++){
        if(s[i] == 'I'){
            tmp++;
        }
        else{
            tmp--;
        }
        if(ans < tmp){
            ans = tmp;
        }
        // cout << tmp << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
	#define setfile(__a) ('orzyrt')
	#define Compile(__a) system("g++ "__a".cpp -lm -o "__a)
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
	#define setfile(__a) freopen(__a".in","r",stdin);freopen(__a".out","w",stdout)
	#define Compile(__a) ('orzyrt')
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline void cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline void cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	const int mod = 1e9+7;
	const int maxn = 25010;
	const int maxk = 444;
	inline LL qpow(R LL a,R LL b){
		R LL ret=1;
		for(;b;b>>=1){
			if(b&1)ret=ret*a%mod;
			a=a*a%mod;
		}
		return ret;
	}
	int n,k,m;
	int a[maxn],lst[maxn];
	LL f[maxn][maxk],g[maxn][maxk];
	inline LL fac(R int x){R LL ret=1;for(R int i=1;i<=x;++i)ret=ret*i%mod;return ret;}
	int main(){
		read(n);read(k);read(m);
		for(R int i=1;i<=m;++i)read(a[i]);
		R int mx=0,x=0;
		R LL ans=1ll*(n-m+1)*qpow(k,n-m)%mod,ret=0;
		for(R int i=1;i<=m;++i){
			x=Min(x+1,i-lst[a[i]]);
			lst[a[i]]=i;
			cmax(mx,x);
		}
		if(mx==m){
			debug("%d\n",2);
			**f=1;
			for(R int i=1;i<=n;++i){
				R LL sf=0,sg=0;
				for(R int j=k-1;j;j--){
					(sf+=f[i-1][j])%=mod;
					(f[i][j]+=f[i-1][j-1]*(k-j+1)+sf)%=mod;
					(sg+=g[i-1][j])%=mod;
					(g[i][j]+=g[i-1][j-1]*(k-j+1)+sg)%=mod;
					if(j>=m)(g[i][j]+=f[i][j])%=mod;
				}
			}
			for(R int i=1;i<=k;++i)(ret+=g[n][i])%=mod;
			ret=1ll*ret*fac(k-m)%mod*qpow(fac(k),mod-2)%mod;
			(ans-=ret)%=mod;
			(ans+=mod)%=mod;
			cout<<ans<<endl;
		}else if(mx==k){
			debug("%d\n",1);
			cout<<ans<<endl;
		}else{
			debug("%d\n",3);
			memset(lst,0,sizeof lst);
			R int u=0,v=0;
			for(R int i=1;i<=m;++i){
				if(!lst[a[i]])u++,lst[a[i]]=1;
				else break;
			}
			memset(lst,0,sizeof lst);
			for(R int i=m;i;i--){
				if(!lst[a[i]])v++,lst[a[i]]=1;
				else break;
			}
			f[0][u]=g[0][v]=1;
			for(R int i=1;i<=n;++i){
				R LL sf=0,sg=0;
				for(R int j=k-1;j;j--){
					(sf+=f[i-1][j])%=mod;
					(f[i][j]+=f[i-1][j-1]*(k-j+1)+sf)%=mod;
					(sg+=g[i-1][j])%=mod;
					(g[i][j]+=g[i-1][j-1]*(k-j+1)+sg)%=mod;
				}
			}
			for(R int i=0;i+m<=n;++i){
				R LL s=0,t=0;
				for(R int j=1;j<k;++j){
					(s+=f[i][j])%=mod;
					(t+=g[n-m-i][j])%=mod;
				}
				(ans-=s*t)%=mod;
			}
			(ans+=mod)%=mod;
			cout<<ans<<endl;
		}
		return 0;
	}
}
int main(){
	return Night::main();
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  double d,t,s;
  cin >> d >> t >> s;
  if(d/s > t) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 3720
#include<stdio.h>
#define LOOP 1
#define LOOP_END 0
#define COUNT_RESET 0
#define RETURN 0
int main(){
	unsigned short usW_D_set;            	/* 使用できる最大値格納用変数 */
	unsigned long ulW_D_tag;            	/* 目標値格納用変数 */
	signed short ssW_D_mid;            	/* 計算用変数 */
	unsigned short usW_C_i, usW_C_j;           	/* ループ変数 */
	unsigned short usW_C_num_count;  	/* 目標を満足する値のカウンタ */

	/* 数値の入力、演算を無限ループ */
	while(LOOP){
		/* 使用できる最大値、目標値の入力 */
		scanf("%d %ld", &usW_D_set, &ulW_D_tag);
		
		/* 終了処理 */
		if(usW_D_set == LOOP_END && ulW_D_tag == LOOP_END){
			break;
		}
		/* カウンタをリセット */
		usW_C_num_count = COUNT_RESET;
		
		/* 目標を満足する値をカウント */
		for(usW_C_i = 1;usW_C_i < usW_D_set;usW_C_i++){
			for(usW_C_j = usW_C_i;usW_C_j <= usW_D_set;usW_C_j++){
				/* usW_C_i + usW_C_j と目標値の差をssW_D_midに代入 */
				ssW_D_mid = ulW_D_tag - (usW_C_i + usW_C_j);
				/* ssW_D_misがusW_C_iとusW_C_jの間にある場合カウント*/
				if(ssW_D_mid > usW_C_i && ssW_D_mid < usW_C_j){
					usW_C_num_count++;
				}
			}
		}
		
		/* 結果の出力 */
		printf("%d\n", usW_C_num_count);
		
	}
	
	return RETURN;
}



Measured memory_bytes: 2076
N, Y = list(map(int, input().split()))

# Y = 10000*x + 5000*y + 1000*z
# N = x + y + z
flag = 0
x = 0
y = 0
z = 0

if Y > 10000*N:
   flag = 1
else :
   x = Y//10000
   while True:
      for z in range(N-x+1):
         y = N-x-z
         if Y == 10000*x + 5000*y + 1000*z:
            flag = -1
            break
      if flag == -1:
         break
      elif x == 0:
         flag = 1
         break
      x = x-1
      
            

if flag == 1:
   print("-1 -1 -1")

else :
   print(str(x)+" "+str(y)+" "+str(z))




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

int main(){
  vector<int>A(5);
  for(int i=0;i<5;i++){
    cin >> A.at(i);
  }
  vector<int>a(5);
  int MAX = 0;
  for(int i=0;i<5;i++){
    a.at(i) = (10 - A.at(i)%10)%10;
    MAX = max(a.at(i),MAX);
  }
  int ans = 0;
  for(int i=0;i<5;i++){
    ans += A.at(i) + a.at(i);
  }
  cout << ans - MAX << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    string res = "";
    
    for(int i = 0; i < dx; i++) res += "R";
    for(int i = 0; i < dy; i++) res += "U";
    for(int i = 0; i < dx; i++) res += "L";
    for(int i = 0; i < dy; i++) res += "D";
    
    res += "D";
    for(int i = 0; i < dx + 1; i++)res += "R";
    for(int i = 0; i < dy + 1; i++)res += "U";
    res += "L";
    res += "U";
    for(int i = 0; i < dx + 1; i++) res += "L";
    for(int i = 0; i < dy + 1; i++) res += "D";
    res += "R";
    cout << res << endl;
    
}


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

char a[5];
int main()
{
	for(int i=0;i<2;i++){
		cin>>a[i];
	}
	if((a[0]-'A')-(a[1]-'A')>0){
		cout<<">"<<endl;}
		else if((a[0]-'A')-(a[1]-'A')<0){
			cout<<"<"<<endl;}
			else if((a[0]-'A')-(a[1]-'A')==0){
				cout<<"="<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int taka=a,aoki=c;
    while(1){
      aoki-=b;
      taka-=d;
      if(aoki<=0){
        printf("Yes");
        break;
      }else if(taka<=0){
        printf("No");
        break;
      }
    }
    return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#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 double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long p[60];
long long C[60][60];
int main(){
	int n,a,b;
	C[0][0]=1;
	for(int i=0;i<55;i++){
		for(int j=0;j<=i;j++){
			C[i+1][j]+=C[i][j];
			C[i+1][j+1]+=C[i][j];
		}
	}
	scanf("%d%d%d",&n,&a,&b);
	for(int i=0;i<n;i++)scanf("%lld",p+i);
	std::sort(p,p+n);
	double cur=0;
	long long la=0;
	for(int i=0;i<a;i++){
		cur+=(double)p[n-1-i]/a;
		la=p[n-1-i];
	}
	printf("%.12f\n",cur);
	int bi=0;
	int eq=0;
	for(int i=0;i<n;i++){
		if(la<p[i])bi++;
		if(la==p[i])eq++;
	}
	long long ret=0;
	if(bi==0){
		for(int i=a;i<=b;i++){
			ret+=C[eq][i];
		}
	}else{
		ret=C[eq][a-bi];
	}printf("%lld\n",ret);
}

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

int main() {

	int H, W;

	cin >> H >> W;

	while (H != 0 && W != 0)
	{
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}

	return 0;
}


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

#define ll             long long
#define LL             long long
#define pii            pair<int, int>
#define pll            pair<ll, ll>
#define pil            pair<int, ll>
#define pli            pair<ll, int>
#define vi             vector<int>
#define vl             vector<ll>
#define vii            vector<pii>
#define vll            vector<pll>
#define vil            vector<pil>
#define vli            vector<pli>
#define pb             push_back
#define ppb            pop_back
#define mp             make_pair
#define ff             first
#define ss             second
#define sz(x)          (int)x.size()
#define TN             typename
#define all(v)         v.begin(), v.end()
#define fill(a, b)     memset(a, b, sizeof(a))
#define endl           '\n'

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> T lcm(T a, T b) {return a * (b / gcd(a, b));}
template <TN T> T sqr(T a) {return a * a;}
template <TN T> T cube(T a) {return a * a * a;}
template <TN T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void smax(T &a, T b) {a = a > b ? a : b;}

template <TN T> inline void Int(T &n) {
	n = 0; int f = 1; register int ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
	for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
	n = n * f;
}

#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
	vector <string> v;
	stringstream ss(s); string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
	cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
	err(++it, args...);
}

inline int in() {int n; scanf("%d", &n); return n;}
inline ll Lin() {ll n; scanf("%lld", &n); return n;}
inline double Din() {double n; scanf("%lf", &n); return n;}

inline int add(int a, int b, int mod) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b, int mod) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod;}

const int N          = 2e5 + 5;
const ll  Mod        = (ll)1e9 + 7;
const int inf        = (int)2e9;
const ll  Inf        = (ll)1e18;
const int mod        = (int)1e9 + 7;

vi g[N];

// returns a pair {black, white}
pii dfs(int u, int p = -1) {
	int white = 1, black = 0;
	for (auto v : g[u]) {
		if (v == p) continue;
		pii p = dfs(v, u);
		black = add(mul(white, p.ff, mod), mul(black, add(p.ff, p.ss, mod), mod), mod);
		white = mul(white, p.ss, mod);
	}
	return {white, add(white, black, mod)};
}

int solve() {
	int n = in();
	for (int i = 0; i < n - 1; i++) {
		int u = in(), v = in();
		g[u].pb(v);
		g[v].pb(u);
	}
	pii p = dfs(1);
	int ans = add(p.ff, p.ss, mod);
	printf("%d\n", ans);
	return 0;
}

int main() {
	int test = 1, tc = 0;
	//scanf("%d", &test);
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
	return 0;
}





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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll n; cin >> n;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> h(n); rep(i, n) cin >> h[i];
  vector<ll> dp(n, INF);
  // ll ans = 0;
  // bool ok = false;

  dp[0] = 0;
  rep1(i, n - 1) {
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if(i - 2 >= 0) {
      chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
  }
  
  cout << dp[n - 1] << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){

int a,b,c,i,j,count;
count = 0;
scanf("%d %d %d",&a,&b,&c);

if(a > b){
i = a;
a = b;
b = i;
}
for(int j = b-a;j >= 0;j--){
 
  if(c%(a+j) == 0){
  count++;
  }
}
printf("%d\n",count);
return 0;
}


Measured memory_bytes: 2056
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try (Scanner sc = new Scanner(br)) {
			int len = sc.nextInt();
			int numOfQuestion = sc.nextInt();
			String str = sc.next();
			question(str, numOfQuestion, sc);
		}
	}

	private static void question(String str, int numOfQuestion, Scanner sc) {
		int[] counts = countAC(str);
		for (int i = 1; i <= numOfQuestion; i++) {
			int l = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			System.out.println(counts[r - 1]  - (l > 0 ? counts [l - 1] : 0));
		}
	}

	// 0〜i番目の部分文字列がACの場合の数
	private static int[] countAC(String str) {
		int[] counts = new int[str.length() - 1];
		char[] chars = str.toCharArray();
		int len = chars.length;
		int count = 0;
		for (int i = 0; i < len - 1; i++) {
			if (chars[i] == 'A' && chars[i + 1] == 'C') {
				count++;
			}
			counts[i] = count;
		}
		return counts;
	}
}


Measured memory_bytes: 66596
N,Y=map(int, input().split())
flag=0
for i in range(N+1):
  for j in range(N+1-i):
    k =N-i-j
    if 10000*i+5000*j+1000*k==Y:
      print(i,j,k)
      flag=1
      break
  else:
    continue
  break
if flag==0:
  print('-1 -1 -1')

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

int main () {;
	int S;
	int h, m, s;
	cin >> S;
	
	h = S / 3600;
	S = S % 3600;
	m = S / 60;
	s = S % 60;
	
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 3088
//minimum spanning tree
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_ 12_A&lang=jp
//右　奥

#include <iostream>
#include <algorithm>
#include <tuple>
using namespace std;


int P[10010]; // 0 から 10000 までの頂点を取り扱い可能
void init(int N) { // 初期化 はじめは全ての頂点はバラバラ
  for (int i=0; i<N; i++) P[i] = i;
}
int root (int a) { //aの大表現を求める
  if (P[a] == a) return a;
  return (P[a] = root(P[a]));
}
bool is_same_set (int a, int b){
  return root(a) == root(b);
}
void unite(int a, int b){
  P[root(a)] = root(b);
}


int main(){
  int n;
  cin >> n;
  tuple<int,int,int> cost[10010]; //Array for cost
  int count = 0;
  for (int i = 0; i < n; i ++){
    for (int j = 0; j < n; j++){
      int t;
      cin >> t;
      if (t >= 0){
      get<1>(cost[count]) = i;
      get<2>(cost[count]) = j;
      get<0>(cost[count]) = t;
      count++;
    }
    }
  } // tupleに行列Aの情報を入れる
  sort(cost,cost + n*n);//sortする //n*n個ソートするときの書き方

  init(n + 10); // 初期化 はじめは全ての頂点はバラバラ

  int ans = 0;
  int anscount = 0; //このcountがnになった時点で終了する
  int k = 0;
  while (anscount != n-1){
    if (is_same_set(get<1>(cost[k]), get<2>(cost[k]))) {
      k ++; //get<1>(cost[k]), get<2>(cost[k])の親が同じときkを１増やす
    }
    else{
      unite(get<1>(cost[k]), get<2>(cost[k])); //合同じゃなければ合同にする（なぜならsortによって最小値から返されるから）
      ans += get<0>(cost[k]);
      k++;
      anscount++;
    }
  }


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



Measured memory_bytes: 3236
package main

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

func main() {
	abc := getIntSlice(3)
	sort.Ints(abc)

	ans := "NO"
	if abc[0] == 5 && abc[1] == 5 && abc[2] == 7 {
		ans = "YES"
	}
	fmt.Println(ans)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
# https://atcoder.jp/contests/abc106/tasks/abc106_b

N = int(input())

ans = 0
# X % M == 0
for X in range(1,N+1,2):
    cnt = 0
    for M in range(1,X+1,2):
        if X % M == 0:
            cnt += 1
    if cnt == 8:
        ans += 1

print(ans)

Measured memory_bytes: 2940
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    n = int(input())
    A = list(map(int, input().split()))
    B = []
    for i in range(n):
        for _ in range(A[i]):
            B.append(i + 1)

    res = [[0] * W for _ in range(H)]
    for b in B:
        for h in range(H):
            for w in range(W):
                if res[h][w] == 0:
                    res[h][w] = b
                    break
            else:
                continue
            break

    for i in range(H):
        if i % 2 == 0:
            print(*res[i])
        else:
            print(*res[i][::-1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 44508
n = int(input())
an = list(map(int,input().split()))
an_s = sorted(an, reverse=True)
alice = 0
bob =0


for i in range (n):
  if i%2 == 0:
    alice += an_s[i]
  elif i%2 != 0:
    bob += an_s[i]

ans = alice - bob
print(ans)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int W, a, b; cin >> W >> a >> b;

	int res = 0;
	if (a < b){
		if (b <= a + W){
			res = 0;
		}else{
			res = b - (a + W);
		} // end if
	}else
	if (a > b){
		if (a <= b + W){
			res = 0;
		}else{
			res = a - (b + W);
		} // end if
	} // end if

	cout << res << endl;

	return 0;
}

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

void solve(std::string S) {
    ll ans = 0;
    rep(i, 4) {
        if (S[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }
    cout << ans << endl;
}

int main() {
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[200010], b[200010]; // 各列がどこまで裏返せるかを記録

int main(){
    ll n, q;
    cin >> n >> q;
    ll ans = (n - 2) * (n - 2);
    rep(i, n) a[i+1] = n, b[i+1] = n;
    ll h = n, w = n;

    rep(i, q){
        int p;
        ll x;
        cin >> p >> x;
        if (p == 1) {
            if (x < w) {
                for(int i = x; i < w; i++) b[i] = h;
                w = x; // 横の最小値を記録しておく
            }
            ans -= b[x] - 2;
        }
        else {
            if (x < h) {
                for(int i = x; i < h; i++) a[i] = w;
                h = x; // 縦の最小値を記録しておく
            }
            ans -= a[x] - 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main () {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  unordered_map<char, int> mt;
  for(int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    mt[s[0]]++;
  }

  const string s = "MARCH";
  vector<int> v = {0,0,1,1,1};
  ll ret = 0;
  do {
    ll cur = 1;
    for(int i = 0; i < 5; ++i) {
      if (v[i]) {
        cur *= mt[s[i]];
      }
    }
    ret += cur;
  } while (next_permutation(v.begin(), v.end()));
  cout << ret;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int K;
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    scanf("%d",&K);
    printf("%d",a[K-1]);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include<string.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N, M;
	cin >> N >> M;

	vector<ll> p(M, 0);	//回答
	// vector<string> ss;

	vector<bool> isCorrect(N, false);
	vector<ll> waCnt(N, 0);

	for (ll i = 0; i < M; ++i){
		cin >> p[i];
		char hoge[] ="";
		cin >> hoge;

		// ss.push_back(hoge);
		ll probNo = p[i] - 1;
		if (isCorrect[probNo] == false){
			if (strcmp(hoge, "AC")==0) {
			// if (hoge == "AC"){
				isCorrect[probNo] = true;
			} else {
				waCnt[probNo]++;
			}
		}

	}

	ll correctCnt = 0;
	ll waCntSum = 0;
	for (ll i = 0; i < N; ++i){
		if (isCorrect[i]){
			correctCnt++;
			waCntSum += waCnt[i];
		}
	}

	cout << correctCnt << " " << waCntSum << endl;


	return 0;
}



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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << ' ' << b << ' ' << c << endl;
}

Measured memory_bytes: 256
a = int(input())
b = 0
l = int(a**0.5)+1
count = 0
for i in range(l):
    i = i+1
    if a%i == 0:
        j = a//i
    if i*j == a:
        if count == 0:
            count += 1
            c = i
            d = j
        if count>0:
            if (c+d)>(i+j):
                c = i
                d = j
ans = c+d-2
print(ans)

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
	return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main()
{
	long long int a;
	long long int b;
	long long int k;
	cin >> a >> b >> k;

	if (a >= k)
	{
		cout << a - k << " " << b << endl;
		return 0;
	}
	long long int temp;
	if (a < k)
	{
		temp = k - a;
		if (b > temp)
		{
			cout << 0 << " " << b - temp << endl;
			return 0;
		}
		else
		{
			cout << 0 << " " << 0 << endl;
		}
	}

	return 0;
}


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

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

    vector<long long> A(N);
    set<long long> s;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    vector<long long> q(1, 10000000000);
    for (int i = 0; i < N; i++)
    {
        if (A[i] <= q.back())
        {
            q.push_back(A[i]);
            continue;
        }
        int l = 0;
        int r = q.size() - 1;
        while (r - l > 1)
        {
            int c = (l + r) / 2;
            if (A[i] > q[c])
            {
                r = c;
            }
            else
            {
                l = c;
            }
        }
        q[r] = A[i];
    }
    cout << q.size() - 1 << endl;
}


Measured memory_bytes: 2168
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	var nums []int
	for i := 1; i < 2*100+1; i++ {
		nums = append(nums, i*(i+1)*(i+2)/6)
	}
	var ins []int
	N := 0
	for true {
		n := sc.nextInt()
		if n == 0 {
			break
		}
		ins = append(ins, n)
		N = max(N, n)
	}
	dp := make([]int, N+1)
	dp2 := make([]int, N+1)
	for i := 1; i < N+1; i++ {
		dp[i] = INF
		dp2[i] = INF
	}
	for i := 0; i < len(nums); i++ {
		n := nums[i]
		if n > N {
			break
		}
		for j := 0; j < N+1; j++ {
			if j >= n {
				dp[j] = min(dp[j], dp[j-n]+1)
				if n%2 != 0 {
					dp2[j] = min(dp2[j], dp2[j-n]+1)
				}
			}
		}
	}
	for i := 0; i < len(ins); i++ {
		fmt.Fprintln(wtr, dp[ins[i]], dp2[ins[i]])
	}
}


Measured memory_bytes: 17032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
typedef long long ll;
#define mod 1000000007

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  rep(i, 0, N) cin >> X[i];
  ll ans = 0;
  rep(i, 1, N) {
    ll dif = X[i] - X[i-1];
    ll costA = dif * A;
    ans += min(costA, B);
  }
  cout << ans << endl;
  return 0;
}


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

const int MAXN = 4010;
const int mod = 998244353;

int n;
int dp[MAXN][MAXN];
char s[MAXN];

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    std::vector<int> red, blue;
    for (int i = 1; i <= n; ++i) {
        if (s[i] == '0') {
            red.push_back(i);
            red.push_back(i);
        } else if (s[i] == '1') {
            red.push_back(i);
            blue.push_back(i);
        } else {
            blue.push_back(i);
            blue.push_back(i);
        }
    }
    dp[0][0] = 1;
    n <<= 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < i; ++j) {
            if (j < red.size() && red[j] <= i) {
                (dp[i][j + 1] += dp[i - 1][j]) %= mod;
            }
            if (i - j - 1 < blue.size() && blue[i - j - 1] <= i) {
                (dp[i][j] += dp[i - 1][j]) %= mod;
            }
        }
    }
    printf("%d\n", dp[n][red.size()]);
    return 0;
}


Measured memory_bytes: 61440
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 a, b, n;
    cin >> a >> b >> n;
    i64 ans = 0;
    akari<i64> xs = {n, n - 1, n / b * b - 1};
    for (i64 x : xs)
    {
        ans = max(a * x / b - a * (x / b), ans);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3636
n, m, x = map(int, input().split())
A = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
for i in range(x+1, n):
    if i in A:
        cnt1 += 1
for j in range(x-1, 0, -1):
    if j in A:
        cnt2 += 1
print(min(cnt1, cnt2))


Measured memory_bytes: 3060