akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (long long i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n, x;
    string ans;
    cin >> n;

    x = n % 10;
    if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9) {
        ans = "hon";    
    } else if (x == 0 || x == 1 || x == 6 || x == 8) {
        ans = "pon";
    } else {
        ans = "bon";
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    ll L;
    string N;
    cin >> L >> N;
    if(L%2==1) {
        cout<<"No"<<endl;
        return 0;
    }
    int l=L/2;
    for(int i=0;i<l;i++){
        if(N[i]!=N[i+l]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
    int num[6];
    int h_idx;      //Table facing (head) num's index.
    int n_idx, e_idx, s_idx, w_idx;
} Dice;

int init_dice(Dice *d);
int set_num(Dice *d);

void move_dice(Dice *d, char order);

void print(const Dice *d);
void print_exp(const Dice *d);

int init_dice(Dice *d)
{
    int i;

    for(i=0;i<6;i++)
        d->num[i] = 0;

    d->h_idx = 0;
    d->n_idx = 4;
    d->e_idx = 2;
    d->s_idx = 5 - d->n_idx;
    d->w_idx = 5 - d->e_idx;

    return 1;
}

int set_num(Dice *d)
{
    scanf("%d %d %d %d %d %d", &(d->num[0]), &(d->num[1]), &(d->num[2]), &(d->num[3]), &(d->num[4]), &(d->num[5]));
    scanf("%*c");

    return 1;
}

void move_dice(Dice *d, char order)
{
    int h = d->h_idx;
    switch (order) {
        case 'N':   d->n_idx = h;
                    d->h_idx = d->s_idx;
                    d->s_idx = 5 - h;
                    break;

        case 'E':   d->e_idx = h;
                    d->h_idx = d->w_idx;
                    d->w_idx = 5 - h;
                    break;

        case 'S':   d->s_idx = h;
                    d->h_idx = d->n_idx;
                    d->n_idx = 5 - h;
                    break;

        case 'W':   d->w_idx = h;
                    d->h_idx = d->e_idx;
                    d->e_idx = 5 - h;
                    break;

        default :   break;
    }
}

void print(const Dice *d)
{
    int i;

    for(i=0;i<6;i++) {
        printf("%d ", d->num[i]);
    }
    putchar('\n');

    print_exp(d);

    return;
}

void print_exp(const Dice *d)
{
    printf("  |%d|\n", d->n_idx+1);
    printf("|%d|%d|%d|%d|\n", d->w_idx+1, d->h_idx+1, d->e_idx+1, 6 - d->h_idx);
    printf("  |%d|\n", d->s_idx+1);

    return;
}

int main(void)
{
    char order;
    Dice d;

    init_dice(&d);
    set_num(&d);

    while(1) {
        scanf("%c", &order);
        if(order == '\n') break;

        move_dice(&d, order);
    }

    printf("%d\n", d.num[d.h_idx]);

    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
const long long INF = 99999999;
ll dp[100005][4];
int main(){
 
    string s;
    cin>>s;
    ll temp=1;
    int n=s.size();
    for(int i=1;i<=n;i++)
        if(s[i-1]=='A'){
            dp[i][0]=(dp[i-1][0]+temp)%mod;
            dp[i][1]=dp[i-1][1];
            dp[i][2]=dp[i-1][2];
        }else if(s[i-1]=='B'){
            dp[i][1]=(dp[i-1][0]+dp[i-1][1])%mod;
            dp[i][0]=dp[i-1][0];
            dp[i][2]=dp[i-1][2];
 
        }else if(s[i-1]=='C'){
            dp[i][2]=(dp[i-1][1]+dp[i-1][2])%mod;
            dp[i][1]=dp[i-1][1];
            dp[i][0]=dp[i-1][0];
 
        }else{
            dp[i][0]=(3LL*dp[i-1][0]+temp)%mod;
            dp[i][1]=(dp[i-1][0]+3LL*dp[i-1][1])%mod;
            dp[i][2]=(dp[i-1][1]+3LL*dp[i-1][2])%mod;
            temp=temp*3LL;
            temp%=mod;
 
        }
        cout<<dp[n][2]<<endl;
    }

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

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

    int n, k, i;
    cin >> n >> k;
    int a[n + 5];
    for (i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (i = k - 1; i < n - 1; ++i) {
        if (a[i - k + 1] >= a[i + 1]) {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3904
n = int(input())
arr = list(map(int, input().split()))
ans =0
for i in range(1,n-1, 1):
    if arr[i-1] < arr[i] and arr[i] <arr[i+1]:
        ans +=1
    if arr[i-1] > arr[i] and arr[i] >arr[i+1]:
        ans +=1
print(ans)

Measured memory_bytes: 61764
"""
愚直に全探索すると、O(2**N+2**M)かかる
制約的にはDPっぽいかな。
あ、これ部分文字列DPの発想に近いな。
dp[i][j] => Sのインデックスi、Tのインデックスjまでみる。インデックスi、インデックスjは使う。
nt[i][j] => Tのi項以降で数字jが出てくるインデックス。
"""
N,M = map(int,input().split())

N += 1
M += 1

S = list(map(int,input().split()))
S = [0]+S
T = list(map(int,input().split()))
T = [0]+T

dp = [[0]*M for _ in range(N)]
mod = 10**9 +7
for j in range(M):
    dp[0][j] = 1

for i in range(1,N):
    for j in range(M):
        if j == 0:
            dp[i][j] += dp[i-1][j]
        else:
            dp[i][j] += dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
            if S[i] == T[j]:
                dp[i][j] += dp[i-1][j-1]
        dp[i][j] %= mod

print(dp[-1][-1])

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

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

	unsigned long long power = 1;

	for (int loop = 1; loop <= n; ++loop) {
		power *= loop;
		power %= 1000000000 + 7;
	}

	cout << power << endl;

	return 0;
}


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

int main() {
    string s;
    cin >> s;

    int num = 0;

    if(s[0] == 'o') ++num;
    if(s[1] == 'o') ++num;
    if(s[2] == 'o') ++num;

    int cost = 700 + (100 * num);
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 256
#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 mk make_pair
#define pb push_back

typedef long long lld;
typedef pair<lld,lld> pr;
typedef priority_queue <lld> max_heap;
typedef priority_queue <lld, vector<lld>, greater<lld> > min_heap;
lld const mod = 1e9+7;
lld const N = 1e5+5;
#define ordered_set tree<lld, null_type,less<lld>, rb_tree_tag,tree_order_statistics_node_update>

lld fact[N], ifact[N];

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

lld power_mod(lld base, lld y)
{
    lld t = 1;
    while (y > 0)
    {

        if (y % 2 != 0)
            t = (t * base) % mod;
        base = (base * base) % mod;
        y /= 2;
    }
    return t % mod;
}

void findFact() {
    fact[0] = 1;
    for(lld i = 1; i <= N; i++)
        fact[i] = 1ll * fact[i - 1] * i % mod;
    ifact[N] = power_mod(fact[N], mod - 2);
    for(lld i = N - 1; i >= 0; i--)
        ifact[i] = 1ll * ifact[i + 1] * (i + 1) % mod;
}

lld comb(lld n, lld r) {
    return 1ll * fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}


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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  string t;
  cin>>s;
  cin>>t;
  lld i,j,n1,n2;
  n1 = s.length();
  n2 = t.length();
  lld ans = n2;
  lld sum = 0;
  for(i=0;i<=n1-n2;i++)
  {
    sum = 0;
    for(j=0;j<n2;j++)
    {
      if(s[i+j]!=t[j])
      {
        sum++;
      }
    }
    // cout<<"i = "<<i<<" sum = "<<sum<<endl;
    ans = min(ans,sum);
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include<cstdio>
#include<iomanip>

using namespace std;


int main() {
  int W,H,x,y;
  cin >> W >> H >> x >> y;

  double ans = (double)W*H/2;
  cout<<setprecision(6)<<fixed<<ans<<" ";
  //cout << ans << endl;

  if (x*2 == W && y*2 == H) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    int i;
    int cnt = 0;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if (tmp % 2 && i % 2 == 0) cnt++;
    }
    printf("%d\n", cnt);

    return;
}

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


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

typedef long long ll;
bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    if (a.second != b.second)
        return a.second < b.second;
    else
        return a.first <= b.first;
}

int main(void){
    int n;
    cin >> n;
    vector<pair<ll, ll>> pairs(n);
    for (int i = 0; i < n; i++) {
        ll x, l;
        cin >> x >> l;
        pairs[i] = make_pair(x-l, x+l);
    }
    
    sort(pairs.begin(), pairs.end(), comp);
    
    int ans = 1;
    ll t = pairs[0].second;
    for (int i = 1; i < n; i++) {
        if (t <= pairs[i].first) {
            ans++;
            t = pairs[i].second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
import * as fs from 'fs';
const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).split('\n');
const n = +input[0];
const a = [];
for(let i = 0; i < n; i++){
  a.push(input[i + 1].split(' ').map((x: string): number => +x));
}
let result = true
for (let i = 0; i < n; i++){
  const [ti, xi, yi] = a[i]
  const [tj, xj, yj] = i === 0 ? [0, 0, 0] : a[i-1]
  const dt = ti - tj
  const dist = Math.abs(xi - xj) + Math.abs(yi - yj);
  if (dt < dist) {
    result = false;
    break;
  }
  if (dist % 2 != dt % 2) {
    result = false;
    break;
  }
}
console.log(result ? 'Yes' : 'No');

Measured memory_bytes: 50508
from collections import Counter
N = int(input())
s_counter = Counter()
for _ in range(N):
    s = input()
    s_counter[s] += 1
M = int(input())
t_counter = Counter()
for _ in range(M):
    t = input()
    t_counter[t] += 1
max_profit = 0
for key in s_counter.keys():
    max_profit = max([max_profit, s_counter[key] - t_counter[key]])
print(max_profit)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

struct edge { int to, cost; };

int n, m, s, t;
vector<edge> vec1[100010], vec2[100010];
int d1[100010], d2[100010];
priority_queue<P, vector<P>, greater<P>> cnt;

void dijkstra(int x, vector<edge> *vec, int *d) {
	for (int i = 1; i <= n; i++)d[i] = INF;
	priority_queue<P, vector<P>, greater<P>> que;
	d[x] = 0;
	que.push({ 0,x });
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int a = p.first, b = p.second;
		if (d[b] < a)continue;
		for (int i = 0; i < (int)vec[b].size(); i++) {
			edge e = vec[b][i];
			if (d[e.to] > d[b] + e.cost) {
				d[e.to] = d[b] + e.cost;
				que.push({ d[e.to],e.to });
			}
		}
	}
}

signed main() {
	cin >> n >> m >> s >> t;
	for (int i = 0; i < m; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		vec1[a].push_back({ b,c });
		vec1[b].push_back({ a,c });
		vec2[a].push_back({ b,d });
		vec2[b].push_back({ a,d });
	}
	dijkstra(s, vec1, d1);
	dijkstra(t, vec2, d2);
	for (int i = 1; i <= n; i++) {
		cnt.push({ d1[i] + d2[i],i });
	}
	for (int i = 1; i <= n; i++) {
		while (cnt.top().second < i)cnt.pop();
		cout << 1000000000000000 - cnt.top().first << endl;
	}
}

Measured memory_bytes: 20524
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


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

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

void solve(){
	int n;
	cin>>n;
	int arr[4];
	for(int i=3;i>=0;--i){
		arr[i]=n%10;
		n/=10;
	}
	for(int i=0;i<2;++i){
		for(int j=0;j<2;++j)
		for(int k=0;k<2;++k){
			int cal=arr[0];
			if(i==0)
			cal+=arr[1];
			else
			cal-=arr[1];
			if(j==0)
			cal+=arr[2];
			else
			cal-=arr[2];
			if(k==0)
			cal+=arr[3];
			else
			cal-=arr[3];
			if(cal==7){
				cout<<arr[0];
				i==0? cout<<"+" : cout<<"-";
				cout<<arr[1];
				j==0? cout<<"+" : cout<<"-";
				cout<<arr[2];
				k==0? cout<<"+" : cout<<"-";
				cout<<arr[3];
				cout<<"=7";
				return ;
			}
		}
	}
}


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


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();

    stdin.read_line(&mut buf).unwrap();
    let n: usize = buf.trim().parse().unwrap();

    let mut d: Vec<usize> = Vec::new();

    for _i in 0..n {
        buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        d.push(buf.trim().parse().unwrap());
    }

    d.sort();
    d.dedup();

    println!("{}", d.len());
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}
 
 
const int N=2e5+5;
int n,ans;
string s[N];
map<string,int>mp;
 
int main()
{
	n=read();
	for ( int i=1; i<=n; ++i ) cin>>s[i];
	sort(s+1,s+n+1);
	for ( int i=1; i<=n; ++i ) mp[s[i]]++;
	for ( int i=1; i<=n; ++i ) ans=max(ans,mp[s[i]]);
	for ( int i=1; i<=n; ++i )
	if (mp[s[i]]==ans) 
	{
		cout<<s[i]<<endl;
		mp[s[i]]--;	
	}
	return 0;	
}

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

int main() {

	int N,s=0;
	int C[50],V[50],n[50];	

	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> C[i];

	for (int i = 0; i < N; i++)
		cin >> V[i];


	for (int i = 0; i < N; i++) {
		n[i] = C[i] - V[i];
		if (n[i] > 0)
			s += n[i];
	}



	if (s <= 0)
		cout << "0";
	else
		cout << s;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
da=list(map(int,input().split()))
ans=[0 for i in range(2**n)]
jud=[False for i in range(n)]

def cal(i):
    k=i
    su=0
    for j in range(n):
        if k%2==1:
            su+=da[j]
        k//=2
    ans[i]=su

for i in range(2**n):
    cal(i)
kop=set(ans)
m=int(input())
qu=list(map(int,input().split()))
for i in qu:
    if len({i}&kop):
        print('yes')
    else:
        print('no')


Measured memory_bytes: 43088
//FIRST THINK THEN CODE.

  #include <bits/stdc++.h>


  using namespace std;

  typedef long long ll;

  #define rep(i,a,b) for(ll i=a;i<b;++i)
  #define rrep(i,a,b) for(ll i=a;i>b;--i)
  #define FOR(i,n)  for(ll i=0;i<n;i++)
  #define vi vector<int>
  #define vl vector<ll>
  #define ld long double
  #define vld vector<ld>
  #define vvi vector<vector<int>>
  #define vvl vector<vector<long long>>
  #define vvld vector<vector<ld>>
  #define pii pair<int,int>
  #define pll pair<long,long>
  #define vpii vector<pii>
  #define vpll vector<pll>
  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define d1(x) cout<<(x)<<endl
  #define d2(x,y) cout<<(x)<<" "<<(y)<<endl
  #define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
  #define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
  #define PI 3.1415926535897932384626433832795
  #define fix(f,n) fixed<<setprecision(n)<<f
  #define all(x) x.begin(),x.end()
  #define rev(p) reverse(p.begin(),p.end());
  #define endl "\n"
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define popcount(x) __builtin_popcountll(x)
  #define sz(x) ((ll)x.size())
  const ll M=1000000007;
  const ll MM=998244353;
  ll begtime = clock();
  #define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
  //#define _Find_next 
  //#define _Find_first 



  ll newmod(ll a,ll b)
  {
  return ((a%b)+b)%b;
  }


  ll powM(ll a,ll b,ll m )
  { 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
  if(b&1)ans=ans*a%m;
  a=a*a%m;
  b>>=1;
  }

  return ans;
  }



  ll poww(ll a,ll b)
  { 

  ll ans=1;
  while(b)
  {
  if(b&1)ans=ans*a;
  a=a*a;
  b>>=1;
  }

  return ans;

  }

  template<typename T,typename F>
  void chmax( T &a,F b){
  if(b>a)a=b;
  }

  template<typename T,typename F>
  void chmin( T &a,F b){
  if(b<a)a=b;
  }



  const ll N=1e5+5;



  int main()
  { 

  IOS;

ll h,w,m;
cin>>h>>w>>m;

set<pll>s;

vpll row(h+1);
vpll col(w+1);

while(m--){
  ll x,y;

  cin>>x>>y;
  s.insert({x,y});
  row[x].ff++;
  col[y].ff++;
}

for(int i=1;i<=h;i++)row[i].ss=i;

  for(int j=1;j<=w;j++)col[j].ss=j;

sort(all(row));
sort(all(col));

rev(row);
rev(col);




ll ans=0;

for(int i=0;i<h;i++){
ll temp=col[0].ff+row[i].ff;
if(s.count({row[i].ss,col[0].ss}))temp--;
//if(temp==4)d1(i);
chmax(ans,temp);
}

for(int i=0;i<w;i++){
ll temp=row[0].ff+col[i].ff;
if(s.count({row[0].ss,col[i].ss}))temp--;
chmax(ans,temp);
}

cout<<ans;

  return 0;

  }

Measured memory_bytes: 31452
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  double n,m,d;
  cin>>n>>m>>d;
  //cout<<n;
  //cout<<m;
  //cout<<d;
  double ans;
  if(d==0){
    ans = (n-d)*(m-1)/(n*n);
  }else{
    ans = 2*(n-d)*(m-1)/(n*n);
  }
  cout<<fixed<<setprecision(7)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
//use std::num;
//use petgraph::unionfind::UnionFind;
//use permutohedron::LexicalPermutation as _;

//#[fastout()]
fn main() {
  input! {
      X:i64,K:i64,D:i64
  }
  let a = X.abs() / D;
  // a or a+1回移動した時点で原点に一番近づく。
  if K <= a {
    let mut ans = X.abs() - D * K;
    println!("{}", ans.abs());
    return;
  }
  // a+1回以上の移動が可能。
  // 後K-a回移動する。
  let b = if (K - a) % 2 == 0 { a } else { a + 1 };
  let mut ans = X.abs() - D * b;
  println!("{}", ans.abs());
}


Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int N;
int A[1000006];
int GCD[1000006];
unordered_map<int, bool> is_prime;

bool prime_factor(int n) {
  for(int i = 2; i * i <= n; i++) {
    if (n%i==0) {
      if (is_prime[i]) return true;
      else is_prime[i] = true;
    }
    while(n % i == 0) n /= i;
  }
  if(n != 1) {
    if (is_prime[n]) return true;
    else is_prime[n] = true;
  }
  return false;
}

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> A[i];
  GCD[0] = A[0];
  rep(i, N-1) GCD[i+1] = gcd(GCD[i], A[i+1]);
  if (GCD[N-1]>=2) {
    cout << "not coprime" << endl;
    return 0;
  }
  rep(i, N) {
    if (prime_factor(A[i])) {
      cout << "setwise coprime" << endl;
      return 0;
    }
  }
  
  cout << "pairwise coprime" << endl;
  return 0;
}

Measured memory_bytes: 11436
n = int(input())
b_list = [ int(v) for v in input().split() ]

a_list = [None for i in range(n)]
for i in range(n):
    if i == 0:
        a_list[0] = b_list[0]
    elif i == n - 1: 
        a_list[-1] = b_list[-1]
    else:
        a_list[i] = min(b_list[i-1], b_list[i])

print(sum(a_list))

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

int main() {
	int a, b, c, k, ans = 0;

	cin >> a >> b >> c >> k;

	if (a <= k) {
		ans += a;
		if (b <= k - a) {
			if (c <= k - a - b) {
				ans -= c;
			}
			else ans -= k - a - b;
		}
	}
	else ans += k;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
S = input()
T = input()

cand = []
for i in range(len(S) - len(T) + 1):
    f = True
    for s, t in zip(S[i:i+len(T)], T):
        if s == '?':
            continue
        if s != t:
            f = False
            break
    if f:
        cand.append(S[:i] + T + S[i+len(T):])
if cand == []:
    print('UNRESTORABLE')
    exit()
print(cand[-1].replace('?', 'a'))

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int m = sc.nextInt();
			
			int[][] A = new int[n][m];
			int[] b = new int[m];
			
			for(int i=0;i<n;i++) {
				for(int j=0;j<m;j++) {
					A[i][j] = sc.nextInt();
				}
			}
			for(int i=0;i<m;i++) {
				b[i] = sc.nextInt();
			}
			
			for(int i=0;i<n;i++) {
				int sum = 0;
				for(int j=0;j<m;j++) {
					sum += A[i][j] * b[j];
				}
				System.out.println(sum);
			}
		}
	}
}


Measured memory_bytes: 40212
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	to = [Int[] for i in 1:n]
	fr = [Int[] for i in 1:n]
	d = zeros(Int,n)
	for i in 1:m
		s,t = readline() |> split |> parseMap
		push!(to[s],t)
		push!(fr[t],s)
		d[s] += 1
	end
	z = zeros(Float64,n)
	for i in 0:n-1
		for j in fr[n-i]
			z[j] += (1.0+z[n-i])/d[j]
		end
	end
	minim = z[1]
	for i in 1:n
		if d[i] > 1
			x = copy(z)
			for j in 1:i
				x[j] = 0.0
			end
			tmp = 0.0
			tes = 0.0
			for j in to[i]
				tes += z[j]
				tmp = max(tmp,z[j])
			end
			x[i] = (tes-tmp)/(d[i]-1)+1.0
			for j in 1:i-1
				for k in to[i-j]
					x[i-j] += (1.0+x[k])/d[i-j]
				end
			end
			minim = min(minim,x[1])
		end
	end
	println(minim)
end

main()

Measured memory_bytes: 157972
#include <stdio.h> 
    
   int main(void) { 
    
     int i, n; 
     int sum = 0; 
    
     scanf("%d", &n); 
    
    for (i = 1; i <= n; i++) { 
      sum += i; 
    } 
   
    printf("%d\n", sum); 
   
    return 0; 
  } 
  


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

int main() {
int A,B;
  cin>>A>>B;
    
if (max(A,B)==2) {cout<<"3"<<endl;}
 else if (min(A,B)==2) {cout<<"1"<<endl;}
 else {cout<<"2"<<endl;};

  
}



Measured memory_bytes: 256
/*
 * Created by Dipta Das on 
 * Title: [gg]
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/
#include <bits/stdc++.h>
#define fin freopen("input", "r", stdin);
#define fout freopen("output", "w", stdout);
#define wt(x) cerr << #x << ": " << x << " ";
#define whatis(x) {cerr << #x << ": " << x << endl;}
#define whatis2(x, y) {wt(x); wt(y); cerr << endl;}
#define whatis3(x, y, z) {wt(x); wt(y); wt(z); cerr << endl;}
#define whatis4(x, y, z, a) {wt(x); wt(y); wt(z); wt(a); cerr << endl;}
using namespace std;

typedef long long ll; typedef unsigned long long ull; typedef long double ld;
const ll MOD = 1000000007; const ld PI = acos(-1.0);

const int N = 1000000;
int power[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll n;
    cin >> n;
    ll cnt = 0;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            n /= i;
            power[i] += 1;
        }
    }
    int ans = 0;
    if (n > 2) {
        /* power[n] += 1; */
        ans += 1;
    }
    for (int i = 0; i < N; ++i) {
        int val = 1;
        int cnt = 0;
        while (power[i]) {
            cnt += val;
            val += 1;
            /* if (i == 2) whatis(cnt); */
            if (cnt <= power[i]) {
                ans += 1;
            } else {
                break;
            }
        }
    }

    /* whatis(power[3]); */
    /* whatis(power[2]); */
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		
		String str = br.readLine();
//		int n = Integer.parseInt(br.readLine());
		
		String[] tmpArray = str.split(" ");
	
		int a = Integer.parseInt(tmpArray[0]);
		int b = Integer.parseInt(tmpArray[1]);
		int angle = Integer.parseInt(tmpArray[2]);
		
		double area = a*b*Math.sin(Math.toRadians(angle))/2;
		double c = Math.pow( a*a + b*b - 2*a*b*Math.cos(Math.toRadians(angle)), 0.5);
		double h = area/a*2;
		
		System.out.println(area);
		System.out.println(a+b+c);
		System.out.println(h);
//		Point2D.Double p1 = new Point2D.Double(Double.parseDouble(tmpArray[0]), Double.parseDouble(tmpArray[1]));
//		Point2D.Double p2 = new Point2D.Double(Double.parseDouble(tmpArray[2]), Double.parseDouble(tmpArray[3]));
		
//		System.out.println(p1.distance(p2));
		

//		System.out.println(count);

//
//			if(Character.isLowerCase(c)){
//				System.out.print(Character.toUpperCase(c));
//			}
//
//			else if(Character.isUpperCase(c)){
//				System.out.print(Character.toLowerCase(c));
//			}
//			else {
//				System.out.print(c);
//			}
//		}
//		System.out.println();

//		String[] tmpArray = br.readLine().split(" ");
//		int n = Integer.parseInt(tmpArray[0]);
//		int m = Integer.parseInt(tmpArray[1]);
//		int l = Integer.parseInt(tmpArray[2]);
//
//		long[][] a = new long[n][m];
//		long[][] b = new long[m][l];
//		long[][] c = new long[n][l];
//
//		for(int i = 0; i < n; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < m; j++){
//				a[i][j] = Long.parseLong(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < m; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < l; j++){
//				b[i][j] = Integer.parseInt(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < n; i++){
//			for(int j = 0; j < l; j++){
//				for(int k = 0; k < m; k++){
//					c[i][j] += a[i][k]*b[k][j];
//				}
//
//				if(j != 0 ){
//					System.out.print(" ");
//				}
//				System.out.print(c[i][j]);
//			}
//			System.out.println();
//		}


	}

}

