akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int N;
    cin >> N;
    VI a(N);
    int maxi=-INF,mini=INF;
    REP(i,N){
        cin >> a[i];
        maxi=max(maxi,a[i]);
        mini=min(mini,a[i]);
    }
    int result = maxi - mini;
    cout << result << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    char[] S = sread().dup;
    long Q = lread();
    auto bit = new BIT[]('z' - 'a' + 1);
    foreach (i; 0 .. bit.length)
        bit[i] = BIT(N);
    foreach (i; 0 .. N)
    {
        bit[S[i] - 'a'].add(i + 1, 1);
    }
    outer: foreach (_; 0 .. Q)
    {
        auto input = readln.split();
        long a = input[1].to!long();
        if (input[0] == "1")
        {
            char b = input[2][0];
            if (S[a - 1] == b)
                continue outer;
            bit[S[a - 1] - 'a'].add(a, -1);
            bit[b - 'a'].add(a, 1);
            S[a - 1] = cast(char) b;
        }
        if (input[0] == "2")
        {
            long b = input[2].to!long();
            long ans;
            foreach (c; 0 .. bit.length)
                ans += (bit[c].sum(b) - bit[c].sum(a - 1) != 0);
            writeln(ans);
        }
    }
}

struct BIT
{
    long _n;
    long[] _data;
    this(long n)
    {
        _n = n;
        _data = new long[](_n + 1);
    }

    long sum(long i)
    {
        long ans;
        while (0 < i)
        {
            ans += _data[i];
            i -= (i & -i);
        }
        return ans;
    }

    void add(long i, long x)
    {
        while (i <= _n)
        {
            _data[i] += x;
            i += (i & -i);
        }

    }
}


Measured memory_bytes: 114448
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)
#include <map>

using namespace std;
#define ll long long

int main(){
  int N;
  ll M;
  cin >> N >> M;
  vector<ll> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];

  vector<ll> B(N+1, 0);
  for(int i=0; i<N; i++)
    B[i+1] = B[i] + A[i];

  map<ll, int> m1;
  vector<ll> m2;
  for(int i=0; i<N+1; i++) {
    ll mod = B[i] % M;
    m1[mod];
    if(m1[mod] == 0)
      m2.push_back(mod);
    m1[mod]++;
  }

  ll ans = 0;
  for(int i=0; i<m2.size(); i++) {
    ll num = m1[m2[i]];
    ans += num * (num - 1) / 2;
  }

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


Measured memory_bytes: 6264
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
  int a=0, n, i;
  int input;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &input);
    if(input%2!=0) a++;
  }
  printf(a%2==0 ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  int64_t n,k;
  cin>>n>>k;
  if ((k % 2) == 0) {
    int64_t hk = k / 2;
    int64_t so = n / k;
    int64_t se = n / hk - so;
    cout << so*so*so + se*se*se << endl;
  } else {
    int64_t s = n / k;
    cout << s*s*s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		if (n == 1) {
			if (a == b) {
				System.out.println(1);
			} else {
				System.out.println(0);
			}
		} else if (a > b) {
			System.out.println(0);
		} else {
			long x = b - a;
			System.out.println(x * (n - 2) + 1);
		}
	}
}


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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == 'p')
      cnt++;
  cout << s.size() / 2 - cnt << endl;

  return 0;
}


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

int main(void){
    int N;cin>>N;
    int ans=0;
    for(int i=1;i<=N;i+=2){
        int div=0;
        for(int j=1;j<=sqrt(i);j++){
            if(i%j==0)div+=2;
        }
        if(div==8)ans++;
    }
    cout<<ans<<endl;
}

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

// template {{{
/* vim: set foldmethod=marker: */

// constant
const int INF = (int)1e9;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-14;

// typedef
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

