akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)

typedef long long ll;

struct FenwickTree{
	vector<ll> data;
	FenwickTree(int n):data(n+1){}
	void AddRange(int i,int x){
		for(;i;i-=i&-i)
			data[i]+=x;
	}
	void AddRange(int i,int j,int x){
		AddRange(i,-x);
		AddRange(j,x);
	}
	int Get(int i){
		ll res=0;
		for(i++;i<data.size();i+=i&-i)
			res+=data[i];
		return res;
	}
};



int main()
{
	for(int n,k,m;cin>>n>>k>>m,n|k|m;){
		FenwickTree ft(n);
		rep(i,n) ft.AddRange(i,n,1);
		
		int p=m-1;
		for(int rest=n;rest>1;){
			ft.AddRange(p,n,-1);
			int x=(ft.Get(p)+k-1)%--rest+1;
			int lo=0,hi=n;
			while(lo<hi){
				int mi=(lo+hi)/2;
				if(ft.Get(mi)>=x)
					hi=mi;
				else
					lo=mi+1;
			}
			p=lo;
		}
		
		cout<<p+1<<endl;
	}
	
	return 0;
}

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

int main() {
    ll k;
    cin>>k;
    string ans="0";
    while(k>0){
        k--;
        ll pos=-1;
        rep(i,ans.size()-1){
            if(ans[i]-'0'==9)continue;
            if(ans[i+1]+1!=ans[i]){
                ans[i]++;
                pos=i;
                break;
            }
        }
        if(pos==-1){
            if(ans[ans.size()-1]=='9'){
                ans.push_back('1');
                pos=ans.size()-1;
            }else{
                ans[ans.size()-1]++;
                pos=ans.size()-1;
            }
        }
        for(ll i=pos;i>0;i--){
            if(ans[i]=='0'){
                ans[i-1]=ans[i];
            }else{
                ans[i-1]=ans[i]-1;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int sum = a + b + c;
	int maxv = max({a, b, c});
	sum -= maxv;
	if(maxv == sum) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int n;

void dfs(string s, char mx) {
    if (s.length() == n) {
        cout << s << endl;
        // printf("%s\n", s.c_str());
    }
    else {
        for (char c = 'a'; c <= mx; c++) {
            dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx));
        }
    }
}

int main()
{
    cin >> n;
    dfs("", 'a');
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int a, b;
    cin >> a >> b;
    for (double i = 0; i <= 1000000; i++) {
        if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
            cout << (int)i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

const int MOD = 1e9 + 7;

int N, M;
long long int fact(int n) {
    long long int x = 1;
    for(int i=2; i<=n; ++i) {
        x *= i;
        x %= MOD;
    }
    return x;
}
int main() {
    std::cin >> N >> M;

    int diff = std::abs(N - M);
    if(diff >= 2) {
        std::cout << 0 << std::endl;
        return 0;
    } 

    long long int ans = (fact(N) * fact(M)) % MOD;
    if(diff == 1) {
        std::cout << (int)ans << std::endl;
    } else if(diff == 0) {
        ans *= 2;
        ans %= MOD;
        std::cout << (int)ans << std::endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define M 1000003
using namespace std;

typedef long long ll;

const int mod = M;

ll mod_pow(ll a,ll x){
  ll res=1;
  while(x){
    if(x%2) res=res*a%mod;
    a=a*a%mod;
    x/=2;
  }
  return res;
}

ll inv(ll x){
  return mod_pow( x, mod - 2 );
}

int X[M], invX[M];

void init(){
  
  int num = 1;
  
  for(int i=1;i<M;i++){
    num *= i;
    num %= mod;
    X[i] = num;
  }
  
  for(int i=0;i<M;i++) invX[i] = inv( X[i] );
  
}

int cal(int x, int d, int n){
  
  if( d == 0 ) return mod_pow( x, n );
  
  int R = ( x * inv( d ) + ( n - 1 ) ) % mod;
  int L = ( x * inv( d ) - 1 + mod ) % mod;
  
  int l = ( R - ( n - 1 ) - 1 );
  if( l <= 0 ) return 0;
  
  return ( ( X[R] * invX[L] ) % mod * mod_pow( d, n ) ) % mod;
}

signed main(){
  
  init();
  
  int q;
  cin >> q;
  
  while( q-- ){
    
    int x, d, n;
    cin >> x >> d >> n;
    
    cout << cal( x, d, n ) << endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 16512
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

while True:
    s1 = input()
    if s1 == '.':
        break
    s2 = input()
    a = s1.strip().split('\"')
    b = s2.strip().split('\"')

    if len(a) != len(b):
        print("DIFFERENT")
    elif a[0::2] != b[0::2]:
        print("DIFFERENT")
    else:
        c = a[1::2]
        d = b[1::2]
        cnt = 0
        for i in range(len(c)):
            if c[i] != d[i]:
                cnt += 1
        if cnt == 0:
            print("IDENTICAL")
        elif cnt == 1:
            print("CLOSE")
        else:
            print("DIFFERENT")


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

int main(){
    int a,b,c,d,e,m;
    cin >> a >> b >> c >> d >> e;
    a += 9;
    b += 9;
    c += 9;
    d += 9;
    e += 9;
    m = min(a%10,b%10);
    m = min (m,c%10);
    m = min (m,d%10);
    m = min (m,d%10);
    a /= 10;
    b /= 10;
    c /= 10;
    d /= 10;
    e /= 10;

    cout << (a+b+c+d+e)*10-9+m  << endl;   
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 一行読み出し
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 文字列リバース関数
func strReverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

// 引数個の数値を読み込む
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	train := a * n
	taxi := b

	if train > taxi {
		fmt.Println(taxi)
	} else {
		fmt.Println(train)
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
int main()
{
  int N, M, X, Y;std::cin >> N >> M >> X >> Y;
  std::vector<int> x(N),y(M);
  for(auto& e:x){std::cin >> e;}
  for(auto& e:y){std::cin >> e;}
  std::sort(x.begin(),x.end()),std::sort(y.begin(),y.end());
  const bool ok = x.back()<y.front() and y.front()>X and y.front()<=Y;
  std::cout << (ok?"No War":"War") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int mod = 1e9 + 7;

string S;

int main() {
    cin >> S;
    long long N = S.length();
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] != S[N - 1 - i]) {
            cnt++;
        }
    }
    cout << cnt / 2 << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn left(node_id: usize) -> usize {
    return node_id * 2;
}

fn right(node_id: usize) -> usize {
    return node_id * 2 + 1;
}

fn max_heapify(a: &mut Vec<i32>, node_id: usize) {
    let left = left(node_id);
    let right = right(node_id);
    let mut largest: usize;
    if left <= (a.len() - 1) && a[left] > a[node_id] {
        largest = left;
    } else {
        largest = node_id;
    }
    if right <= (a.len() - 1) && a[right] > a[largest] {
        largest = right;
    }

    if largest != node_id {
        a.swap(node_id, largest);
        max_heapify(a, largest);
    }
}

fn increase_key(key: i32, a: &mut Vec<i32>) {
    let mut i = a.len() - 1;
    if key < a[i] {
        return;
    }
    a[i] = key;
    while i > 1 && a[i / 2] < a[i] {
        a.swap(i, i / 2);
        i = i / 2;
    }
}

fn insert(key: i32, a: &mut Vec<i32>) {
    a.push(i32::min_value());
    increase_key(key, a);
}

fn extract(a: &mut Vec<i32>) -> i32 {
    if a.len() < 1 {
        return i32::min_value();
    }

    let maxv;
    maxv = a[1];
    a[1] = *a.last().unwrap();
    a.pop();
    max_heapify(a, 1);
    maxv
}

fn main() {
    let mut done = false;
    let mut a: Vec<i32> = vec![-1];

    while !done {
        let command: String = read();
        match &*command {
            "insert" => {
                let number: i32 = read();
                insert(number, &mut a);
            }
            "extract" => println!("{}", extract(&mut a)),
            _ => {
                done = true;
            }
        }
    }
}



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

const int inf = 1e9;

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

    vector<int> dp(n, inf);

    dp[0] = 0;

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

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

Measured memory_bytes: 1024
import numpy as np
n,m,c = map(int,input().split())
b = np.array([list(map(int,input().split()))])
ans = 0

for i in range(n):
    a = np.array([list(map(int,input().split()))])
    if np.sum(a*b) + c > 0:
        ans += 1
print(ans)

Measured memory_bytes: 14536
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <tuple>
#include <functional>
#include <limits>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cstring>

// use printf, scanf instead of cout, cin.

using namespace std;

// Overload operator<< for pair.
template <typename First, typename Second>
std::ostream& operator<<(std::ostream& os, const std::pair<First, Second>& pair)
{
	os << pair.first << " " << pair.second;

	return os;
}

// Print each element of a container.
template <typename Container>
void print(const Container& container)
{
	for (const auto& element : container)
	{
		std::cout << element << std::endl;
	}
}

int main()
{
    deque<pair<string, int>> processes1;
    vector<pair<string, int>> processes2;

    int n, q;
    cin >> n >> q;

    for(size_t i(0); i < n; ++i)
    {
        string name;
        int time;

        cin >> name >> time;

        processes1.emplace_back(name, time);
    }

    int time(0);
    while(!processes1.empty())
    {
        if (processes1.front().second > q)
        {
            time += q;

            processes1.front().second -= q;
            processes1.push_back(processes1.front());
            processes1.pop_front();
        }
        else
        {
            time += processes1.front().second;

            processes2.emplace_back(processes1.front().first, time);
            processes1.pop_front();
        }
    }

    print(processes2);

    return 0;
}

Measured memory_bytes: 6932
from collections import defaultdict
length, types = map(int, input().split(" "))
match = [n for n in input().split(" ")]
cost = {}
cost.update({"1":2, "2":5, "3":5, "4":4, "5":5, "6":6, "7":3, "8":7, "9":6})

dp = ["-" for n in range(10010)]

def compare_str(a, b):
    if a == "":
        return b
    elif len(a) == len(b):
        return a if a > b else b
    elif len(a) > len(b):
        return a
    return b
    
# for m in match:
#     dp[cost[m]] = m
dp[0] = ""
for i in range(length + 1):
    # print(dp, i)
    if dp[i] != "-":
        for m in match:
            # if i + cost[m] <= length:
            dp[i + cost[m]] = compare_str(dp[i + cost[m]], dp[i] + m)
print(dp[length])

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

using namespace std;
int col[6], row[6];
char mp[6][6];
int ans=0;
int h, w, k;

int Count(int x, int y){
    int res=0;
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            if (!(x&(1<<i))&&!(y&(1<<j))&&mp[i][j]=='#') res++;
        }
    }
    return res;
}



int main(){
    cin>>h>>w>>k;
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            cin>>mp[i][j];
        }
    }
    for (int i=0; i<(1<<h)-1; i++){
        for (int j=0; j<(1<<w)-1; j++){
            if (Count(i, j)==k) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0,h,w;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
cin >> h>>w;
string board[50];
for (int i = 0; i < h; ++i) cin >> board[i];
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
REP(i,h){
    REP(j,w){
        if(board[i][j] == '#')continue;
        int num =0;
        REP(d,8){
            const int ni = i + dy[d];
            const int nj = j + dx[d];
            if (ni < 0 or h <= ni) continue;
            if (nj < 0 or w <= nj) continue;
            if (board[ni][nj] == '#') num++;
        }
        board[i][j] =char(num + '0');
    }
}
REP(i,h)cout << board[i] << endl;
return 0;
}


Measured memory_bytes: 3660
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N = II()

    mn = 10**10
    for i in range(1, int(N**0.5)+1):
        if N % i == 0:
            mn = min(len(str(N // i)), mn)

    print(mn)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9300
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
   char s;
   cin >> s;
   if ('a' <= s && s <= 'z'){
      cout<< "a" << endl;
   } else cout << "A" << endl;
} 

Measured memory_bytes: 3620
/*
BROKEN AF
CODING IS JOINING THE BODY PARTS AND THE SOUL
*/
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<numeric>
#include<vector>
#include<math.h>
using namespace std;
#define dude             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mesc(number,character)   char f[number];memset(f,character,number);
#define mesi(number,value)   int f[number];memset(f,value,number);
#define fr(i,start,end)  for(i=start;i<=end;i++)
#define rf(i,start,end)  for(i=start;i>=end;i--)
#define tst              int t;cin>>t;while(t--)
#define ai               ll n,i;cin>>n;ll a[n];
#define pi               3.14159265358979323846
#define ll               long long int
#define ld               long double
#define pb               push_back
#define r0               return 0;
#define pp               pop_back
#define vec              vector
#define S                string
#define D                double
#define len              length
#define br               break;
#define wh               while
#define F                float
#define gcd              __gcd
#define sz               size
#define endl             "\n"
#define sp              " "
const ll ifn=-1000000007;
ll power(ll x, ll y, ll p) { 
    ll res = 1;
    x = x % p;  
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p; 
    } 
    return res; 
} 
/*bool prim(ll n) { 
     int x=0;
    if (n<=1) {
        return false; 
    }
    for (ll i=2;i<=sqrt(n);i++) 
        if (n%i==0) {
            x=1;
            return false;
        }
        if(x==0) {
    return true;
        }
}*/
/*int fib(int n) {
    int i;
    int f[n];
    memset(f,n,int(-1));
    if(f[n]==-1) {
        if(n<=1) {
            f[n]=n;
        }
        else {
            f[n]=fib(n-1)+fib(n-2);
        }
    }
    else {
    return f[n];
    }
}
int prime(ll n) { 
    bool prim[n+1]; 
    memset(prime,true,sizeof(prim)); 
    for(int p=2;p*p<=n;p++) { 
        if(prime[p]==true) {
            for(inti=p*p;i<=n;i+=p) 
                prime[i]=false; 
        } 
    }
    return prim[n];
}*/
void swap(int x,int y) {
    int t=x;
    x=y;
    y=t;
}
bool vow(char c) {
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') {
        return true;
    }
    else {
        return false;
    }
}
/*int mmsed() {
    ll f[n];
    memset(f,1,n) {
        
    }
}*/
int fact(ll x) {
    ll i=1,cnt=1;
    fr(i,1,x) {
        cnt*=i;
    }
    return cnt;
}
bool isPrime(ll n) { 
    if (n<=1)  return false; 
    if (n<=3)  return true;
    if (n%2==0||n%3==0) return false; 
  
    for (ll i=5;i*i<=n;i=i+6) 
        if (n%i==0||n%(i+2)==0) 
           return false; 
  
    return true; 
} 
void solve() {
  int n;
  cin>>n;
  S a[n];
  int i;
  fr(i,0,n-1) {
      cin>>a[i];
  }
  sort(a,a+n);
  ll val=0;
  S t=a[0];
  fr(i,1,n-1) {
      if(t.compare(a[i])!=0) {
          val++;
          t=a[i];
      }
  }
  cout<<val+1;
}
int main() {
    dude
    solve();
    
   r0
}


Measured memory_bytes: 9804
import { readFileSync } from "fs";

const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]/g);
  let count = 0;
  return [() => inputs[count++], () => Number(inputs[count++]), () => BigInt(inputs[count++])];
})() as [() => string, () => number, () => bigint];

const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);

/**
 * Program
 */
const getName = (n: bigint): string => {
  const alphabets = range(26).map((i) => String.fromCharCode("a".charCodeAt(0) + i));

  const getName = (n: bigint, l: bigint): string => {
    const m = 26n ** l;

    return n <= m
      ? range(l).reduce(
          ({ num, str }, _) => ({
            num: num / 26n,
            str: alphabets[Number(num % 26n)] + str,
          }),
          { num: n - 1n, str: "" }
        ).str
      : getName(n - m, l + 1n);
  };

  return getName(n, 1n);
};

{
  const N = biCin();
  console.log(getName(N));
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> dp(100010, INF);
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  rep(i,n){
    dp[i+2] = min(dp[i+1] + abs(h[i+2]-h[i+1]), dp[i] + abs(h[i+2]-h[i]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int w,s;
	while(scanf("%d",&w),w>=0)
	{
		s=1150;
		if((w-=10)>0)s+=(w<10?w:10)*125;
		if((w-=10)>0)s+=(w<10?w:10)*140;
		if((w-=10)>0)s+=w*160;
		printf("%d\n",4280-s);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  String w = sc.next();
  char[] alp = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  boolean b = true;
  for(int i = 0;i < 26;i++){
    int counter = 0;
    for(int j = 0;j < w.length();j++){
      if(w.charAt(j) == alp[i]){
        counter++;
      }
    }
    if(counter%2 == 1){
      b = false;
      System.out.println("No");
      break;
    }
  }
    if(b)System.out.println("Yes");
}}

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

typedef long long ll;
const ll InF = 1e15;

int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<pair<int,int>> ps(n + 1);
    ps[0].first = ps[0].second = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') {
            ps[i + 1].first = ps[i].first + 1;
            ps[i + 1].second = ps[i].second;
        }  else  {
            ps[i + 1].first = ps[i].first;
            ps[i + 1].second = ps[i].second + 1; 
        }
    }
    int ans = n;
    for (int i = 1; i <= n; i++) {
        int res = ps[i - 1].second + ps[n].first - ps[i].first;
        ans = min(res,ans);
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef vector< ll > 	vi;
typedef pair< ll,ll > 	ii;

#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define present(c,x) 	((c).find(x) != (c).end())
#define rep(i,n)        for(ll i=1LL; i<=(n); i++)

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}

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

	ll n,k;
	cin>>n>>k;

	ll x= n%k;
	cout<<min(x, abs(x-k));
	
	// cout<<"\nExecution time : "<<tick()<<"\n";
	return 0;
}

Measured memory_bytes: 256
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		string a;
		cin>>a;
		for(i=a.size()-1;i>=0;i--)
		{
			int flag=0;
			if(i%2!=0)
			{
				int q=(i+1)/2;
				string b="";
				string c="";
				for(j=0;j<q;j++)
					b=b+a.at(j);
				for(j=q;j<i+1;j++)
					c=c+a.at(j);
				if(b==c)
					flag=1;
				//cout<<b<<" "<<c<<endl;
			}	
			if(i+1==a.size())
				flag=0;
			if(flag==1 )
				break;
		}
		cout<<i+1<<endl;
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


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

int main()
{
  int H,W,h,w,r;
  scanf("%d %d",&H,&W);
  scanf("%d %d",&h,&w);
  printf("%d\n",H*W-h*W-w*H+h*w);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N; cin>>N;
  vector<vector<ll>> A(N,vector<ll>(3,0));
  for(ll i=0; i<N; i++) cin>>A[i][0]>>A[i][1]>>A[i][2];
  sort(A.begin(), A.end(), [](auto& x, auto& y){return x[2] > y[2];});  
  ll H;
  for(ll X=0; X<=100; X++){//頂点の全探索
    for(ll Y=0; Y<=100; Y++){
      H=abs(X-A[0][0])+abs(Y-A[0][1])+A[0][2];
      for(ll i=1; i<N; i++){
        ll x=A[i][0];
        ll y=A[i][1];
        ll h=A[i][2];
        ll dif=H-abs(X-x)-abs(Y-y);
        if(h>0 && dif!=h) break;
        else if(h==0 && dif>0) break;
        if(i==N-1){
          cout<<X<<" "<<Y<<" "<<H<<endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
   int l,r,d;
   cin>>l>>r>>d;
   int ans=0;
   for(int i=l;i<r+1;i++){
      if(i%d==0) ans+=1;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define de(x) cout<<#x<<" ="<<x<<endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
//-----------------------------------------
const int N=305;
int dis[N][N],b[N][N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) {
        for(int j=1;j<=n;++j) {
            scanf("%d",&dis[i][j]);
        }
    }


    ll ans=0;
    memset(b,0,sizeof b);
    for(int i=1;i<=n;++i) {
        for(int j=i+1;j<=n;++j) {
            int f=0;
            for(int k=1;k<=n;++k) {
                if(k==i||k==j) continue;
                if(dis[i][k]+dis[k][j]<dis[i][j]) return 0*puts("-1");
                if(dis[i][k]+dis[k][j]==dis[i][j]) {
                    f=1;
                    break;
                }
            }
            if(!f) {
                b[i][j]=dis[i][j];
                ans+=0ll+b[i][j];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut h: usize = s.trim().parse().unwrap();
    let mut cnt = 1usize;
    let mut ans = 0;
    while h > 0 {
        ans += cnt;
        cnt *= 2;
        h /= 2;
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N;
    cin >> N;
    vector<int> L(2 * N);
    REP(i, 2 * N) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    for (int i = 0; i < L.size(); i += 2) {
        ans += L[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 500;
int f[N][N];
int dp[N][N];
int a[N], b[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < n; ++i) {
    for (int k = a[i]; k <= b[i]; ++k) {
      int prod = 1;
      for (int j = 0; j <= m; ++j) {
        f[i][j] = (f[i][j] + prod) % MOD;
        prod = (int64)prod * k % MOD;
      }
    }
  }
  dp[n][0] = 1;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j <= m; ++j) {
      for (int k = 0; k <= j; ++k) {
        dp[i][j] = (dp[i][j] + (int64)f[i][k] * dp[i + 1][j - k]) % MOD;
      }
    }
  }
  printf("%d\n", dp[0][m]);
  return 0;
}


Measured memory_bytes: 1792
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
x = 0
y = 0
# 価値とコストが0以上である宝石を選ぶ。
for i in range(n):
    if v[i] - c[i] > 0:
        x += v[i]
        y += c[i]
# 選択した宝石の価値とコストの総和差の計算。
print(x-y)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    int n,m;
    cin>>n>>m;
    int p=1900*m+100*(n-m);
    cout<<p*pow(2,m)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
  
int main(){
  int n,a=1;
  char s[100000];
  scanf("%d ",&n);
  for(int i=0;i<n;i++){scanf("%c",&s[i]);}
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1])a++;
  }
  printf("%d\n",a);
  //for(int i=0;i<n;i++){printf("%c",s[i]);}
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,a,b,c;
int t[100][100];
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      t[a-1][c-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",t[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
/* ABC144_B
    Stuartyg */

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>


int main(void){
        int num; /*nのこと*/
        int i,j; 
        scanf("%d",&num); /*入力を受け取る*/
        for (i=1;i<=9;i++){ /* for文二個で1*1,1*2,1*3,・・・9*9まで調べる*/
                for (j=1;j<=9;j++){
                        if (num==i*j){
                                printf("Yes\n");
                                return 0; /*一致すればそこでYesと出力して終了*/
                        }
                }
        }
        /*一致しなかった場合*/
        printf("No\n");
        return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int m = in.nextInt();
        ArrayList<Integer>[] a = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            a[i] = new ArrayList();
        }
        for (int i = 0; i < m; i++) {
            int u = in.nextInt() - 1;
            int v = in.nextInt() - 1;
            a[u].add(v);
            a[v].add(u);
        }
        boolean ok = false;
        for (int i = 0; i < a[0].size(); i++) {
            int j = a[0].get(i);
            for (int k = 0; k < a[j].size(); k++) {
                if (a[j].get(k) == n - 1) ok = true;
            }
        }
        out.println(ok ? "POSSIBLE" : "IMPOSSIBLE");
        out.close();
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 87748
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll h;
    cin >> h;
    ll odp = 0;
    ll ile = 1;
    while (h != 0)
    {
        odp += ile;
        h /= 2;
        ile *= 2;
    }

    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



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

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

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

ll dp[50010];

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

    ll n,ans=0;
    cin>>n;
    pair<ll,ll> red[n],blue[n];
    rep(i,n) cin>>red[i].first>>red[i].second;
    rep(i,n) cin>>blue[i].first>>blue[i].second;
    sort(red,red+n);
    sort(blue,blue+n);
    
    rep(i,n){
        ll maxi=-INF,minit=INF;
        rep(j,n){
            if(blue[i].second>red[j].second && blue[i].first>red[j].first){
                if(maxi<red[j].second){
                    maxi=red[j].second; minit=j;
                }
            }
        }
        if(minit!=INF){
            blue[i].second=INF; red[minit].second=INF;
            blue[i].first=INF; red[minit].first=INF;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3660
import numpy as np
n = int(input())
ha = []
hb = []
hc = []
for i in range(n):
  t1, t2, t3 = map(int, input().split())
  ha.append(t1)
  hb.append(t2)
  hc.append(t3)
dp = np.zeros((n,3))

dp[0,0] = ha[0]
dp[0,1] = hb[0]
dp[0,2] = hc[0]
for i in range(1, n):
  for c in range(3):
    if c == 0:
      tmp = ha[i]
    if c == 1:
      tmp = hb[i]    
    if c == 2:
      tmp = hc[i]
    dp[i,c] = max([dp[i-1,j] for j in range(3) if j!=c] ) + tmp
print(int(max(dp[n-1,0],dp[n-1,1],dp[n-1,2])))

Measured memory_bytes: 26848
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 999999999

int t[2][10002];
int dp[3][10002];
int cost[3][3][4] = {
	{{1,2,4,4},{2,2,3,3},{3,3,3,3}},
	{{2,2,3,3},{1,2,2,3},{2,3,2,3}},
	{{3,3,3,3},{2,3,2,3},{1,4,2,4}},
};

int main(void){
	int T;
	cin>>T;

	while(T--){
		int n;
		cin>>n;

		memset(t,0,sizeof(t));
		rep(i,2)rep(j,2*n){
			char ch;
			cin>>ch;
			if(ch == 'Y') t[i][(j+1)/2]++;
		}

		rep(i,3) rep(j,10002) dp[i][j] = MAX;
		dp[0][0] = 0;
		dp[1][0] = 1;
		dp[2][0] = 2;
		rep(j,n+1) rep(i,3) {
			int flg = (t[0][j]!=0 ? 1 : 0);
			flg |= (t[1][j]!=0 ? 1 : 0)<<1;

			rep(to,3){
				dp[to][j+1] = min(dp[to][j+1],dp[i][j]+cost[i][to][flg]);
			}
		}

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

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    while (n--){
        int p, q;
        cin >> p >> q;
        int l = sqrt(p*p + q*q);
        bool isprime = 1;
        REP(i,l) REP(j,l) {
            int x = i*i + j*j;
            if (x <= 1 || x >= p*p + q*q) continue;
            if ((i*p + j*q) % x == 0 && (i*q - j*p) % x == 0) isprime = 0;
        }
        cout << (isprime ? "P" : "C") << endl;
    }

    return 0;
}

Measured memory_bytes: 2996
// CODE © by 𝕌𝕥𝕜𝕒𝕣𝕤𝕙 𝔾𝕒𝕣𝕘
// Copying or sharing of this code without permission of the Author is strictly prohibited!!!
#include <bits/stdc++.h>
using namespace std;
#define Speed ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define endl "\n"
signed main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
#endif
	string s1, s2;
	cin >> s1 >> s2;
	int l1 = s1.size(), l2 = s2.size();
	int dp[l1 + 1][l2 + 1];
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i <= l1; i++) {
		dp[i][0] = 0;
	}
	for (int i = 0; i <= l2; i++) {
		dp[0][i] = 0;
	}
	for (int i = 1; i <= l1; i++) {
		for (int j = 1; j <= l2; j++) {
			if (s1[i - 1] == s2[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	// for (int i = 0; i <= l1; i++) {
	// 	for (int j = 0; j <= l2; j++)
	// 		cout << dp[i][j] << " "; cout << endl;
	// }
	int i = l1; int j = l2; string ans = "";
	while (i != 0 && j != 0) {
		if (dp[i][j] != dp[i][j - 1] && dp[i][j] != dp[i - 1][j]) {
			ans = s2[j - 1] + ans;
			i--; j--;
		}
		else if (dp[i][j] == dp[i][j - 1] && dp[i][j] != dp[i - 1][j]) {
			j--;
		}
		else if (dp[i][j] != dp[i][j - 1] && dp[i][j] == dp[i - 1][j]) {
			i--;
		}
		else i--;
		// cout << i << " " << j << endl;
	}
	cout << ans;
}

Measured memory_bytes: 38800
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ld=long double;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;
const int inf = TEN(18) * 3 + 10;

int like[100010];

signed main()
{
	int n; cin >> n;
	vi a(n);
	int ans = 0;
	rep(i, n) {
		cin >> a[i];
		--a[i];
	}
	rep(i, n) {
		if (a[a[i]] == i) ans++;
	}

	cout << ans/2 << endl;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n,p[20006];
ll magic=30000;
int main()
{
	FAST
	cin>>n;
	FOR(i,0,n){
		ll a; cin>>a;
		p[a-1]=i;
	}
	FOR(i,0,n){
		cout<<(i+1)*magic<<' ';
	}
	cout<<'\n';
	FOR(i,0,n){
		cout<<(n-i)*magic+(p[i]+1)<<' ';
	}
	cout<<'\n';
}


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

int main() {
  int N, M;
  cin >> N >> M;
  map<int, bool> A;
  map<int, int> Pcount;
  int p = 0;
  int count = 0;
  for (int i = 0; i < M; i++) {
    int mondai;
    string answer;
    cin >> mondai >> answer;
	if (answer == "AC" && !A[mondai]){
      count++;
      A[mondai] = true;
      p += Pcount[mondai];
    } else if (answer == "WA" && !A[mondai]) {
      Pcount[mondai]++;
    }
  }
  
  cout << count << " " << p <<endl;
}

Measured memory_bytes: 9600
N = int(input())
A = list(map(int, input().split()))
 
count = 0
flag = False
while True:
  for n in range(N):
    if A[n] % 2 != 0:
      flag = True
      break
  if flag: break
  
  for n in range(N):
    A[n] //= 2
  count += 1

print(count)

Measured memory_bytes: 9176
#include <iostream>
#include<math.h>
using namespace std;

int main(){
  int a, b; 
  cin >>  a  >> b;
  for(int x = 1; x<=10000; x++){
  if( a==  floor(x /12.5) &&  b == floor(x / 10.0)) {
    cout << x << endl;
    return 0;
  }
 }
  cout  << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
def calc(a, b, c, x):
    r = 0
    for aa in range(a+1):
        for bb in range(b+1):
            for cc in range(c+1):
                if aa * 500 + bb * 100 + cc*50 == x:
                    r += 1
    return r


a = int(input())
b = int(input())
c = int(input())
x = int(input())

r = calc(a, b, c, x)
print(r)


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

#define SAFE_DELETE( x ) { if ( x ){ delete x; x = NULL; } }

struct tCell{
	tCell() : x( 0 ), prev( NULL ), next( NULL ){}
	int x;
	tCell *prev, *next;
};


class MyArray{
public:
	MyArray() : mSize( 0 ), head( NULL ), tail( NULL ){
		head = new tCell;
		tail = new tCell;
		head->next = tail;
		tail->prev = head;
	}
	~MyArray(){
		init();
		SAFE_DELETE( head );
		SAFE_DELETE( tail );
	}

	void init(){
		for ( int i = mSize; i > 0; --i ){
			tCell* it = tail->prev;
			it->prev->next = it->next;
			it->next->prev = it->prev;
			SAFE_DELETE( it );
		}
		mSize = 0;
	}

	void pushBack( int x ){
		tCell* it = new tCell;
		it->x = x;
		it->prev = tail->prev;
		it->next = tail;
		it->prev->next = it;
		it->next->prev = it;
		++mSize;
	}
	void pushAsc( int x ){
		
	}
	int size(){ return mSize; }

	tCell operator[]( int index ){
		tCell* it = head->next;
		for ( int i = 0; i < index; ++i ){
			it = it->next;
		}
		return *it;
	}

private:
	int mSize;
	tCell *head, *tail;
};

struct tData{
	tData() : done( false ){}

	bool done;
	MyArray to;
	MyArray dis;
};


class Route{
public:
	Route( int m ) : list( NULL ), mSize( m ){
		list = new tData[ mSize ];
	}
	~Route(){
		delete[] list;
	}

	int calc(){
		bool end;
		int ret = 0;
		list[ 0 ].done = true;
		do{
			end = true;
			int nextTo, nextDis = INT_MAX;
			for ( int i = 0; i < mSize; ++i ){
				if ( list[ i ].done ){
					for ( int j = 0; j < list[ i ].to.size(); ++j ){
						int to = list[ i ].to[ j ].x;
						if ( !list[ to ].done && list[ i ].dis[ j ].x < nextDis ){
							nextTo = to;
							nextDis = list[ i ].dis[ j ].x;
							end = false;
						}
					}
				}
			}
			if ( !end ){
				ret += nextDis / 100 - 1;
				list[ nextTo ].done = true;
			}
		}while ( !end );

		return ret;
	}

	int mSize;
	tData* list;
};

int main(){
	int n, m, p1, p2, d;
	char c;

	while ( cin >> n && n ){
		Route* route = new Route( n );
		cin >> m;
		for ( int i = 0; i < m; ++i ){
			cin >> p1 >> c >> p2 >> c >> d;
			route->list[ p1 ].to.pushBack( p2 );
			route->list[ p1 ].dis.pushBack( d );
			route->list[ p2 ].to.pushBack( p1 );
			route->list[ p2 ].dis.pushBack( d );
		}

		cout << route->calc() << endl;


		SAFE_DELETE( route );
	}
	return 0;
}

Measured memory_bytes: 0