Measured memory_bytes: 24600
import math
a, b, h, m = map(int, input().split())
h = (h + m / 60) / 12 * 2 * math.pi
m = (m / 60) * 2 * math.pi
print((a ** 2 + b ** 2 - 2 * a * b * math.cos(h - m)) ** 0.5)

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

#define INF 1234567890
#define ll long long

int main()
{
	string s, t;
	cin >> s >> t;
	int res = INF;
	for(int i=0; i<(int)s.size()-(int)t.size()+1; i++)
	{
		int cnt = 0;
		for(int j=0; j<t.size(); j++)
		{
			if (s[i+j] != t[j])
				cnt++;
		}
		res = min(res, cnt);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif


static void ABC115C_task();

#if 1
int main()
{
	ABC115C_task();

	fflush(stdout);
	return 0;
}
#endif

static void ABC115C_task()
{
	int N, K;
	scanf(" %d %d", &N, &K);

	auto height = new L_LONG[N + 1];
	for (int i = 0; i < N; i++) {
		scanf(" %lld", &height[i]);
	}
	height[N] = 0;
	std::sort(height, height + N);
	L_LONG diffMin = LLONG_MAX;
	L_LONG tmpDiff = 0;
	for (int i = 0; (i + K - 1) < N; i++) {
		tmpDiff = height[i + K - 1] - height[i];
		if (diffMin > tmpDiff) {
			diffMin = tmpDiff;
		}
	}

	printf("%lld\n", diffMin);

	delete[] height;
}


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

int main() {

	int n[3];
	cin >> n[0];
	cin >> n[1];
	cin >> n[2];

	int tmp;
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < 3; j++) {
			if (n[j] < n[i]) {
				tmp = n[i];
				n[i] = n[j];
				n[j] = tmp;
			}
		}
	}

	for (int i = 0; i < 3; i++) {
		if (i < 2) {
			cout << n[i] << " ";
		} else {
			cout << n[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); int m = sc.nextInt();
        ArrayList<Integer> [] adj = new ArrayList[n+1];
        int [] h = new int [n+1];
        for (int i = 1; i <= n; i++) h[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) adj[i] = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt(); int b = sc.nextInt();
            adj[a].add(b); adj[b].add(a);
        }
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            boolean good = true;
            for (Integer next: adj[i]) {
                if (h[i] <= h[next]) good = false;
            }
            if (good) ans++;
        }
        System.out.println(ans);
    }


}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