// repetition
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define RFOR(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPit(type, i, obj) for (type::iterator i = (obj).begin(); i != (obj).end(); i++)
#define RREPit(type, i, obj) for (type::iterator i = (obj).rbegin(); i != (obj).rend(); i++)

// short
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

// input
template <class T = int> inline T in(){ T x; cin >> x; return x; }
template <class T = int> inline vector<T> in(int n){ vector<T> v; v.reserve(n); REP(i, n) v.pb(in<T>()); return v; }
template <class T = int> inline void in(T* x, int n){ REP(i, n) x[i] = in<T>(); }
#define inl in<ll>
#define ind in<double>

// container util
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define sz(obj) obj.size()
#define sza(ary) (sizeof(ary) / sizeof(*ary))
#define sort(obj) sort(all(obj))
#define exist(obj, key) ((obj).find(key) != (obj).end())
#define clear(ary) memset((ary), 0, sizeof(ary))

// print util
#define print(x) cout << (x) << endl
#define printd(x, d) cout << fixed << setprecision(d) << (x) << endl
template <class T> inline void printv(vector<T>& v, int n = -1){ n = ~n ? n : sz(v); REP(i, n) cout << v[i] << "\n "[i < n - 1]; }
template <class T> inline void printa(T* ary, int n){ REP(i, n) cout << ary[i] << "\n "[i < n - 1]; }
#define dump(x) cerr << #x << ": " << (x) << endl
#define debug(x) cerr << #x << ": " << (x) << " (" << __LINE__ << ")" << endl

//template }}}

signed main()
{
    int n = in(), m = in();
    int box[n + 1];
    bool reddable[n + 1] = {false, true};

    fill(box, box + n + 1, 1);
    REP(i, m){
        int x = in(), y = in();
        box[y]++;
        box[x]--;
        reddable[y] |= reddable[x];
        reddable[x] &= !!box[x];
    }
    print(count(reddable, reddable + n + 1, true));

    return 0;
}


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

int main(){
	string S;
	cin>>S;
	int ans = 0;
	string tmp;
	int i=0;
	int owari=0;
	while(true){
		if(i==0){
			tmp = S[0];
			ans++;
			i++;
		}
		else{
			int j = 1;
			while(true){
				if(S.substr(i,j)!=tmp){
					tmp=S.substr(i,j);
					ans++;
					break;
				}
				if(i+j>=S.size()){
					owari = 1;
					break;
				}
				j++;
			}
			i += j;
		}
		if(i>=S.size() || owari == 1)break;
	}
	cout<<ans<<endl;
}


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

int main() {
    
    int h,n;
    cin>>h>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum=sum+a[i];
    }
    if(h>sum){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    
    
	return 0;
}

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

const ll nax=1e18;

bool is_prime(ll n)
{
 ll i;
    if(n==1
       ) return false;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0) return false;
    }
    return true;
}


void solve()
{
   
    ll n,res=1;
    cin>>n;
    vector<ll>a(n);
        map<ll,ll>mp;
    for(ll &x:a)
    {cin>>x;mp[x]++;}

    if(mp[0])
    {
        cout<<0<<endl;
        return ;
    }
    
    for(ll x:a)
    {
       if((nax/res)<x)
       {
        cout<<-1<<endl;
                 // cout<<res<<" "<<x<<" ";
           return ;
    
       }
        res*=x;
    }
    
    cout<<res<<endl;
}

int main()
{
 int t=1;
  //  cin>>t; 
    
    while(t--)
     solve();   
    
}

Measured memory_bytes: 10232
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# vertexごとに3つの状態数を持つ
N, M = lr()
graph = [[] for _ in range((N+1)*3)]  # 1-indexed
for _ in range(M):
    a, b = lr()
    a *= 3; b *= 3
    for i in range(3):
        j = i+1 if i < 2 else 0
        graph[a+i].append(b+j)

INF = 10 ** 15

def dijkstra(start):
    dist = [INF] * (N+1) * 3
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next in graph[prev]:
            #print(graph[prev],dist[next],next)
            d1 = d + 1
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
    return dist

S, T = lr()
dist = dijkstra(S*3)
answer = dist[T*3]
if answer == INF:
    answer = -1
else:
    answer //= 3
print(answer)


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



int main(){
    string str;
    cin >> str;
    ll ans = 1;
    ll sum = str.size();

    map<char,int> map;
    for(int i = 0; i < str.size(); i++){
        map[str[i]]++;
    } 
    
    for(int i = 0; i < str.size(); i++){ 
        ans += sum - map[str[i]];
        sum--;
        map[str[i]]--;
    }

    cout << ans << endl;

}



Measured memory_bytes: 3748
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let it = s.trim().split_whitespace();
    let mut a: Vec<usize> = it.map(|s| s.parse().unwrap()).collect();
    a.sort();
    if a[0] != a[2] && (a[1] == a[0] || a[1] == a[2]) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include<cstdio>
#include<cmath>
#include<malloc.h>
#include<stdlib.h>
#include<algorithm>
int main()
{
	int a,b,c;
	while(~scanf("%d %d %d",&a,&b,&c))
	{
		if((a+b==c)||(b+c==a)||(a+c==b))
		puts("Yes");
		else
		puts("No");
	}
	return 0;
}

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

