akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


void prime_factorize(int n, std::map<int,int>& prime_factors) {
	for(int i=2;i*i<=n;i++) {
		while(n%i==0) {
			prime_factors[i]++;
			n/=i;
		}
	}
	if(n!=1) prime_factors[n]++;
}


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];

	std::map<int,int> maxmap;
	rep(i,n) {
		std::map<int,int> prime_factors;
		prime_factorize(a[i],prime_factors);
		for(auto x:prime_factors) {
			maxmap[x.first] = std::max(maxmap[x.first],x.second);
		}
	}
	mint lcm = 1;
	for(auto x:maxmap) {
		lcm*=mint(x.first).pow(x.second);
	}
	mint ans = 0;
	rep(i,n) {
		ans+=lcm/mint(a[i]);
	}
	print(ans);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	int ret = 0;
	char s[16], t[16];

	scanf("%s", s);
	scanf("%s", t);

	ret = strncmp(s, t, strlen(s));

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

	return 0;
}


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

#define int ll

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int32_t main() {
	string s, t;
	cin >> s >> t;
	for(int i = 0; i < sz(s); i++) {
		if(s[i] != t[i]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


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

int main()
{
  long N, W;
  cin >> N >> W;
  long w[105] = {};
  long v[105] = {};
  for (int i = 1; i <= N; i++)
  {
    cin >> w[i] >> v[i];
  }
  
  long mx_value[105][100005] = {}; // N行W列
  mx_value[1][w[1]] = v[1];
  
  for (int i = 2; i <= N; i++)
  {
    long wi = w[i], vi = v[i];
    
    for (int j = 1; j <= W; j++)
    {
      mx_value[i][j] = mx_value[i - 1][j]; // 上の行に書いてある価値を下の行に書き写す
    }
    
    for (int j = W - 1; j >= 1; j--)
    {
      if (mx_value[i][j] > 0 && j + wi <= W)
      {
        mx_value[i][j + wi] = max(mx_value[i][j + wi], mx_value[i][j] + vi);
      }
    }
    
    mx_value[i][wi] = max(mx_value[i][wi], vi);
  }
  
  long ans = 0;
  for (int j = 1; j <= W; j++)
  {
    ans = max(ans, mx_value[N][j]);
    //cout << mx_value[N][j] << " ";
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 82304
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
int flag[30];
int main(){
    char s[100500];
    cin>>s;
    memset(flag,0,sizeof(flag));
    for(int i=0;i<strlen(s);i++){
        flag[s[i]-'a']++;
    }
    int cnt=0;
    for(int i=0;i<26;i++){
        if(flag[i]==0){
            cout<<(char)(i+'a')<<endl;
            cnt++;
            break;
        }
    }
    if(!cnt) cout<<"None"<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

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

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

int main(){
    int N,T,cnt=0;
    cin>>N>>T;
    vector<int> t(N);
    
    for(int i=0;i<N;i++){
        cin>>t.at(i);
    }
    if(t.size()==1){
        cout<<T<<endl;
        return 0;
    }
    cnt+=T;
    for(int j=1;j<N;j++){
        if(t.at(j)-t.at(j-1)>=T)
            cnt+=T;
        else
            cnt+=t.at(j)-t.at(j-1);
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
n = gets.to_i
n.times do
  x0, y0, w, h = gets.split.map(&:to_i)
  k = 0
  gets.to_i.times do
    x, y = gets.split.map(&:to_i)
    k += 1 if (x0..x0+w) === x && (y0..y0+h) === y
  end
  p k
end


Measured memory_bytes: 6848
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	string s;
	cin >> s;
	if(s.back() == '3')
		cout << "bon";
	else
	if(s.back() == '0' || s.back() == '1' || s.back() == '6' || s.back() == '8')
			cout << "pon";
		else
			cout << "hon";





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll K,A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>A>>B;
	if(A>=B-2 || (K+1)<=A) {
		cout<<(K+1)<<endl;
	}
	else {
		ll C=A;
		K-=A-1;
		C+=(B-A)*(K/2);
		if(K%2) C++;
		cout<<C<<endl;
		
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;

int main(){
    int a;
    cin>>a;
    if(a==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
    else if(a==23){
        cout<<"Christmas Eve Eve"<<endl;
    }
    else if(a==24){
        cout<<"Christmas Eve"<<endl;
    }
    else{
        cout<<"Christmas"<<endl;
    }
    
    return 0;
}

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

int main(void)
{
	int t, d, l;
	while (true) {
		int ans = 0;
		int time = 0;
		cin >> t >> d >> l;
		if (t == d && d == l && l == 0) break;
		vector<int> n(t);
		for (int i = 0; i < t; i++) {
			cin >> n[i];
		}
		for (int i = 0; i < t-1; i++) {
			if (n[i] >= l) {
				time = d;
			}
			else {
				time--;
			}
			if (time > 0) {
				ans++;
			}
			//cout << time << endl;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3484
#include <algorithm>
#include <cstdio>
int mx[305][305], dis[305][305]; 
int main()
{
	// freopen("ARC089-E.in", "r", stdin); 
	int a, b, n = 300; 
	scanf("%d%d", &a, &b); 
	for (int i = 1; i <= a; i++)
	{
		for (int j = 1; j <= b; j++)
			scanf("%d", dis[i] + j); 
	}
	for (int x = 0; x <= 100; x++)
	{
		for (int y = 0; y <= 100; y++)
		{
			for (int i = 1; i <= a; i++)
			{
				for (int j = 1; j <= b; j++)
					mx[x][y] = std::max(mx[x][y], dis[i][j] - (i * x + j * y)); 
			}
		}
	}
	for (int i = 1; i <= a; i++)
	{
		for (int j = 1; j <= b; j++)
		{
			bool f = false; 
			for (int x = 0; x <= 100 && !f; x++)
			{
				for (int y = 0; y <= 100 && !f; y++)
					f |= mx[x][y] + i * x + j * y == dis[i][j]; 
			}
			if (!f)
			{
				puts("Impossible"); 
				return 0; 
			}
		}
	}
	puts("Possible");
	// return 0; 
	printf("%d %d\n", n, 101 * 101 + 100 * 2);
	for (int i = 1; i <= 100; i++)
		printf("%d %d X\n", i, i + 1);
	for (int i = 1; i <= 100; i++)
		printf("%d %d Y\n", n - i, n - i + 1);
	for (int i = 0; i <= 100; i++)
	{
		for (int j = 0; j <= 100; j++)
			printf("%d %d %d\n", i + 1, n - j, mx[i][j]);
	}
	printf("%d %d\n", 1, n);
	return 0; 
}


Measured memory_bytes: 384
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
ans = ''
score = 0
for i in range(N):
  if i - K < 0:
    if T[i] == 'r':
      score += P
      ans += 'r'

    if T[i] == 's':
      score += R
      ans += 's'

    if T[i] == 'p':
      score += S
      ans += 'p'

  else:
    if T[i] != ans[i-K]:
      if T[i] == 'r':
        score += P
        ans += 'r'

      if T[i] == 's':
        score += R
        ans += 's'

      if T[i] == 'p':
        score += S
        ans += 'p'
    else:
      if i + K < N:
        if T[i] == T[i+K]:
          if T[i+K] == 'r':
            ans += 'p'
          if T[i+K] == 's':
            ans += 'r'
          if T[i+K] == 'p':
            ans += 's'

        else:
          if T[i+K] == 'r':
            ans += 'p'
          if T[i+K] == 's':
            ans += 'r'
          if T[i+K] == 'p':
            ans += 's'

      else:
        ans += 'p'


print(score)

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  long double a,b,x;
  cin >> a >> b >> x;

  // x /= a;

  long double ans;
  long double pi = acos(-1);

  if(a*b - 2*x/a >= 0){
    ans = pi / 2 - atan(2 * x/a / ( b * b));
    ans = ans * 180 / pi;
  }else{
    ans = atan(2 * (a*b - x/a) / (a * a));
    ans = ans * 180 / pi;
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
int n,x,t;
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>x>>t;
	cout<<(n+x-1)/x*t;
	re 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <queue>

using namespace std;

int main(void)
{
    int terms_count;
    int eval_length;
    
    cin >> terms_count >> eval_length;

    queue<int> score_que;

    int i = 0;
    for(;i < eval_length; i++){
        int s;
        cin >> s;
        score_que.push(s);
    }

    for(;i < terms_count; i++){
        int s;
        cin >> s;

        if(score_que.front() < s){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        score_que.pop();
        score_que.push(s);
    }

    return 0;
}

Measured memory_bytes: 4448
import sys

def main():

    N = int(sys.stdin.readline().rstrip())
    X = [int(x) for x in sys.stdin.readline().rstrip().split()]

    m = 100**2 * 100
    for p in range(101):
        tmp = 0
        for x in X:
            tmp += (x - p)**2
        m = min(tmp,m)

    print(m)


main()

Measured memory_bytes: 9084
from collections import deque

N,M = map(int, input().split())

G = [[] for i in range(N)]
for i in range(M):
    A,B = map(int, input().split())
    G[A-1].append(B-1)
    G[B-1].append(A-1)

dist = [1e8 for i in range(N)]
dist[0] = 0

ans = [-1 for i in range(N)]

Q = deque()
Q.append(0)

while len(Q) > 0:
    now = Q.popleft()

    for to in G[now]:
        if(dist[now] + 1 < dist[to]):
            dist[to] = dist[now] + 1
            ans[to] = now+1
            Q.append(to)

print("Yes")
for i in ans[1:]:
    print(i)




Measured memory_bytes: 38812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] strs = Console.ReadLine().Split(' ');

            int[] l = new int[strs.Length];
            int index = 0;
            int sum = 0;
            int max = 0;
            foreach (var str in strs)
            {
                l[index] = int.Parse(str);

                sum += l[index];

                if (max < l[index]) max = l[index];

                ++index;
            }

            Console.WriteLine((max < sum - max)? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
N,K=map(int,input().split())
P=list(map(int,input().split()))
a=N-K
D=0
for i in range(K):
  b=(1+P[i])*P[i]/2
  D+=b/P[i]
ans=D
for i in range(a):
  b=(1+P[i])*P[i]/2
  c=(1+P[i+K])*P[i+K]/2
  D+=c/P[i+K]
  D-=b/P[i]
  ans=max(ans,D)
print(ans)

Measured memory_bytes: 25604
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
#define ld long double
const ll INF = 1e13;
const ll N = 301;
const ll mod= 1000000007;
bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}
 ld dp[N][N][N];
void solve()
{
  
  ll n,x;
  ll c1=0, c2=0, c3=0;
  cin>>n;
  loop(i,0,n)
  {
  	cin>>x;
  	if(x==1) c1++;
  	if(x==2) c2++;
  	if(x==3) c3++;
  }
  loop(i,0,n+1)
  {
  	loop(j,0,n+1)
  	{
  		loop(k,0,n+1)
  		{
  			ll sum = i+j+k;
  			if(sum==0)
  			{
  				dp[i][j][k]=0;
  				continue;
			}
			dp[i][j][k]+=n;
			if(i) dp[i][j][k]+=dp[i-1][j+1][k]*i;
			if(j) dp[i][j][k]+=dp[i][j-1][k+1]*j;
			if(k) dp[i][j][k]+=dp[i][j][k-1]*k;
			dp[i][j][k]/=sum;
		}
	}
  }
  cout<<fixed<<setprecision(13)<<dp[c3][c2][c1];
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}


Measured memory_bytes: 426368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  vector<map<string, int> > mp(10);
  int n; cin >> n;
  mp[0]["a"] = 1;

  REP(i, 1, n){
    for(pair<string, int> p : mp[i-1]){
      if(i == n){
        cout << p.first << endl;
      }
      else{
        string s = p.first;
        int x = p.second;
        rep(j, x+1){
          string t;
          t = s;
          t += 'a' + j;
          int y = x;
          if(j == x) y++;
          mp[i][t] = y;
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 17408
#include<iostream>
#include<sstream>
#include<algorithm>

using namespace std;

const string s = "01235789";

int main(){
  int n;
  while(cin >> n, n){
    stringstream ss;
    while(n){
      ss << s[n % 8];
      n /= 8;
    }
    string ans = ss.str();
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<int>> c(3,vector<int>(3));
  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++) cin >> c.at(i).at(j);
  }
  int x0; //x1, x2, y0, y1, y2;
  for(int i=0; i<=100; i++){
    x0=i;
    int y0=c.at(0).at(0)-x0;
    int y1=c.at(0).at(1)-x0;
    int y2=c.at(0).at(2)-x0;
    int x1=c.at(1).at(0)-y0;
    int x2=c.at(2).at(0)-y0;
    
    if(c.at(1).at(1) == x1+y1 && c.at(1).at(2) == x1+y2 && c.at(2).at(1) == x2+y1 && c.at(2).at(2) == x2+y2){
      cout << "Yes" << endl;
      return 0;
    }
  }
   cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll H, W; cin >> H >> W;
    vector<vector<char>> s(55, vector<char>(55));
    reps(i, H) {
        reps(j, W) cin >> s[i][j];
    }

    bool ans = true;
    reps(i, H) {
        reps(j, W) {
            if (s[i][j] == '#' && s[i][j - 1] != '#' && s[i - 1][j] != '#' && s[i][j + 1] != '#' && s[i + 1][j] != '#') ans = false;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3636
import           Control.Monad (replicateM)

main :: IO ()
main = do
    css <- replicateM 3 getInts
    putStrLn $ if null $ solve css
               then "No"
               else "Yes"

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve css = let h = head . head $ css
                cs = flip map [0..h]
                     $ \i -> make i (h - i) in
                filter (uncurry f) cs
    where
      make :: Int -> Int -> ([Int], [Int])
      make a b = let as' = map head css
                     bs' = head css in
                     (map (subtract b) as', map (subtract a) bs')
      f as bs = checkSign as bs && checkVal as bs
      checkSign as bs = all (>= 0) as && all (>= 0) bs
      checkVal as bs = map (\i -> map (+ i) bs) as == css


Measured memory_bytes: 508
#include<bits/stdc++.h>
#include<string.h>
#include<tuple>
#define all(c) c.begin(),c.end()
#define tr(x,n) for(int i=x;x<n?i<n:i>=n;x<n?i++:i--)
#define ll long long int
#define pb push_back
#define em emplace_back
#define mp make_pair
#define mt make_tuple
#define debug(c) cout<<c<<endl;
#define isro ios_base::sync_with_stdio(false);
#define find(v,x) find(all(v),x)!=v.end()


using namespace std;
typedef vector<ll>vi;
typedef vector<vi>vii;
typedef pair<ll,ll>pi;
typedef tuple<ll,ll,ll>ti;

int main(){
    isro;
    ll n;
    cin>>n;

    ll minn=1e9;
    
    vi v(n+1,0);
    for(ll i=1;i<=n;i++){
           cin>>v[i];
           v[i]+=v[i-1];
    } 

    ll right=0,left=0;
    for(ll i=1;i<=n;i++){
        right=v[n]-v[i];
        left=v[i];
        minn=min(minn,abs(right-left));
    }

    cout<<minn<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100
#define BLACK 0
#define WHITE 1
#define INF 100000000
#define NIL -1

void dijkstra(void);

int A[N][N],n;

int main()
{
  int u,k,v,c;

  scanf("%d",&n);

  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < n; j++)
    {
      A[i][j] = INF;
    }
  }

  for(int i = 0;i < n; i++)
  {
    scanf("%d%d",&u,&k);
    for(int j = 0; j < k; j++)
    {
      scanf("%d%d",&v,&c);
      A[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}

void dijkstra()
{

  int u,mincost;
  int d[N],pi[N],color[N];

  for(int u = 0; u < n; u++)
  {
    d[u] = INF;
    pi[u] = NIL;
    color[u] = WHITE;
  }

  d[0] = 0;

  while(1)
  {
    mincost = INF;
    for(int i = 0; i < n; i++)
    {
      if(color[i] != BLACK && d[i] < mincost)
      {
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == INF) break;

    color[u] = BLACK;

    for(int v = 0; v < n; v++)
    {
      if(color[v] != BLACK && A[u][v] + d[u] < d[v] && A[u][v] != -1){
        pi[v] = u;
        d[v] = A[u][v] +d[u];
      }
    }

  }
  for(u = 0; u < n; u++)
  {
    printf("%d %d\n",u,d[u]);
  }

}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
 
void solve() {
    int a, b;
    cin >> a >>b;
    for(int i=1; i<=1009; i++) {
        double da=i*0.08, db=i*0.1;
        ll aa=da, bb=db;
        if(aa==a && bb==b) {
            cout<<i<<"\n";
            return;
        }
    }
    cout<<"-1\n";
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <functional>
using namespace std;

string S; long long A[200009], N, VL[200009], VR[200009], mod = 1000000007;

int main() {
	cin >> S; N = S.size();
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A') A[i + 1] = 1;
		if (S[i] == 'B') A[i + 1] = 2;
		if (S[i] == 'C') A[i + 1] = 3;
		if (S[i] == '?') A[i + 1] = 4;
	}
	for (int i = 1; i <= N; i++) {
		if (A[i] == 1) VL[i] = 3;
		if (A[i] == 3) VR[i] = 3;
		if (A[i] == 4) { VL[i] = 1; VR[i] = 1; }
	}
	for (int i = 1; i <= N; i++) VL[i] += VL[i - 1];
	for (int i = N; i >= 0; i--) VR[i] += VR[i + 1];

	long long sum = 0;
	for (int i = 1; i <= N; i++) {
		long long R = VL[i - 1] * VR[i + 1];
		if (A[i] == 2) R *= 3;
		else if (A[i] == 4) R *= 1;
		else R *= 0;
		sum += R; sum %= mod;
	}
	sum *= 370370373; sum %= mod;
	for (int i = 1; i <= N; i++) {
		if (A[i] == 4) { sum *= 3; sum %= mod; }
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3840
count = [0 for i in range(26)]
while(1):
    try:
        str = raw_input().lower()
    except EOFError:
            break
    
    for i in range(len(str)):
        k = 97
        for j in range(26):
            if str[i] == chr(k):
                count[j] += 1
            k += 1

k = 97
for i in range(26):
    print "%s : %d" % (chr(k), count[i])
    k += 1

Measured memory_bytes: 6380
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <utility>
#include <bitset>
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define per(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,a,b) for (int i=(a);i<=(b);i++)
#define PER(i,a,b) for (int i=(b);i>=(a);i--)
#define de(x) cout<<">> "<<#x<<" = "<<x<<endl;
using namespace std;
typedef long long LL;

const int INF = 0x3f3f3f3f;
const int MAXN = 1000005; // 1e6;
string p;
int main()
{
	// freopen("in.txt","r",stdin);
	cin>>p;
	if (p[0]==p[1] && p[1]==p[2]) puts("Yes");
	else if (p[1]==p[2] && p[2]==p[3]) puts("Yes");
	else puts("No");

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
string S; int N, cnt;
 
int main() {
	cin >> N >> S;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3648
//DFS traversal
#include <bits/stdc++.h>
 
# define C continue;
# define R return
 
# define D double
# define I insert
# define ll long long
# define ld long double
 
# define ull unsigned long long
# define ui unsigned int
 
# define pb push_back
# define pf push_front
 
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue
 
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >
 
# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp
 
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
# define pipii pair<int, pii >
# define pcpii pair<char,pii>
 
# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >
 
# define vvpii vector < vector < pii > >
# define vpipii vector< pipii >
 
# define F first
# define S second
# define mp make_pair
 
# define unm unordered_map
# define unmii unm< int , int >
# define unmll unm< ll , ll >
# define unms unm<string,int>
# define unmci unm<char,int>
 
# define sortvia sort(a.begin(),a.end());
# define sortvib sort(b.begin(),b.end());
# define revsorta sort(a.begin(), a.end(), greater <int>());
# define revsortb sort(b.begin(), b.end(), greater <>());
# define loop(q,n) for(int i=q;i<n;i++)
# define loopj(r,n) for(int j=r;j<n;j++)
# define loopm(s,m) for(int k=s;k<m;k++)
# define test int t;cin >> t;while(t--)
# define nextline "\n"
# define tab "\t"
# define space " "
//YES
//NO
//cout
//true
//false
//yes
//no
 
const ll mod9=1e9+7;
const ll maxsize=2e9+1;
// const ll mod =998244353;
const ll mod2=1073741824;

 
using namespace std;

int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif*/
    int n,k;
    cin >> n>>k;
    vll dp(n+1);
    vi a(n+1);
    loop(1,n+1)cin>>a[i];
    dp[1]=0;
    int min=mod9;
    int temp=0;
    for(int i=2;i<=n;i++){
        int j=i-1;
        int cnt=0;
        min=mod9;
        while(j>0 && cnt<k){
            if((a[i]-a[j])<0)temp=dp[j]+(-1*(a[i]-a[j]));
            else temp=dp[j]+(a[i]-a[j]);
            if(temp<min)min=temp;
            j--;
            cnt++;
        }
        dp[i]=min;
    }
    cout<<dp[n];
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int f[22][1<<21];
int a[22][22];
int lowbit(int x)
{
    return x&-x;
}
int count1(int n)
{
    int ret=0;
    while(n)
    {
        ret++;
        n-=lowbit(n);
    }
    return ret;
}
int main()
{
    int i,j,k,l,n;
    scanf("%d",&n);
    f[0][0]=1;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            scanf("%d",&a[i][j]);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<(1<<n);j++)
        {
            if(count1(j)!=i)
                continue;
            for(l=0;l<n;l++)
            {
                if((j&(1<<l))==0||!a[i][n-l])
                    continue;
                f[i][j]=(f[i][j]+f[i-1][j^(1<<l)])%1000000007;
            }
        }
    }
    printf("%d",f[n][(1<<n)-1]);
    return 0;
}

Measured memory_bytes: 162048
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return a;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

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

int main(void){
	string s;
	int a[26];
	rep(i,26){
		a[i] = 0;
	}
	cin>>s;
	rep(i,4){
		a[s[i] - 'A']++;
	}
	bool ans = true;
	rep(i,26){
		if(a[i] != 0 && a[i] != 2){
			ans = false;
		}
	}
	cout<<(ans?"Yes":"No")<<endl;
	return 0;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  ll n, m;
  cin >> n >> m;
  map<ll, ll, greater<ll>> a;
  rep(i, n){
    ll tmp;
    cin >> tmp;
    a[tmp]++;
  }
  rep(i, m){
    int b, c;
    cin >> b >> c;
    a[c] += b;
  }

  ll ans = 0;
  for(auto itr : a){
    if(n < itr.second){
      ans += n * itr.first;
    }
    else{
      ans += itr.second * itr.first;
    }
    n -= itr.second;
    if(n <= 0){
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12800
n,k=gets.split.map(&:to_i)
l=k.times.map{gets.split.map(&:to_i)}
dp=Array.new(n+1,0)
dp[1]=1
sum=[0,1]
(2..n).each do |i|
  l.each do |a,b|
    suma=i-b-1>0?sum[i-b-1]:0
    sumb=i-a>0?sum[i-a]:0
    dp[i]+=(sumb-suma)%998244353
  end
  sum[i]=sum[i-1]+dp[i]
end
p dp[n]%998244353


Measured memory_bytes: 17632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

int n, d;
vector<vector<double>> X(10, vector<double>(10));

double dfs(int now, double res, int y, int z)
{
	if (now == d)return sqrt(res);

	return dfs(now + 1, res + pow(X[y][now] - X[z][now], 2), y, z);
}

int main()
{
	cin >> n >> d;
	rep(i, 0, n - 1)rep(j, 0, d - 1)cin >> X[i][j];
	int ans = 0;
	rep(i, 0, n - 2)rep(j, i + 1, n - 1)
	{
		double tmp = dfs(0, 0, i, j);
		if (floor(tmp) == ceil(tmp))++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let a = Scanf.scanf "%d " (fun a -> a) in
  let as_ = Array.init (n - 2) (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let a' = Scanf.scanf "%d " (fun a' -> a') in
  Array.fold_left (fun (minimum, x, y) a ->
    (min minimum (abs (x - y)), x + a, y - a))
    (max_int, a, Array.fold_left ( + ) a' as_) as_
  |> (fun (minimum, x, y) -> min minimum (abs (x - y)))
  |> Printf.printf "%d\n"

Measured memory_bytes: 5888
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let n:usize = read();
    let k:usize = read();
    let h:Vec<i64> = (0..n).map(|_| read()).collect();
    let mut dp:Vec<i64> = vec![1e9 as i64;n];
    dp[0] = 0;
    for i in 1..n{
        for j in 1..k + 1{
            if(i as i64 - j as i64 >= 0){
                dp[i] = min(dp[i], dp[i - j] + (h[i] - h[i - j]).abs());
            }
        }
    }
    println!("{}",dp[n - 1]);
}

Measured memory_bytes: 3640
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N = II()
    X = LI()
    min = 10**9


    for p in range(1,100):
        S = 0
        for i in range(N):
            S = S + (X[i]-p)**2
        
        if min > S:
            min = S


    print(min)



if __name__ == "__main__":
	main()

Measured memory_bytes: 38512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String
    }

    let result = match &*s {
        "A" => "T",
        "C" => "G",
        "G" => "C",
        "T" => "A",
        _ => unreachable!()
    };

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


Measured memory_bytes: 4352
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
N,Q = map(int,input().split())
tree = [[] for _ in range(N)]
cnt = [0]*N
for _ in range(N-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
for _ in range(Q):
    p,x = map(int,input().split())
    cnt[p-1] += x
sys.setrecursionlimit(10 ** 6)
def dfs(cur,parent):
    li = tree[cur]
    for chi in li:
        if chi == parent:
            continue
        cnt[chi] += cnt[cur]
        dfs(chi,cur)
dfs(0,-1)
print(" ".join(map(str,cnt)))


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    
    char c;
    int w_cnt = 0, c_cnt = 0;
    int first_index = 0;
    bool r = false;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'W') {
            if (!r) {
                first_index = i;
                r = true;
            }
            w_cnt++;
        }
    }
    for (int i = s.size()-1; i >= first_index; i--) {
        if (s.at(i) == 'R') {
            c_cnt++;
            while (i >= ++first_index) {
                if (s.at(first_index) == 'W') {
                    break;
                }
            }
        }
    }

    cout << min(c_cnt, w_cnt) << endl;

    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, Q, temp;
  cin >> N >> K >> Q;
  
  vector<int> A(N, K);
  vector<int> ai(N, 0);
  
  for (int i = 0; i < Q; i++) {
    cin >> temp;
    ai.at(temp - 1)++;
  }
  
  for (int i = 0; i < N; i++) {
    A.at(i) -= (Q - ai.at(i));
  }
  
  for (int i = 0; i < N; i++) {
    if(A.at(i) <= 0){
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}
 

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int T;
  T=1;
  while(T--)
  {
    int n;
    cin>>n;
    vector<int> h(n+1);
    for(int i=1;i<=n;i++)
    {
      cin>>h[i];
    }
    vector<int> dp(n+1,0);
    for(int i=2;i<=n;i++)
    {
      if((i-2)>=1)
      {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
      }
      else
      {
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
      }
    }
    cout<<dp[n]<<endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int Count = 0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if(500*i+100*j+50*k==X) Count++;
            }
        }
    } 
    cout << Count << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int n;

    while(scanf("%d",&n)!=EOF){
        if((n-1)%39<9){
            printf("3C0%d\n",(n-1)%39+1);
        } else {
            printf("3C%d\n",(n-1)%39+1);
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int k, n;
    cin >> n >> k;

    int a = 0;
    while(n > 0){
        n /= k;
        a++;
    }

    COUT(a);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();
        long cnt = 0;

        for (int i = 1; i <= N; i++) {
            if (i % 3 == 0 || i % 5 == 0) {
                continue;
            }
            cnt += i;
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 35664
#include<stdio.h>
#include<string.h>
#define C 201
void reset();
int a;
char n[C],cp1[C],cp2[C],cp[C];

main()
{
	int m,c1,c2,c3,h,len;
	while(1){
		scanf("%s",n);
		if(n[0]=='-')break;
		len=strlen(n);
		
		reset();
		
		scanf("%d",&m);
		for(c1=0;c1<m;c1++){
			scanf("%d",&h);
			for(c2=0;c2<h;c2++){
				cp1[c2]=n[c2];
			}
			for(c2=h,c3=0;c2<=len-1;c2++,c3++){
				cp2[c3]=n[c2];
			}
			strcat(cp2,cp1);
			strcpy(cp,cp2);
			strcpy(n,cp);
			reset();
		}
		puts(n);
	}
	return 0;
}

void reset(){
	for(a=0;a<C;a++){
		cp [a]='\0';
		cp1[a]='\0';
		cp2[a]='\0';
	}
}

Measured memory_bytes: 600
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N = s_in()
if ('1' in N) and ('9' in N) and ('7' in N) and ('4' in N):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    int64 a, b, k; cin >> a >> b >> k;

    if (a <= k) {
        k -= a;
        a = 0;
    } else {
        a -= k;
        k = 0;
    }

    if (b <= k) {
        b = 0;
    } else {
        b -= k;
    }

    cout << a << " " << b << endl;
}


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

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

//------------------------------------------------
int main(){
  int r;
  cin>>r;
  cout<<3*r*r<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, m, i, l, r, d;
vector< pair<int, int> > list[maxN];
ll x[maxN];
bool us[maxN];

void dfs(int node) {
    us[node] = true;

    for (auto to : list[node]) {
        if (us[to.first]) {
            if (x[to.first] != x[node] + to.second) {
                printf("No");
                exit(0);
            }
        } else {
            x[to.first] = x[node] + to.second;
            dfs(to.first);
        }
    }
}

int main()
{
 //   freopen("test.in","r",stdin);

    scanf("%d%d", &n, &m);
    for (i = 1; i <= m; i++) {
        scanf("%d%d%d", &l, &r, &d);
        list[l].pb(mp(r, d));
        list[r].pb(mp(l, -d));
    }

    for (i = 1; i <= n; i++)
        if (!us[i])
            dfs(i);

    printf("Yes");


    return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, X, sum = 0;
    cin >> N >> X;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        sum += A.at(i);
    }
    sort(A.begin(), A.end());
    cout << N + (X - sum) / A.at(0) << endl;
    return 0;
}

Measured memory_bytes: 3608