akhauriyash/Code-Regression huggingface dataset:
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>

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

using namespace std;

struct block{
	int h,w;
	vector<string> B;
	block(int h,int w):h(h),w(w){
		B.resize(h);
		rep(i,h) B[i].resize(w);
	}
};

// 余分な枠を削除
block trim(const block &P){
	int h=P.h,w=P.w;
	int t,b,l,r;
	for(t= 0 ;;t++) if(count(P.B[t].begin(),P.B[t].end(),'#')>0) break;
	for(b=h-1;;b--) if(count(P.B[b].begin(),P.B[b].end(),'#')>0) break;
	for(l= 0 ;;l++){ bool ok=false; rep(i,h) if(P.B[i][l]=='#') { ok=true; break; } if(ok) break; }
	for(r=w-1;;r--){ bool ok=false; rep(i,h) if(P.B[i][r]=='#') { ok=true; break; } if(ok) break; }

	block res(b-t+1,r-l+1);
	rep(i,res.h) res.B[i]=P.B[t+i].substr(l,res.w);
	return res;
}

bool overlap(const block &P,const block &Q,int dy,int dx){
	rep(i,Q.h) rep(j,Q.w) if(P.B[i+dy][j+dx]=='#' && Q.B[i][j]=='#') return true;
	return false;
}

block merge(const block &P,const block &Q,int dy,int dx){
	block res=P;
	rep(i,Q.h) rep(j,Q.w) if(Q.B[i][j]=='#') res.B[i+dy][j+dx]='#';
	return res;
}

int count_line(const block &P){
	int h=P.h,w=P.w;
	int res=0;
	rep(i,h) if(count(P.B[i].begin(),P.B[i].end(),'#')==w) res++;
	return res;
}

block spin(const block &P){
	int h=P.h,w=P.w;
	block res(w,h);
	rep(i,h) rep(j,w) res.B[j][h-i-1]=P.B[i][j];
	return res;
}

int solve(){
	int h,w;
	cin>>h>>w;
	block P(h,w); // piece
	rep(i,P.h) cin>>P.B[i];

	cin>>h>>w;
	block F(h,w); // field
	rep(i,F.h) cin>>F.B[i];

	P=trim(P);

	int ans=-1;
	rep(t,4){
		rep(i,F.h-P.h+1) rep(j,F.w-P.w+1) if(!overlap(F,P,i,j)) {
			ans=max(ans,count_line(merge(F,P,i,j)));
		}
		P=spin(P);
	}
	return ans;
}

int main(){
	int T; cin>>T;
	while(T--) cout<<solve()<<endl;
	return 0;
}

Measured memory_bytes: 968
/* Simplicity and Goodness */

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

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 3e3+2;


void solve()
{
    int n;
    scn(n);

    vl a(n);

    rep(i, 0, n)
    lscn(a[i]), a[i] -= i;

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

    ll median = a[n/2];

    ll sum = 0;

    rep(i, 0, n)
    sum += abs(a[i] - median);

    lprin(sum);
}

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

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

int main() {
  char x,y;
  cin >> x >> y;

  char c;
  if (x<y)
    c='<';
  else if (x==y)
    c='=';
  else
    c='>';

  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]
alphabets=[chr(i) for i in range(97,123)]
ans=[10**10]*26

for i in range(26):
    for j in s:
        p=j.count(alphabets[i])
        ans[i]=min(ans[i],p)
        
moji=""
for i in range(26):
    moji+=alphabets[i]*ans[i]
print(moji)
    

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int n, h[100002];
bool judge = true;

int main() {

	cin >> n;
	rep(i, n) cin >> h[i];

	for (int i = n - 2; i >= 0;i--) {
		if (h[i] - 1 == h[i + 1]) {
			h[i]--;
		}
		else if (h[i] - 1 > h[i + 1]) {
			judge = false;
			break;
		}
	}

	if (judge)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int n, x, _max=-1000000, _min = 1000000, numofmax, numofmin;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(x>_max){
			_max = x;
			numofmax = i;
		}
		if(x<_min){
			_min = x;
			numofmin = i;
		}
	}
	cout<<2*n-1<<endl;
	if(abs(_max)>abs(_min)){
		for(int i=1;i<=n;i++){
			cout<<numofmax<<" "<<i<<endl;
		}
		for(int i=1;i<n;i++)
			cout<<i<<" "<<i+1<<endl;
	}
	else{
		for(int i=1;i<=n;i++){
			cout<<numofmin<<" "<<i<<endl;
		}
		for(int i=n;i>1;i--)
			cout<<i<<" "<<i-1<<endl;
	}

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a, b;
    char op;
    do
    {
        cin >> a >> op >> b;
        switch (op)
        {
        case '+':cout << a + b << endl; break;
        case '-':cout << a - b << endl; break;
        case '*':cout << a * b << endl; break;
        case'/' :cout << a / b << endl; break;
        }
    } while (op != '?');
  
}


