akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	string s[3];
	rep(i,0,3)cin>>s[i];
	rep(i,0,3)transform(ALL(s[i]),s[i].begin(),::toupper);

	string t;
	rep(i,0,3)t+=s[i][0];
	print(t);
}


Measured memory_bytes: 256
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

def solve(N,K,Q,A):
    score = [K] * N
    tot = 0
    for a in A:
        a -= 1
        score[a] += 1
        tot += 1
    ans = []
    for i, s in enumerate(score):
        if s-tot > 0:
            ans.append('Yes')
        else:
            ans.append('No')
    return ans


N, K, Q = rrm()
A = [ rri() for _ in xrange(Q) ]
ans = solve(N,K,Q,A)
for row in ans:
    print row
    


Measured memory_bytes: 42396
#include<iostream>

using namespace std;

char A[1100][1100];
int f[1100][1100];
const int MOD = 1000000007;

int main()
{
    int h, w;

    cin>>h>>w;

    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>A[i][j];
    for(int j=0;j<w;j++)
        if(A[0][j] == '.')
            f[0][j] = 1;
        else
            break;
    for(int i=0;i<h;i++)
        if(A[i][0] == '.')
            f[i][0] = 1;
        else
            break;
    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(A[i][j] == '.')
            {
                f[i][j] = (f[i-1][j] + f[i][j-1]) %MOD;
            }
        }
    }
    cout<<f[h-1][w-1]%MOD<<endl;
}

Measured memory_bytes: 5632
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.io.*;
//import java.util.stream.IntStream;



public class Main {

    public static class Node{
        Queue<Integer> child = new ArrayDeque<>();
    }

    static int colors[];
    static int d[];
    static int f[];
    static Node[] nodes;
    static int time = 0;

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //try{}
        
        int n = sc.nextInt();
        nodes = new Node[n+1];
        for(int i=0;i<=n;i++){
            nodes[i] = new Node();
        }
        colors = new int[n+1];
        d = new int[n+1];
        f = new int[n+1];

        
        // Node[]で、各ノード番号の要素にListで近接ノードを保存
        for(int i=0;i<n;i++){
            int id= sc.nextInt();
            int numChild = sc.nextInt();
            for(int j=0;j<numChild;j++){
                int child = sc.nextInt();
                nodes[id].child.add(child);
            }
        }

        for(int i=1;i<=n;i++){
            if(colors[i] == 0){
                d[i] = ++time;
                dfs(i);
            }
        }

        StringBuffer buf = new StringBuffer();
        for(int i=1;i<=n;i++){
            buf.append(i + " " + d[i] + " " + f[i] + '\n');
        }
        System.out.print(buf);

    }

    public static void dfs (int id){
        Stack<Integer> stack = new Stack<>();

        stack.push(id);
        colors[id] = 1; // stackに入ったノードをGRAYとする

        while(!stack.empty()){
            int u = stack.peek();
            Integer v = nodes[u].child.poll();

            if(v == null){
                stack.pop();
                colors[u] = 2;
                f[u] = ++time;
                continue;
            }
            if(colors[v] == 0){
                stack.push(v);
                colors[v] = 1;
                d[v] = ++time;
            }

        }

    }
}





Measured memory_bytes: 27996
memo = [[0] * 10 for i in range(10)]

def kazu(start_num,end_num):
    global memo
    if memo[start_num][end_num] > 0:
        #print('memo',start_num,end_num)
        return memo[start_num][end_num]
    else:
        ans = 0
        #1桁
        if start_num == end_num:
            if start_num <= n:
                #print(start_num)
                ans += 1
        #2桁
        if start_num * 10 + end_num <= n:
            #print(start_num * 10 + end_num)
            ans += 1
        #3桁
        for i in range(10):
            if start_num * 100 + i * 10 + end_num <= n:
                #print(start_num * 100 + end_num)
                ans += 1
            else:
                break
        #4桁
        for i in range(100):
            if start_num * 1000 + i * 10 + end_num <= n:
                #print(start_num * 1000 + end_num)
                ans += 1
            else:
                break
        #5桁
        for i in range(1000):
            if start_num * 10000 + i * 10 + end_num <= n:
                #print(start_num * 10000 + end_num)
                ans += 1
            else:
                break
        #6桁
        for i in range(10000):
            if start_num * 100000 + i * 10 + end_num <= n:
                #print(start_num * 100000 + end_num)
                ans += 1
            else:
                break
        memo[start_num][end_num] = ans
        #print(start_num,end_num,'---',ans)
        return ans