using ll = long long;

template <typename T>
class node {
public:
	node<T> *l, *r;
	T val, add;
	node(T val_ = 0, node<T>* l_ = nullptr, node<T>* r_ = nullptr) :
		l(l_), r(r_), val(val_), add(0) {}
};

template <typename T>
class DynamicLazySegmentTree {
	const ll n;
	node<T> *root;
	int it;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	T sub(ll l, ll r, node<T>* n, ll lb, ll ub) {
		if (ub <= l || r <= lb) return 0;
		if (l <= lb && ub <= r) return n->val + n->add * (ub - lb);
		return n->add * (min(r, ub) - max(l, lb)) + (n->l != nullptr ? sub(l, r, n->l, lb, (lb + ub) / 2) : 0) + (n->r != nullptr ? sub(l, r, n->r, (lb + ub) / 2, ub) : 0);
	}
	void suc(ll l, ll r, node<T>* n, ll lb, ll ub, T val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			n->add += val;
			return;
		}
		n->val += val * (min(r, ub) - max(l, lb));
		if (n->l == nullptr) {
			n->l = new node<T>();
		}
		if (n->r == nullptr) {
			n->r = new node<T>();
		}
		suc(l, r, n->l, lb, (lb + ub) / 2, val);
		suc(l, r, n->r, (lb + ub) / 2, ub, val);
	}