Measured memory_bytes: 3096
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        String [] s = sc.next().split("");

        long k = sc.nextLong();

        long sum = 0;

        int ans = 0;

        for (int i = 0; i < s.length; i++) {
            int value = Integer.parseInt(s[i]);
            if (value == 1) {
                sum += 1;
            }
            if (sum >= k || value != 1) {
                ans = value;
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,a;
    for(int i=1,z;i<=5;i++)
    {
        cin>>x;
        if(x==0)a=i;

    }
    cout<<a<<endl;



    return 0;
}


Measured memory_bytes: 3572
import java.io.*;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    new Main().solve();
  }

  private void solve() {
    try(InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {

      final int A = in.nextInt();
      final int B = in.nextInt();
      final int Q = in.nextInt();

      long[] s = new long[A+1];
      for (int i = 0; i < A; i++) {
        s[i] = in.nextLong();
      }
      s[A] = 1L << 40;

      long[] t = new long[B+1];
      for (int i = 0; i < B; i++) {
        t[i] = in.nextLong();
      }
      t[B] = 1L << 40;

      for (int q = 0; q < Q; q++) {
        long x = in.nextLong();
        long dist = 1L << 50;

        for (int c = 0; c < 2; c++) {
          long[] af = c == 0 ? s : t;
          long[] as = c == 0 ? t : s;

          for (int i = 0; i < 2; i++) {
            int posF = binarySearch(af, x) + i;
            long df = af[posF];

            for (int j = 0; j < 2; j++) {
              int posS = binarySearch(as, x) + j;
              long ds = as[posS];
              
              long d = Math.abs(x - df);
              d += Math.abs(df - ds);
              dist = Math.min(dist, d);
            }
          }
        }

        out.println(dist);
      }
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private int binarySearch(long[] arr, long x) {
    int left = 0;
    int right = arr.length;

    return loop(arr, x, left, right);
  }

  private int loop(long[] arr, long x, int left, int right) {
    if(right - left < 2) return left;
    else {
      int mid = (left + right) / 2;
      if(arr[mid] <= x) return loop(arr, x, mid, right);
      else return loop(arr, x, left, mid);
    }
  }

  static class InputReader implements AutoCloseable {
    static public BufferedReader br;
    static public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream), 32768);
      st = null;
    }
    public String next() {
      if (st == null || !st.hasMoreTokens()) {
        try { st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      }
      return st.nextToken();
    }
    public int nextInt() { return Integer.parseInt(next()); }
    public long nextLong() { return Long.parseLong(next()); }
    public int[] mapInt(int len) {
      int[] ret = new int[len];
      for (int i = 0; i < len; i++) ret[i] = Integer.parseInt(next());
      return ret;
    }
    public long[] mapLong(int len) {
      long[] ret = new long[len];
      for (int i = 0; i < len; i++) ret[i] = Long.parseLong(next());
      return ret;
    }
    @Override public void close() throws IOException { br.close(); }
  }
}

Measured memory_bytes: 52992
n = gets.to_i
arr = []

n.times{
    
    arr<<gets.chomp}
    
if arr.uniq.length<n
    
    puts "No"
    exit
end

i = 0
(n-1).times{
    
  if arr[i][-1] != arr[i+1][0]
  puts "No"
  exit
  end
    
   i+=1 
}

