akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n, k;
    cin >> n >> k;
    int out = 0;
    for (int i = k - 1; i <= n; i++) {
        int mi = i * (i + 1) / 2;
        int ma = n * (n + 1) / 2 - (n - i - 1) * (n - i) / 2;
        out += ma - mi + 1;
        out %= MOD;
    }
    cout << out % MOD << endl;
    return 0;
}

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

void solve(const string& A, const string& B, string C, vector<int> borrow, int i, int k, int n, int& ans){
	if( i == n ){
		int res = 0;
		reverse(C.begin(),C.end());
		for(int i=0 ; i < C.size() ; i++ ){
			res = res * 10 + C[i] - '0';
		}
		ans = max( ans , res );
		return ;
	}
	int a = A[i] - '0';
	int b = B[i] - '0';
	if( a - borrow[i] >= b ){
		C[i] = (a - borrow[i] - b) + '0';
		borrow[i+1] = 0;
		solve(A, B, C, borrow, i+1, k, n, ans);
	}else{
		C[i] = (a - borrow[i] + 10 - b) + '0';
		if( k ){
			borrow[i+1] = 0;
			solve(A, B, C, borrow, i+1, k-1, n, ans);
		}
		borrow[i+1] = 1;
		solve(A, B, C, borrow, i+1, k, n, ans);
	}
}

int main(){
	string A, B;
	int k;
	cin >> A >> B >> k;
	while( B.size() < A.size() ) B = "0" + B;
	reverse(A.begin(),A.end());
	reverse(B.begin(),B.end());
	string C;
	for(int i=0 ; i < A.size() ; i++ ) C.push_back('0');
	vector<int> borrow(A.size()+1, 0);
	int ans = 0;
	solve(A, B, C, borrow, 0, k, A.size(), ans);
	cout << ans << endl;
}

Measured memory_bytes: 1228
# AOJ 0180 Demolition of Bridges
# Python3 2018.6.22

# UNION-FIND library
class UnionSet:
	def __init__(self, nmax):
		self.size = [1]*nmax
		self.id = [i for i in range(nmax+1)]
	def root(self, i):
		while i != self.id[i]:
			self.id[i] = self.id[self.id[i]]
			i = self.id[i]
		return i
	def connected(self, p, q): return self.root(p) == self.root(q)
	def unite(self, p, q):
		i, j = self.root(p), self.root(q)
		if i == j: return
		if self.size[i] < self.size[j]:
			self.id[i] = j
			self.size[j] += self.size[i]
		else:
			self.id[j] = i
			self.size[i] += self.size[j]
# UNION-FIND library

# 最小全域木。V:総ノード数、E:枝情報(a,b,cost)
def kruskal(V, edge):
	edge2 = sorted(edge, key=lambda x:(x[2]))
	u = UnionSet(V)
	ans = 0
	for e in edge2:
		if not u.connected(e[0], e[1]):
			u.unite(e[0], e[1])
			ans += e[2]
	return ans;

while 1:
	n, m = map(int, input().split())
	if n == 0: break
	edge = []
	for i in range(m):
		s, t, w = map(int, input().split())
		edge.append((s, t, w))
	print(kruskal(n, edge))


Measured memory_bytes: 5616
#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)))
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=0,sum=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  rep(i,n){
    sum-=a[i];
    result+=a[i]*sum;
  }
  printf("%lld",result);
  return 0;
}

Measured memory_bytes: 2176
import math
A,B,H,M=map(int,input().split())
Md=M*6
Hd=H*30+0.5*M

if Hd>Md:
    de=Hd-Md
else:
    de=Md-Hd
C=A**2+B**2-(2*A*B*float(math.cos(math.radians(de))))
C=float(C**0.5)
print(C)

Measured memory_bytes: 9364
from collections import deque
INF = 10**6

n, m = [int(item) for item in input().split()]
edge = [[] for _ in range(n*3)]
for i in range(m):
    u, v = [int(item) for item in input().split()]
    u -= 1; v -= 1
    edge[u*3].append(v*3 + 1)
    edge[u*3 + 1].append(v*3 + 2)
    edge[u*3 + 2].append(v*3)
s, t = [int(item) for item in input().split()]
s -= 1; t -= 1

distance = [INF] * (n * 3)
dq = deque()
dq.append([0, s*3])
while(dq):
    dist, node = dq.popleft()
    if len(edge[node]) == 0:
        distance[node] = dist 
        continue
    if distance[node] != INF:
        continue
    distance[node] = dist 
    dist += 1
    for item in edge[node]:
        dq.append([dist, item])