struct Segtree{
	typedef int sgT;
	vector<sgT> seg;
	int nbn; sgT INF;
	void init(int n){
		for(nbn=1; nbn<n+2; nbn<<=1); INF=0; // min:+inf,max:-inf
		seg.assign(nbn*2, INF);
	}
	sgT comp(sgT l, sgT r){return l | r;}  //min<->max
	void update(int k,sgT x){
		k+=nbn-1; seg[k]=x;
		while(k>0){ k=(k-1)/2; seg[k]=comp(seg[k*2+1],seg[k*2+2]); }
	}
	sgT query2(int a,int b,int l,int r,int k){
		if(b<=l||r<=a) return INF;
		if(a<=l&&r<=b) return seg[k];
		return comp(query2(a,b,l,(l+r)/2,k*2+1), query2(a,b,(l+r)/2,r,k*2+2));
	}
	sgT query(int a,int b){ return query2(a,b,0,nbn,0); }
	sgT get(int a){return seg[nbn+a-1];}  // =query(a,a+1)
	int getpos(sgT v, int l, int r ){
		int lo=l-1, hi=r;
		while(hi - lo >1){
			int md = (hi + lo) >> 1;
			if( query(lo, md+1) == v ) hi = md; else lo = md; 
		}
		return hi;
	}
};


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, q;
	string s;
	cin >>n >>s >>q;
	
	Segtree sga;
	sga.init(n);
	rep(i, n) sga.update(i, 1<<(s[i]-'a'));
	
	rep(_q,q){
		int x; cin >>x;
		if(x==1){
			int y; char z; cin >>y >>z;
			y--;
			if(s[y]==z) continue;
			sga.update(y, 1<<(z-'a'));
			s[y] = z;
		}else{
			int l,r; cin >>l >>r;
			cout << __builtin_popcount(sga.query(l-1, r)) <<"\n";
		}
	
	
	
	}

	return 0;
}


