akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N, M;
int main() {
	cin >> N >> M;
	N = N * (N - 1);
	N /= 2;
	M = M * (M - 1);
	M /= 2;
	cout << N + M;
	return 0;
}

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

int main(void)
{
	set<int> st;
	int n;
	cin >> n;
	int m;
	cin >> m;

	map<int,int> mp;

	for(int i = 0;i < n;i++)
	{
		int k;
		cin >> k;

		for(int j = 0;j < k;j++)
		{
			int val;
			cin >> val;
			mp[val]++;
		}
	}

	int cnt = 0;
	for(auto it = mp.begin();it != mp.end();++it)
	{
		//cout << it->second << endl;
		if(it->second == n)
			cnt++;
	}

	cout << cnt;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.141592653589793
#define nl cout<<"\n"
 
int main() 
{	fastio;
	int testcases = 1;
	//cin>>testcases;
	while (testcases--) {
		ll a; 
		int int_part;
		char decimal;
		int frac_part;
		cin>>a>>int_part>>decimal>>frac_part;
		//cout<<a<<" "<<int_part<<" "<<decimal<<" "<<frac_part;
		ll ans = a * int_part + (a * frac_part)/100;
		cout<<ans;
		nl;
	}
    return 0; 
}

Measured memory_bytes: 3608
#include<stdio.h>
int gcd (int x, int y);
int main( )
{
  int x,y,kai;
  scanf("%d%d",&x,&y);
kai = gcd(x,y);
 printf("%d\n",kai);
  return 0;
}
  int gcd(int x, int y)
  {
  int a,r;
  if( x < y){
    a = x;
    x = y;
    y = a;
  }
    while( y > 0){
      r = x % y;
      x = y;
      y = r;
    }
    return x;
  }

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,t,x;
    cin >> n >> x >> t;
    cout << ((n/x)+(n%x > 0))*t;
    return 0;
}

Measured memory_bytes: 3620
n, m, X, Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
for i in range(X + 1, Y + 2, 1):
    if max(x) < i and min(y) >= i:
        break;
if i == Y + 1:
    print("War")
else:
    print("No War")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;
ll e[N] , root = -1;
vector<int> adj[N];