if distance[t*3] == INF:
    print(-1)
else:
    print((distance[t*3]) // 3)

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

int main() {
  int N;
  cin >> N;
  int a;
  int maxi = 0;
  int mini = 1010;
  for (int i = 0; i < N; i++) {
    cin >> a;
    maxi = max(maxi, a);
    mini = min(mini, a);
  }
  cout << maxi - mini << endl;
  return 0;
}


Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<P> a(n);
  REP(i,n) cin >> a[i].fs >> a[i].sc;
  
  auto comp = [&](P a, P b){
    return min(a.fs,b.fs-a.sc) > min(b.fs,a.fs-b.sc);
  };
  sort(a.begin(),a.end(),comp);

  mat dp(n+1,vec(n+1,INF));
  dp[0][0] = 0;
  REP(i,n){
    REP(j,n+1){
      dp[i+1][j] = min(dp[i+1][j],dp[i][j]); //取らない
      if(dp[i][j] <= a[i].fs) dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+a[i].sc); //取る
    }
  }

  RREP(i,n+1){
    if(dp[n][i] != INF){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 195968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
typedef long long ll;
inline int read() {
	int x=0,s=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') s=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return s*x;
}

const int MAXN=200005,Mo=1000000007;
ll sum[MAXN];
int n,m,q,a[MAXN],b[MAXN],f[MAXN];
#define lowbit(x) ((x)&(-(x)))
void add(int x,int y){ for (;x<MAXN;x+=lowbit(x)) f[x]+=y; }
int getsum(int x){ int y=0; for (;x;x-=lowbit(x)) y+=f[x]; return y; }
int cmp(int i,int j){ return sum[i]<sum[j]; }
int main(){
	n=read(); m=read();
	b[0]=sum[0]=0;
	FOR(i,1,n) a[i]=read()-m,b[i]=i,sum[i]=sum[i-1]+a[i];
	sort(b,b+1+n,cmp);
	//FOR(i,0,n) printf("%lld%c",sum[i]," \n"[i==n]);
	//FOR(i,0,n) printf("%d%c",b[i]," \n"[i==n]);
	int k=1;
	FOR(i,0,n) {
		if (i&&sum[b[i]]!=sum[b[i-1]]) k++;
		a[b[i]]=k;
	}
	//FOR(i,0,n) printf("%d%c",a[i]," \n"[i==n]);
	memset(f,0,sizeof(f));
	ll ans=0;
	FOR(i,0,n) {
		ans+=getsum(a[i]);
		add(a[i],1);
	}
	printf("%lld\n",ans);
	
	return 0;
}

/*
*/


Measured memory_bytes: 4096
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

int main() {
  int k; std::cin >> k;
  int odds = (k+1) / 2;
  int evens = k / 2;
  std::cout << odds * evens << std::endl;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    string ans = "Yes";
    rep(i, n){
        if (h[i-1] < h[i] or i ==0) h[i]--;
    }
    rep(i, n-1){
        if (h[i] > h[i+1]){
            ans = "No";
            break;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 1024
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    //ABCACCBABCBCAABCB
    //AXAAXXAAX
    //XAAAXXAAX
    //XAAXAXAAX
    //XAAXXAAAX
    //XAAXXAAXA

    //XAAXXAXAA
    //XAAXXXAAA
    let mut abc_vec = read_as_string().replace("BC", "X").replace("B", "D").replace("C", "D")
        .split("D").map(|x| x.to_string()).collect::<Vec<String>>();
    let mut counter: usize = 0;

    //println!("{:?}", abc_vec);

    for ax_str in abc_vec{
        let ax_vec = ax_str.match_indices("X").collect::<Vec<(usize, &str)>>();
        
        counter += ax_vec.iter().map(|x| x.0).sum::<usize>();
        let mut numx = ax_vec.iter().count();
        if numx > 0{
            numx -= 1;
        }
        counter -= numx*(numx+1)/2
    }

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


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

int main() {
  int N, P, B;
  P = 1;
  string S;
  cin >> N;
  while( N-P>0){
    cin >> S;
    if(S=="Y"){
      cout << "Four" << endl;
      break;
    }
    P++;
  }
  if( N-P==0){
    if( S=="Y"){
      cout << "Four" << endl;
    }
    else if( S!="Y"){
      cout << "Three" << endl;
    }
  }

}


Measured memory_bytes: 3552
#include <stdio.h>

int main(void)
{
  char s[7];
  int c = 0;
  int i;
  scanf("%s", s);
  for ( i=0; i<6; i++ ) {
    if ( s[i] == '1' ) { c++; }
  }
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;



int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n;
    cin >> n;
    cout << "Christmas";
    n = 25 - n;
    forn(qwe, n)
        cout << " Eve";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cassert>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<vector>
#include<time.h>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(ll i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const ll N=1e4+7;
const ll INF=1e15+7;
ll pos[N],dis[N],Qu[N*90],cur[N];
bool vis[N];
struct edge{ll v,next,c,f;}e[N*2];
ll n,num=0,S,T,ans=0;
void add(ll x,ll y,ll c,ll f){
	e[num]=(edge){y,pos[x],c,f}; pos[x]=num++;
	e[num]=(edge){x,pos[y],0,-f}; pos[y]=num++;
}
bool spfa(){
	ll hd=0,ti=1;
	Qu[1]=S;
	rep(i,n+n+10){
		dis[i]=INF;
		vis[i]=1;
		cur[i]=pos[i];
	}
	dis[S]=0;
	while(hd!=ti){
		ll t=Qu[++hd];
		vis[t]=1;
		repG(i,t){
			if(dis[e[i].v]>dis[t]+e[i].f&&e[i].c){
				dis[e[i].v]=dis[t]+e[i].f;
				if(vis[e[i].v]){
					vis[e[i].v]=0;
					Qu[++ti]=e[i].v;
				}
			}
		}
	}
	return dis[T]<INF;
}
ll dfs(ll x,ll f){
	if(x==T){
		ans+=f*dis[T];
		return f;
	}
	vis[x]=0;
	ll used=0;
	for(;~cur[x];cur[x]=e[cur[x]].next){
		ll i=cur[x];
		if(e[i].c&&dis[e[i].v]==dis[x]+e[i].f&&vis[e[i].v]){
			ll k=dfs(e[i].v,min(e[i].c,f-used));
			used+=k;
			e[i].c-=k;
			e[i^1].c+=k;
		}
		if(used==f)break;
	}
	if(used==f)vis[x]=1;
	return used;
}
int main(){
	memset(pos,-1,sizeof(pos));
	scanf("%lld",&n);
	S=2*n+1;
	T=2*n+2;
	REP(i,2,5)add(n+n+2*i-1,n+n+2*i,INF,0);
	rep(i,n){
		ll c,x,y; scanf("%lld%lld%lld",&x,&y,&c);
		add(S,i,c,0);
		add(i,n+n+3,c,-x-y);
		add(i,n+n+5,c,-x+y);
		add(i,n+n+7,c,x-y);
		add(i,n+n+9,c,x+y);
	}
	rep(i,n){
		ll c,x,y; scanf("%lld%lld%lld",&x,&y,&c);
		add(i+n,T,c,0);
		add(n+n+4,i+n,c,x+y);
		add(n+n+6,i+n,c,x-y);
		add(n+n+8,i+n,c,-x+y);
		add(n+n+10,i+n,c,-x-y);
	}
	while(spfa())dfs(S,INF);
	printf("%lld\n",-ans);
	return 0;
}


Measured memory_bytes: 1024
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc001 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        public main(this: TaskA): void {
            const s:string= this.args[0][0];
            if (s === 'ABC') {
                console.log('ARC');
            }else{
                console.log('ABC');
            }
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}



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

long long int modPow(long long int a, long long int n){//繰り返し自乗法(a^n mod p)。計算量 O(logN)
    long long int p = pow(10, 9) + 7;//任意のp(素数) modのやつで使える 
    if(n == 0){
        return 1;
    }
    if(n == 1){
        return a % p;
    }
    if (n % 2 == 1){ 
        return (a * modPow(a, n - 1)) % p;
    }      
    long long t = modPow(a, n / 2);
    return (t * t) % p;
}

int main(){
    long long int k;
    cin >> k;
    
    long long int count = 1;
    long long int tmp = 0;
    long long int x = 7;
    for(int i = 1; i <= k; i++){
        if((tmp*10 + 7) % k == 0){
            break;
        }else{
            tmp = (tmp*10 + 7) % k;
        }
        //tmp = x % k;
        count++;
    }
    if(count - 1 == k){
        count = -1;
    }
    cout << count << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		n %= 10;
		String result = digit(n);
		System.out.println(result);

	}
	private static String digit(int n) {
		if(n == 3) {
			return "bon";
		} else if (n == 0 || n == 1 || n == 6 || n == 8) {
			return "pon";
		} else {
			return "hon";
		}
	}

}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n){
		cin >> a.at(i);
	}
	ll ans = 0;
	ll sum = 1;
	int ts = 0;
	for(int i=0; i<n; i++){
		int t = ts;
		sum--;
		int f = 0;
		for(int j=i+sum; j<n; j++){
			t = t ^ a.at(j);
			ts += a.at(j);
			if(t != ts){
				f = 1;
				ts -= a.at(j);
				ts -= a.at(j-sum);
				break;
			}
			if(f == 1) break;
			sum++;
		}
		ans += sum;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int N = 2e4 + 4;
int n;
int p[N];
int a[N];
int b[N];
int main(){
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , p + i);
    }
    for(int i = 1 ; i <= n ; ++i){
        a[i] = i * (n + 2);
    }
    for(int i = 1 ; i <= n ; ++i){
        b[p[i]] = 1e9 - a[p[i]] + i;
    }
    for(int i = 1 ; i < n ; ++i){
        assert(a[i] < a[i + 1]);
        assert(b[i] > b[i + 1]);
        assert(a[p[i]] + b[p[i]] < a[p[i + 1]] + b[p[i + 1]]);
    }
    for(int i = 1 ; i <= n ; ++i){
        printf("%d%c" , a[i] , " \n"[i == n]);
    }
    for(int i = 1 ; i <= n ; ++i){
        printf("%d%c" , b[i] , " \n"[i == n]);
    }
}

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

typedef long long ll;

struct Node {
    string pattern;
    ll len,factor;
    vector<Node*> child;
};

int p;

Node *parse(string &s) {
    if(isdigit(s[p])) {
        int r = 0;
        while(isdigit(s[p])) {
            r *= 10;
            r += s[p] -'0';
            p++;
        }

        Node *node = new Node();
        node->factor = r;
        if(s[p] == '(') {
            p++;
            while(s[p] != ')') {
                Node *nr = parse(s);
                node->child.push_back(nr);
            }
            p++;
            node->len = 0;
            for(int i=0; i<node->child.size(); ++i) {
                node->len += node->child[i]->len;
            }
            node->len *= node->factor;
            return node;
        }else{
            node->pattern = string(1,s[p]);
            p++;
            node->len = r;
            return node;
        }
    }

    Node *node = new Node();
    string pattern = "";
    while(p < s.length() && isalpha(s[p])) {
        pattern += string(1,s[p]);
        p++;
    }
    node->pattern = pattern;
    node->len = pattern.length();
    node->factor = 1;
    return node;
}

void dff(Node *v) {
    cout<<v->len<<" -> "<<v->pattern<<endl;
    for(int i=0; i<v->child.size(); ++i)
        dff(v->child[i]);
}

char dfs(Node *v,ll idx) {
    if(v->child.empty()) {
        string pat = v->pattern;
//        cout<<pat.length()<<" "<<v->factor<<" "<<idx<<" "<<pat<<endl;
        if(idx < v->factor*pat.length()) return pat[idx%(pat.length())];
        v->len = pat.length()*(v->factor);
        return '-';
    }

    ll offset = 0;
    for(int i=0; i<v->child.size(); ++i) {
        char c = dfs(v->child[i],idx-offset);
        if(c != '-') return c;
        offset += v->child[i]->len;
    }
    if(idx/offset < v->factor) {
        idx %= offset;
        return dfs(v,idx);
    }
    v->len = offset*v->factor;
    return '-';
}

int main() {
    int n;
    string s;
    while(cin>>s) {
        cin>>n;
        if(s == "0" && n == 0) break;
        p = 0;
        s += ")";
        s = "1(" + s;
        Node *root = parse(s);

//        dff(root);
        char ans = dfs(root,n);
        if(ans == '-') cout<<"0"<<endl;
        else cout<<ans<<endl;
    }
}

Measured memory_bytes: 0
n = int(input())
h = [int(x) for x in input().split()]

INF = 10**10
dp = [INF]*n

dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]))
    dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]))

