akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repr(i,from,to) for(long long (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(long long (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    ll p[n+2];
    rep(i,n){cin>>p[i+1];}
    multiset<ll> idxes;
    ll idx[n+2];
    repr(i,1,n+1){
        idx[p[i]]=i;
    }

    idxes.insert(n+1); 
    idxes.insert(n+1); 
    idxes.insert(0);
    idxes.insert(0);
    ll res = 0;
    ll tmp;
    for(ll i=n;i>0;i--){
        DEBUG{cout << i << endl;}
        auto cur = idxes.lower_bound(idx[i]);
        DEBUG{cout << "cur: " <<*cur<<endl;}
        res += i*(*next(cur,1)-*cur)*(idx[i]-*prev(cur,1));
        res += i*(*prev(cur,1)-*prev(cur,2))*(*cur-idx[i]);
        idxes.insert(idx[i]);
        DEBUG{cout <<"res: " <<res << endl;}
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6528
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n, k;
    cin >> n >> k;
    int ans = k;
    forn(i, n - 1) ans *= (k - 1);
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
#define endl '\n'
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
string s;
ll mark[200005];
int main()
{
    FIO;
    cin>>s;
    ll  st=0;
    while(st<s.ln){
        if(st<s.ln-1&&s[st]=='S'&&s[st+1]=='T'){
            if(mark[st]||mark[st+1]) continue;
            mark[st]=1;mark[st+1]=1;
            ll pr=st-1,nx=st+2;
            while(pr>=0&&nx<s.ln){
                bool cc=0;
                if(mark[pr]) cc=1,pr--;
                if(mark[nx]) cc=1,nx++;
                if(cc) continue;
                if(s[pr]!='S'||s[nx]!='T') break;
                mark[pr]=1;mark[nx]=1;
                pr--;nx++;
            }
            st=nx-1;
        }
        st++;
    }
    ll ct=0;
    rep(i,0,s.ln-1) if(!mark[i]) ct++;
    cout<<ct;
    cout<<endl;
}

Measured memory_bytes: 2196
#include "stdio.h"

char pro[10002][12];
int num[26] = {};
int N, K;
int box;
int ans = 0;
bool flag = true;

int main() {
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%s", pro[i]);
		num[pro[i][0] - 'A']++;
	}
	
	while (flag) {
		for (int i = 0; i < 26; i++) {
			for (int j = i + 1; j < 26; j++) {
				if (num[j] > num[i]) {
					box = num[i];
					num[i] = num[j];
					num[j] = box;
				}
			}
		}
		if (num[K - 1] > 0) {
			for (int i = 0; i < K; i++) {
				num[i]--;
			}
			ans++;
		}
		else {
			flag = false;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <cmath>
#include <set>
#include <vector>
using namespace std;
int n;
int a;
bool is_prime(int a)
{
    if(a==2) return true;
    for(int i=2;i*i<=a;i++)
    {
        if(a%i==0) return false;
    }
    return true;
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int cnt=0;
    while(n--)
    {
        scanf("%d",&a);
        if(is_prime(a)) cnt++;
    }
    printf("%d\n",cnt);

    return 0;
}

Measured memory_bytes: 3236
#include<iostream>
#include<cmath>
using namespace std;
int H,W,N;
int main()
{
    cin>>H>>W>>N;
    int k=max(H,W);
    if(N%k==0)
    {
        cout<<N/k;
    }
    else
        cout<<N/k+1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int n, k, ans = 0;
    cin >> n >> k;

    while (n > 0)
    {
        n /= k;
        ans++;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

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

using namespace std;


int main(){
    
    int n;
    int x = 0;
    int a[20]={}, b[50]={}, c[50]={};
    int i, m;
    cin >> n;
    for(i = 0;i < n;i++){
        cin >> a[i];
    }
    for(i = 0;i < n;i++){
        cin >> b[i];
    }
    for(m = 0;m < n - 1;m++){
        cin >> c[m];
    }
    for(i = 0;i < n ;i++){
        x = x + b[a[i] - 1];
    }
    for(i = 0;i < n - 1;i++){
        if(a[i] + 1==a[i + 1])
            x = x + c[a[i] - 1];
    }
    cout << x << endl;
    
    
   /* int N; cin >> N;
    int A[20] = {}, B[20] = {}, C[19] = {};
    rep(i, N)cin >> A[i];
    rep(i, N)cin >> B[i];
    rep(i, N - 1)cin >> C[i];
    
    int ans = 0;
    
    rep(i, N){
        ans += B[i];
        if(i < N - 1){
            if(A[i] + 1 == A[i + 1]){
                ans += C[i + 1];
            }
        }
    }
    
    cout << ans << endl;*/
     
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s; cin >> s;
  int n = s.size();
  int t = 0;
  reverse(s.begin(), s.end());
  while(true){
    if(t == n) break;

    if(t+4<n && s.substr(t,5) == "maerd") t += 5;
    else if(t+6<n && s.substr(t,7) == "remaerd") t += 7;
    else if(t+4<n && s.substr(t,5) == "esare") t += 5;
    else if(t+5<n && s.substr(t,6) == "resare") t += 6;
    else break;
  }
  if(t == n) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 512
#2019は3と673で割り切れることを考慮する必要がある(重要)
#入力。範囲指定
L, R = list(map(int,input().split()))
#解を仮に無限大と置いておく
ans = float('inf')
"""
mod(x)とし、i = y1 * x + b, j = y2 * x + cなどと置くと i * j で xで括れない項は
b*c(余り同士の)掛け算のみ。
"""
#LとRの2019で割った時の余りは求めておく。
l = L % 2019
r = R % 2019
#LとRで挟まれる領域が十分に広い(673以上の)場合絶対に解は0(動ける範囲制限)
if R - L >= 673:
  ans = 0
  print(ans)
  exit(0)
#LとRで挟まれる範囲内に3で割り切れる要素と673で割り切れる要素が同時に存在したら解は0
#判定用変数
flag1 = 0 
flag2 = 0
#LとRで挟まれるリスト作製
list = [i for i in range(L,R+1)]
for i in range(len(list)):
  #3で割り切れるか判定
  if list[i] % 3 == 0:
    flag1 += 1
  #673で割り切れるか判定,3で割り切れていても判定するようにelifではなくifを使う
  if list[i] % 673 == 0:
    flag2 += 1
#両方満たしていたら解が0になる
if flag1 * flag2 != 0:
  ans = 0
  print(ans)
  exit(0)
#LとRの間に2019の倍数の壁がある=2019で割って余りが0になるタイミングがある
if l > r:
  ans = 0
  print(ans)
  exit(0)
#ここまで候補削ったらあとは全探索でもできる(と思われる)
#最小値をansと置く
ans = float('inf')
for i in range(l,r):
  for j in range(l+1,r+1):
    if ans > (i * j) % 2019:
      ans = (i * j) % 2019
print(ans)

Measured memory_bytes: 3064
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

ll h, w, n, ans ;

signed main() {
	scanf("%lld%lld%lld", &n, &h, &w) ;
	ans = 1ll * (n - w + 1) * (n - h + 1) ;
	printf("%lld\n", ans) ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
} 
int main()
{
    ll a=read(),b=read();
    printf("%lld\n",a*b);
}


Measured memory_bytes: 3764
import java.awt.Point;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int num = stdin.nextInt();

		Point[] redArray = new Point[num];
		for (int i = 0; i < num; i++) {
			int x = stdin.nextInt();
			int y = stdin.nextInt();
			redArray[i] = new Point(x, y);
		}
		// Yの降順にソート
		Arrays.sort(redArray, (pt1, pt2) -> (pt2.y - pt1.y));

		Point[] blueArray = new Point[num];
		for (int i = 0; i < num; i++) {
			int x = stdin.nextInt();
			int y = stdin.nextInt();
			blueArray[i] = new Point(x, y);
		}
		// Xの昇順にソート
		Arrays.sort(blueArray, (pt1, pt2) -> (pt1.x - pt2.x));

		int count = 0;
		for (int i = 0; i < num; i++) {
			Point blue = blueArray[i];
			for (int j = 0; j < num; j++) {
				if (redArray[j] == null) {
					continue;
				}

				Point red = redArray[j];
				if ((red.x < blue.x) && (red.y < blue.y)) {
					redArray[j] = null;
					count++;

					break;
				}
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 27348
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>

ll power(ll a, ll n) 
{ 
    if (n == 0) 
        return 1; 
    ll p = power(a, n / 2); 
    p = (p * p) ; 
    if (n & 1) 
        p = (p * a) ; 
    return p; 
} 

int32_t 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;
       cin>>n;
       ll a[n];
       ll total_xor=0;
       fori(0,n){cin>>a[i];total_xor=total_xor^a[i];}

       fori(0,n)cout<<(a[i]^total_xor)<<" ";



      
 

     
 
return 0;
}     

Measured memory_bytes: 5144
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max  1000

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}
int int_sort( const void * a , const void * b ) {
  return strcmp(( char * )a , ( char * )b );
}

int main()
{
    int k, a, b, i;
    
    scanf("%d%d%d", &k, &a, &b);
    
    for (i=1; i<=b; i++) {
        if (k*i<=b&&k*i>=a) {
            printf("OK");
            return 0;
        }
    }
    
    printf("NG");
    
    return 0;
} 



Measured memory_bytes: 1736
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll nl, nm;

int a[100010];
int b;

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

  int n, ans = 0LL;
  cin >> n;
  REP(i, n) {
    int b;
    cin >> b;
    a[b]++;
  }
  
  FOR(i, 2, 100001) ans = max(ans, a[i-2]+a[i-1]+a[i]);

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


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

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
//int l[n+1];
int main() {
  int n;
  cin >> n;
  long long res = 0;
  for(int i=1;i<n;i++){
   res += i; 
  }
  
  cout << res;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=-1,tmp=0;
  int a[LIMIT2]={0};
  char s[LIMIT1],c; 
  
  scanf("%s",&s);
  n = strlen(s);
  rep(j,2){
    tmp=0;
    rep(i,n){
      c = (i+j)%2+'0';
      if(s[i]!=c) tmp++;
      //printf("%c",c);
    }
    //printf("\n");
    if(result==-1 || tmp<result) result = tmp;
  }
  printf("%lld",result);
  return 0;
}

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

using namespace std;

#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb(x) push_back(x)

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

void solve(){
    string str; cin >> str;
    if(str[1] == 'B') cout << "ARC";
    else cout << "ABC";
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? LLONG_MAX : INT_MAX;
const int MOD = 1000000007;
const long double EPS = 1e-8;

struct Bipartite_Matching
{
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  Bipartite_Matching(int n)
  {
    timestamp = 0;
    graph.resize(n);
    alive.assign(n, 1);
    used.assign(n, 0);
    match.assign(n, -1);
  }

  void add_edge(int u, int v)
  {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int v)
  {
    used[v] = timestamp;
    for(int i = 0; i < graph[v].size(); i++) {
      int u = graph[v][i], w = match[u];
      if(alive[u] == 0) continue;
      if(w == -1 || (used[w] != timestamp && dfs(w))) {
        match[v] = u;
        match[u] = v;
        return (true);
      }
    }
    return (false);
  }

  int bipartite_matching()
  {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return (ret);
  }
};

signed main() {
	int n;
	cin >> n;
	int a[n], b[n], c[n], d[n];
	Bipartite_Matching bm(n * 2);
	rep (i, n) cin >> a[i] >> b[i];
	rep (i, n) cin >> c[i] >> d[i];
	rep (i, n) rep (j, n) {
		if (a[i] < c[j] && b[i] < d[j]) {
			bm.add_edge(i, j + n);
		}
	}
	cout << bm.bipartite_matching() << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    int a,b;
   char op;
        while(1){
          scanf("%d %c %d",&a,&op,&b);
           if( op =='?')
               break;
           else if( op == '+')
               printf("%d\n",a+b);
           else if( op == '-')
               printf("%d\n",a-b);
           else if( op == '*')
               printf("%d\n",a*b);
           else if( op == '/')
               printf("%d\n",a/b);
           }
              return 0;
}


Measured memory_bytes: 2120
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

using namespace std;
using pii = pair<int, int>;
using ll = long long;

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

	int n;
	cin >> n;
	int now = 1;
	int answer = 0;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		if (tmp == now) {
			answer += 1;
			now += 1;
		}
	}
	if (answer == 0) cout << -1;
	else cout << n - answer;
	return 0;
}


Measured memory_bytes: 256
import kotlin.math.*
import java.util.*

const val DIV = 1000000007L

fun main(args: Array<String>) {
  val (n, k) = readLine()!!.split(' ').map(String::toLong)
  var ans = 0L
  for (i in k..n + 1) {
    val a = (i - 1) * i / 2
    val b = (n + n - i + 1) * i / 2
    ans += (b - a + 1) % DIV
  }
  println(ans % DIV)
}


Measured memory_bytes: 36428
#include <stdio.h>

int sol(int,int);


int A[2000];
int n;

int main(){
  int q,i,mi;

  scanf("%d",&n);

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&mi);
    if(sol(n,mi))printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int sol(int n2,int mi){
  int resp;
  if(mi==0) return 1;
  if(n2 < 0)return 0;

  resp = sol(n2-1,mi) || sol(n2-1,mi-A[n2]);
  return resp;
}

  
    
    
  



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
string s[maxn];
int main(){
	int n;
	cin>>n;
	map<string,int>m;
	for(int i=0;i<n;i++){
		string ss;
		cin>>ss;
		m[ss]++;
	}
	int max1=-1;
	for(auto it=m.begin();it!=m.end();it++){
		if(max1<it->second)max1=it->second;
	}
	for(auto it=m.begin();it!=m.end();it++){
		if(it->second==max1)cout<<it->first<<endl;
	}
	return 0;
}

Measured memory_bytes: 26752
#include<iostream>
#include<string>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int k;
	cin>>k;
	string s;
	cin>>s;
	if(k<s.size()){
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"...";
	}
	else{
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int a,b;

    scanf("%d%d",&a,&b);

    int s=a+b;
    int m=a-b;
    int t=a*b;

    if(s>=m&&s>=t)
    {
        printf("%d\n",s);
    }
    else if(m>=s&&m>=t)
    {
       printf("%d\n",m);
    }
    else
    {
       printf("%d\n",t);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll X; cin >> X;
  ll pos, i;
  for(i=1, pos = 0; pos < X ;++i) {
    pos += i;
  }
  cout << i-1  << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int i;
        int[] array = new int[3];
        for (i = 0; i < 3; i++) {
            array[i] = sc.nextInt();
        }

        int j;
        int k;
        int z;
        for(j=0;j<2;j++){
            for(k=0;k<2;k++){
                if(array[k]>array[k+1]){
                    z = array[k];
                    array[k] = array[k+1];
                    array[k+1] = z;
                }
            }
        }

        for(i=0;i<2;i++){
            System.out.print(array[i]+" ");
        }
        System.out.println(array[2]);

    }
}


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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int sum = 0;;
    for(int i = 0; i<n+1;i++){
        int ax = 0;
        for(int buf = i; buf !=0;){
            ax += buf % 10;
            buf = buf / 10;
        }
        if(ax >=a & ax <=b){
            sum += i;
        }
        
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

void f(int n) {
    while(n) {
        if (n %10 == 7) {cout << "Yes"<<endl;return;}
        n /=10;
    }
    cout << "No"<<endl;
}
int main() {
    
    int N;
    cin >> N;
    f(N);
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define pb push_back
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,a[N];
char s[N];
int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
int main()
{
	mem(a,0);
	scanf("%s",s+1);
	n=strlen(s+1);
	FOR(i,1,n-1)
	{
		if (s[i]=='R'&&s[i+1]=='L')
		{
			int cnt1=1,cnt2=1;
			while (s[i-cnt1]=='R'&&i-cnt1>=1) cnt1++;
			while (s[i+cnt2+1]=='L'&&i+cnt2+1<=n) cnt2++;
			if ((cnt1+cnt2)%2==0) a[i]=a[i+1]=(cnt1+cnt2)/2;
			else
			{
				if ((cnt1>cnt2&&cnt1%2==0)||(cnt2>cnt1&&cnt2%2!=0)) a[i]=(cnt1+cnt2)/2,a[i+1]=(cnt1+cnt2+1)/2;
				else a[i+1]=(cnt1+cnt2)/2,a[i]=(cnt1+cnt2+1)/2;
			}
			i=i+cnt2;
		}
	}
	FOR(i,1,n) printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int l, r;
  cin >> l >> r;

  int d = r-l;
  l %= 2019;
  r %= 2019;
  int ans = 2018;
  if(l == 0 || r == 0 || l + d >= 2019){
    ans = 0;
  } else {
    FOR(i, 0, d){
      FORe(j, i+1, d) chmin(ans, ((l+i)%2019)*((l+j)%2019)%2019);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 123456
#define mod 1000000007

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

int n;
ll a[123456][3];
ll dp[123456][4];

ll memo(int idx, int p) {
	if(idx < 0) return 0;
	if(dp[idx][p] != -1) return dp[idx][p];
	ll res = 0;
	for(int i=0; i<3; i++) {
		if(p == i) continue;
		res = max(res, memo(idx-1, i) + a[idx][i]);
	}
	return dp[idx][p] = res;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2];
	memset(dp, -1, sizeof dp);
	cout << memo(n-1, 3) << endl;
	return 0;
}

Measured memory_bytes: 12672
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define M 1005

int ans[M][M];

using namespace std;

int main()
{
	int h, w, a, b;

	cin >> h >> w >> a >> b;

	for (int i = 1; i <= b; i++)
		for (int j = a + 1; j <= w; j++)
			ans[i][j] = 1;

	for (int i = b + 1; i <= h; i++)
		for (int j = 1; j <= a; j++)
			ans[i][j] = 1;

	for (int i = 1; i <= h; i++)
	{
		for (int j = 1; j <= w; j++)
			cout << ans[i][j];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 5120
using Yorukatsu054.Questions;
using Yorukatsu054.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu054.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/abc093/tasks/arc094_a
    /// </summary>
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var abc = inputStream.ReadIntArray();

            var count = 0;
            while (abc[0] != abc[1] || abc[1] != abc[2] | abc[2] != abc[0])
            {
                Array.Sort(abc);
                var diff1 = abc[2] - abc[0];
                var diff2 = abc[2] - abc[1];
                if (diff2 != 0)
                {
                    abc[0]++;
                    abc[1]++;
                }
                else
                {
                    abc[0] += 2;
                }

                count++;
            }

            yield return count;
        }
    }
}


namespace Yorukatsu054
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu054.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu054.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11348
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e5;
int n,mt[N+2][4],dp[N+2][4];
int dfs(int st,int ls)
{
  if(st>n)return 0;
  if(dp[st][ls]!=-1)return dp[st][ls];
  int now=0;
  for(int i=1;i<=3;i++)
  {
    if(i==ls)continue;
    now=max(now,mt[st][i]+dfs(st+1,i));
  }
  return dp[st][ls]=now;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>n;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=3;j++)
      cin>>mt[i][j];
  memset(dp,-1,sizeof(dp));
  cout<<dfs(1,0)<<endl;
  return 0;
}

Measured memory_bytes: 11136
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[100010];
ll l[100010], r[100010];

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

  rep( i, N+1 )
    std::cin >> A[i];

  l[N] = A[N], r[N] = A[N];

  repd( i, N )
  {
    l[i] = (l[i+1]+1)/2+A[i];
    r[i] = r[i+1]+A[i];
  }

  if( l[0] <= 1 && 1 <= r[0] )
  {
    ll p = 1;
    ll ans = 1;

    repi( i, 1, N+1 )
    {
      p *= 2;
      p = std::min( p, r[i] );
      ans += p;
      p -= A[i];
    }

    std::cout << ans << std::endl;
  }
  else
    std::cout << -1 << std::endl;

  return 0;
}

Measured memory_bytes: 5972
from collections import deque
from typing import List


if __name__ == "__main__":
    stack_num, query_num = map(lambda x: int(x), input().split())
    stacks: List[deque] = [deque() for _ in range(stack_num)]

    for _ in range(query_num):
        op, *value = map(lambda x: int(x), input().split())
        if (0 == op):
            stacks[value[0]].append(value[1])
        elif (1 == op):
            stack = stacks[value[0]]
            if (0 != len(stack)):
                print(stack[len(stack) - 1])
        elif (2 == op):
            stack = stacks[value[0]]
            if (0 != len(stack)):
                stack.pop()
        else:
            pass



Measured memory_bytes: 15732
#include<stdio.h>
#define NILL -1

typedef struct{
  int parent;
  int r;
  int l;
} TREE;

int sibling(int);
int degree(int);
int depth(int,int);
int height(int);

int n;
int h[30];
TREE t[30];

int main(){
  int i;
  int n;
  scanf("%d",&n);  
  for(i=0;i < n;i++){
      t[i].parent = NILL;
  }

  int v;
  for(i = 0;i < n; i++){
    scanf("%d",&v);
    scanf("%d%d",&t[v].l,&t[v].r);
    if(t[v].l != NILL){
        t[t[v].l].parent = v;
    }

    if(t[v].r != NILL){
        t[t[v].r].parent = v;
    }
  }
  
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
	   i,t[i].parent,sibling(i),degree(i),depth(i,0),height(i));
    if(t[i].parent == NILL){
        printf("root\n");
    }else if(t[i].l == NILL && t[i].r == NILL){
        printf("leaf\n");
    }else{
        printf("internal node\n");
    }
  }

  return 0;
}

int sibling(int i){
  if(t[i].parent == NILL){
      return NILL;
  }

  if(t[t[i].parent].r != i && t[t[i].parent].r != NILL){
      return t[t[i].parent].r;
  }

  if(t[t[i].parent].l != i && t[t[i].parent].l != NILL){
      return t[t[i].parent].l;
  }

  return -1;
}

int degree(int i){
  int cnt = 0;
  if(t[i].l != NILL){
      cnt++;
  }

  if(t[i].r != NILL){
      cnt++;
  }

  return cnt;
}

int depth(int i, int di){
  di = 0;

  while(t[i].parent != NILL){
    i = t[i].parent;
    di++;
  }

  return di;
}

int height(int i){
  int h1 = 0,h2 = 0;
  if(t[i].r != NILL){ 
      h1 = height(t[i].r)+1;
  }
  if(t[i].l != NILL) {
      h2 = height(t[i].l)+1;
  }

  if(h1 > h2){
      h[i] = h1;
  }else{
      h[i] = h2;
  }
  
  return h[i];
}




Measured memory_bytes: 2028
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>

int n, a[2];

bool solve()
{
    for (int cur = 0; ; cur ^= 1) {
        int cop = cur ^ 1;
        if (std::abs(a[cur] - a[cop]) > 1)
            a[cur] += (a[cop] - a[cur]) / std::abs(a[cop] - a[cur]);
        else 
            a[cur] -= (a[cop] - a[cur]) / std::abs(a[cop] - a[cur]);
        if (a[cur] < 1 || a[cur] > n)
            return cur;
    }
}

int main()
{
    scanf("%d%d%d", &n, &a[0], &a[1]);
    puts(solve() ? "Alice" : "Borys");
}


Measured memory_bytes: 128
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

class Direct_Graph {
    public:
    struct Edge { 
        int to; double cost;
    };
    std::vector<std::vector<Edge>> G;
    int node_num;
    Direct_Graph() {}
    Direct_Graph(const int node_num_in) {
        node_num = node_num_in;
        G.resize(node_num);
    }
    void add_edge(const int from, const int to, const double cost) {
        Edge edge; edge.to = to; edge.cost = cost;
        G[from].push_back(edge);
    }
    void add_edge_both(const int node1, const int node2, const double cost) {
        add_edge(node1, node2, cost);
        add_edge(node2, node1, cost);
    }

    std::vector<double> Dijkstra(int s, const double dist_inf) {
        std::vector<double> dist; dist.resize(node_num);
        for (int i = 0; i < dist.size(); i++) {
            dist[i] = dist_inf;
        }
        typedef std::pair<double, int> Pair;

        std::priority_queue <Pair, std::vector<Pair>, std::greater<Pair>> que;
        dist[s] = 0;
        que.push(Pair(0, s));

        while (!que.empty()) {
            Pair pair = que.top(); que.pop();
            int v = pair.second;
            if (dist[v] < pair.first) { continue; }
            for (Edge edge : G[v]) {
                if (dist[v] + edge.cost < dist[edge.to]) {
                    dist[edge.to] = dist[v] + edge.cost;
                    que.push(Pair(dist[edge.to], edge.to));
                }
            }
        }

        return dist;
    }
};

const int MAX_N = 1050;
const double MAX_DIST = 1000000000000.0;

Direct_Graph direct_graph = Direct_Graph(MAX_N);

int N;
long long xs, ys, xt, yt;
long long x[MAX_N], y[MAX_N], r[MAX_N];

double calc_dist(const int i, const int j) {
    double dist2 = (double)(x[i] - x[j]) * (x[i] - x[j]) + (double)(y[i] - y[j]) * (y[i] - y[j]);
    double dist = sqrt(dist2);
    return std::max(dist - r[i] - r[j], 0.0);
}

int main(int argc, char **argv) {
    std::cin >> xs >> ys >> xt >> yt;
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> x[i] >> y[i] >> r[i];
    }
    N++;

    x[0] = xs; y[0] = ys; r[0] = 0;
    x[N] = xt; y[N] = yt; r[N] = 0;

    for (int i = 0; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            double dist = calc_dist(i, j);
            direct_graph.add_edge_both(i, j, dist);
        }
    }

    std::vector<double> dist = direct_graph.Dijkstra(0, MAX_DIST);
    std::cout << std::setprecision(12) << dist[N] << std::endl;
    

    return 0;
}

Measured memory_bytes: 21780
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = 1000000007;

//毎回変える定数
#define N_MAX 200


//問題文のとおりの変数
int N;

//オリジナル変数
int s;
vector<vector<LL>> dp;

//入力
void input() {
	cin >> N;
	string tmp;
	cin >> tmp;
	s = tmp.size();

	REP(i, N+1) {
		dp.push_back(vector<LL>(N+1));
	}
	dp[0][0] = 1;
}

void calc() {
	REP(i, N){
		REP(j, N) {
			//バックスペース
			if (j == 0) {
				dp[i + 1][0] += dp[i][j];
				dp[i + 1][0] %= INF;
			}
			else {
				dp[i + 1][j - 1] += dp[i][j] * 2;
				dp[i + 1][j - 1] %= INF;
			}
			//挿入
			dp[i + 1][j + 1] += dp[i][j];
			dp[i + 1][j + 1] %= INF;
		}
		//cout << i << endl;
	}
}



void output() {
	cout << dp[N][s] << endl;
}

void debug() {
	/*
	REP(i, N + 1) {
		REP(j, N) {
			cout << dp[i][j] << "  ";
		}
		cout << endl;
	}*/
	cin >> N;
}


//メイン関数
int main() {
	
	input();
	calc();
	output();
	return 0;
}





Measured memory_bytes: 195840
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

# solve
# 解説AC
# いやなぜわからん
# 三段階に分けて個数を数えることができて,
# 1段階目D
# 2段階目DM
# 3段階目DMC
# とすれば考えやすい
# キョウプロ辞めたら？　
def solve():
    n = II()
    s = input().rstrip()
    q = II()
    k = LI()
    for ki in k:
        ans = 0
        d = 0
        dm = 0
        m =0
        for i in range(n):
            if i >= ki:
                if s[-ki +i] == "D":
                    d -= 1
                    dm -= m
                elif s[-ki + i] == "M":
                    m -= 1
            if s[i] == "D":
                d += 1
            elif s[i] == "M":
                m += 1
                dm += d
            elif s[i] == "C":
                ans += dm
        print(ans)
    return


#main
if __name__ == '__main__':
    solve()


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

int main(){
    char S[5];
    int check[4];

    for(int i = 0; i < 4; i++){
        check[i] = 0;
    }

    cin>>S;

    int c = 0;
    for(int i = 0; i < 4; i++){
        c = 0;
        for(int j = i+1; j < 4; j++){
            if(check[j] == 0){
                if(S[i] == S[j]){
                    c++;
                    check[i] = check[j] = 1;
                }
            }
            if(c > 1){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }

    for(int i = 0; i < 4; i++){
        if(check[i] == 0){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;

    return 0;
}

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

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

	int A[n], B[n], C[n - 1], sum = 0;
	for (int i = 0; i < n; ++i) cin >> A[i];
	for (int i = 0; i < n; ++i) {cin >> B[i]; sum += B[i];}
	for (int i = 0; i < n-1; ++i) cin >> C[i];

	for (int i = 1; i < n; ++i) {
		if (A[i] == A[i - 1] + 1) {
			// printf("A[%d] = %d\n", i, A[i]);
			sum += C[A[i - 1] - 1];
		}
	}

	cout << sum << '\n';

	return 0;
}

Measured memory_bytes: 256
import scala.math._

object Main extends App {
 val in = readLine.split("").tail
 val list = for(i <- (0 to in.length - 3)) yield {
   val num = in(i)+in(i+1)+in(i+2)
   abs(num.toInt - 753)
 }
  println(list.min)
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

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

    vi A(N), B(N), C(N-1);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N-1) cin >> C[i];

    int ans = 0;
    REP(i, N) {
        ans += B[A[i] - 1];
        if (A[i-1] + 1 == A[i]) {
            ans += C[A[i-1] - 1];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int a,b;
	cin >> a >> b;
	(a-b >= 0)? cout << a-b : cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long total = 0;
            long input = long.Parse(Console.ReadLine());
            for (int i = 1; i<= input; i++)
            {
                if (i%3 == 0 || i%5 == 0)
                    continue;
                total += i;
            }
            Console.WriteLine(total);
        }
    }
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll h, w;
	cin >> h >> w;
	
	ll ans = min(h,w);
	if(h % 3 == 0 || w % 3 == 0)
	{
		ans = 0;
		cout << ans << endl;
		return 0;
	}
	rep(i,2){
		for(ll tate = 1; tate < h; tate++){
			ll one = tate * w;
			ll two, three;
			if(w % 2 == 0){
				two = three = (h-tate) * (w/2);
				if(chmax(three,one)){
					one = two;
				}
			} else {
				two = (h - tate) * (w/2);
				three = (h - tate) * ((w+1)/2);
				if(two < one){
					three = max(one,three);
					one = two;
				}
			}
			chmin(ans,three-one);
		}
		swap(h,w);
	}
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    ll n[26] = {};
    for(int i=0;i<s.size();i++) {
        n[s[i]-'a']++;
    }

    vector<ll> v;
    for(ll i=0;i<26;i++) {
        if(n[i] != 0)
            v.push_back(n[i]);
    }
    ll ans = 0;
    if(v.size() <= 1) {
        ans = 1;
    } else {
        for(ll i=0;i<v.size()-1;i++) {
            for(ll j=i+1;j<v.size();j++) {
                ans += v[i] * v[j];
            }
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640