akhauriyash/Code-Regression huggingface dataset:
#! /usr/bin/env python3

s = input()[::-1]
s = s[1:]
s = s[len(s) % 2:]
for i in range(0, len(s), 2):
    t = s[:len(s) // 2]
    if s == t * 2:
        print(len(s))
        break
    s = s[2:]


Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,a,b,ans=0;
  cin >> n >> a >> b;

  if((b-a)%2==0){
    cout << (b-a)/2 << endl;
  }
  else{
    //ans = min(b-1,n-a,);
    ans = min(a-1+(b-a+1)/2,n-b+(b-a+1)/2);
    pri(ans);
  }
}

Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
a = [int(input()) for i in range(m)]
a.append(n+1)
x,mod = [1,1],10**9+7
for i in range(n-1): x.append((x[-2]+x[-1])%mod)
if a[0]-1: ans,p = x[a[0]-1],a[0]
else: ans,p = 1,1
for i in range(1,m+1):
    if a[i]-p-1: ans,p = (ans*x[a[i]-p-2])%mod,a[i]
    else: ans = 0
print(ans)

Measured memory_bytes: 11048
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
typedef long long ll;

int a[1005];
int k, n;

//bool cmp(int a, int b)
//{
//	return a <= b;
//}

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	
//	for (int i = 1; i <= n; i++) cout << a[i] << ' ';
	ll ans = 0; 
	for (int i = 1; i <= k; i++) ans += a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    vector<int> l(q),r(q);
    for(int i=0;i<q;i++){
        cin >> l[i] >> r[i];
    }
    vector<bool> like(100001);
    like[0]=like[1]=false;
    for(int i=2;i<=100000;i++){
        if(i%2==0){
            like[i]=false;
            continue;
        }
        bool tmp=true;
        for(int j=2;j<=i/j;j++){
            if(i%j==0){
                tmp=false;
                break;
            }
        }
        int tmp2=(i+1)/2;
        for(int j=2;j<=tmp2/j;j++){
            if(tmp2%j==0){
                tmp=false;
                break;
            }
        }
        like[i]=tmp;
    }
    vector<int> a(100001);
    a[0]=0;
    for(int i=1;i<=100000;i++){
        a[i]=a[i-1]+(like[i]?1:0);
    }

    for(int i=0;i<q;i++){
        cout << a[r[i]]-a[l[i]-1] << endl;
    }


    return 0;
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BGuidebook solver = new BGuidebook();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGuidebook {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            List<BGuidebook.City> arr = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                arr.add(new BGuidebook.City(i + 1, in.next(), in.nextInt()));
            }
            arr.sort((c1, c2) -> c1.city.equals(c2.city) ? c2.score - c1.score : c1.city.compareTo(c2.city));
            for (BGuidebook.City city : arr) {
                out.println(city.id);
            }
        }

        public static class City {
            int id;
            int score;
            String city;

            public City(int id, String city, int score) {
                this.id = id;
                this.score = score;
                this.city = city;
            }

        }

    }
}



Measured memory_bytes: 26580
#include <bits/stdc++.h>
#define mod 1000000007
#define fr first
#define val second
#define N 100000000
#define fo(i,m,n) for(int i=m;i<n;i++)
#define M 7
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
using ul=unsigned long long;
using pii=pair<int,int>;
using vvi=vector<vector<int>>;
using vi=vector<int>;
using pll=pair<ll,ll>;
using vsi=vector<set<int>>;
using vll=vector<ll>;

ll power(ll a,ll n){
    ll j=0;
    ll x=1;
    while(1ll<<j<=n){
        if(1ll<<j&n)
            x=(x*a)%mod;

        a=a*a%mod;
        j++;
    }

    return x;
}

int gcd(int a,int b){
    if(b==0)
        return a;
    else
        return gcd(b,a%b);

}