print(dp[n-1])



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

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

int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if(H%h==0 && W%w==0) fail();
    int MX = 1e9-1;
    int a = MX/(h*w-1);
    cout << "Yes" << endl;
    for(int i=0; i<H; i++) for(int j=0; j<W; j++){
        int v = a;
        if(i%h==h-1 && j%w==w-1) v = -a*(h*w-1)-1;
        cout << v << " \n"[j==W-1];
    }
}

Measured memory_bytes: 2944
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int gcd(int a, int b) {
  while (b) {
    int c = a;
    a = b;
    b = c % b;
  }
  return a;
}

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int best = 1;
  for (int k = 1; k * k <= a[0]; ++k) {
    if (a[0] % k) continue;
    int cnt = 0;
    for (int i = 1; i < n; ++i) {
      cnt += (a[i] % k == 0);
    }
    if (cnt >= n - 2) best = max(best, k);
    cnt = 0;
    int u = a[0] / k;
    for (int i = 1; i < n; ++i) {
      cnt += (a[i] % u == 0);
    }
    if (cnt >= n - 2) best = max(best, u);
  }
  int g = a[1];
  for (int i = 2; i < n; ++i) {
    g = gcd(g, a[i]);
  }
  best = max(best, g);
  printf("%d\n", best);
  return 0;
}