n = int(input())
str_n = str(n)
kotae = 0
#print(memo)
for a in range(1,n+1):
    if a%10!=0:
        str_a = str(a)
        #print('-----',a,'-----',int(str_a[-1]),int(str_a[0]))
        kotae += kazu(int(str_a[-1]),int(str_a[0]))
        #print(memo)
print(kotae)

Measured memory_bytes: 9256
#include <cstdio>
#include <cmath>
#include <algorithm>
#pragma warning(disable:4996)
using namespace std;

int arr[100005];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &arr[i]);
	bool flag = true;
	for (int i = 1; i < n ; i++) {
		if (i != 1 && arr[i - 1] > arr[i])
			flag = false;
		if (arr[i - 1] - arr[i] >= 2)
			flag = false;
		else if (arr[i - 1] < arr[i])
			arr[i] -= 1;
	}
	if (flag)printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 512
N,M=map(int,input().split())
bridge=[]
size=[1]*(N+1)
tree=list(range(N+1))
def find(a):
    x=tree[a]
    if a==x:
        return a
    x=find(x)
    tree[a]=x
    return x
for i in range(M):
    A,B=map(int,input().split())
    bridge.append((A,B))
Ans=N*(N-1)//2
ans=[]
for a,b in bridge[::-1]:
    aroot=find(a)
    broot=find(b)
    if aroot==broot:
        ans.append(Ans)
        continue
    ans.append(Ans)
    sa=size[aroot]
    sb=size[broot]
    Ans-=sa*sb
    if sa>sb:
        tree[broot]=aroot
        size[aroot]+=sb
    else:
        tree[aroot]=broot
        size[broot]+=sa
for i in ans[::-1]:
    print(i)

Measured memory_bytes: 24140
package main

import (
    "fmt"
    "os"
    "bufio"
    "math"
)

func main() {
    var fp *os.File
    fp = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)
    line := []byte(readLine(reader))
    length := len(line)
    var res0 float64 = 0
    var res1 float64 = 0

    // 10101
    //  or
    // 01010
    for i := 0; i < length; i++ {
        if i % 2 == 0 {
            if string(line[i]) != "1" {
                 res1++
            } else {
                 res0++
            }
        } else {
            if string(line[i]) != "0" {
                 res1++
            } else {
                 res0++
            }
        }
    }

    fmt.Println(math.Min(res0, res1))
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}

Measured memory_bytes: 1408
#include"bits/stdc++.h"
#include<math.h>
#include<vector>
using namespace std;
int64_t i,j,k,l;//preparation for
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    do{
        a-=d;
        c-=b;
    }
    while(a>0&&c>0);

    if(c<=0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

    return 0;
}

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

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////

signed main() {
  int n;
  cin>>n;
  map<int,int>a;
  rep(i,n){
    int t;
    cin>>t;
    a[t]++;
  }
  int m1=0,m2=0;
  for(auto[i,x]:a){
    if(x>=4){
      m1=max(i,m1);
      m2=max(i,m2);
    }
    if(x>=2){
      if(i>m1){m2=m1;m1=i;}
      else if(i>m2)m2=i;
    }
  }
  cout<<m1*m2<<endl;
}


Measured memory_bytes: 9872
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int n;
ll d[270000];

// BIT は 1-indexed であることに注意(外部から呼び出すときに 1 を足しておく)

void add( int a, int x ){ // a のところに x を加える
	for( int i = a; i <= n; i += ( i & -i ) ) d[i] += x;
}

ll kan( int a ){
	ll res = 0;
	for( int i = a; i > 0; i -= ( i & -i ) ) res += d[i];
	return res;
}

void jia( int l, int r, int x ){
	add( l, x );
	add( r+1, -x );
}