public:
	DynamicLazySegmentTree(ll n_) :
		n(size(n_))
	{
		it = 0;
		root = new node<T>();
	}
	void add(ll l, ll r, T val) {
		suc(l, r + 1, root, 0, n, val);
	}
	T getSum(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	DynamicLazySegmentTree<ll> dlst(1000000000000000000ll);
	for (int i = 0, type, s, t, x; i < q; i++) {
		cin >> type;
		if (type) {
			cin >> s >> t;
			printf("%lld\n", dlst.getSum(s, t));
		}
		else {
			cin >> s >> t >> x;
			dlst.add(s, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 10768
body_1,body_2,body_3,cards=map(int,input().split())
total=0
sa=cards-body_1-body_2
if body_1>=cards:
    total=cards
elif body_1<cards:
    if (body_1+body_2)>=cards:
        total=body_1*1
    else:
        total=body_1-sa

print(total)        
    

Measured memory_bytes: 9172
h,w=map(int,input().split())
c=[[int(x) for x in input().split()] for _ in [0]*10]
a="".join([input() for _ in [0]*h])
nokori = [0,2,3,4,5,6,7,8,9]
while nokori:
    thiscost = 10**3
    for i in nokori:
        if c[i][1] <= thiscost:
            argmin = i
            thiscost = c[i][1]
    nokori.remove(argmin)
    for i in nokori:
        c[i][1] = min(c[i][1],c[i][argmin]+c[argmin][1])
c = c
ans = 0
for num in "023456789":
    ans += c[int(num)][1]*a.count(num)
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int p[100005];
int main(void){
    int N; cin>>N;
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        if(p[i]==i+1){
            ans++; i++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
n,m=gets.split.map(&:to_i)

x=gets.split.map(&:to_i)
x.sort!
z=Array.new(n,false)
dist=Array.new(n-1,0)
result=0

if n>=m
    p 0
    exit
elsif
for i in 0..m-2
    dist[i]=x[i+1]-x[i]
end
    
s=dist.length-(n-1)
dist.sort!
result=dist[0..s-1].sum
end

p result

Measured memory_bytes: 22688
/*
	##############################
	#  Author: Pratyush Gaurav   #
	#  College: NIT ROURKELA     #
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define rep(i,a,b) for(i = a ; i < b ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)
#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()

#define endl '\n'

const long long INF = 2000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

lli a[200][200];

void solve()
{
    lli n,tot = 0,last,i;
    cin >> n;
    vlli v(n+2,0);
    REP(i,1,n) {
        cin >> v[i];
        tot += abs(v[i] - v[i-1]);
    }
    REP(i,1,n) {
        lli ans;
        if(i != n)
            ans = tot - abs(v[i] - v[i-1]) - abs(v[i+1] - v[i]) + abs(v[i+1] - v[i-1]);
        else
            ans = tot - abs(v[i] - v[i-1]);
        if(i != n)
            ans += abs(v[n]);
        else {
            //cout << "ans " << ans << " last " << abs(v[n - 1]) << endl;
            ans += abs(v[n - 1]);
        }
        cout << ans << '\n';
    }
}
int main()
{
    opt;
    lli t = 1;
    while(t--)
        solve();
    return 0;
}










Measured memory_bytes: 2048
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>

using namespace std;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a < b && b < c )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	string s, t;
	cin >> s >> t;
	s = s + s;
	for (int i = 0; i < s.size()- t.size(); i++) {
		if (s.substr(i, t.size()) == t) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int main(){
  int cnt=0;
  string s,ss="CODEFESTIVAL2016";
  cin>>s;
  rep(i,s.size())if(s[i]!=ss[i])cnt++;
  cout<<cnt<<endl;
  return 0;
}


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

int main() {
    unordered_map<string, int> ump;
    int n;
    cin >> n;

    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ump[s]++;
    }

    cout << ump.size() << endl;

    return 0;
}

Measured memory_bytes: 17792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanLines)
	defer out.Flush()

	for sc.Scan() {
		a, b := nextInts()
		x, y := gcd(a, b), lcm(a, b)
		fmt.Fprintf(out, "%d %d\n", x, y)
	}

}

func nextInts() (a, b int) {
	s := strings.Split(sc.Text(), " ")
	ra, _ := strconv.Atoi(s[0])
	rb, _ := strconv.Atoi(s[1])
	a = ra
	b = rb
	return
}

func gcd(x, y int) int {
	if x < y {
		gcd(y, x)
	}
	for 0 < y {
		r := x % y
		x, y = y, r
	}
	return x
}

func lcm(x, y int) int {
	return (x * y) / gcd(x, y)
}



Measured memory_bytes: 1100
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=2e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

//set multiset vector queue priority_queue map multimap pair string structure 

//枚举 思维 贪心 搜索 模拟 预处理 二分 排序 

int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
	string s,t;
	cin>>s>>t;
	int cnd=0;
	for(int i=0;i<3;i++){
		if(s[i]==t[i])
		cnd++;
	}
	cout<<cnd;
	
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll k;
    cin>>k;
    string s="ACL";
    forn(i, 0, k){
        cout<<s;
    }
    cout<<endl;
}

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

int main()
{
	int k;
	string s;
	cin>>k>>s;
	
	int z=s.size();
	if(z<=k)
	  cout<<s;
	else
	  cout<<s.substr(0,k)<<"...";
	
	return 0;
	
 } 

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


int main()
{
    int n,a=0,b=0,c=0,d=0;
    cin>>n;
    string s;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        switch(s[0])
        {
            case 'A':a++;
                break;
            case 'W':b++;
            break;
            case 'T': c++;
            break;
            case 'R':d++;
            break;
        }
    }
    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<b<<"\n";
    cout<<"TLE x "<<c<<"\n";
    cout<<"RE x "<<d<<"\n";
}


Measured memory_bytes: 3628
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	x := nextInt()
	var kyu int
	if x < 600 {
		kyu = 8
	} else if x < 800 {
		kyu = 7
	} else if x < 1000 {
		kyu = 6
	} else if x < 1200 {
		kyu = 5
	} else if x < 1400 {
		kyu = 4
	} else if x < 1600 {
		kyu = 3
	} else if x < 1800 {
		kyu = 2
	} else {
		kyu = 1
	}

	fmt.Fprintf(out, "%d\n", kyu)
}


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

const ll MAX = 1e18;

int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    vector<ll> a(n);
    rep (i,n) cin >> a[i];
    if (find(a.begin(), a.end(), 0) != a.end()) {
        cout << 0 << endl;
        return 0;
    }
    rep (i,n) {
        if (MAX/ans < a[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}


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

bool acgt(char ch)
{
  char atgc[]="ACGT";
  for(int j=0 ; j<4 ; ++j)
  {
      if(ch==atgc[j])
      {
        return true;
      }
  }
  return false;
}

int main()
{
	string str;
  	cin>>str;
  	vector<int> atcg(str.length(),0);
  	int ans=0;
  	for(int i=0 ; i<str.length() ; ++i)
    {
    	if(acgt(str[i]))
        atcg[i]=1;
      	if(i && acgt(str[i-1]))
    	atcg[i]+=atcg[i-1];
      	ans=max(atcg[i],ans);
    }
  	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
D = [0 for _ in range(N)]
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for i in range(d):
        D[A[i] - 1] += 1
res = 0
for i in range(N):
    if not D[i]:
        res += 1
print(res)

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

typedef long long ll;

int main () {
	char S[200005], T[200005];
	cin >> S;
	cin >> T;
	int ans = 0;
	for (int i=0; S[i] != '\0';  i++)
		if (S[i] != T[i])
			ans ++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
   int n,l;
   cin>>n>>l;
   string a[101];
   for(int i=0;i<n;i++){
       
       cin>>a[i];
       
   }
   sort(a,a+n);
   for(int i=0;i<n;i++){
   cout<<a[i];
  
       
   }
    return 0;
}


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

int main()
{
  string S;
  cin >> S;
  if(S.at(0)==S.at(1)&&S.at(0)==S.at(2))
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}


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

int main(){
  int n, t; cin >> n >> t;
  int x, y;
  int ans = INT_MAX;int idx = -1;
  for(int i = 0; i < n; ++i){
     cin >> x >> y;
    if(y <= t)ans = min(ans,x);
  }
  if(ans < INT_MAX)cout << ans << '\n';
  else cout << "TLE" << '\n';
}

Measured memory_bytes: 3528
#include<iostream>
#include<algorithm>
using namespace std;
int n;
long ans,a,sum[1<<17],mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
main()
{
	cin>>n;
	for(int i=1;i<1<<17;i++)sum[i]=sum[i-1]+power(i,mod-2)%mod;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		ans=(ans+(sum[i+1]+sum[n-i]+mod-1)%mod*a%mod);
	}
	for(int i=0;i<n;i++)ans=ans*(i+1)%mod;
	cout<<ans<<endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, A, B;
string S;

int main() {
    //cout.precision(10);
    cin >> N >> A >> B;
    cin >> S;
    S = "#" + S;
    int a = 0;
    int b = 0;
    for(int i = 1; i <= N; i++) {
        if(S[i] == 'c') {
            cout << "No" << endl;
            continue;
        }
        if(S[i] == 'a') {
            if(a + b < A + B) {
                a++;
                cout << "Yes" << endl;
            } else cout << "No" << endl;
            continue;
        }
        if(a + b < A + B && b < B) {
            cout << "Yes" << endl;
            b++;
        } else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 892
#!/usr/bin/env python3
from bisect import bisect
N, Q = map(int, input().split())
A = [0] * (N % 2) + list(map(int, input().split()))

HF = len(A) // 2
li = []
cumsum = [sum(A[HF:])]

for i in range(HF - 1):
    left = A[2 * i + 1]
    right = A[i + HF]
    li += [(left + right) // 2 + 1]
    cumsum += [cumsum[-1] + left - right]

for _ in range(Q):
    X = int(input())
    print(cumsum[bisect(li, X)])


Measured memory_bytes: 14664
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, k = sc.nextInt()
    val hs = Array.fill(n)(sc.nextLong()).sorted

    val acc = for (i <- k - 1 until n) yield {
      hs(i) - hs(i - k + 1)
    }

    println(acc.min)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}


Measured memory_bytes: 60280
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//BEGIN CUT HERE
template<typename T>
struct DiameterForVertex{
  vector<T> vs,dp;
  vector<vector<int> > G;
  DiameterForVertex(int n):dp(n),G(n){}
  DiameterForVertex(vector<T> vs):vs(vs),dp(vs.size()),G(vs.size()){}
  void add_edge(int u,int v){
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  void dfs(int v,int p,int &s){
    if(p<0) dp[v]=T(0);
    dp[v]+=vs[v];
    if(dp[s]<dp[v]) s=v; 
    for(int u:G[v]){
      if(u==p) continue;
      dp[u]=dp[v];
      dfs(u,v,s);
    }    
  }  
  T build(){
    assert(!vs.empty());
    int s=0;
    dfs(s,-1,s);
    dfs(s,-1,s);
    return dp[s];    
  }
  T build(vector<T> us){
    assert(us.size()==dp.size());
    vs=us;
    return build();
  }
};
//END CUT HERE

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE

signed AGC033_C(){
  int n;
  cin>>n;
  vector<int> vs(n,1);
  DiameterForVertex<int> G(vs);
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G.add_edge(x,y);
  }  
  int ans=G.build();
  cout<<((ans%3!=2)?"First":"Second")<<endl;
  return 0;
}
/*
  verified on 2019/05/07
  https://atcoder.jp/contests/agc033/tasks/agc033_c
*/

signed ARC097_F(){
  int n;
  cin>>n;
  DiameterForVertex<int> G(n);
  vector<int> deg(n,0);
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G.add_edge(x,y);
    deg[x]++;
    deg[y]++;
  }
  string s;
  cin>>s;
  
  int cnt=(n-1)*2,num=0;
  queue<int> que;
  vector<int> dead(n,0);
  for(int i=0;i<n;i++){
    num+=(s[i]=='W');
    if((deg[i]==1)&&(s[i]=='B')){
      dead[i]=1;
      que.emplace(i);
    }
  }
  
  while(!que.empty()){
    int v=que.front();que.pop();
    cnt-=2;
    for(int u:G.G[v]){
      if(dead[u]) continue;
      deg[u]--;
      if(deg[u]==1&&(s[u]=='B')){
        dead[u]=1;
        que.emplace(u);
      }
    }
  }
  
  if(num<=1){
    cout<<num<<endl;
    return 0;
  }
  
  vector<int> vs(n,0);  
  for(int i=0;i<n;i++){
    if(dead[i]) continue;
    vs[i]=deg[i]+(s[i]=='W');
    vs[i]%=2;
    cnt+=vs[i];
  }
  
  cout<<cnt-G.build(vs)*2<<endl;
  return 0;            
}
/*
  verified on 2019/05/07
  https://atcoder.jp/contests/arc097/tasks/arc097_d
*/

signed main(){
  //AGC033_C();
  ARC097_F();
  return 0;
}


Measured memory_bytes: 11600
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
typedef long long ll;
int OO = 0x3f3f3f3f;

int h, w;
char grid[1003][1003];
ll mem[1003][1003];

ll solve(int x, int y)
{
    ll op1, op2;
    if(x == h && y == w)
        return 1;
    if(mem[x][y] != -1)
        return mem[x][y];
    op1 = op2 = 0;
    if(x+1 <= h && grid[x+1][y] == '.')
        op1 = solve(x+1, y);
    if(y+1 <= w && grid[x][y+1] == '.')
        op2 = solve(x, y+1);

    return mem[x][y] = (op1%1000000007+op2%1000000007)%1000000007;
}

int main()
{
    cin >> h >> w;
    memset(mem, -1, sizeof mem);
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1;j <= w; j++)
        {
            cin >> grid[i][j];
        }
    }
    cout << solve(1, 1)%1000000007 << endl;
    return 0;
}


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


int main(){

int N,Y;
cin >> N >> Y; //N=枚数　Y=総額　

int A=-1,B=-1,C=-1;

for (int a = 0; a <= N; ++a){
    for(int b = 0; a + b <= N; ++b){
        int c = N - a - b;
        if (a*10000 + b*5000 + c*1000 == Y){
            A = a;
            B = b;
            C = c;
        }

        
    }
}
 cout << A << " " << B << " " << C <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;



int main(int argc, char* argv[])
{
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  std::vector<int> a(4);
  for (int& v : a) cin >> v;
  std::sort(a.begin(), a.end());
  if (a == std::vector<int>{1, 4, 7, 9})
  {
    cout << "YES\n";
  }
  else
  {
    cout << "NO\n";
  }

  return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
a=[int(input()) for _ in range(n)]
c=set()
s=a[0]
cnt=1
while(1):
    if s==2:
        print(cnt)
        sys.exit()
    if s in c:
        print(-1)
        sys.exit()
    c.add(s)
    s=a[s-1]
    cnt+=1

Measured memory_bytes: 13216
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll n,sum=0;
   cin>>n;
   ll a[n];
   map<ll,ll>m;
   for(int i=0;i<n;i++){
    cin>>a[i];
    m[a[i]]++;
    sum+=a[i];
   }
   ll q;
   cin>>q;
   while(q--){
        ll x,y;
        cin>>x>>y;
       // cout<<m[x]<<" ";
        sum-=m[x]*x;
        sum+=m[x]*y;
        ll t=m[x];
         m[x]=0;
        m[y]+=t;
        cout<<sum<<endl;
   }

}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


// AGC020A - Move and Win
int main(){
  int N, A, B; // 2 <= N <= 100, 1 <= A < B <= N <= 100
  cin >> N >> A >> B;
  const int firstA = A, firstB = B;

  int diff = B - A;
  if (diff % 2 == 0) {
    // 差が偶数の場合は、Alice
    cout << "Alice" << endl;
  } else if (diff % 2 == 1) {
    // 差が奇数の場合は、Borys
    cout << "Borys" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	int32_t main(){
		IOS;
		map<int,string>mp;
		mp[0]=mp[1]=mp[6]=mp[8]="pon";
		mp[2]=mp[4]=mp[5]=mp[7]=mp[9]="hon";
		mp[3]="bon";
		int n;
		cin>>n;
		cout<<mp[n%10]<<endl;
		return 0;
	}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
	string a;
	cin >> a;
	int s = 0;
	char b=a[0];
	for (char c : a) {
		if (b != c) { s++; b = c; }
	}
	cout << s << endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++)cin >> a[i];

    ll lef = 0, rig = 10000000000; //xxxxxxoooo

    while(rig - lef > 1) {
        ll mid = (rig + lef) / 2;
        ll cnt = 0;
        for(ll i = 0; i < n; i++) {
            cnt += (a[i] + mid - 1) / mid - 1;
        }
        (cnt > k ? lef : rig) = mid;
    }
    cout << rig << endl;
}

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

typedef long long ll;
int n,a;
ll sum,ans;
map<ll,int> mp;

int main(){
	++mp[sum];
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a;
		sum+=a;
		ans+=mp[sum];
		++mp[sum];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12800
import sys
input = sys.stdin.readline
N = int(input())
H = [int(x) for x in input().split()]

ans = 0
temp = 0
for i in range(1,N) :
    if H[i] <= H[i-1] :
        temp += 1
        ans = max(ans, temp)
    else :
        temp = 0

print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;
   int ans;
   if (n % 1000 == 0)
      ans = 0;
   else
      ans = n/1000*1000 + 1000 - n;
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3648
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)

#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c)
#define     M             32000

int main()
{
    ll a[3];
bool b = false;
    for(int i=0;i<3;i++)cin>>a[i];
    sort(a,a+3);
    for(int i=0;i<1;i++)
    {
        if((a[i]==a[i+1] && a[i+1]!=a[i+2]) ||(a[i]!=a[i+1] && a[i+1]==a[i+2]))
        {
            b = true;
            break;

        }
    }
    if(b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        var blue = new Dictionary<string, int>();
        for(int i=0; i<n; i++) {
            var s = input.ReadLine();
            if (!blue.ContainsKey(s)) blue[s] = 0;
            blue[s]++;
        }

        var m = int.Parse(input.ReadLine());
        for (int i = 0; i < m; i++) {
            var s = input.ReadLine();
            if (blue.ContainsKey(s)) blue[s]--;
        }

        return Math.Max(0, blue.Values.Max());
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    int h[n];
    rep(i,n) cin >> h[i];

    int dp[n];
    rep(i,n) dp[i] = INF;
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);

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

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
 
using namespace std;
 
typedef unsigned long long ll;
typedef pair<ll, ll> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
 
int main(){

    ll h,w;
    cin >> h >> w;
    ll ans=0;

    if((h==1)||(w==1)) cout << "1";

    else{
        rep(i, h){
            
            if(i%2==0) ans += (w+1)/2;
            else ans += w /2;
        }
        cout << ans;
    }

   
    return 0;
 
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		strA = sc.next().toCharArray();
		strB = sc.next().toCharArray();
		int n = strA.length - 1;
		int m = strB.length - 1;
		memo = sc.nextInt2DArr(n + 1, m + 1, -1);
		dp(n, m);
		System.out.println(trace(n, m));

		pw.close();
	}

	static char[] strA, strB;
	static int[] memo[];

	static int dp(int x, int y) {
		if (x == -1 || y == -1)
			return 0;
		if (memo[x][y] != -1)
			return memo[x][y];
		if (strA[x] == strB[y])
			return memo[x][y] = 1 + dp(x - 1, y - 1);

		return memo[x][y] = max(dp(x - 1, y), dp(x, y - 1));

	}

	static String trace(int x, int y) {
		if (x == -1 || y == -1)
			return "";
		if (strA[x] == strB[y]) {

			return trace(x - 1, y - 1) + strA[x];
		} else if (dp(x - 1, y) >= dp(x, y - 1)) {

			return trace(x - 1, y);
		} else

			return trace(x, y - 1);

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public int[] nextIntArr(int n) throws IOException {
			int arr[] = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public int[] nextIntArr(int n, int f) throws IOException {
			int arr[] = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = f;
			}
			return arr;
		}

		public int[][] nextInt2DArr(int n, int m) throws IOException {
			int arr[][] = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int k = 0; k < m; k++) {
					arr[i][k] = nextInt();
				}
			}
			return arr;
		}

		public int[][] nextInt2DArr(int n, int m, int f) throws IOException {
			int arr[][] = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int k = 0; k < m; k++) {
					arr[i][k] = f;
				}
			}
			return arr;
		}

		public String[] nextStringArr(int n) throws IOException {
			String arr[] = new String[n];
			for (int i = 0; i < n; i++) {
				arr[i] = next();
			}
			return arr;
		}

		public char[] nextCharArr(int n) throws IOException {
			char arr[] = new char[n];
			for (int i = 0; i < n; i++) {
				arr[i] = next().charAt(0);
			}
			return arr;
		}

	}

	public static int max(int a, int b) {
		return a > b ? a : b;
	}

	public static int min(int a, int b) {
		return a < b ? a : b;
	}
}

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