Measured memory_bytes: 768
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = a%500;
       
      if(b>=x){
      System.out.print("Yes");
      }else{
      System.out.print("No");
      }
      
    }
}

Measured memory_bytes: 23764
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> Int -> String
solve k x = let
    minV :: Int
    minV = max (-1000000) $ x - k + 1
    maxV :: Int
    maxV = min 1000000 $ x + k - 1
    in
        unwords $ show <$> [minV .. maxV]


main = do
    (k,x) <- readTuple2
    putStrLn $ solve k x


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

class Program
{
    public static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int A = int.Parse(str[0]);
        int B = int.Parse(str[1]);
        int C = int.Parse(str[2]);
        long ans = 0;
        if(C <= B+1)
        {
            ans = B + C;
            Console.WriteLine(ans.ToString());
            return;
        }
        C -= (B + 1);
        ans += 2 * B + 1;
        if(C <= A)
        {
            ans += C;
        }
        else
        {
            ans += A;
        }
        Console.WriteLine(ans.ToString());
        return;
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
	int n;
	cin >> n;
	n/=2;
	int i=1;
	while(i<=n){
		i*=2;
	}
	cout << i << "\n";
}




Measured memory_bytes: 3636
x = list(map(int, input().split()))
ans = 0
man = 0
gosen = 0
sen = 0
y = x[0]+1
for i in range(y):
  for j in range(y-i):
    if i*10000+j*5000+(x[0]-i-j)*1000 == x[1]:
      man = i
      gosen = j
      sen = x[0]-i-j
      ans = 1
      break
