akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

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

struct edge { 
    ll to;//行き先の頂点
    ll cap;//辺の容量
    ll cost;//１フローあたりのコスト
    ll rev;//逆辺のインデックス(G[e.to][e.rev]で逆辺にアクセスできる。)
};

#define MAX_V 1000
#define INF (1e9)

ll V;//頂点数 ここに頂点数をセットするのを忘れないように。
vector<edge> G[MAX_V];
ll h[MAX_V]; //ポテンシャル
ll dist[MAX_V];//sから各頂点への最短距離
ll prevv[MAX_V],preve[MAX_V]; // 直前の頂点と辺

void add_edge(ll from,ll to,ll cap,ll cost) {
    G[from].push_back((edge){to,cap,cost,(ll)G[to].size()});//辺の追加
    G[to].push_back((edge){from,0,-cost,(ll)G[from].size() - 1});//辺の逆辺
}

// 最小費用流を求める(sからt)
// 流せない場合はINFをかえす。

ll min_cost_flow (ll s,ll t,ll f) {
    ll ret = 0;
    fill(h,h + V,0); // hを初期化 h_-1(v)=0とする。

    //f_0の残余ネットワークはもとのグラフ

    while(f > 0) {
        //現在f_iの残余ネットワークにおけるs-v最短路h_iを求める。
        //蟻本よりポテンシャルとしてh_i-1を使っても良い
        priority_queue<P,vector<P>,greater<P> > que;
        fill(dist,dist + V,INF);
        dist[s] = 0;
        que.push(P(0,s));
        while(!que.empty()) {
            P p = que.top(); que.pop();
            ll v = p.second;//頂点番号
            if(dist[v] < p.first) continue;//すでに最小値が求まっていた。
            rep(i,G[v].size()) {
                edge &e = G[v][i];
                if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    que.push(P(dist[e.to],e.to));
                } 
            }
        }

        if(dist[t] == INF) {
            //正のフローを流せるs-t道がなかった
            return -1;
        }
        rep(v,V) h[v] += dist[v];//INFのオーバーフローに注意
        //h_i(v) = (上で求まった最短距離)+h_i-1(v)-h_i-1(s)
        //で今、負の閉路が無いのでh_i-1(s)=0となるのでこのような式となる。

        //続いてf_i+1の残余ネットワークを求めていく。
        //f_i残余ネットワークにおけるs-t間最短路に沿って目一杯流す(上で求めたh_iよりわかる)
        ll d = f;//新たに流すフローの量を求める。
        for(ll v = t;v != s;v = prevv[v]) {//t側から更新していく
            d = min(d,G[prevv[v]][preve[v]].cap);//パスの容量を求めている
        }
        f -= d;
        ret += d * h[t];//総費用の更新
        //h_i(t)はf_i残余ネットワークにおけるs-t間最短距離
        for(ll v = t;v != s;v = prevv[v]) {//残余ネットワークの更新
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return ret;
}

ll E,F;

int main() {
    cin >> V >> E >> F;
    rep(i,E) {
        ll u,v,c,d;
        cin >> u >> v >> c >> d;
        add_edge(u,v,c,d);
    }
    cout << min_cost_flow(0,V-1,F) << endl;;
    return 0;
    
}


Measured memory_bytes: 3308
a,b=map(int,input().split())
a=max(0,a-1)

if a%4==0:
    a=a
elif a%4==1:
    a=1
elif a%2==0:
    a=a+1
else:
    a=0
if b%4==0:
    b=b
elif b%4==1:
    b=1
elif b%2==0:
    b=b+1
else:
    b=0
print(a^b)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"os"
)

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	var a, b, c, d, e, k int

	fmt.Fscan(fp, &a, &b, &c, &d, &e, &k)

	if k >= e-a {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}

}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e15;

