akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cstring>
#include <bits/stdc++.h>
#include <search.h>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include<stack>
#include <utility>
using namespace std;
int main()
{
int h,w;
int col[100]={0},row[100]={0};
char g[100][100];
cin>>h>>w;
for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
        cin>>g[i][j];
    }
}
for(int i=0;i<h;++i){
    int check=0;
    for(int j=0;j<w;++j){
        if(g[i][j]!='.') check++;
    }
    if(check==0) row[i]=1;
}
for(int i=0;i<w;++i){
    int check=0;
    for(int j=0;j<h;++j){
        if(g[j][i]!='.') check++;
    }
    if(check==0) col[i]=1;
}

for(int i=0;i<h;++i){
     if(row[i]==0)
       {
           for(int j=0;j<w;++j){
              if(col[j]==0){
                cout<<g[i][j];
              }
           }
           cout<<endl;
       }
    }

return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int j,m,s,e,score=0;
  for(int i=0;i<2;i++){
    cin >> j >> m >> s >> e;
    if(score<j+m+s+e) score = j + m + s + e;
  }
  cout << score << endl;
  return 0;
}

Measured memory_bytes: 1160
<?php
$in = explode(" ", fgets(STDIN));
$vol1 = $in[0];
$wt1 = $in[1];
$wt2 = $in[2];

/*
$vol1 = $argv[1];
$wt1 = $argv[2];
$wt2 = $argv[3];
*/

$l = $wt2 - ($vol1 - $wt1);
if($l<0){ $l = 0; }

echo($l);

?>

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

int main()
{
	int w;

	while (cin >> w){
		for (int i = 1; i <= 512; i *= 2){
			if (w % (i * 2) != 0){ // next check
				cout << i;
				w -= i;
				if (w != 0){
					cout << " ";
				}
			}
			if (w == 0){
				cout << endl;
				break;
			}
		}
	}

	return (0);
}