Measured memory_bytes: 5020
/* Volume0 */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
          sb.append(i).append("x").append(j).append("=").append(i * j);
          sb.append("\n");
        }
      }

      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24456
S = input()
patterns = ['dreamer', 'dream', 'eraser', 'erase']


while len(S) != 0:
    isShaved = False
    for p in patterns:
        if S.endswith(p):
            S = S[:len(S)-len(p)]
            isShaved = True
            break
    if not isShaved:
        break

print('YES' if len(S) == 0 else 'NO')

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

//Compiler version g++ 6.3.0

int main()
{
   int x,y;
   float m;
   cin>>x>>y;
   if(y%2!=0)
   {
     cout<<"No";
     exit(0);
   }
   m=(float)y/x;
   if(m>=2&&m<=4)
   cout<<"Yes";
   else
   cout<<"No";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long int
#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define pi 3.1415926535897932384626
#define MOD 1000000007
#define DEBUG false
#define b begin()
#define e end()
#pragma GCC optimize "trapv"

const int mod=998244353; 
const int m=1073741824;
using namespace std;

int32_t main()
{
 nitro;
    int n,m;
    cin>>n>>m;
    std::vector<int> v(m);
    for(int& x:v)
    cin>>x;
    int s=0;
    int sum=accumulate(v.b,v.e,s);
    if(n-sum>=0)
    cout<<n-sum;
    else
    cout<<-1;
return 0;
}


Measured memory_bytes: 3724
#include<iostream>

using namespace std;

int main(){
  int K;

  cin >> K;
  int even;
  int odd;

  if(K%2 == 0){
    even = K/2;
    odd = K/2;
  } else {
    even = K/2;
    odd = K/2 + 1;
  }

  cout << even*odd << endl;

}


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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) elems.push_back(item);
      item.clear();
    }
    else item += ch;
  }
  if (!item.empty()) elems.push_back(item);
  return elems;
}

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

