akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef pair< int , int > P;
typedef pair< pair< int , P > , pair< P , bool > > PP;
//コスト,左座標,右座標,次どっちの足？(true:左,false:右)
#define fr first
#define sc second
#define MAX_W 30
#define MAX_H 60
#define mp(a,b) make_pair(a,b)

const int dx[]={1,1,1,1,1,2,2,2,3},dy[]={2,1,0,-1,-2,1,0,-1,0};
int w,h;
char mas[MAX_H][MAX_W];

bool over(int nx,int ny){
  return nx < 0 || nx >= w || ny < 0 || ny >= h;
}

int bfs(vector<P>& st){
  map< pair< pair< P , P > , bool > , bool > used;
  priority_queue< PP , vector<PP> , greater<PP> > que;
  for(int i = 0 ; i < st.size() ; i++ ){
    que.push(PP(mp(0,st[i]),mp(P(-1,-1),false)));
    que.push(PP(mp(0,P(-1,-1)),mp(st[i],true)));
  }
  while(!que.empty()){
    PP p = que.top();
    que.pop();
    if(used[mp(mp(p.fr.sc,p.sc.fr),p.sc.sc)]++) continue;
    if(mas[p.fr.sc.fr][p.fr.sc.sc] == '0') return p.fr.fr;
    if(mas[p.sc.fr.fr][p.sc.fr.sc] == '0') return p.fr.fr;
    for(int i = 0 ; i < 9 ; i++ ){
      if(p.sc.sc){ // 左足を動かす
        int ny = p.sc.fr.fr + dy[i] , nx = p.sc.fr.sc - dx[i];
        if(over(nx,ny) || mas[ny][nx] == 'X') continue;
        que.push(PP(mp(p.fr.fr+(mas[ny][nx]-'0'),P(ny,nx)),mp(p.sc.fr,false)));
      }else{ //右足を動かす
        int ny = p.fr.sc.fr + dy[i] , nx = p.fr.sc.sc + dx[i]; // p.sc.fr.sc + dx[i]
        if(over(nx,ny) || mas[ny][nx] == 'X') continue;
        que.push(PP(mp(p.fr.fr+(mas[ny][nx]-'0'),p.fr.sc),mp(P(ny,nx),true)));
      }
    }
  }
  return -1;
}

int main(){
  while(cin >> w >> h , w){
    vector<P> st;
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        cin >> mas[i][j];
        if(mas[i][j] == 'S') st.push_back(P(i,j));
        if(mas[i][j] == 'T') mas[i][j] = '0';
      }
    }
    cout << bfs(st) << endl;
  }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    ll ans=0;
    rep(i,n)FOR(j,i+1,n-1){
        int t = a[i]+a[j];
        ans += lower_bound(a.begin()+(j+1), a.end(), t)-(a.begin()+(j+1));
    }
    cout<<ans<<"\n";
    return 0;
}


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

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

typedef long long Int;

Int MAX_N;
vector<int> par(500000); //親
vector<int> tree_rank(500000); // 木の深さ
vector<int> sz(500000); //根について，それを含む集合の大きさ

//n要素で初期化
void init(int n) {
    rep(i,n) {
        par[i] = i;
        tree_rank[i] = 0;
        sz[i] = 1;
    }
}

