akhauriyash/Code-Regression huggingface dataset:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    a,b=map(str, readline().rstrip().split())
    a=int(a)
    b1,b2=b.split(".")
    b=int(b1)*100+int(b2)
    print((a*b)//100)
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16204
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= n; i--)
#define all(c) c.begin(),c.end()
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 2e3 + 10; 
int main()
{   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  	ll a,b,c,k;
  	cin>>a>>b>>c>>k;
    if(k<=a) cout<<k;
    else if(k>a && a+b>=k) cout<<a;
    else  cout<<2*a+b-k;
	return 0;
} 

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int d = a/b;
		int r = a%b;
		double f = 1.0 * a / b;
		String keta =String.format("%.8f",f);
		System.out.println(d+" "+r+" "+keta);
	}
}

Measured memory_bytes: 26512
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]



fetch_one_line()
nums = fetch_int_input()

set_nums = set(nums)

answer = ["NO", "YES"]

print(answer[int(len(nums) == len(set_nums))])


Measured memory_bytes: 95088
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef long double ld;
const ll mod = 998244353;//1e9+7

void solve() {
  int x,y;  cin>>x>>y;
  if(y%2) {
    cout<<"No";return;
  }
  if(x*4 < y) {
    cout<<"No";return;
  }
  if(x*2 > y) {
      cout<<"No";return;
  }
  cout<<"Yes";
}


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  #endif
  ll t = 1;
//  cin>>t;
  rep(i,t)  {
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string str;
int N, Q;
int l, r;
int psum[200010];
int main() {
	cin >> N >> Q;
	cin >> str;

	for (int i = 1; i < str.size(); i++) {
		int val = 0;
		if (str[i] == 'C' && str[i - 1] == 'A') {
			val = 1;
		}
		psum[i+1] = psum[i]+val;
	}


	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << psum[r] - psum[l] << endl;
	}
}

Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimmize("unroll-loops")

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "-1\n"; return;}

const int N = 2e5 + 7;

int p[N], sz[N];

int get(int v) {
    if (v == p[v])
        return v;
    return p[v] = get(p[v]);
}

void unite(int u, int v) {
    u = get(u);
    v = get(v);
    if (u == v)
        return;
    if (sz[u] < sz[v])
        swap(u, v);
    p[v] = u;
    sz[u] += sz[v];
}