void dfs(int v , int p = 0){
    ll sum = 0 , maxi = -1;
    for(auto u : adj[v]){
        if(u == p)continue;
        dfs(u , v);
        sum += e[u];
        maxi = max(maxi , (ll)e[u]);
    }
    if(adj[v].size() == 1)return ;
    if(sum < e[v] || sum > 2 * e[v]){cout << "NO\n"; exit(0);}
    maxi = max(maxi , 2 * e[v] - sum);
    if((2 * e[v]) - maxi < maxi){cout << "NO\n"; exit(0);}
    e[v] = 2 * e[v] - sum;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    for(int i=1;i<=n;i++)cin >> e[i];
    for(int i=0;i<n-1;i++){
        int u , v; cin >> u >> v;
        adj[u].pb(v); adj[v].pb(u);
        if(adj[u].size() > 1)root = u;
        if(adj[v].size() > 1)root = v;
    }
    if(n == 2){
        if(e[1] == e[2])cout << "YES\n";
        else cout << "NO\n";
        return 0;
    }//cout << " root " << root << endl;
    dfs(root);
    if(e[root] == 0)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 14336
abcd = list(input())
for i in range(2**3):
    tmp = abcd[:]
    bag = []
    for j in range(2, -1, -1):
        if (i >> j) & 1:
            tmp.insert(j+1, "+")
        else:
            tmp.insert(j+1, "-")
    if (eval(''.join(tmp)) == 7):
        print(''.join(tmp), "=7", sep="")
        exit()

Measured memory_bytes: 3060
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int A, B, M; scanf("%d%d%d", &A, &B, &M);
    vector<ll> a(A), b(B);
    for(int i=0; i<A; i++) scanf("%lld", &a[i]);
    for(int i=0; i<B; i++) scanf("%lld", &b[i]);

    vector<int> x(M), y(M);
    vector<ll> c(M);
    for(int i=0; i<M; i++) {
        scanf("%d%d%lld", &x[i], &y[i], &c[i]);
        x[i]--; y[i]--;
    }

    ll ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    for(int i=0; i<M; i++) {
        chmin(ans, a[ x[i] ] + b[ y[i] ] - c[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef long long ll;

int main()
{
    IO;
    int n, r;
    cin >> n >> r;
    if (n >= 10)
        cout << r << endl;
    else
        cout << r + 100 * (10 - n) << endl;
}

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

int main()
{
    double a,b,c,d,e,f;
    double x,y;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){

    y = (((f)*(a)-(d)*(c))/((e)*(a)-(d)*(b)));
    x = (((c)-(b)*(y))/(a));
    printf("%0.3lf %0.3lf\n",x,y);
    }
return 0;
}

Measured memory_bytes: 652
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c,d,i;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    for(;;)
    {
        c=c-b;
        if(c<=0)
        {
           i=0;
           break;
        }
        a=a-d;
        if(a<=0)
        {
            i=1;
            break;
        }
    }
    if(i==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

int cnt[200010];
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N];
    rep(i,N){
        cin >> A[i];
        cnt[A[i]]++;
    }
    int ans=0;
    rep(i,200010){
        if(cnt[i]>=2){
            ans+=(cnt[i]*(cnt[i]-1))/2;
        }
    }
    rep(i,N){
        if(cnt[A[i]]>=2){
            cout << ans-(cnt[A[i]]*(cnt[A[i]]-1))/2+((cnt[A[i]]-1)*(cnt[A[i]]-2))/2 << endl;
        }
        else cout << ans << endl;
    }

}

Measured memory_bytes: 4736
A=list("keyence")
f=-1;p=0
S=list(map(str,input()))
if S[0:7]==A or S[len(S)-7:len(S)]==A:
  f=1
else:
  if S[0]!=A[0]:
    f=0
  else:    
    for i in range(len(S)):
      if S[i]==A[i]:
        p=p+1
      else:
        if A[0:p]+S[len(S)-(len(A)-p):len(S)]==A:
          f=1
          break
        else:
          f=0
          break
print("YES" if f==1 else "NO")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <array>

using namespace std;

int main() {
  array<int,1501> x, y;
  array<int,1500001> t;
  int n, m;
  while (cin >> n >> m && n+m != 0) {
    y[0] = x[0] = 0;
    for (int i=1; i <= n; i++) {
      cin >> y[i];
      y[i] += y[i-1];
    }
    for (int i=1; i <= m; i++) {
      cin >> x[i];
      x[i] += x[i-1];
    }
    fill(t.begin(), t.begin()+m*1000, 0);
    for (int i=0; i < n; i++) {
      for (int j=i+1; j <= n; j++)
        t[y[j]-y[i]]++;
    }
    int cnt = 0;
    for (int i=0; i < m; i++) {
      for (int j=i+1; j <= m; j++)
        cnt += t[x[j]-x[i]];
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 8864
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    int s;
    int a,b;
    cin >> s >> a >> b;
    if(s == 1) {
        cout << "Hello World";
    } else {
        cout <<a+b;
    }
}

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

using namespace std;

#define N 1
int q, l, r;

// Prime and Primitive Root
struct PRIME {
    static const int np = 100000;
    bool p[100001];
    vector<int> primes;
    PRIME() {
        memset(p, false, sizeof(p));
        p[1] = true;
        for (int i = 2; i <= np; i++)
            if (!p[i]) {
                primes.push_back(i);
                for (int j = i; j <= np; j += i)
                    p[j] = true;
                p[i] = false;
            }
    }
    bool is_prime(int n) {
        for (int i = 0; i < (int)primes.size(); i++)
            if (n == primes[i])
                return true;
            else if (n % primes[i] == 0)
                return false;
        return true;
    }
};

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    PRIME prime;
    int pre[100001];
    pre[0] = 0;
    for (int i = 1; i <= 100000; i++)
        if (i % 2 == 1 && !prime.p[i] && !prime.p[(i + 1) / 2])
            pre[i] = pre[i - 1] + 1;
        else
            pre[i] = pre[i - 1];
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> l >> r;
        cout << pre[r] - pre[l - 1] << endl;
    }
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(max(a,c)<=min(b,d))
        cout<<min(b,d)-max(a,c);
    else
        cout<<0;
    return 0;
}


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

int main() {
string s; cin >> s;
ll n=s.size();
ll cnt=0,d=n-1;
  for(ll i=n-1;i>=0;i--){
    if(s[i]=='B'){
      cnt+=d-i;
      d--;
    }
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll h,w,k;
    cin>>h>>w>>k;
    ve <string> arr(h);
    rep (i,0,h)
    {
        cin>>arr[i];
    }
    ll ans[h][w];
    ve <ll> row(h,0);
    rep (i,0,h)
    {
        rep (j,0,w)
        {
            if (arr[i][j]=='#')
            {
                row[i]++;
            }
            ans[i][j]=0;
        }
    }
    ll x1=1;
    ll cnt=0;
    rep (i,0,h)
    {
        if (row[i]!=0)
        rep (j,0,w)
        {
            if (arr[i][j]=='#')
            {
                cnt++;
            }
            if (cnt<2)
            {
                ans[i][j]=x1;
            }
            else if (cnt==2)
            {
                x1++;
                ans[i][j]=x1;
                cnt=1;
            }
            if (j==w-1)
            {
                cnt=0;
                x1++;
            }
        }
    }
    ll ind=0;
    rep (i,0,h)
    {
        if (row[i]!=0)
        {
            ind=i;
            bb;
        }
    }
    rep (i,ind+1,h)
    {
        if (row[i]==0)
        {
            rep (j,0,w)
            {
                ans[i][j]=ans[i-1][j];
            }
        }
    }
    rev (i,ind,0)
    {
        if (row[i]==0)
        {
            rep (j,0,w)
            {
                ans[i][j]=ans[i+1][j];
            }
        }
    }
    rep (i,0,h)
    {
        rep (j,0,w)
        {
            cout<<ans[i][j]<<" ";
        }
        cout<<"\n";
    }
}


Measured memory_bytes: 1536
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
)

func main() {
	T := ReadInt()
	for t := 0; t < T; t++ {
		n, a, b, c, d := ReadInt(), ReadInt(), ReadInt(), ReadInt(), ReadInt()
		fmt.Println(solve(n, a, b, c, d))
	}
}

const Inf = math.MaxInt64

func solve(n, a, b, c, d int) int {
	q := Heap{}
	now := State{n, 0}
	q.push(now)
	visited := make(map[int]bool)

	ans := Inf
	for len(q) > 0 {
		now = q.pop()
		if now.number <= (Inf-now.cost)/d {
			// Infを超えない範囲だったら number * d を加算したやつを暫定最小値として計算する
			ans = Min(ans, now.cost+now.number*d)
		}
		if now.cost >= ans {
			return ans
		}
		if visited[now.number] {
			continue
		}
		visited[now.number] = true
		{ // c *5
			l := now.number / 5 * 5
			r := l + 5
			q.push(State{
				number: l / 5,
				cost:   now.cost + c + (now.number-l)*d,
			})
			q.push(State{
				number: r / 5,
				cost:   now.cost + c + (r-now.number)*d,
			})
		}
		{ // b *3
			l := now.number / 3 * 3
			r := l + 3
			q.push(State{
				number: l / 3,
				cost:   now.cost + b + (now.number-l)*d,
			})
			q.push(State{
				number: r / 3,
				cost:   now.cost + b + (r-now.number)*d,
			})
		}
		{ // a *2
			l := now.number / 2 * 2
			r := l + 2
			q.push(State{
				number: l / 2,
				cost:   now.cost + a + (now.number-l)*d,
			})
			q.push(State{
				number: r / 2,
				cost:   now.cost + a + (r-now.number)*d,
			})
		}
	}
	return ans
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

type State struct {
	number int
	cost   int
}

type HeapElement = State
type Heap []HeapElement

func (h Heap) Less(i, j int) bool    { return h[i].cost < h[j].cost }
func (h Heap) Len() int              { return len(h) }
func (h Heap) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *Heap) Push(x interface{})   { *h = append(*h, x.(HeapElement)) }
func (h *Heap) Pop() (x interface{}) { *h, x = (*h)[:len(*h)-1], (*h)[len(*h)-1]; return }
func (h *Heap) push(v HeapElement)   { heap.Push(h, v) }
func (h *Heap) pop() HeapElement     { return heap.Pop(h).(HeapElement) }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 6816
import sys
nm=input().rstrip().split(" ")
n=int(nm[0])
m=int(nm[1])
answers=[[] for i in range(n)]
for i in range(m):
    line=input().rstrip().split(" ")
    if line[1]=="AC":
        answers[int(line[0])-1].append(1)
    if line[1]=="WA":
        answers[int(line[0])-1].append(0)
#print(answers)
ac=0
i=0
was=[]
while i<n:
    sums=0
    j=0
    while j<len(answers[i]):
        sums=sums+answers[i][j]
        if sums>0:
            ac+=1
            was.append(j)
            break
        j=j+1
    i=i+1
print(ac,end=" ")
#print(was)
wacount=0
for j in was:
    wacount=wacount+j
print(wacount)  

Measured memory_bytes: 15700
#include<stdio.h>
#include<math.h>

struct point {double x,y;};

void koch(int n,struct point p1,struct point p2){
  struct point s,u,t;
  double radian;

  radian = 60.0 * (M_PI / 180.0);
  
  if(n == 0) return;

  s.x = (2.0 * p1.x + 1.0 * p2.x)/3;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3;
  u.x = (t.x - s.x) * cos(radian) - (t.y - s.y) * sin(radian) + s.x;
  u.y = (t.x - s.x) * sin(radian) + (t.y - s.y) * cos(radian) + s.y;
  
  koch(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,p2);
}

int main(){
  int n;
  struct point a,z;
  
  scanf("%d",&n);
  
  a.x = 0.0;
  a.y = 0.0;
  z.x = 100.0;
  z.y = 0.0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,z);
  printf("%.8f %.8f\n",z.x,z.y);

  return 0;
}



Measured memory_bytes: 2048
from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]

