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

using namespace std;

int main(int argc, char** argv){
    int N;
    cin >> N;
    int det = 0;
    int b = 0;
    for (int i=0; i<N; i++){
        int a;
        cin >> a;
        if (a % 4 == 0) det++;
        else if (a % 4 == 2) b++;
        else det--;
    }
    cout << ((det>=0 ||(det==-1 && b == 0)) ? "Yes\n" : "No\n");
    return 0;
}


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

int main() {
  
  int n, k;
  cin >> n >> k;
  
  vector<int> h(n);
  int cnt = 0;
  REP(i,n) {
    cin >> h[i];
    if (h[i] >= k) cnt++;
  }
  
  cout << cnt << endl;
    
}

Measured memory_bytes: 640
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			int N = scn.nextInt();

			String[] kuji = new String[N];

			Map<String, Integer> map = new HashMap();
			String key;
			int cnt;
			for(int i = 0; i < N; i++) {
				key = scn.next();
				map.put(key, 0);
			}

			System.out.println(map.size());
		}
	}
}

Measured memory_bytes: 71392
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
string s,ans;
int n;

P getNum(string str,int x){
  int r=0;
  while('0'<=str[x]&&str[x]<='9')
    r=r*10+str[x]-'0',x++;
  return P(x,r);
}

void dfs(int b,int e){
  int p=b;
  while(p<=e&&ans.size()<=n){
    while('0'<=s[p]&&s[p]<='9'){
      P r=getNum(s,p);
      int x=r.first,num=r.second;
      int y=r.first,z=r.first;
      if(s[x]=='('){
	int c=1;
	y=x+1;
	for(z=y;z<=e&&c;z++){
	  if(s[z]=='(')c++;
	  if(s[z]==')')c--;
	}
	p=z;
	z-=2;
	while(num--)dfs(y,z);
      }else{
	while(num--)ans+=s[x];
	p=x+1;
      }
    }
    while('A'<=s[p]&&s[p]<='Z')
      ans+=s[p++];
  }
}

int main(){
  while(1){
    cin>>s>>n;
    if(s=="0"&&!n)break;
    dfs(0,s.size()-1);
    if(ans.size()<n+1)
      cout<<0<<endl;
    else cout<<ans[n]<<endl;
    ans.clear();
  }
  return 0;
}

Measured memory_bytes: 3792
#!/usr/bin/env python3
import sys
from collections import deque
sys.setrecursionlimit(1000000)

class UnionFind:
    def __init__(self, num):
        self.par = list(range(1,num+1))
        self.size = [1]*num
    
    def root(self, n):
        if self.par[n-1] != n:
            self.par[n-1] = self.root(self.par[n-1])
        return self.par[n-1]

    def unite(self, a, b):
        a=self.root(a)
        b=self.root(b)
        if a!=b:
            self.par[b-1]=a
            self.size[a-1] += self.size[b-1]
        return
    
    def get_size(self, n):
        return self.size[self.root(n)-1]