puts "Yes"



Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#define IL inline
#define x first
#define y second
typedef long long ll;
using namespace std;
const	int N=500010;
struct node{
	int l;
	int r;
	int sum;
}tr[N*4][26];
void build(int u,int l,int r,int x)
{
	tr[u][x]={l,r,0};
	if(l==r)	return;
	else
	{
		int mid=l+r>>1;
		build(u<<1,l,mid,x),build(u<<1|1,mid+1,r,x);
	}
}
void modify(int u,int pos,int x,int val)
{
	if(tr[u][x].l==pos&&tr[u][x].r==pos)
	{
		tr[u][x].sum+=val;
	}
	else
	{
		int mid=tr[u][x].l+tr[u][x].r>>1;
		if(pos<=mid)	modify(u<<1,pos,x,val);
		else			modify(u<<1|1,pos,x,val);
		tr[u][x].sum=tr[u<<1|1][x].sum+tr[u<<1][x].sum;
	}
}
int query(int u,int l,int r,int x)
{
	if(tr[u][x].l>=l&&tr[u][x].r<=r)
	return tr[u][x].sum;
	else
	{
		int mid=tr[u][x].l+tr[u][x].r>>1;
		int ans=0;
		if(l<=mid)	ans+=query(u<<1,l,r,x);
		if(r>mid)	ans+=query(u<<1|1,l,r,x);
		return ans;
	}
}
int main()
{
	int n;
	char s[N];
	cin>>n;
	scanf("%s",s+1);
	int m;
	cin>>m;
	for(int i=0;i<=25;i++)
	build(1,1,n,i);
	for(int i=1;s[i];i++)
	modify(1,i,s[i]-'a',1);
	while(m--)
	{
		int op;
		cin>>op;
		if(op==1)
		{
			char a[2];
			int x;
			cin>>x;
			scanf("%s",a);
			int  t=a[0]-'a';
			modify(1,x,s[x]-'a',-1);
			modify(1,x,t,1);
			s[x]=a[0];
		}
		else
		{
			int l,r;
			cin>>l>>r;
			int ans=0;
			for(int i=0;i<=25;i++)
			if(query(1,l,r,i)>0)
			ans++;
			cout<<ans<<endl;
		}
	}
    return 0;
}





Measured memory_bytes: 322304
W, H, N = [int(x) for x in input().split()]
L = [[int(y) for y in input().split()] for _ in range(N)]
xmin = 0
xmax = W
ymin = 0
ymax = H

for i in range(N):
    if L[i][2] == 1 and L[i][0] > xmin:
        xmin = L[i][0]
    elif L[i][2] == 2 and L[i][0] < xmax:
        xmax = L[i][0]
    elif L[i][2] == 3 and L[i][1] > ymin:
        ymin = L[i][1]
    elif L[i][2] == 4 and L[i][1] < ymax:
        ymax = L[i][1]

print((xmax-xmin)*(ymax-ymin) if xmax-xmin > 0 and ymax-ymin > 0 else 0)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
	int N;
	cin>>N;
	int ans=0;
	if(N%2==0)
	ans=N/2;
	else
	ans=N/2+1;
	cout<<ans<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);


 ll k,x;
 cin>>k>>x;
  if(k*500>=x)
  {
      cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  long n;
  cin>>n;
  if(n%2==1){
    cout<<0<<endl;
    return 0;
  }
  else{
    long a=10,b=0;
    while(a<=n){
      long N = n/a;
      b+=N;
      a*=5;
    }
    cout<<b<<endl;
  }
}

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

#define MOD 1000000LL

typedef unsigned long long ll;

int n;
ll dp[1002];
string s[1002];
string utf[4][4] = {
	{"0xxxxxxx","","",""},
	{"110yyyyx","10xxxxxx","",""},
	{"1110yyyy","10yxxxxx","10xxxxxx",""},
	{"11110yyy","10yyxxxx","10xxxxxx","10xxxxxx"}
};

ll check(int idx,int len){
	ll res = 1;
	int xcnt = 0; //rbgp^[ÅyÌÊuÅ, üÍñªxÉÈÁÄ¢é
	int onecnt = 0; //rbgp^[ÅyÌÊuÅ, üÍñª1ÉÈÁÄ¢é

	for(int i=0;i<len;i++){
		for(int j=0;j<8;j++){
			char cu = utf[len-1][i][j];
			char cs = s[idx+i][j];

			if(cu == '0' || cu == '1'){
				if(cs != 'x' && cu != cs) return 0;
			}
			else if(cu == 'x'){
				if(cs == 'x') res = (res * 2) % MOD;
			}
			else{
				if(cs == 'x') xcnt++;
				else if(cs == '1') onecnt++;
			}
		}
	}

	if(len == 1) return res;
	if(onecnt==0 && xcnt==0) return 0;

	if(onecnt == 0) res = (res * ((1<<xcnt) - 1)) % MOD;
	else res = (res * (1<<xcnt)) % MOD;

	return res;
}

