akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int k;
double p,e,t;

double solve(double l, double r, int c){
  if(t-e<=l&&r<=t+e) return 1;
  double mid = (l+r)/2;
  if(c==k){
    if(t-e<=mid&&mid<=t+e) return 1;
    else return 0;
  }
  double ans = 0;
  if(mid>=t-e){
    ans+=(mid>=t?1-p:p)*solve(l,mid,c+1);
  }
  if(mid<=t+e){
    ans+=(mid<t?1-p:p)*solve(mid,r,c+1);
  }
  return ans;
}

int main(){
  double l,r;
  cin >> k >> l >> r;
  cin >> p >> e >> t;
  cout << fixed << setprecision(10) << solve(l,r,0) << endl;
  return 0;
}



Measured memory_bytes: 3288
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int m,f,r;
	while(1){
		cin >> m >> f >> r;
		if(m==-1&&f==-1&&r==-1) break;
		if(m==-1||f==-1) cout << "F" << endl;
		else if(m+f>=80) cout << "A" << endl;
		else if(65<=m+f&&m+f<80) cout << "B" << endl;
		else if(50<=m+f&&m+f<65) cout << "C" << endl;
		else if(30<=m+f&&m+f<50&&r<50) cout << "D" << endl;
		else if(30<=m+f&&m+f<50&&r>=50) cout << "C" << endl;
		else if(m+f<30) cout << "F" << endl;
	}
}

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