int main(){
    ll k;
    cin >> k;
    ll a,b;
    cin>> a >> b;
    bool ok=false;
    for(ll i=1;i<=1000;i++){
        if(a<=i && i<=b && i%k==0){
            ok=true;
            break;
        }
    }
    if(ok) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll x,cnt = 1;
    cin >> x;
    double store = 100;
    while(1){
        store *= 1.01;
        if(store >= x){
            cout << cnt << endl;
            break;
        }
        store = floor(store);
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define max 100005
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    string s;
    cin>>s;
    rep(i,3){
        if(s[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;

    vector<int> a;
    vector<int> b;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == '0')
        {
            int start = i;
            while(s[i] == '0' && i < n)
            {
                i++;
            }
            a.push_back(i-start);
          i--;
        }
        else if(s[i] == '1')
        {
            int start = i;
            while(s[i] == '1' && i < n)
            {
                i++;
            }
            b.push_back(i-start);
          i--;
        }
    }
    int ans = 0;
    int as = a.size();
    int bs = b.size();
    if(as <= k)
    {
        cout << n << endl;
        return 0;
    }
    if(s[0] == '1')
    {
        int tmp = 0;
        for(int i = 0; i < k; i++)
        {
            tmp += a[i];
            tmp += b[i];
        }
        if(bs > k) tmp += b[k];
        ans = tmp;
        int start = k-1;
        while(start < as)
        {
            start++;
            if(start == as) break;
            tmp = tmp - a[start-k] - b[start-k];
            tmp += a[start];
            ans = max(tmp, ans);
            if(bs > start + 1)
            {
                tmp += b[start+1];
                ans = max(ans, tmp);
            }
            else break;
        }
    }

    if(s[0] == '0')
    {
        int tmp = 0;
        for(int i = 0; i < k; i++)
        {
            tmp += a[i];
            tmp += b[i];
        }
        ans = tmp;
        int start = k-1;
        while(start < as)
        {
            start++;
            if(start == as) break;
            if(start == k)
            {
                tmp = tmp - a[start-k];
            }
            else
            {
                tmp = tmp - a[start-k] - b[start-k-1];
            }
            tmp += a[start];
            ans = max(tmp, ans);
            if(bs > start)
            {
                tmp += b[start];
                ans = max(ans, tmp);
            }
            else break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1020
N, K = map(int, input().split())
A=list(map(int, input().split()))

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

#Aの数をlで表現
for i in range(N):
  l[A[i]-1] += 1
#lを昇順にソート
l=sorted(l)

ans=0
#なって欲しい数になっていない数の種類はN-K
#それらの玉の数を足す
for i in range(N-K):
  ans += l[i]
print(ans)

Measured memory_bytes: 32228
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll x[100], y[100], z[100], w[100];

void solve(){
    cin >> n >> m;
    if(n % 2 == 1){
        ll a = 2, b = n;
        for(ll i=0;i<m;i++){
            pe(a);p(b);
            a ++; b --;
        }
    }else{
        ll a = 1, b = n;
        for(ll i=0;i<m;i++){
            pe(a);p(b);
            a ++; b --;
            if(b - a == n / 2 || b - a == n / 2 - 1){
                b--;
            }
        }

    }
    return;
}


int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 3664
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

//main.cpp----------------------------


void solve();

string n;
map<char, int> mp;

int main() {
  cin >> n;

  solve();

  return 0;
}

void solve() {

  rep(i, 4) {
    mp[n[i]] += 1;
  }

  cout << mp['2'] << endl;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


#hashでカウンタを格納する
#ソートして、要素がインクリメントされない箇所を検出する: → 要素がaa

s = input()

h = {"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}

for i in s:
    h[i] += 1

#print(h)
for k,v in h.items():
    if (v == 0):
        print(k)
        exit()

print("None")



Measured memory_bytes: 9028
import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.Map as M
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  n <- readLn
  putChar ' '
  putStrLn $ unwords $ map show $ solve n

solve :: Int -> [Int]
solve n = [ i | i <- [1..n], i `rem` 3 == 0 || i `has` 3 ]
  where
    x `has` k
      | r == k    = True
      | q == 0    = False
      | otherwise = q `has` k
      where (q, r) = x `quotRem` 10



Measured memory_bytes: 4136
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0524?year=2008

#include <bits/stdc++.h>

using namespace std;

int main() {
    int m;

    while (true) {
        cin >> m;
        if (m == 0) return 0;

        vector<pair<int, int>> constellation(m);//星座
        for (int i = 0; i < m; ++i) {
            cin >> constellation[i].first >> constellation[i].second;
        }
        sort(constellation.begin(), constellation.end());

        int dx[m - 1], dy[m - 1];//星座の変位のパターン
        for (int i = 0; i < m - 1; ++i) {
            dx[i] = constellation[i + 1].first - constellation[i].first;
            dy[i] = constellation[i + 1].second - constellation[i].second;
        }

        int n;
        cin >> n;
        vector<pair<int, int>> stars(n);//星
        for (int i = 0; i < n; ++i) {
            cin >> stars[i].first >> stars[i].second;
        }

        for (int i = 0; i < n; ++i) {//出発点
            bool flag = true;

            int x = stars[i].first;
            int y = stars[i].second;
            for (int j = 0; j < m - 1; ++j) {
                x += dx[j];
                y += dy[j];
                if (find(stars.begin(), stars.end(), make_pair(x, y)) == stars.end()) {
                    flag = false;
                    break;
                }
            }

            if (flag) {
                int ans_x = stars[i].first - constellation[0].first;
                int ans_y = stars[i].second - constellation[0].second;
                cout << ans_x << " " << ans_y << endl;
            }
        }
    }
}

/*
 * 星座から各星をむすぶパターンを作り，それを星々にあてはめる。
 */


Measured memory_bytes: 2996
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,l,a[100010];
signed main(){
	cin>>n>>l;
	rep(i,n)cin>>a[i];
	rep(i,n-1){
		if(a[i]+a[i+1]>=l){
			puts("Possible");
			for(int j=1;j<=i;j++)cout<<j<<endl;
			for(int j=n-1;j>i;j--)cout<<j<<endl;
			return 0;
		}
	}
	puts("Impossible");
	return 0;
}

Measured memory_bytes: 1536
#getting input from user
#cranes and turtle already give the information
#condition yes or no 
X,Y= map(int,input().split())
cranes= 2 # assign 2 to cranes
turtles= 4 # assign 4 to turtle
ans="No"
for i in range(X+1): 
    b=X-i
    if cranes*i + turtles*b == Y:
        ans = "Yes"
print(ans)

# Time complixity O(X)

Measured memory_bytes: 9144
N = int(input())
  
countAC=0
countWA=0
countTLE=0
countRE=0
for i in range(0,N):
        val = input()
        if val=="AC":
                countAC=countAC+1
        elif val=="WA":
                countWA=countWA+1
        elif val=="TLE":
                countTLE=countTLE+1
        elif val=="RE":
                countRE=countRE+1
        else:
                break
print("AC x "+str(countAC))
print("WA x "+str(countWA))
print("TLE x "+str(countTLE))
print("RE x "+str(countRE))

Measured memory_bytes: 9208
import sys
sys.setrecursionlimit(int(1e6))

def search(x, num):
    nodes.remove(x)
#     for y in edge[x]:
    for y in list(edge[x]):
        edge[y].remove(x)
        if y in nodes:
            num = search(y, num)
    return num + 1

(n,m),*d  = [list(map(int, s.split())) for s in open(0)]

edge = [set() for _ in range(n+1)]
for x in d:
    edge[x[0]].add(x[1])
    edge[x[1]].add(x[0])

nodes = set(range(1,n+1))
ans = 1
for x in list(nodes):
    if x in nodes:
        ans = max(ans, search(x, 0))
print(ans)

Measured memory_bytes: 291436
#include <iostream>
#include <string>
#include <limits.h>
#include <math.h>
using namespace std;
typedef long long ll;

ll max2(ll x, ll y) {
    if (x > y) return x;
    else return y;
}

int main(void){
    ll n;
    cin >> n;
    
    ll min = 1e10;
    for (int i = 1; i < 1e5 && i <= n; i++) {
        if (n % i == 0) {
            int id = 0, jd = 0;
            while (i >= pow(10, id)) id++;
            while (n / i >= pow(10, jd)) jd++;
            if (min > max2(id, jd)) min = max2(id, jd);
        }
    }
    
    cout << min << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;

const int nmax=12;
int l,r[nmax],n;

void solve(){
  sort(r,r+n);
  deque<int> rr;
  bool f=true;
  for(int i=0;i<n/2;i++){
    if(f){
      rr.push_front(r[i]);
      rr.push_back(r[n-i-1]);
      f=false;
    }
    else {
      rr.push_front(r[n-i-1]);
      rr.push_back(r[i]);
      f=true;
    }
  }
  
  if(n==1){
    rr.push_front(r[0]);
  }
  else if(n%2==1){
    if(rr[0]>rr[n-2])rr.push_front(r[n/2]);
    else rr.push_back(r[n/2]);
  }

  double sum=rr[0]+rr[n-1];
  for(int i=0;i<n-1;i++){
    sum+=2*sqrt(rr[i]*rr[i+1]);
  }
  if(sum<=l)cout<<"OK"<<endl;
  else cout<<"NA"<<endl;
}

int main(){
  char c;
  while(cin>>l){
    n=0;
    while(~(c=getchar())){
      if(c=='\n')break;
      else if(c==' ')cin>>r[n++];
    }
    solve(); 
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 30);
typedef pair<ll,ll> pii;
typedef vector<vector<ll>> Graph;
typedef vector<pii> vpii;

int v[1<<26];

int main() {
  string s; cin>>s;
  for (ll i=0;i<(1<<26);i++) v[i]=INF;
  int cur=0; v[cur]=0;
  for(char c:s) {
    c-='a';
    cur^=(1<<c);
    int mi=v[cur];
    for(int i=0;i<26;i++) {
      mi=min(mi,v[cur^(1<<i)]);
    }
    v[cur]=min(mi+1,v[cur]);
  }
  cout<<max(1,v[cur])<<endl;
}


Measured memory_bytes: 262660
a = "abcdefghijklmnopqrstuvwxyz"
A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
dic = dict(zip(A,a))

w = input()
tex = []
while(1):
    t = input()
    if t == "END_OF_TEXT":
        break
    tex.extend(t.split())
c = 0
tex_ = []
for i in tex:
    i = list(i)
    for j in range(len(i)):
        if i[j] in A:
            i[j] = dic[i[j]]
    tex_.append("".join(i))
for i in tex_:
    if i == w:
        c += 1
print(c)


Measured memory_bytes: 5564
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <bitset>
using namespace std;

const int MAXN = 4e6 + 10;
int N;
int A[MAXN];
bitset<MAXN> f;
int sum;

int main() {
	register int i;
	scanf("%d", &N);
	f[0] = 1;
	for(i = 1; i <= N; ++i)
		scanf("%d", A + i), sum += A[i], f |= f << A[i];
	for(sum = (sum + 1) / 2; !f[sum]; ++sum);
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll gcd(ll x, ll y)
{
    ll r;
    while((r = x % y) != 0) 
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x, ll y){
    return (x*y)/gcd(x,y);
}


int main(void){
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    ll e=B/C;
    ll f=B/D;
    ll g=B/lcm(C,D);
    ll h=e+f-g;
    ll i=(A-1)/C;
    ll j=(A-1)/D;
    ll k=(A-1)/lcm(C,D);
    ll l=i+j-k;
    ll ans=B-A+1-(h-l);
    /* cout<<e<<" "<<f<<" "<<g<<" "<<h<<" "<<l<<endl;*/
    cout<<ans<<endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int N, K; cin >> N >> K;
  vi h(N);
  rep(i, N) cin >> h[i];

  vi dp(N+K, INFL);
  dp[0] = 0;
  rep(i, N) {
    rep(j, K) {
      dp[i+1+j] = min(dp[i+1+j], dp[i] + abs(h[i] - h[i+1+j]));
    }
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
n,x=map(int,input().split());a=list(map(int,input().split()));ans=0
for i in range(n-1):
  m=a[i]+a[i+1]
  if a[i]>=x:a[i+1]=0;a[i]=x
  else:a[i+1]=min(x-a[i],a[i+1])
  ans+=m-a[i]-a[i+1]
print(ans)

Measured memory_bytes: 14252
n = int(input())
s, t = [],[]
for _ in range(n):
    s.append(input())
s_dict = {s_:0 for s_ in s}
s_dict['aaaaaaaaaaa'] = 0
m = int(input())
for _ in range(m):
    t.append(input())
t_dict = {t_:0 for t_ in t}
for i in range(n):
    s_dict[s[i]] += 1
for i in range(m):
    t_dict[t[i]] += 1
    
for i in s_dict:
    if i in t_dict:
        s_dict[i] -= t_dict[i]
        
print(max(s_dict.values()))

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

using namespace std;

const long long mo = 1e9+7;
const int maxi = 1e6+10;
#define pb push_back
int n,k;
string s;
vector<int> v[maxi];
int a[maxi];
int cnt[maxi];

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


    int otvoreni = 1;
    int par = 0;
    long long ans = 1;
    for (int i=1;i<2*n;i++)
    {
        if (s[i]=='B') par = 1; else par = 0;

        if ((otvoreni&1) == (par&1))
        {
            ans*=1ll*otvoreni;
            ans%=mo;
            otvoreni--;
        } else
        {
            otvoreni++;
        }

        if (otvoreni<0) return !printf("0\n");
    }

    if (otvoreni) return !printf("0\n");

    for (int i=1;i<=n;i++)
    {
        ans*=1ll*i;
        ans%=mo;
    }
    printf("%lld\n",ans);

    return 0;
}
//ja bih da pevam jos malo
//jer je zivot samo jedan
//i do njega mi je stalo
//meni je vredan


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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  bool ok = false;

  for (int row = 0; row <= n; row++) {
    for (int column = 0; column < m; column++) {
      int black = row * m + column * n - row * column * 2;
      if (black == k) ok = true;
    }
  }

  if (ok)
    puts("Yes");
  else
    puts("No");

  return 0;
}


Measured memory_bytes: 3640
r,c=map(int,input().split())
A=[]
for i in range(r):
    *Ai,=map(int,input().split())
    Ai.append(sum(Ai))
    A.append(Ai)
B=[sum([A[i][j] for i in range(r)]) for j in range(c+1)]
for a in A:
    print(*a)
print(*B)


Measured memory_bytes: 6232
/// WA

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type,
less<T>, rb_tree_tag, 
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    if (n == m)
        cout << "Yes";
    else
        cout << "No";        
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long;

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    char c; cin >> c;

    char m[10] = {"aiueo"};

    for (int i=0; i<5; i++)
    {
        if (c==m[i])
        {
            cout << "vowel" << "\n";
            return 0;
        }
    }

    cout << "consonant" << "\n";
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	size_t a{0};
	string s = "";
	cin >> a >> s;
	if (a >= 2800 && a < 5000) {
	if (a < 3200) cout << "red" << endl;
	else cout << s << endl;
	} else return 0;
}


Measured memory_bytes: 256
from collections import deque

K = int(input())
d = deque([1,2,3,4,5,6,7,8,9])
ansq = deque([1,2,3,4,5,6,7,8,9])

while len(ansq)<=K:
    num = d.popleft()

    if str(num)[-1] == "0":
        da = num*10
        db = num*10+1
        d.append(da)
        d.append(db)
        ansq.append(da)
        ansq.append(db)
        continue

    if str(num)[-1] == "9":
        da = num*10+8
        db = num*10+9
        d.append(da)
        d.append(db)
        ansq.append(da)
        ansq.append(db)
        continue

    da = num*10+int(str(num)[-1])-1
    db = num*10+int(str(num)[-1])
    dc = num*10+int(str(num)[-1])+1
    d.append(da)
    d.append(db)
    d.append(dc)
    ansq.append(da)
    ansq.append(db)
    ansq.append(dc)


print(ansq[K-1])

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

int main(){
	int x,y;
	cin>>x>>y;
  	if(x==2||y==2){
      cout<<"No"<<endl;
      	return 0;
    }
  	(x==4||x==6||x==9||x==11)?x=0:x=1;
  	(y==4||y==6||y==9||y==11)?y=0:y=1;
	if(x+y==0||x+y==2)cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
  	return 0;
}

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

Measured memory_bytes: 7384
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int mod=998244353;

int n;
pair<int,int> a[200010];
int sledeci[200010];
int dp[200010][2];
int seg[1000010];

int add(int a, int b)
{
    int ret=a+b;
    if(ret>=mod) ret-=mod;
    return ret;
}

void dodaj(int t, int l, int r,int x, int val)
{
    seg[t]=max(seg[t],val);
    if(l==r)
        return;
    int mid=(l+r)/2;
    if(x<=mid) dodaj(2*t,l,mid,x,val);
    else dodaj(2*t+1,mid+1,r,x,val);
}

int maxq(int t, int l, int r, int L, int R)
{
    if(l>R || L>r) return 0;
    if(l>=L && r<=R) return seg[t];
    int mid=(l+r)/2;
    int r1=maxq(2*t,l,mid,L,R);
    int r2=maxq(2*t+1,mid+1,r,L,R);
    return max(r1,r2);
}

int nadji(int i)
{
    int val=a[i].first+a[i].second;
    int l=i;
    int r=n-1;
    while(l<r)
    {
        int sr=(l+r+1)/2;
        if(a[sr].first>=val) r=sr-1;
        else l=sr;
    }
    //cout<<"*"<<i<<" "<<r<<endl;
    return maxq(1,0,n-1,i,r);
}

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

	cin>>n;
	for(int i=0;i<n;i++)
        cin>>a[i].first>>a[i].second;

    sort(a,a+n);

    dp[n][0]=1;
    for(int i=0;i<n;i++)
        dodaj(1,0,n-1,i,i+1);
    for(int i=n-1;i>=0;i--)
    {
        dp[i][0]=add(dp[i+1][0],dp[i+1][1]);
        int index=nadji(i);
        dp[i][1]=add(dp[index][0],dp[index][1]);
        //sledeci[i]=index;
        dodaj(1,0,n-1,i,index);

        //cout<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<" "<<index<<endl;
    }
    cout<<add(dp[0][0],dp[0][1]);
	return 0;
}


Measured memory_bytes: 7936
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<deque>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
using namespace std;
char s[10];
int main()
{
     scanf("%s",s);
     bool flag=false;
     for(int i=0;i<=1;i++)
     {
          if(s[i]==s[i+1]&&s[i+1]==s[i+2])
          {
               flag=true;
               break;
          }
     }
     if(flag)
     {
          cout<<"Yes"<<endl;
     }
     else cout<<"No"<<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 ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	ll now = 0;
	ll ans = 0;
	rep(i,n)
	{
		if(s[i]!='W')break;
		now++;
	}
	rep(i,n-1)
	{
		if(s[i]=='B'&&s[i+1]=='W')
		{
			ans += i+1-now;
			now ++;
			s[i+1]='B';
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> vs;

int main(void){
	map <char, int> m;
	int num[] = {1,5,10,50,100,500,1000};
	for (int i=0; i<7; i++)
		m["IVXLCDM"[i]] = num[i];

	char c;
	string r;
	while (cin>>r){
		int tmp, tmp2= m[r[0]],s=0;
		int n=r.size();
		for (int i=0; i<n; i++){
			tmp = m[r[i]];
			if (tmp2<tmp)
				s-= tmp2*2;
			s += tmp;
			tmp2 = tmp;
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
map<int,int> f;
map<int,bool> us;
map<int,int> ds;
map<int,bool> us2;


int find(int val){
	if(ds[val]!=val+1)
	return ds[val]=find(ds[val]-1);
	else
	return val+1;
}

void add(int uno,int due){
	ds[find(uno)-1]=ds[find(due)-1];
}



int main(){
int n;
cin>>n;
int v[n],v1[n];
int temp=0;
for(int i=0;i<n;i++){
	cin>>v[i];
	temp^=v[i];
	
	f[v[i]]++;
}
//cout<<temp<<endl;
f[temp]++;
int cont=0;
bool ok=true;
int temp2=0;
for(int i=0;i<n;i++){
	cin>>v1[i];
	temp2^=v1[i];
	us[v1[i]]=true;
	f[v1[i]]--;
	if(f[v1[i]]<0){
		cont++;
	}
	if(cont>1){
		ok=false;
		break;
	}
}
f[temp2]--;
	if(f[temp2]<0){
		cont++;
	}
	if(cont>1){
		ok=false;
	}

if(ok){
	int ans=1;
	if(us[temp]==true)
	ans--;
	//cout<<ans<<endl;
	int comp=0;
	int indice=-1;
	for(int i=1;i<=n;i++){
		if(us[v[i-1]]==false){
			//cout<<i-1<<" "<<v[i-1]<<endl;
		v[i-1]=temp;
		
		indice=i-1;
		}
		if(ds[v[i-1]]==0)
		ds[v[i-1]]=v[i-1]+1;
		
		if(v[i-1]!=v1[i-1]&&us2[v[i-1]]==false){
			us2[v[i-1]]=true;
			comp++;
		}
		if(v[i-1]!=v1[i-1])
		ans++;	
	}
	if(indice!=-1&&us2[v[indice]]==false){
	comp++;
	ans++;
	}
	
	//cout<<comp<<" "<<ans<<endl;
	if(comp==0){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		if(find(v[i])!=find(v1[i])){
			add(v[i],v1[i]);
			comp--;
		}
	}
	ans+=comp-1;
	
	cout<<ans<<endl;
	
}
else
cout<<-1<<endl;

return 0;
}


Measured memory_bytes: 29184
#include<stdio.h>

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

	//3????????´??°a,b,c?????\???
	scanf("%d %d %d", &a, &b, &c);

	//a < b < c????????§????????????
	if (a < b && b < c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

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

int main() {
  int D;
  string d;
  cin >> D;
  if(D==22){
    d="Christmas Eve Eve Eve";
  }else if(D==23){
    d="Christmas Eve Eve";
  }else if(D==24){
    d="Christmas Eve";
  }else if(D==25){
    d="Christmas";
  }
  cout << d << endl;
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int n;
	cin >> n;
	if (n <= 44) {
		cout << 2 << " " << 3 << " " << 25 << " ";
		n -= 3;
		int cur = 30;
		while (n) {
			cout << cur << " ";
			cur += 30;
			n -= 1;
		}
	}
	else {
		int cur = 1;
		while (n >= 44) {
			for (int i = cur; i < cur + 60; ++i) {
				if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0)
					cout << i << " ";
			}
			n -= 44;
			cur += 60;
		}
		cur += 29;
		while (n) {
			cout << cur << " ";
			n -= 1;
			cur += 30;
		}
		cout << "\n";
	}
	return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N,count=0;
    string S;
    cin >> 	N;
    cin >> 	S;
    for(int i=0;i<N-2;i++){
        if(S.substr(i,3)=="ABC") count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<utility>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;

int main() {

	int n;

	cin >> n;

	vector<int> p(n);

	int i, j;
	for (i = 0; i < n; i++) cin >> p[i];

	int count = 0;
	int min = p[0];

	for (i = 0; i < n; i++) {
		j = 0;
		if (min >= p[i]) {
			count++;
			min = p[i];
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 1024
using System;

namespace AtCoder
{
    internal static class Program
    {
        private static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] nbrs = new int[N];
            for(int i = 0; i < N; i++)
            {
                nbrs[i] = int.Parse(Console.ReadLine());
            }

            int res = -1;
            int presses = 0;
            int click = 0;

            while(presses < N + 1)
            {
                click = nbrs[click] - 1;
                presses++;
                if (click == 1)
                {
                    res = presses;
                    break;
                }
            }

            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 13280
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll N;
  cin>>N;
  string S,T,L;
  cin>>S>>T;
  FOR(i,N){
    L+=S[i];
    L+=T[i];
  }
  cout<<L<<endl;
      
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    multiset<int, greater<int>> a;
    int ans = 0;
    vector<int> powers;
    ll p = 1;
    while (p <= (2 * 1e9)) {
        powers.push_back(p);
        p *= 2;
    }
    rep(i, n) {
        int tmp;
        cin >> tmp;
        a.insert(tmp);
    }
    auto it = a.begin();
    while(sz(a)) {
        bool deleted = false;
        rrep(i, sz(powers)) {
            if (powers[i] <= *it) break;
            auto itp = a.find(powers[i] - *it);
            if (itp == it) itp++;
            if (itp == a.end()) continue;
            if (*itp == (powers[i] - *it)) {
                a.erase(itp);
                a.erase(it++);
                ans++;
                deleted = true;
                break;
            }
        }
        if (!deleted) a.erase(it++);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
n = int(input())
a = [int(i) for i in input().split()]
a.extend(a)
ans = 0
k = 0
for i in range(n):
    ans += a[i]*(-1)**k
    k += 1
print(ans,end=" ")
for i in range(n-1):
    ans = 2*a[i]-ans 
    print(ans,end=" ")

Measured memory_bytes: 14028
n, k = gets.chomp.split.map(&:to_i)
arr = []
n.times{arr << gets.to_i}
arr2 = []
1.upto(n-1){|i| arr2 << arr[i] - arr[i-1] - 1}
arr2.sort!
sum = n
(n-k).times{|i| sum += arr2[i]}
puts sum


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

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll sum = 0;
  if(a+b>=c*2){
    sum += c*2*min(x,y);
    if(max(x,y) == x){
      sum += min(c*2,a)*abs(x-y);
    }
    else{
      sum += min(c*2,b)*abs(x-y);
    }
  }
  else{
    sum += a*x + b*y;
  }
  cout << sum << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define f(p,n) for(ll i=p;i<n;i++)
ll exp(ll a,ll b,ll m);

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

 	string s1="keyence";
 	string s;
 	cin>>s;

 	if(s==s1)
 	{
 		cout<<"YES"<<endl;
 		return 0;
 	}
 	ll ind=0;

 	ll l=s.length();

 	for(ll j=0;j<l;j++)
 	{
 		for(ll j2=j;j2<l;j2++)
 		{
 			if(l-(j2-j+1)!=7) continue;
 			string ch="";
 		for(ll k=0;k<l;k++)
 		{
 			if(k>=j && k<=j2) continue;

 			ch+=s[k];
 			if(ch==s1)
 			{
 				cout<<"YES"<<endl;
 				return 0;
 			}
 			if(ch.size()>7) break;
 		}
 		}


 	}

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

ll exp(ll a,ll b,ll m)
{
	if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
count = 0

if k == 0:
    print(n*n)
else:
    for i in range(n):
        if k > i:
            continue
        count = count + (i + 1 - k)*(n//(i+1))
        mod = n % (i+1)
        if mod >= k:
            count = count + mod - k + 1
    print(count)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            //string[] input = Console.ReadLine().Split(' ');

            int X = int.Parse(Console.ReadLine());
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());

            var result = (X - A) % B;
            
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    int p[55];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&p[i]);
    }
    int a[55];
    for(int i=0;i<n;i++)
    {
        a[i]=p[i];
    }
    sort(a,a+n);
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]!=p[i])
        {
            count++;
        }
    }
    if(count==0||count==2)
    {
        printf("YES\n");
        return 0;
    }
    /*
    int b[55];
    for(int i=0;i<n;i++)
    {
        b[i]=-p[i];
    }
    sort(b,b+n);
    count=0;
    for(int i=0;i<n;i++)
    {
        if(b[i]==-p[i])
        {
            count++;
        }
    }
    if(count==0||count==2)
    {
        printf("YES\n");
        return 0;
    }
    */
    printf("NO\n");
    
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    long long a[10001]={0};
    int n;
    long long min;
    long long max;
    int i;
    long long sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    min=a[0];
    for(i=0;i<n;i++){
        if(min>a[i])    min=a[i];
        }
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    max=a[0];
    for(i=0;i<n;i++){
        if(max<a[i])    max=a[i];
        }    
    for(i=0;i<n;i++)    sum=sum+a[i];        
    cout<<min;
    cout<<" ";
    cout<<max;
    cout<<" ";
    cout<<sum;
    cout<<endl;
}



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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r, g, b; cin >> r >> g >> b;
  int res = r*100 + g*10 + b;
  if(res%4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3544
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e3+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  

 void solve() {
     string s,p;
     cin>>s>>p;
     int ct=0;
     
     rep(i,0,sz(s)) {
		   if(s[i]!=p[i]) ct++;
		 }
     
       cout<<ct<<endl;
     
   					   
 }

    
int32_t main() {
	cool;
	int t=1;

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


return 0;	   
}


Measured memory_bytes: 3824
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

int main(){
    int n;
    cin >> n;
    vint p(n+1);
    rep(i,n) cin >> p[i] >> p[i+1];

    ll dp[110][110];

    for(int l=2; l<n+1; l++){
        for(int i=1; i<n-l+2; i++){
            int j= i+l-1;
            dp[i][j] = inf;
            for(int k=i; k<j; k++){
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j] + p[i-1]*p[k]*p[j] );
            }
        }
    }
    cout << dp[1][n] << endl;
    return 0;
}



Measured memory_bytes: 3172
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;

fn main() {
    input! {
        d: usize,
        t: usize,
        s: usize,
    }

    if t * s >= d {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2112
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs


int main() {
  string s;
  cin >> s;
  i64 n = s.size();
  vector<i64> cnt(26);
  for (char c : s) cnt[int(c - 'a')]++;
  i64 ans = n * (n + 1) / 2 + 1;
  for (i64 c : cnt) {
    ans -= c * (c + 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

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




    cout << T << S << endl;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    int cnt=0;
    rep(i,s.size()-1){
        if(s[i]!=s[i+1])cnt++;
    }

    cout<<cnt<<endl;

}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for (auto &e : v) scanf("%d", &e);
    std::sort(v.begin(), v.end());
    i64 t = 2, s = v[0] + v[1];
    for (int i = 2; i < n; i++) {
        s += t * v[i];
        t *= 2;
    }
    printf("%.10f\n", s / (double)t);

    return 0;
}


Measured memory_bytes: 256
x1,y1,x2,y2=map(int,input().split())
d=(x2-x1,y2-y1)
d90=(-d[1],d[0])
d180=(-d[0],-d[1])
x3=x2+d90[0]
y3=y2+d90[1]
print(x3,y3,x3+d180[0],y3+d180[1])

Measured memory_bytes: 38256
object Main {
	def main(args: Array[String]): Unit = {
		val str = io.StdIn.readLine()
		val strList = List(str(0), str(1), str(2), str(3))
		
		def judge(list: List[Char]): String = {
			if (list(0) == list(1) && list(2) == list(3) && list(1) != list(2)) "Yes"
			else "No"
		}
		
		println(judge(strList.sorted))
	}
}

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

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

	int c[n] = {};
	for (int i = 0; i < m; i++) {
		c[a[i]-1]++;
		c[b[i]-1]++;
	}
	for (int i = 0; i < n; i++) {
		cout << c[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 256