int main(void){
	while(cin>>n,n){
		for(int i=0;i<n;i++) cin>>s[i];

		memset(dp,0,sizeof(dp));
		dp[0] = 1;

		for(int i=0;i<n;i++){
			for(int j=1;j<=4;j++){
				if(i+j > n) break;
				ll pat = check(i,j);
				if(pat == 0) continue;
				dp[i+j] = (dp[i+j] + dp[i] * pat) % MOD;
			}
		}

		cout<<dp[n]<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import sys

def main():
    N = int(input())
    t = [0] * (N+1)
    x = [0] * (N+1)
    y = [0] * (N+1)
    for i in range(1, N+1):
        t[i], x[i], y[i] = map(int, input().split())
    
    flag = True
    for i in range(N):
        dt = t[i+1] - t[i]
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
        if dt % 2 != dist % 2 or dt < dist:
            flag = False
            break
            
    print('Yes' if flag else 'No')
    
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 11636
#include <bits/stdc++.h>
#define cinspeed ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N = 1010;

using namespace std;
typedef long long ll;

int main()
{
    cinspeed;

    ll a,b,k;
    cin >> a >> b >> k;

    if(k <= a)
    {
        a -= k;
    }
    else  
    {
        k -= a;
        a = 0;
        if(b >= k)
        b -= k;
        else 
        b = 0;
    }
    cout << a <<" "<< b <<"\n";

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
int N, M, Q;
vector<vector<int>> sum;

// Problem Specific Parameter:
int buildSumTable(vector<int> L, vector<int> R) {
  sum = vector<vector<int>>(N+1, vector<int>(N+1, 0));
  for(int i = 0; i < M; ++i){
    sum[L[i]][R[i]]++;
  }
  for(int i = 1; i <= N; ++i) {
    for(int j = 1; j <= N; ++j) {
      sum[i][j] += sum[i-1][j];
      sum[i][j] += sum[i][j-1];
      sum[i][j] -= sum[i-1][j-1];
    }
  }
  return 0;
}

int getSumRange(int L, int R) {
  int ans = sum[R][R] - sum[R][L-1] - sum[L-1][R] + sum[L-1][L-1];
  return ans;
}

int main() {
  cin >> N >> M >> Q;
  vector<int> L(M), R(M), p(Q), q(Q);
  for(int i = 0; i < M; ++i) cin >> L[i] >> R[i];
  for(int i = 0; i < Q; ++i) cin >> p[i] >> q[i];
  buildSumTable(L, R);
  for(int i = 0; i < Q; ++i) {
    int ans = getSumRange(p[i], q[i]);
    cout << ans << endl;
  }


  return 0;
}


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

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

Measured memory_bytes: 4392
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	instr a, b;

	string s = a + b;

	double c = std::atoi(s.c_str());

	OUT(sqrt(c) - (double)((int)sqrt(c)) == 0.0 ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;
const int maxn = 1e5+10;
int n,c,k;
long long t[maxn];
int findpos(int left,long long x){
    int right = n;
    while (right-left>1) {
        int middle = (left+right)/2;
        if(t[middle]>=x){
            right = middle;
        }else{
            left = middle;
        }
    }
    int pos = left;
    if(t[right]<=x){
        pos = right;
    }
    return pos;
}
bool vis[maxn];
int main(){
    int i,j;
    scanf("%d%d%d",&n,&c,&k);
    for(i=1;i<=n;i++){
        scanf("%lld",t+i);
    }
    sort(t+1, t+1+n);
    memset(vis, true, sizeof(vis));
    int p = 1;
    int kpos;
    long long res = 0;
    int last = -1;
    while(vis[n]){
        kpos = findpos(p, t[p]+k);
        //cout<<"kpos "<<kpos<<" p "<<p<<endl;
//        if(p+c-1<kpos){
//            for(i=p;i<=p+c-1;i++){
//                vis[i] = false;
//            }
//            res ++;
//            p = p+c;
//        }else{
//            for(i=p;i<=kpos;i++){
//                vis[i] =false;
//            }
//            res += kpos - p;
//            p = kpos + 1;
//        }
        int another = (kpos-p+1)%c;
        res += (kpos-p+1)/c;
        for(i=p;i<=kpos-another;i++){
            vis[i] = false;
        }
        p = kpos - another+1;
        if(p == last){
            res++;
            for(i=p;i<=kpos;i++){
                vis[i] =false;
            }
            p = kpos + 1;
            continue;
        }
        last = p;
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n,m;
vector<vector<int>> dat;
vector<int> oe;

//inputします
void input() {
	cin >> n >> m;
}

//ライブラリ置き場



//main
int main() {
    input();
	dat.resize(m);
	oe.resize(m);
	ff(i, 0, m) {
		int a;
		cin >> a;
		dat[i].resize(a);
		ff(j, 0, a) {
			cin >> dat[i][j];
			dat[i][j]--;
		}
	}
	ff(i, 0, m) {
		cin >> oe[i];
	}
	int ans = 0;
	ff(i, 0, 1 << n) {
		bitset<10> sw(i);
      //cout<<sw<<endl;
		int y = 0;
		ff(j, 0, m) {
          //cout<<j<<endl;
			int num = 0;
			ff(k, 0, dat[j].size()) {
				if (sw.test(dat[j][k]))num++;
              //cout<<num<<" ";
			}
          //cout<<num<<endl<<endl;
			if (num % 2 != oe[j]) {
              //cout<<"点灯せず"<<endl;
				y++;
				break;
			}
		}
		if (y == 0){
          ans++;
          //cout<<"全部点灯"<<endl;
        }
	}
	cout << ans << endl;
    return 0;
}

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

int dp[5001][5001],a[5001],n,ans=2;
map<int,int>M;

int main(){
  cin>>n;
  r(i,n)cin>>a[i];
  sort(a,a+n);
  r(i,n)M[a[i]]=i;

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

      dp[i][j] = max( dp[i][j] , 2 );
      ans = max( ans , dp[i][j] );
      int nex = a[j]+(a[j]-a[i]);

      if(M.count(nex)){
        int idx = M[nex];
        dp[j][idx] = max( dp[j][idx] , dp[i][j]+1 );
      }
    }
  }
  cout<< ans <<endl;
}


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

#define int long long
typedef pair<int, int> P;
//#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream & operator>>(istream & is, vector<T> & vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

double d(int x1, int y1, int x2, int y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

signed main() {

	int N;
	cin >> N;
	vector<int> x(N), y(N);
	rep(i, N) cin >> x[i] >> y[i];

	double ans = 0.0;
	vector<int> a(N);
	rep(i, N) a[i] = i;

	int cnt = 0;
	do {
		for (int i = 0; i < N - 1; i++) {
			ans += d(x[a[i]], y[a[i]], x[a[i + 1]], y[a[i + 1]]);
		}
		cnt++;
	} while (next_permutation(a.begin(), a.end()));

	cout << fixed << setprecision(15) << ans / cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int debt = 100000;
	int n;
	int i;
	
	scanf("%d", &n);
	i = 0;
	while (i != n){
		debt = debt + (debt * 0.05);
		debt = ((debt + 999) / 1000) * 1000;
		i++;
	}
	printf("%d\n", debt);
	
	return (0);
}

Measured memory_bytes: 588
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    constexpr ll MOD = 1e9 + 7;
    ll ans = 0;
    ll max_A = *max_element(A.begin(), A.end());
    for (ll i = 1; i <= max_A; i++) {
        vector<ll> C(N + 1);
        C[0] = 0;
        for (ll j = 0; j < N; j++) {
            C[j + 1] = (A[j] > i ? 1 : 0) + C[j];
        }

        for (ll j = 0; j < N; j++) {
            if (A[j] == i) {
                //左にある数
                (ans += K * (K + 1) / 2 % MOD * C[j] % MOD) %= MOD;

                //右にある数
                (ans += K * (K - 1) / 2 % MOD * (C[N] - C[j]) % MOD) %= MOD;
            }
        }
    }

    cout << ans << endl;
}

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


int main(){
  ll n;
  cin >> n;
  ll a[n];
  ll k[n];
  for(int i=0;i<n;i++){
    a[i] = 0;
  }

  for(int i=0;i<n;i++){
    ll temp;
    cin >> temp;
    k[i] = temp-1;
    a[temp-1] += 1;
  }

  ll ans=0;
  for(int i=0;i<n;i++){
    if(a[i]>1){
      ans += (a[i]*(a[i]-1))/2;
    }
  }

  for(int i=0;i<n;i++){
    ll out=0;
    if(a[k[i]]>=2){
      out=ans-(a[k[i]]-1);
    }
    else{
      out = ans;
    }
    cout << out << endl;
  }
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll H, W;
vector<bool> dp(10001, 0);

signed main() {
    cin >> H >> W;
    ll ans = LINF;
    REP(loop, 2) {
        FOR(i, 1, H) {
            ll smin = min({i * W, (H - i) * (W / 2), (H - i) * (W - W / 2)});
            ll smax = max({i * W, (H - i) * (W / 2), (H - i) * (W - W / 2)});
            if(smin) ans = min(ans, smax - smin);
            smin = min({i * W, ((H - i) / 2) * W, (H - i - (H - i) / 2) * W});
            smax = max({i * W, ((H - i) / 2) * W, (H - i - (H - i) / 2) * W});
            if(smin) ans = min(ans, smax - smin);
        }
        swap(H, W);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import numpy as np

S = np.array(list(map(int,input())))

answer_option_A = np.array([0 if i%2 == 0 else 1 for i in range(len(S))])
answer_option_B = np.array([1 if i%2 == 0 else 0 for i in range(len(S))])

answer_option_A = np.logical_xor(S, answer_option_A)
answer_option_B = np.logical_xor(S, answer_option_B)

print(min(answer_option_A.sum(),answer_option_B.sum()))

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

int main() {
    int N; string S; cin >> N >> S;
    int res = 0; int tmp = 0;
    char prev = '?';
    for (int i = 0; i < N; ++i) {
        if (S[i] == prev) {
            res += tmp/2;
            tmp = 1;
        }
        else ++tmp;
        prev = S[i];
    }
    res += tmp/2;
    cout << res << endl;
}



Measured memory_bytes: 3320
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

long long n;
int len,a[105],dp[105][2][2][2][2];
int main(){
	scanf("%lld",&n); n++;
	int i,j,k,x,y,u,v,t1,t2,p,q;
	for (; n; n>>=1) a[++len]=n&1;
	dp[0][1][1][0][1]=1;
	//第i为，与n关系为j,k，有无a+b=v+1<<i，有无a+b=v
	for (i=1; i<=len; i++)
		for (j=0; j<2; j++)
			for (k=0; k<2; k++)
				for (x=0; x<2; x++)
					for (y=0; y<2; y++) if (x+y>0)
						for (u=0; u<=((j)?1:a[i]); u++)
							for (v=0; v<=((k)?1:a[i]); v++){
								t1=t2=0;
								for (p=0; p<2; p++)
									for (q=0; q<2; q++){
										if ((p^q)==u && (x && p+q+1==v+2 || y && p+q==v+2)) t1=1;
										if ((p^q)==u && (x && p+q+1==v || y && p+q==v)) t2=1;
									}
								dp[i][j][k][t1][t2]=(dp[i][j][k][t1][t2]+dp[i-1][j|(u<a[i])][k|(v<a[i])][x][y])%mod;
							}
	printf("%d\n",(dp[len][0][0][0][1]+dp[len][0][0][1][1])%mod);
	return 0;
}


Measured memory_bytes: 256
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (LL I = 0; I < (N); ++I)
#define REPP(I, A, B) for (LL I = (A); I < (B); ++I)
#define RI(X) scanf("%lld", &(X))
#define RII(X, Y) scanf("%lld%lld", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define DRI(X) LL (X); scanf("%lld", &X)
#define DRII(X, Y) LL X, Y; scanf("%lld%lld", &X, &Y)
#define DRIII(X, Y, Z) LL X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<LL>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second


using namespace std;
typedef long long LL;
LL A[200000],sum=0;

int main(){
  DRI(N);
  REP(i,N){
    RI(A[i]);
    sum+=A[i];
  }
  LL cur=0,ans=1e18;
  REP(i,N){
    cur+=A[i];
    if(i!=N-1)ans=min(ans,abs(sum-2*cur));
  }
  printf("%lld\n",ans);
}

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

ll modpow(ll a, ll n, ll modd = 1e9 + 7) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % modd;
        a = a * a % modd;
        n >>= 1;
    }
    return res;
}

int popcnt(int num) {
    int ans = 0;
    while (num > 0) {
        num &= num - 1;
        ans++;
    }
    return ans;
}

int filler(int num) {
    if (num == 0) {
        return 0;
    }
    int res = num % popcnt(num);
    return filler(res) + 1;
}

int main() {
    int n;
    string x;
    cin >> n >> x;
    int basemod = 0;
    int onebase = 0;
    int zerobase = 0;
    rep(i, n) if (x[i] == '1') basemod++;

    rep(i, n) {
        onebase = (onebase * 2 + int(x[i] - '0')) % (basemod + 1);
        if (basemod == 1) continue;
        zerobase = (zerobase * 2 + int(x[i] - '0')) % (basemod - 1);
    }
    rep(i, n) {
        int modthis = basemod;
        if (x[i] == '1') {
            int num = zerobase;
            modthis--;
            if (modthis == 0) {
                cout << 0 << endl;
                continue;
            }
            if (modthis == 1) {
                cout << 1 << endl;
                continue;
            }
            num -= modpow(2, n - i - 1, modthis);
            if (num < 0) num += modthis;
            cout << filler(num) + 1 << endl;
        } else {
            int num = onebase;
            modthis++;
            if (modthis == 1) {
                cout << 1 << endl;
                continue;
            }
            num += modpow(2, n - i - 1, modthis);
            num %= modthis;
            cout << filler(num) + 1 << endl;
        }
    }
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
// #define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}


unordered_map<int,int>mm;
int temp=0;

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    string a;
    cin>>a;
    int n=a.length();
    for(int i=0;i<n;i++)
    {
        temp^=(1<<(a[i]-'a'));  
        for(int j=0;j<26;j++)
        {
            int z=(temp^(1<<j));
            if(z==0)
                mm[temp]=1;
            else if(temp==0)
                mm[temp]=1;
            else if(mm[temp]!=0 && mm[z]!=0)
                mm[temp]=min(mm[temp],mm[z]+1);
            else if(mm[temp]==0&& mm[z]!=0)
                mm[temp]=mm[z]+1;
        }
        if(temp==0)
            mm[temp]=1;
    }
    if(temp==0)
        cout<<1;
    else
        cout<<mm[temp];
    
} 
    


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int ans = inf;
  for(int i = -100; i <= 100; i++) {
    int tmp = 0;
    rep(j,n) {
      tmp += abs(a[j]-i) * abs(a[j]-i);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
    
    char S[101],T[101],ss;
    int i,j,k,c;
    
    scanf("%s %s",S,T);
    
    int len;
    len = strlen(S);
    
    for(i = 0;i < len; i++){
        c = 0;
        for(j = 0; j < len; j++){
            if(S[j] == T[j])c++;
        }
        if(len == c){
            printf("Yes");
            break;
        }
        ss = S[len-1];
        for(k = len-1; k > 0; k--){
            S[k] = S[k-1];
        }
        S[0] = ss;
    }
    
    if(len != c)printf("No");

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#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))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int main(){
    int n;cin>>n;
    map<ll,ll>mp;
    rep(i,n){
        ll a;cin>>a;
        mp[a]++;
    }
    ll res = 0;
    for(auto m : mp){
        if(m.second-m.first>=0)res += m.second-m.first;
        else res += m.second;
    }
    cout<<res<<endl;
}



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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<char, int>;

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

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

signed main(){
    int a, b, c; cin >> a >> b >> c;
    cout << max( { a, b, c } ) - min( { a, b, c } ) << endl;;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef struct {
  char mark;
  int value;
} data;

void BubbleSort(data*, int);
void SelectionSort(data*, int);
int StableJudge(data*, data*, int*, int);

void BubbleSort(data *C, int N) {
  int i,j;
  data temp;

  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(C[j].value < C[j-1].value){
        temp = C[j];
        C[j] = C[j-1];
        C[j-1] = temp;
      }
    }
  }
}

void SelectionSort(data *C, int N){
  int i, j, minj;
  data temp;

  for(i=0;i<N;i++){
    minj = i;
    for(j=i;j<N;j++){
      if(C[j].value < C[minj].value){
        minj = j;
      }
    }
    if(C[i].value != C[minj].value){
      temp = C[i];
      C[i] = C[minj];
      C[minj] = temp;
    }
  }
}

int StableJudge(data *C, data *C_sort, int *list, int N){
  int i, j, n;
  int *mark_C, *mark_C_sort;
  int flag = 0; //is it necessary to free()?

  for(i=0;i<9;i++){
    // If there is the same number
    if(list[i] > 1){
      flag = 1;

      mark_C = (int *)malloc(sizeof(int) * list[i]);
      n = 0;
      for(j=0;j<N;j++){
        if(C[j].value == i+1){
          mark_C[n] = j;
          n++;
        }
        if(n == list[i]) break;
      }

      mark_C_sort = (int *)malloc(sizeof(int) * list[i]);
      n = 0;
      for(j=0;j<N;j++){
        if(C_sort[j].value == i+1){
          mark_C_sort[n] = j;
          n++;
        }
        if(n == list[i]) break;
      }

      for(j=0;j<n;j++){
        if(C[mark_C[j]].mark != C_sort[mark_C_sort[j]].mark) {
            printf("Not stable\n");
          return 0;
        }
      }
    }
  }
  
  if(flag){
    free(mark_C);
    free(mark_C_sort);
  }
  
  printf("Stable\n");
  return 0;
}

int main(){
  int N, i;
  char inp[3];
  data *C, *C_bub, *C_sel;
  // to judge same number
  int list[9] = {0,0,0,0,0,0,0,0,0};

  // data set
  scanf("%d",&N);

  C = (data *)malloc(sizeof(data) * N);
  C_bub = (data *)malloc(sizeof(data) * N);
  C_sel = (data *)malloc(sizeof(data) * N);

  for(i=0;i<N;i++){
    scanf("%s",inp);
    C[i].mark = C_bub[i].mark = C_sel[i].mark = inp[0];
    C[i].value = C_bub[i].value = C_sel[i].value = atoi(&inp[1]);
  }

  // get same number list
  for(i=0;i<N;i++){
    list[C[i].value-1]++;
  }

  // sort
  BubbleSort(C_bub, N);
  SelectionSort(C_sel, N);

  // print
  for(i=0;i<N;i++){
      printf("%c%d",C_bub[i].mark ,C_bub[i].value);
      if(i != N-1) printf(" ");
      else printf("\n");
  }
  StableJudge(C, C_bub, list, N);

  for(i=0;i<N;i++){
      printf("%c%d",C_sel[i].mark ,C_sel[i].value);
      if(i != N-1) printf(" ");
      else printf("\n");
  }
  StableJudge(C, C_sel, list, N);
  
  return 0;
}



Measured memory_bytes: 2128
#include<iostream>

int main(void)
{
	int R,G,B,N;
	int count=0;

	std::cin >> R >> G >> B >> N;
	for(int i=0; i*R <= N; i++)
		for(int j=0; j*G + i*R <= N; j++)
			if((N - i*R - j*G) % B == 0)
				count++;

	std::cout << count << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        d: i64,
        xy: [(i64, i64); n],
    };
    let ans = xy
        .iter()
        .filter(|&&(x_i, y_i)| x_i * x_i + y_i * y_i <= d * d)
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 7856
for i in range(int(input())):
    xa, ya, ra, xb, yb, rb = map(float, input().split(' '))
    ab_length = ((xa - xb) ** 2 + (ya - yb) ** 2) ** 0.5
    if ra > rb:
        max_r, min_r, min_c = ra, rb, 2
    else:
        max_r, min_r, min_c = rb, ra, -2

    if ab_length > ra + rb:
        ans = 0
    elif ab_length <= ra + rb:
        if ab_length + min_r < max_r:
            ans = min_c
        else:
            ans = 1
    print(ans)

Measured memory_bytes: 6788
#include<bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
int INF=10000;
int N,A,B,C;

int dfs(int now,int a,int b,int c,std::vector<int> l){
    if(now==N){
        if(std::min({a,b,c})>0){
            return abs(A-a)+abs(B-b)+abs(C-c)-30;
        }
        else return INF;
    }
    else{
        int res0=dfs(now+1,a,b,c,l);
        int res1=dfs(now+1,a+l[now],b,c,l)+10;
        int res2=dfs(now+1,a,b+l[now],c,l)+10;
        int res3=dfs(now+1,a,b,c+l[now],l)+10;
        return std::min({res0,res1,res2,res3});
    }
}

int main(){
    cin>>N>>A>>B>>C;
    std::vector<int> l(N);
    for(int i=0;i<N;i++){
        cin>>l[i];
    }
    cout<<dfs(0,0,0,0,l)<<endl;
}

Measured memory_bytes: 256
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    A=list(map(int,input().split()))
    ans=0
    for i in A:
        ans^=i
    
    for i in A:
        ans2=ans
        print(ans2^i, end=' ')
    
resolve()

Measured memory_bytes: 105784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
#define out(a) printf("%lld ",a)
using namespace std;
int a,b,num;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9'){if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9'){s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	a=read(),b=read(); num=1;
	if (a==0) {
	  if (b==100) out(101); else out(b);
    }
	else {
	  for (int i=1;i<=a;i++)
	    num*=100;
	  if (b==100) out(num*b+num); else out(num*b);
    }
	return 0;
}

Measured memory_bytes: 256
import math
a,b,C=map(float,input().split())

s=math.radians(C)
h=b*math.sin(s)
S=(a*h)/2
c=math.sqrt(a**2+b**2-2*a*b*math.cos(s))
L=a+b+c
print(S,L,h,sep="\n")



Measured memory_bytes: 5696
#include <cstdio>
#include <iostream>
#include <cstring>

int main()
{
	std::ios::sync_with_stdio(false);
	int N, M, K, cnt[55];
	memset(cnt, 0, sizeof cnt);
	std::cin >> N >> M;
	for (int i = 0; i < N; i++) {
		std::cin >> K;
		while (K--) {
			int t;
			std::cin >> t;
			++cnt[t];
		}
	}
	++K;
	for (int i = 1; i <= M; ++i)
		if (cnt[i] == N) ++K;
	std::cout << K << std::endl;
	return 0;
}//Rhein_E


Measured memory_bytes: 256