if ans == 1:
  print(str(man)+' '+str(gosen)+' '+str(sen))
else:
  print('-1 -1 -1')

Measured memory_bytes: 66912
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct Data{int place,num;};
bool operator<(Data a,Data b){return a.num!=b.num?a.num>b.num:a.place<b.place;}
int main()
{
  int n,m,place;
  vector<Data>vote;
  while(cin>>n>>m,n|m){
    vote.resize(m);
    for(int i=0;i<m;i++){
      vote[i].place=i+1;
      vote[i].num=0;
    }
    while(n-->0){
      for(int i=0;i<m;i++){
	cin>>place;
	vote[i].num+=place;
      }
    }
    sort(vote.begin(),vote.end());
    for(int i=0;i<m;i++){
      cout<<vote[i].place;
      if(i<m-1)cout<<" ";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 908
#include <iostream>

using namespace std;

int main(){
	int N, total, total2;
	int x[400], y[400], b[400], p[400];

	cin >> N;

	for (int i = 0; i < N; i++){
		cin >> x[i] >> y[i] >> b[i] >> p[i];

		total = (x[i] * b[i]) + (y[i] * p[i]);
		
		if (b[i] < 5){
			b[i] = 5;
		}
		if (p[i] < 2){
			p[i] = 2;
		}

		total2 = (x[i] * b[i]) + (y[i] * p[i]);
		total2 *= 0.8;
		
		if (total > total2){
			cout << total2 << endl;
		}
		else {
			cout << total << endl;
		}
	}

}

Measured memory_bytes: 3104
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N;    cin >> N;
    int D, X; cin >> D >> X;
    
    int sum=0;
    for(int n=0; n<N; ++n){
        int A; cin >> A;
        for(int i=0; A*i+1 <= D; ++i){
            ++sum;
        }
    }
    
    cout << sum+X << endl;
    
    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int N; readf("%d\n", &N);
    auto A = readln.chomp.split(" ").map!(to!int).array;
    auto c = new int[9];
    foreach (a; A) {
        int x = min(a, 3200);
        c[x / 400] += 1;
    }
    int ans = 0;
    foreach (i; 0 .. 8) {
        if (c[i] > 0) ans++;
    }
    if (c[8] == 0) {
        writefln("%s %s", ans, ans);
    } else {
        int ans_min = ans, ans_max = ans + c[8];
        if (ans == 0) {
            ans_min = 1;
        }
        writefln("%s %s", ans_min, ans_max);
    }
}


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

struct Node {
  int key;
  Node *right, *left, *parent;  
};

Node  *NIL;

struct BST {
  Node *root;

  BST() {
    root = NIL;
  }

  void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z = (Node *)malloc(sizeof(Node));    
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while ( x != NIL ) {
      y = x;
      if ( z->key < x->key ) {
	x = x->left;
      } else {
	x = x->right;
      }
    }

    z->parent = y;
    if ( y == NIL ) {
      root = z;
    } else {
      if ( z->key < y->key ) {
	y->left = z;	
      } else {
	y->right = z;
      }
    }
  }
};

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);  
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);  
}

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

  BST bst;
  while ( m-- ) {
    string c;
    cin >> c;
    if ( c == "insert" ) {
      int n;
      cin >> n;
      bst.insert(n);      
    } else {
      inorder(bst.root);
      cout << endl;
      preorder(bst.root);
      cout << endl;      
    }
  }
  
  return 0;
}