signed main()
{
  int n;

  while (cin >> n, n) {
    int sum = 0;
    rep(i, n * (n - 1) / 2) {
      sum += in();
    }
    print(sum / (n - 1));
  }

  return (0);
}

Measured memory_bytes: 3204
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
using namespace std;
#define omajinai ios::sync_with_stdio(false);cin.tie(nullptr);

#pragma region typedef 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
#pragma endregion

#pragma region define
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#pragma endregion

#pragma region const
const ll INF = 1e18;
const ld PI = 3.141592653589793;
#pragma endregion

#pragma region function
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;
}
#pragma endregion

int main(){
omajinai;

    long long h[100010];
    long long dp[100010];

    int N; cin >> N;
    rep(i, N) cin >> h[i];

    rep(i, 100010) dp[i] = INF;

    dp[0] = 0;

    for(int i = 1; i < N; ++i){
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1)
            chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[N-1] << endl;
return 0;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    while (n--) {
        int a, b;
        cin >> a >> b;
        if (a >= h && b >= w) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	bool ao = true;
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] != 0)ao = false;
		mp[A[i]]++;
	}
	if (ao) {
		cout << "Yes" << endl;
		return 0;
	}

	if (N % 3 == 0) {
		sort(A.begin(), A.end());
		int val[3];
		bool ok = true;
		for (int i = 0; i < 3; i++) {
			val[i] = A[(N / 3) * i];
			for (int j = (N / 3) * i; j < (N / 3) * (i + 1); j++) {
				if (val[i] != A[j]) {
					ok = false;
				}
			}
		}
		if (ok && ((val[0] ^ val[1] ^ val[2]) == 0)) {
			cout << "Yes" << endl;
			return 0;
		}

	}

	cout << "No" << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;