A = Counter(a)

total = sum([A[i] * (A[i] - 1) //2 for i in A.keys()])

for i in range(n):
    tmp = a[i]
    print(total - A[tmp] +1)

Measured memory_bytes: 26780
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(m)]

AB.sort(key=lambda x:(x[1],x[0]))
end=AB[0][1]
ans=1
for a,b in AB[1:]:
  if end<=a:
    end=b
    ans+=1
print(ans)


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

int main(){
  string s;
  cin >> s;
  if (s[0] == s[1] && s[0] == s[2] && s[0] == s[3]){
    puts("No");
  } else if (s[0] == s[1] && s[2] == s[3]) {    
    puts("Yes");
  } else if (s[0] == s[2] && s[1] == s[3]){
    puts("Yes");
  } else if(s[0] == s[3] && s[1] == s[2]) {
    puts("Yes");
  } else
    puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    ll s;
    cin >> s;
    ll x1 =1e9;
    ll y1 =1;
    ll x2 =(x1-s%x1)%x1;
    ll y2 =(s + x2) / x1; 
    cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 <<endl;  
}

Measured memory_bytes: 888
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

vlli v;
LLI f[100001];
LLI ans[100001];
int main() {
    int i;
    int N,Q;
    LLI q;
    scanf("%d %d",&N,&Q);
    v.pb(N);
    for (i = 0; i < Q; i++) {
        scanf("%lld",&q);
        while (!v.empty() && (q <= v.back())) v.pop_back();
        v.pb(q);
    }

    f[v.size()-1] = 1;
    for (i = v.size()-1; i >= 1; i--) {
        LLI x = v[i];
        f[i-1] += f[i]*(x/v[i-1]),x %= v[i-1];
        while (x > v[0]) {
            int p = upper_bound(v.begin(),v.end(),x)-v.begin()-1;
            f[p] += f[i]*(x/v[p]),x %= v[p];
        }
        if (x > 0) ans[x] += f[i];
    }
    ans[v[0]] += f[0];
    for (i = N-1; i >= 1; i--) ans[i] += ans[i+1];
    for (i = 1; i <= N; i++) printf("%lld\n",ans[i]);

    return 0;
}



Measured memory_bytes: 4212
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
struct node{
	int to,next,v;
}a[100007];
int head[100007],cnt,dis[100007],vis[100007],f[100007];
queue<int>q;
char s[1007];
void add(int x,int y,int v){
	a[++cnt].next=head[x];
	a[cnt].to=y;
	a[cnt].v=v;
	head[x]=cnt;
}
void dfs(int x,int c){
	vis[x]=c;
	for(int i=head[x];i;i=a[i].next){
		int v=a[i].to;
		if(vis[v]==-1)
            dfs(v,c^1);
		else if(vis[v]!=(c^1)){
            cout<<-1;
            exit(0);
		}
	}
}
void spfa(int s){
	q.push(s);
	memset(dis,1,sizeof(dis));
	f[s]=1,dis[s]=0;
	while(!q.empty()){
		int now=q.front();
		q.pop();
		f[now]=0;
		for(int i=head[now];i;i=a[i].next){
			int v=a[i].to;
			if(dis[v]>dis[now]+a[i].v){
				dis[v]=dis[now]+a[i].v;
				if(!f[v]){
                    q.push(v);
                    f[v]=1;
				}
			}
		}
	}
}
int main(){
	int n=0,mx=0,x;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>s+1;
		for(int j=1;j<=n;++j){
			x=s[j]-'0';
			if(x==1)
                add(i,j,1);
		}
		vis[i]=-1;
	}
	dfs(1,0);
	for(int j=1;j<=n;++j){
		spfa(j);
		for(int i=1;i<=n;++i)
			mx=max(mx,dis[i]);
	}
	cout<<mx+1;
}