Measured memory_bytes: 26580
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

signed main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int cnt = 0;
    rep(i, n) rep(j, i) rep(k, j) {
        if(a[i] == a[j] || a[j] == a[k] || a[k] == a[i]) continue;
        int s = a[i] + a[j] + a[k];
        int x = max({a[i], a[j], a[k]});
        int y = s - x;
        if(y > x) {
            cnt++;
        }
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3636
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    count_x2 = 0
    count_x4 = 0

    for aa in a:
        if aa % 4 == 0:
            count_x4 += 1
        elif aa % 2 == 0:
            count_x2 += 1

    if count_x4 >= n//2:
        print('Yes')
        exit()
    tmp = n - count_x2
    if tmp % 2 == 0:
        if count_x4 >= tmp // 2:
            print('Yes')
            exit()
    else:
        if count_x4 >= tmp // 2 + 1:
            print('Yes')
            exit()
    if count_x2 == n:
        print('Yes')
        exit()

    print('No')


Measured memory_bytes: 14224
# 1つ以上は必ず2で割らないと行けない->ai%2==0の要素が少なくとも1つ必要
# odd * 3 => odd, even * 3 => even,3倍の操作で偶奇は入れ替わらない
# ->すべての偶数に対してai/2の操作を繰り返せる回数の合計が最大の操作回数
# 1 000 000 000 < 2^30

N = int(input())
list = [int(i) for i in input().split() if int(i) % 2 == 0]
count = 0
for i in list:  # max 10000 loops
    while i % 2 == 0:  # max 30 loops
        i = i / 2
        count = count + 1
print(count)
# 計算量 O(10 ^ 5)?


Measured memory_bytes: 4140
require "set"

def bingo(cnt, f)
  if f
    true
  else cnt == 3   end
end

A = 3.times.map { gets.chomp.split }
N = gets.chomp.to_i
B = N.times.map { gets.chomp }.to_set

f = false

for i in 0..2
  cnt = 0
  for j in 0..2
    if B.include?(A[i][j])
      cnt += 1
    end
  end
  f = bingo(cnt, f)

  cnt = 0
  for j in 0..2
    if B.include?(A[j][i])
      cnt += 1
    end
  end
  f = bingo(cnt, f)
end

cnt = 0
for i in 0..2
  if B.include?(A[i][i])
    cnt += 1
  end
end
f = bingo(cnt, f)

cnt = 0
for i in 0..2
  if B.include?(A[i][2 - i])
    cnt += 1
  end
end
f = bingo(cnt, f)

if f
  puts "Yes"
else
  puts "No"
end


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

long long a,b,c,d,e,ans;
int janken(char cc){
  if(cc=='r')return e;
  else if(cc=='s')return c;
  else return d;
}

int main(){
  string h;
  cin>>a>>b>>c>>d>>e>>h;
  
  for(int i=0;i<a;++i){
    if(i<b){ans+=janken(h[i]);}
    else{
      if(h[i]!=h[i-b]){ans+=janken(h[i]);}
      else{h[i]='u';}
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 512
import sys
 
 
a = int(sys.stdin.readline().strip())
b = int(sys.stdin.readline().strip())
c = int(sys.stdin.readline().strip())
d = int(sys.stdin.readline().strip())
e = int(sys.stdin.readline().strip())
k = int(sys.stdin.readline().strip())



l = [a,b,c,d,e]
l.sort(reverse=True)


#flag = 1
#while(flag == 1):
if(l[0]-l[-1] > k):
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int n;
  scanf("%d",&n);

  n = n % 1000;
  if(n==0) n=1000;
  n = 1000 - n;

  printf("%d\n",n);

  return 0;
}

Measured memory_bytes: 1728
from collections import deque
INF = 10 ** 10

def search(nowi, nowj, next, root, yoko, tate):
    global INF
    if nowi == h - 1 and nowj == w - 1:
        return root[nowi][nowj]
    # print(nowi, nowj, len(yoko), len(tate), h, w, yoko, tate)
    dis = root[nowi][nowj]
    if 0 < nowi:
        if root[nowi - 1][nowj] == INF and tate[nowi - 1][nowj] == 0:
            next.append([nowi - 1, nowj])
            root[nowi - 1][nowj] = dis + 1
    if 0 < nowj:
        if root[nowi][nowj - 1] == INF and yoko[nowi][nowj - 1] == 0:
            next.append([nowi, nowj - 1])
            root[nowi][nowj - 1] = dis + 1
    if nowi < len(root) - 1:
        if root[nowi + 1][nowj] == INF and tate[nowi][nowj] == 0:
            next.append([nowi + 1, nowj])
            root[nowi + 1][nowj] = dis + 1 
    if nowj < len(root[nowi]) - 1:
        if root[nowi][nowj + 1] == INF and yoko[nowi][nowj] == 0:
            next.append([nowi, nowj + 1])
            root[nowi][nowj + 1] = dis + 1
    if len(next) == 0:
        return 0
    nextij = next.popleft()
    nexti = nextij[0]
    nextj = nextij[1]
    return search(nexti, nextj, next, root, yoko, tate)


while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0:
        break
    yoko = []
    tate = []

    for i in range(2 * h - 1):
        if i % 2 == 0:
            yoko.append(list(map(int, input().split())))
        else:
            tate.append(list(map(int, input().split())))
    
    root = [[INF for _ in range(w)] for _ in range(h)]
    root[0][0] = 1
    next = deque()
    print(search(0, 0, next, root, yoko, tate))
    


Measured memory_bytes: 6960
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	for(long long i=1;i<=3500;i++)
		for(long long j=i;j<=3500;j++){
			long long a=n*i*j;
			long long b=4*i*j-i*n-j*n;
			if(b!=0&&a/b*b==a){
				long long k=a/b;
				if(k>0){
					printf("%I64d %I64d %I64d\n",i,j,k);
					return 0;
				}
			}
		}
			
}

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

const int N = 100005;

int n, m, q;
int a[N];
vector<int> vec[N];
priority_queue < pair<int, int> > pq;
int last[N];
bool del[N];

// BIT
int T[N];
void upd(int x) { for (; x <= m; x += x & -x) T[x]++; }
int get(int x) { int ret = 0; for (; x > 0; x -= x & -x) ret += T[x]; return ret; }
int get_min() {
	int low = 1, high = m;
	while(low < high) {
		int mid = ((low + high) >> 1);
		if (get(mid) == mid) low = mid + 1;
		else high = mid;
	}
	return low;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> q;
	for (int i = 1; i <= q; ++i) {
		cin >> a[i];
		pq.push(make_pair(i, a[i]));
		vec[a[i]].push_back(i);
	}
	for (int i = 1; i <= n; ++i) last[i] = q + 1;

	while(!pq.empty()) {
		pair<int, int> top = pq.top(); pq.pop();
		if (del[top.second]) continue;
		int x = top.second;
		del[x] = true;

		int ptr = n;
		while(ptr >= 1 && !vec[x].empty()) {
			int pos = vec[x].back();
			vec[x].pop_back();
			if (last[ptr] > pos) last[ptr] = pos, --ptr;
		}
		// cerr << x << endl;
		// for (int i = 1; i <= n; ++i) cerr << last[i] << ' '; cerr << endl;
		
		if (ptr != 0) { // invalid
			int smallest = get_min();
			if (x != smallest) return cout << "No\n", 0;
			upd(x); // delete x

			while(!pq.empty()) {
				top = pq.top(); pq.pop();
				int nx = top.second;
				if (del[nx]) continue;

				del[nx] = true;
				smallest = get_min();
				if (nx != smallest) return cout << "No\n", 0;
				upd(nx);
			}

			return cout << "Yes\n", 0;
		}

		upd(x); // delete x
	}

	cout << "Yes\n";
}

Measured memory_bytes: 7796
#include "bits/stdc++.h"

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

const double PI = 3.14159265358979323846;

int main()
{
	int64_t a, b, k;
	cin >> k >> a >> b;
	auto temp = k;
	for (auto i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			puts("OK");
			temp = -1;
			break;
		}
	}

	if (!(temp < 0))
	{
		puts("NG");
	}
	return 0;
	
	
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
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; }

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

int main(){
    int n; cin >> n;
    int 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 res = 0;
    rep(i, n){
        int read_a=a[i];
        res+=b[a[i]-1];
        if(a[i+1]==a[i]+1&&i!=n-1) res+=c[a[i]-1];
    }
    out(res);
}

Measured memory_bytes: 3588
#include<stdio.h>
    int main()
    {
        int N,i,j,k;
        int data[100001];
        scanf("%d", &N);
        for(i=0;i<N;i++){
        scanf("%d", &data[i]);
        }
        j=data[0];
        for(i=0;i<N;i++){
          if(j==2) {
          printf("1\n");
          break;
        }
          k=data[j-1];
          j=k;
            if(k == 2){
            printf("%d \n",i+2);
            break;
          }
          if(i== N-1) printf("-1\n");
        }
        return 0;
    }

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int A, B, C, X;
int a = 0, b = 0, c = 0;
int num = 0;

int main() {
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;

	c = X / 50;

	for (int _c = c; _c >= 0; _c -= 2, b += 1) {
		for (int _a = a, _b = b; _b >= 0; _b -= 5, _a += 1) {
			//cout << _a << ", " << _b << ", " << _c << endl;
			if (_a <= A && _b <= B && _c <= C) num++;
		}
	}

	cout << num << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
# m = map(int, raw_input().split())
# a, b, c = map(int, raw_input().split())
s = raw_input()
t = raw_input()
ans = 0
for i in xrange(3):
  if s[i] == t[i]:
    ans += 1
print ans
# l = raw_input().split()
# n = int(raw_input())


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
long long int fact(int a);
int main(){
  int n,m;
  cin >> n >> m;
  if(abs(n-m) >= 2){
    cout << 0;
    return 0;
  }
  long long int ans=(fact(n)*fact(m))%mod;
  if(abs(n-m) == 1){
    cout << ans;
  }
  if(abs(n-m) == 0){
    cout << ans*2%mod;
  }
}

long long int fact(int a){
  long long int ans = 1;
  for(int i=1;i<=a;i++){
    ans = (ans*i)%mod;
  }
  return ans%mod;
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<int> second(101,0);
    rep(i,101){
        if(a < i && i <= b){
            second.at(i) ++;
        }
        if(c < i && i <= d){
            second.at(i) ++;
        }
    }
    //second==2が二人ともスイッチを押している時間
    int count=0;
    rep(i,101){
        if(second.at(i) == 2) count ++;
    }
    cout << count << endl;

    
}

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

using namespace std;

int main() {

    int n, q, S[100000], T[50000];

    cin >> n;
    for (int i = 0; i < n; i++) cin >> S[i];

    cin >> q;
    for (int i = 0; i < q; i++) cin >> T[i];

    int ans = 0;

    sort(S, S + n);
    for (int i = 0; i < q; i++) {
        int left, right;
        left = 0;
        right = n;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (S[mid] < T[i]) {
                left = mid + 1;
            } else if (S[mid] > T[i]) {
                right = mid;
            } else {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3620
n , y= map(int, input().split())
ans = 0
li = []
for i in range(n+1):
    for j in range(n+1):
        if 10000 * i + 5000*j +1000 * (n-i-j) == y and n-i-j >= 0:
            print(i, j, n-i-j)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size()) is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) { return false; }
    }

    return true;
};

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

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

template <class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N, M;
    cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256