//木の根を求める
int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    int total = sz[x] + sz[y];
    sz[x] = total;
    sz[y] = total;

    if (tree_rank[x] < tree_rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (tree_rank[x] == tree_rank[y]) tree_rank[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y) {
    return find(x) == find(y);
}

int main() {


    int N, M;

    cin >> N >> M;

    vector<int> a(M), b(M);
    rep(i,M) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    int cnt = 0;

    rep(i,M) {
        init(N);
        rep(j,M) {
            if (j != i) {
                unite(a[j],b[j]);
            }
        }
        if (sz[find(0)] != N) cnt++;
    }

    cout << cnt << endl;



    return 0;
}


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

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

    set<int> S;
    rep(i, N){
        int A;
        cin >> A;
        S.insert(A);
    }

    if(S.size() == N)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    vector<int> a(5);
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    int k;
    cin >> k;
    for(int i = 0; i < 4; i++){
        for(int j = i + 1; j < 5; j++){
            if(a[j] - a[i] > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!"<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (1000000000+7)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
 
 
 
int main(void){
    ll n;
    cin>>n;
    ll t = n;
    map<ll,ll>cnt;
    for(ll p=2;p*p<=n;p++){
        if(t%p==0){
            ll num = 0;
            while(true){
                if(t%p==0)num++,t/=p;
                else break;
            }
            cnt[p]=num;
        }
        else continue;
    }
    if(t>1)cnt[t]=1;
    //cout<<t<<endl;
    ll ans = 0;
    for(auto itr = cnt.begin();itr!=cnt.end();++itr){
        ll prime = itr->first;
        ll num = itr->second;
        ll c=1;
        //cout<<num<<endl;
        for(c=1;;c++){
            ll k = c*(c+1)/2;
            if(num<k){
                ans+=c-1;
                break;
            }
            else{
                if(num==k){
                    ans+=c;
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
    int N,M,p=1,q=1;
    scanf("%d",&N);
    p=N;
    while(N>0){
        N=N/10;
        M++;
        q=q*10;
    }
    if(M%2==0){
        if(M==2){
            printf("9");
        }else if(M==4){
            printf("909");
        }else{
            printf("90909");
        }
    }else{
        if(M==1){
            printf("%d",p);
        }else if(M==3){
            printf("%d",p-90);
        }else{
            printf("%d",p-9090);
        }
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x;
	cin >> x;
		
	int y500, y5;
	y500 = x/500;
	x = x - 500*y500;
	y5 = x/5;
	
	cout << y500*1000 + y5*5 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int maxn = 5005;
const int mod = 998244353;
const lli inf = 4e18;
int tam[maxn],ciclo[maxn],used[maxn];
lli val[maxn];
int p[maxn];
lli c[maxn];
int n;

void getciclo(int x){
	bool f= false;
	int og = x;
	lli v = 0ll;
	int sz = 0;
	while(sz < maxn){
		if(used[x] == og){
			if(x == og) f = true;
			break;
		}
		used[x] = og;
		int mov = p[x];
		x = mov;
		v+=c[mov];
		sz++;
	}

	if(sz == maxn) return;

	if(f){
		x = og;
		tam[x] = sz;
		ciclo[x] = 1;
		val[x]=v;
	}
}

void solve(){
	cin >> n;
	int k;
	cin >> k;
	for(int i=1; i <=n; i++) cin >> p[i];
	for(int i=1; i <=n; i++) cin >> c[i];
	
	for(int i=1; i <=n; i++){
		getciclo(i);
	}

	lli ans = -inf;
	int pastk = k;
	for(int i=1; i <=n; i++){
		int curr = i;
		lli sum =0ll;
		lli res = -inf;
		k = pastk;
		while(k){
			if(ciclo[curr]){
				//terminamos en el ciclo
				if(val[curr] > 0){
					//meconviene tomarlo muchas veces
					int veces = k/tam[curr];
					if(veces){
						sum+= 1ll * (veces-1) * val[curr];
						k-= (veces-1) * tam[curr];
					}
					res = max(res,sum);
					int og = curr;
					for(int j=0; k; j++){
						sum+=c[p[curr]];
						curr = p[curr];
						k--;
						res = max(res,sum);
					}
				}
				else{
					int og = curr;
					for(int j=0; j < tam[og] && k; j++){
						sum+=c[p[curr]];
						curr = p[curr];
						k--;
						res = max(res,sum);
					}
				}
				break;
			}
			else{
				sum+=c[p[curr]];
				curr = p[curr];
				res = max(res,sum);
			}
			k--;
		}
		ans = max(ans,res);
	}

	cout << ans << endl;
}

int main(){__
	int t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3796
#include <cstdio>
#include <algorithm>
#include <ctime>
using namespace std;

#define int long long

int n,a,b,c,d;

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar(),t=-1;
	if(c=='-')c=getchar(),t=-1;
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return s*t;
}

signed main(void){
	n=read();
	a=read();
	b=read();
	c=read();
	d=read();
	for(int i=1;i<n;i++){
		if(i*c-(n-1-i)*d<=b-a&&b-a<=i*d-(n-1-i)*c){
			printf("YES");
			return 0;
		}
	}
	printf("NO");
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=2019;
const int INF=1e15;

int powMod(int x,int r){
    if(r==0)return 1;
    if(r%2==0) return powMod(x,r/2)*powMod(x,r/2)%MOD;
    if(r%2==1) return powMod(x,r-1)*x%MOD;
}

signed main(){
    string S;cin>>S;
    int ans=0;
    vector<int>rSmod(S.size());
    map<int,int>memo;
    REP(i,S.size()){
        int b=S[S.size()-1-i]-'0';
        if(i==0) rSmod[i]=b%MOD;
        else{
          	int x=powMod(10,i);
			rSmod[i]=(rSmod[i-1]+b*x)%MOD;
        }
        memo[rSmod[i]]++;
    }
  	memo[0]++;
    for(auto it=memo.begin();it!=memo.end();it++){
            ans+=it->second*(it->second-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5176
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c&&a==c)
    cout<<"No";
    else if(a==b||b==c||a==c)
    cout<<"Yes";
    else 
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	int N, K;
	List<Integer> h;
	long[] costs;

	Main() {
		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		K = in.nextInt();
		h = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			h.add(in.nextInt());
		}
		in.close();

		costs = new long[N];
		costs[0] = 0;
		for (int i = 1; i < Math.min(K, N); ++i) {
			costs[i] = Math.abs(h.get(i) - h.get(0));
		}
	}

	void calc() {
		for (int i = 1; i < N; ++i) {
			int start = Math.max(0, i - K);
			long diffMin = Long.MAX_VALUE;
			for (int j = start; j < i; ++j) {
				diffMin = Math.min(diffMin, Math.abs(h.get(i) - h.get(j)) + costs[j]);
				// System.out.println(i + ", " + j + ", " + diffMin);
			}
			costs[i] = diffMin;
		}
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		System.out.println(ins.costs[ins.N - 1]);
	}

}

Measured memory_bytes: 63876
import itertools

N=int(input())
P=tuple(map(int, input().split()))
Q=tuple(map(int, input().split()))
A=list(range(1,N+1))

Pattern=[]
for i in itertools.permutations(A):
    Pattern.append(i)

c1=Pattern.index(P) + 1
c2=Pattern.index(Q) + 1

print(abs(c1-c2))

Measured memory_bytes: 7924
N = int(input())
W = [input() for _ in range(N)]

t = "Yes"

li_uniq = []
for x in W:
    if x not in li_uniq:
        li_uniq.append(x)


if W == li_uniq:
    for i in range(N - 1):
        if W[i][-1] == W[i+1][0]:
            continue
        else:
            t = "No"
else:
    t = "No"

print(t)

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main() {
    int num = 0;
    int n, k;
    cin >> n >> k;

    int height = 0;
    for(int i = 0; i < n; ++i){
        cin >> height;
        if(height >= k) num++;
    }

    cout << num;
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
  int n, x;
  cin >> n >> x;
  ll a[n];
  REP(i, n) cin >> a[i];
  sort(a, a+n);
  int ans = 0;
  REP(i, n-1) a[i+1] += a[i];
  if(x == a[n-1]){
    cout << n << endl;
  }
  else if(x > a[n-1]){
    cout << n-1 << endl;
  }
  else{
    while(a[ans] <= x) ans++;
    cout << ans << endl;
  }
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,cou;
    char S[4];
    scanf("%s",&S);
    for(int i=0;i<4;i++){
        if(S[i]=='+'){
            cou++;
        }else{
            cou--;
        }
    }
    
    printf("%d",cou);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve()
{
    string s;
    int i,d;
    char c;
    cin>>s;
    d=s.size();
    c=s[d-1];
    if(c=='s'){
        cout<<s;
        cout<<"es"<<endl;return;
    }
    else{
        cout<<s;
        cout<<"s"<<endl;return;
    }
}
int main()
{
    solve();
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)x.size())
const int N=200010;
const int mod=1e9+7;
int n,a[N],dp[N],mk[N],nxt[N];
int main(){
	cin>>n;
	ref(i,1,n)cin>>a[i];
	def(i,n,1){
		if(mk[a[i]])nxt[i]=mk[a[i]];
		mk[a[i]]=i;
	}
	dp[1]=1;
	ref(i,1,n){
		(dp[i+1]+=dp[i])%=mod;
		if(nxt[i]>i+1)(dp[nxt[i]]+=dp[i])%=mod;
	}
	//ref(i,1,n)cout<<dp[i]<<" ";puts("");
	cout<<dp[n+1]<<endl;
}

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

int main(int argc, char const *argv[])
{
	ll n, ans = 0;
	bool f = 0;
	cin >> n;
	vector<ll> a(n), v((ll)1e6+5, 0);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		v[a[i]]++;
	}

	if(v[1] > 1)
		ans = 0;
	else if(v[1] == 1)
		ans = 1;
	else
		goto next;

	cout << ans;
	return 0;

	next:
	for (int i = 0; i < n; i++)
	{
		if(v[a[i]] > 1)
			continue;
		
		f = 0;
		for (int j = 2; j*j <= a[i]; ++j)
		{
			if(a[i] % j == 0)
			{
				int x = j, y = a[i]/j;
				if(v[x] > 0 || v[y] > 0)
				{
					f = 1;
					break;
				}
			}
		}
		if(!f)
			ans++;
	}

	end:
	cout << ans;

	return 0;
}

Measured memory_bytes: 12668
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  // n 以下で x % k == 0 の個数
  int a = n / k;
  ans += pow(a, 3);
  if (k % 2 == 0) {
    // n 以下で x % k == k/2 の個数
    int tmp = 0;
    for (int i = 1; i <= n; i++) {
      if (i % k == k / 2) tmp++;
    }
    ans += pow(tmp, 3);
  }

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


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
using namespace std;
typedef long long ll;
#define rep(i, N) for(ll)=0;(i)<(N);(i)++)

int main(){
  int n;
  cin >> n;
  int s = 0;
  int tmp = n;
  while(tmp > 0){
    s += tmp % 10;
    tmp /= 10;
  }
  if(n % s) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
import collections

YES="Yes"
NO="No"

N=int(input())
a=list(map(int, input().split()))

c = collections.Counter(a)
l_c = len(c)
if l_c == 1:
    if c[0] == N:
        print(YES)
    else:
        print(NO)
elif l_c == 2:
    v = list(c.values())
    if min(v) * 2 == max(v):
        k = list(c.keys())
        k_few = k[v.index(min(v))]
        k_many = k[v.index(max(v))]
        if k_few ^ k_many == k_many:
            print(YES)
        else:
            print(NO)
    else:
        print(NO)
elif l_c == 3:
    v = list(c.values())
    if v[0] == v[1] == v[2]:
        k = list(c.keys())
        if k[0] == k[1] ^ k[2]:
            print(YES)
        else:
            print(NO)
    else:
        print(NO)
else:
    print(NO)
    

Measured memory_bytes: 14460
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> X){
  ll ans = 100000000000;
  for(ll i=0; i<=100; i++) {
    ll s = 0;
    for(ll j=0; j<N; j++) {
      s+=(X[j]-i)*(X[j]-i);
    }
    ans = min(ans, s);
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> X(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&X[i]);
  }
  solve(N, std::move(X));
  return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

//Range Minimum Query
struct segment {
    int n;
    vector<int64_t> dat;
    // n_は範囲
    segment(int n_) { // nはn_以上の2^?
        n = 1<<(32-__builtin_clz(n_));
        if(n == 2*n_) n >>= 1;
        dat.assign(2*n-1, LINF);
    }
    //更新の手順
    inline int64_t theorem(int i) {
        int64_t chld = dat[i*2+1];
        int64_t chrd = dat[i*2+2];
        return min(chld, chrd);
    }
    inline int chld(int i) {return 2*i+1;}
    inline int chrd(int i) {return 2*i+2;}
    //初期化(初期状態はLINF)
    void init(const vector<int64_t> &vec) {
        int num = vec.size();
        rep(i, num) {
            dat[i+n-1] = vec[i];
        }
        rep(i, n-1) {
            dat[n-2-i] = theorem(n-2-i);
        }
    }
    // k番目の値をaに変更
    void update(int k, int64_t a) {
        // 葉の節点
        k += n-1;
        dat[k] = min(dat[k], a);
        // 登りながら更新
        while(k>0) {
            k = (k-1)/2;
            dat[k] = theorem(k);
        }
    }
    //kは節点の番号, [l, r)に節点が対応
    // (a, b, 0, 0, .n)で呼ぶ
    int64_t query_(int a, int b, int k, int l, int r) {
        if(a>=r || l>=b) return LINF;
        if(a<=l && r<=b) return dat[k];
        else {
            int chl = k*2+1;
            int chr = k*2+2;
            int64_t vl = query_(a, b, chl, l, (l+r)/2);
            int64_t vr = query_(a, b, chr, (l+r)/2, r);
            return min(vl, vr);
        }
    }
};

struct edge{
    int l, r;
    ll c;
    edge(){}
    edge(int l, int r, ll c):l(l), r(r), c(c) {}
    bool operator<(edge pp) {
        if(l == pp.l) {
            return r < pp.r;
        } else {
            return l < pp.l;
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<edge> G(m);
    rep(i, m) {
        int l, r;
        ll c;
        cin >> l >> r >> c;
        G[i] = edge(l, r, c);
    }
    sort(all(G));

    segment seg(n);
    seg.update(0, 0);

    rep(i, m) {
        ll num = seg.query_(G[i].l-1, G[i].r, 0, 0, seg.n);
        seg.update(G[i].r-1, num+G[i].c);
    }

    ll ans = seg.dat[seg.n-1+n-1];
    if(ans == LINF) ans = -1;
    cout << ans << endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    int N; cin >> N;
    vi p(N+1); REP1(i, N) cin >> p[i];

    int ans = 0;
    REP1(i, N-1)
    {
        if(p[i] == i)
        {
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    if(p[N] == N) ans++;
    cout << ans << endl;
}

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

    return 0;
}

Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	set<ll>s; REP(i, 3)s.insert(in()); cout << s.size() << endl;
}

Measured memory_bytes: 256
def prime_table(n):
    prime = [True] * (n+1)
    for i in range(2,n+1):
        if not prime[i]: continue
        for j in range(i+i, n+1, i):
            prime[j] = False
    return prime

X = int(input())
is_prime = prime_table(10**6)
for i in range(X, 10**6):
    if is_prime[i]:
        print(i)
        break

Measured memory_bytes: 16564
#include <iostream>
#include <cstdio>
#include <queue>
const int MAXN = 50 ;
using namespace std ;

struct Node {
	int x , y , s ;
	Node ( int a , int b , int c ) : x ( a ) , y ( b ) , s ( c ) { } 
} ;

queue < Node > Q ;
int v[5][3] ;
char c[MAXN + 5][MAXN + 5] ;
bool vis[MAXN + 5][MAXN + 5] ;

int main ( ) {
	v[1][1] = 1 , v[1][2] = 0 ;
	v[2][1] = 0 , v[2][2] = 1 ;
	v[3][1] = -1 , v[3][2] = 0 ;
	v[4][1] = 0 , v[4][2] = -1 ;
	
	int n , m , sum = 0 ;
	
	cin >> n >> m ;
	
	for ( int i = 1 ; i <= n ; ++i )
		for ( int j = 1 ; j <= m ; ++j ) {
			cin >> c[i][j] ;
			if ( c[i][j] == '#' ) ++sum ;
		}
	
	
	Q.push ( Node ( 1 , 1 , 1 ) ) , vis[1][1] = true ;
	
	while ( !Q.empty ( ) ) {
		Node cur = Q.front ( ) ; Q.pop ( ) ;
		int x = cur.x , y = cur.y , s = cur.s ;
		for ( int i = 1 ; i <= 4 ; ++i ) {
			int tx = x + v[i][1] , ty = y + v[i][2] ;
			if ( tx > 0 && tx <= n && ty > 0 && ty <= m && c[tx][ty] == '.' && !vis[tx][ty] ) {
				vis[tx][ty] = true , Q.push ( Node ( tx , ty , s + 1 ) ) ;
				if ( tx == n && ty == m ) {
					printf ( "%d\n" , n * m - s - 1 - sum ) ;
					return 0 ;
				}
			}
		}
	}
	
	puts ( "-1" ) ;
	
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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

    int n;

    cin >> n;
    
    vector<int> num_even(pow(10, 5)+1);
    vector<int> num_odd(pow(10, 5)+1);

    int tmp;
    for(int i = 0; i < n; i++){
        cin >> tmp;
        if(i % 2 == 0){
            num_even[tmp] += 1;
        }else{
            num_odd[tmp] += 1;
        }
    }

    vector<int>::iterator max_even_it = max_element(num_even.begin(), num_even.end());
    vector<int>::iterator max_odd_it  = max_element(num_odd.begin(),  num_odd.end());
    
    int maxind_even = distance(num_even.begin(), max_even_it);
    int maxind_odd  = distance(num_odd.begin(), max_odd_it);
    
    int maxnum_even = *max_even_it;
    int maxnum_odd  = *max_odd_it;

    int ans = 0;
    if(maxind_even != maxind_odd){
        cout << n - (maxnum_even + maxnum_odd) << endl;
    }else{
        
        num_even[maxind_even] = 0;
        num_odd[maxind_odd]   = 0;

        vector<int>::iterator max2_even_it = max_element(num_even.begin(), num_even.end());
        vector<int>::iterator max2_odd_it  = max_element(num_odd.begin(),  num_odd.end());
        
        int maxind2_even = distance(num_even.begin(), max2_even_it);
        int maxind2_odd  = distance(num_odd.begin(), max2_odd_it);
        
        int maxnum2_even = *max2_even_it;
        int maxnum2_odd  = *max2_odd_it;

        cout << min(n - (maxnum_even + maxnum2_odd), n - (maxnum2_even + maxnum_odd)) << endl;        
    }

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-2):
  if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]:
    count += 1
  else:
    pass
  
print(count)


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

using namespace std;
typedef long long ll;

#ifdef ZERO_IQ
ios_base::sync_with_stdio ( false ), cin.tie ( 0 ), cout.tie ( 0 );
#endif

long long const mod = 1e9 + 7;


vector<ll> fact(1e5 + 1), inv(1e5 + 1);

ll fp(ll base, ll exp) {
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n) {
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++) {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r) {
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    calcFacAndInv(1e5 + 1);
    sort(v.begin(), v.end());
    ll ans = 0;
    for (int j = 0; j < n; ++j) {
        if (j < m - 1 && n - j - 1 >= m - 1) {
            ans = ((ans % mod) + (((v[j] % mod) * -ncr(n - j - 1, m - 1)) % mod) % mod) % mod;
        } else if (n - j - 1 < m - 1 && j >= m - 1) {
            ans = ((ans % mod) + (((v[j] % mod) * ncr(j, m - 1)) % mod) % mod) % mod;
        } else if (n - j - 1 >= m - 1 && j >= m - 1)
            ans = ((ans % mod) + ((((v[j] % mod) * (ncr(j, m - 1) - ncr(n - j - 1, m - 1)) % mod) % mod) % mod)) % mod;
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>

using namespace std;

vector<int> T, A;

class C{
public:
	unsigned long long int hmax, h;
};

int main(){
	int N;
	unsigned long long int M=1000000007;
	cin>>N;
	
	T.resize(N);
	A.resize(N);
	for(int i=0; i<N; i++){
		cin>>T[i];
	}
	for(int i=0; i<N; i++){
		cin>>A[i];
	}

	vector<int> V;
	V.resize(N);
	for(int i=0; i<N; i++){
		V[i]=min(T[i], A[i]);
	}

	V[0]=1;
	if(T[0]>A[0]){
		cout<<0<<endl;
		return 0;
	}

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

	V[N-1]=1;
	if(A[N-1]>T[N-1]){
		cout<<0<<endl;
		return 0;
	}

	for(int i=N-1; i>0; i--){
		if(A[i]<A[i-1]){
			if(A[i-1]>T[i-1]){
				cout<<0<<endl;
				return 0;
			}
			V[i-1]=1;
		}
	}

	unsigned long long int ans=1;
	for(int i=0; i<N; i++){
		ans*=V[i];
		ans%=M;
	}

	cout<<ans<<endl;

	return 0;
}


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

int main() {
    int n, t; cin >> n >> t;
    int ret_c = 2000000000, ret_t = 2000000000;
    for(int i = 1; i <= n; i++) {
        int c, ti; cin >> c >> ti;
        if(ret_c >= c && t >= ti) {
            ret_c = c;
            ret_t = ti;
        }
    }
    if(ret_c != 2000000000) {
        cout << ret_c << endl;
    } else {
        cout << "TLE\n" << endl;
    }
}


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

int main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  vector<vector<int>> ans(h,vector<int>(w));
  rep(i,b)rep(j,a) ans[i][j]++;
  for(int i=b;i<h;i++)for(int j=a;j<w;j++) ans[i][j]++;
  rep(i,h){
    rep(j,w) cout<<ans[i][j];
    cout<<endl;
  }
}

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

int main(){
  int S;
  cin >> S;
  int T, U;
  T = S / 100;
  U = S % 100;
  if((T > 12 || T == 0) && (U > 12 || U == 0)) cout << "NA" << endl;
  else if((T > 12 || T == 0) && (U < 13 && U > 0)) cout << "YYMM" << endl;
  else if((T < 13 && T > 0) && (U > 12 || U == 0)) cout << "MMYY" << endl;
  else if((T < 13 && T > 0) && (U < 13 && U > 0)) cout << "AMBIGUOUS" << endl;
}

Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long int ll;
ll ways[5002][5002];	//ways[length][chances remaining]
#define MOD 1000000007
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	memset(ways,0,sizeof(ways));
	ways[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			if(j>=1)
				ways[j][i]=(ways[j-1][i-1]+(2*ways[j+1][i-1])%MOD)%MOD;
			else
				ways[j][i] = (ways[j][i-1]+(2*ways[j+1][i-1])%MOD)%MOD;
		}
	}
	cout<<ways[s.length()][n]<<endl;
}

Measured memory_bytes: 195712
#include <iostream>

using namespace std;

int main()
{
    int h,w;
    cin>>h>>w;
    char a[h][w];
    long long int dp[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            if(a[i][j]=='#') dp[i][j]=-1;
            else dp[i][j]=0;}}
   /* for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cout<<dp[i][j]<<" ";
            cout<<endl;
       }*/
       dp[0][0]=1;
       for(int i=1;i<h;i++){
        if(dp[i][0]!=-1)dp[i][0]=dp[i-1][0];}

       for(int i=1;i<w;i++){
        if(dp[0][i]!=-1)dp[0][i]=dp[0][i-1];}
       for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
                if(dp[i][j]!=-1){
                if(dp[i-1][j]==-1 || dp[i][j-1]==-1){
                   if(dp[i-1][j]==-1) dp[i][j]=dp[i][j-1]%1000000007;
                   else if(dp[i][j-1]==-1) dp[i][j]=dp[i-1][j]%1000000007;}
                else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;}
        }
       }
       /*for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cout<<dp[i][j]<<" ";
            cout<<endl;
       }*/
      if(dp[h-1][w-1]<0) cout<<0;
       else cout<<dp[h-1][w-1];
    return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define loop(i,a,b) for(int i=a; i<b; i++)
#define INF 10000000000099ll
#define mod 1000000007
#define prDouble(x) cout<<fixed<<setprecision(10)<<x

double dp[301][301][301];
double solve(int x, int y, int z, int& n)
{
    if(x<0 || y<0 || z<0) return 0;
    if(x==0 && y==0 && z==0) return 0;
    if(dp[x][y][z] >-0.1) return dp[x][y][z];
    double ans= n+ x*solve(x-1,y,z,n)+ y*solve(x+1,y-1,z,n)+ z*solve(x, y+1, z-1, n);
    return dp[x][y][z]= ans/(x+y+z);
}

int main()
{
    FASTIO;
    int n,t,x=0,y=0,z=0;
    cin>>n;
    memset(dp, -1, sizeof dp);
    loop(i, 0, n){
        cin>>t;
        if(t==1) x++;
        else if(t==2) y++;
        else z++;
    }
    prDouble(solve(x, y, z, n));
    return 0;
}




Measured memory_bytes: 216864
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n;
    cin>>n;
    long s=0;
    long i=0;
    while(i<=n)
    {
        if(i%3==0||i%5==0)
        {

        }
        else
            s+=i;

        i++;

    }
    cout<<s;
}


Measured memory_bytes: 3544
#include<iostream>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
    long long a,b,x=0;
    cin>>a>>b;
    
    if(a>0 && b>0){
    	cout<<"Positive"<<endl;
    	return 0;
	}
	if(a==0 || b==0){
		cout<<"Zero"<<endl;
		return 0;
	}
	if(a<0 && b<0){
	for(int i=a;i<=b;i++)
    x++;
    if(x%2==0){
    	cout<<"Positive"<<endl;
    	return 0;
	}
	else
	{
		cout<<"Negative"<<endl;
		return 0;
	}
	}
    if(a<0 && b>0){
    	cout<<"Zero"<<endl;
    	return 0;
	}
	if(a>0 && b<0){
		cout<<"Zero"<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
import math
x = int(input())

for i in range(-1000,1000):
  for j in range(-1000,1000):
    X = (i-j)*(i**4 + i**3*j + i**2*j**2 + i*j**3 + j**4)
    if X==x:
      print(i,j)
      exit()

Measured memory_bytes: 67796
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'

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

  int64 x, y, z, K; cin >> x >> y >> z >> K;
  vector<int64> a(x), b(y), c(z);
  rep(i, x) cin >> a[i]; rep(i, y) cin >> b[i]; rep(i, z) cin >> c[i];
  sort(rall(a)); sort(rall(b)); sort(rall(c));
  vector<int64> ans;

  rep(i, x){
    rep(j, y){
      if ((i + 1) * (j + 1) > K) break;
      rep(k, z){
        if ((i + 1) * (j + 1) * (k + 1) > K) break;
        ans.push_back(a[i] + b[j] + c[k]);
      }
    }
  }
  sort(rall(ans));
  rep(i, K) print(ans[i]);

  return 0;
}

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

int is_palindrome(char *str, const int n)
{
	for (int i = 0; i < n / 2; i++)
		if (str[i] != str[n - i - 1])
			return 0;
	return 1;
}

int main(void)
{
	char str[100] = {
		0,
	};
	int len;
	scanf("%s", str);
	len = strlen(str);

	if (is_palindrome(str, len))
	{
		if (is_palindrome(str, (len - 1) / 2))
		{
			if (is_palindrome(str + (len + 3) / 2 - 1, (len - 3) / 2) + 1)
			{
				printf("Yes");
				return 0;
			}
		}
	}

	printf("No");
	return 0;
}


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

int main() {

	int X,A;
	cin>>X>>A;
	if(X>=0&&X<=9&&A>=0&&A<=10)
	{
	    if(X<A)
	    {
	        cout<<0;
	    }
	    else
	    cout<<10;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Nmax 100005
#include <cmath>
#define INF 0x3f3f3f3f

using namespace std;

ifstream f("1.in");
ofstream g("1.out");

int n, k, dp[Nmax], h[Nmax];

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
        dp[i]=INF;
    }
    dp[1]=0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= k; j++)
            if(i+j<=n) dp[i+j]=min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
    cout << dp[n];
}


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

#define ll long long
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define fill(a,b) memset(a,b,sizeof(a))
#define f first
#define s second

#define inf 1e15
#define ninf -1*1e15
#define mod 1000000007
#define N 500005
#define Ns 5005

string s;
ll n,m,x,y,d,k;
ll a[N],p[N],c[N],cost[N];

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
	int t=1;
//	cin>>t;
	while(t--){
	    
	    
	    cin>>n>>k;
	    for(int i=0;i<n;i++){
	        cin>>p[i];
	        p[i]--;
	    }
	     for(int i=0;i<n;i++){
	        cin>>c[i];
	        
	    }
	    ll ans=ninf;
	    
	    for(int i=0;i<n;i++){
	        
	        ll len=0,total=0;
	        
	        int j=p[i];
	        
	        while(j!=i){
	            total+=c[j];
	            cost[len++]=total;
	            j=p[j];
	        }
	        
	        total+=c[i];
	        cost[len++]=total;
	        
	       // cout<<len<<" @\n";
	        
	        if(k<=len){
	            
	            ll cnt=ninf;
	            
	            for(int j=0;j<k;j++){
	               // cout<<cost[j]<<" ";
	                cnt=max(cnt,cost[j]);
	            }
	           // cout<<" &\n";
	            
	           // cout<<cnt<<" )\n";
	            ans=max(ans,cnt);
	        }
	        else
	        {
	            ll mx=ninf,mx2=ninf;
	            for(int j=0;j<len;j++){
	                mx=max(mx,cost[j]);
	            }
	            if(k%len)
	            {
	             for(int j=0;j<k%len;j++){
	                 mx2=max(mx2,cost[j]);
	             }
	            }
	            else
	            {
	                mx2=0;
	            }
	            
	            ll h=k/len;
	            
	           // cout<<mx<<" #\n";
	           // cout<<mx2<<" *\n";
	           // cout<<mx+total*(h-1)<<" $\n";
	           // cout<<mx2+total*(h)<<" %\n\n";
	            
	            ans=max(ans,mx);
	            ans=max(ans,mx+total*(h-1));
	            ans=max(ans,mx2+total*(h));
	        }
	    }
	    
	    
	    
	    
	    cout<<ans<<"\n";
	    
	    
	}
	return 0;
}


Measured memory_bytes: 3764
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/3 22:02:32
File Name     :main.cpp
************************************************ */
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include<random>
#include<ctime>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 1e9
#define bug puts("--------------")
const ll N = 2e5 + 10;
const ll mod = 1e9 + 7;
const ll Max_n = 1e6 + 10;
using namespace std;
double sum[N];
int main(){
    int n,m;
    cin >> n >> m;
    for(int i = 1;i <= n;++i){
        int a;
        cin >> a;
        sum[i] = sum[i-1] + (1.0/a)*(a+1)*a/2;
    }
    double  M = -1;
    for(int i = m;i <= n;++i){
        M = max(M,sum[i]-sum[i-m]);
    }
    printf("%.13lf",M);

}

Measured memory_bytes: 1792
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  int A;
  int nAns=0,pAns=0;
  for(int i = 0; i < M; i++){
    cin >> A;
    if(A<X) ++nAns;
    else ++pAns;
  }

  printf("%d\n",min(nAns,pAns));
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int a,b,c;
int main()
{
	a=read(),b=read(),c=read();
	if (a==b&&b==c&&a%2==0) cout << -1 << endl; else
	if (a==b&&b==c) cout << 0 << endl;
	else
	{
		int ans=0;
		while (a%2==0&&b%2==0&&c%2==0)
		{
			++ans;
			int x=(a+b)/2,y=(b+c)/2,z=(c+a)/2;
			a=x,b=y,c=z;
		}
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;

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

    int ret = 1;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1])ret++;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			long n = stdIn.nextLong();
			long m = stdIn.nextLong();
			if(n == 0 && m == 0) break;
			Long[] c = new Long[11];
			for (int i = 0; i < 11; i++) {
				c[i] = 0L;
			}
			for (int i = 0; i < n; i++) {
				long d = stdIn.nextLong();
				int p = stdIn.nextInt();
				c[p] += d;
			}
			
			for (int i = 10; i >= 0; i--) {
				c[i] -= m;
				m = 0;
				if (c[i] < 0) {
					m += c[i] * -1L;
					c[i] = 0L;
				}
				if (m == 0)
					break;
			}
			Long ans = 0L;
			for (int i = 0; i <= 10; i++) {
				ans += c[i] * i;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 93972
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
   //cin>>test;

  
  while(test--)
  {
    int n,m,x,sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
      cin>>x;
      sum+=x;
    }
    n-=sum;
    if(n<0)cout<<-1;
    else cout<<n;
  
  // while loop ending
   }
  

return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
int main(int argc,char* argv[]){
  int N,K;
  long min;
  cin >> N >> K;
  vector<long> v(N);
  for(int i=0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end(),greater<long>());
  min = v[0]-v[K-1];
  for(int i=1;i<N-K+1;i++){
    if(v[i]-v[i+K-1]<min) min = v[i]-v[i+K-1];
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

int f(int x){
    int ans=0;
    for(int i=1;i<100;i++){
        if(x>=i){
            x-=i;
            ans++;
        }
    }
    return ans;
}

void solve(){
    long long n;
    cin>>n;
    vector<int> primes;
    vector<bool> p(int(1e6)+1,true);
    p[0]=p[1]=false;
    for(int i=0;i<p.size();i++){
        if(p[i]){
            primes.pb(i);
            int j=i;
            while(1ll*i*j<p.size()){
                p[i*j]=false;
                j++;
            }
        }
    }
    int ans=0;
    for(int i=0;i<primes.size();i++){
        if(n%primes[i]==0){
            int x=0;
            while(n%primes[i]==0){
                x++;
                n/=primes[i];
            }
            ans+=f(x);
        }
    }
    if(n!=1){
        ans+=1;
    }
    cout<<ans<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 4004
n=int(input())
l=list(map(int,input().split()))
d={}
f=0
for a in l:
    if a<400:
        if not 0 in d:
            d[0]=1
    elif a<800:
        if not 1 in d:
            d[1]=1
    elif a<1200:
        if not 2 in d:
            d[2]=1
    elif a<1600:
        if not 3 in d:
            d[3]=1
    elif a<2000:
        if not 4 in d:
            d[4]=1
    elif a<2400:
        if not 5 in d:
            d[5]=1
    elif a<2800:
        if not 6 in d:
            d[6]=1
    elif a<3200:
        if not 7 in d:
            d[7]=1
    else:
        f+=1
v=sum(d.values())
min_=1 if v==0 else v
max_=v+f
print(min_,max_)

Measured memory_bytes: 9156
/*
 * ID: 0619
 * Problem: Selecting subjdects
 */

#include <stdio.h>

int main(void)
{
    int point[6];

    for (int i = 0; i < 6; i++)
        scanf("%d", point + i);

    int sum = point[0];
    int min = sum;
    for (int i = 1; i < 4; i++) {
        sum += point[i];
        min = min < point[i] ? min : point[i];
    }
    sum -= min;
    sum += point[4] > point[5] ? point[4] : point[5];
    
    printf("%d\n", sum);

    return 0;
}



Measured memory_bytes: 2104
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        
        if i == 0 or i == h-1:
            print('#'*w)
        else:
            print('#','.'*(w-2),'#',sep='')
      
       
    print()


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

int main(){
    int A,B;
    cin >> A >> B;
    
    int max = 0;
    if(A > B){
        max = max + A;
        if((A-1) > B){
            max = max + A - 1;
        }else{
            max = max + B;
        }
    }else if(A == B){
        max = max + A + B;
    }else{
        max = max + B;
        if(A == (B-1)){
            max = max + A;
        }else{
            max = max + B - 1;
        }
    }
    
    cout << max << endl;

    return 0;
}


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

using namespace std;

int X,Y;
int found;

int main()
{
    cin>>X>>Y;
    found = false;
    for(int i = 0; i<=150; i++){
        for(int j = 0; j<=150; j++){
            if((i+j == X) && (2*i + 4*j == Y)){
                found = true;
                break;
            }
        }
    }

    if(found){
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
using namespace std;
int main() {
    int b, f, r, v;
    int m[4][3][10];
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                m[i][j][k] = 0;
            }
        }
    }
    
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        m[b - 1][f - 1][r - 1] += v;
    }
    
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << m[i][j][k];
            }
            cout << endl;
        }
        if (i != 3) cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long llong;
// static const int max_n = 110;
// static const llong max_cost = 2000000000000000;
// // vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// // vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
// vector<vector<pair<llong, int>>> adj_list(max_n);
// vector<llong> distance_table(max_n, max_cost);
// set<pair<llong, int>> points_sort_x;
// set<pair<llong, int>> points_sort_y;

int N;



int main(){
    // int u, v;
    // bool updated = false;
    llong X, Y, Z;
    scanf("%lld %lld %lld", &X, &Y, &Z);
    // printf("ok3\n");

    printf("%lld %lld %lld\n", Z, X, Y);


    return 0;

}

Measured memory_bytes: 256