Measured memory_bytes: 896
program test
integer(8) :: nn,k,aa(100),aaa(100),a(100),b(100),c(10000),i,a_min,atai,sig,last(100)=0,j,count,temp


read(*,*) nn,k
read(*,*) (aa(i),i=1,nn)

a(1:nn) = aa(1:nn)

do i = 1,nn
	b(i) = i
enddo

call heapsort2(nn,a(1:nn),b(1:nn))


count = 1



do i = 1,k
	aaa(1:nn) = aa(1:nn)
	if(last(max(1,i-1)) > 0 )then
		aaa(last(max(1,i-1))) = 999
	endif
	
	minimum = 999999
	do j =1,nn
		if(aaa(j) <= minimum) then
			last(i) = j
			minimum = aaa(j)
		endif
	enddo

	do j=1,nn
		if(i==1) then
			if((j .ne. last(i))) then
				c(count) = j
				aa(j) = aa(j) -1
				count = count + 1
			endif
		else
			if((j .ne. last(i-1)) .and. (j .ne. last(i))) then
				c(count) = j
				aa(j) = aa(j) -1
				count = count + 1
			endif
		endif
	enddo

	do j=1,nn
		if(j == last(i)) then
			c(count) = j
			aa(j) = aa(j) -1
			count = count + 1
		endif
	enddo