int main()
{
    int n;
    cin >> n;
    if(n % 2 == 0){
        cout << 0.5 << endl;
    }else{
        cout << fixed << setprecision(10) << double(n/2 + 1) / double(n) << endl;
        
    }
    return 0;
}

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

int main() {

    // 1. input.
    int a, b, c;
    cin >> a >> b >> c;
    
    // 2. calculate the number of divisors.
    int ans = 0;
    for(int i = a; i <= b; i++) if(c % i == 0) ans++;
    
    // 3. output answer.
    cout << ans << endl;
    return 0;
    
}


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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int ans=1000000000;
    
    for (int i=0; i<=100000; i++){
        ans=min(2*C*i+max(0, X-i)*A+max(0, Y-i)*B, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n, m, k;
  scanf("%d", &n);
  scanf("%d", &m);
  k = m % n;
  if(k==0){
    printf("%d\n", n+m);
  }else{
    printf("%d\n", m-n);
  }
  return 0;
}


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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9 + 7;
    int a;
    string b;
    cin>>a>>b;
    int ans=(b[0]-'0')*a;
    int bf=stoi(b.substr(2,2));
    ans+=bf*a/100;
    cout<<ans<<endl;
}

Measured memory_bytes: 3656
s = int(input())
l = s / 100
r = s % 100