def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]", D: "List[int]"):

    fris = [0]*N
    blos = [0]*N

    union = UnionFind(N)
    for ai, bi in zip(A, B):
        union.unite(ai,bi)
        fris[ai-1]+=1
        fris[bi-1]+=1
    
    for ci, di in zip(C, D):
        if union.root(ci) == union.root(di):
            blos[ci-1]+=1
            blos[di-1]+=1
    
    ans = [0]*N
    for i in range(1,N+1):
        s = union.get_size(i)
        s -= fris[i-1]
        s -= blos[i-1]
        s -= 1
        ans[i-1] = s

    print(*ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    C = [int()] * (K)  # type: "List[int]"
    D = [int()] * (K)  # type: "List[int]"
    for i in range(K):
        C[i] = int(next(tokens))
        D[i] = int(next(tokens))
    solve(N, M, K, A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 57964
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val P = new Array[Int](N+1)

  for(i <- 1 to N) {
    P(i) = in.next().toInt
  }

  val Q = new Array[Int](N+1)
  for(i <- 1 to N) {
    Q(P(i)) = i
  }

  var ans = N
  var cnt = 1
  for(i <- 2 to N) {
    if(Q(i) > Q(i-1)) {
      cnt += 1
    }
    else {
      ans = Math.min(ans, N - cnt)
      cnt = 1
    }
  }

  ans = Math.min(ans, N - cnt)

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



Measured memory_bytes: 41344
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
char s[N][N]={'\0'};

int n,m,a,b;
int cs=0,ch=0;
void attempt(){
	if(ch>=a&&cs>=b){
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(s[i][j]=='<'&&ch>a){
					s[i][j]=s[i][j+1]='.';
					ch--;
				}
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(s[i][j]=='^'&&cs>b){
					s[i][j]=s[i+1][j]='.';
					cs--;
				}
			}
		}
		puts("YES");
		for(int i=0;i<n;i++){
			printf("%s\n",s[i]);
		}
		exit(0);
	}
}
void t3(){
	if(n>=3&&m>=3&&n%2==1&&m%2==1){
		ch-=1;
		cs-=1;
		bool v=s[n-3][m-3]=='<';
		(v?ch:cs)-=2;
		s[n-2][m-2]='.';
		s[n-3][m-3]=s[n-1][m-2]='<';
		s[n-3][m-2]=s[n-1][m-1]='>';
		s[n-3][m-1]=s[n-2][m-3]='^';
		s[n-2][m-1]=s[n-1][m-3]='v';
		ch+=2;
		cs+=2;
		attempt();
		ch-=2;
		cs-=2;
		s[n-1][m-1]='.';
		s[n-3][m-1]='^';
		s[n-2][m-1]='v';
		s[n-1][m-3]='<';
		s[n-1][m-2]='>';
		if(v){
			s[n-3][m-3]=s[n-2][m-3]='<';
			s[n-3][m-2]=s[n-2][m-2]='>';
		}else{
			s[n-3][m-3]=s[n-3][m-2]='^';
			s[n-2][m-3]=s[n-2][m-2]='v';
		}
		(v?ch:cs)+=2;
		ch+=1;
		cs+=1;
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			s[i][j]='.';
		}
	}
	int nn=n/2*2,mm=m/2*2;
	for(int i=0;i<nn;i+=2){
		for(int j=0;j<mm;j+=2){
			s[i][j]=s[i+1][j]='<';
			s[i][j+1]=s[i+1][j+1]='>';
			ch+=2;
		}
	}
	// cerr<<ch<<" "<<cs<<endl;
	if(n%2){
		for(int i=0;i<mm;i+=2){
			s[n-1][i]='<';
			s[n-1][i+1]='>';
			ch+=1;
		}
	}
	// cerr<<ch<<" "<<cs<<endl;
	if(m%2){
		for(int i=0;i<nn;i+=2){
			s[i][m-1]='^';
			s[i+1][m-1]='v';
			cs+=1;
		}
	}
	// cerr<<ch<<" "<<cs<<endl;
	attempt();
	for(int i=0;i<nn;i+=2){
		for(int j=0;j<mm;j+=2){
			attempt();
			t3();
			attempt();
			s[i][j]=s[i][j+1]='^';
			s[i+1][j]=s[i+1][j+1]='v';
			ch-=2;
			cs+=2;
			attempt();
			t3();
			attempt();
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> p(n);
  rep(i, n) cin >> p[i];
  ll ans = 0;
  ll cur = 0;
  for(ll i = 0; i < k; i++) cur += p[i];
  ans = cur;
  for(ll i = k; i < n; i++){
    cur -= p[i - k];
    cur += p[i];
    ans = ans < cur ? cur : ans;
  }
  ans += k;
  double a = ans;
  printf("%lf\n", a / 2);
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
ul H, W;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string A, B, C;
  cin >> N;
  cin >> A;
  cin >> B;
  cin >> C;
  ul ans = 0;
  REP(ii, N) {
    int tmp = 2;
    if (A[ii] == B[ii]) --tmp;
    if (A[ii] == C[ii]) --tmp;
    if (B[ii] == C[ii]) --tmp;
    ans += max(tmp, 0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

d = {}
for si in s:
    if si not in d:
        d[si] = 0
    d[si] += 1

s_list = list(sorted(list(d.keys())))
value = max(d.values())
for si in s_list:
    if d[si] == value:
        print(si)


Measured memory_bytes: 38532
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,k;cin>>n>>k;
  int res=0;
  while(n>0){
    res++;
    n/=k;
  }
  cout<<res<<endl;
  return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;

ll x;
int main(){
  cin >> x;
  ll ans = 2 * (x/11);
  if(x%11!=0 && x%11 <= 6)ans++;
  else if (x%11!=0 &&x%11<11)ans += 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete

signed main(){

    string S;
    cin>>S;

    if(S=="ABC")
        cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;

    return 0;
}


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

int main(void) {
    int a=0, b=0;
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A') {
            a = i;
            break;
        }
    }
    for (int i = S.size()-1; i >= 0; i--) {
        if (S[i] == 'Z') {
            b = i;
            break;
        }
    }
    cout << b - a + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

B = []

for i in range(1, N+2):
  x = abs(A[i] - A[i-1])
  B.append(x)

distance = sum(B)

for i in range(1, N+1):
  sub = B[i-1] + B[i]
  add = abs(A[i+1] - A[i-1])
  print(distance - sub + add)

Measured memory_bytes: 14048
en='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+' .,-\'?' 
de={
'101':' ','000000':'\'','000011':',','10010001':'-','010001':'.','000001':'?',
'100101':'A','10011010':'B','0101':'C','0001':'D','110':'E','01001':'F',
'10011011':'G','010000':'H','0111':'I','10011000':'J','0110':'K','00100':'L',
'10011001':'M','10011110':'N','00101':'O','111':'P','10011111':'Q','1000':'R',
'00110':'S','00111':'T','10011100':'U','10011101':'V','000010':'W','10010010':'X',
'10010011':'Y','10010000':'Z'
}
while 1:
    try:s=input()
    except:break
    a=b=c=''
    for x in s:a+=str(bin(en.index(x)))[2:].zfill(5)
    for i in range(len(a)):
        b+=a[i]
        if b in de:c+=de[b];b=''
    print(c)

Measured memory_bytes: 7420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		StringBuilder sb = new StringBuilder(s);
		char[] word = new char[s.length()];
		char[] key = new char[t.length()];
		word = s.toCharArray();
		key = t.toCharArray();
		boolean flg = false;

		tansa: for (int i = s.length() - 1; i >= t.length() - 1; i--) {
			for (int j = 0; j < t.length(); j++) {
				if (word[i - j] != key[key.length - 1 - j] && word[i - j] != '?') {
					break;
				}
				if (j == t.length() - 1) {
					sb.replace(i - t.length()+1, i+1, t);
					flg = true;
					break tansa;
				}
			}
		}
		if (flg == false) {
			System.out.println("UNRESTORABLE");
		} else {
			String ans = sb.toString().replace('?', 'a');
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 22996
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>

#define IN 2000000000
using namespace std;


int main() {
	int V, E;
	scanf("%d %d", &V, &E);
	int A[101][101];
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 101; j++) {
			if (i == j) {
				A[i][j] = 0;
			}
			else {
				A[i][j] = IN;
			}
		}
	}
	int s, t, d;
	for (int i = 0; i < E; i++) {
		scanf("%d %d %d", &s, &t, &d);
		A[s][t] = d;
	}

	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			if (A[j][i] != IN) {
				for (int k = 0; k < V; k++) {
					if (A[i][k] != IN) {
						A[j][k] = min(A[j][k], A[j][i] + A[i][k]);

					}
				}
			}
		}
	}

	int flag = 0;
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			if (A[i][i] < 0) {
				flag = 1;
			}
		}
	}

	if (flag == 1) {
		printf("NEGATIVE CYCLE\n");
	}
	else {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				if (A[i][j] == IN) {
					printf("INF");
				}
				else {
					printf("%d", A[i][j]);
				}if (j != V - 1) printf(" ");
				else printf("\n");
			}
		}
	}
	return 0;

}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define N 500003
#define endl "\n"
#define sz(x) (int)(x).size()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define trace1(x)             	 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;