int main(){
	cin >> n;
	ll r, a; cin >> r >> a;
	vector<pair<int, int>> e;
	for( int i = 0; i < n; ++i ){
		int x, y; cin >> x >> y;
		e.emplace_back(x, y);
	}
	sort( e.begin(), e.end() );
	vector<ll> x(n+1);
	vector<ll> h(n+1);
	for( int i = 1; i <= n; ++i ){
		x[i] = e[i-1].first;
		h[i] = e[i-1].second;
	}
	ll ans = 0;
	auto xb = x.begin();
	++xb;
	for( int link = 1; link <= n; ++link ){
		if( kan(link) >= h[link] ) continue;
		int recht = upper_bound( x.begin(), x.end(), x[link]+2*r ) - xb;
		ll xuyao = h[link]-kan(link);
		ll cnt = (xuyao+a-1)/a;
		ans += cnt;
		jia( link, recht, cnt*a );
	}
	cout << ans << endl;
}

Measured memory_bytes: 7148
#include<stdio.h>

int main(void){

  int S,h,m,s;

  scanf("%d", &S);

  h=S/3600;
  m=(S-h*3600)/60;
  s=S-h*3600-m*60;
  
  printf("%d:%d:%d\n",h,m,s);




  return 0;
}

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

int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	int s=0;
	for(int i=1;i<=n;i++){
		int m=0,t=i;
		while(t){
			m+=t%10;
			t/=10;
		}
		int f=0;
		for(int j=0;j<m;j++)
			if(m>=a && m<=b){
				f=1;
				break;
			}
		if(0==f)	continue;
		s+=i;
//		cout<<i<<":"<<s<<endl;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 
  typedef pair<double,int> PDI;

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

typedef struct{
  double x,y,r;
}Coo;

const int MAX_V = 1e3+10;
int V;
vector<vector<double> > dp(MAX_V,vector<double>(MAX_V,0));
vector<double> d(MAX_V,DBL_MAX);
vector<bool> used(MAX_V,false);

double dist(const Coo& s, const Coo& t){
  return sqrt((s.x-t.x)*(s.x-t.x) + (s.y-t.y)*(s.y-t.y));
}

//void dijkstra(int s){
//  priority_queue<PDI, vector<PDI>, greater<PDI> > pque;
//  d[s] = 0;
//  pque.push(PDI(0,s));
//  while(!pque.empty()){
//    PDI p = pque.top(); pque.pop();
//    int v = p.second;
//    if(d[v] < p.first)continue;
//    rep(u,V){
//      if(d[u] > d[v] + dp[v][u]){
//        d[u] = d[v] + dp[v][u];
//        pque.push(PDI(d[u],u));
//      }
//    }
//  }
//}

//O(V^2)
void dijkstra(int s){
  d[s] = 0;
  while(true){
    int v = -1;
    //まだ使われてない頂点のうち距離が最小のものを探す．
    rep(u,V) if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
    if(v==-1)break;
    used[v] = true;
    rep(u,V) d[u] = min(d[u], d[v]+dp[v][u]);
  }
}


int main(void){
  SPEEDUP
  cout << setprecision(15);
  Coo s,t;cin >> s.x >> s.y >> t.x >> t.y;
  s.r = t.r = 0;
  cin >> V;
  vector<Coo> v(V+2);
  v[0] = s;
  rep(i,V)cin >> v[i+1].x >> v[i+1].y >> v[i+1].r;
  v[V+1] = t;
  V+=2;
  rep(i,V){
    repp(j,i+1,V) dp[i][j] = dp[j][i] = max(0.0,dist(v[i],v[j])- v[i].r - v[j].r);
  }
  dijkstra(0);
  cout << d[V-1] << endl;
  return 0;
}


Measured memory_bytes: 8448
// ref: https://drken1215.hatenablog.com/entry/2019/03/03/150200

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

//---

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

//---

int main(){
    uint N; cin >> N;
    vector<int> vH(N);
    for(uint i=0; i<N; ++i){ cin>>vH[i]; }
    
    int64 cnt=0ll;
    for(;;){
        if(*max_element(vH.begin(), vH.end())==0){ break; }
        
        for(uint i=0;;){
            bool isUpdate=false;
            while( i<vH.size() && vH[i]==0 ){ ++i; } // skip empty
            while( i<vH.size() && vH[i]!=0 ){ --vH[i]; ++i; isUpdate=true; }
            if(isUpdate){ ++cnt; }
            
            if(i==vH.size()){ break; }
        }
    }
    cout << cnt << endl;
    
    return 0;
}

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

int main(){
  	long long int a,b,c,d;cin>>a>>b>>c>>d;
  	cout << b - a + 1 - (b/c - (a-1)/c + b/d - (a-1)/d) + b/(c*d/__gcd(c,d)) - (a-1)/(c*d/__gcd(c,d)) ;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
typedef pair<Point, Point> Line;
const double EPS = 1e-12;

// 内積 |a||b|cosθ
double dot(Point a, Point b){
	// return a.real() * b.real() + a.imag() * b.imag();
	return (conj(a) * b).real();
}

int main(){
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        double x, y;
        Point p[4];
        for(int j = 0; j < 4; j++){
            cin >> x >> y;
            p[j] = {x, y};
        }
        Line s1 = {p[0], p[1]};
        Line s2 = {p[2], p[3]};
        double cost = dot(p[1] - p[0], p[3] - p[2]) / (abs(p[1] - p[0]) * abs(p[3] - p[2]));
        if(fabs(cost) < EPS) cout << 1 << endl;
        else if(fabs(cost) > 1 - EPS) cout << 2 << endl;
        else cout << 0 << endl;
    }
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll MOD = 1e9 + 7;
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))