enddo

	do j=1,nn
		if(j .ne. last(k)) then
			c(count) = j
			aa(j) = aa(j) -1
			count = count + 1
		endif
	enddo


if( sum(a(1:nn))<nn*(k+1)-k .or. a(1)<1+k/2 ) then
	write(*,*) -1
else
	write(*,*) count-1
	write(*,*) c(1:count-1)
endif









contains
 
subroutine heapsort2(n,y1,y2)
 
	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8),intent(inout) :: y2(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1,t2
	
	l = n/2+1
	k = n
 
	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				t2 = y2(l)
				
		 else
				t1 = y1(k)
				t2 = y2(k)
				y1(k) = y1(1)
				y2(k) = y2(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 y2(1) = t2
					 exit
				endif
		 endif
 
		 i = l
		 j = l+l
 
		 do while(j <= k)
				if(j < k) then
					 if(y1(j) < y1(j+1)) j = j+1
				endif
				
				if (t1 < y1(j)) then
					 y1(i) = y1(j)
					 y2(i) = y2(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
		 y2(i) = t2
	
	enddo
	return
 
end subroutine heapsort2

end program

Measured memory_bytes: 384
#include <iostream>
using namespace std;
void ABC80(void);
void ABC81(void);
void ABC83(void);
void ABC85(void);
void ABC86(void);
void ABC87(void);
void ABC88(void);
void ABC89(void);

int main(void){
    ABC85();
}

void ABC85(void){
    string a;
    cin>>a;
    a[3]='8';
    cout<<a<<endl;
}

Measured memory_bytes: 256
import sys

N, K = map(int, input().split())
A = list(map(int, input().split()))
maxA = max(A)
if K > maxA:
	print("IMPOSSIBLE")
	sys.exit()

if K in A:
	print("POSSIBLE")
	sys.exit()

def GCD(a,b):
	if b == 0:
		return a
	return GCD(b,a%b)

for i in range(1,N):
	if i == 1:
		temp = GCD(A[0],A[1])
	else:
		temp = GCD(temp, A[i])

if K % temp == 0:
	ans = "POSSIBLE"
else:
	ans = "IMPOSSIBLE"
print(ans)


Measured memory_bytes: 14096
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   string x,y,z;
  cin>>x>>y>>z;
    if(x.at(x.size()-1) == y.at(0) && y.at(y.size()-1) == z.at(0)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
  
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int n{},ans{};
int vis[100005];
vector<int>v(n);
int solve(int size,int i)
{
	if(i==2)return ans;
	if(!vis[i] && i<size){
		ans++;
		vis[i]=1;
		int a=solve(size,v[i]);
		return a;
	}
	else return -1;
}


int main()
{
	IO;
	cin>>n;
	v.resize(n+1);
	For(i,1,n+1)cin>>v[i];
	cout<<solve(n+1,1)<<'\n';

	//system("pause");
	return 0;
}

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

int main(){
    int n; cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++){
        cin>>d.at(i);
        }
    sort(d.begin(),d.end());
    cout<<d.at(n-1)-d.at(0)<<endl;
    }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, s = 0, a, b;
	cin >> n;
	while (n--) {
		cin >> a >> b;
		s += b - a + 1;
	}
	cout << s << "\n";

	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using pdd = pair<double,double>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  fix20;
  int n;
  cin >> n;
  vector<pdd> pos(n);
  vector<int> num(n);
  double k = 1.0;
  rep(i,n){
    cin >> pos.at(i).first >> pos.at(i).second;
    num.at(i) = i;
    k *= i+1.0;
  }
  double sum = 0;
  do{
    rep(i,n-1){
      int now = num.at(i);
      int next = num.at(i+1);
      double x = pos.at(now).first;
      double y = pos.at(now).second;
      double nx = pos.at(next).first;
      double ny = pos.at(next).second;
      double dis = sqrt((nx-x)*(nx-x)+(ny-y)*(ny-y));
      sum += dis;
    }
  }while(next_permutation(num.begin(),num.end()));
  cout << sum / k << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib> //func147bでインクルード
#include <vector>  //func146b
using namespace std;
 
 
void func143b()
{
    int n,s;
    
    int healamount = 0;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
         v.emplace_back(s);
    }
    for (int i = 0; i < n-1; ++i) {
        for (int j = i +1 ; j < n; ++j) {
            healamount += v[i] * v[j];
        }
    }
    cout << healamount << endl;
}
int main()
{
  func143b();
  return 0;
}

Measured memory_bytes: 256
from itertools import combinations
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
if N==1:
    print(1)
else:
    C = {}
    for z in combinations(X,2):
        x1,x2 = z
        a = x1[0]-x2[0]
        b = x1[1]-x2[1]
        if a>=0 and b>=0:
            if (a,b) not in C:
                C[(a,b)] = 0
            C[(a,b)] += 1
        elif a>0 and b<0:
            if (a,b) not in C:
                C[(a,b)] = 0
            C[(a,b)] += 1
        elif a==0 and b<0:
            if (a,-b) not in C:
                C[(a,-b)] = 0
            C[(a,-b)] += 1
        elif a<0 and b>0:
            if (-a,-b) not in C:
                C[(-a,-b)] = 0
            C[(-a,-b)] += 1
        elif a<0 and b==0:
            if (-a,b) not in C:
                C[(-a,b)] = 0
            C[(-a,b)] += 1
        elif a<0 and b<0:
            if (-a,-b) not in C:
                C[(-a,-b)] = 0
            C[(-a,-b)] += 1
    C = sorted(list(C.items()),key=lambda x:x[1],reverse=True)
    k = C[0][1]
    print(N-k)

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

using namespace std;

int main(){
	int n;
	cin>>n;
	int h[n], cost[n];
	cost[0] = 0;
	for(int i = 0; i<n;i++){
		cin>>h[i];
	}
	cost[1] = abs(h[1] - h[0]);
	for(int i = 2; i<n ;i++){
		cost[i] = min(cost[i-1]+abs(h[i] - h[i-1]), cost[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<cost[n-1]<<endl;
}

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

using namespace std;
using ll = long long int;
#define INF 20000000000000000;

int main(void){
  int x, a, b;
  cin >> x >> a >> b;
  
  if(a >= b) cout << "delicious" << endl;
  else if(b - a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

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

    int n, m;
    cin >> n >> m;

    int ans = 0;
    if (n > 0) { ans += n * (n - 1) / 2; }
    if (m > 0) { ans += m * (m - 1) / 2; }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	string str;
	char left[50]="qwertasdfgzxcvb";
	char right[50]="yuiophjklnm";

	while(cin >> str && str!="#")
	{
		int flag=0;
		int keep=0;
		int count=0;

		rep(i,str.length())
		{
			if(i==0)
			{
				rep(j,15)if(left[j]==str[0])flag=1;
				rep(j,11)if(right[j]==str[0])flag=0;
				i++;
			}

			keep=flag;

			rep(j,15)if(left[j]==str[i])flag=1;
			if(keep!=flag)count++;
			keep=flag;

			rep(j,11)if(right[j]==str[i])flag=0;
			if(keep!=flag)count++;
		}
		cout << count <<endl;		
	}
}

Measured memory_bytes: 1184
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char buf[100005];
int bufLen;

int main() {
  scanf("%s", buf);
  bufLen = strlen(buf);
  for(int i = 0; i+1 < bufLen; i++) {
    if(buf[i] == buf[i+1]) {
      printf("%d %d\n", i+1, i+2);
      return 0;
    }
  }
  for(int i = 0; i + 2 < bufLen; i++) {
    if(buf[i] == buf[i+2]) {
      printf("%d %d\n", i+1, i+3);
      return 0;
    }
  }
  printf("-1 -1\n");
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
// #define Kongxiangzhouye
#define sd(x) scanf("%d",&x)
#define ss(x) scanf("%s",x)
#define sc(x) scanf("%c",&x)
#define sf(x) scanf("%f",&x)
#define slf(x) scanf("%lf",&x)
#define slld(x) scanf("%lld",&x)
#define me(x,b) memset(x,b,sizeof(x))
#define pd(d) printf("%d\n",d);
#define plld(d) printf("%lld\n",d)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;
const int INF = 0x3f3f3f3f;

int b[30];
int n;
//int t=0;
int solve(int i,int m){
//	t++;
	if(m<0)
		return 0;
	if(m==0)
		return 1;
	if(i>=n)
		return 0;
	int res=solve(i+1,m)||solve(i+1,m-b[i]);
	return res;
}
int main()
{
	#ifdef Kongxiangzhouye
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	int m;
	while(cin>>n){
//		t=0;
		for(int i=0;i<n;i++){
			cin>>b[i];
		}
		cin>>m;
		int te;
		for(int i=0;i<m;i++){
			cin>>te;
			if(solve(0,te))
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}
	//	cout<<t<<endl;
	}
	
	
	return 0;
}



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

using namespace std;

/**/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/**/

#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;



int main () {

	ios_base::sync_with_stdio(false);  cin.tie(NULL); 

	int n; cin >> n;
	std::vector<int> v (n);
	for (int &x : v) cin >> x;

	std::vector<int> r (n, 0);
	for (int i = n - 2; i >= 0; --i) {
		if (v[i] >= v[i + 1])
			r[i] = 1 + r[i + 1];
	}

	int ans = *max_element (r.begin(), r.end());
	cout << ans << '\n';

	return 0;
}



Measured memory_bytes: 1024
def matprod(A,B):
    C = []
    for i in range(len(A)):
        tmpList = []
        for k in range(len(B[0])):
            tmpVal = 0
            for j in range(len(A[0])):
                tmpVal += A[i][j] * B[j][k]
            tmpList.append(tmpVal)
        C.append(tmpList)
    return C


n,m,l = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

B = []
for i in range(m):
    B.append(list(map(int, input().split())))


for cr in matprod(A,B):
    print(' '.join(map(str, cr)))

Measured memory_bytes: 8872
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

//`入力
int n;

//DP TABLE
long long dp[100100];

int main(){
	cin >> n ;
long long h[n];
	
	rep(i,n){
		cin>>h[i+1];
	}
	h[0]=h[1];

	//初期化　最小化問題なのでINFに初期化
	rep(i,100100)dp[i]=INF;
	dp[0] = 0 ;
	dp[1] = 0 ;
	//DP roop

		for(int i = 2 ; i <= n ; i++){
			for(int j = 1 ; j <= 2 ; j++){
					chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
			}
		}
					cout<<dp[n]<<endl;
}



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

typedef unsigned long long int ulli;

const ulli Undefined = static_cast<ulli>(-1);
const ulli MOD = 1e+9 + 7;

int main()
{
  unsigned N;
  std::cin >>N;
  
  std::vector<ulli> T(N), A(N);
  for(unsigned n=0; n<N; ++n) std::cin >> T[n];
  for(unsigned n=0; n<N; ++n) std::cin >> A[n];
  
  if(T[N-1] != A[0])
  {
    std::cout << 0 << std::endl;
    return 0;
  }
  
  if(N == 1)
  {
    std::cout << 1 << std::endl;
    return 0;
  }
  
  std::vector<ulli> h(N, Undefined);
  h[0] = T[0];
  h[N-1] = A[N-1];
  
  for(unsigned n=1; n<N; ++n)
  {
    if(T[n] > T[n-1])
    {
      h[n] = T[n];
      if(T[n] > A[n])
      {
        std::cout << 0 << std::endl;
        return 0;
      }
    }
  }
  
  for(long n=N-2; n>=0; --n)
  {
    if(A[n] > A[n+1])
    {
      h[n] = A[n];
      if(A[n] > T[n])
      {
        std::cout << 0 << std::endl;
        return 0;
      }
    }
  }
  
  /*
  for(unsigned n=0; n<N; ++n)
  {
    if(h[n] != Undefined)
      std::cerr << h[n];
    else
      std::cerr << "?";
    if(n + 1 < N) std::cerr << ", ";
  }
  std::cerr << std::endl;
  */
  
  ulli S = 1;
  for(unsigned n=0; n<N; ++n)
  {
    if(h[n] == Undefined)
    {
      ulli x = std::min(T[n], A[n]);
      //std::cerr << "min(" << T[n] << ", " << A[n] << ") = " << x << std::endl;
      S = (S * x) % MOD;
    }
  }
  std::cout << S << std::endl;
  
  return 0;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    Dice d = new Dice();
	    int n = kbd.nextInt();
	    if(n!=0) solve(d, n);
	}
    }

    static void solve(Dice d, int n){
	int sum = 1;
	while(n>0){
	    String s = kbd.next();
	    d.roll(s);	
	    sum += d.getTop();
	    n--;
	}
	System.out.println(sum);
    }
}

class Dice{
    int[] d;
    public Dice(){
	d = new int[3];
	d[0]=1; d[1]=2;d[2]=3;
	// top, south, east
    }
    public void roll(String s){
	int a = d[0];
	int b = d[1];
	int c = d[2];
	if(s.equals("North")){
	    d[0] = b;
	    d[1] = 7-a;
	}
	else if(s.equals("East")){
	    d[0] = 7-c;
	    d[2] = a;
	}
	else if(s.equals("West")){
	    d[0] = c;
	    d[2] = 7-a;
	}
	else if(s.equals("South")){
	    d[0] = 7-b;
	    d[1] = a;
	}
	else if(s.equals("Right")){
	    d[1] = c;
	    d[2] = 7-b;
	}
	else if(s.equals("Left")){
	    d[1] = 7-c;
	    d[2] = b;
	}
	//System.out.println(d[0]+" "+d[1]+" "+d[2]);
    }
    public int getTop(){
	return d[0];
    }
}	

Measured memory_bytes: 25176
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
#define fi first
#define se second
#define ll long long
#define _for(i,j,k) for(int i=j;i<k;i++)
#define endl  '\n'
#define inf 0x3f3f3f3f
const int mod=1e9+7;
const int MAX=1e+7;
ll a[MAX],ans[MAX];
int main()
{
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	for(int i=1;i<10;i++)
 	a[i]=i;
 	ll l=1,r=10,t=0,cnt=0;
 	while(l<r)
 	{
 		t=a[l++];
 		if(t>1e11)break;
 		ans[cnt++]=t;
		int b=t%10;
		a[r++]=t*10+b;
		if(b!=0)a[r++]=t*10ll+b-1;
		if(b!=9)a[r++]=t*10ll+b+1; 	
	}
 	ll k;
 	cin>>k;
 	sort(ans,ans+cnt);
 	cout<<ans[k-1];
 	
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll n;
  cin >> n;
  ll ans=0;
  vll l(n);
  rep(i,0,n) cin >> l[i];
  sort(all(l));
  
  rep(i,0,n){
   rep(j,i+1,n){ 
    rep(k,j+1,n){
     ll x=l[i],y=l[j],z=l[k];
      if(x==y||y==z||z==x) continue;
     if(abs(x-y)<z&&z<x+y){
      if(abs(x-z)<y&&y<x+z){
       if(abs(y-z)<x&&x<y+z) ans++; 
      }
     }
    }
   }
  }
  
  
 cout << ans << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3656
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int mod=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=2005,mx=N*N+N;

ll fac[mx+1],inv[mx+1];
int n,k,f[N][N];

il void inc(int &x,const int &y){
	x+=y;
	if(x>=mod) x-=mod;
}

il int c(int n,int k){
	return fac[n]*inv[n-k]%mod*inv[k]%mod;
}

int main(){
	inv[1]=1;
	rep(i,2,mx) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	fac[0]=inv[0]=1;
	rep(i,1,mx){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=inv[i-1]*inv[i]%mod;
	}
	scanf("%d%d",&n,&k);
	if(k==1) return puts("1"),0;
	--k;
	f[0][0]=1;
	rep(i,1,n){
		f[i][0]=(ll)f[i-1][0]*c(i*k-1,k-1)%mod;
		rep(j,1,i){
			f[i][j]=f[i][j-1];
			inc(f[i][j],(ll)f[i-1][j]*c(i*k+j-1,k-1)%mod);
		}
	} 
	printf("%d\n",fac[n]*f[n][n]%mod); 
	return 0;
}


Measured memory_bytes: 77952
import collections

N = int(input())
k = input().split(" ")
m = {}

#print(k)

c = collections.Counter(k)
#print(c)

for i in c:
    m[i] = c[i]*(c[i]-1)//2        
total = sum(m.values())
#print(m)
#print(total)


for i in k:
    print(total - (c[i]-1))



Measured memory_bytes: 34460
#include <iostream>
#include <string>
#include <memory.h>

using namespace std;

int ans[11][331] = { 0 };


int solve(int n, int sum, int *pUsed) {
	int i, count = 0;

	if (sum < 0) {
		return 0;
	}
	if (ans[n][sum] != 0) {
		return ans[n][sum];
	}

	if (n == 1) {
		if (sum < 10 && pUsed[sum] == 0) {
			ans[n][sum] = count;
			return 1;
		}
		return 0;
	}

	for (i = 0; i < 10; i++) {
		if (!pUsed[i]) {
			pUsed[i] = 1;
			count += solve(n - 1, sum - n*i, pUsed);
			pUsed[i] = 0;
		}
	}

	return count;
}

int main(void) {
	int n, s, count;
	int used[10] = { 0 };

	while (cin >> n >> s) {
		count = 0;
		if (s < 331) {
			count = solve(n, s, used);
			memset(used, 0, 10);
		}
		cout << count << endl;
	}

	return 0;
}




Measured memory_bytes: 3100