const int MOD = 1000000007;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);

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

	int i;
	for (i = 0; i < v.size() && x > 0; ++i)
		x -= v[i];

	if (x != 0) i--;
	cout << i << endl;
	return 0;
}


Measured memory_bytes: 256
from math import sqrt

def main():
    N = int(input())

    ans = float('inf')
    for i in range(1, int(sqrt(N))+1):
        if N % i == 0:
            tmp = i + (N // i) - 2
            ans = min(ans, tmp)
        
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,const P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e5;
int n, m, z[N];
ll u[N];
V<P<int, ll>> e[N];
void ans(int a){
  cout << a << endl;
  exit(0);
}
void dfs2(int a){
  for(auto t:e[a]) if(!z[t.fi]){
    z[t.fi] = 1;
    u[t.fi] = t.se-u[a];
    dfs2(t.fi);
  }
}
void odd(int v){
  fill(z, z+n, 0);
  z[0] = 1;
  u[0] = v;
  dfs2(0);
  FOR(i, 0, n){
    if(u[i]<=0) ans(0);
    for(auto t:e[i]) if(u[i]+u[t.fi]!=t.se) ans(0);
  }
  ans(1);
}
void dfs1(int a){
  for(auto t:e[a]){
    if(z[t.fi]==0){
      z[t.fi] = -z[a];
      u[t.fi] = t.se-u[a];
      /*
      show(t.fi);
      show(t.se);
      show(u[a]);
      show(u[t.fi]);
      */
      dfs1(t.fi);
    }else if(z[t.fi]==z[a]){
      int z1=z[t.fi], z2=-z[a];
      ll u1=u[t.fi], u2=t.se-u[a];
      if(z1 > z2) swap(z1, z2), swap(u1, u2);
      u1 -= u2;
      if(u1%2) ans(0);
      odd(u1/2);
    }else if(u[t.fi]+u[a]!=t.se) ans(0);
  }
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(_, 0, m){
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    e[a].emplace_back(b, c);
    e[b].emplace_back(a, c);
  }
  z[0] = 1;
  dfs1(0);
  ll l=1, r=LINF;
  FOR(i, 0, n)for(auto t:e[i]){
    if(z[i]==1){
      mins(r, t.se-u[i]-1);
      maxs(l, -u[i]+1);
    }else{
      mins(r, u[i]-1);
      maxs(l, u[i]-t.se+1);
    }
  }
  cout << max(0ll, r-l+1) << endl;
}

Measured memory_bytes: 13184
n = int(input())
h = [int(_) for _ in input().split()]
'''
dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
#print(dp[n-1])
print(dp)
'''

dp = [1000000000] * n
dp[0] = 0
for i in range(n):
    if i+1 < n:
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]))
    if i+2 < n:
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]))
print(dp[n-1])