if(1 <= l and l <= 12):
    if(1 <= r and r <= 12):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if(1 <= r and r <= 12):
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, P>;
#define FOR(t, a, b) for (int t = (a); t < (b); ++t)
#define REP(t, n) FOR(t, 0, n)

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    REP(i, 3)
    {
        if (s[i] == 'o')
            cnt++;
    }
    cout << 700 + 100 * cnt << endl;

    return 0;
}


Measured memory_bytes: 256
//by tzupengwang™
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<iostream>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n;

int query(int x) {
  printf("%d\n", x);
  fflush(stdout);

  char buf[20];
  scanf("%s", buf);
  if (buf[0] == 'V') {
    exit(0);
  } else if (buf[0] == 'M') return 0;
  else return 1;
}

void init() {
  scanf("%d", &n);

  int st = 0;
  int ed = n - 1;
  int lp = query(st);
  int rp = query(ed);

  while (st < ed) {
    int mid = (st + ed) / 2;
    int rt = query(mid);

    if ((mid - st + rt - lp) % 2) {
      ed = mid, rp = rt;
    } else st = mid, lp = rt;
  }
}

void process() {
}

int main() {
/*
#ifdef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
  int Cases;
  scanf( "%d" , &Cases ) ;
  for ( int cases = 1 ; cases <= Cases ; cases ++ ) {
*/
    init() ;
    process() ;
/*
  }
*/
  return 0 ;
}

Measured memory_bytes: 852
#include <iostream>
#include <cassert>
#include <fstream>
#include <sstream>
#include <math.h>
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <time.h>
#include <stdio.h>
#include <deque>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
#define CHK(i,j)(i & (1 << j))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

int N, A;
int X[100];
const int offset = 50 * 50;
ll dp[51][offset * 2]; //i枚目までの合計値j

void solve() {
	ll ans = 0;
	dp[0][50 * 50] = 1;

	

	FOR(i, 0, N) FOR(j, 0, offset * 2) if (dp[i][j]){
		int buf = X[i] + j;
		dp[i + 1][j] += dp[i][j];
		dp[i + 1][buf] += dp[i][j];
	}

	cout << dp[N][offset]-1 << endl;
}

int main() {
	cin >> N >> A;

	REP(i, N) {
		cin >> X[i]; X[i] -= A;
	}

	solve();

	return 0;
}

Measured memory_bytes: 896