int main() {
    ll n, x;
    cin >> n;
    map<ll, ll>m;

    for (ll i = 0; i < n; i++) {
        cin >> x;
        m[x]++;
    }

    vector<pair<ll, ll>>v, u;

    for (auto i = m.begin(); i != m.end(); i++) {
        if(i->second >= 2) {
            v.push_back({i->first, i->second});
        }
        if(i->second >= 4) {
            u.push_back({i->first, i->second});
        }
    }
   ll ans, ans1= 0;
    if(u.size() >= 1) {
    sort(u.begin(), u.end());
    reverse(u.begin(), u.end());
    ans1 = u[0].first * u[0].first;
   }
   if(v.size() > 1) {
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ans = v[0].first * v[1].first;
   }

   else if(v.size() == 1 && v[0].second >= 4 ) {
    ans = v[0].first * v[0].first;
   }
    else {
        ans = 0;
    }
    cout << max(ans, ans1) << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int N, K;
ll a[1100];
vector<ll> cand;

int countMask(ll a) {
  ll ret = 0;
  for (ll x : cand) {
    if ((x & a) == a) {
      ret++;
    }
  }
  return ret;
}

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < N; i++) {
    ll sum = 0;
    for (int j = i; j < N; j++) {
      sum += a[j];
      cand.push_back(sum);
    }
  }

  ll ans = 0;
  for (int i = 40; i >= 0; i--) {
    if (countMask(ans | (1LL << i)) >= K) {
      ans |= (1LL << i);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#include <set> 
#include <iterator> 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)


int main()
{
   
    fastio();

        int n,k;
        cin>>n>>k;
        int a[n];
        cn(a,n);
        int dp[n]={0};
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        for(int i=2;i<n;i++)
        {
            int m = INT_MAX;
            for(int j=i-1;j>=max(0,i-k);j--)
            {
                if((dp[j]+abs(a[j]-a[i]))<m)
                    m=dp[j]+abs(a[j]-a[i]);
            }
            dp[i]=m;
        }
        cout<<dp[n-1]<<endl;
      

}


Measured memory_bytes: 1024
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn @Int
  xs <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let m = U.maximum xs
  let vec :: U.Vector Int
      vec = U.create $ do
        vec <- UM.replicate (m+1) 0
        U.forM_ xs $ \x -> do
          t <- UM.read vec x
          when (t <= 1) $ do
            UM.modify vec (+ 1) x
            forM_ [2*x,3*x..m] $ \i -> do
              UM.modify vec (+ 2) i
        return vec
  print $ length [ () | x <- U.toList xs, vec U.! x <= 1 ]


Measured memory_bytes: 18588
def slove():
    import sys
    input = sys.stdin.readline
    a = int(input().rstrip('\n'))
    b = int(input().rstrip('\n'))
    c = int(input().rstrip('\n'))
    x = int(input().rstrip('\n'))
    cnt = 0
    for i in range(a + 1):
        for j in range(b + 1):
            for k in range(c + 1):
                if i * 500 + j * 100 + k * 50 == x:
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38896
#include <stdio.h>
#include <math.h>
#include <iostream>

using namespace std;

int main()
{
    int n,k;
    cin >> n;
    int sl=0;
    for (int i=1; i <= n ; i++)
    {
        cin >> k;
        if (k % 2 == 0) sl++;
    }
    cout << pow(3,n) - (1<<sl);
    return 0;
}


Measured memory_bytes: 256
n,k,*l=map(int,open(0).read().split())
m=1e10
for i,j in zip(l,l[k-1:]):
  if i*j<0:
    m=min(m,-i*2+j,-i+j*2)
  else:
    m=min(m,max(abs(i),abs(j)))
print(m)

Measured memory_bytes: 14052
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String args[]) {
    Scanner in = new Scanner(System.in);
    String str;
    int sum = 0;
    boolean flag = true;
    while(true){
      str = in.nextLine();
      if(str.equals("0")) break;
      char [] cin = str.toCharArray();
      for(int i = 0; i < cin.length; i++){
          sum += Character.getNumericValue(cin[i]);
      }
      System.out.println(sum);
      sum = 0;
    }
  }
}