Measured memory_bytes: 13924
#include <stdio.h>

int main(void) {
	int h, w;
	int a, b;
	int asumi, iguti;
	if (scanf("%d%d", &h, &w) != 2) return 1;
	if (scanf("%d%d", &a, &b) != 2) return 1;
	asumi = h / a;
	iguti = w / b;
	printf("%d\n", h * w - (a * asumi) * (b * iguti));
	return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,cnt=0;
  cin>>a>>b>>c;
  for(int i=a;i<=b;i++){
    if(c%i==0){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

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


    long long money=100;
    for(int i=1;;i++){
        money *= 1.01;
        if (X<=money){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

int a[200000];

int main(){
    int n,m;
    cin >> n >> m;
    for(int i = 0 ; i  < m ;i++){
      int u,v;
      cin >> u >>v;
      //G[u].push_back(v);
      if(u==1){
         a[v] +=2;
        }
      if(v==n)
         a[u] -=1;
      }
      for(int i = 0; i < n ;i++)
          if(a[i] == 1){
               cout <<"POSSIBLE"<<endl;
               return 0;
           }
      cout <<"IMPOSSIBLE"<<endl;
}

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

using namespace std;

bool solve(int, int, int, int*);

int main(){
	int n, q;
	vector<int> A, m;
	int i, j, k;
	int ain, min;
	bool exist;
	
	cin >> n;
	for(i=0;i<n;++i){
		cin >> ain;
		A.push_back(ain);
	}
	cin >> q;
	for(i=0;i<q;++i){
		cin >> min;
		m.push_back(min);
	}
	
	for(i=0;i<q;++i){
		exist = false;
		
		if(solve(0, m[i], n, &A[0]))exist = true;
		if(exist)cout << "yes\n";
		else cout << "no\n";
	}
	
	return 0;
}

bool solve(int i, int m, int n, int* tmp){
	int res;
	if(m == 0)return true;
	if(i>=n)return false;
	res = solve(i+1, m, n, tmp) || solve(i+1, m-tmp[i], n, tmp);
	return res;
}


Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> a(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> a[i][j];
		}
	}
	int dots_count;
	vector<int> rm_row(0), rm_column(0);
	for (int i = 0; i < H; i++) {
		dots_count = 0;
		for (int j = 0; j < W; j++) {
			if (a[i][j] == '.') {
				dots_count++;
			}
		}
		if (dots_count == W) {
			rm_row.push_back(i);
		}
	}
	for (int i = 0; i < W; i++) {
		dots_count = 0;
		for (int j = 0; j < H; j++) {
			if (a[j][i] == '.') {
				dots_count++;
			}
		}
		if (dots_count == H) {
			rm_column.push_back(i);
		}
	}
	for (int i = 0; i < H; i++) {
		if (find(rm_row.begin(), rm_row.end(), i) == rm_row.end()) {
			for (int j = 0; j < W; j++) {
				if (find(rm_column.begin(), rm_column.end(), j) == rm_column.end()) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct B { int a, b, c; ll d;};
int N, M, Q;
ll ans;
B bag[50];

void dfs(int x, vector<int> dd) {
    if (dd.size() == N) {
        ll ret = 0;
        for (int i = 0; i < Q; ++i) {
            B b = bag[i];
            if (dd[b.b - 1] - dd[b.a - 1] == b.c) {
                ret += b.d;
            }
        }
        ans = max(ans, ret);
        return;
    }
    for (int i = x; i <= M; ++i) {
        auto ddd = dd;
        ddd.push_back(i);
        dfs(i, ddd);
    }
}

void solve() {
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; ++i) {
        int a, b, c; ll d;
        cin >> a >> b >> c >> d;
        B x = { a = a, b = b, c = c, d = d };
        bag[i] = x;
    }
    dfs(1, vector<int>());
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a1, v1, a2, v2, t;
	scanf("%lld%lld%lld%lld%lld", &a1, &v1, &a2, &v2, &t);
	ll d = abs(a1 - a2);
	if (v1 > v2 && (v1 - v2)*t >= d)printf("YES\n");
	else printf("NO\n");
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main()
{
    int N, Q;
    cin >> N >> Q;
    dsu disjoint(N);
    for (int i = 0; i < Q; ++i) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) 
            disjoint.merge(u, v);
        if (t == 1)
            cout << (disjoint.same(u, v) ? 1 : 0) << endl;
    }
}




Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    int ans = 0;
    rep(i, N - 1) {
        bool flag = p[i] == i + 1;
        if (flag) {
            swap(p[i], p[i + 1]);
            ans += 1;
        }
    }
    if (p[N - 1] == N) ans += 1;
    cout << ans << endl;
    return 0;
}

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

#define ll long long
ll l,r,ans=10'000'000'000;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>l>>r;
	if(r-l+1 >= 2019)
		ans=0;
	else {
		for(ll i=l;i<r;i++){
			for(ll j=i+1;j<=r;j++){
				ans = min(ans, i*j%2019);
			}
		}
	}
	cout<<ans;
 	return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
    "os"
    "bufio"
    "strings"
    "strconv"
)

type long int64
type float float32
type double float64

// io
type Scanner struct {
    reader *bufio.Reader
    buffer []string
    pointer int
}

func NewScanner() *Scanner {
    return &Scanner{
        reader: bufio.NewReaderSize(os.Stdin,4096),
        pointer: 0,
    }
}

func (self *Scanner) NextLine () string {
    var buffer []byte
    for {
        line,isPrefix,_ := self.reader.ReadLine()

        buffer = append(buffer, line...)
        if !isPrefix {
            break
        }
    }
    return string(buffer)
} 

func (self *Scanner) Next () string {
    if self.pointer >= len(self.buffer) {
        line := self.NextLine()
        self.buffer = strings.Fields(line)
        self.pointer = 0
    }
    self.pointer++
    return self.buffer[self.pointer-1]
}

func (self *Scanner) NextInt () int {
    s := self.Next()
    i,_ := strconv.ParseInt(s,10,32)
    return int(i)
}

func (self *Scanner) NextLong () long {
    s := self.Next()
    l,_ := strconv.ParseInt(s,10,64)
    return long(l)
}

func (self *Scanner) NextFloat () float {
    s := self.Next()
    f,_ := strconv.ParseFloat(s,32)
    return float(f)
}

func (self *Scanner) NextDouble () double {
    s := self.Next()
    d,_ := strconv.ParseFloat(s,64)
    return double(d)
}
// math
// func Max (a,b int) int { if a < b { return b } else { return a } }
// func Max (a,b long) long { if a < b { return b } else { return a } }

func main () {
    cin := NewScanner()

	R := cin.NextInt()
	G := cin.NextInt()

	fmt.Println(G * 2 - R)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int a[12][12],p[12];

int main()
{
    int n,m,i,k,x,rez,mask,nr,nrlight,j;
    scanf("%d%d",&n,&m);
    for(i=1; i<=m; i++)
    {
        scanf("%d",&k);
        while(k--)
        {
            scanf("%d",&x);
            a[i][x]=1;
        }
    }
    for(i=1; i<=m; i++)
        scanf("%d",&p[i]);
    rez=0;
    for(mask=0; mask<(1<<n); mask++)
    {
        nrlight=0;
        for(i=1; i<=m; i++)
        {
            nr=0;
            for(j=1; j<=n; j++)
                if(a[i][j] && (mask&(1<<(j-1)))!=0)
                    nr++;
            if(nr%2==p[i]%2)
                nrlight++;
        }
        if(nrlight==m)
            rez++;
    }
    printf("%d",rez);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main(){int n,i,j;double x[4],y[4];std::cin>>n;for(i=0;i<n;i++){for(j=0;j<4;j++)std::cin>>x[j]>>y[j];if(((y[0]-y[1])/(x[0]-x[1]))==((y[2]-y[3])/(x[2]-x[3])))std::cout<<"YES\n";else std::cout<<"NO\n";}}

Measured memory_bytes: 0
S = input()
k = int(input())
goal = ord('z') + 1
ans = []
for c in S:
    if c == 'a':
        ans.append('a')
        continue
    d = goal - ord(c)
    if k >= d:
        k -= d
        ans.append('a')
    else:
        ans.append(c)
last = (k + ord(ans[-1]) - ord('a')) % 26
ans[-1] = chr(ord('a') + last)
print(''.join(ans))


Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    double ans =1.0;
    double bunbo =0;
    cin >> n;
    
    vector<int> v(n,0);
    
    for(int i=0;i<n;i++){
        cin >> v[i];
        bunbo+=(1.0/v[i]);
    }
    cout << ans/bunbo <<endl;
   
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;

int main(void){
	int five[5], i, j, hand[3], var, ans, win, lose;
	while(1){
		scanf("%d",&five[0]);
		if(five[0] == 0){
			break;
		}
		for(i = 1;i < 5;i++){
			scanf("%d",&five[i]);
		}
		memset(hand,0,sizeof(hand));
		for(i = 0;i < 5;i++){ // 手の数をグー(hand[0])、チョキ(hand[1])、パー(hand[2])で数える
			hand[five[i] - 1]++;
		}
		var = 0;
		for(i = 0;i < 3;i++){ // みんなの手の種類を数える
			if(hand[i] != 0){
				var++;
			}
		}
		if(var == 1 || var == 3){ // 1種類の手と3種類の手はあいこ
			for(i = 0;i < 5;i++){
				printf("3\n");
			}
		}else{
			for(i = 0;i < 3;i++){
				if(hand[i] != 0 && hand[(i + 1) % 3] != 0){
					win = i;
					lose = (i + 1) % 3;
				}
			}
			for(i = 0;i < 5;i++){
				if(win == five[i] - 1){
					printf("1\n");
				}else{
					printf("2\n");
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1012
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
// #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 998244353;

const int N = 303;
const int M = 90003;
ll dp[N][M][2][2];

ll mod_pow(ll x, ll n){
    ll ret = 1;
    while(n){
        if(n&1) (ret *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

ll mod_inv(ll x){
    return mod_pow(x,mod-2);
}

const ll DIV = mod_inv(2);
int main(){
    int n;
    cin >>n;
    vector<int> a(n);
    int sa = 0;
    rep(i,n){
        cin >>a[i];
        sa += a[i];
    }

    dp[0][0][0][0] = 1;
    rep(i,n)rep(j,M)rep(x,2)rep(y,2)if(dp[i][j][x][y]){
        int nx = j+a[i];
        if(nx < M) (dp[i+1][nx][x][y] += dp[i][j][x][y]) %= mod;

        (dp[i+1][j][x|1][y] += dp[i][j][x][y]) %= mod;
        (dp[i+1][j][x][y|1] += dp[i][j][x][y]) %= mod;
    }

    ll sub = 0;
    rep(i,M)rep(x,2)rep(y,2){
        if(sa-i <= i){
            if(sa-i==i && (x==0 || y==0)) sub += dp[n][i][x][y]*DIV;
            else sub += dp[n][i][x][y];
            sub %= mod;
        }
    }
    sub *= 3;
    sub %= mod;

    ll ans = mod_pow(3,n) - sub + mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}




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

int d1[101], d2[101], d3[101], s1[101], s2[101], s3[101], sta[101];
int N, K;

void search(int n){
	
	if(n == N) return;
	
	if(n == 0){
		if(sta[0] == 1) s1[0] = 1;
		if(sta[0] == 2) s2[0] = 1;
		if(sta[0] == 3) s3[0] = 1;
		if(sta[0] == 0)s1[0] = s2[0] = s3[0] = 1;
		//cout << d1[0] << d2[0] << d3[0] << s1[0] << s2[0] << s3[0] << endl;
		search(1);
		return;
	}
	
	if(sta[n] == 1){
		d1[n] = s1[n - 1] % 10000;
		s1[n] = (d2[n - 1] + d3[n - 1] + s2[n - 1] + s3[n - 1]) % 10000;
		
	}
	if(sta[n] == 2){
		d2[n] = s2[n - 1] % 10000;
		s2[n] = (d1[n - 1] + d3[n - 1] + s1[n - 1] + s3[n - 1]) % 10000;
		
	}
	if(sta[n] == 3){
		d3[n] = s3[n - 1] % 10000;
		s3[n] = (d1[n - 1] + d2[n - 1] + s1[n - 1] + s2[n - 1]) % 10000;
		
	}
	if(sta[n] == 0){
		d1[n] = s1[n - 1] % 10000;
		d2[n] = s2[n - 1] % 10000;
		d3[n] = s3[n - 1] % 10000;
		s1[n] = (d2[n - 1] + d3[n - 1] + s2[n - 1]  + s3[n - 1]) % 10000;
		s2[n] = (d1[n - 1] + d3[n - 1] + s1[n - 1]  + s3[n - 1]) % 10000;
		s3[n] = (d1[n - 1] + d2[n - 1] + s1[n - 1]  + s2[n - 1]) % 10000;
	}
	
	if(sta[n + 1] != 0){
	
		if(sta[n + 1] == sta[n + 2]){
			if(sta[n + 1] == 1) s1[n] = 0; 
			if(sta[n + 1] == 2) s2[n] = 0;
			if(sta[n + 1] == 3) s3[n] = 0;
		}
	}
	//cout << d1[n] << d2[n] << d3[n] << s1[n] << s2[n] << s3[n] << endl;
	search(n + 1);
	return;
}

int main(){
	for(int i = 0;i < 101;i ++) sta[i] = 0;
	d1[0] = d2[0] = d3[0] = s1[0] = s2[0] = s3[0] = 0;
	
	cin >> N >> K;
	int Ai, Bi;
	for(int i = 0;i < K;i ++){
		cin >> Ai >> Bi;
		sta[Ai - 1] = Bi;
	}
	search(0);
	cout << (d1[N - 1] + d2[N - 1] + d3[N - 1] + s1[N - 1] + s2[N - 1] + s3[N - 1]) % 10000<< endl;
	
	return 0;
}



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

using namespace std;

int main(){
    
    
    int X;
    cin >> X;
    int ans = 1;
    
    for (int i = 2; i <= X; i++) {
        int a = i;
        for (int j = 1; j <= 10; j++) {
            a = a*i;
            
            if (a <= X) {
                if (ans < a) {
                    ans = a;
                }
            }else{
                break;
            }
            
            
        }
        
    }
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
template<typename V> typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int x, y;
  while (cin >> x >> y, x) {
    int t = 0;
    if (x < y) swap(x, y);
    for (; y; t++) {
      x %= y;
      swap(x, y);
    }
    cout << x << ' ' << t << endl;
  }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define int long long
#define endl "\n"
using namespace std;
int n  , m, x  , c , k ;
const int N = 1000000;
int z ;
int inf = 1e14;
int dp[N];
int a[N];



signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    cin >> n >> k;
    int nl=0;
    cout << max(n-k+1,nl) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	int n,i;
	cin>>n;
	int a[n],b[n];
	for(i=0;i<n;i++)
		cin>>a[i]>>b[i];
	for(i=0;i<n-2;i++)
	{
		if(a[i]==b[i])
		{
			if(a[i+1]==b[i+1])
			{
				if(a[i+2]==b[i+2])
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
	"sort"
)

type P struct {
	index int
	time  int
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n, q int
	fmt.Fscan(r, &n, &q)

	ps := make([]P, n)
	names := make([]string, n)
	for i := range ps {
		fmt.Fscan(r, &names[i])
		fmt.Fscan(r, &ps[i].time)
		ps[i].index = i
	}

	sort.Slice(ps, func(i, j int) bool {
		a, b := (ps[i].time-1)/q, (ps[j].time-1)/q
		if a == b {
			return ps[i].index < ps[j].index
		}
		return a < b
	})

	end := make([]uint8, n/8+1)
	et := 0
	for i, p := range ps {
		et += p.time
		endn := 0
		for j := 0; j <= p.index/8; j++ {
			endn += bits.OnesCount8(end[j] << uint(max(0, 8-p.index+8*j)))
		}
		aliven := p.index - endn
		fmt.Println(names[p.index], et+(n-i-1)*q*((p.time-1)/q)+aliven*q)
		end[p.index/8] |= 1 << (uint(p.index) % 8)
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}



Measured memory_bytes: 4440
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n := readInt()

	pro := 0
	m := make(map[int]bool)
	for i := 0; i < n; i++ {
		a := readInt()
		if a/400 > 7 {
			pro++
			continue
		}
		m[a/400] = true
	}

	fmt.Println(max(len(m), 1), len(m)+pro)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e4 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	map<int, int> mc;
	for (auto &c : str) mc[c] ^= 1;
	for (auto &p : mc)
	{
		if (p.second == 1)
			puts("No"), exit(0);
	}
	puts("Yes");
	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int n, k;
vector<int> a(100005);
vector<int> dp(100005, -1);

int solve(int start)
{
	if (start == n - 1)
		return 0;
	if (dp[start] != -1)
		return dp[start];

	int val = INT_MAX;

	for (int i = start + 1; i <= min(n, start + k); i++)
	{
		val = min(val, abs(a[start] - a[i]) + solve(i));
	}

	return dp[start] = val;
}

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

	cout << solve(0) << '\n';

	return 0;
}

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define RFOR(i, a, n) for (ll i = (ll)a; i >= n; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FOR(i, 1, n + 1)
#define RREP(i, n) RFOR(i, n - 1, 0)
#define RREPN(i, n) RFOR(i, n, 1)
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll extGCD(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1;
        y = 0;
        return a;
    }

    ll d = extGCD(b, a & b, y, x);
    y -= a / b * x;
    return d;
}

inline ll mod(ll &a, ll m)
{
    a = (a % m + m) % m;
    return a;
}

ll modinv(ll a, ll m)
{
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}

ll modadd(ll &a, ll b)
{
    mod(a, MOD);
    mod(b, MOD);
    a += b;
    return mod(a, MOD);
}

ll modsub(ll &a, ll b)
{
    return modadd(a, -b);
}

ll modmulti(ll &a, ll b)
{
    mod(a, MOD);
    mod(b, MOD);
    a *= b;
    return mod(a, MOD);
}

ll moddiv(ll &a, ll b)
{
    mod(a, MOD);
    a *= modinv(b, MOD);
    return mod(a, MOD);
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

//a,bの最大公約数
inline ll gcd(ll a, ll b)
{
    ll temp;
    while (a % b != 0)
    {
        temp = a;
        a %= b;
        b = temp;
    }
    return b;
}

//a,bの最小公倍数
inline ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

const int MAX_N = 1e5 + 10;

int main()
{
    int n, d, x[15][15];
    cin >> n >> d;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < d; ++j)
        {
            cin >> x[i][j];
        }
    }

    int result = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i; j < n; ++j)
        {
            if (i == j)
            {
                continue;
            }

            int r = 0;
            for (int k = 0; k < d; ++k)
            {
                r += pow(x[i][k] - x[j][k], 2);
            }
            int a = sqrt((double)r);
            if (a * a == r)
            {
                ++result;
            }
        }
    }

    cout << result << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
#define pi 3.1415926

int a[(int)2e5][11];

int main(){
    int n;
    cin >> n;
    if(n%2 == 0)
        cout << n/2;
    else    
        cout << n/2 + 1;
    

}

    

		


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int width, height, m[15][15];
	while (cin >> width >> height, width && height) {
		for (int y = 0; y < height; ++y)
			for (int x = 0; x < width; ++x)
				cin >> m[y][x];

		int sum = 0, pattern[15][15] = {0};
		for (int x = 0; x < width; ++x)
			pattern[0][x] = 1;

		for (int y = 0; y < height-1; ++y)
			for (int x = 0; x < width; ++x)
				if (m[y][x] == 0) {
					if (x - 1 >= 0 && m[y+1][x-1] == 0) pattern[y+1][x-1] += pattern[y][x];
					if (x + 1 < width && m[y+1][x+1] == 0) pattern[y+1][x+1] += pattern[y][x];
					if (m[y+1][x] != 1) pattern[y+1][x] += pattern[y][x];
				}
				else if (m[y][x] == 2) {
					if (y + 2 == height) sum += pattern[y][x];
					else if (m[y+2][x] != 1) pattern[y+2][x] += pattern[y][x];
				}


		for (int x = 0; x < width; ++x)
			if (m[height-1][x] != 1) sum += pattern[height-1][x];

		cout << sum << endl;
	}
	return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)
// }}} 2

// numerous {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// systems }}} 2

// }}} 1

int main() {

    priority_queue<ll> q;

    ll n,a;
    Scll(n);

    Rep(i,n){
        Scll(a);
        q.push(a);
    }

    a = 0;
    ll l = 0;

    while( q.empty() == 0){
        a = q.top();
        q.pop();
        if( q.empty() == 1 ) break;
        if( a == q.top()){
            q.pop();
            if( l ){
                printf ("%lld\n", a*l);
                return 0;
            }else{
                l = a;
                a = 0;
            }
        }
    }

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


    return 0;
}



Measured memory_bytes: 1400