void solve() {
    loop(i, N) {
        sz[i] = 1;
        p[i] = i;
    }
    int n, m;
    cin >> n >> m;
    loop(i, m) {
        int u, v;
        cin >> u >> v;
        unite(u, v);
    }
    int ans = 0;
    loop1(i, n)
        ans = max(ans, sz[i]);
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 5208
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<int, int>;
template <typename T> using vec = std::vector<T>;
using namespace std;

static inline constexpr int roundup(int val) { return 10 * ((val + 9) / 10); }

int main() {
  multimap<int, int> dishes;
  REP(i, 5) {
    int v;
    cin >> v;
    dishes.emplace(v % 10, v);
  }

  int answer = 0, count = 1;
  constexpr array<int, 10> numbers = {0, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  for (const auto &k : numbers) {
    if (dishes.count(k) == 0) {
      continue;
    }
    auto range = dishes.equal_range(k);
    for (auto it = range.first; it != range.second; ++it) {
      if (count < 5) {
        answer += roundup(it->second);
        count++;
      } else {
        answer += it->second;
      }
    }
  }

  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
using namespace std;
int main() {

	int small = 100000;
	string s;
	cin >> s;

	for (int i = 0; i < s.size() - 2; i++) {
		int n100 = s[i] - '0', n10 = s[i + 1] - '0', n1 = s[i + 2] - '0';
		int num = n100 * 100 + n10 * 10 + n1;
		if (num > 754) {
			if (num - 753 < small) {
				small = num - 753;
			}
		}
		else {
			if (753 - num < small) {
				small = 753 - num;
			}
		}
	}

	cout << small << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
#include "atcoder/all"

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

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

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

    bool is_union(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        return ra == rb;
    }
};


int main() {
    int n;
    cin >> n;
    vector<P> v(n);
    for (P &p:v)cin >> p.first >> p.second;
    vector<P> u = v;

    sort(v.begin(), v.end());

    map<int, int> index;
    rep(i, n) index[v[i].second] = i;

    PQ_ASK q;
    q.push(v.front().second);

    UnionFind uf(n);

    rep(i, n) {
        if (i == 0) continue;

        int now = v[i].second;

        vector<int> mi;
        mi.push_back(now);
        while (!q.empty() && q.top() < now) {
            mi.push_back(q.top());
            q.pop();
        }

        for (int y : mi) uf.connect(index[y], i);
        int p = *min_element(mi.begin(), mi.end());
        q.push(p);
    }

    rep(i, n) {
        int h = u[i].second;
        int vi = index[h];
        cout << uf.size(vi) << endl;
    }

}


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

int main()
{
    int N, M, sum = 0;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++)
    {
        cin >> A.at(i);
        sum += A.at(i);
    }
    if (N >= sum)
    {
        cout << N - sum << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}


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

int main()
{
  int a, b;
  cin >> a >> b;

  if (a >= b)
  {
    for (int i = 0; i < a; i++)
    {
      cout << b;
    }
    cout << endl;
  }
  else
  {
    for (int i = 0; i < b; i++)
    {
      cout << a;
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
const int MAX_V = 201;
double ft[103];
double tt[103];
double v[103];

void AtCoderExpress() {
	int n;
	cin >> n;
	int T = 0;
	for (size_t i = 1; i <= n; i++)
	{
		int t;
		cin >> t;
		//t *= 2;
		T += t;
		ft[i] = T - t;
		tt[i] = T;
	}
	tt[n + 1] = T;
	ft[n + 1] = T;
	for (size_t i = 1; i <= n; i++)
	{
		cin >> v[i];
	}
	double res = 0;
	double prev = 0;
	for (double i = 0.5; i <= T; i += 0.5)
	{
		double minu = 100;
		for (int j = 0; j <= n + 1; j++)
		{
			if (j >= 1 && ft[j] <= i && i <= tt[j]) {
				minu = min(minu, v[j]);
			}

			if (tt[j] < i) {
				minu = min(minu, v[j] + (i - tt[j]));
			}

			if (j >= 1 && i < ft[j]) {
				minu = min(minu,v[j] + (ft[j] - i));
			}
			
		}

		res +=  (prev + minu) * 0.25;
		prev = minu;
	}
	cout << to_string(res) << endl;
}

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



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int r;
	cin >> r;
	cout << (2 * r * PI) << endl;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  ll a, b;
  vvl ab(N + 1);
  rep(i, N - 1){
    cin >> a >> b;
    ab[a].push_back(b);
    ab[b].push_back(a);
  }

  queue<ll> que;
  vl vis(N + 1, 0);
  vl prev(N + 1, 0);
  que.push(1);
  vis[1] = 1;
  prev[1] = 1;

  while(true){
    ll top = que.front();
    que.pop();

    rep(i, ab[top].size()){
      if(vis[ab[top][i]] == 1) continue;
      
      vis[ab[top][i]] = 1;
      prev[ab[top][i]] = top;
      que.push(ab[top][i]);
    }

    if(vis[N] == 1) break;
  }

  vl path;
  path.push_back(N);
  ll bot = N;

  while(bot != 1){
    path.push_back(prev[bot]);
    bot = prev[bot];
  }

  ll sh = path[path.size() / 2 - 1];
  ll fh = path[path.size() / 2];
  
  queue<ll> que2;
  rep(i, N + 1) vis[i] = 0;
  vis[fh] = vis[sh] = 1;
  que2.push(fh);
  ll nds = 1;

  while(!(que2.empty())){
    ll top = que2.front();
    que2.pop();

    rep(i, ab[top].size()){
      if(vis[ab[top][i]] == 1) continue;

      vis[ab[top][i]] = 1;
      que2.push(ab[top][i]);
      nds++;
    }
  }

  if(nds <= (N - nds))
    cout << "Snuke" << endl;
  else
    cout << "Fennec" << endl;
  
  return 0;
}


Measured memory_bytes: 8440
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
 
 
int main()
{
    int n; std::string s;
    std::cin >> n >> s;
    if(n%2==1)
    {
        
    }
    else
    {
        if(s.substr(0, n/2)==s.substr(n/2, n/2))
        {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x, y, r, t;

	scanf("%d %d", &x, &y);
	if (x < y) {
		t = x;
		x = y;
		y = t;
	}

	for (;;) {
		r = x % y;
		if (r == 0) break;
		x = y;
		y = r;
	}
	printf("%d\n", y);

	return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  ll k;
  cin>>n>>k;
  ll a[n+1]={};
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int kbit[60]={},ma=-1;
  for(int i=0;i<60;i++){
    if((1ll<<i)&k){
      kbit[i]++;
      ma=i;
    }
  }

  ll abitOne[60]={},abitZero[60]={};
  for(int i=0;i<60;i++){
    for(int j=0;j<n;j++){
      if((1ll<<i)&a[j]){
        abitOne[i]++;
      }else{
        abitZero[i]++;
      }
    }
  }

  ll dp[61][2]={};
  for(int i=55;i>=0;i--){
      if(i<=ma){
        if(kbit[i]){
          dp[i][1]=max(dp[i][1],dp[i+1][0]+abitOne[i]*(1ll<<i));
          dp[i][0]=max(dp[i][0],dp[i+1][0]+abitZero[i]*(1ll<<i));
          if(i!=ma) dp[i][1]=max(dp[i][1],dp[i+1][1]+abitZero[i]*(1ll<<i));
          dp[i][1]=max(dp[i][1],dp[i+1][1]+abitOne[i]*(1ll<<i));
        }else{
          dp[i][1]=max(dp[i][1],dp[i+1][1]+abitZero[i]*(1ll<<i));
          dp[i][1]=max(dp[i][1],dp[i+1][1]+abitOne[i]*(1ll<<i));
          dp[i][0]=max(dp[i][0],dp[i+1][0]+abitOne[i]*(1ll<<i));
        }
      }else{
        dp[i][0]=max(dp[i][0],dp[i+1][0]+abitOne[i]*(1ll<<i));
      }
  }
  cout<<max(dp[0][0],dp[0][1])<<endl;

  return 0;
}


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

int main(){
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int vector_x = x2 - x1;
    int vector_y = y2 - y1;
    
    int x3 = x2 - vector_y;
    int y3 = y2 + vector_x;
    int x4 = x3 - vector_x;
    int y4 = y3 - vector_y;

    cout << x3 << " " << y3 << " " << x4 << " " << y4;
    return 0;

}

Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void Solve()
{
	VL x(5);
	REP(i, 5) cin >> x[i];
	ll ans = 0;
	REP(i, 5) {
		if (x[i] == 0) ans = i + 1;

	}
	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <string.h>

typedef long long ll;
using namespace std;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;

const double EPS = 1e-8;

int main()
{
	long int X;
	long int i=0,Sum=0;

	cin >> X;
	if(X%11==0) {cout << X/11*2<<endl;}
	else if(X%11<=6){ cout<< X/11*2+1<<endl;}
	else if(X%11 >6){cout << X/11*2+2<<endl;}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static long[] fact;
	static long[] inv;
	static long mod=1000000007;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=Math.min(n-1,sc.nextInt());
		fact=new long[2*n+1];
		fact[0]=1;
		fact[1]=1;
		for(int i=2; i<=2*n; i++){
			fact[i]=(fact[i-1]*i)%mod;
		}
		inv=new long[2*n+1];
		inv[2*n]=pow(fact[2*n],mod-2);
		for(int i=2*n-1; i>=0; i--){
			inv[i]=(inv[i+1]*(i+1))%mod;
		}
		long ans=1;
		for(int i=1; i<=k; i++){
			ans+=comb(n,i)*comb(n-1,n-1-i);
			ans%=mod;
		}
		System.out.println(ans);
	}
	static long comb(int t,int y){
		long re=1;
		re*=fact[t];
		re*=inv[y];
		re%=mod;
		re*=inv[t-y];
		return re%mod;
	}
	static long pow(long p,long q){
		long res=1;
		while(q>0){
			if((q & 1)==1){
				res*=p;
				res%=mod;
			}
			q>>=1;
			p*=p;
			p%=mod;
		}
		return res;
	}

}


Measured memory_bytes: 29524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n;
    cin >> n;
    VI a(n), sorted;
    FOR(i, 0, n)cin >> a[i];
    sorted = a;
    SORT(sorted);

    int cnt = 0;
    FOR(i, 0, n)if (a[i] == sorted[i])cnt++;

    if (cnt == n) {
        cout << "0\n";
        return 0;
    }

    int q, x, y;
    cin >> q;
    eFOR(c, 1, q) {
        cin >> x >> y;
        if (a[--x] == sorted[x])cnt--;
        if (a[--y] == sorted[y])cnt--;
        swap(a[x], a[y]);
        if (a[x] == sorted[x])cnt++;
        if (a[y] == sorted[y])cnt++;
        if (cnt == n) {
            cout << c << "\n";
            return 0;
        }
    }
    cout << "-1\n";
}



Measured memory_bytes: 5244
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#define ll long long
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rep1(i,a) for(ll i = 1;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;

//二分探索
bool solve(ll n, ll key){
	return n >= key;
}
//left,rightを半開区間で管理し、常にどちらか一方のみが真であるようにする
//デフォルトは与えられた配列でkey以上の最初の場所
ll binary_search(ll a, ll key){
	ll left = 0;
	ll right = a+1;
	while (right - left > 1){
		ll mid = left + (right - left) / 2;
		if (solve(mid, key)) right = mid;
		else left = mid;
	}
	return right;
}

int main(){
	string s; cin >> s;
	ll count = 0;
	ll ans = 0;
	rep(i, s.size()-1){
		if (s[i] == 'A') count++;
		else if (s[i] == 'B' && s[i + 1] == 'C'){
			ans += count;
			i++;
		}
		else count = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
// import java.io.BufferedReader;
// import java.io.IOException;
// import java.io.InputStreamReader;
// import java.util.ArrayList;
// import java.util.Arrays;
// import java.util.Collections;
// import java.util.List;
// import java.util.HashSet;
// import java.util.Set;
// import java.util.Map;
// import java.util.HashMap;

import java.math.*;

public class Main {
    private static Scanner sc;
    private static final long mod = 1000000007;

    public static void main(final String[] args) {
        final Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private static String getUpperAlpha(int i) {
        return String.valueOf((char) (i + 64));
    }

    /* i=1 return a */
    private static String getLowerAlpha(int i) {
        return String.valueOf((char) (i + 96));
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null)
                br.close();
        }

        public String next() throws IOException {
            if (i < s.length)
                return s[i++];
            String st = br.readLine();
            while (st == "")
                st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

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

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

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

        public long[] nextLongArray(int n) throws NumberFormatException, IOException {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

        public int[] nextIntArray(int n) throws NumberFormatException, IOException {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }
    }

    private void solve() {
        try {
            int a = sc.nextInt();

            System.out.println(a + a * a + a * a * a);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}


Measured memory_bytes: 32644
// 6/20 解き直し
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
    int N;  // Sの長さ
    string S;
    cin >> N >> S;

    int Q;  // Queryのかず
    cin >> Q;

    // stringをアルファベットに分解して26個のsetに格納
    vector<set<int>> st(26);
    rep(i, N) {
        int c = S[i] - 'a';
        st[c].insert(i);
    }
    // rep(i, 26) {
    //     cout << i << "番目のアルファベットは：";
    //     for (auto s : st[i]) cout << s << " ";
    //     cout << endl;
    // }

    while (Q--) {
        int q;
        cin >> q;

        if (q == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            if (S[i] != c) {
                st[S[i] - 'a'].erase(i);
                st[c - 'a'].insert(i);
                S[i] = c;
            }
            // cout << "here>2" << endl;
        }

        else {
            int l, r;
            cin >> l >> r;
            l--;  // r--;

            int res = 0;

            rep(i, 26) {
                // if (st[i].size() == 0) continue;

                // cout << "herehere" << endl;
                // auto itr1 = lower_bound(st[i].begin(), st[i].end(), l);
                // auto itr2 = upper_bound(st[i].begin(), st[i].end(), r);
                // int num = distance(itr1, itr2);
                // int num = distance(st[i].begin(), itr1);
                // cout << num << endl;
                // if (num <= r) res++;
                // cout << *itr1 << endl;
                // if (*itr1 <= r) res++;

                // if (num > 0) res++;
                // cout << "here?" << endl;

                auto it = st[i].lower_bound(l);
                if (it != st[i].end() && *it < r) ++res;
            }

            cout << res << endl;
        }
    }


}

Measured memory_bytes: 27248
n, m = map(int, input().split())
lst = [[] for _ in range(8)]
for _ in range(n):
    index = 0
    x, y, z = map(int, input().split())
    for nx in [x, -x]:
        for ny in [y, -y]:
            for nz in [z, -z]:
                lst[index].append(nx+ny+nz)
                index += 1
sortlst = []
for l in lst:
    sortlst.append(sorted(l, reverse=True))
msums = []
for sl in sortlst:
    msums.append(sum(sl[:m]))
print(max(msums))

Measured memory_bytes: 43244
#include<iostream>
#include<sstream>

using namespace std;

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

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

	return 0;
}

Measured memory_bytes: 256
#b
S=input()
T=input()
lt = len(T)
ls=len(S)

ans=10**20
for i in range(ls-lt+1):
    ss = S[i:i+lt]
    cand = sum(ss[j]!=T[j] for j in range(lt))
    
    #print(ss,T,cand)
    ans=min(ans,cand)
print(ans)

Measured memory_bytes: 68008
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0522

"""
import sys
from sys import stdin
input = stdin.readline


def find_pattern(txt, p):
    count = 0
    i = txt.find(p, 0)
    while i != -1:
        count += 1
        i = txt.find(p, i+1)
    return count


def main(args):
    for line in sys.stdin:
        print(find_pattern(line, 'JOI'))
        print(find_pattern(line, 'IOI'))


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7460
#include <cstdio>
#include <algorithm>

int main()
{
	int n;
	scanf("%d", &n);
	int p[8];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", p + i);
	}
	int q[8];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", q + i);
	}
	int ap = 0;
	int a[] = {1, 2, 3, 4, 5, 6, 7, 8};
	do
	{
		ap += 1;
		bool b = true;
		for (int i = 0; i < n; ++i)
		{
			if (a[i] != p[i]) b = false;
		}
		if (b) break;
	} while (std::next_permutation(a, a + n));
	int aq = 0;
	for (int i = 0; i < 8; ++i)
	{
		a[i] = i + 1;
	}
	do
	{
		aq += 1;
		bool b = true;
		for (int i = 0; i < n; ++i)
		{
			if (a[i] != q[i]) b = false;
		}
		if (b) break;
	} while (std::next_permutation(a, a + n));
	printf("%d\n", ap > aq ? ap - aq : aq - ap);
}


Measured memory_bytes: 128
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');
 
var n = null;
var index = 0;
while (line = lines.shift()) {
    const isN = index % 2 === 0;
    const numberArray = line.split(' ').map(Number);
 
    if(isN){
        n = numberArray[0];
    } else {
        var smallestScore = null;
        for(var i = 0; i < numberArray.length; i++){
            for(var j = 0; j < numberArray.length; j++){
                if (i!==j) {
                    let scoreDifference = Math.abs(numberArray[i] - numberArray[j]);
                    if(smallestScore === null){
                        smallestScore = scoreDifference;
                    } else {
                        if(scoreDifference < smallestScore){
                           smallestScore = scoreDifference; 
                        }
                    }
                }
            }    
        }
        console.log(smallestScore);
        n = null;
    }
    index ++;
} 
 


Measured memory_bytes: 18320
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B, K := sc.nextInt(), sc.nextInt(), sc.nextInt()
	ans := []int{}
	for i := A; i < min(A+K, B); i++ {
		ans = append(ans, i)
	}
	for i := max(B-K+1, A); i <= B; i++ {
		ans = append(ans, i)
	}
	ans = uniq(ans)
	sort.Ints(ans)
	for _, v := range ans {
		fmt.Fprintln(wtr, v)
	}

	wtr.Flush()
}

func uniq(a []int) []int {
	set := make(map[int]bool)
	res := []int{}
	for _, v := range a {
		if !set[v] {
			res = append(res, v)
			set[v] = true
		}
	}
	return res
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        string s = NextString().PadLeft(4,'0');
        Console.WriteLine(("YAKI" == s.Substring(0,4)?"Yes":"No"));
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define dbg() cerr << 
#define show(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

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

  string s; cin >> s;
  int n = s.size();
  vector<int> ans(n + 1);
  for (int i = 0; i < n; ++i) {
    if (s[i] == '<') {
      ans[i + 1] = max(ans[i + 1], ans[i] + 1); 
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == '>') {
      ans[i] = max(ans[i], ans[i + 1] + 1);
    }
  }
  cout << accumulate(ans.begin(), ans.end(), 0LL) << endl;

  cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}


Measured memory_bytes: 2844
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x=scan.nextInt();
        int i;
        int answer=1;
        for(i=0;i<3;i++){
            answer*=x;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 26344
# https://atcoder.jp/contests/abc080/tasks/abc080_c

import itertools
import collections
import bisect


def main():
    N = int(input())
    F = [list(map(int, input().split())) for _ in range(N)]
    P = [list(map(int, input().split())) for _ in range(N)]

    # print(F)
    # print(P)

    # big value
    INF = int(1e15)
    ans = -INF
    pattern = 1024  # 1 をパターンの数だけ左にシフトする
    for i in range(1, pattern):
        score = 0
        # print(bin(i))
        for s in range(N):
            matched = 0
            f = F[s]
            p = P[s]
            # print(f)
            # print(p)
            for j in range(10):
                if (i >> j) & 1:  # open
                    matched += 1 if f[j] else 0

            # print("s = {} match = {}".format(s, matched))
            score += p[matched]
        # print(score)
        ans = max(ans, score)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
package main

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

var keys = []string{"M", "A", "R", "C", "H"}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	strs := make([]string, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%s", &strs[i])
	}

	mp := make(map[string]int)
	for _, str := range strs {
		for _, key := range keys {
			if strings.HasPrefix(str, key) {
				mp[key]++
			}
		}
	}

	ans := 0
	for i := 0; i < len(keys)-2; i++ {
		for j := i + 1; j < len(keys)-1; j++ {
			for k := j + 1; k < len(keys); k++ {
				v := mp[keys[i]] * mp[keys[j]] * mp[keys[k]]
				ans = ans + v
			}
		}
	}
	fmt.Println(ans)
}


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

double abs(double x){
  if(x>=0)return x;
  else return -x;
}

int main(){
  int N,sel,tmph=100000;
  double h,A,T;
  cin >> N >> T >> A;
  double IdealH=(T-A)/0.006;
    
  for(int i=1;i<=N;i++){
    cin >> h;
    if( abs(IdealH-tmph)>abs(IdealH-h) ){
      sel=i;tmph=h;
    }  
  }
  cout << sel << endl;
  
  return 0;
}

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

using namespace std;

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

    string s;
    cin >> s;
    int i = 1;

    for (auto &x : s)
    {
        if (i)
        {
            if (x == 'L')
            {
                cout << "No\n";
                return 0;
            }
        }
        else
        {
            if (x == 'R')
            {
                cout << "No\n";
                return 0;
            }
        }
        i ^= 1;
    }
    cout << "Yes\n";

}


Measured memory_bytes: 256
<?php
 
function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(' ', input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

list($a, $b) = input_array('intval');

if ($a < 0) {
    if ($b < 0) {
        if (($b - $a + 1) % 2 === 0) {
            echo 'Positive';
        } else {
            echo 'Negative';
        }
    } else{
        echo 'Zero';
    }
} else if ($a > 0) {
    if ($b > 0) {
        echo 'Positive';
    } else {
        echo 'Zero';
    }
} else {
    echo 'Zero';
}

echo "\n";

Measured memory_bytes: 4604
#include<bits/stdc++.h>
#include<string>
#define pii pair<int,int>
#define fr(j,n) for(int j=0;j<n;j++)
#define f(n) for(int i=0;i<n;i++)
#define rt return 0;
#define sc second
#define fi first
#define i(n) int n;cin>>n;
#define pb(i) push_back(i);
#define rt return 0;
#define sz(v) v.size()
#define allv v.begin(),v.end()
#define ff(i,in,fi) for(int i=in;i<fi;i++)
//#define df int n;cin>>n;int a[n];fr(n){cin>>a[i];}5 8 7 14 55 19 9 2
using namespace std;
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define invect(data,n,commands) for(int xxx = 0;xxx<n;xxx++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define ll long long int
#define p(s) cout<<#s<<":"<<s<<'\n';
#define here(n) cout<<"here"<<n<<endl;
#define ios         ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

int main()
{
	ios;
	int n;
	cin>>n;
	int a[n];
	f(n)
	{
		cin>>a[i];
	}
	int maxx=0,sum=0;
	f(n-1)
	{

		if(a[n-1-i]<=a[n-2-i])
			{
				sum++;
				if(i==n-2)
					maxx=max(maxx,sum);
			}
		else
		{
			maxx=max(maxx,sum);
			sum=0;
		}
	}
	cout<<maxx;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int K;
  int A, B;
  cin >> K;
  cin >> A >> B;

  bool ok = false;
  rep(i,1005){
    if(A <= K*i && K*i <= B) ok = true;
  }

  if(ok) cout << "OK" << endl;
  else cout << "NG" << endl;
  
  return 0;
}


Measured memory_bytes: 3596
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: usize = s.next().unwrap().parse().unwrap();
	let l: usize = s.next().unwrap().parse().unwrap();
	let mut road = UnionFind::new(n);
	let mut railway = UnionFind::new(n);
	for _ in 0..k {
		let p: usize = s.next().unwrap().parse().unwrap();
		let q: usize = s.next().unwrap().parse().unwrap();
		road.unite(p - 1, q - 1);
	}
	for _ in 0..l {
		let r: usize = s.next().unwrap().parse().unwrap();
		let s: usize = s.next().unwrap().parse().unwrap();
		railway.unite(r - 1, s - 1);
	}
	let mut getid = |i| n as i64 * road.find(i) as i64 + railway.find(i) as i64;
	let mut mp = std::collections::HashMap::new();
	for i in 0..n {
		*mp.entry(getid(i)).or_insert(0) += 1;
	}
	use std::io::Write;
	let out = std::io::stdout();
	let mut out = out.lock();
	for i in 0..n {
		write!(
			out,
			"{:?}{}",
			mp[&getid(i)],
			if i + 1 == n { '\n' } else { ' ' }
		)
		.unwrap();
	}
}

pub struct UnionFind {
	data: Vec<i32>,
}

impl UnionFind {
	pub fn new(n: usize) -> UnionFind {
		UnionFind { data: vec![-1; n] }
	}

	pub fn unite(&mut self, x: usize, y: usize) -> bool {
		let x = self.find(x);
		let y = self.find(y);
		if x == y {
			false
		} else {
			let (x, y) = if self.data[x] > self.data[y] {
				(y, x)
			} else {
				(x, y)
			};
			self.data[x] += self.data[y];
			self.data[y] = x as i32;
			true
		}
	}

	pub fn find(&mut self, i: usize) -> usize {
		if self.data[i] < 0 {
			i
		} else {
			let p = self.data[i] as usize;
			self.data[i] = self.find(p) as i32;
			self.data[i] as usize
		}
	}

	pub fn size(&mut self, i: usize) -> usize {
		let i = self.find(i);
		(-self.data[i]) as usize
	}
}


Measured memory_bytes: 12224
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        if(c<d) {
            long tmp = c;
            c = d;
            d = tmp;
        }

        long cc = c;
        long cd = d;

        long x = c*d;
        long r = c%d;
        while(r!=0) {
            c = d;
            d = r;
            r = c%d;
        }

        x = x/d;


        long l = b/cc + b/cd - b/x;
        long s = (a-1)/cc + (a-1)/cd - (a-1)/x;
        //System.out.println(l +" "+ s);
        System.out.println(b-(a-1)-(l-s));

    }
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0203

"""
import sys
from sys import stdin
from collections import deque, defaultdict
input = stdin.readline


def solve(field):
    BLANK, OBSTACLE, JUMP = 0, 1, 2
    ans = 0                     #  ??????????????°???????????°

    # dy = [1, 1, 1]
    dx = [0, -1, 1] # ?????????????????????????????????????§???????
    x_limit = len(field[0])
    y_limit = len(field)

    path = defaultdict(int)     #  ??????????????????????????°???????????°????????????'x???_y???'???????????????
    Q = deque()                 #  ?????§??????????????????????????¨??????????????\???
    
    # ???????????§??????????????§????????´????????¢???????????\??????????????????
    for x, m in enumerate(field[0]):
        if m == BLANK:              #  ?????????????????°?????´?????????????????????????????????
            k = '{}_{}'.format(x, 0)
            Q.append((x, 0))
            path[k] = 1

    while Q:
        cx, cy = Q.popleft()        #  ?????¨??°?????§?¨?
        k = '{}_{}'.format(cx, cy)
        num = path.pop(k)       #  ????????§?¨?????????????????????°

        if field[cy][cx] == OBSTACLE: #  ?????£????????§?????°??????????????????????????±????????????????????????????????§?????£?????????????????
            continue
        elif field[cy][cx] == JUMP: #  ?????£????????§?????°?????????????????£????????°
            if cy+2 > y_limit-1: #  ?????£???????????????????¶?????????´??????OK??¨?????????
                ans += num
            else:
                k = '{}_{}'.format(cx, cy+2)
                if not path[k]:
                    Q.append((cx, cy+2))
                path[k] += num
            continue
        elif cy == y_limit -1:
            ans += num
            continue

        for i in range(3):      #  ?????????3???len(dy)?????????
            nx = cx + dx[i]     #  ?????°????????§?¨?
            ny = cy + 1         #  ??????+1????????§???dy[i]??¨?????????????????????OK

            if 0<= nx < x_limit:
                if field[ny][nx] == JUMP and dx[i] == 0: #  ?????£????????°????????£??????????????\????????´???
                    if ny+2 > y_limit - 1:
                        ans += num
                    else:
                        k = '{}_{}'.format(nx, ny+2)
                        if not path[k]:
                            Q.append((nx, ny+2))
                        path[k] += num
                elif field[ny][nx] == BLANK:
                    if (ny >= y_limit - 1):
                        ans += num
                    else:
                        k = '{}_{}'.format(nx, ny)
                        if not path[k]:
                            Q.append((nx, ny))
                        path[k] += num
    return ans


def main(args):
    while True:
        X, Y = map(int, input().strip().split())
        if X == 0 and Y == 0:
            break
        field = []
        for _ in range(Y):
            temp = [int(x) for x in input().strip().split()]
            field.append(temp)
        result = solve(field)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 8044
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    cin >> S >> T;
    string res = "";
    for (int i = 0; i < N; i++) {
        res += S[i];
        res += T[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
class Dice2{
public:
    Dice2(){
        number = new int[6];
        relative = new int[55];
        relative[31] = relative[43] = relative[24] = relative[12] = 0;
        relative[3] = relative[20] = relative[52] = relative[35] = 1;
        relative[1] = relative[40] = relative[54] = relative[15] = 2;
        relative[4] = relative[10] = relative[51] = relative[45] = 3;
        relative[2] = relative[30] = relative[53] = relative[25] = 4;
        relative[21] = relative[42] = relative[34] = relative[13] = 5;
    };
    ~Dice2(){
        delete[] number;
        delete[] relative;
    };
 
    void setNumber(int index,int num){
        number[index] = num;
    };
 
    int returnRight(int top,int front){
        int top_index,front_index;
        for(int i = 0; i < 6; i++){
            if(number[i] == top)
                top_index = i;
            if(number[i] == front)
                front_index = i;
        }
        return number[relative[10*top_index+front_index]];
    }
private:
    int* number;
    int* relative;
};
 
int main(){
    Dice2 dice2;
    int x,q,top,front;
    for(int i = 0; i < 6; i++){
        scanf("%d",&x);
        dice2.setNumber(i,x);
    }
    scanf("%d",&q);
    for(int i = 0; i < q; i++){
        scanf("%d %d",&top,&front);
        printf("%d\n",dice2.returnRight(top,front));
    }
}


Measured memory_bytes: 2692
n=int(input())
a=list(map(lambda x:int(x),input().split()))
cnt=0
cnt2=0
for i in a:
    if i%4==0:
        cnt+=1
    if i%4!=0 and i%2==0:
        cnt2+=1
if (2*cnt+cnt2>=n and cnt2>0) or (cnt2==0 and 2*cnt+1>=n):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252