int n;
string s;
vector<string> ans;

void dfs(string& s,int m){
    if(s.size()>n){
        ans.emplace_back(s);
        return;
    }
    for(int i = 0; i < m; i++) {
        s.push_back(char(i+'a'));
        dfs(s,m);
        s.pop_back();
    }
    s.push_back(char(m+'a'));
    dfs(s,m+1);
    s.pop_back();
}

//#define int long long
//signed main(){
int main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    cin >> n;
    n--;
    s="a";
    dfs(s,1);
    sort(ans.begin(),ans.end());
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 7236
N, K = map(int, input().split())

candy_list = []

for i in range(K):
  d = int(input())
  A = [int(x) for x in input().split()]
  candy_list.append(A)
  
member_list = [0] * N

for k in range(K):
  target_candy = candy_list[k]
  
  for n in target_candy:
    member_list[n-1] += 1

ans = 0
for i in range(N):
  if member_list[i] == 0:
    ans += 1

print(ans)

Measured memory_bytes: 9208
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(long long i = 0; i < (n); i++)
using ll = long long;
using namespace std;

ll mod_mul(ll a, ll b, ll mod)
{
    return a % mod * (b % mod) % mod;
}

ll mod_pow(ll a, ll b, ll mod)
{
    if(b == 0) return 1;
    else if(b % 2 == 0){
        return mod_pow(mod_mul(a, a, mod), b/2, mod);
    } else{
        return mod_mul(a, mod_pow(a, b-1, mod), mod);
    }
}

