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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    const i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;

    vector<vector<i64>> a(N,vector<i64>(N));
    rep(i,0,N){
        rep(j,0,N){
            cin >> a[i][j];
        }
    }

    const i64 size=21;
    static i64 dp[size][1<<size];
    fill_n((i64*)dp,size*(1<<size),0);

    rep(j,0,N){
        if(a[0][j]==0) continue;
        ++dp[0][1<<j];
    }

    rep(i,0,N-1){
        rep(s,0,1<<N){
            if(dp[i][s]==0) continue;
            rep(j,0,N){
                if(s&(1<<j)) continue;
                if(a[i+1][j]==0) continue;
                i64 t=s|(1<<j);
                dp[i+1][t]+=dp[i][s];
                dp[i+1][t]%=mod;
            }
        }
    }

    cout << dp[N-1][(1<<N)-1] << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 344320
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

def gcd(a, b):
    """
    Greatest Common Divisor
    Euclidean Algortihm
    """
    if a < b:
        gcd(b, a)
    while b != 0:
        a, b = b, a % b
    return a

INF = float('inf')
NIL = - 1


def lcm(x, y):
    return (x * y) // gcd(x, y)


A, B, C, D = map(int, input().split())
total = B - A + 1

if A % C != 0:
    c_count = (B // C) - (A // C)
else:
    c_count = (B // C) - (A // C) + 1

if A % D != 0:
    d_count = (B // D) - (A // D)
else:
    d_count = (B // D) - (A // D) + 1


lcm = lcm(C, D)
if A % lcm != 0:
    lcm_count = (B // lcm) - (A // lcm)
else:
    lcm_count = (B // lcm) - (A // lcm) + 1


print(total - c_count - d_count + lcm_count)


Measured memory_bytes: 38384
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

int N;

char queryRange(int pos)
{
    cout << "? ";
    rep(i, N) {
        cout << (pos+i+1) << ' ';
    }
    cout << endl;

    string ret;
    cin >> ret;
    return ret[0];
} 

char queryWithEvenRange(int pos, int rangePos)
{
    cout << "? " << (pos+1) << ' ';
    if (rangePos <= pos && pos < rangePos+N) {
        for (int i = 0; i < rangePos-1; ++i) {
            cout << (i+1) << ' ';
        }
        for (int i = rangePos+N; i < 2*N; ++i) {
            cout << (i+1) << ' ';
        }
    } else {
        rep(i, N-1) {
            cout << (rangePos+i+1) << ' ';
        }    
    }
    cout << endl;

    string ret;
    cin >> ret;
    return ret[0];
} 

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

    cin >> N;

    vector<char> balls(2* N);

    //! find one of the boundry between R and B
    int l = 0;
    int r = N;
    char c0 = queryRange(0);
    char c1 = (c0 == 'R' ? 'B' : 'R');
    while (l + 1 < r) {
        int m = (l + r) / 2;
        char c = queryRange(m);
        if (c == c0) {
            l = m;
        } else {
            r = m;
        }
    }

    // cout << "Found the boudary!. l = " << l << endl;
    balls[l] = c0;
    balls[l+N] = c1;
    //! We have even number of Rs and Bs in range [l+1, l+N)
    rep(i, 2*N) {
        if (i != l && i != l+N) {
            // cout << "Trying to identify ball at = " << i << endl;
            balls[i] = queryWithEvenRange(i, l+1);
        }
    }

    cout << "! ";
    rep(i, 2*N) {
        cout << balls[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 724
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll N;
  cin >> N;
  
  vll dp(N+1);
  dp[0] = 0;
  
  for(ll i=1; i<=N; i++) {
    //たぶん，見るべき回数はそんなに多くない
    //1円
    ll minv = dp[i - 1] + 1;
    ll s = 6;
    while(s <= N) {
      if(i - s >= 0) {
        chmin(minv, dp[i - s] + 1);
      }
      s *= 6;
    }
    
    s = 9;
    while(s <= N) {
      if(i - s >= 0) {
        chmin(minv, dp[i - s] + 1);
      }
      s *= 9;
    }
    
    dp[i] = minv;
  }
  
  fin(dp[N]);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  char c[2][3];
  
  for(int i = 0; i < 2; i++)
  {
    for(int j = 0; j < 3; j++)
    {
      cin>>c[i][j];
    }
  }
  if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	nums := make([]int, N, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&nums[i])

	}

	ans := 0

	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			for k := j + 1; k < N; k++ {
				if nums[i] != nums[j] && nums[j] != nums[k] && nums[i] != nums[k] {
					if nums[i]+nums[j] > nums[k] && nums[j]+nums[k] > nums[i] && nums[k]+nums[i] > nums[j] {
						ans++
					}
				}
			}
		}
	}

	fmt.Println(ans)
}


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



int main(){
  int n;
  cin >> n;
  int x=0, y=0, z=0;
  rep(i, n) {
    int a;
    cin >> a;
    if (a % 2) x++;
    else {
      if (a % 4) y++;
      else z++;
    }
  }

  if (y > 0) x++;
  if (x - 1 <= z) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
def input_n(infile,outfile):
	while True:
		n = int(infile.readline())
		if n == 0:
			break
		dice(infile,outfile,n)

def dice(infile,outfile,n):
	point = 1
	top = 1
	east = 3
	south = 2
	for i in range(n):
		buff = top
		command = infile.readline().split()[0]
		if command == "North":
			point += south
			top = south
			south = (7 - buff)
		elif command == "South":
			point += (7 - south)
			top = (7 - south)
			south = buff
		elif command == "East":
			point += (7 - east)
			top = (7 - east)
			east = buff
		elif command == "West":
			point += east
			top = east
			east = (7 - buff)
		elif command == "Right":
			point += top
			remember = south
			south = east
			east = (7 - remember)
		elif command == "Left":
			point += top
			remember = east
			east = south
			south = (7 - remember)
		else:
			break
	print >> outfile,point

if __name__ == "__main__":
	import sys
	input_n(sys.stdin, sys.stdout)

Measured memory_bytes: 4392
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string t="CODEFESTIVAL2016";
    string s;
    cin >> s;
    int ans =0;
    REP(i,16){
        if(t[i]!=s[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return (rand()<<16|rand())%x;
}
int n,m,h,w;
int main(){
	n=read(); m=read(); h=read(); w=read();
	if(n%h==0&&m%w==0){
		puts("No"); return 0;
	}
	puts("Yes");
	if(n%h){
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)if(i%h==0){
				write(2*n*(h-1)-1); putchar(' ');
			}else{
				write(-2*n); putchar(' ');
			}
			puts("");
		}
	}else{
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)if(j%w==0){
				write(2*m*(w-1)-1); putchar(' ');
			}else{
				write(-2*m); putchar(' ');
			}
			puts("");
		}
	}
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int>>graph(n+1);
	vector<int>indegree(n+1);
	queue<int>q;
	for(int i=1;i<=m;i++)
	{
		int from,to;
		cin>>from>>to;
		graph[from].push_back(to);
		indegree[to]++;
		
}
vector<int>maxDis(n+1);
for(int node=1;node<=n;node++)	
{
	if(indegree[node] == 0)	
	{
		q.push(node);
}
}
int longestPath=0;
while(q.size())
{
	int from = q.front();	
	q.pop();
	longestPath = max(longestPath,maxDis[from]);
	for(auto to : graph[from])
	{
		maxDis[to] = max(maxDis[to],maxDis[from]+1);
		indegree[to]--;
		if(indegree[to]==0)
		{
			q.push(to);
}
}
}
cout<<longestPath<<endl;

}
int  main()
{
	solve();
}






Measured memory_bytes: 9496
from collections import deque
import sys
sys.setrecursionlimit(10**7)

N,M=map(int,input().split())
H=list(map(int,input().split()))
road=[[] for i in range(N)]
toutatu=[0]*N
for i in range(M):
  a,b=map(int,input().split())
  road[a-1].append(b-1)
  road[b-1].append(a-1)
#print(road)

count=0

for i in range(N):
  flag=True
  for j in road[i]:
    if(H[i]<=H[j]):
      flag=False
  if(flag==True):
    count+=1
print(count)

Measured memory_bytes: 92320
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

ll N,M;
vector<ll>A(106);

void batten(ll i,ll k){
	if(i==N)return;
	if((A[i]%k)>(A[i+1]%k)){
		swap(A[i],A[i+1]);
		batten(i+1,k);
		return;
	}else{
		batten(i+1,k);
		return;
	}
}

ll mapdata[310][310];
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll ans=1;
	ll data=1;
	ll N;
	cin>>N;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		if(a%2==0)data*=2;
		ans*=3;
	}
	cout<<ans-data<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int H,W;
char maze[25][25];
int d[25][25];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(int sx,int sy,int gx,int gy){
    queue<pair<int,int>> que;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            d[i][j]=INF;
        }
    }
    que.push(make_pair(sx,sy));
    d[sx][sy]=0;
    while(!que.empty()){
        pair<int,int> p=que.front();
        que.pop();
        if(p.first==gx && p.second==gy) break;
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#' && d[nx][ny]==INF){
                que.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
    return d[gx][gy];
}

int main(){
    cin>>H>>W;
    rep(i,H){
        rep(j,W){
            cin>>maze[i][j];
        }
    }
    int ans=0;
    rep(i,H){
        rep(j,W){
            rep(k,H){
                rep(l,W){
                    if(maze[i][j]=='#' || maze[k][l]=='#') continue;
                    int tmp=bfs(i,j,k,l);
                    //cout<<tmp<<endl;
                    ans=max(ans,tmp);
                }
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void) {
    int i,j,k;
    int n,d;
    scanf("%d%d",&n, &d);
    int seq[n][d];
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
           scanf("%d",&seq[i][j]);
        }
    }
    int ans = 0;
    int tmp;
    double tmp2;
    double up, down;
    for(i=0;i<n;i++) {
        for(k=i+1;k<n;k++){
            tmp = 0;
            for(j=0;j<d;j++) {
                tmp = tmp + (seq[i][j] - seq[k][j]) * (seq[i][j] - seq[k][j]);
            }
            tmp2 = sqrt(tmp);
            down = modf(tmp2, &up);
            if(down == 0.0)
                ans++;
        }
    }

    printf("%d\n",ans);
}

Measured memory_bytes: 128
import math


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

    print(math.factorial(n) % (10 ** 9 + 7))

    # power = 1
    # 
    # for i in range(1, n + 1):
    #     power *= i

    # print(power % (10 ** 9 + 7))


if __name__ == "__main__":

    main()


Measured memory_bytes: 3980
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> xs, ys;
  vector<vector<int>> xy(100000);
  vector<vector<int>> yx(100000);
  vector<pair<int, int>> dat;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    dat.emplace_back(x, y);
    xs.emplace_back(x);
    ys.emplace_back(y);
    xy[x].push_back(y);
    yx[y].push_back(x);
  }
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  ys.erase(unique(ys.begin(), ys.end()), ys.end());

  vector<bool> xv(100000), yv(100000);
  queue<pair<int, int>> q;
  long long ans = -n;
  for (auto coord : dat) {
    int x, y;
    tie(x, y) = coord;
    if (!xv[x] && !yv[y]) {
      long long xcnt = 0, ycnt = 0;
      xv[x] = true;
      yv[y] = true;
      q.emplace(x, 0);
      xcnt++;
      q.emplace(y, 1);
      ycnt++;
      while (!q.empty()) {
        auto fr = q.front(); q.pop();
        int c, d;
        tie(c, d) = fr;
        if (d == 0) {
          // x
          for (auto e : xy[c]) {
            if (yv[e] == false) {
              yv[e] = true;
              q.emplace(e, 1);
              ycnt++;
            }
          }
        }
        else {
          // y
          for (auto e : yx[c]) {
            if (xv[e] == false) {
              xv[e] = true;
              q.emplace(e, 0);
              xcnt++;
            }
          }
        }
      }
      ans += xcnt * ycnt;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

#define int long long

const int MAXN = 1.2e8 + 28;

const int INF = 8e18 + 118;

map<int, vector<pair<int, int>>> mod;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x, d;
    cin >> n >> x >> d;
    if (d < 0)
    {
        d = -d;
        x = -x;
    }
    if (d == 0)
    {
        if (x == 0)
        {
            cout << 1 << endl;
            return 0;
        }
        cout << n + 1 << endl;
        return 0;
    }
    int ans = 0;
    vector<int> a(n + 1);
    for (int i = 0; i <= n; ++i)
    {
        a[i] = i;
    }
    if (x < 0)
    {
        reverse(a.begin(), a.end());
    }
    for (auto i : a)
    {
        int l = (i * (i - 1ll)) / 2ll;
        int r = i * (n - 1ll) - l + 1ll;
        int ind = ((i * x) % d + d) % d;
        int st = ((i * x) - ((i * x) % d + d % d)) / d;
        int en = st + r;
        st += l;
        if (st > en)
        {
            swap(st, en);
        }
        mod[ind].push_back({st, -1});
        mod[ind].push_back({en, 1});
    }
    for (auto el : mod)
    {
        sort(el.second.begin(), el.second.end());
        int cur = 0;
        int pr = 0;
        int st = 0;
        for (auto e : el.second)
        {
            cur -= e.second;
            if (cur == 0)
            {
                ans += e.first - st;
            }
            if (pr == 0)
            {
                st = e.first;
            }
            pr = cur;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,c,cnt=0;
    scanf("%d%d%d",&n,&m,&c);
    int b[m+1];
    for(int j=0; j<m; j++)scanf("%d",&b[j]);
    for(int i=1; i<=n; i++)
    {
        int a[m+1],yoo=0,var;
        for(int j=0; j<m; j++)
        {
            scanf("%d",&var);
            yoo+=(var*b[j]);
        }
        if(yoo+c>0)++cnt;
    }
    printf("%d\n",cnt);
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b;cin>>n>>a>>b;
  cout<<min(b,a*n)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;
using lli = long long int;
using tlli3 = tuple<lli, lli, lli>;

lli D[200001] = {};

int main(void) {

	lli N, Q;
	cin >> N >> Q;

	priority_queue<tlli3> pq;

	for (int i = 0; i < N; i++) {
		lli S, T, X;
		cin >> S >> T >> X;
		pq.push(tlli3{ X - S,X,0LL });
		pq.push(tlli3{ X - T,X,1LL });
	}

	for (int i = 0; i < Q; i++) {
		cin >> D[i];
	}
	sort(D, D + Q);

	set<lli> s;

	for (int i = 0; i < Q; i++) {
		lli d = D[i];

		while (!pq.empty()) {

			auto t = pq.top();

			get<0>(t) *= -1;

			if (get<0>(t) <= d) {
				pq.pop();
				if (get<2>(t) == 0)
				{
					s.insert({ get<1>(t) });
				}
				else if (get<2>(t) == 1) {
					s.erase({ get<1>(t) });
				}
			}
			else {
				break;
			}
		}

		//cout << d << " ";

		if (s.size() == 0) {
			cout << "-1" << endl;
		}
		else {
			lli lower = *s.lower_bound(0);

			cout << lower << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 23016
#include <iostream>
int main() {
    int b, f, r, v, z[5][4][11] = { 0 };
    std::string s = { "####################" };
    std::cin >> b; // skip
    while (std::cin >> b >> f >> r >> v) {
        z[b][f][r] += v;
    }
    for (int i = 1; i < 5; ++i) {
        if (i != 1) {
            std::cout << s << std::endl;
        }
        for (int j = 1; j < 4; ++j) {
            for (int k = 1; k < 11; ++k) {
                std::cout << ' ' << z[i][j][k];
            }
            std::cout << std::endl;
        }
    }
}



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

int main(){
    char buf[4];
    
    cin >> buf;
    int a = atoi(buf);

    cin >> buf;
    int b = atoi(buf);

    cin >> buf;
    int c = atoi(buf);

    if(a == b){
        cout << c << endl;
    }else if(a == c){
        cout << b << endl;
    }else{
        cout << a << endl;
    }
}

Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

S = rs()
T = rs()

ans = len(T)
for i in range(len(S)-len(T)+1):
	c = 0
	for j in range(len(T)):
		if S[i+j] != T[j]:
			c += 1
	ans = min(ans, c)
print(ans)


Measured memory_bytes: 68596
#include <iostream>
#include <vector>
#include <cstring>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;
typedef pair<int, bool> IB;

struct P{
	int id;
	int tanka;
	int kosuu;
};

ll shain[4001];
bool used[4001];
bool more[4001];

int main()
{
	int n;

	while (cin >> n && n ){
		memset (shain, 0LL, sizeof (shain ) );
		memset (used, false, sizeof (used ) );
		memset (more, false, sizeof (more ) );
		vector<P> data (n );

		rep (i, n )
			cin >> data[i].id >> data[i].tanka >> data[i].kosuu;

		rep (i, n ){
			ll total = (ll)data[i].tanka*(ll)data[i].kosuu;
			shain[data[i].id] += total;
		} // end if

		for (int i = 1; i <= 4000; i++ )
			if (shain[i] >= 1000000LL )
				more[i] = true;

		bool found = false;
		rep (i, n ){
			if (more[data[i].id] && !used[data[i].id] ){
				cout << data[i].id << endl;
				used[data[i].id] = true;
				if (!found )
					found = true;
			} // end if
		} // end rep

		if (!found )
			cout << "NA" << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1252
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

N = int(input())
# S = input()
# N, M = map(int, input().split())
# 横
H = [int(x) for x in input().split()]
H.reverse()
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]

flag = True
tmp = 10 ** 9 + 1

for h in H :
    if h > tmp :
        if h - 1 > tmp :
            flag = False
            break
        tmp = h - 1

    else :
        tmp = h

print("Yes" if flag else "No")


Measured memory_bytes: 63984
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
    while (true) {
        int n, m;
        int diff = 0;
        int s_taro[100], s_hanako[100];
        cin >> n >> m;
        if (n == 0 && m == 0) {
            break;
        }
        for (int i=0; i<n; i++) {
            cin >> s_taro[i];
            diff += s_taro[i];
        }
        for (int i=0; i<m; i++) {
            cin >> s_hanako[i];
            diff -= s_hanako[i];
        }
        if (diff%2 != 0) {
            cout << -1 << endl;
            continue;
        }
        sort(s_taro, s_taro+n);
        sort(s_hanako, s_hanako+m);

        bool is_found = false;
        for (int i=0; i<n; i++) {
            int begin = 0;
            int end = m-1;
            int center = (begin+end)/2;
            while (begin <= end) {
                int condition = (s_taro[i]-s_hanako[center])-diff/2;
                if (condition == 0) {
                    is_found = true;
                    break;
                }
                if (condition > 0) {
                    begin = center+1;
                    center = (begin+end)/2;
                }
                else {
                    end = center-1;
                    center = (begin+end)/2;
                }
            }
            if (is_found) {
                cout << s_taro[i] << ' ' << s_hanako[center] << endl;
                break;
            }
        }
        if (!is_found) {
            cout << -1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1180
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,x = f()
    a = f()
    sum1 = sum(a)

    a = [ min(x, i) for i in a ]
    ans = sum1 - sum(a)

    for i in range(1,n):
        if a[i] + a[i-1] > x:
            ans += a[i] + a[i-1] -x
            a[i] =  x - a[i-1]
    print(ans)

solve()


Measured memory_bytes: 14188
N = int(input())

ans = [0]*N
for i in range(N-1):
    c,s,f = map(int,input().split())
    ans[i] += c+s
    for j in range(i):
        ans[j] = max((ans[j]+f-1)//f*f, s)+c
for a in ans:
    print(a)
    


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

int main(){
  int a,b,c[3],tmp;
  cin>>a>>b;
  c[0]=a+b;c[1]=a-b;c[2]=a*b;
  if(c[1]<c[2]){
    c[1]=c[2];
  }
  if(c[0]<c[1]){
    c[0]=c[1];
  }
  cout<<c[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
   
struct node{
  struct node *l;
  struct node *r;
  struct node *p;
  int key;
};
 
typedef struct node * Node;
 
Node root;
 
void insert(int);
Node Search(Node ,int );
void Preorder(Node );
void Inorder(Node );
 
main()
{
  int n, i, a;
  char str[20];
  Node s;
  scanf("%d",&n);
   
  for(i=0; i<n; i++){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d", &a);
      insert(a);
    }
    else if(str[0]=='f'){
      scanf("%d", &a);
      s = Search(root,a);
      if(s!= NIL ) {printf("yes\n");}
      else {printf("no\n");}
    }
    else if (str[0]=='p'){
      Inorder(root);
      printf("\n"); 
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}
 
 
void insert(int k)
{
  Node b=NIL;
  Node a=root;
  Node c;
   
  c = malloc(sizeof(struct node));
  c->key=k;
  c->l=NIL;
  c->r=NIL;
   
  while(a!=NIL){
    b=a;    
    if(c->key<a->key) a=a->l;
    else a=a->r;
  }
  c->p=b;
   
  if(b==NIL) root=c;
  else if(c->key<b->key) b->l=c;
  else b->r=c;
}
 
 
Node Search(Node t,int k)
{
  if(t==NIL || k==t->key) return t;
  if(k<t->key) return Search(t->l,k);
  else return Search(t->r,k);
}
 
 
void Preorder(Node t)
{
  printf(" %d",t->key);
  if(t!=NIL){
    if(t->l!=NIL) Preorder(t->l);
    if(t->r!=NIL) Preorder(t->r);
  }
}
   
 
void Inorder(Node t)
{  
  if(t!=NIL){
    if(t->l != NIL){
      Inorder(t->l);
    }
    printf(" %d", t->key);   
    if(t->r!=NIL){
      Inorder(t->r);
    }
  }
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

void solve(long long A, long long B){
    cout << A*B << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3760
use std::io::*;

fn main() {
  let input = {
    let mut buf = vec![];
    stdin().read_to_end(&mut buf);
    unsafe { String::from_utf8_unchecked(buf) }
  };
  let mut lines = input.split('\n').map(|s| s.parse::<u32>().unwrap());

  let a = lines.next().unwrap();
  let b = lines.next().unwrap();
  let c = lines.next().unwrap();
  let d = lines.next().unwrap();
  let p = lines.next().unwrap();

  let x = p * a;
  let y = b + p.saturating_sub(c) * d;

  println!("{}", if x < y { x } else { y });
}



Measured memory_bytes: 5016
i;
main(x)
{
  char s[99];
  for(;~scanf("%s",s);puts(""))
    {
      for(i=0;s[i]!=0;i++)
	if(s[i]!=64)
	  putchar(s[i]);
	else
	  for(x=s[i+1]-48,i+=2;x--;)
	    putchar(s[i]);
    }
  exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>

using namespace std;

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2;
    s3 = "";
    int i = 0, j = 0;
    while (i < s1.size() || j < s2.size()){
        if (i < s1.size()){
            s3 += s1[i];
            i++;
        }
        if (j < s2.size()){
            s3 += s2[j];
            j++;
        }
    }
    cout << s3 << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

var dest []rune
var diff int = 0
var arr [10]rune =[10]rune {'a','b','c','d','e','f','g','h','i','j'}

func dfs(len int,N int){
	if len  == N {
		fmt.Println(string(dest))
		return
	}
	var flag bool = false
	for i:=0;i<=diff;i++ {
		dest[len] = arr[i]
		if i == diff {
			diff++
			flag = true
		}
		dfs(len+1,N)
		if flag {
			diff--
		}
	}

}

func main() {
	var N int
	fmt.Scanf("%d",&N)
	dest = make([]rune,N)
	dfs(0,N)

}


Measured memory_bytes: 5504
import sys
import math
import bisect

def solve(n, A):
    for i in range(1000):
        s = str(i)
        if len(s) == n:
            ok = True
            for p in A:
                a, b = (p[0], p[1])
                if s[a-1] != str(b):
                    ok = False
                    break
            if ok:
                return i
    return -1

def main():
    n, m = map(int, input().split())
    A = []
    for _ in range(m):
        a, b = map(int, input().split())
        A.append([a, b])
    print(solve(n, A))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    ll ma = -1e10, mi = 1e10, mapos, mipos;
    REP(i, n){
        cin >> a[i];
        if(a[i] > ma){
            ma = a[i];
            mapos = i;
        }
        if(a[i] < mi){
            mi = a[i];
            mipos = i;
        }
    }
    cout << 2 * n - 2 << endl;
    if(abs(ma) > abs(mi)){
        REP(i, n){
            if(i != mapos) cout << mapos + 1 << " " << i + 1 << endl;
        }
        REP(i, n - 1){
            cout << i + 1 << " " << i + 2 << endl;
        }
    }
    else{
        REP(i, n){
            if(i != mipos) cout << mipos + 1 << " " << i + 1 << endl;
        }
        REPR(i, n - 1){
            cout << i + 2 << " " << i + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N, W = MI()
    dp = [0] * (W+1)
    w = [0] * N
    v = [0] * N

    for i in range(N):
        w[i], v[i] = MI()

    for i in range(N):
        dp_next = [0] * (W + 1)
        for j in range(W):
            dp_next[j] = max(dp_next[j], dp[j])
            if j + w[i] <= W:
                dp_next[j+w[i]] = max(dp[j] + v[i], dp_next[j])
        dp = dp_next

    print(max(dp))


if __name__ == '__main__':
    main()


Measured memory_bytes: 117612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() { ll X, Y;
  cin >> X >> Y;
  ll ans = 0;
  ll num = X;
  while(num<=Y){
    ans++;
    num *= 2;
  }
  cout << ans << endl;
}

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

typedef long long ll;

#define $(i, a, n) for(int i = a; i <= n; i++)

inline ll read(){
	ll ans = 0;
	char last = ' ', ch = getchar();
	while(ch <'0' || ch > '9') last = ch, ch = getchar();
	while(ch >='0' && ch <='9') ans = (ans << 3) + (ans << 1) + ch -'0', ch = getchar();
	if(last == '-') ans = -ans;
	return ans;
}
using namespace std;
const int INF = 0x3f3f3f;
const int MAXN = 105;
char s[MAXN];
int main(){
	//freopen("testdata.in","r", stdin);
	//freopen("ans.out", "w", stdout);
	char *op;
	scanf("%s", s);
	op = s;
	bool flagc = false;
	bool flagk = false, flagf = false;
	while(*op != '\0') {
		if(*op == 'C') {
			flagc = true;
			flagk = true;
		}
		if(flagk && *op == 'F') {
			flagf = true;
			break;
		}
		op++;
	}
	if(flagc && flagf) printf("Yes");
	else printf("No"); 
	return 0;
}


Measured memory_bytes: 128
n = int(input())
s = input()
ans = s.count("R") * s.count("G") * s.count("B")

for i in range(n):
    for j in range(i+1,n):
        if s[i] != s[j]:
            k = j + (j - i)
            if k >= n or j >= n:
                break
            if s[i] != s[j] != s[k] != s[i]:
                # print(i, j, k)
                ans -= 1

print(ans)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

int IsPrime(int X){
    if(X<=1)return false;
    for(int i=2;i*i<=X;i++){
        if(X%i==0){
            return false;
        }
    }
    return true;
}


signed main(){
    int N,P;
    cin >> N >> P;
    map<int,int> sosu;
    vector<int> platypus;
    if(N==1){
        cout << P << endl;
        return 0;
    }
    
    if(IsPrime(P)==true){
        cout << 1 << endl;
    }
    
    int M=P;
    bool c=false;
    while(M>1){
        c=false;
        for(int i=2;i*i<=M;i++){
            if(M%i==0){
                if(sosu[i]==0){
                    platypus.push_back(i);
                }
                sosu[i]++;
                M/=i;
                c=true;
                break;
            }
            c=false;
        }
        if(c==false){
            if(sosu[M]==0){
                platypus.push_back(M);
            }
            sosu[M]++;
            M=1;
        }
        //cout << M << endl;
    }
    
    //cout << platypus.size() << endl;
    //REP(i,platypus.size()){cout << platypus[i] << " ";}cout << Endl;
    
    int Ans=1;
    REP(i,platypus.size()){
        int f=sosu[platypus[i]];
        f/=N;
        REP(j,f){
            Ans*=platypus[i];
        }
    }
    
    cout << Ans << endl;
    
    return 0;
}   


Measured memory_bytes: 256
n = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
    if P[i - 1] < P[i] < P[i + 1] or P[i - 1] > P[i] > P[i + 1]:
        ans += 1

print(ans)


Measured memory_bytes: 2940
import sys
s=input()
t=input()
s_l=[]
t_l=[]

for i in range(len(s)):
    s_l.append(s[i])
    s_l.sort()
for i in range(len(t)):
    t_l.append(t[i])
    t_l.sort(reverse=True)


for i in range(min(len(s),len(t))):   
    
    if ord(s_l[i])>ord(t_l[i]):
        print("No")
        sys.exit()
    elif ord(s_l[i])==ord(t_l[i]):
        pass
    elif ord(s_l[i])<ord(t_l[i]):
        print("Yes")
        sys.exit()
    
if len(s)>=len(t):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define tag "spoj"
#define maxn 10007
#define oo 2000000007
#define meset(a,x) memset(a,x,sizeof(a))
#define loop(x) for(int LoOpEr=x;LoOpEr-->0;)
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool check(const vector<int> &a,const vector<int> &b)
{
    long long sum=0;
    for(int i=0;i<a.size();i++) sum+=(a[i]-b[i])*(a[i]-b[i]);

    return (int)sqrt(sum)*sqrt(sum)==sum;
}
int main()
{
    #ifdef dmdd
    freopen(tag".inp","r",stdin); freopen(tag".out","w",stdout);
    #endif // dmdd
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,d;

    vector<int> a[11];

    cin>>n>>d;
    for(int i=1;a[i].resize(d),i<=n;i++)
        for(int j=0;j<d;j++)
            cin>>a[i][j];

    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<i;j++)
            ans+=check(a[i],a[j]);

    cout<<ans;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<long long> h(n);
  for (long long& hi : h) {
    cin >> hi;
  }
  vector<long long> dp(n, INT_MAX);
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j : {i - 1, i - 2}) {
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 4764
#include <iostream>
using namespace std;
int main()
{
	int w,a,b,z,x,s,v;
	cin>>w>>a>>b;
	if(b>a)
	{
		z = w+a;
		x = b-z;
		if(x<0)
		{
			cout<<"0";
		}
		else
		{
			cout<<x;
		}
	}
	else
	{
		s = w+b;
		v = a-s;
		if(v<0)
		{
			cout<<"0";
		}
		else
		{
			cout<<v;
		}
	}
}

Measured memory_bytes: 256
N=int(input())
As=[0]*N
Bs=[0]*N
for i in range(N):
    As[i],Bs[i] = map(int,input().split())
As.sort()
Bs.sort()

if N%2==1:
    Amin=As[(N+1)//2-1]
    Bmin=Bs[(N+1)//2-1]
    ans=Bmin-Amin+1
else: #N%2==0
    Amin=(As[N//2-1]+As[N//2])/2
    Bmin=(Bs[N//2-1]+Bs[N//2])/2
    ans=(Bmin-Amin)/0.5+1
print(int(ans))

Measured memory_bytes: 25492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,K;
    string S;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    ll ans = 0;
    rep(i,K){
        ans += A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h> // First Second, by Errichto
using namespace std;
const int nax = 1e6 + 5;
int child[nax][26];
bool is_end[nax];
int nxt = 1;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> in(n);
    vector<vector<int>> paths(n);
    for(int who = 0; who < n; ++who) {
        string& s = in[who];
        cin >> s;
        reverse(s.begin(), s.end());
        int node = 0;
        for(char ch : s) {
            paths[who].push_back(node);
            if(child[node][ch-'a'] == 0) {
                child[node][ch-'a'] = nxt++;
            }
            node = child[node][ch-'a'];
        }
        is_end[node] = true;
    }
    long long answer = 0; // 'int' is enough
    for(int who = 0; who < n; ++who) {
        string& s = in[who];
        set<char> suffix;
        for(int i = (int) s.length() - 1; i >= 0; --i) {
            suffix.insert(s[i]);
            int node = paths[who][i];
            for(char ch : suffix) {
                answer += is_end[child[node][ch-'a']];
            }
        }
    }
    printf("%lld\n", answer - n); // subtract pairs (s[i], s[i])
}

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

int main() {
  ll w,h,x,y;
  cin >> w >> h >> x >> y;
  string check="0";
  if(x*2==w&&y*2==h) {
    check="1";
  }
  cout << fixed << setprecision(10) << w*h/2.0 << " " << check << endl;
}

Measured memory_bytes: 256
using System;
class c
{
    static void Main()
    {
        var ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int ans = 0;
        if (ab[0] >= ab[1])
        {
            ans += ab[0];
            ab[0]--;
        }
        else
        {
            ans += ab[1];
            ab[1]--;
        }
        if (ab[0] >= ab[1])
        {
            ans += ab[0];
            ab[0]--;
        }
        else
        {
            ans += ab[1];
            ab[1]--;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(){
  int s;
  scanf("%d",&s);
  int a[4];
  a[0] = s % 10;
  a[1] = (s/10) % 10;
  a[2] = (s/100) % 10;
  a[3] = (s/1000) % 10;
  int p = (a[0]-a[1])*(a[1]-a[2])*(a[2]-a[3]);
  if(p == 0) printf("Bad\n");
  else printf("Good\n");
  return 0;
}

Measured memory_bytes: 128
N = input()
if N  == 0:
    print 0
elif N > 0:
    A = []
    B = []
    carry = 0
    cnt = 0
    while N > 0:
        if cnt == 0:
            B.append(0)
            if N % 2 == 1 and carry == 0:
                A.append(1)
            elif N % 2 == 1 and carry == 1:
                A.append(0)
            elif N % 2 == 0 and carry == 0:
                A.append(0)
            elif N % 2 == 0 and carry == 1:
                A.append(1)
                carry = 0
        else:
            A.append(0)
            if N % 2 == 1 and carry == 0:
                B.append(1)
                carry = 1
            elif N % 2 == 1 and carry == 1:
                B.append(0)
            elif N % 2 == 0 and carry == 0:
                B.append(0)
            elif N % 2 == 0 and carry == 1:
                B.append(1)
        N /= 2
        cnt ^= 1
    if carry:
        if cnt == 0:
            A.append(1)
            B.append(0)
        else:
            A.append(0)
            B.append(1)
            A.append(1)
            B.append(0)
    A.reverse()
    B.reverse()
    ans = []
    for a, b in zip(A, B):
        ans.append(a + b)
    print "".join(map(str, ans))
else:
    N *= -1
    A = []
    B = []
    carry = 0
    cnt = 0
    while N > 0:
        if cnt == 0:
            B.append(0)
            if N % 2 == 1 and carry == 0:
                A.append(1)
                carry = 1
            elif N % 2 == 1 and carry == 1:
                A.append(0)
            elif N % 2 == 0 and carry == 0:
                A.append(0)
            elif N % 2 == 0 and carry == 1:
                A.append(1)
        else:
            A.append(0)
            if N % 2 == 1 and carry == 0:
                B.append(1)
            elif N % 2 == 1 and carry == 1:
                B.append(0)
            elif N % 2 == 0 and carry == 0:
                B.append(0)
            elif N % 2 == 0 and carry == 1:
                B.append(1)
                carry = 0
        N /= 2
        cnt ^= 1
    if carry:
        if cnt == 1:
            B.append(1)
            A.append(0)
        else:
            B.append(0)
            A.append(1)
            B.append(1)
            A.append(0)
    A.reverse()
    B.reverse()
    ans = []
    for a, b in zip(A, B):
        ans.append(a + b)
    print "".join(map(str, ans))


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  int s;
  double w, l;

  while (scanf("%d,%lf,%lf", &s, &w, &l) != EOF){
    if (w / (l * l) >= 25.0) cout << s << endl;
  }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(auto &x : v) {
    cin >> x;
  }
  
  for(int x : v) {
    if(x%2==0 && x%3 != 0 && x%5 != 0){
      cout << "DENIED";
      return 0;
    }
  }
    cout << "APPROVED";
}

Measured memory_bytes: 256