Measured memory_bytes: 1168
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N,K;
int main() {
	cin>>N>>K;

	int ans=1;
	for(int i=0;i<N;i++){
		if(ans*2>ans+K)ans+=K;
		else ans*=2;
	}

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


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

int main()
{
    int N,L;
    cin >> N >> L;
    int res = 0;
    int min = 10000;
    int minPos=10000;
        for (int i = L; i < N+L; i++)
        {
            res+=i;
            if(abs(i)<min){
                min=abs(i);
                minPos = i;
            }
        }
        
    cout << res-minPos <<endl;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long
const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

int a[N], rmq[N][31];
signed main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n; cin >> n;
	for(int i = 1 ; i <= n ; ++i) cin >> a[i];
	int d, q; cin >> d >> q;
	for(int i = 1 ; i <= n ; ++i)
		rmq[i][0] = (upper_bound(a + 1,a + n + 1, a[i] + d) - a - 1);
	for(int j = 1 ; j <= 20 ; ++j)
		for(int i = 1 ; i <= n ; ++i)
			rmq[i][j] = rmq[rmq[i][j - 1]][j - 1];
	for(int i = 1 ; i <= q ; ++i)
	{
		int u, v; cin >> u >> v;
		if(u > v) swap(u , v);
		int cnt = 0;
		for(int j = 20 ; j >= 0 ; --j)
		{
			if(rmq[u][j] < v)
			{
				cnt += (1 << j);
				u = rmq[u][j];
			}
		}
		cout << cnt + 1 << "\n";
	}
}
				




Measured memory_bytes: 25856
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define all(a) a.begin(),a.end()
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using pll=pair<ll, ll>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

signed main()
{
    int n, m; cin >> n >> m;

    vector<int> A(n);
    rep(i, n) cin >> A[i];
    sort(all(A));

    vector<pair<int,int> > p;
    rep(i, m) {
        int b, c; cin >> b >> c;
        p.PB(pair < int,int >(c, b));
    }

    sort(begin(p),end(p),greater<pair<int,int>>());
    int idx = 0;

    rep(i, m) {
        rep(j, p[i].scd) {
            if (A[idx] < p[i].fst) A[idx] = p[i].fst;
            idx++;
            if (idx == n) break;
        }
        if (idx == n) break;
    }

    ll sum = 0;
    rep(i, n) sum += A[i];

    cout << sum << endl;
}




Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  for(int i:irange(0,h)) {
    for(int j:irange(0,w)) {
      if (i < b) {
        if (j < a) {
          cout<<'1';
        } else {
          cout<<'0';
        }
      } else {
        if (j < a) {
          cout<<'0';
        } else {
          cout<<'1';
        }
      }
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int R,D,X;
    cin >> R >> D >> X;
    rep(i,0,10){
        X = X * R - D;
        cout << X << endl;
    }
}

Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 10

ll N,A,B,max_hp;
std::vector<ll> hp;
bool killable(ll times){
    ll spell_left = times;
    ll widespread_dmg = times*B;
    REP(i,N){
        if(hp[i] > widespread_dmg){
            spell_left-=(hp[i]-widespread_dmg)/(A-B);
            if((hp[i]-widespread_dmg)%(A-B)!=0LL){
                spell_left--;
            }
        }

        if(spell_left<0){
            return false;
        }
    }
    return true;
}

int main(){

    cin>>N>>A>>B;
    REP(i,N){
        ll temp; cin >> temp;
        hp.push_back(temp);
        max_hp=max(max_hp,temp);
    }

    //binary seach on the answer
    ll left = 1LL, right = max_hp/B+1LL, mid, ans = right;

    while(left <= right){
        mid = (right+left)/2LL;
        if(killable(mid)){
            ans = min(mid, ans);
            right = mid-1LL;
        } else {
            left = mid+1LL;
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=60;
int n,m,x,y,eg,u[MAXN],v[MAXN],hd[MAXN],ver[2*MAXN],nx[2*MAXN],f[MAXN];
bitset <51> q[21],t[1<<20];
ll ans;
ll qpow (ll a,ll b) {
	ll res=1;
	while (b) {
		if (b&1) {res*=a;}
		a*=a,b>>=1;
	}
	return res;
}
void add_edge (int x,int y) {
	ver[++eg]=y;
	nx[eg]=hd[x];
	hd[x]=eg;
	return;
}
void dfs (int x,int fa) {
	f[x]=fa;
	for (int i=hd[x];i;i=nx[i]) {
		if (ver[i]==fa) {continue;}
		dfs(ver[i],x);
	}
	return;
}
void mk (int x,int y,int p) {
	for (int i=x;i!=1;i=f[i]) {q[p].set(i,1);}
	int cur=y;
	for (;cur!=1&&!q[p][cur];cur=f[cur]) {q[p].set(cur,1);}
	for (;cur!=1;cur=f[cur]) {q[p].set(cur,0);}
	return;
}
int main () {
	eg=1;
	scanf("%d",&n);
	for (int i=1;i<=n-1;i++) {
		scanf("%d%d",&x,&y);
		add_edge(x,y),add_edge(y,x);
	}
	dfs(1,0);
	scanf("%d",&m);
	for (int i=1;i<=m;i++) {
		scanf("%d%d",&u[i],&v[i]);
		mk(u[i],v[i],i);
	}
	for (int i=0;i<(1<<m);i++) {
		int cnt=0,cur=0;
		for (int j=0;j<m;j++) {
			if (i&(1<<j)) {cnt++,cur=j+1;}
		}
		if (cnt) {t[i]=t[i^(1<<(cur-1))]|q[cur];}
		if (cnt&1) {
			ans-=qpow(2,n-1-t[i].count());
		} else {
			ans+=qpow(2,n-1-t[i].count());
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11988
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int a,b,c; cin >> a >> b >> c;
    if(a==5&&b==5&&c==7) cout << "YES" << endl;
    else if(a==5&&b==7&&c==5) cout << "YES" << endl;
    else if(a==7&&b==5&&c==5) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
Nums = [0 for i in range(N)]
for i in A:
    Nums[i-1] += 1

NormalAns = [i*(i-1)//2 for i in Nums]
AnotherAns = [((i-1)*(i-2)//2 if i-2>=0 else 0) for i in Nums]
Ans = sum(NormalAns)
for i in A:
    print(Ans-NormalAns[i-1]+AnotherAns[i-1])

Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
ll n, a,b;
cin >> n >> a >> b;
ll ans = b-a;
if(ans%2==0)ans/=2;
else{
    ans = min(a-1,n-b)+1+(b-a-1)/2;
}
cout << ans << endl;
}
 


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

int main() {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n,d;
	cin>>n>>d;
	int x[n][d];
	for(int i=0;i<n;i++)
		for(int j=0;j<d;j++)
			scanf("%d",&x[i][j]);
	
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++) {
			int sum=0;
			for(int k=0;k<d;k++)
				sum+=(x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
			
			float root=sqrt(sum);
			if(floor(root) == root)
				ans++;
		}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    vector<int>h(n+1);
    int dp[n+1];
    dp[0]=0;
    dp[1]=0;
    h[0]=0;
    rep(i,1,n+1){
        cin>>h[i];
    }
    rep(i,2,n+1){
        dp[i]=1000000007;
    }
    rep(i,1,n+1){
        rep(j,1,k+1){
            if(i+j>n){break;}
            else{
                dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
            }
        }
    }
    cout<<dp[n];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, tmp, my, your, ans=0;
    cin >> N;
    deque<int> a[N], b;
    vector<int> flag(N, 0);
    bool ok=true, ok2=true;
    
    for(int i=0; i<N; i++){
	for(int j=0; j<N-1; j++){
	    cin >> tmp;
	    a[i].push_back(tmp-1);
	}
    }
    
    while(true){
	for(int i=0; i<N; i++){
	    if(flag[i] == 0){
		ok = false;
		b.push_back(i);
	    }
	    if(!a[i].empty())
		ok2=false;
	    flag[i] = 1;
	}
	if(ok){
	    cout << -1 << endl;
	    return 0;
	}
	else if(ok2){
	    cout << ans<< endl;
	    return 0;
	}

	while(!b.empty()){
	    int i = b.front();
	    b.pop_front();
	    if(a[i].empty())
		continue;
	    my = a[i].front();
	    
	    if(a[my].empty())
		continue;
	    your = a[my].front();
	    
	    if(i==your && flag[i]==1 && flag[my]==1){
		a[i].pop_front();
		a[my].pop_front();
		flag[i]=0;
		flag[my]=0;
	    }
	}
	
	ok=true;
	ok2=true;
	ans++;
    }
}


Measured memory_bytes: 4736
#include <iostream>
#include <array>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    std::array<int,256> nCharRight, nCharLeft;
    std::fill(nCharRight.begin(), nCharRight.end(), 0);
    std::fill(nCharLeft.begin(), nCharLeft.end(), 0);
    for(auto c : s)
    {
        nCharRight[c] += 1;
    }
    int maxNumCommonChar = 0;
    int numCommonChar = 0;
    for(auto c : s)
    {
        if(nCharLeft[c] == 0)
        {
            numCommonChar++;
        }
        nCharLeft[c] += 1;
        nCharRight[c] -= 1;
        if(nCharRight[c] == 0)
        {
            numCommonChar--;
        }
        maxNumCommonChar = max(numCommonChar, maxNumCommonChar);
    }
    cout << maxNumCommonChar << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        String x = "";
        String y = "";
        int max = 0;
        for(int i=1; i <= N-1; i++) {
            x = S.substring(0, i);
            y = S.substring(i, N);
            List<String> l = new ArrayList<>();
            String[] xs = x.split("");
            String[] ys = y.split("");
            int count = 0;
            for(String s : xs) {
                if(l.contains(s)) continue;
                else l.add(s);
            }
            for(String s : ys) {
                if(l.contains(s)) count++; l.remove(s);
            }
            if(max < count) {
                max = count;
            }
        }
        System.out.println(max);
    }
}

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

class MyClass
{
    public static void Main(string[] args)
    {
        var dic = new HashSet<string>();
        var n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            var input = Console.ReadLine().Split();
            if (input[0] == "insert")
            {
                dic.Add(input[1]);
            }
            else
            {
                Console.WriteLine(dic.Contains(input[1]) ? "yes" : "no");
            }
        }
    }
}


Measured memory_bytes: 48908
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n, k;
	cin >> k >> n;
	int arr[n], max = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		arr[i] %= k;
	}
	sort(arr,arr+n);
	for(int i = 0; i < n-1; i++)
		if( max < arr[i+1] - arr[i] )
			max = arr[i+1] - arr[i];
	if( max < (k - arr[n-1]) + arr[0] )
		max = (k - arr[n-1]) + arr[0];
	cout << k - max;
}

Measured memory_bytes: 1024
N = int(input())
A_1 = [int(i) for i in input().split()]
A_2 = [int(i) for i in input().split()]
scores = []
for u in range(N):
    A_1_c = A_1[0:u+1]
    A_2_c = A_2[u:]
    SUM = sum(A_1_c)+sum(A_2_c)
    scores.append(SUM)
print(max(scores))

Measured memory_bytes: 3060
def solve():
    N = input()
    if N[len(N)-1] == '2' or N[len(N)-1] == '4' or N[len(N)-1] == '5' or N[len(N)-1] == '7' or N[len(N)-1] == '9':
        print('hon')
    elif N[len(N)-1] == '3':
        print('bon')
    else:
        print('pon')


solve()


Measured memory_bytes: 61800
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
pair<int, int> LR[100000];

signed main(){
	cin >> N;
	rep(i, N){
		int X, L;
		cin >> X >> L;
		LR[i] ={ X-L, X+L };
	}
	sort(LR, LR+N);
	
	int l = INT_MAX;
	int ans = 0;
	for(int i=N-1; i>=0; i--){
		if(LR[i].second <= l){
			ans++;
			l = LR[i].first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import sys

def solve(balls):
    ans = distribute(balls, [], [])
    if ans is True: print('YES')
    else: print("NO")
        
def distribute(balls, R, L):    
    if len(balls) != 0:
        next = balls[0]
        ans = False
        #case R
        if isMutch(next, R):
            neoR = R
            neoR.append(next)
            ans = distribute(balls[1:], neoR, L)
        if ans: return True
        
        if isMutch(next, L):
            neoL = L
            neoL.append(next)
            ans =distribute(balls[1:], R, neoL)
        if ans: return True
    else:
        return isOrdered(R) and isOrdered(L)

def isMutch(next, lis):
    if len(lis) != 0:
        return next >= lis[len(lis)-1]
    return True
    
def isOrdered(lis):
    #check both R and L are ordered
    checker = sorted(lis)
    return checker == lis
  
limit = 2**11
sys.setrecursionlimit(limit)
  
line = input()
size = -1;
while True:
    if size == -1:
        size = int(line)
    else:
        balls = []
        for a in line.split(' '):
            balls.append(int(a))   
        solve(balls)
        size -= 1
        if size == 0: break
    line = input()

Measured memory_bytes: 7756
// #include <bits/stdc++.h>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
#include <map>
#include <set>
// #include <complex>
// #include <cassert>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map> 
// #include <ctime>
 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace __gnu_pbds;  

// Declaring ordered_set 
typedef tree<int, 
    null_type, 
    less<int>, 
    rb_tree_tag, 
    tree_order_statistics_node_update>  
    ordered_set;  
 
#define int long long
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define sumarr for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long ll;  
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
 
const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);
 
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;
	vi v(n), dp(n, 0);
	for0(i,n) cin>>v[i];
	dp[1] = abs(v[1] - v[0]);
	for(int i = 2; i < n; i++) {
		dp[i] = min(dp[i-1] + abs(v[i] - v[i-1]), dp[i-2] + abs(v[i] - v[i-2]));
	}
	cout<<dp[n-1];

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int aft(int,int);
int main()
{
  int x,y,s;
  int i,j;
  int sum;
  while(1)
    {
      scanf("%d%d%d",&x,&y,&s);
      if((x==0)&&(y==0)&&(s==0)) break;
      sum=0;
      for(i=1;i<s;i++)
	{
	  for(j=1;j<s;j++)
	    {
	      if(aft(i,x)+aft(j,x)==s)
		{
		  if(aft(i,y)+aft(j,y)>sum) sum=aft(i,y)+aft(j,y);
		}
	      else if(aft(i,x)+aft(j,x)>s) break;
	    }
	}
      printf("%d\n",sum);
    }
  return 0;
}
int aft(int x,int p)
{
  return x*(100+p)/100;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
const int inf=1e9;
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  vector<vector<int> >in(a,vector<int>(a));
  rep(i,a)rep(j,a)in[i][j]=inf;
  int c,d,e,f;
  //cout<<"!"<<endl;
  rep(i,b+1){
    char x;
    cin>>c>>x>>d>>x>>e>>x>>f;
    c--;d--;
    if(i==b)break;
    in[c][d]=e;
    in[d][c]=f;
  }
  vector<vector<int> >tmp(a,vector<int>(a));
  rep(i,a)rep(j,a)tmp[i][j]=in[i][j];
  rep(k,a)rep(i,a)rep(j,a){
    tmp[i][j]=min(tmp[i][j],tmp[i][k]+tmp[k][j]);
    in[i][j]=min(in[i][j],in[i][k]+in[k][j]);
  }
  cout<<e-f-(tmp[c][d]+in[d][c])<<endl;
}

Measured memory_bytes: 1216
s = list(input())
ls = len(s)
p = 0
status = 0
a = 0
ans = 0
while p < ls:
    if status == 0:
        if s[p] == "A":
            status = 1
            a = 1

    elif status == 1:
        if s[p] == "A":
            a += 1
        elif s[p] == "B":
            status = 2
        else:
            status = 0
            a = 0

    elif status == 2:
        if s[p] == "C":
            ans += a
            status = 1

        elif s[p] == "A":
            status = 1
            a = 1
        elif s[p] == "B":
            status = 0
    p += 1

print(ans)


Measured memory_bytes: 61680
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;


int main(void){
    map<char,string>s;
    map<char,int>num;
    cin>>s['a']>>s['b']>>s['c'];
    num['a']=0;
    num['b']=0;
    num['c']=0;
    char index='a';
    while(true){
        if(num[index]==s[index].length()){
            if(index=='a')cout<<'A';
            if(index=='b')cout<<'B';
            if(index=='c')cout<<'C';
            cout<<endl;
            return 0;
        }
        char x=s[index][num[index]];
        num[index]++;
        index=x;
        //cout<<index<<endl;       
    }
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <cstring>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    
    long  mod = 1000000007;
    vector<ll> dp(13);
    long res=0;
    string s;
    cin>>s;
    reverse(s.begin(), s.end());
    int n=s.size();
    dp[0]=1;
    int mul=1;
    for(int i=0;i<n;i++){
        vector<ll> nextdp(13);
        char c=s[i];
        if(c=='?'){
            rep(k, 10){
                rep(j, 13){
                    nextdp[(j+k*mul)%13] += dp[j];
                    nextdp[(j+k*mul)%13] %= mod;
                }
            }
        }
        else{
            int k=s[i]-'0';
            rep(j, 13){
                nextdp[(j+k*mul)%13] += dp[j];
                nextdp[(j+k*mul)%13] %= mod;
            }
        }
        mul*=10;
        mul%=13;
        rep(i, 13){
            dp[i]=nextdp[i];
            
        }
       
    }
    res=dp[5];

    cout<<res<<endl;
    return 0;


}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  
  s.erase(unique(s.begin(), s.end()), s.end());
  cout << (int)s.size() << endl;

  return 0;
}

Measured memory_bytes: 3756
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define RFOR(i,a,b) for(lint i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    REP(i, n){
        cin >> a[i];
    }
    sort(ALL(a));
    lint max_a = a[n-1];
    lint k, l;
    lint ans_n, ans_r;
    double m = (double)max_a / 2.0;
    ans_n = max_a;
    double min_diff = (double)INF;
    REP(i, n-1){
        if(abs(a[i] - m) < min_diff){
            min_diff = (double)fabs(a[i] - m);
            ans_r = a[i];
        }
    }
    cout << ans_n << " " << ans_r << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
const int INF = 1e9 + 5;
vector<vector<int>> v;
vector<vector<ll>> dpp;

ll dp(ll i, ll w)
{
    if (i == 0 || w == 0)
    {
        dpp[i][w] = 0;
        return dpp[i][w];
    }
    if (dpp[i][w] != -1)
        return dpp[i][w];
    if (v[i - 1][0] <= w)
    {
        dpp[i][w] = max(v[i - 1][1] + dp(i - 1, w - v[i - 1][0]), dp(i - 1, w));
        return dpp[i][w];
    }
    else
    {
        dpp[i][w] = dp(i - 1, w);
        return dpp[i][w];
    }
}

int main()
{
    int n, w;
    cin >> n >> w;
    for (int i = 0; i < n; i++)
    {
        vector<int> k(2);
        for (auto &a : k)
            cin >> a;
        v.push_back(k);
    }
    for (int i = 0; i <= n; i++)
    {
        vector<ll> z(w + 1);
        for (int j = 0; j <= w; j++)
        {
            z[j] = -1;
        }
        dpp.push_back(z);
    }
    ll ans = dp(n, w);
    cout << ans << "\n";
    return 0;
}


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

typedef long long ll;

int main()
{
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin>>n;
    long double x = 2*(3.1415926535897932)*n;
    cout<<x<<endl;
    
    return 0;
}

Measured memory_bytes: 3804
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int get_parent(int i, int *parent) {
  while (i != parent[i]) i = parent[i];
  return i;
}

void Union(int i, int j, int *parent, int *rank) {
  i = get_parent(i, parent);
  j = get_parent(j, parent);
  if (i == j) return;
  if (rank[i] < rank[j]) swap(i, j);
  parent[j] = i;
  rank[i] = max(rank[i], rank[j] + 1);
  return;
}

int main(void) {

  int n, m, k;
  cin >> n >> m;
  vector< vector<int> > lng(m);
  rep(i, n) {
    cin >> k;
    int x;
    rep(j, k) {
      cin >> x;
      lng[x - 1].push_back(i);
    }
  }

  int parent[100100], rank[100100] = {};
  rep(i, n) parent[i] = i;

  rep(i, m) {
    if (lng[i].size() <= 1) continue;
    for (int j = 1; j < lng[i].size(); j++) {
      Union(lng[i][0], lng[i][j], parent, rank);
    }
  }

  int s = get_parent(0, parent);
  rep(i, n) {
    if (s != get_parent(i, parent)) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;

}

  
      


Measured memory_bytes: 4992
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    string s;
    cin >> s;

    string res;

    for (auto c : s) {
        if (c == 'B') {
            if (res.size() > 0) {
                res.pop_back();
            }
        } else {
            res += c;
        }
    }

    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, K;
	cin >> N >> K;
	vector<double> V(N);
	for (int i = 0; i < N; i++) cin >> V[i], V[i]++;
	double ANS = 0, COUNT = 0;
	for (int i = 0; i < K; i++) COUNT += V[i];
	ANS = COUNT;
	for (int i = 0; i + K < N; i++) {
		COUNT -= V[i];
		COUNT += V[i + K];
		ANS = max(ANS, COUNT);
	}
	printf("%.12lf\n", ANS / 2);
}

Measured memory_bytes: 1792
int main(void){
	int n,i,b,j,k;
	int a[3][3],c[3][3]={0};

	for(i=0;i<3;i++){
		scanf("%d %d %d\n",&a[i][0],&a[i][1],&a[i][2]);
	}
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d\n",&b);
		for(j=0;j<3;j++){
			for(k=0;k<3;k++){
				if(b==a[j][k]){
					c[j][k]=1;
					break;
				}
			}
		}
	}
	if((c[0][0]==1&&c[0][1]==1&&c[0][2]==1)||(c[1][0]==1&&c[1][1]==1&&c[1][2]==1)||(c[2][0]==1&&c[2][1]==1&&c[2][2]==1)||(c[0][0]==1&&c[1][0]==1&&c[2][0]==1)||(c[0][1]==1&&c[1][1]==1&&c[2][1]==1)||(c[0][2]==1&&c[1][2]==1&&c[2][2]==1)||(c[0][0]==1&&c[1][1]==1&&c[2][2]==1)||(c[2][0]==1&&c[1][1]==1&&c[0][2]==1)){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

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

int32_t main()
{
	int h,n;
	cin>>h>>n;
	
	int dp[n+1][h+1];
	for (int i=0;i<=h;i++)
		dp[0][i]=INT_MAX;
	for (int i=0;i<=n;i++)
		dp[i][0]=0;
		
	for (int i=1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		
		for (int j=1;j<=h;j++)
		{
			int yum = j-a;
			if (yum<=0) 
				dp[i][j] = min(dp[i-1][j],b);
			else
				dp[i][j] = min(dp[i-1][j],b+dp[i][j-a]);
		}
	}
	
	cout<<dp[n][h];
	
	
}


Measured memory_bytes: 78464
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string array;
    cin>>array;
    int sum=0;
    for(int i=0;i<array.length();i++){
        sum+=array[i]-'0';
        
    }
    if(sum%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}



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



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

    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
        --A[i];
    }

    std::vector<int> v;
    std::vector<bool> check(N);
    int now = 0;
    while (!check[now]) {
        check[now] = true;
        v.push_back(now);
        now = A[now];
    }

    int i = 0;
    for (; i < v.size(); i++) {
        if (i == K) {
            std::cout << v[i] + 1 << "\n";
            return 0;
        }
        if (v[i] == now) break;
    }

    long long x = v.size() - i;
    long long y = (K - i) % x;

    std::cout << v[i + y] + 1 << "\n";
}

Measured memory_bytes: 5128
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

INF = 10**7
max = -INF
max2 = -INF

for a in A:
    if a >= max:
        max2 = max
        max = a
    else:
        if a >= max2:
            max2 = a
    
for a in A:
    if a == max:
        print(max2)
    else:
        print(max)



Measured memory_bytes: 12532
#include <stdio.h>
#include <math.h>
#include <vector>

using namespace std;

int main(){

	int n,tmp,sum=0,tmp_min;
	scanf("%d",&n);
	int table[n][n],check[n],num_of_group=0,parent,child;
	vector<int> Group;

	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++){
			scanf("%d",&tmp);
			table[i][k]=tmp;
		}
		check[i]=0;
	}

	Group.push_back(0);
	check[0]=1;
	num_of_group = 1;
	while(num_of_group<n){
		tmp_min=2001;

		for(int i=0;i<num_of_group;i++){
			for(int k=0;k<n;k++){
				if(table[Group[i]][k]!=-1&&check[k]==0&&table[Group[i]][k]<tmp_min){
					tmp_min = table[Group[i]][k];
					parent=Group[i];
					child = k;
				}
			}
		}
		Group.push_back(child);
		sum+=table[parent][child];
		check[child]=1;
		num_of_group++;
	}

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

    return 0;
}

Measured memory_bytes: 2820
import sys

def Partition(A,p,r):

	x = A[r]
	i = p-1
	for j in range(p,r):

		if A[j] <= x:

			i += 1
			A[i],A[j] = A[j],A[i]

	A[i+1],A[r] = A[r],A[i+1]

	return i+1

def test():

	n = int(sys.stdin.readline())
	A = list(map(int,sys.stdin.readline().split()))
	Ptt = Partition(A,0,n-1)

	for i in range(n):

		if i == Ptt:
			print(f"[{A[i]}]",end='')
		else:
			print(f"{A[i]}",end='')

		if i != n-1:
			print(" ",end='')
		else:
			print()


if __name__ == "__main__":
	test()



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

int num[200005] = {0};

int main () {
	int n;
	cin >> n;
	for (int i = 2; i <= n; ++i) {
		int tmp;
		cin >> tmp;
		++num[tmp];
	}
	for (int i = 1; i <= n; ++i)
		cout << num[i] << endl;
	return 0
;}

Measured memory_bytes: 4364
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,M;
int D[200100];
int T[200100];
map<int,int> n,m;
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&D[i]);
		n[D[i]]++;
	}
	scanf("%d",&M);
	for(int i=0;i<M;i++){
		scanf("%d",&T[i]);
		m[T[i]]++;
	}
	map<int,int>::iterator it;
	bool flag = true;
	for(it=m.begin();it!=m.end();it++){
		int key = it->fi;
		map<int,int>::iterator it2;
		it2 = n.find(key);
		if(it2==n.end()){
			flag = false;
			break;
		}
		if((it2->sec)<(it->sec)){
			flag = false;
			break;
		}
	}
	if(flag)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 20608
#include<stdio.h>

void trace(int A[],int N)
{
  for(int i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}


int bubbleSort(int A[],int N){
  int flag=1;
  int sw=0;
  while(flag){
    flag=0;
    for(int j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	int t=A[j];
	A[j]=A[j-1];
	A[j-1]=t;
	sw++;
	flag=1;
      }
    }
  }
  trace(A,N);
  return sw;
}

int main(void)
{
  int N;
  int A[100];
  int sw;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  sw=bubbleSort(A,N);
  printf("%d\n",sw);
  return 0;
}



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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e11;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int a[5], k;
    for (int i = 0; i < 5; ++i) cin >> a[i];
    cin >> k;

    for (int i = 0; i < 5; ++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
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

struct SegmentTreeRUPQ<T, F> {
    n: usize,
    b: usize,
    a: Vec<T>,
    id: T,
    op: F,
}

impl <T: Copy, F: Fn (T, T) -> T> SegmentTreeRUPQ<T, F> {
    pub fn new (n: usize, id: T, op: F) -> SegmentTreeRUPQ<T, F> {
        let mut k = 0;
        while (1 << k) < n {
            k += 1;
        }
        SegmentTreeRUPQ {
            n: 1 << k,
            b: k,
            a: vec![id; 2 << k],
            id: id,
            op: op,
        }
    }
    fn down (&mut self, x: usize) {
        let k = x + self.n;
        let a = &mut self.a;
        for i in (1..(self.b + 1)).rev() {
            let y = k >> i;
            a[2 * y] = (self.op) (a[2 * y], a[y]);
            a[2 * y + 1] = (self.op) (a[2 * y + 1], a[y]);
            a[y] = self.id;
        }
    }
    pub fn update (&mut self, mut l: usize, mut r: usize, v: T) {
        self.down (l);
        self.down (r - 1);
        l += self.n;
        r += self.n;
        let a = &mut self.a;
        while l < r {
            if (l & 1) == 1 {
                a[l] = (self.op) (a[l], v);
                l += 1;
            }
            if (r & 1) == 1 {
                r -= 1;
                a[r] = (self.op) (a[r], v);
            }
            l >>= 1;
            r >>= 1;
        }
    }
    pub fn find (&mut self, x: usize) -> T {
        self.down (x);
        self.a[x + self.n]
    }
}

fn add (a: u32, b: u32) -> u32{
    a + b
}

fn run() {
    input! {
        n: usize,
        m: usize,
        p: [(usize, usize); m],
    }
    let mut s = SegmentTreeRUPQ::new (n, 0, add);
    for (l, r) in p {
        s.update (l - 1, r, 1);
    }
    let mut ans = 0;
    for i in 0..n {
        if s.find (i) == (m as u32) {
            ans += 1;
        }
    }
    println! ("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
long long weird_abs(bool flip, long long a, long long b)
{
    return flip ? a - b : b - a;
}
int main()
{
    while(cin>>n)
    {
        ll x[n+2],y[n+2];
        for(int i=0; i<n; i++)
        {
            cin>>x[i]>>y[i];
        }
        ll ans=-1e18;
        for (int mask = 0; mask < (1 << 2); mask++)
        {
            ll values[n+2];
            ll pre[n+2];
            ll suf[n+2];
            for (int i = 0; i < n; i++)
            {
                values[i] = weird_abs(mask & 1, 0, x[i]) + weird_abs(mask & 2, 0, y[i]) ;
            }
            pre[0]=values[0];
            for(int i=1; i<n; i++)
            {
                pre[i]=max(pre[i-1],values[i]);
            }
            suf[n-1]=values[n-1];
            for(int i=n-2; i>=0; i--)
            {
                suf[i]=max(suf[i+1],values[i]);
            }
            for (int i = 0; i < n; i++)
            {
                long long cur_v = weird_abs(mask & 1, x[i], 0) + weird_abs(mask & 2, y[i], 0) ;
                long long left = i == 0 ? -1e18 : pre[i - 1];
                long long right = i == n - 1 ? -1e18 : suf[i + 1];
                ll req=max(cur_v + left, cur_v + right);
                ans = max(ans,req);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 11436
(let ((n (read))
      (lst '(2 1 3 4 7 11 18 29 47 76 123 199 322 521 843 1364 2207 3571 5778 9349 15127 24476 39603 64079 103682 167761 271443 439204 710647 1149851 1860498 3010349 4870847 7881196 12752043 20633239 33385282 54018521 87403803 141422324 228826127 370248451 599074578 969323029 1568397607 2537720636 4106118243 6643838879 10749957122 17393796001 28143753123 45537549124
 73681302247 119218851371 192900153618 312119004989 505019158607 817138163596 1322157322203 2139295485799 3461452808002 5600748293801 9062201101803 14662949395604 23725150497407 38388099893011 62113250390418 100501350283429 162614600673847 263115950957276 425730551631123 688846502588399 1114577054219522 1803423556807921 2918000611027443 4721424167835364
 7639424778862807 12360848946698171 20000273725560978 32361122672259149 52361396397820127 84722519070079276 137083915467899403 221806434537978679 358890350005878082 580696784543856761 939587134549734843)))

  (format t "~A~%"
          (nth n lst)))


Measured memory_bytes: 24036
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int grid[3][3], a[3], b[3];
    
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>grid[i][j];
        }
    }
    
    for(int a1=-100; a1<=100; a1++){
        a[0]=a1;
        b[0]=grid[0][0]-a1;
        b[1]=grid[0][1]-a1;
        b[2]=grid[0][2]-a1;
        a[1]=grid[1][0]-b[0];
        a[2]=grid[2][0]-b[0];
        
        /*
        if(!a1){
            for(int i=0; i<3; i++){
                cout<<a[i]<<" "<<b[i]<<endl;
            }
        }
        */
        
        bool works=true;
        for(int i=1; i<=2; i++){
            for(int j=1; j<=2; j++){
                works=works&&(grid[i][j]==a[i]+b[j]);
            }
        }
        if(works){
            cout<<"Yes";
            return 0;
        }
        
        
        
        
        
    }
    
    cout<<"No";
    
   
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	n %= 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
		cout<<"hon"<<endl;
	}else if(n == 0 || n == 1 || n == 6 || n == 8){
		cout<<"pon"<<endl;
	}else{
		cout<<"bon"<<endl;
	}

	return 0;
}

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

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

  int n;
  cin >> n;

  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  
  sort(a.begin(),a.end());

  int ans = 0;
  vector<int> used(1100000,0);
  vector<int> check(n, 0);
  map<int,int> mp;

  for (int i = 0; i < n; i++) {
    int x = a[i];
    mp[x]++;

    if(used[x]) continue;

    ans++;

    check[i] = 1;
    int add = x;
    while(x < 1010000) {
      used[x] = 1;
      x += add;
    }
  }

  for (int i = 0; i < n; i++) {
    if(check[i] && mp[a[i]] > 1) ans--;
  }

  cout << ans << '\n';
}


Measured memory_bytes: 18332
A,B,C,D = input().split(' ')
A,B,C,D = int(A),int(B),int(C),int(D)

while (A > 0) and (C > 0):
	C = C - B
	if C <= 0:
		break
	A = A - D
	if A <= 0:
		break

if(A <= 0):
	print('No')
else:
	print('Yes')

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;

int main() {
	cout << fixed << setprecision(0);
	int N, M;
	cin >> N >> M;
	double passable = pow(0.5, M);
	//1回で通る確率:
	double pass = 0;
	for (size_t i = 1; i<100000; i++)
	{
		pass += (double)((N-M)*100+M * 1900)*i * pow((1.0 - passable), i - 1) * passable;
		//100 5cout << pass << endl;
	}
	
	cout << pass;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 10, MOD = 1e9 + 7;

int N, M, S, T;
vector<pi> Ed[MAX_N];
ll Dis[2][MAX_N]; int Cnt[2][MAX_N], Vis[2][MAX_N];

typedef pair<ll, int> pli;
void getDis(int s, int t, int k) {
	priority_queue<pli, vector<pli>, greater<pli>> Q;
	for(int i=1; i<=N; i++) Dis[k][i] = LINF;
	Cnt[k][s] = 1;
	Q.emplace(Dis[k][s] = 0, s);
	while(!Q.empty()) {
		ll d; int v; tie(d, v) = Q.top(); Q.pop();
		if(Vis[k][v]) continue; Vis[k][v] = true;
		for(pi &val : Ed[v]) {
			int w, d; tie(w, d) = val;
			if(Dis[k][w] + d == Dis[k][v]) Cnt[k][v] += Cnt[k][w], Cnt[k][v] %= MOD;
		}
		for(pi &val : Ed[v]) {
			int w, d; tie(w, d) = val;
			if(!Vis[k][w] && Dis[k][w] > Dis[k][v] + d) Q.emplace(Dis[k][w] = Dis[k][v] + d, w);
		}
	}
}
int main() {
	cin >> N >> M >> S >> T;
	for(int i=0; i<M; i++) {
		int x, y, c; scanf("%d%d%d", &x, &y, &c);
		Ed[x].emplace_back(y, c);
		Ed[y].emplace_back(x, c);
	}
	getDis(S, T, 0);
	getDis(T, S, 1);

	ll ans = 1ll * Cnt[0][T] * Cnt[0][T] % MOD;
	ll D = Dis[0][T];
	for(int v=1; v<=N; v++) {
		for(auto &val : Ed[v]) {
			int w, d; tie(w, d) = val;
			if(Dis[0][v]*2 < D && Dis[1][w]*2 < D && Dis[0][v] + Dis[1][w] + d == D)
				ans -= 1ll * Cnt[0][v] * Cnt[0][v] % MOD * Cnt[1][w] % MOD * Cnt[1][w] % MOD;
		}
		if(Dis[0][v] * 2 == D) 
			ans -= 1ll * Cnt[0][v] * Cnt[0][v] % MOD * Cnt[1][v] % MOD * Cnt[1][v] % MOD;
		ans %= MOD;
	}
	ans = (ans + MOD) % MOD;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 15060