int lb(vi &a,int x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;
    while(l<=r){
        int mid=(l+r)/2;
        if(x>=a[mid]){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind+1;

}

int up(vll &a,ll x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;

    while(l<=r){
        int mid=(l+r)/2;

        if(a[mid]>x){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind;
}

ll max(ll a,ll b){
    if(a>b)
        return a;
    else
        return b;

}

ll min(ll a, ll b){
    if(a>b)
        return b;
    else
        return a;

}
template<typename T>
void pra(T a[],int n){
    fo(i,0,n)
            cout<<a[i]<<' ';
    cout<<endl;

}

ifstream input;
ofstream output;
int t;
const ll inf=1e16;
int cs;
int tcs;
void build(vll &F,int ind,int tl,int tr,vll &st){

    if(tl==tr)
        st[ind]=F[tl];
    else{
        int mid=(tl+tr)/2;
        build(F,2*ind+1,tl,mid,st);
        build(F,2*ind+2,mid+1,tr,st);
        st[ind]=min(st[2*ind+1],st[2*ind+2]);
    }

}

void update(int j,ll nv,int ind,int tl,int tr,vll &st){

    if(j<tl||j>tr)
        return;
    else if(tl==tr)
        st[ind]=nv;
    else{
        int mid=(tl+tr)/2;
        update(j,nv,2*ind+1,tl,mid,st);
        update(j,nv,2*ind+2,mid+1,tr,st);
        st[ind]=min(st[2*ind+1],st[2*ind+2]);
    }

}


ll query(int ind,int tl,int tr,int l,int r,vll &st){
    int mid=(tl+tr)/2;
    if(r<tl||l>tr)
        return inf;
    else if(tl==l&&tr==r)
        return st[ind];
    else
        return min(query(2*ind+1,tl,mid,l,min(mid,r),st),query(2*ind+2,mid+1,tr,max(mid+1,l),r,st));

}

int main(){
    int n;
    cin>>n;
    char c[n];

    fo(i,0,n)
            cin>>c[i];

    int j=n-1;
    int cnt=0;
    fo(i,0,n){
        if(c[i]=='W'){
            while(j>i&&c[j]!='R')
                j--;
            if(c[j]=='R'){
                cnt++;
                c[j]='W';
            }

        }


    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// Segment Tree
template <class M> class ST {
    void init(int n_) {
        for (n = 1, lev = 0; n < n_; n <<= 1, ++lev);
        d.assign(n << 1, e1);
    }

public:
    int n, lev;
    vector<M> d;
    virtual void assign(int, M) = 0;
    virtual M f(M, M) = 0;
    const M e1;

    ST(M e1) : e1(e1) {}

    void build(const vector<M>& v) {
        int n_ = v.size();
        init(n_);
        for (int i = 0; i < n_; ++i) d[n + i] = v[i];
        for (int i = n - 1; i > 0; --i) d[i] = f(d[(i << 1) | 0], d[(i << 1) | 1]);
    }
    void build(int n_) { init(n_); }

    void update(int k, M x) {
        assign(k += n, x);
        while (k >>= 1) d[k] = f(d[(k << 1) | 0], d[(k << 1) | 1]);
    }

    M query(int a, int b) {
        M L = e1, R = e1;
		for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) L = f(L, d[l++]);
            if (r & 1) R = f(d[--r], R);
		}
        return f(L, R);
    }
    M query(int a) { return query(a, a + 1); }
};

// Range Maximum Query (RMQ)
template <class M> struct RMQ : public ST<M> {
    RMQ(M e1 = numeric_limits<M>::min()) : ST<M>(e1) {}
    M f(M a, M b) override { return max(a, b); }
    void assign(int k, M x) override { this->d[k] = x; }
};

// Range Minimum Query (RmQ)
template <class M> struct RmQ : public ST<M> {
    RmQ(M e1 = numeric_limits<M>::max()) : ST<M>(e1) {}
    M f(M a, M b) override { return min(a, b); }
    void assign(int k, M x) override { this->d[k] = x; }
};

// Range Sum Query (RSQ)
template <class M> struct RSQ : public ST<M> {
    RSQ(M e1 = 0) : ST<M>(e1) {}
    M f(M a, M b) override { return a + b; }
    void assign(int k, M x) override { this->d[k] += x; }
};

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

    int n, q;
    cin >> n >> q;
    RSQ<int> rmq;
    rmq.build(n);
    REP (i, q) {
        int com, x, y;
        cin >> com >> x >> y;
        x--;
        if (com == 0) {
            rmq.update(x, y);
        } else {
            cout << rmq.query(x, y) << endl;
        }
    }
}


Measured memory_bytes: 4880
#include<stdio.h>
#include<iostream>
using namespace std;

long long int combination(int n,int lb)
{
	if(n>lb)
		return(n*combination(n-1,lb));
	else
		return(1);
}


int main()
{

	long long int m,n;
	cin>>n>>m;
	long long int n_odd,n_even;
	n_odd = 0;
	n_even = 0 ;
	if(n>1)
	{
		n_even  = combination(n,n-2)/2;
	}
	if(m>1)
	{
		n_odd  = combination(m,m-2)/2;
	}
	cout<<n_odd+n_even;
	return(0);
}

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

int main(){
  int N;
  cin>>N;
  map<string,int> A;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    A[S]++;
  }
  int j=0;
  for(pair<string,int> i:A)
    j=max(j,i.second);
  for(pair<string,int> i:A)
    if(i.second==j)
      cout<<i.first<<endl;
}

Measured memory_bytes: 25216
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    V<tuple<string, ll, ll>> v;
    for(ll i = 0; i < N; i++) {
        string s;
        ll p;
        cin >> s >> p;
        v.emplace_back(s, p, i);
    }

    sort(ALL(v),
         [&](auto a, auto b) {
             if(get<0>(a) != get<0>(b)) return get<0>(a) < get<0>(b);
             else return get<1>(a) > get<1>(b);
         });

    for(auto ele : v) cout << get<2>(ele) + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <unordered_set>
using namespace std;
#define N 610000
#define P 1000000007

int n, p[N], b[N], empty_a, empty, tot, sum[N], prod[N], inv[N];
int used[N];
int ans;

int calc(int x) {
	int ans = 0;
	for (; x; x -= x & -x)
		ans += b[x];
	return ans;
}

void upd(int x) {
	for (; x <= n; x += x & -x)
		b[x] += 1;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &p[i]);
	for (int i = 1; i <= n; i++)
		used[p[i]] = 1;
	for (int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + used[i];
	empty = n - sum[n];
	prod[0] = 1;
	for (int i = 1; i <= n; i++)
		prod[i] = 1LL * i * prod[i - 1] % P;
	inv[1] = 1;
	for (int i = 2; i <= n; i++)
		inv[i] = (-1LL * inv[P % i] * (P / i) % P + P) % P;

	empty_a = 0;
	tot = 0;
	for (int i = n; i; i--) {
		if (!p[i]) {
			ans = (ans + 1LL * prod[n - i] * tot % P * prod[empty - 1]) % P;
			ans = (ans + 1LL * prod[n - i] * prod[empty] % P * empty_a % P * inv[2]) % P;
			empty_a += 1;
		}else {
			ans = (ans + 1LL * prod[n - i] * calc(p[i]) % P * prod[empty]) % P;
			if (empty) {
				ans = (ans + 1LL * prod[n - i] * (p[i] - sum[p[i]]) % P * prod[empty - 1] % P * empty_a % P) % P;
			}
			upd(p[i]);
			tot += (n - p[i]) - (sum[n] - sum[p[i]]);
			tot %= P;
		}
	}
	ans = (ans + prod[empty]) % P;
	printf("%d\n", ans);
}


Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    ll ans=1;
    rep2(i,N){
        ans=(ans*i)%mod;
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n - 1; i++) cin >> b[i];
    
   int ret = b[0];
    for (int i = 0; i + 2 < n; i++){
		int val = min(b[i], b[i + 1]);
	    ret += val;
	}
	ret += b[n - 2];
	cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//n ~ mの和
ll sigma(ll n, ll m)
{
  return ((n + m) * (m - n + 1) * 0.5);
}

void Main()
{
  ll a, b, x; cin >> a >> b >> x;
  fin((a <= x&&a + b >= x ? "YES" : "NO"));
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if((a+b)%2){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << (max(a,b)-min(a,b))/2+min(a,b) << endl;
    
}

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

set<ll> s;

void dfs(ll cntup, ll a) {
    s.insert(a);

    ll b = a%10;
    if(cntup == 10){
        s.insert(a);
        return;
    }

    if(b >= 1) dfs(cntup+1, a*10+b-1);
    if(b <= 8) dfs(cntup+1, a*10+b+1);
    dfs(cntup+1, a*10+b);

}

int main(){
    ll k; cin >> k;

    rep(i,9){
        dfs(1,i+1);
    }

    auto itr = s.begin();
    rep(i,k-1) itr++;

    cout << *itr << endl;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
//typedef long long int ll;
using namespace std;
using ll = long long;
using ld = long double;
using Vc = vector <char>;
using Vs = vector <string>;
using Vll = vector <ll>;
using Vi = vector <int>;
using Sll = set <ll>;
using Ss = set <string>;
using Sc = set <char>;
using Si = set <int>;
using MiVi = map<int,Vi>;
using MllVll = map<ll,Vll>;
using Mllll = map<ll,ll>;
using Mii = map<int,int>;
using MllSll = map<ll,Sll>;
using Mlls = map<ll,string>;
using Pllll = pair<ll,ll>;
using Pii = pair<int,int>;


#define nl cout<<endl
#define ns cout<<" "
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define forAuto(i,x) for(auto i: x)
#define forRange(i,l,h) for(int i=l;i<h;i++)
#define all(x) x.begin(),x.end()
#define append push_back


void vsInput()
{
    #ifndef ONLINE_JUDGE
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
    #endif // ONLINE_JUDGE
}
template<class T1>
ll sum(T1 a){ll ans=0;forAuto(i,a)ans+=i;return ans;}

template<class T>
void printC(T a){forAuto(i,a)cout<<i<<" ";cout<<endl;}

template<class T1,class T2>
void printP(pair<T1,T2> i){cout<<"{"<<i.first<<",";cout<<i.second<<"} ";}

template<class T1,class T2>
void printG(map<T1,T2> a){forAuto(i,a){cout<<i.first<<" -> ";printC(i.second);}}

template<class T1,class T2>
void printWG(map<T1,T2> a){forAuto(i,a){cout<<i.first<<" -> ";forAuto(j,i.second)printP(j);nl;}}

void value() {}
template <class T1, class... T2>
void value(T1& var1, T2&... var2) { cin>>var1; value(var2...); }

void print() {}
template <class T1, class... T2>
constexpr void print(const T1& var1, const T2& ... var2) { cout<<var1;ns; print(var2...); }


template<class T1,class T2>
void printM(map<T1,T2> a){forAuto(i,a){cout<<i.first<<" -> ";cout<<i.second; nl;}}


#define CPN 700007
#define M 1000000007
//const int inf=1e18+5;


//----------------------------CODE----------------------------//
int dp[100002];

int frog(int a[],int n,int i)
{
    int x,b;
    if(i==n-1)
        return 0;
    if(dp[i] != -1)
        return dp[i];
    if(i+2<n)
    {
        x=abs(a[i+1]-a[i])+frog(a,n,i+1);
        b=abs(a[i+2]-a[i])+frog(a,n,i+2);
        return dp[i]=min(x,b);
    }
    else
    {
        return dp[i]=(abs(a[i+1]-a[i])+frog(a,n,i+1));
    }
    
    
}


int main()
{
    memset(dp,-1,sizeof(dp));
    fast;
    //vsInput();
    int n,res;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    res=frog(a,n,0);
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 12188
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
  int N, K, input;
  double ans, temp;
  cin >> N >> K;
  vector<double> p(N);
  for(int i = 0; i < N; i++){
    cin >> input;
    p.at(i) = (double)(input + 1) / 2;
  }
  
  ans = 0;
  for(int i = 0; i < K; i++) ans += p.at(i);
  temp = ans;
  for(int i = K; i < N; i++){
    temp -= p.at(i-K);
    temp += p.at(i);
    ans = max(ans, temp);
  }
  
  printf("%lf\n", ans);
  
  return 0;
  
}

Measured memory_bytes: 1920
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
h = list(map(int, input().split()))

ans = 0

for i in range(len(h)): 
    while h[i] != 0:
        j = i
        while j < len(h) and h[j] != 0:
            j += 1
        for k in range(i, j):
            h[k] -= 1
        ans += 1
print(ans)

Measured memory_bytes: 39920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef unsigned long long Long;

Long f(Long n, Long x) {
  if (n == x) return x;
  Long k = (n + x - 1) / x - 1;
  return 2 * x * k + f(x, n - k * x);
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  Long n, x;
  cin >> n >> x;

  cout << n + f(n - x, x);

}



Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, a;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a % 2 == 1) {
      printf("first\n");
      return 0;
    }
  }
  printf("second\n");
  
  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

int h, m, s;

int main()
{
  rep(_, 3){
    cin >> h >> m >> s;
    int res = -(h * 60 + m) * 60 - s;
    cin >> h >> m >> s;
    res += (h * 60 + m) * 60 + s;
    int rh = res / 3600;
    int rm = (res - rh * 3600) / 60;
    int rs = (res - rh * 3600 - rm * 60) % 60;
    cout << rh << ' ' << rm << ' ' << rs << endl;
  }

  return 0;
}

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

int main(){
  string s;
  int xy[2];
  cin>>s>>xy[0]>>xy[1];
  int j=0;
  vector<int> d[2];
  d[0].push_back(0);
  rep(i,s.size()){
    if(s[i]=='T'){
      j^=1;
      d[j].push_back(0);
    }
    else d[j].back()++;
  }
  rep(i,2){
    vector<bool> v1(16005,false);
    v1[8003]=true;
    rep(k,d[i].size()){
      if(k==0){
	if(i==0){
	  v1[8003+d[0][0]]=true;
	  continue;
	}
	else{
	  v1[8003]=true;
	}
      }
      int x=d[i][k];
      vector<bool> v2(16005,false);
      rep(j,16005){
	if(v1[j]){
	  v2[j+x]=true;
	  v2[j-x]=true;
	}
      }
      v1=v2;
    }
    if(!v1[xy[i]+8003]){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// CHAR_MAX  = 127
// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


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

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }


    return 0;
}


Measured memory_bytes: 888
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()
	t := scanString()

	ss := strings.Repeat(s, (len(t)+len(s)-1)/len(s)+1)

	zarr := Zalgorithm(t + "#" + ss)
	zarr = zarr[len(t)+1:][:len(s)]

	for i := 0; i < len(s); i++ {
		zarr[i] /= len(t)
		if zarr[i] != 0 {
			zarr[i] = 1
		}
	}

	done := make([]bool, len(s))
	memo := make([]int, len(s))
	var dfs func(to int) int
	dfs = func(to int) int {
		if done[to] {
			return -1
		}

		if zarr[to] == 0 {
			return 0
		}

		done[to] = true
		if memo[to] == 0 {
			memo[to] = dfs((to + len(t)) % len(s))
			if memo[to] != -1 {
				memo[to]++
			}
		}
		done[to] = false
		return memo[to]
	}

	ans := 0
	for i := 0; i < len(s); i++ {
		t := dfs(i)
		if t == -1 {
			fmt.Fprintln(wr, -1)
			return
		}
		ans = max(ans, t)
	}

	fmt.Fprintln(wr, ans)
}

// Zalgorithm function
func Zalgorithm(s string) []int {
	n := len(s)
	res := make([]int, n)
	i, j := 1, 0
	for i < n {
		for i+j < n && s[j] == s[i+j] {
			j++
		}
		res[i] = j
		if j == 0 {
			i++
			continue
		}
		k := 1
		for i+k < n && k+res[k] < j {
			res[i+k] = res[k]
			k++
		}
		i += k
		j -= k
	}
	return res
}


Measured memory_bytes: 149760
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
using namespace std;
#define ll long long
ll num[10000005]={0};
void app(){
	for(ll i=1;i<=10000005;i++){
		if(num[i]==0){//没有判断 
			if(i%3==0||i%5==0){//判断出一个不合格 
				for(ll j=i;j<=10000005;j=j+i){
					num[i]=-1;//不能处理 
				}
			}else{
				num[i]=i;
			}
		}
	}
}
int main(){
	ll N;
	ll sum=0;
	app();
	cin>>N;
	for(int i=1;i<=N;i++){
		if(num[i]!=-1){
			sum=sum+num[i];
		}
	}
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 81760
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

	ll T = 1,A=1;
	for(int i = 0; i < n; i++){
		//ll co = max((double)ceil(T/t[i]),(double))ceil(A/a[i]));
		ll x = T/t[i];
		ll y = A/a[i];
		if(T%t[i] != 0) x++;
		if(A%a[i] != 0) y++;
		ll co = max(x,y);
		T = co * t[i];
		A = co * a[i];
	}

	cout << T+A << endl;

	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	int mn=INT_MAX;
	long long int ans=0;
	long long int a[n];
	int i;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ans=a[n-1];
	int cnt=n-2;
	for(i=n-2;i>=0 && cnt>0;i--)
	{
	//	cout<<cnt<<" "<<ans<<endl;
		if(cnt==1)
		{
			ans+=a[i];
			cnt--;
		}
		else
		{
			ans=ans+a[i]+a[i];
			cnt=cnt-2;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 5208
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<double,P> P2;

const double EPS = 1e-7;
P v[3];

double cross(P a, P b){ return imag(conj(a)*b);}

P rotate(P p, double rad){
  double x = real(p) * cos(rad) - imag(p) * sin(rad);
  double y = real(p) * sin(rad) + imag(p) * cos(rad);
  return P(x,y);
}

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  return m.first + B / A * (m.second - m.first);
}

double areaV(){
  double sum = 0.0;
  for(int i=0;i<3;i++) sum += (real(v[i]) - real(v[(i+1)%3])) * (imag(v[i]) + imag(v[(i+1)%3]));
  return abs(sum) / 2.0;
}

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

P2 check2(P2 p, int pos){
  double le = 0.1, ri = 2.0 * areaV() / (abs(v[1]-v[0]) + abs(v[2]-v[1]) + abs(v[0]-v[2]));
  L l[2];
  P2 res;
  for(int i=0;i<1000;i++){
    double mid = (le + ri) / 2.0;

    for(int j=pos;j<pos+2;j++){
      P a = (v[(j+1)%3]-v[j%3]) * mid / abs(v[(j+1)%3]-v[j%3]);
      P b = rotate(a, M_PI/2.0);
      l[j-pos] = L(v[(j+1)%3]+b, v[j%3]+b);
    }
    res = P2(mid, crossPoint(l[0],l[1]));

    if(equal(abs(res.second-p.second), res.first+p.first)) return res;
    else if(abs(res.second-p.second) < res.first+p.first) ri = mid;
    else le = mid;
  }
}

int check(double r, int pos){
  L l[2];
  P2 p[3];
  for(int i=0;i<2;i++){
    P a = (v[i+1]-v[i]) * r / abs(v[i+1]-v[i]);
    P b = rotate(a, M_PI/2.0);
    l[i] = L(v[i+1]+b, v[i]+b);
  }
  p[0] = P2(r, crossPoint(l[0],l[1]));


  for(int i=1;i<3;i++) p[i] = check2(p[0], i);

  if(pos == 999 || equal(abs(p[2].second-p[1].second), p[2].first+p[1].first)){
    printf("%.6f %.6f %.6f\n",p[2].first, p[0].first, p[1].first);
    return 1;
  }
  else if(abs(p[2].second-p[1].second) < p[2].first+p[1].first) return 2;
  else return 0;
  
}

void solve(){
  double le = 0.1, ri = 2.0 * areaV() / (abs(v[1]-v[0]) + abs(v[2]-v[1]) + abs(v[0]-v[2]));
  for(int i=0;i<1000;i++){
    double mid = (le + ri) / 2.0;
    int res = check(mid,i);
    if(res == 0) ri = mid;
    else if(res == 2) le = mid;
    else return;
  }
}

int main(){
  int x[3],y[3];
  while(cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] && (x[0]|y[0]|x[1]|y[1]|x[2]|y[2])){
    for(int i=0;i<3;i++) v[i] = P((double)x[i], (double)y[i]);
    solve();
  }
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
const int n = 4 * 1e3;
long long dp[n][2];
int main() {
	int c;
	cin>>c;
	int A[c + 1];
	rep(i, 1, c + 1)
		cin>>A[i];
	for(int i = c; i >= 1; i--) {
		dp[i][0] = A[i];
		for(int j = i + 1; j <= c; j++) {
			if(A[i] + dp[j][1] >= A[j] + dp[j - 1][1]) {
				long long tem = dp[j][0];
				dp[j][0] = A[i] + dp[j][1];
				dp[j][1] = tem;
			}
			else {
				dp[j][0] = A[j] + dp[j - 1][1];
				dp[j][1] = dp[j - 1][0];
			}
		}
	}
	cout<<dp[c][0]-dp[c][1]<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

H_l = list(map(int, input().split()))

chk_l = [0 for i in range(N)]

for i in range(M):
	road_l = list(map(int, input().split()))
	left_h = road_l[0]-1
	right_h = road_l[1]-1

	if(H_l[left_h] > H_l[right_h]):
		chk_l[right_h] -= 1
	elif(H_l[left_h] < H_l[right_h]):
		chk_l[left_h] -= 1
	else:
		chk_l[left_h] -= 1
		chk_l[right_h] -= 1

cnt = 0
for i in range(N):
	if(chk_l[i] == 0):
		cnt += 1

print(cnt)

Measured memory_bytes: 20128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif
const int N=100005;
int r[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int X,k,q,a,b,x,y;
  int lans,rans;
  cin>>X>>k;
  rep(i,1,k+1)
    cin>>r[i];
  r[++k]=1e9+10;
  //calculate a,b,c for t=0
  a=lans=0,b=rans=X;
  cin>>q;
  int ind=1;
  while(q--)
    {
      cin>>x>>y;//x is time
      while(ind<=k && x>r[ind])
	{
	  int diff=r[ind]-r[ind-1];
	  if(ind&1)//x s.t x+lans-a-diff=0
	    {
	      a=max(a,min(b,a+diff-lans));
	      lans=max(0,lans-diff);
	      rans=max(0,rans-diff);
	    }
	  else//x s.t x+rans-b+diff=X
	    {
	      b=min(b,max(a,X+b-rans-diff));
	      lans=min(X,lans+diff);
	      rans=min(X,rans+diff);
	    }
	  ind++;
	}
      int diff=x-r[ind-1];
      int ans;
      if(y<=a)
	{
	  if(ind&1) ans=max(0,lans-diff);
	  else ans=min(X,lans+diff);
	}
      else if(y>=b)
	{
	  if(ind&1) ans=max(0,rans-diff);
	  else ans=min(X,rans+diff);
	}
      else
	{
	  if(ind&1) ans=max(0,y-a+lans-diff);
	  else ans=min(X,y-a+lans+diff);
	}
      cout<<ans<<endl;
    }
  return 0 ;
}


Measured memory_bytes: 1664
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a / b + (a % b != 0));
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
import re
import math
import itertools
import collections
import bisect
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.141592653589
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

class UnionFind:
    def __init__(self, size):
        self.rank=[0]*size
        self.par =range(size)
        self.grp =size

    def find(self, x):
        if x==self.par[x]: return x

        self.par[x]=self.find(self.par[x])
        return self.par[x]

    def same(self, x, y): #2つの頂点が同じグループであるかを判定する
        return self.find(x)==self.find(y)

    def unite(self, x, y): #辺で接続されている2つの頂点を投げて統合する
        x,y=self.find(x),self.find(y)
        if x==y:
            return

        self.grp-=1
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def group_num(self):
        return self.grp
    def ra(self):
        return self.par

n,k,l=map(int,raw_input().split())
uf=UnionFind(n)
uf2=UnionFind(n)
ans=[1]*n

for i in range(k):
    a,b=map(int,raw_input().split())
    uf.unite(a-1,b-1)

for i in range(l):
    a,b=map(int,raw_input().split())
    uf2.unite(a-1,b-1)

q1=uf.ra()
q2=uf2.ra()
d={}
for i in range(n):
    while 1:
        if q1[i]!=q1[q1[i]]:
            q1[i]=q1[q1[i]]
        else:
            break
    while 1:
        if q2[i]!=q2[q2[i]]:
            q2[i]=q2[q2[i]]
        else:
            break

for i in range(n):
    if (q1[i],q2[i]) in d:
        d[(q1[i],q2[i])]+=1
    else:
        d[(q1[i],q2[i])]=1
for i in range(n):
    print d[(q1[i],q2[i])],

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

#define ll long long int
#define pi pair<ll,ll>


int main()
{

    int n, m;
    cin >> n >> m;
    int ans = 0;
    vector<ll> v(n);
    for (int i = 0; i < n; i += 1)
    {
        cin >> v[i];
    }

    ll sum = accumulate(v.begin(), v.end(), 0LL);
    for (int i = 0; i < n; i += 1)
    {
        if (v[i]*4*m >= sum)
            ans += 1;
    }

    if (ans >= m)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int count = 0;
	for (int i = 0; i < n; i++) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

#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 EPS (1e-7)
#define INF 1e18

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int MAX_N=300;

int main(){
	string s[2];
	REP(i,2)cin>>s[i];
	REP(i,3){
		if(s[0][i]==s[1][2-i])continue;
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split())
house_list = list(map(int, input().split()))
for i in range(n):
  house_list.append(house_list[i] - k)
tmp_list = sorted(house_list)
ans_list = []
for j in range(n + 1):
  ans_list.append(tmp_list[j + n - 1] - tmp_list[j])
print(min(ans_list))

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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
   //cin t;
   while(t--){
            ll a , b , c , d;
            cin >> a >> b >> c >> d;
            ll ans = 0;
            if(d!=0)
            {
                ans += min(a , d);
                d -= min(a , d);
            } 
            if(d!=0)
            {
                d-=min(b , d);
            }
            if(d!=0)
            {
                ans -= min(c, d);

            }
            cout << ans << endl;
   }
}


Measured memory_bytes: 3548
#nは問題数　mは提出した回数　
n,m = map(int,input().split())
submit = []
check = [0] * n

for x in range(m):
    a,b = input().split()
    a = int(a)
    x = [a,b]
    submit.append(x)

o = 0
x = 0


for y in submit:
    if check[y[0]-1] == 0:
        if y[1] == "AC":
            o += 1
            check[y[0]-1] = 1
        elif y[1] == "WA":
            x += 1

for z in submit:
    if check[z[0]-1] == 0:
        if z[1] == "WA":
            x -= 1


print(o,x)


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

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second
#define xmax(x,y) ((x) = max((x),(y)))
#define xmin(x,y) ((x) = min((x),(y)))
#define all(x) (x).begin(),(x).end()
#define mem(x) memset(x , 0 , sizeof(x))
#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define FP(a , b , c)  for(ll (a) = (b) ; (a) < (c) ; (a++));
#define FM(a , b , c)  for(ll (a) = (b) ; (a) >= (c) ; (a--));
#define connect(a , b , c) a[b].pb(c) , a[c].pb(b)

typedef long long int ll;
typedef unsigned long long int ull;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector <ll> vl;
typedef vector <int> vi;
typedef vector <string> vs;

const ll Maxn3 = 1e3 + 10;
const ll Maxn4 = 1e4 + 10;
const ll Maxn5 = 1e5 + 10;
const ll Maxn6 = 1e6 + 10;
const ll Maxn7 = 1e7 + 10;
const ll Maxn8 = 1e8 + 10;
const ll Maxn9 = 1e9 + 10;
const ll Maxn18 = 1e18 + 10;
const ll Mod1 = 1e7 + 7;
const ll Mod2 = 1e9 + 7;
const ll LLMax = LLONG_MAX;
const ll LLMin  = LLONG_MIN;
const ll INTMax = INT_MAX;
const ll INTMin  = INT_MIN;

ll mn = LLMax , mx = LLMin;

int main()
{_
    ll a , b , x; cin >> a >> b >> x;
    return cout << (a <= x and x <= a+b ? "YES" : "NO") , 0;
}
///SAliB


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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  void solve(std::istream& in, std::ostream& out)
  {
    int n;
    in >> n;
    vector<int> a(n);
    for(auto&& i : a) {
      in >> i;
    }
    int now = 0;
    sort(a.begin(), a.end());
    vector<int> cnt;
    for (auto&& i : a) {
      if(now != i) {
        cnt.push_back(1);
        now = i;
      } else {
        cnt[cnt.size() - 1]++;
      }
    }
    int c = 0;
    bool flag = false;
    for (auto&& i : cnt) {
      while(i > 1) {
        if(i >= 3) {
          i -= 2;
          c++;
        } else {
          i--;
          c += !flag;
          flag = !flag;
        }
      }
    }
    int ans = n - c * 2;
    out << ans << "\n";
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




Measured memory_bytes: 1276
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if((i % 2 == 0 && s[i] == 'L')
                || (i % 2 == 1 && s[i] == 'R')){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] s = Console.ReadLine().Split(' ');

            int W, H, x, y, r;
            W = int.Parse(s[0]);
            H = int.Parse(s[1]);
            x = int.Parse(s[2]);
            y = int.Parse(s[3]);
            r = int.Parse(s[4]);

            if (x - r < 0 || x + r > W || y - r < 0 || y + r > H)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}

Measured memory_bytes: 8896
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  if (n >= 10) {
    cout << r;
  } else {
    r += 100 * (10 - n);
    cout << r;
  }
  return 0;
}


Measured memory_bytes: 256