int main(void) {
    ll N,K; cin >> N >> K;
    ll ans;
    ll x=N/K;
    N -= x*K;
    if(abs(N-K)<N) ans = abs(N-K);
    else ans = N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    vector<pii> v(n);

    int a,b;
    for(int i=0;i<n;++i)
    {
        cin>>a>>b;
        v[i].F=a+b;
        v[i].S=a-b;
    }

    sort(all(v));

    int ans=0,cur=-inf;
    for(int i=0;i<n;++i)
    {
        if(cur<=v[i].S)
        {
            ++ans;
            cur=v[i].F;
        }
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 1792
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		int a=sc.nextInt();
		double p=3.141592653589793;
		System.out.println(2*a*p);
		//String S=sc.next();
		//int v[]=new int[a];
		
		
		 
		
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 35900
#include <iostream>
#include <cmath>
using namespace std;
int x[102],y[102],h[102];
int c_x,c_y,c_h;
int max_h;
int main()
{
	int n;
	scanf("%d",&n);
	max_h = -1;
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d%d%d",x + i,y + i,h + i);
		max_h = max(max_h,h[i]);
	}
	int sign = 1;
	for(c_h = max_h;sign;c_h ++)
		for(c_x = 0;sign && c_x <= 100;c_x ++)
			for(c_y = 0;sign && c_y <= 100;c_y ++)
			{
				int i = 1;
				for(;i <= n;i ++)
					if(h[i] != max(0,(c_h - abs(c_x - x[i]) - abs(c_y - y[i]))))
						break;
				if(i > n)
					sign = 0;
			}
	printf("%d %d %d\n",c_x - 1,c_y - 1,c_h - 1);
	return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll b[40]={0};
    for(ll i=0;i<n;i++){
        cin>>a[i];
        for(ll j=0;j<40;j++){
            if(a[i]&(1LL<<j))b[j]++;
        }
    }

    ll num=0;
    for(ll i=39;i>=0;i--){
        if((b[i]<(n-b[i]))&&((1LL<<i)+num<=k)){
            num+=(1LL<<i);
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=num^a[i];
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

long long C[51][51];
void comb_table(int N){
  for(int i=0;i<=N;++i){
    for(int j=0;j<=i;++j){
      if(j==0 or j==i){
        C[i][j]=1LL;
      }else{
        C[i][j]=(C[i-1][j-1]+C[i-1][j]);
      }
    }
  }
}

int main()
{
  int N,A,B;
  cin>>N>>A>>B;
  cout.precision(20);
  comb_table(N);
  vector <long long> v(N);
  for(int i=0;i<N;i++){
     cin>>v[i];
  }
  sort(v.rbegin(),v.rend());
  long long sum = accumulate(v.begin(),next(v.begin(),A),0LL);
  cout <<fixed<<(double)sum/A << endl;
  
  long long ans=0LL;
  long long tmp=v[A-1];
  int left = distance(v.begin(),find(v.begin(),v.end(),tmp));
  sort(v.begin(),v.end());
  int right = N-distance(v.begin(),find(v.begin(),v.end(),tmp))-1;
  sort(v.rbegin(),v.rend());
  if(v[0]!=v[A-1]){
    ans=C[right-left+1][A-left];
  }else{
    for(int i=A;i<=B;i++){
      ans+=C[right+1][i];
    }
  }
  if (ans==0) ans++;
  cout<< ans <<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void insertionSort(int[] A, int n) {

		for (int i = 1; i < n; i++) {

			printArray(A, n);

			int v = A[i];
			int j = i - 1;

			while (j >= 0 && A[j] > v) {

				A[j + 1] = A[j];
				j--;

			}

			A[j + 1] = v;
		}

		printArray(A, n);

	}

	public static void printArray(int[] A, int n) {

		for (int i = 0; i < n - 1; i++) {

			System.out.print(A[i] + " ");
		}
		System.out.println(A[n - 1]);
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int A[] = new int[n];

		for (int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}
		sc.close();

		insertionSort(A, n);

	}

}



Measured memory_bytes: 32724
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int n,a,b;
	cin >> n >> a >> b;
	int tot=n*a;
	if(tot>b)
	{
		cout << b;
	}
	else
	cout << tot;
	
	return 0;
} 

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

int N;

signed main(){
    cin>>N;
    map<int,int>cnt;
    rep(i,N){
        int a;cin>>a;
        cnt[a]++;
    }

    vint v;
    for(auto p:cnt)v.pb(p.se);
    sort(all(v));
    
    vint acc(v.size()+1);
    rep(i,v.size())acc[i+1]=acc[i]+v[i];
    for(int i=1;i<=N;i++){
        if(v.size()<i){
            puts("0");
            continue;
        }
        int lb=0,ub=N+1;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            int k=lower_bound(all(v),mid)-v.begin();
            int tmp=acc[k]+(v.size()-k)*mid;
            if(tmp/i>=mid)lb=mid;
            else ub=mid;
        }
        printf("%lld\n",lb);
    }
    return 0;
}

Measured memory_bytes: 25068
#include<cstdio>
const int MAXN=43,MAXS=(1<<18)+3,MOD=1000000007;

int N,X,Y,Z;
long long dp[MAXN][MAXS];
long long pow10[MAXN];

int main()
{
	scanf("%d%d%d%d",&N,&X,&Y,&Z);
	pow10[0]=1;
	for(int i=1;i<=N;i++)
		pow10[i]=(pow10[i-1]*10LL)%MOD;
	long long ans=0;
	dp[0][1]=1;
	for(int i=0;i<=N;i++)
		for(int s=1;s<(1<<18);s++)
			if(dp[i][s])
			{
				if((s&(1<<Z))&&(s&(1<<(Y+Z)))&&(s&(1<<(X+Y+Z))))
				{
					(ans+=1LL*dp[i][s]*pow10[N-i]%MOD)%=MOD;
					continue;
				}
				for(int k=1;k<=10;k++)
					(dp[i+1][((s<<k)|1)&((1<<18)-1)]+=dp[i][s])%=MOD;
			}
		
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 86144
program prob2
    implicit none
    character(len=30)::s
    integer::c(26), i, l, tmp
    c = 0
    read(*,*) s
    l = len_trim(s)
    do i = 1, l
        tmp = ichar(s(i:i)) - ichar('a') + 1
        if(c(tmp) == 1) then
            write(*,'(a)') "no"
            stop
        else
        	c(tmp) = 1
        end if
    end do
    write(*,'(a)') "yes"
    stop
end program

Measured memory_bytes: 2908
import java.util.Scanner;

//Parallelism
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n--!=0){
			double[] a = new double[8];
			for(int i=0;i<8;i++)a[i]=sc.nextDouble();
			double e = (a[2]-a[0])*(a[7]-a[5])-(a[3]-a[1])*(a[6]-a[4]);
			System.out.println(e==0?"YES":"NO");
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mx = 3000;
double dp[mx],coin[mx],p;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    //for(int i=1;i<=n;i++)
        //cin>>coin[i];
    dp[0] =1;
    for(int i=1;i<=n;i++)
        {
            cin>>p;
            for(int j=i;j>0;j--)
            dp[j] = (dp[j]*(1.0-p) +dp[j-1]*p);
            dp[0] = dp[0]*(1-p);

        }

    double ans =0;
    for(int i=(n+1)/2;i<=n;i++)
        ans+= dp[i];
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
A, B = map(float, input().split())
aa = int(A)
b_100 = int(round(100 * B))

seki = aa * b_100
ans = seki // 100

# ans=math.floor(aa*b_100/100)

# ab = Decimal(A) * Decimal(B)
# ans = math.floor(ab)

print(ans)

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

using namespace std;
int main(){
	int t;
	cin >> t;
	double ans=0;
	while (t-->0){
		double x;
		string u;
		cin >> x >> u;
		if (u[0]=='J')
			ans += x;
		else 
			ans += 380000.0*x;
	}
	printf("%.8lf",ans);
}

Measured memory_bytes: 256
import itertools

def main():
    
    input_lines_n = input()
    n = int(input_lines_n)
    xyz_max = 100
    l = [0] * 10001
    
    for x, y, z in itertools.product(range(xyz_max), range(xyz_max), range(xyz_max)):
        fn = 0
        if x > 0 and y > 0 and z > 0:
            fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if fn <= n:
                l[fn] += 1
    
    for i in range(1, n+1):
        print(l[i])
                    
    
if __name__ == "__main__":
    main()


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

int main(){
    std::vector<std::vector<int>> grid(3, std::vector<int>(3));
    int sum = 0;
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            std::cin >> grid.at(i).at(j);
            sum += grid.at(i).at(j);
        }
    }

    int a, b, c, d, e, f;
    for(int i = 0; i < 2; ++i){
        a = grid.at(0).at(i + 1) - grid.at(0).at(i);
        b = grid.at(1).at(i + 1) - grid.at(1).at(i);
        c = grid.at(2).at(i + 1) - grid.at(2).at(i);
        d = grid.at(i + 1).at(0) - grid.at(i).at(0);
        e = grid.at(i + 1).at(1) - grid.at(i).at(1);
        f = grid.at(i + 1).at(2) - grid.at(i).at(2);
    }

    std::string ans = "No";
    if(a == b && b == c && d == e && e == f){
        ans = "Yes";
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int N, maxim = 0;
    cin >> N;

    vector<ll> V(N+1);

    for (int i = 0; i < N; i++)
        cin >> V[i];

    V[N] = (10e+9) + 7; 
    
    for (int i = 0; i < N;i++) {
        int k = 0;
        while (V[i] >= V[i+1]) {
            k++;
            i++;
       }
        maxim = max(maxim, k);
    }

    cout << maxim << endl;
    
    return 0;
}

Measured memory_bytes: 1024
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N, T = map(int, input().split())
    dp = [0] * (T + 1)
    AB = []
    for k in range(N):
        a, b = map(int, input().split())
        AB.append((a, b))

    AB.sort()
    maxdp = 0
    temp = 1
    for i in range(N):
        a, b = AB[i]  # a:time  b:value
        temp += a
        dp[T] = max(maxdp + b, dp[T])
        for j in range(min(T - 1, temp), a - 1, -1):
            if dp[j] < dp[j-a] +b:
                dp[j] = dp[j - a] + b
                maxdp = max(dp[j], maxdp)
    print(dp[T])


if __name__ == "__main__":
    main()


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

vector <int> money ;
int dp [ 100005 ][ 20 ];

int main ( ) {
    int a = 1 ;
    while (a*6 < 100001) {
        money.push_back ( a*6 );
        a=a*6;
    }
    a = 1 ;
    money.push_back (a);
    while ( a*9 < 100001) {
        money.push_back( a*9 );
        a=a*9;
    }
//    cout << "-1";
//    return 0;
    int n;
    cin >> n;
    for ( int i = money.size()-1 ; i>= 0 ;i-- ) {
        for ( int j = 0 ; j <= n ; j++ ) {
            if ( j-money[i] < 0 && i == money.size()-1) dp[j][i%2] = 1100000;
            else if ( j-money[i]==0 ) dp[j][i%2] = 1;
            else if ( j-money[i] < 0 ) dp[j][i%2] = dp[j][(i+1)%2];
            else if ( i == money.size()-1 ) dp[j][i%2] = dp[j-money[i]][i%2]+1 ;
            else dp[j][i%2] = min ( dp[j-money[i]][i%2]+1, min ( dp[j-money[i]][(i+1)%2]+1, dp [j][(i+1)%2] ) );
        }
    }
    cout << dp [n][0] << '\n';
    return 0;
}


Measured memory_bytes: 8192
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    using namespace std;
    #define INF 10000000;
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

  
  
    int main(){
      string s,t;
      cin >>s>>t;
      string res = t+s;
      cout << res <<endl;
      
    }
      


    


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var NKTUVL=(Arr.shift()).split(" ").map(Number);
var N=NKTUVL[0];
var K=NKTUVL[1];
var T=NKTUVL[2];
var U=NKTUVL[3];
var V=NKTUVL[4];
var L=NKTUVL[5];
var time=0;
var obj={};
for(var i=0;i<N;i++)obj[Arr.shift()-0]=true;
var fast=0;
var stock=0;
for(var i=0;i<L;i++){
   var now=(obj.hasOwnProperty(i))?true:false;
   if(fast==0 && now==true){time+=1/V;fast=(T*V-1);continue;}
   if(fast==0 && now==false && stock==0){time+=1/U;continue;}
   if(fast==0 && now==false && stock>0){time+=1/V;fast=(T*V-1);stock--;continue;}
   if(fast>0 && now==false){time+=1/V;fast--;continue;}
   if(fast>0 && now==true && stock+1<=K){time+=1/V;fast--;stock++;continue;}
   if(fast>0 && now==true && stock+1>K){time+=1/V;fast=(T*V-1);continue;}
}
console.log(time.toFixed(9));

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

using namespace std;

#define f first
#define s second
#define pub push_back
#define pob pop_back
	
typedef vector<int> vi;
typedef vector<vi> graf;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> wgraf;

typedef vector<double> vd;
typedef pair<double,double> dd;
typedef vector<dd> vdd;

typedef uint64_t ui64;

int main(){

	int n;
	cin >> n;

	vi del(n);

	for(auto &x: del)
		cin >> x;

	sort(del.begin(), del.end());

	int total = 0;

	for(int i = 0; i < n; i++){

		for(int j = 0; j < i; j++){

			total += del[i]*del[j];

		}

	}

	cout << total << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// const int N = 1e5 + 7;
// typedef long long int lli;
// int a[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k = 2;
    cin >> n;
    vector<int> ve(n, 0);
    for (int i = 0; i < n; i++) cin >> ve[i];
    vector<int> v(n, INT_MAX);
    v[0] = 0;
    for (int i = 1; i < n && i <= k; i++) {
        for (int j = 0; j < i; j++) {
            v[i] = min(v[j] + abs(ve[j] - ve[i]), v[i]);
        }
    }
    for (int i = k + 1; i < n; i++) {
        for (int j = i - k; j < i; j++) {
            v[i] = min(v[j] + abs(ve[j] - ve[i]), v[i]);
        }
    }
    cout << v[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

class ALDS1_1A
{
    static void Main()
    {
        string str = Console.ReadLine();
        int a = int.Parse(str.Split(' ')[0]);
        int b = int.Parse(str.Split(' ')[1]);
        int c;
        if (a < b)
        {
            c = a; a = b; b = c;
        }
        while (true)
        {
            c = a % b;
            if (c == 0) break;
            a = b;
            b = c;
        }
        Console.WriteLine(b);
    }
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n;
  cin >> n;
  int b[n] = {};
  vector<int> a(n - 1);
  REP(i, n - 1) {
    cin >> a[i];
    b[a[i] - 1]++;
  }

  REP(i, n) cout << b[i] << endl;

  return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int maximam;
  maximam=A.at(1)-A.at(0);
  for (int j=0;j<N-1;j++){
    maximam=max(maximam,A.at(j+1)-A.at(j));
  }
  maximam=max(maximam, A.at(0)+K-A.at(N-1));
  cout << K-maximam << endl;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ans = 0
count = [[0,0] for i in range(N)]
for i in range(N):
  for j in range(i):
    if A[i] > A[j]:
      count[i][0] += 1
  for k in range(i+1,N):
    if A[i] > A[k]:
      count[i][1] += 1
  if K%2 == 0:
    ans += count[i][1]*(K*K//2+K//2) + count[i][0]*((K-1)*((K-1)//2+1))
  else:
    ans += count[i][1]*(K*(K//2+1)) + count[i][0]*((K-1)*((K-1)//2)+(K-1)//2)
print(ans%(10**9+7))


Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;

int main() {
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> eat(3,0);
    vector<ll> p(a),q(b),r(c);
    vector<pair<ll,int>> s; 
    rep(i,a) cin >> p[i]; sort(ALL(p));
    rep(i,b) cin >> q[i]; sort(ALL(q));
    rep(i,c) cin >> r[i]; sort(ALL(r));
    rep(i,x) s.push_back(make_pair(p[a-1-i],1));
    rep(i,y) s.push_back(make_pair(q[b-1-i],2));
    rep(i,c) s.push_back(make_pair(r[i],0));
    sort(ALL(s));
    ll ans=0;
    int j = x + y + c -1;
    while(eat[0]<x+y){
        if(s[j].second==1&&eat[1]<x){
            eat[1]++;
            eat[0]++;
            ans += s[j].first;
        } else if (s[j].second==2&&eat[2]<y){
            eat[2]++;
            eat[0]++;
            ans += s[j].first;
        } else {
            eat[0]++;
            ans += s[j].first;
        }
        j--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13984
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <random>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    int D, alp = 26;
    cin >> D;
    vector<int> c(alp), t(D);
    vector<vector<int>> s(D, vector<int>(alp));
    for (int i = 0; i < alp; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < alp; j++) {
            cin >> s[i][j];
        }
    }
    for (int i = 0; i < D; i++) {
        cin >> t[i];
        t[i]--;
    }

    int ans = 0;
    vector<int> last(alp, 0);
    for (int i = 0; i < D; i++) {
        ans += s[i][t[i]];
        last[t[i]] = i + 1;

        for (int j = 0; j < alp; j++) {
            ans -= c[j] * (i - last[j] + 1);
        }

        cout << ans << endl;
    }

    return 0;
}


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

public class Program
{

	static void Main(string[] args)
	{
		var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		var N = array[0];
		var K = array[1];

		if (K <= 1)
		{
			Console.WriteLine(0);
		}
		else
		{
			Console.WriteLine(N - K);
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

ll luc[87];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  luc[0]=2;
  luc[1]=1;
  FOR(i,2,n+1){
    luc[i] = luc[i-1]+luc[i-2];
  }
  cout << luc[n] << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (A, B): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    const N: usize = 1_000_000;
    let mut p = vec![true; N + 1];
    for i in 2..N {
        if p[i] {
            let mut j = 2 * i;
            while j <= N {
                p[j] = false;
                j += i;
            }
        }
    }
    fn gcd(a: i64, b: i64) -> i64 { if b == 0 { a } else { gcd(b, a % b) } }
    let mut g = gcd(A as i64, B as i64) as usize;
    let ds = (1..(N + 1)).filter(|&i| A % i == 0 && B % i == 0 && p[i]).collect::<std::collections::HashSet<usize>>();
    for &d in &ds { while d > 1 && g % d == 0 { g /= d;} }
    let ans = if g > N { ds.len() + 1 } else { ds.len() };

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


Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>

using namespace std;

typedef long long ll;

int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n),cp(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    cp = a;
    sort(cp.begin(), cp.end());
    for(ll i = 0;i < n; i++){
        if(a[i] == cp[n - 1]){
            cout << cp[n - 2] << endl;
        }else{
            cout << cp[n - 1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll t;
  // cin>>t;
  t=1;
  while(t--){
    ll n, cnt=0;
    cin>>n;
    vector<ll> a(n);
    forn(i,0,n)
      cin>>a[i];
    sort(a.begin(),a.end());
    forn(i,0,n-2){
      forn(j,i+1,n-1){
        forn(k,j+1,n){
          if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]){
            if(a[i]+a[j]>a[k])
              cnt++;
          }
        }
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}


Measured memory_bytes: 3664
import java.util.*;
 
public class Main implements Runnable {
 
    private static int MOD = 1_000_000_007;
 
    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }
 
    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }
 
    static void solve(Scanner scanner) {
        int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] b = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        System.out.println(b[0] != a[0] ? 1 : 0);
    }
 
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
#define Yes cout<<"Yes"<<endl; 
#define No cout<<"No"<<endl;
#define YES cout<<"YES"<<endl; 
#define NO cout<<"NO"<<endl;
#define yes cout<<"yes"<<endl; 
#define no cout<<"no"<<endl;

// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
ll a,b,c,d;
cin>>a>>b>>c>>d;
cout<<max({a*c,a*d,b*c,b*d})<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
int n,k;
int a[103];
bool dp[100005];
main() {
    ios::sync_with_stdio(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int x = 1; x <= k; x++)
        for (int j = 1; a[j] <= x&&j<=n; j++)
        if (dp[x - a[j]] == 0)
                dp[x] = 1;
    if (dp[k]) cout << "First";
    else cout << "Second";
}


Measured memory_bytes: 3700
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <stack>
#define MX 1000005
#define INF 1000000005

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

struct UF
{
    int par[MX],rank[MX];
    
    void init(int n)
    {
        for(int i=0;i<n;i++)
        {
            par[i]=i;
            rank[i]=0;
        }
    }
    void rem(int i)
    {
        par[i]=i;
        rank[i]=0;
    }
    int find(int x)
    {
        if(x==par[x]) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y)
    {
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y])
        {
            par[x]=y;
        }
        else
        {
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }
    bool same(int x,int y)
    {
        return find(x)==find(y);
    }
};
UF uf;
vector <int> vec[MX];
vector <P> query[MX];
int id[MX];
bool use[MX];
int dp[MX];

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int p,q,c;
        scanf("%d %d %d",&p,&q,&c);p--,q--,c--;
        query[c].push_back(P(p,q));
    }
    int sz=n;
    for(int i=0;i<MX;i++)
    {
        if(query[i].empty()) continue;
        for(int j=0;j<query[i].size();j++)
        {
            P p=query[i][j];
            uf.rem(p.first);
            uf.rem(p.second);
            id[p.first]=id[p.second]=-1;
            use[p.first]=use[p.second]=false;
        }
        for(int j=0;j<query[i].size();j++)
        {
            P p=query[i][j];
            uf.unite(p.first,p.second);
        }
        for(int j=0;j<query[i].size();j++)
        {
            P p=query[i][j];
            if(!use[p.first])
            {
                use[p.first]=true;
                int r=uf.find(p.first);
                if(id[r]==-1) id[r]=sz++;
                //printf("%d %d: %d\n",r,id[r],p.first);
                vec[p.first].push_back(id[r]);
                vec[id[r]].push_back(p.first);
            }
            if(!use[p.second])
            {
                use[p.second]=true;
                int r=uf.find(p.second);
                if(id[r]==-1) id[r]=sz++;
                //printf("%d %d: %d\n",r,id[r],p.second);
                vec[p.second].push_back(id[r]);
                vec[id[r]].push_back(p.second);
            }
        }
    }
    queue <int> que;
    que.push(0);
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    while(!que.empty())
    {
        int v=que.front();que.pop();
        for(int i=0;i<vec[v].size();i++)
        {
            int to=vec[v][i];
            if(dp[to]==-1)
            {
                dp[to]=dp[v]+1;
                que.push(to);
            }
        }
    }
    if(dp[n-1]==-1) puts("-1");
    else printf("%d\n",dp[n-1]/2);
    return 0;
}
    

Measured memory_bytes: 73600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    int ans = 1 << 30;
    int f = 0;
    for(int i = 0; i < N; i++){
        int H, temp;
        cin >> H;
        temp = (T * 1000 - H * 6) - A * 1000;
        if(temp < 0) temp = -temp;
        if(ans > temp){
            f = i+1;
          	ans = temp;
        }
    }
    cout << f << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            String s = String.valueOf(i);
            if (s.length() % 2 == 1) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


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

#define N 100010
#define pii pair <int, int>
int n;
int arr[N], cnt[N];
pii Max[2], MMax[2]; 

void work(int st)
{
	memset(cnt, 0, sizeof cnt);
	for (int i = st; i <= n; i += 2) ++cnt[arr[i]];
	for (int i = 1; i <= 100000; ++i) 
	{
		if (cnt[i] > Max[st - 1].first)
		{
			MMax[st - 1] = Max[st - 1];
			Max[st - 1] = pii(cnt[i], i);
			
		}
		else if (cnt[i] > MMax[st - 1].first)
		{
			MMax[st - 1] = pii(cnt[i], i);
		}
	}	
}

bool ok()
{
	for (int i = 2; i <= n; ++i) if(arr[i] != arr[i - 1]) return false;
	return true;
}

int main()
{
	while (scanf("%d", &n) != EOF)
	{	
		for (int i = 1; i <= n; ++i) scanf("%d", arr + i); 
		memset(Max, 0, sizeof Max);
		memset(MMax, 0, sizeof MMax);
		work(1), work(2);
		int res = 0;
		if (Max[0].second != Max[1].second) res = n - Max[0].first - Max[1].first;
		else res = n - max(Max[0].first + MMax[1].first, Max[1].first + MMax[0].first);
		printf("%d\n", res);
	}
	return 0;
}


Measured memory_bytes: 1024
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n, m = MI()
    switch = [0 for _ in range(n)]
    for i in range(m):
        l = LI1()
        k = l[0]
        s = l[1:]
        # print(k, s)
        for ss in s:
            switch[ss] = switch[ss] | (1 << i)

    # print(switch)
    P = 0
    for j, l in enumerate(LI()):
        P = P | (l << j)
    # print(P)

    ans = 0
    for i in range(pow(2, n)):
        x = 0
        # print(bin(i))
        for j in range(n):
            # print('  ', j)
            if 1 & (i >> j):
                # print('    Y', x, switch[j])
                x = x ^ switch[j]
                # print(x)
        if x == P:
            ans += 1

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll p[n+1];
    ll a[n+1];
    for(int i=0;i<n;i++){
        cin>>p[i];
        a[p[i]]=i+1;
    }
    set<ll> s;
    s.insert(0);
    s.insert(n+1);
    ll b[n+1];
    memset(b,0,sizeof(b));
    ll x[4];
    set<ll>::iterator itr1,itr2,itr3;

    for(int i=n;i>=1;i--){
        s.insert(a[i]);
        itr1=s.find(a[i]);
        itr2=itr1;
        itr1++;
        x[0]=*itr1-*itr2;
        itr3=itr1;
        itr1++;
        x[1]=(itr1==s.end())?0:*itr1-*itr3;

        ///////
        itr1=itr2;
        itr1--;
        x[2]=*itr2-*itr1;
        itr3=itr1;
        if(itr3==s.begin()){
            x[3]=0;
        }
        else{
            itr1--;
            x[3]=*itr3-*itr1;
        }
        b[i]=x[0]*x[3]+x[1]*x[2];
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=b[i]*i;
    }
    cout << ans<<endl;
    return 0;
}



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

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

int main(){
	string S, T;
	cin >> S >> T;
	int ans=0;
	rep(i,3){
		if(S[i]==T[i]) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# W行H列, x[W][H]
def create_grid(W, H, value = 0):
    return [[ value for _ in range(H)] for _ in range(W)]

########
N, H = l_inpl()
a, b = [], []

for _ in range(N):
    ai, bi = l_inpl()
    a.append(ai)
    b.append(bi)

a.sort()
b.sort()
max_a = max(a)

ans = 0
for bi in b[bisect_right(b, max_a):][::-1]:
    H -= bi
    ans += 1
    if H <= 0:
        break

if H > 0:
    ans += math.ceil(H / max_a)

print(ans)

Measured memory_bytes: 13600
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
A = ILI()
B = ILI()
C = ILI()
ans = sum(B)
for i in range(N-1):
    if A[i+1] - A[i] == 1:
        ans += C[A[i]-1]
print(ans)

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

using namespace std;

int main() {
  char grid[111][111];
  char ans[111][111] = {0};

  int h, w;
  cin >> h >> w;

  for (int i = 0; i < h; i++) {
    scanf("%s", grid[i]);
  }

  for (int i = 0; i < h+2; i++) {
    for (int j = 0; j < w+2; j++) {
      if (i == 0 || i == h+1) {
        ans[i][j] = '#';
      } else if (j == 0 || j == w+1) {
        ans[i][j] = '#';
      } else {
        ans[i][j] = grid[i-1][j-1];
      }
    }
  }

  for (int i = 0; i < h+2; i++) {
    printf("%s\n", ans[i]);
  }

  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int main(void) {
	long x = 0,
		h = 0,
		y = 0;
	//500 100 50 10 5 1
	scanf("%d", &x);
	while (x != 0) {
		if (x < 5 && x != 0) {
			printf("%d", h);
			return 0;
		}
		if (x % 500 == 0) {
			h += 1000;
			x -= 500;
		}
		else if (x % 5 == 0 && x != 0) {
			h += 5;
			x -= 5;
		}
		else  {
			x -= x % 5;
		}
	}
	printf("%d", h);

}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<utility>
using namespace std;

int N;
int B[2000100];
long long ans;
long long ans2;

int main(){

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

	sort(B, B + N);

	for (int i = 0; i < N; i++){
		ans += abs(B[i] - B[N / 2]);
	}
	for (int i = 0; i < N; i++){
		ans2 += abs(B[i] - B[N / 2 - 1]);
	}

	cout << min(ans,ans2) << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;
    double x = 0.0;
    REP(i, N) x += 1.0 / A[i];
    x = 1.0 / x;
    Out(x);
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
a = gets.strip.split.map(&:to_i)
b = Array.new(a.max-a.min+1,0)
for i in a.min..a.max 
    
    for j in 0..N-1

        b[i-a.min] += (a[j] - i ) ** 2

    end

end

puts b.min

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int *slime;
    int N , magic = 0;
    cin >> N;
    slime = new int[N];
    for(int i = 0;i < N;i++){
        cin >> slime[i];
    }
    for(int i = 1;i < N;i++){
        if(slime[i-1] == slime[i]){
            slime[i]++;
            if(slime[i] == slime[i + 1]){
                slime[i]++;
            }
            magic++;
        }
    }
    cout << magic << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
h[0]-=1
for i in range(1,n-1):
    if h[i]>h[i+1] or h[i]>h[i-1]:
        h[i]-=1
for i in range(n-1):
    if h[i]>h[i+1]:
        print("No")
        quit()
print("Yes")

Measured memory_bytes: 14704
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };

int N = 1e3 + 7;



vector<int> conn[2007];
bool vis[2007];
int dist[2007];


void bfs(int src) {
	queue<int> q;
	q.push(src);
	dist[src] = 0;
	vis[src] = 1;
	while(q.size()) {
		int node = q.front();
		q.pop();
		for (auto i : conn[node]) {
			if (!vis[i]) {
				vis[i] = 1;
				q.push(i);
				dist[i] = dist[node] + 1;
			}
		}
	}
}



int main() {
	fastIO;
	int n, x, y;
	cin >> n >> x >> y;
	for (int i = 1; i < n; i++) {
		conn[i].push_back(i+1);
		conn[i+1].push_back(i);
	}
	conn[x].push_back(y);
	conn[y].push_back(x);

	map<int, int> count;
	for (int i = 1; i <= n; i++) {
		memset(vis, 0, sizeof vis);
		bfs(i);
		for (int j = i+1; j <= n; j++) {
			count[dist[j]]++;
		}
	}

	for (int i = 1; i < n; i++) {
		cout << count[i] << endl;
	}

}


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

int main()
{
    ll x,y;
    cin>>x>>y;
    ll ans =0;
    while(x<=y)
    {
        ans++;
        x = x*2;
    }
    cout<<ans;
}

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

int main(){
	string s;
	cin>>s;
	
	s.push_back('@');
	int ryoiki=0;
	int now=s[0];
	for(int i=0;i<s.size();i++){
		if(now!=s[i]){
			ryoiki++;
			now=s[i];
			}
		}
		
	if(ryoiki%2==1){
		cout<<s[0]<<endl;
		}	
	else{
		cout<<'o'<<endl;
		}	
		return 0;
	}

Measured memory_bytes: 3184
#include<iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    double ave = (double)(a + b) / 2;
    if (ave == (int)ave) {
        cout << ave << endl;
    } else {
        cout << (int)ave + 1 << endl;
    }
    return 0;
}


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


int main(){
    while(true){
        int x, y;
        cin >> x >> y;
        if(x==0 && y==0) break;
        if(x>y) swap(x, y);
        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if B % A == 0:
        print(A+B)
    else:
        print(B-A)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940