ll mod_div(ll a, ll b, ll mod)
{
    return a % mod * mod_pow(b, mod - 2, mod) % mod;
}

int main()
{
    const ll mod = 1e9+7;
    ll x, y;
    cin >> x >> y;
    ll z = max(x,y);
    vector<ll>mod_facto(z+1);
    mod_facto[0] = 1;
    for(ll i = 1; i <= z; i++){
        mod_facto[i] = mod_mul(i, mod_facto[i - 1], mod);
    }
    rep(i,x+1){
        ll n = x, m = y, a = i, b = 0;
        n -= i;
        m -= 2 * i;
        if(n % 2 == 0) b = n / 2;
        if(b == m && n % 2 != 1){
            cout << mod_div(mod_facto[a + b], mod_mul(mod_facto[a], mod_facto[b], mod), mod) << endl;
            return 0;
        }
        if(m <= 0 || n <= 0) break; 
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 11116
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int a, b; cin >> a >> b;
  vector<int> P(b);
  vector<string> S(b);
  loop(i,0,b) cin >> P[i] >> S[i];
  loop(i,0,b) P[i]--;
  
  vector<int> C(a, 0);
  vector<bool> AC(a, false);
  int ac = 0;
  
  loop(i,0,b) {
    int p = P[i];
    if (AC[p]) continue; // AC済みはペナルティ増加無し
    if (S[i] == "WA") {
      C[p]++;
    } else {
      ac++;
      AC[p] = true;
    }
  }
  
  ll cnt = 0;
  loop(i,0,a) {
    if (!AC[i]) continue;
    cnt += C[i];
  }
  cout << ac << " " << cnt << endl;
  return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

template<class T>
constexpr T gcd(T a, T b) {
    if (a < b) gcd(b, a);
    T r = 0;
    while ((r = a % b)) { a = b; b = r; }
    return b;
}
template<class T>
constexpr T lcm(T a, T b) {
    T g = gcd<T>(a, b);
    return a / g * b;
}


ll a, b;
void solve() {
    cin >> a >> b;
    cout << lcm(a, b) << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
typedef long long ll;

int main() {
	int a, b,c,d;
	std::cin >> a >> b >> c >> d;
	if (std::min(b, d) - std::max(a, c) <= 0) {
		std::cout << '0' << std::endl;
		return 0;
	}
	std::cout << std::min(b, d) - std::max(a, c) << std::endl;
	return 0;
}

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

using namespace std;

int main()
{
  string S; cin >> S;

  int res = 999999;
  for (int i = 0, length = S.length(); i < length - 2; ++i) {
    res = min(res, abs(stoi(S.substr(i, 3)) - 753));
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL a,b;
	cin>>a>>b;
	int cnt=0;
	while(a<=b){
		cnt++;
		a*=2LL;
		//cerr<<a<<" "<<b<<"; ";
	}
	cout<<cnt<<endl;
    return 0;
}


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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }

#define fi first
#define se second

typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;

const int kN = 3e5 + 5;

int a[kN], n;

int main() {
	rd(n); for(int i = 1; i <= 3 * n; ++i) rd(a[i]);
	std::sort(a + 1, a + 3 * n + 1, [](int x, int y) { return x > y; });
	ll ans = 0;
	for(int i = 1; i <= n; ++i) ans += a[i * 2];
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1408