Measured memory_bytes: 26696
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#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 RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	retur5n a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	VI a(5);
	int min = 10,mem;
	rep(i, 5) {
		cin >> a[i];
		if (min > a[i] % 10 && a[i]%10!=0) {
			min = a[i] % 10;
			mem = i;
		}
	}

	double c;
	int sum = 0;
	rep(i, 5) {
		if (i == mem) {
			sum += a[i];
		} else {
			c = a[i];
			c=ceil(c / 10);
			c *= 10;
			sum += c;
		}
	}
	cout << sum << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	ll ans = min(a, k);
	if (a+b >= k)
		cout << ans << endl;
	else
	{
		k -= (a+b);
		cout << ans - k << endl;
	}
}



Measured memory_bytes: 3632
#include <stdio.h>
int main() {

    int a,b;
    scanf("%d%d", &a,&b);
    
     if(a%b==0) {
        printf("%d",(a/b));}
        
     else if(a>b) {
        printf("%d", (a/b)+1);
    }
    
    else if(a<b) {
            printf("%d", 1);
    }


 return 0;
}

Measured memory_bytes: 1680
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct unionfind{
	vector<int> data;
	void use(int n){ data.assign(n, -1); }
	void reset(void){ data.clear(); }
	bool unionset(int x, int y){
		x = root(x); y = root(y);
		if(x != y){
			if(data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y){ return root(x) == root(y); }
	int root(int x){ return (data[x] < 0) ? x : data[x] = root(data[x]); }
	int size(int x){ return -data[root(x)]; }
};

signed main(void){
  int i, j;
  unionfind U;
  for(int testcase = 0;testcase >= 0;testcase++){
    int n, m;
    scanf("%d%d", &n, &m);
    U.use(n + m);
    rep(i, n){
      int(k);
      rep(j, k){
        int(l);
        U.unionset(i, n + l - 1);
      }
    }
    bool is = true;
    rep(i, n)if(!U.findset(0, i))is = false;

    puts(is ? "YES" : "NO");

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 1024
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
        SAME AS EDITORIAL
       
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
  ll H,i,N,A,sum=0;cin>>H>>N;
  fo(i,0,N)cin>>A,sum+=A;
  if(sum>=H)cout<<"Yes\n";
  else cout<<"No\n";
}
int main()
{
   fastio
   solve();
  return 0;
}


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

int main(int argc, char const *argv[]) {
	int n, k; cin >> n >> k;

	if (k == 0) {
		cout << (ll)n * n << endl;
		return 0;
	}

	ll ans = 0;
	for (int b = 1; b <= n; ++b) {
		// a = bp + rep

		/*
		for (int a = 1; a <= n; ++a) {
			int p = a / b;
			int r = a % b;
			printf("a:%d b:%d p:%d r:%d\n", a, b, p, r);
			if (r >= k) ans++;
		}
		*/

		int P = n / b;
		int R = n % b;	
		// r = ([0, 1, 2, .. , b - 1] * P) + ([0, 1, .. , R])
		ans += 	max((b - 1) - (k) + 1, 0) * P + max(R - k + 1, 0);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

class UnionFind {
    vector<int> parent;
    vector<int> rank;

public:
    UnionFind(int n){
        parent = vector<int>(n, -1); // parent[i] = -1 -> i is root.
        rank = vector<int>(n, 0);
    }

    int find(int n){
        vector<int> path;
        while(parent[n]!=-1){
            path.push_back(n);
            n = parent[n];
        }
        for(vector<int>::iterator it = path.begin(); it != path.end(); it++){
            parent[*it] = n;
            rank[*it] = 0;
        }
        return n;
    }

    void unify(int x, int y){
        int rx = find(x), ry = find(y);
        if(rx == ry) return;

        if(rank[rx] < rank[ry]){
            parent[rx] = ry;
        } else {
            parent[ry] = rx;
            if(rank[rx] == rank[ry]) rank[rx]++;
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
};

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

    li n, k;
    cin >> n >> k;
    vector<li> xs(n);
    set<li> range;
    li lastrev = 0, original_id = -1;
    UnionFind uf(n - k + 1);
    for (int i = 0; i < n; ++i) {
        const li id = i - k + 1;
        li x;
        cin >> x;
        xs[i] = x;
        if (i > 0 && x < xs[i - 1]) {
            lastrev = i;
        } else if (lastrev <= i - k + 1) {
            if (original_id == -1) {
                original_id = id;
            } else {
                uf.unify(original_id, id);
            }
        }
        if (i < k) {
            range.insert(x);
        } else {
            li sm = *range.begin();
            li lg = *range.rbegin();
            if (sm != xs[i - k] || lg > x) {

            } else {
                uf.unify(id, id - 1);
            }
            range.erase(xs[i - k]);
            range.insert(x);
        }
    }
    set<li> kinds;
    for (int i = 0; i < n - k + 1; ++i) {
        kinds.insert(uf.find(i));
    }
    cout << kinds.size() << endl;

    return 0;
}

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

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define MOD  1000000007
#define INF  0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef long long ll;

int N,M;
int used[100010];

int main() {

    cin >> N >> M;
    REP(i,100010) used[i] = 0;
    REP(i,M) {
        int a,b; cin >> a >> b;
        used[a]++;
        used[b]++;
    }
    
    for(int i=1; i<=N ;i++) {
        if(used[i]%2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
	int a, b, x, y, z;
	if(scanf("%d", &a)== 1);
	if(scanf("%d", &b)== 1);
	
	x = 1;
	y = 2;
	z = 3;
	
	if (a == 1 || b ==1){
		if (a == 2 || b == 2){
			printf("%d",z);
		}else{
			printf("%d",y);
		}
	}else if(a == 2 || b == 2){
		if (a == 1 || b == 1){
			printf("%d",z);
		}else{
			printf("%d",x);
		}
	}else{
		if (a == 2 || b == 2){
			printf("%d",x);
		}else{
			printf("%d",y);
		}
	}
	
    return 0;
}

Measured memory_bytes: 128
N, L = gets.split(/ /).collect{|n| n.to_i}

a_list = gets.split(/ /).collect{|n| n.to_i}


start = nil
(1...a_list.length).each{|i|
	if a_list[i - 1] + a_list[i] >= L
		start = i
		break
	end
}

if start
	puts 'Possible' 
	(1...start).each{|i|
		puts i
	}
	((start + 1)...a_list.length).to_a.reverse.each{|i|
		puts i
	}
	puts start
else
	puts 'Impossible' 
end



Measured memory_bytes: 13316
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;


int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;

    vll p(n);

    vector<ld> e(n);

    for0(i, n) cin >> p[i];

    for0(i, n){
        e[i] = ld(p[i] + 1) / 2.0;
    }

    ld result = 0;
    ld bef = 0;
    for0(i, k){
        bef += e[i];
    }
    result = bef;

    forx(i, n, k){
        result = max(result, bef = bef - e[i - k] + e[i]);
    }

    cout << setprecision(10) << result;

    // cout << result;

    return 0;
}


Measured memory_bytes: 4992
N=int(input())
ans = []
for i in range(N):
    ans.append(str(input()))  
a=ans.count("AC")
b=ans.count("WA")
c=ans.count("TLE")
d=ans.count("RE")
print("AC x ",a)
print("WA x ",b)
print("TLE x ",c)
print("RE x ",d)

Measured memory_bytes: 16172
import java.util.*;

class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int s = scan.nextInt();
        int out = 0;
        for(int i = 0; i <= k; i++){
            for(int j = 0; j <= k; j++){
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            }
        }
        System.out.println(out);
        scan.close();
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 27152
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n - 1)]
Q, K = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(Q)]

from heapq import heappop, heappush

def main():
    cost = [[] for _ in range(n)]
    for i in range(n - 1):
        a = abc[i][0] - 1
        b = abc[i][1] - 1
        c = abc[i][2]
        cost[a].append((b, c))
        cost[b].append((a, c))
    # print(cost)

    start = K - 1
    d = [float('inf') for i in range(n)] # 最短距離
    d[start] = 0

    q = [] # min-heap, (距離, 頂点)
    heappush(q, (d[start], start))
    while q:
        du, u = heappop(q) # 最短距離とその頂点
        if d[u] < du:
            continue
        for v, weight in cost[u]:
            alt = du + weight
            if d[v] > alt:
                d[v] = alt
                heappush(q, (alt, v))

    for goal1, goal2 in xy:
        print(d[goal1 - 1] + d[goal2 - 1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 89864
#include <iostream>

using namespace std;

int main()
{
    int n,k,c=0;
    cin>>n>>k;
    int h[n],i;
    for(i=0;i<n;i++)
    {
        cin>>h[i];
        if(h[i]>=k)
            c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void merge(lld brr[], lld arr[], lld l, lld m, lld r){
    lld i , j ,  k;
    lld n1 = m-l+1; 
    lld n2 = r - m;
    lld L1[n1], L2[n1];
    lld R1[n2], R2[n2];
    for (i = 0; i < n1; i++){
        L1[i] = arr[l + i];
        L2[i] = brr[l + i];
    }
    for (j = 0; j < n2; j++){
        R1[j] = arr[m+1+j];
        R2[j] = brr[m+1+j];
    }
    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2)
    {
        if (L1[i] <= R1[j]){
            arr[k] = L1[i];
            brr[k] = L2[i];
            i++;
        }
        else{
            arr[k] = R1[j];
            brr[k] = R2[j];
            j++;
        }
        k++;
    }
        while (i   <   n1){
            arr[k] = L1[i];
            brr[k] = L2[i];
            i++;
            k++;
        }
        while (j   <   n2){
            arr[k] = R1[j];
            brr[k] = R2[j];
            j++;
            k++;
        }
}
void mergeSort(lld brr[], lld arr[], lld l, lld r){
    if (l < r)
    {
        lld m = l+(r-l)/2;
        mergeSort(brr, arr, l, m);
        mergeSort(brr,arr, m+1,r);
        merge(brr, arr, l, m , r);
    } 
}
int main ()
{
      FastIO
      lld n, i;
      cin >> n;
      lld A[n];
      lld B[n];
      foi(i, n)
      {
            cin >> A[i];
            B[i] =  i+1;
      }
      mergeSort(B, A, 0, n-1);
      lld f;
      f = 0;
      foi(i, n)
      {
            if (A[i]==1)
                  f = 1;
      }
      if (f==0)
            cout <<"-1";
      else
      {
            lld x = A[0];
            lld y = B[0];
            lld count= 1;
            for(i = 1; i < n; i += 1)
            {
                  if (A[i] == x+1 && B[i] > y)
                  {
                        count+=1;
                        x = A[i];
                        y = B[i];
                  }
            }

            cout << (n-count);
      }
      return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  string S;
  cin >> S;

  if(S[2] == S[3] && S[4] == S[5]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import sys
h,w,a,b = map(int,input().split())
if a != 0 and b != 0:
    for i in range(b):
        row = [0]*a+[1]*(w-a)
        print(*row,sep='')
    for i in range(h-b):
        row = [1]*a+[0]*(w-a)
        print(*row,sep='')
    sys.exit()
elif a == 0 and b == 0:
    for i in range(h):
        row = [0]*w
        print(*row,sep='')
    sys.exit()
elif b == 0:
    for i in range(h):
        row = [1]*a+[0]*(w-a)
        print(*row,sep='')
    sys.exit()
elif a == 0:
    for i in range(h):
        if i//b==0:
            row = [1]*w
            print(*row,sep='')
        else:
            row = [0]*w
            print(*row,sep='')
    sys.exit()
print('No')

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;

int main() {
    int n;
    cin>>n;
    vi v(n+1,0);
    rep(i,n-1){
        int a;
        cin>>a;
        v[a]+=1;
    }
    rep(i,n){
        cout<<v[i+1]<<endl;
    }

    return 0;
}

Measured memory_bytes: 4052
#include<stdio.h>
#define N 100000

int main(){
  
  int i, j, n, m, num, cnt = 0, right, left, center, array[N];
  
  scanf("%d",&n);

  for(i = 0; i < n ; i++)scanf("%d",&array[i]);
  
  scanf("%d",&m);

  for(i = 0; i < m ; i++)
    {
      scanf("%d",&num);

      right = n - 1, left = 0;
      
      while(1)
	{
	  center = (right + left)/2;
	  
	  if(right == left)
	    {
	      if(array[center] == num)cnt++;
	      break;
	    }
	  
	  if(array[center] == num)
	    {
	      cnt++;
	      break;
	    }
	  
	  if(array[center] > num)
	    {
	      right = center;
	      continue;
	    }

	  if(array[center] < num)
	    {
	      left = center + 1;
	      continue;
	    }
	} 
    }
  printf("%d\n",cnt);
  
  return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define pb push_back
#define Int int64_t
using namespace std;

int N,K;

int main()
{
    cin>>N;
    vector<int64_t> A(N);
    for(auto &x:A) cin>>x;
    int64_t XorSum=0;
    for(auto x:A) XorSum^=x;
    
    for(auto x:A){
        int64_t itr=XorSum^x;
        cout<<itr<<" ";
    }
    cout<<"\n";
}

Measured memory_bytes: 4800
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b;
	cin>>b>>a;
	ll res = b;
	b -= a;
	if(a>b) swap(a, b);
	while(a){
		ll c = b/a;
		res += 2*c*a;
		b -= c*a;
		swap(a, b);
	}
	cout<<res-b<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    n = int(input())
    a_b = [list(map(int, input().split())) for i in range(n)]
    a_b = sorted(a_b, key=lambda x: x[1])

    time_space = 0
    for i in range(len(a_b)):
        if i == 0:
            time_space = a_b[i][1] - a_b[i][0]
        else:
            time_space = a_b[i][1] - a_b[i - 1][1] - a_b[i][0] + time_space

        if time_space < 0:
            print("No")
            return

    print("Yes")


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """5
2 4
1 9
1 8
4 9
3 12"""
        output = """Yes"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """3
334 1000
334 1000
334 1000"""
        output = """No"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720"""
        output = """Yes"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 101460
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>
#include<limits.h>

void judge(char *);
int judge2(int *);

int main()
{
	char str[16];

	while(scanf("%s", str) != EOF)
		judge(str);

	return 0;
}

void judge(char str[])
{
	int i, j, num[16]={0}, buf[16]={0}, ans[16]={0}, c;

	for(i=1; i<=9; i++){
		for(j=0; j<13; j++){
			if(str[j] == '0' + i)
				num[i]++;
		}
	}

	c = 0;
	for(i=1; i<=9; i++){				//1つ追加する数字
		for(j=1; j<=9; j++){			//2つ取り除く数字
			memcpy(buf, num, sizeof(buf));
			if(buf[i] == 4)
				break;
			buf[i]++;
			if(buf[j] >= 2){
				buf[j] -= 2;
				if(judge2(buf)){
					ans[c] = i;
					c++;
					break;
				}
			}
		}
	}

	if(c==0)
		printf("0\n");
	else{
		for(i=0; i<c; i++){
			if(i==c-1)
				printf("%d\n", ans[i]);
			else
				printf("%d ", ans[i]);
		}
	}

	return;
}

int judge2(int buf[])
{
	int c, i;

	c = 1, i = 0;
	while(1){

		if(i == 4)
			return 1;

		if(buf[c] == 0){
			c++;
			continue;
		}else if(buf[c] == 1 || buf[c] == 2){
			buf[c]--;
			buf[c+1]--;
			buf[c+2]--;
			if(buf[c] < 0 || buf[c+1] < 0 || buf[c+2] < 0)
				return 0;
			i++;
			continue;
		}else if(buf[c] >= 3){
			buf[c] -= 3;
			i++;
			continue;
		}
	}
}

Measured memory_bytes: 552