akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(void){
    int n=0;
    cin >> n;
    int a[n], b[n], c[n];
    REP(i,n) {
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
    }
    REP(i,n) {
        if(a[i]*a[i] == b[i]*b[i] + c[i]*c[i] || b[i]*b[i] == a[i]*a[i] + c[i]*c[i] || c[i]*c[i] == a[i]*a[i] + b[i]*b[i]) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 3012
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define ull long long
using namespace std;
 
const int nmax = 200100;
ull N;
ull a[nmax], b[nmax], c[nmax];
ull curmod = 0;
 
void read(){
    cin >> N;
    for(int i=0;i < N; ++i)cin >> a[i];
    for(int i=0;i < N; ++i)cin >> b[i];
}
ull bs(ull a, ull C, ull B, ull A)
{
    ull res = 0;
    int ind = lower_bound(c, c+N, C - a) - c;
    res = res + ind;
    ind = lower_bound(c, c+N, A - a) - c;
    res = res - ind ;
    ind = lower_bound(c, c+N, B - a) - c;
    res = res + N - ind;
    return res;
}
 
void solve(){
    ull ans = 0;
    curmod = 1;
    for(int i = 0; i <= 28; ++i)
    {
        vector <ull> bmod;
        for(int j=0; j < N; ++j)
            c[j] = b[j] % (curmod<<1);
        sort(c, c+N);
        ull cnt = 0;
        for(int j=0;j<N; ++j)
        {
            cnt += bs(a[j] % (curmod << 1), curmod, 3 * curmod , curmod << 1);
            //cout << cnt << ' ' << a[j] << endl;
        }
        ans += (cnt & 1) * (curmod);
        //if(curmod==4)break;
        curmod <<=1;
        //cout << "---\n";
    }
    cout << ans << endl;
}
 
int main(){
    read();
    solve();
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9+1)
#define MAXX (int)1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (ll)(1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
//printf("myco\n");//for debug
/*--------------------------------------------*/
int main(){
    ll w,h,x,y;cin>>w>>h>>x>>y;
    double s=w*h/2.0;
    bool ans=false;
    if(2*x==w&&2*y==h)ans=true;
    printf("%.10f %d",s,ans);
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let x = read_vec::<usize>();
    let mut ans = 0;
    for num in x {
        ans += min(num, k - num) * 2;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep0(i,n) for(i=0;i<(n);i++)
#define repn(i,m,n) for(int i=(m);i<=(n);i++)
#define all(n) n.begin(),n.end()
#define mp make_pair
#define PUTLINE cout<<__LINE__<<endl;

int dx[]={1,-1,0,0,1,1,-1,-1,0};
int dy[]={0,0,1,-1,1,-1,1,-1,0};

string l[100];

int main() {
	string str,res="a";
	int i;
	for(i=0;;++i){
		str=res.substr(res.size()-1,1);
		str+="not";
		str+='a'+i/10;
		str+='a'+i%10;
		str+='a';
		printf("?%s\n",str.c_str());
		fflush(stdout);
		char s[100];
		scanf("%s",s);
		res=s;
		if('a'!=res[0])break;
		rep(j,i)if(l[j]==res)goto end;
		l[i]=res;
	}
	end:;
	printf("!OUT\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define fi first
#define se second
using namespace std ;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

void solve()
{
	lli d,t,s;
	cin>>d>>t>>s;
	if(d<=t*s)cout<<"Yes";
	else cout<<"No";
}
 
int main()
{
/////////////////////////////////////
    fastio;
    
/////////////////////////////////////  
    lli t,m;
    //cin>>t;
    t=1;
    while(t--)
    {
    	solve();  
    	m++;  
    	cout<<endl;
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using ll = long long;


int main()
{
    int A, B;
    std::cin >> A >> B;

    if (A % 2 == 1 && B % 2 == 1)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;

    }
    return 0;
}

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

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    cout << (1000 - N % 1000) % 1000 << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  bool flag = false;
  for (int i=0;i<s.size();++i){
    for (int j=0;j<s.size();++j){
      if(i!=j && s.at(i)==s.at(j)) flag=true;
    }
  }
  if(flag) cout << "no" << endl;
  else cout << "yes" << endl;
         
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
s1,s2 = 0,0
a = []
for i in range(1,n):
    for j in range(0,n):
        if j < i:
            s1 += p[j]
        else:
            s2 += p[j]
    ans = abs(s1-s2)
    a.append(ans)
    s1,s2 = 0,0

print(min(a))

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
int main(){
    unsigned long long N;
    vector<int> ans;
 
    cin >> N;
 
    while(N){
        N -= 1;
        ans.push_back(N % 26ULL);
        N /= 26ULL;
    }
 
    for(int i = ans.size() - 1;i >= 0;i--){
        cout << (char)(ans[i] + 'a');
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int A, B;
    cin >> A >> B;
    cout << A*B - A - B + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
typedef long long s64;

const int ONE = 1000005;
const int MOD = 1e9 + 7;

#define next nxt

int get()
{
		int res = 1, Q = 1; char c;
		while( (c = getchar()) < 48 || c > 57)
			if(c == '-') Q = -1;
		if(Q) res = c - 48;
		while( (c = getchar()) >= 48 && c <= 57)
			res = res * 10 + c - 48;
		return res * Q;
}

int n;
int next[ONE], first[ONE], go[ONE], tot;

void Add(int u, int v)
{
		next[++tot] = first[u], first[u] = tot, go[tot] = v;
		next[++tot] = first[v], first[v] = tot, go[tot] = u;
}

int x, y;
int SG[ONE], val[ONE];

void Dfs(int u, int father)
{
		int pd = 0;
		for(int e = first[u]; e; e = next[e])
		{
			int v = go[e];
			if(v == father || val[v] >= val[u]) continue;
			Dfs(v, u);
			if(SG[v] == 0) pd = 1;
		}
		SG[u] = pd;
}

int main()
{
		//freopen(".in","r",stdin);
		//freopen(".out","w",stdout);
		n = get();
		for(int i = 1; i <= n; i++) val[i] = get();
		for(int i = 1; i < n; i++)
			x = get(), y = get(), Add(x, y);
		for(int i = 1; i <= n; i++)
		{
			memset(SG, 0, sizeof(SG));
			Dfs(i, 0);
			if(SG[i]) printf("%d ", i);
		}

}

Measured memory_bytes: 10496
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll max_h = 0;
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        ll h;
        cin >> h;
        if(max_h <= h){
            ans++;
        }
        max_h = max(max_h, h);
    }
    cout << ans << endl;
    return 0;
}


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

//a,b,cを受け取って1,2,3を返す
int func(char a){
	if(a=='a')
		return 1;
	if(a=='b')
		return 2;
	if(a=='c')
		return 3;
}

int main(){
	string sa,sb,sc;
	cin >> sa >> sb >> sc;
	int a=0;
	int b=0;
	int c=0;
	int now=1; //最初はaさんから
	int win = -1;
	while(1){
		if(now==1){
			now=func(sa[a]);
			a++;
		}
		if(now==2){
			now=func(sb[b]);
			b++;
		}
		if(now==3){
			now=func(sc[c]);
			c++;
		}
		if(a>sa.size()){
			win = 1;
			break;
		}
		if(b>sb.size()){
			win = 2;
			break;
		}
		if(c>sc.size()){
			win = 3;
			break;
		}
	}
	if(win==1) cout << 'A' << endl;
	if(win==2) cout << 'B' << endl;
	if(win==3) cout << 'C' << endl;
	return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(n);
    for (int i = 0; i < m; i++) {
        int k, j;
        cin >> k;
        while (k--) {
            cin >> j;
            s[j - 1] |= (1 << i);
        }
    }
    int z = 0;
    for (int i = 0; i < m; i++){
        int t;
        cin >> t;
        z += (t << i);
    }
 
    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        int y = 0;
        for (int j = 0; j < n; j++)
            if (i & (1 << j)) y ^= s[j];
            if (y == z) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 51
using namespace std;
typedef long long ll;
int n,m;
int x[N],y[N],z[N];
int X[N],Y[N],Z[N];
int s[N],t[N],u[N];
int S[N],T[N],U[N];
int xd[201],yd[201],zd[201];

void compress(int a[51],int A[51],int b[51],int B[51],int c[201]){
  vector <int> v;
  for(int i=0;i<n;i++)v.push_back(a[i]),v.push_back(A[i]);
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  for(int i=0;i<v.size();i++) c[i]=v[i];
  for(int i=0;i<n;i++){
    b[i]=lower_bound(v.begin(),v.end(),a[i])-v.begin();
    B[i]=lower_bound(v.begin(),v.end(),A[i])-v.begin();
  }
}

ll calc(){
  ll res=0;
  for(int i=0;i<101;i++) //x
    for(int j=0;j<101;j++)//y
      for(int k=0;k<101;k++){//z
	int cnt=0;
	for(int l=0;l<n;l++)cnt+=((s[l]<=i&&i<S[l])&&(t[l]<=j&&j<T[l])&&(u[l]<=k&&k<U[l]));
	if(cnt<m)continue;
	ll a=xd[i+1]-xd[i],b=yd[j+1]-yd[j],c=zd[k+1]-zd[k];
	res+=a*b*c;
      }
  return res;
}

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>z[i]>>X[i]>>Y[i]>>Z[i];
  compress(x,X,s,S,xd),compress(y,Y,t,T,yd),compress(z,Z,u,U,zd);
  cout << calc()<<endl;  
  return 0;
}

Measured memory_bytes: 1220
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>
#include <tuple>
#define INF 1000000000000
const long long MOD = 998244353;

using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N,A;
    cin >> N >> A;
    vector<llong> X(N+1, 0);
    llong total=0;
    for(int i=1; i<=N; i++){
        cin >> X[i];
        total += X[i];
    }
    vector<vector<vector<llong> > > dp(N+1, vector<vector<llong> >(total+1, vector<llong>(N+1, 0)));
    dp[0][0][0] = 1;

    for(int i=1; i<=N; i++){
        for(int j=0; j<=total; j++){
            for(int k=0; k<=N; k++){
                if(k-1<0){
                    dp[i][j][k] = dp[i-1][j][k];
                    continue;
                }
                if(j-X[i]<0){
                    dp[i][j][k] = dp[i-1][j][k];
                    continue;
                }
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-X[i]][k-1];
            }
        }
    }
    llong ans=0;

    for(int i=1; i<=total; i++){
        for(int k=1; k<=N; k++){
            if((double)i/(double)k==(double)A){
                ans = ans + dp[N][i][k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 58840
from collections import deque
def bfs(sy,sx,gy,gx):
    q=deque([[sy,sx]])
    visited[sy][sx]=0
    while q:
        y,x=q.popleft()
        if [y,x]==[gy,gx]:
            return visited[y][x]
        for i,j in ([1,0],[-1,0],[0,1],[0,-1]):
            ny,nx=y+i,x+j
            if ny<0 or ny>h-1 or nx<0 or nx>w-1:continue
            if path[ny][nx]=="#" and visited[ny][nx]==-1:
                visited[ny][nx]=visited[y][x]+1
                q.append([ny,nx])
h,w=map(int,input().split())
path=[input() for i in range(h)]
visited=[[-1]*w for _ in range(h)]
c=0
for p in path:
    for pp in p:
        if pp=='#':
            c+=1

sy,sx=0,0
gy,gx=h-1,w-1
bfs(sy,sx,gy,gx)
if visited[gy][gx]==h+w-2 and c==h+w-1:
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000007;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

void factoring(int n, int (&f)[1001]);

int factors[1001];

int main(int argc, char *argv[]) {
  // INFILE();
  ll n;
  cin >> n;

  REP(i, 1, n + 1) factoring(i, factors);

  ll count = 1;
  for (const auto &v : factors) {
    count *= v + 1;
    count %= LL_MOD;
  }
  cout << count << "\n";
  return 0;
}

void factoring(int n, int (&f)[1001]) {
  int sq = floor(sqrt(n)) + 1;
  REP(i, 2, sq) {
    while (n % i == 0) {
      f[i]++;
      n /= i;
    }
  }

  if (n != 1) {
    f[n]++;
  }
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val s = readLine()!!
    val t = readLine()!!
    if(canMatch(s,t)) {
        println("Yes")
    } else {
        println("No")
    }
}

fun canMatch(s:String, t:String):Boolean {
    if(s == t) {
        return true
    }
    for(i in (1 .. s.length)) {
        if(s.substring(i) + s.substring(0 until i) == t) {
            return true
        }
    }
    return false
}

Measured memory_bytes: 35680
#include <stdio.h>


int main(){
    double a,b;
    scanf("%lf %lf",&a,&b);
    for(int i = 1;i < 1001;i++){
        double a1 = (double)(i * 0.08);
        double b1 = (double)(i * 0.1);
        if(a1 - a < 1 && a1 - a >= 0 && b1 - b < 1 && b1 - b >= 0){
            printf("%d",i);
            return 0;
        }
    }
    printf("-1");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>

using namespace std;

long N, h, n, w;

int main_even(){
  h = N/2;
  n = N;
  w = N;
}

int main_odd(){
  n = N;
  int end = 0;
  h = 0;
  for( h = 1; h <= 3500; h++ ){
    for( n = 1; n <= 3500; n++ ){
      long tmp = 4*h*n - N*h - N*n;
      if( tmp == 0 ){ continue; }
      w = N*h*n / tmp;
      if( w > 0 && tmp*w == N*h*n ){ return 0; }
    }
  }
  return -1;
}

int main(){
  cin >> N;
  if( N % 2 == 0 ){
    main_even();
  }else{
    main_odd();
  }
  cout << h << " " << n << " " << w << " "<< endl;
  return 0;
}

Measured memory_bytes: 256
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 x: String = read();
    if x.parse::<u32>().unwrap() < 100 {
        println!("0");
        return ();
    }
    let n = x.len();
    let a: u32 = x[..n-2].parse().unwrap();
    let mut b: u32 = x[n-2..].parse().unwrap();
    //println!("{}, {}", a,b);

    let mut count:u32 = 0;
    let mut k:u32 = 5;
    while b>0 {
        count += b/k;
        b -= b/k * k;
        k -= 1;
        //println!("count:{}, b:{}, k:{}", count, b, k);
    }

    println!("{}", if a >= count {"1"} else {"0"});

}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int stw[200000][3];
int stw_s[200000][3];
int index_stw[200000];
int par[100000];
int x[100000], y[100000];

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

int unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry){
        return 0;
    }
    par[rx] = ry;
    return 1;
}

int compare_int_x(const void *a, const void *b)
{
    return x[*(int*)a] - x[*(int*)(b)];
}
int compare_int_y(const void *a, const void *b)
{
    return y[*(int*)a] - y[*(int*)(b)];
}
int compare_int_stw(const void *a, const void *b)
{
    return stw[*(int*)a][2] - stw[*(int*)(b)][2];
}

int same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry){
        return 1;
    }
    return 0;
}
int index_x[100000];
int index_y[100000];
int main(void){
    int n;
    int i, j, k;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d%d", &x[i], &y[i]);
        index_x[i] = i;
        index_y[i] = i;
    }

    qsort(index_x, n, sizeof(int), compare_int_x);
    qsort(index_y, n, sizeof(int), compare_int_y);




    int cnt = 0;
    for(i = 1; i < n; i++){
        stw[cnt][0] = index_x[i];
        stw[cnt][1] = index_x[i-1];
        stw[cnt][2] = abs(x[index_x[i]] - x[index_x[i-1]]);
        cnt++;
    }
    for(i = 1; i < n; i++){
        stw[cnt][0] = index_y[i];
        stw[cnt][1] = index_y[i-1];
        stw[cnt][2] = abs(y[index_y[i]] - y[index_y[i-1]]);
        cnt++;
    }

    for(i = 0; i < cnt; i++){
        index_stw[i] = i;
    }

    qsort(index_stw, cnt, sizeof(int), compare_int_stw);

    for(i = 0; i < cnt; i++){
        stw_s[i][0] = stw[index_stw[i]][0];
        stw_s[i][1] = stw[index_stw[i]][1];
        stw_s[i][2] = stw[index_stw[i]][2];
        
    }


    //クラスカル法
    for(i = 0; i < n; i++){
        par[i] = i;
    }

    long long int ans = 0;
    for(i = 0; i < cnt; i++){
        //stw_s[i][]の辺を取り出す
        if(same(stw_s[i][0], stw_s[i][1]) == 0){
            unite(stw_s[i][0], stw_s[i][1]);
            ans += stw_s[i][2];
            
        }
    }

    printf("%lld\n", ans);
    return 0;






}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> s(n);
    REP(i, n){
        cin >> s.at(i);
    }
    s.push_back(-1);
    ll q;
    cin >> q;
    ll ans = 0;
    REP(i, q){
        ll t;
        cin >> t;
        s.back() = t;
        ll j;
        for(j = 0; t != s.at(j); ++j){}
        if(j < n){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3220
open Batteries

let n = read_int ()

let a_list =
    read_line ()
    |> String.split_on_char ' '
    |> List.map int_of_string

let rec even lst =
    match lst with
    | first :: rest -> if first mod 2 = 0 then first :: even(rest) else even (rest)
    | _ -> [];;


let rec is_mod_3_5 num =
    match num with 
    | num when num mod 5 = 0 -> true
    | num when num mod 3 = 0 -> true
    | _ -> false


let rec ans lst = 
    match lst with 
     [] -> "APPROVED"
    | first :: rest -> if is_mod_3_5(first) then ans(rest) else "DENIED"


let () = even a_list
    |> ans
    |> print_endline


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>

//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
const long long inf = 1e18;
 
using namespace std;

int root_n;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void always_ignore_function_name()
{
    int n;
    cin>>n;
    vi v(n+1);
    int cnt=0;
    repu(i,1,n)
    {
        cin>>v[i];
        if(i%2 && v[i]%2)
            cnt++;
    }
    cout<<cnt<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        always_ignore_function_name();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool ok = a != c;
    cout << ok << endl;
}


Measured memory_bytes: 256
import numpy as np

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

N,L = LI()
ringo = np.array(list(range(1,N+1))) + L - 1

taste_all = sum(ringo)

min_index = 0
min_abs = abs(ringo[0])

for i in range(1,N):
  if min_abs > abs(ringo[i]):
    min_index = i
    min_abs = abs(ringo[i])

print(taste_all - ringo[min_index])

Measured memory_bytes: 12452
package main

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

const Inf = 1 << 62

func main() {
	N := ReadInt()
	sum := 0
	rem := Inf
	for i := 0; i < N; i++ {
		v := ReadInt()
		sum += v
		if v%10 > 0 && v < rem {
			rem = v
		}
	}
	if sum%10 > 0 {
		fmt.Println(sum)
	} else if rem < Inf {
		fmt.Println(sum - rem)
	} else {
		fmt.Println(0)
	}
}

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 }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
# include <bits/stdc++.h>
# define int long long
# define endl "\n"
using namespace std;

void solve() {

	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}
signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif

	// int t;
	// cin >> t;
	// while (t--)
	solve();

	return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
//using namespace std;

#define N 100
#define MYSCAN scanf

int main(void){

	int i;
	int input, max = 0;
	int bucket[N + 1];

	// テゥツ?催・ツ按療」ツ?ョテ・ツ按敕ヲツ慊淌・ツ個?
	for (int i = 0; i < N + 1; i++){
		bucket[i] = 0;
	}

	// テ・ツ?・テ・ツ環崚」ツ?ォテ」ツ?療」ツ?淌」ツ?古」ツ?」テ」ツ?ヲテゥツ??ヲツャツ。テゥツ?催・ツ按療」ツつ津」ツつォテ」ツつヲテ」ツδウテ」ツδ暗」ツつ「テ」ツδε」ツδ?
	while (MYSCAN("%d", &input) != EOF){
		bucket[input]++;
	}

	// テ」ツつづ」ツ?」テ」ツ?ィテ」ツつづ・ツ、ツ堙」ツ?湘・ツ?コテ」ツ?淌・ツ崢榲ヲツ閉ーテ」ツつ津ヲツアツづ」ツつ?」ツつ?
	for (int i = 0; i < N + 1; i++){
		if (max < bucket[i]){
			max = bucket[i];
		}
	}

	// テ」ツ?敕」ツ?ョテ・ツ崢榲ヲツ閉ーテ」ツ??」ツ?妥・ツ?・テ・ツ環崚」ツ?陛」ツつ古」ツ?淌ヲツ閉ーテ・ツ?、テ」ツつ津・ツ?コテ・ツ環?
	for (int i = 0; i < N + 1; i++){
		if (max == bucket[i]){
			printf("%d\n", i);
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;
	map<char, int> mp;
	cin >> mp['A'] >> mp['B'] >> mp['C'];

	vector<string> vc(n);
	for(auto& el: vc) cin >> el;

	for(int i = 0; i < n; i++) {
		char& p = vc[i][0], &q = vc[i][1];
		if(mp[p] > mp[q] || (mp[p] == mp[q] && (i + 1 == n || vc[i + 1].find(q) != string::npos)))
			swap(p, q);
		mp[p]++, mp[q]--;
		if(mp[q] < 0) {
			cout << "No\n"; return 0;
		}
	}

	cout << "Yes\n";
	for(auto el: vc) cout << el[0] << '\n';
}



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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; string S;
    cin >> N >> S >> K;
    rep(i, S.length()){
        if(S[i] != S[K-1]) S[i] = '*';
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3580
import sys
input = sys.stdin.readline

from collections import defaultdict

N = int(input())

res = defaultdict(int)

def g(x, y, z):
    return x**2 + y**2 + z**2 + x*y + x*z + y*z

for x in range(1, 10**2+1):
    y = 1
    while g(x, y, 1) <= N:
        z = 1
        while g(x, y, z) <= N:
            res[g(x, y, z)] += 1
            z += 1
        y += 1

for i in range(1, N+1):
    print(res[i])


Measured memory_bytes: 70552
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>v(N - 1);
	for (auto& i : v)cin >> i;
	cin >> M;
	int sum = accumulate(v.begin(), v.end(), 0);
	sum -= v[0] + v[1];
	deque<int>Q;
	for (int i = 0; i <= sum; i++)Q.push_back(i);
	for (int i = 2; i < N - 1; i++) {
		vector<int>p;
		for (int j = 1; j <= v[i]; j++) {
			p.push_back(Q[j]);
		}
		for (int j = 1; j <= v[i]; j++)Q.pop_back();
		for (auto j : p)Q.push_front(j);
	}
	for (int i = 0; i < M; i++) {
		cin >> K;
		if (K > sum) {
			cout << K - sum + v[0] - v[1] << endl;
		}
		else {
			cout << Q[K] + v[0] - v[1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 11356
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,a,b;
    cin>>n>>d;
    a=(2*d)+1;
    b=n/a;
    if(n%a==0)
        cout<<b<<endl;
    else
        cout<<b+1<<endl;
   // main();
}


Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstdio> 
using namespace std;
int main(){
   int a,b;
   cin>>a>>b;
   if(a<=8&&b<=8)
   cout<<"Yay!";
   else
   cout<<":(";
   system("pause");
   return 0;
} 

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

class Edge
{
	public:
	int to;
	int cost;
	Edge(int t,int c)
	{
		to=t;
		cost=c;
	}
};

vector<Edge> g[1000];
int color[1000];

//cで塗る
//戻り値が0未満なら構成不可
int saiki(int now,int c)
{
	int ret=0;
	if(color[now]==-1)
	{
		color[now]=c;
		for(int i=0;i<g[now].size();i++)
		{
			Edge e=g[now][i];
			if(color[e.to]==c)
				ret--;
			else if(color[e.to]==-1)
				ret+=saiki(e.to,(c+1)&1);
		}
	}
	return ret;
}

int count(int num,int n)
{
	int ret=0;
	for(int i=0;i<n;i++)
	{
		if(color[i]==num)
			ret++;
	}
	return ret;
}

int main()
{
	while(1)
	{
		int n,m;
		cin>>n>>m;
		if(n==0)
			break;
		for(int i=0;i<1000;i++)
			g[i].clear();
		fill(color,color+1000,-1);
		for(int i=0;i<m;i++)
		{
			int x,y;
			cin>>x>>y;
			x--;y--;
			g[x].push_back(Edge(y,1));
			g[y].push_back(Edge(x,1));
		}
		int ans=saiki(0,0);
		int v[2]={9999,9999};
		if(ans<0)
			cout<<0<<endl;
		else{
			int tmp=count(0,n);
			//cerr<<tmp<<" "<<n-tmp<<endl;
			if(tmp>0 && (tmp%2==0))
				v[0]=tmp/2;
			tmp=n-tmp;
			if(tmp>0 && (tmp%2==0) && v[0]!=tmp/2)
				v[1]=tmp/2;
			sort(v,v+2);
			if(v[0]==9999)
				cout<<0<<endl;
			else if(v[1]==9999){
				cout<<1<<endl;
				cout<<v[0]<<endl;
			}else{
				cout<<2<<endl;
				cout<<v[0]<<endl;
				cout<<v[1]<<endl;
			}
		}
	}
}


Measured memory_bytes: 3340
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

ll X[100005];

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	REP(i, N)
	{
		cin >> X[i];
	}

	ll ans = 0;
	REP(i, N - 1)
	{
		ans += std::min(B, (X[i + 1] - X[i])*A);
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

  int n, q;
  string s;
  cin >> n >> q >> s;

  vector<pair<int, int>> quest(q);
  rep (i, 0, q)
    cin >> quest[i].first >> quest[i].second;

  int ac[n] = {};
  int count = 0;
  rep (i, 0, n - 1) {
    ac[i] = count;
    if (s[i] == 'A' && s[i+1] == 'C') {
      count++;
    }
  }
  ac[n - 1] = count;

  rep (i, 0, q) {
    cout << ac[quest[i].second - 1] - ac[quest[i].first - 1] << endl;
  }

	return 0;
}

Measured memory_bytes: 2256
#include <bits/stdc++.h>
using namespace std;
 
string S;
long long L, ans;

void calc(int n, int m) {
	ans += stoi(S.substr(n, 1)) * pow(10, m) * pow(2, n);
	if (n != 0) {
		// "+"を使う場合
		calc(n - 1, 0);
		// "+"を使わない場合
		calc(n - 1, m + 1);
	}
}

int main() {
	cin >> S;
	L = S.size();

	ans = 0;
	calc(L - 1, 0);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	string s;
	cin >> s;
	puts(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
N = int(input())
hlist = list(map(int,input().split()))
dp = [ 0 for i in range(N)]
for j in range(N):
    if j == 0:
        dp[j] = 0
    elif j == 1:
        dp[j] = abs(hlist[1]-hlist[0])
    else:
        dp[j] = min((dp[j-1]+abs(hlist[j]-hlist[j-1])),(dp[j-2]+abs(hlist[j]-hlist[j-2])))
print(dp[N-1])

Measured memory_bytes: 13928
//GODLEON'S CODE
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ff                first
#define ss                second
#define int        	  long long
#define ll                long long
#define ddouble           long double  
#define pb 		  push_back
#define mp 		  make_pair
#define pii               pair<int , int>
#define vi                vector<int>
#define mii               map<int,int>
#define gsort             greater<int>
#define pqb               priority_queue<int>
#define pqs               priority_queue<int , vi , greater<int>>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define mod1              mod
#define mod2              1000000009
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr = new type[n] ;
#define test(t)           int t ; cin >> t ; while(t--)
#define ifor(a,b)         for(int i = a ; i < b ; i++)
#define dfor(a,b)         for(int i = b-1 ; i >= a ; i--)
#define fio               ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
mt19937                   rng(chrono::steady_clock::now().time_since_epoch().count());


// check odd even : n & 1
// check power of 2 : n & n - 1 == 0
//flip xor
//set or
//unset and
//for -ve no.s mod ( a % mod + mod ) % mod ; 

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


Measured memory_bytes: 4844
#include <stdio.h>

int main(void)
{
    int para,time;
    int i;
    int div = 3600;
    scanf("%d",&para);

    for (i = 1; i <= 3; i++)
    {
        time = para / div;
        para %= div;
        div /= 60;
        printf("%d",time);

        if (i != 3)
            putchar(':');
    	else
    	putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2100
s = input()
n = len(s)

# if (n//2) % 2 == 0:
#     print("No")
#     exit()

t = 0
for i in range(n//2):
    if s[i] != s[-i-1]:
        print("No")
        exit()

for j in range((n//2) // 2):
    if s[j] != s[-j-(n//2)-2]:
        print("No")
        exit()

for j in range((n//2) // 2):
    if s[j+(n//2)+1] != s[-j-1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
const int INF = 1e9;
const ll LLINF = 1e16;

bool canCut(vector<double> a, double max_size,ll k) {
    ll sum = 0;
    for (int i = 0; i < a.size(); i++)
    {
        if(a[i] > max_size){
            sum += ceil(a[i] / max_size)-1;
        }
    }

    if(sum <= k){
        return true;
    }
    else{
        return false;
    }
}

int main(void)
{
    ll n, k;
    cin >> n >> k;
    vector<double> a(n);
    ll max_a = 0;
    REP(i, n) { 
        cin >> a[i];
        if(max_a <= a[i]){
            max_a = a[i];
        }
    }
    double right = max_a;
    double left = 0.5;
    double middle;
    while(true) {
        middle = (right + left) / 2;
        if((ll)ceil(right) == (ll)ceil(left)){
            break;
        }
        if(canCut(a,middle,k)){
            right = middle;
        }
        else{
            left = middle;
        }
    }
    cout << (ll)ceil(middle) << endl;
    return 0;
}

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

int main(){
  int a,b,c;

  cin >> a >> b >> c;

  bool flag = false;
  for(int i = a;i <= b*a;i+=a){
    if(i % b == c){
      cout << "YES" << endl;
      flag = true;
      break;
    }
  }

  if(!flag){
    cout << "NO" << endl;
  }

  return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl


int main(){
    ll n,m,t;
    cin >> n >> m;
    map<ll,ll,greater<ll>>map1;
    REP(i,n){
        cin >> t;
        map1[t]++;
    }
    ll b,c;
    REP(i,m){
        cin >> b >> c;
        map1[c]+=b;
    }
    ll ans = 0;
    ll count=n;
    for(const auto &x:map1){
        ll y = x.first;
        ll z = x.second;
        if(count>=z){
            ans+=y*z;
            count-=z;
        }
        else{
            ans += y*count;
            break;
        }
    }
    COUT(ans);
    return 0;
}

Measured memory_bytes: 12800
n = int(input())
taro_point, hanako_point = 0, 0
for _ in range(n):
    cards = input().split()
    if cards[0] > cards[1]:
        taro_point += 3
    elif cards[1] > cards[0]:
        hanako_point += 3
    else:
        taro_point += 1
        hanako_point += 1
print(taro_point, hanako_point)


Measured memory_bytes: 5604
#include<iostream>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
  int H, W;
  while (cin >> H >> W) {
    if (H == 0 && W == 0) return 0;
    REP(h, H) {
      REP(w, W) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

map<P,bool> mp;
vector<P> v;

int main(){
    LL H,W;
    int N;
    cin >> H >> W >> N;
    for(int i=0;i<N;i++){
        LL a,b;
        cin >> a >> b;
        mp[make_pair(a,b)]=true;
        v.push_back(make_pair(a,b));
    }
    LL ans[10];
    memset(ans,0,sizeof(ans));
    for(auto p:v){
        for(int i=-1;i<=1;i++){
            for(int j=-1;j<=1;j++){
                int count=0;
                bool h=false;
                for(int s=-1;s<=1;s++){
                    for(int t=-1;t<=1;t++){
                        if(1<=p.first+i+s&&p.first+i+s<=H&&1<=p.second+j+t&&p.second+j+t<=W){
                            if(mp[make_pair(p.first+i+s,p.second+j+t)]) count++;
                        }
                        else h=true;
                    }
                }
                if(h) continue;
                ans[count]++;
            }
        }
    }
    LL sum=0;
    for(int i=1;i<10;i++){
        sum+=ans[i]/i;
    }
    cout << (H-2)*(W-2)-sum << endl;
    for(int i=1;i<10;i++){
        cout << ans[i]/i << endl;
    }
    return 0;
}

Measured memory_bytes: 158064
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int X,Y,Z;
  cin>>X>>Y>>Z;
  X-=Z;
  int ans=X/(Y+Z);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main() {
    while(cin >> n) {
        if(n == 0) { break; }
        for (i=1; i<=n; i++) {
            cin >> pA >> pB;
            if (pA >pB) {
                tA += pA + pB;
            } else {
                if (pA < pB) {
                    tB += pA + pB;
                } else {
                    tA += pA;
                    tB += pB;
                }
            }
         }
         cout << tA << " " << tB << endl;
         tA = 0; tB = 0;
    }
    return 0;
}

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

int solve(int n, int k, vector<int>h){
  vector<int>dp(n,INF);
  dp[0]=0;
  for (int i=0; i<n; i++){
    for (int j=i+1; j<=i+k; j++){
      if (j<n){
        dp[j] = min(
          dp[j],
          dp[i] + abs( h[i] - h[j] )
        );
      }
    }
  }
  return dp[n-1];
}

int main(){
  int n,k; cin>>n>>k;
  vector<int>h(n); rep(i,n) cin>>h[i];
  cout << solve(n,k,h);
}

Measured memory_bytes: 4576
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<string>
#include<vector>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)
static const int MAX = 10;
static const int di[4] = {0, -1, 0, 1};
static const int dj[4] = {1, 0, -1, 0};
static const string D = "RULD";

int H, W, sum;
char G[MAX][MAX];

bool hasLeaf(int pi, int pj, int r, int &ni, int &nj){
  do{
      pi += di[r];
      pj += dj[r];
      if ( pi < 0 || pj < 0 || pi >= H ||  pj >= W ) break;
      if ( G[pi][pj] == 'o' ) {
	  ni = pi;
	  nj = pj;
	  return true;
      }
  } while(1);
  return false;
}

bool dfs(int pi, int pj, int dir, vector<int> path, int rem){
  if ( rem == 1 ){
      rep(i, path.size()) cout << D[path[i]];    
      cout << endl;
      return true;
  }

  rep(r, 4){
    if ( (r+2)%4 == dir ) continue;
    int ni, nj;
    if ( hasLeaf(pi, pj, r, ni, nj) ){
	vector<int> np = path;
	G[pi][pj] = '.';
	np.push_back(r);
	if (dfs(ni, nj, r, np, rem-1)) return true;
	G[pi][pj] = 'o';
    }
  }
  return false;
}

int getDir(char c){
    rep(i, D.size()) if ( c == D[i] ) return i;
}

main(){
  int si, sj, dir;
  cin >> H >> W;
  sum = 0;
  rep(i, H) rep(j, W) {
    cin >> G[i][j];
    if ( G[i][j] != 'o' && G[i][j] != '.' ){
      dir = getDir(G[i][j]);
      si = i; sj = j;
      G[i][j] = 'o';
    }
    if ( G[i][j] == 'o' ) sum++;
  }
  vector<int> P;
  dfs(si, sj, dir, P, sum);
}

Measured memory_bytes: 0