akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	int l, r;
	cin >> N;
	int ans = 0;
	rep(i, 0, N)
	{
		cin >> l >> r;
		ans += (r - l + 1);
	}

	cout << ans << endl;

	return 0;
}

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

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


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;


    set<string> str3;
    set<string> str2;
    set<string> str1;

    for (auto ch: S) {
        for(auto s: str2) {
            str3.insert(s + ch);
        }
        for(auto s: str1) {
            str2.insert(s + ch);
        }
        // str1.insert("" + ch)は誤りなので注意
        str1.insert(string(1, ch));
    }

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

    return 0;
}


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


int main(void) {
    int N;
    long long int before_sum=0,sum=0;
    int cnt=0;
    bool noflag = false;
    char temp;
    string S,T,copy;
    int vecS[26];
    int vecT[26];

  cin>>S>>T;



    for (int j=0;j<(int)S.size();j++){
      for (int i=0;i<(int)S.size();i++){
        if(S[i]==T[i]){
          cnt++;
        }
      }

      if(cnt==(int)S.size()){
              cout<<"Yes"<<endl; return 0;
      }
      cnt=0;
      //rot
      for (int i=0;i<(int)S.size();i++){
      copy[i] = S[i];
      }
      temp = S[(int)S.size()-1];
      for (int i=1;i<(int)S.size();i++){
      S[i] = copy[i-1];
      }
      S[0] = temp;

    }


      // for (int j=0;j<26;j++){
      //   if(vecS[j]!=vecT[j]) {
     cout<<"No"<<endl;
      //   }
      // }

    // cout<<"Yes"<<endl;
    return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("uncopyrightable");
            //yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("different");
            //no
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("no");
            //yes
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[0];

        if (S.ToCharArray().Distinct().Count() == S.Length) {
            Console.WriteLine("yes");
        }
        else Console.WriteLine("no");
    }
}


Measured memory_bytes: 13276
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,K =(int(i) for i in input().split())

ans = [0]*(K+1)
mod = 1000000007

for i in range(1,K+1):
    if N-K < i-1:
        ans[i-1]= 0
    else:
        a = comb(K-1,i-1)
        b = comb(N-K+1,i)
        ans[i-1]=(a*b)%mod

for i in range(K):
    print(ans[i])


Measured memory_bytes: 66520
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



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

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

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

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

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

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

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    vec<ll> num(n+1,0);
    rrep(i,n) num[i]=num[i-1]+i;
    ll sum=0;
    for(ll i=k;i<=n;i++){
        sum+=((num[n]-num[n-i])-(num[i-1])+1);
    }
    cout<<(sum+1)%mod<<endl;
    return 0;
}


Measured memory_bytes: 4776
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static string[] input = Console.ReadLine().Split(' ');
static long n = long.Parse(input[0]);
static long v = long.Parse(input[1]);
static long[,] nums = new long[4,n];
static long[] firstSums = new long[n*n];
static long[] secondSums = new long[n*n];
static long[,] secondOptions = new long[n*n, 2];//数値と個数
static long optionsCount = 1;//選択肢の個数
static long nowCheckNum = 0;
static long answer = 0;

	static void Main()
	{

    for(long i = 0; i < 4; i++)
    {
      long[] numGets = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      for(long j = 0; j < n; j++)
      {
        nums[i,j] = numGets[j];
      }
    }

    for(long i = 0; i < n; i++)
    {
      for(long j = 0; j < n; j++)
      {
        firstSums[n*i+j] = nums[0,i] + nums[1,j];//最初の2袋の和の全通り
        secondSums[n*i+j] = nums[2,i] + nums[3,j];//後の2袋の和の全通り
      }
    }
    Array.Sort(secondSums);
    
    secondOptions[0,0] = secondSums[0];
    secondOptions[0,1] = 1;
    for(long i = 1; i < n*n; i++)
    {
      if(secondSums[i] == secondSums[i-1])
      {
        secondOptions[optionsCount-1, 1]++;
      }else
      {
        optionsCount++;
        secondOptions[optionsCount-1,0] = secondSums[i];
        secondOptions[optionsCount-1, 1]++;
      }
    }

    for(long i = 0; i < n*n; i++)
    {
      nowCheckNum = firstSums[i];
      Search(0, optionsCount-1);
    }

		Console.WriteLine(answer);
	}

  static void Search(long min, long max)//二分探索法で最大値を求める
  {
    while (true)
    {
      long mid = min + (max - min) / 2;
      if(Check(mid)) min = mid;//さらに大きくても成り立つかも
      else max = mid;

      if(max - min <= 1)
      {
        if(secondOptions[max,0] + nowCheckNum == v) 
        {
          answer += secondOptions[max,1];
        }
        else if(secondOptions[min,0] + nowCheckNum == v)
        {
          answer += secondOptions[min,1];
        }
      break;
      }  
    }
  }

  static bool Check(long testNum)
  {
    if(secondOptions[testNum,0] + nowCheckNum <= v) return true;
    return false;
  }

  
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

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

    mat<int> memo = mmat<int>(10, 10);
    For(i, 1, n) {
        vec dign;
        int x = i;
        while (x > 0) {
            dign.pb(x % 10);
            x /= 10;
        }
        reverse(all(dign));
        memo[dign[0]][dign.back()]++;
    }

    int ans = 0;
    For(i, 1, 9) {
        For(j, 1, 9) { ans += memo[i][j] * memo[j][i]; }
    }
    print(ans);

    return 0;
}


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

int main() {
  int n;
  bool j = true;
  cin >> n;
  vector<long long> h(n);
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
  }
  reverse(h.begin(),h.end());
  for(int i = 0; i < n - 1; i++){
    if(h.at(i + 1) - h.at(i) >= 2){
      j = false;
      break;
    }else if(h.at(i + 1) - h.at(i) == 1){
      h.at(i + 1) -= 1;
    }
  }
  if(j){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
import Foundation

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

let nmk = readInts()
let (_, _, remaining) = (nmk[0], nmk[1], nmk[2])
let bookA = readInts()
let bookB = readInts()
//
var countCanReadBookB = bookB.count
var readBookTime = bookB.reduce(0) { $0 + $1 }
var varRem = remaining
var ans = 0

for countReadedBookA in 0...bookA.count {
    // Aから0冊読んだ場合から検証するため
    readBookTime += countReadedBookA > 0 ? bookA[countReadedBookA - 1]: 0
    
    
    while countCanReadBookB > 0 && readBookTime > remaining {
        countCanReadBookB -= 1
        readBookTime -= bookB[countCanReadBookB]
    }
    
    if readBookTime > remaining {
        break
    }
    ans = max(ans, countReadedBookA + countCanReadBookB)
}
print(ans)









Measured memory_bytes: 31384
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int n, ans = 0;
	string a, b, c;
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; ++i) {
		if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i]) { ans += 2; }
		else if (a[i] == b[i] && b[i] == c[i]) { continue; }
		else { ++ans; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, q;
string s;
char t[200000], d[200000];

int main() {
    cin >> n >> q >> s;
    rep(i,q) cin >> t[i] >> d[i];
    int le, ri;
    {
        int st = -1, en = n, mid;
        while (en-st > 1) {
            mid = (st+en)/2;
            int pos = mid;
            bool ok = false;
            rep(i,q) {
                if (t[i] == s[pos]) {
                    if (d[i] == 'R') {
                        pos++;
                    } else {
                        pos--;
                    }
                    if (pos < 0) {
                        ok = true;
                        break;
                    }
                    if (pos >= n) {
                        ok = false;
                        break;
                    }
                }
            }
            if (ok) st = mid;
            else en = mid;
        }
        le = st;
    }
    {
        int st = -1, en = n, mid;
        while (en-st > 1) {
            mid = (st+en)/2;
            int pos = mid;
            bool ok = false;
            rep(i,q) {
                if (t[i] == s[pos]) {
                    if (d[i] == 'R') {
                        pos++;
                    } else {
                        pos--;
                    }
                    if (pos < 0) {
                        ok = false;
                        break;
                    }
                    if (pos >= n) {
                        ok = true;
                        break;
                    }
                }
            }
            if (ok) en = mid;
            else st = mid;
        }
        ri = en;
    }
    cout << ri-le-1 << endl;
}



Measured memory_bytes: 900
#include <stdio.h>

int main(){
  
  int n,i=0;
  int a[10]={};
  while( scanf("%d",&n) !=EOF){
    if(n==0){
      i--;
      printf("%d\n",a[i]);
    }
    else{
      a[i]=n;
      i++;
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"

using namespace std;
const int MAXN = 2e5 + 5;

int N;
long long K;

int A[MAXN];
int F[MAXN];

bool check(long long x) {
    long long s = 0LL;
    for (int i=0; i < N and s <= K; i++)
        s += max(A[i] - x / F[i], 0LL);

    return s <= K;
}

int main(int argc, char* argv[]) {
    
    scanf("%d%lld", &N, &K);

    for (int i=0; i < N; i++)
        scanf("%d", A + i);

    for (int i=0; i < N; i++)
        scanf("%d", F + i);

    sort(A, A + N);
    sort(F, F + N);
    reverse(A, A + N);

    long long L = -1, size = 1e12 + 5;

    while (size > 1) {
        if (check(L + size / 2))
            size = size / 2;
        else{
            L += size / 2;
            size -= size / 2;
        }
    }
    printf("%lld\n", L + 1);
    return 0;
}

Measured memory_bytes: 1920
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int main() {
	int a,b; qr(a); qr(b);
	if(b>=a) puts("unsafe");
	else puts("safe");
	return 0;
}



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

int main()
{
    long long int a,b,c,d,x,y,a1,a2,a3,a4;
    cin>>a>>b>>c>>d;
    a1 = a*c;
    a2 = a*d;
    a3 = b*c;
    a4 = b*d;

    x = max(a1,max(a2,max(a3,a4)));

    cout<<x<<endl;


    return 0;
}


Measured memory_bytes: 3628
public class Hello{
    public static void Main(){
        int score = 0;
        
        // 入力
        int N = int.Parse(System.Console.ReadLine());
        string A = System.Console.ReadLine();
        string B = System.Console.ReadLine();
        string C = System.Console.ReadLine();

        // 処理
        for(int i=0; i<N; ++i)
        {
            if(A[i] == B[i] && B[i] == C[i])
            {
                score += 0;
            }
            else if(A[i] == B[i] && B[i] != C[i])
            {
                score += 1;
            }
            else if(A[i] == C[i] && C[i] != B[i])
            {
                score += 1;
            }
            else if(B[i] == C[i] && C[i] != A[i])
            {
                score += 1;
            }
            else
            {
                score += 2;
            }
        }
        
        // 出力
        System.Console.WriteLine(score);
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if((a-b)%2 != 0){
            System.out.println("IMPOSSIBLE");
            return;
        }
        
        int k = (a+b)/2;
        System.out.println(k);
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }




int f(int x) {
    int cnt = 0;
    while (x % 2 == 0) {
        x /= 2;
        cnt++;
    }
    return cnt;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        if (a[i] % 2) { cout << 0 << endl; return; }
        a[i] /= 2;
    }
    
    int a0 = f(a[0]);
    rep3(i, 1, n) {
        if (f(a[i]) != a0) {
            cout << 0 << endl;
            return;
        }
    }
    
    int t = pow(2, a0);
    rep(i, n) {
        a[i] /= t;
    }
    m /= t;
    
    ll L = a[0];
    rep3(i, 1, n) {
        L = lcm(L, 1LL * a[i]);
        if (L > m) {
            cout << 0 << endl;
            return;
        }
    }
    
    int cnt = m / L;
    cout << cnt / 2 + (cnt % 2) << endl;
    
    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}




Measured memory_bytes: 640
#include <iostream>

using namespace std;

int f(int n, int &a){
  if (n == 0){
    return a;
  }
  a += n % 10;
  return f(n / 10, a);
}

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

  int res = 0;
  res = f(n, res);
  if (n % res == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

template <typename Tu>
static inline constexpr bool is_multiplication_safe(Tu a, Tu b)
{
    return !a || b <= 1000000000000000000 / a;
}

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n; cin >> n;
	ll ans = 1;
	vector<ll> v(n);
	bool ok = true;
	rep(i, n){
		cin >> v[i];
		if(v[i] == 0) ok = false;
	}
	if(!ok){
		cout << 0 << endl;
		return 0;
	}
	rep(i, n){
		ll a; a = v[i];
		if(!is_multiplication_safe(ans, a)){
			ans = -1;
			break;
		}
		ans *= a;
	}
	cout << ans << endl;
	return 0;
}


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

#define N 5005

char s[N];

int a[N];

int n, k;

int get_max(int l, int d) {
    if (d) l *= 2;
    for (int i = 1; i < k; i ++) {
        l *= 2;
        if (l >= n) return n;
    }
    return l;
}

void print(int n, char ch) {
    for (int i = 0; i < n; i ++) putchar(ch);
    putchar('\n');
    return;
}

string ans;

void update(string s) {
	if (ans.empty()) ans = s;
    else if (ans > s) ans = s;
    return;
}

string get_string(int p, int sz, char ch) {
    string res;
	if (p == n) {
        for (int i = 0; i < sz; i ++) res += ch;
        p = n - a[n];
        for (int i = sz; i < n; i ++) res += s[p--];
        return res;
	}
    else {
        for (int i = 0; i < sz; i ++) res += ch;
        for (int i = sz; i < n; i ++) {
			p ++;
            if (p <= n) res += s[p];
            else res += s[2*n+1-p];
        }
        return res;
    }
}

int main() {
    scanf("%d %d", &n, &k);
    scanf("%s",s+1);
    char ch = 'z';
    for (int i = 1; i <= n; i ++) ch = min(ch, s[i]);
    for (int i = 1; i <= n; i ++) {
        if (ch == s[i]) a[i] = a[i-1] + 1;
        else a[i] = 0;
    }
    int mx = 0;
    for (int i = 1; i < n; i ++) mx = max(mx, a[i]);
    int b[2] = {0};
    b[0] = get_max(mx, 0);
    b[1] = get_max(a[n], 1);
    if (max(b[0], b[1]) >= n) {
		print(n, ch);
        return 0;
    }
    if (a[n] > 0) update(get_string(n, b[1], ch));
    if (mx > 0) {
        for (int i = 1; i < n; i ++) if (mx == a[i]) update(get_string(i, b[0], ch));
    }
    cout << ans << endl;
	return 0;
}


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

int main(){
  string a;
  string b;
  cin>>a;
  cin>>b;
  int count=0;
  int i;
  
  for(i=0;i<=2;i++){
  if(a[i]==b[i]){
    count++;
  }
  }
  cout<<count<<endl;
  return 0;
}
  


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

int main() {
	string s;
	cin>>s;
	int count1 = 0;
	for (char ch : s) {
		if (ch == '1')
			count1++;
	}
	int ans = min(count1, (int)s.size() - count1);
	cout<<2*max(ans, 0)<<endl;
	return 0;
}

Measured memory_bytes: 512
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=STR()
    a=[]
    for i in range(len(n)):
        #print(n[i])
        if n[i]=='1':
            a.append('9')
        else:
            a.append('1')
    print(*a,sep='')
if __name__ == '__main__':
    do()

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    long long a, b, c; cin >> a >> b >> c;

    if(b >= c) cout << "delicious";
    else if(a >= c - b) cout << "safe";
    else cout << "dangerous";
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<vector<ll>> vs(N, vector<ll>(3));

  for (auto i = 0; i < N; i++) {
    cin >> vs[i][0] >> vs[i][1] >> vs[i][2];
  }

  for (auto cx = 0; cx <= 100; cx++) {
    for (auto cy = 0; cy <= 100; cy++) {
      // find H
      ll H = 0;
      for (auto i = 0; i < N; i++) {
        auto x = vs[i][0];
        auto y = vs[i][1];
        auto h = vs[i][2];
        if (h == 0) continue;
        H = h + abs(x - cx) + abs(y - cy);
        break;
      }

      // validation
      bool valid = true;
      for (auto i = 0; i < N; i++) {
        auto x = vs[i][0];
        auto y = vs[i][1];
        auto h = vs[i][2];

        auto h2 = max(0LL, (ll)(H - abs(x-cx) - abs(y-cy)));
        if (h != h2){
          valid = false;
          break;
        }
      }
      if (valid) {
        cout << cx << " " << cy << " " << H << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(100<=N&&N<=111) {
			System.out.println(111);
		}
		else if(112<=N&&N<=222) {
			System.out.println(222);
		}
		else if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main() {
  int L, R;
  cin >> L >> R;
  if (R - L > 2019) {
    cout << 0 << endl;
    return 0;
  }
  
  int min = 2019;
  for (int i = L; i < R; i++) {
    for (int j = i+1; j < R+1; j++) {
      int multi = ((long long)(i % 2019) * (j % 2019)) % 2019;
      if (min > multi) min = multi;
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def nPr(n, r):
   """
   Calculate the number of permutation (nPr = n!/(n-r)!).
   The parameters need to meet conditions of n >= r >= 0.
   It returns 1 if r == 0, which means there is one pattern
   to choice 0 items out of the number of n.
   """
   num = 1
   for i in range(n, n-r, -1):
       num *= i
   return num

def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """

    # 10C7 = 10C3
    r = min(r, n-r)

    # Calculate the numerator.
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    # Calculate the denominator. Should use math.factorial?
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator


def solve(N: int, s: "List[str]"):
    for i in range(N):
        l = list(s[i])
        l.sort()
        s[i] = ''.join(l)

    from collections import Counter

    c = Counter(s)
    ans = 0
    # print(c.most_common())
    for k, v in c.most_common():
        if( v >= 2):
            ans += nCr(v,2)

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24508
#include <stdio.h>
#include <stdbool.h>

int	H, W;
char S[51][51];
int	COUNT[51][51] = {0};

bool	check_block(int i, int j)
{
	if (i < 0 || i >= H)
		return (false);
	if (j < 0 || j >= W)
		return (false);
	if (S[i][j] == '#')
		return (false);
	if (COUNT[i][j] > 0)
		return (false);
	return (true);
}

int		main(void)
{
	int	white = 0;
	int black = 0;
	int	tail = 1;
	int	que[2500][2] = {0};
	int	now_i, now_j;
	int	i, j;

	//入力
	scanf("%d%d", &H, &W);
	for (i = 0; i < H; i++)
	{
		scanf("%s", S[i]);
	}
	//処理
	//色毎にマスの数を求める
	for (i = 0; i < H; i++)
	{
		for (j = 0; j < W; j++)
		{
			if (S[i][j] == '.')
				white++;
			else
				black++;
		}
	}
	//キューのセッティング
	for (i = 1; i < 2500; i++)
	{
		que[i][0] = -1;
		que[i][1] = -1;
	}
	//ゴールへの最短距離を求める
	//幅優先探索
	COUNT[0][0] = 1;
	for (i = 0; i <= 2500; i++)
	{
		if (que[i][0] == -1)
			break ;
		now_i = que[i][0];
		now_j = que[i][1];
		if (check_block(now_i + 1, now_j))
		{
			COUNT[now_i + 1][now_j] = COUNT[now_i][now_j] + 1;
			que[tail][0] = now_i + 1;
			que[tail][1] = now_j;
			tail++;
		}
		if (check_block(now_i - 1, now_j))
		{
			COUNT[now_i - 1][now_j] = COUNT[now_i][now_j] + 1;
			que[tail][0] = now_i - 1;
			que[tail][1] = now_j;
			tail++;
		}
		if (check_block(now_i, now_j + 1))
		{
			COUNT[now_i][now_j + 1] = COUNT[now_i][now_j] + 1;
			que[tail][0] = now_i;
			que[tail][1] = now_j + 1;
			tail++;
		}
		if (check_block(now_i, now_j - 1))
		{
			COUNT[now_i][now_j - 1] = COUNT[now_i][now_j] + 1;
			que[tail][0] = now_i;
			que[tail][1] = now_j - 1;
			tail++;
		}
		if (COUNT[H - 1][W - 1] != 0)
			break ;
	}
	//最短距離の分以外の白マスは黒に変換可能
	if (COUNT[H - 1][W - 1] == 0)
	{
		printf("%d\n", -1);
		return (0);
	}
	printf("%d\n", white - COUNT[H - 1][W - 1]);
	return (0);
}

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

#define int long long

int in[200005] , out[200005] , final[200005];
int tim = 0;
bool vis[200005];
vector <int> adj[200005];

void dfs(int root){
  tim++;
  vis[root] = true;
  in[root] = tim;
  for(auto i : adj[root]){
    if(!vis[i]){
      dfs(i);
    }
  }
  out[root] = tim;
}

signed main(){
  int n , q ,x , y , l , r;
  cin >> n >> q;
  int ind[n+5];

  for(int i = 0; i < n-1; i++){
    cin >> x >> y;
    adj[x].push_back(y); adj[y].push_back(x);
  }

  dfs(1);
  vector <pair <int , int> > v;
  for(int i = 1; i <= n; i++){
    v.push_back({in[i] , i});
  }

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

  for(int i = 0; i < n; i++){
    ind[v[i].second] = i+1;
  }

  while(q--){
    cin >> x >> y;
    l = in[x]; r = out[x];
    final[l]+=y; final[r+1]-=y;
  }

  for(int i = 1; i <= n; i++){
    final[i]+=final[i-1];
  }

  for(int i = 1; i <= n; i++){
    cout << final[ind[i]]  << " ";
  }
}

Measured memory_bytes: 29936
local mfl = math.floor

local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end
local function upper_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if comp(x, ary[1]) then return 1 end
  if not comp(x, ary[num]) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if not comp(x, ary[mid]) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local s = io.read()
local t = io.read()
local n = #s
local m = #t
local s_tbl = {}
local sstr = ""
for i = 1, n do
  sstr = s:sub(i, i)
  if not s_tbl[sstr] then s_tbl[sstr] = {} end
  table.insert(s_tbl[sstr], i)
end

local curpos = 0
local loop = 0
local isok = true
for i = 1, m do
  sstr = t:sub(i, i)
  if not s_tbl[sstr] then
    isok = false
    break
  else
    local bnd = upper_bound(s_tbl[sstr], curpos)
    if #s_tbl[sstr] < bnd then
      loop = loop + 1
      curpos= s_tbl[sstr][1]
    else
      curpos = s_tbl[sstr][bnd]
    end
  end
end

if isok then
print(loop * n + curpos)
else
  print(-1)
end


Measured memory_bytes: 1884
#include <stdio.h>

int main(void) {
  int k, n;
  scanf("%d %d", &k, &n);
  int arr[n + 1];
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  arr[n] = k + arr[0];

  int _max = 0, index = 0;
  for (int i = 0; i < n; i++) {
    int tmp = arr[i + 1] - arr[i];
    if (_max < tmp) {
      _max = tmp;
      index = i;
    }
  }

  int ans = k - _max < arr[index] + k - arr[index + 1] ? k - _max : arr[index] + k - arr[index + 1];
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long int
#define pb push_back
#define mp make_pair
#define ip pair<int, int>
#define F first
#define S second
#define fori(l, n) for(int i = l; i < n; i++)
#define forj(k, m) for(int j = k; j < m; j++)
#define revi(h) for(int i = h; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define PI 3.14159265358
#define debug(x) cout<<"DEBUGGING --- "<<x<<endl;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file freopen("output.txt", "w", stdout);
signed main(){
    fastio;
	// input_from_file; 
	// output_to_file;
    int n;
    cin>>n;
    vector<int>H(n + 1);
    fori(1, n + 1) cin>>H[i];
    vector<int>DP(n + 1, 0);
    DP[1] = 0;
    DP[2] = abs(H[2] - H[1]);
    fori(3, n + 1) DP[i] = min(DP[i - 2] + abs(H[i] - H[i - 2]), DP[i - 1] + abs(H[i] - H[i - 1]));
    cout<<DP[n]<<endl;    
} 

Measured memory_bytes: 1792
let solve s =
  let len = String.length s in
  let rec aux i pre count =
    if i = len then count
    else if pre <> s.[i] then aux (i + 1) s.[i] (count + 1)
    else aux (i + 1) pre count
  in
  aux 0 s.[0] 1

let () = solve (read_line ()) - 1 |> Printf.printf "%d\n"

Measured memory_bytes: 2560
N, M = map(int, input().split())
# 4個入力それぞれ1,2,3,4個
H = list(map(int, input().split()))
# テーブル作成初期化
t = [0] * N
# 3本入力
for _ in range(M):
    # 組み合わせを2つ入力
    A, B = map(int, input().split())
    # 自分と相手の標高を比べて買った方がテーブルとして選抜
    t[A - 1] = max(t[A - 1], H[B - 1])
    t[B - 1] = max(t[B - 1], H[A - 1])

# 最初0から始まり
result = 0
# 4つ中のi番目の標高がtより高い場合＋1優秀
for i in range(N):
    if H[i] > t[i]:
        result += 1
print(result)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;
    vi h(n+2);
    REP(i,n)cin>>h[i];
    vi dp(n+k, INT_MAX);
    dp[0]=0;

    FOR(i,0,n){
        FOR(j,1,k+1){
            if(i+j >= n) break;
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    
    int ans = dp[n-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;
int a[1000]={0};
int main(){
	int n,sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i+=2){
		if(a[i]%2!=0) sum++;
	}
	printf("%d",sum);
	

	return 0; 
}





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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[202020];
int ans[202020];
void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	int acnt = 0;
	for(int i = n; i > 0; i--){
		int cnt = 0;
		for(int j = 2; j*i <= n; j++){
			cnt += ans[j*i];
		}
		ans[i] = (cnt%2) ^ a[i];
		if(ans[i]) acnt++;
	}
	
	cout << acnt << endl;
	for(int i = 1; i <= n; i++){
		if(ans[i]) cout << i << " ";
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 2560
import kotlin.math.pow

fun main(){
    val x = readLine()!!.toLong()
    for (a in -120 until 121){
        for(b in -120 until 121){
            if(a.toDouble().pow(5).toLong() - b.toDouble().pow(5).toLong() == x){
                println("$a $b")
                return
            }
        }
    }
}

Measured memory_bytes: 34384
#include<bits/stdc++.h>
using namespace std;
int main(){
 int N;
  cin>>N;
  
  vector<int>p(N);
  vector<int>q(N);
  vector<int>r(N);
  
  for(int i=0;i<N;i++){
    cin>>p[i];
    q[i]=p[i];
  }
  
  sort(q.begin(),q.end());
  
  int sum=0;
  
  for(int i=0;i<N;i++){
    if(q[i]!=p[i]){
      sum++;
      r[i]++;
    }
  }
  
  
  if(sum==0){
    cout<<"YES"<<endl;
  }
  
  else if(sum==2){
    int A=0;
    int B=0;
    int chk=0;
    for(int i=0;i<N;i++){
      if(r[i]==1&&chk==0){
        A=i;
        chk++;
      }
      else if(r[i]==1&&chk!=0){
        B=i;
        
       
      }
    }
    int mem=p[A];
    p[A]=p[B];
    p[B]=mem;
    int sum2=0;
    for(int i=0;i<N;i++){
      if(p[i]!=q[i]){
sum2++;
      }
    }
    
    if(sum2==0){

    cout<<"YES"<<endl;
    }
    
    else{
      cout<<"NO"<<endl;
  }
  }
  else{
    cout<<"NO"<<endl;
  }
}
   

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    int N;
    read(N);

    i64 rankMax = 0;
    i64 ans = 0;

    rep(i, N) {
        i64 a, b;
        read(a, b);
        if (chmax(rankMax, a)) {
            ans = a + b;
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();

        // 全体数 - (B以下でCまたはDで割り切れるものの個数 - A-1以下でCまたはDで割り切れるものの個数)
        long ans = (B - A + 1) -
                ((B/C + B/D - B/(C*D/gcd(C, D))) - ((A-1)/C + (A-1)/D - (A-1)/(C*D/gcd(C, D))));
    System.out.print(ans);
    }


    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}


Measured memory_bytes: 24020
import sys
input = sys.stdin.readline


def main():
    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    
    ch += 1
    cw += 1
    dh += 1
    dw += 1
    
    
    s = ["#"*(w+4)]
    s.append("#"*(w+4))
    for i in range(h):
        s.append("##" + input()[:-1] + "##")
    s.append("#"*(w+4))
    s.append("#"*(w+4))
    
    
    ans = [[-1]*(w+4) for _ in range(h+4)]
    for i in range(h+4):
        for j in range(w+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ans[ch][cw] = 0
    
    move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    move2 = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), \
             (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), \
             (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), \
             (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), \
             (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]
        
    not_yet = [(ch, cw)]
    one_time = []
    
    while len(not_yet) > 0:
        x, y = not_yet.pop()
        one_time.append((x, y))
        for (p, q) in move:
            v1, v2 = x+p, y+q
            if ans[v1][v2] == -1:
                not_yet.append((v1, v2))
                ans[v1][v2] = ans[x][y]
                
        if len(not_yet) == 0:
            while len(one_time) > 0:
                x2, y2 = one_time.pop()
                for (v1, v2) in move2:
                    i, j = x2+v1, y2+v2
                    if ans[i][j] == -1:
                        ans[i][j] = ans[x2][y2]+1
                        not_yet.append((i, j))
          
    print(ans[dh][dw])
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 23116
main(){
    int n;
    while(~scanf("%d",&n)){
        int a,b,c,d,cnt=0;
        for(a=0;a<=9;a++)
            for(b=0;b<=9;b++)
                for(c=0;c<=9;c++)
                    for(d=0;d<=9;d++)
                        if(a+b+c+d==n)
                            cnt++;
        printf("%d\n",cnt);
    }
    return 0;
}


Measured memory_bytes: 2040
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x; cin >> x;
	int ans = 0;
	int sum = 100;
	while (sum < x) {
		ans++;
		sum = sum * 1.01;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3608
#include <cstdio>

int main()
{
    int X;
    scanf("%d", &X);
    long pow5[240];
    for (int i = 0; i < 120; i++)
    {
        long x = i;
        pow5[120 + i] = x * x * x * x * x;
        pow5[120 - i] = -pow5[120 + i];
    }
    for (int A = 0; A < 120; ++A)
    {
        for (int B = 0; B < A; ++B)
        {
            if (pow5[120 + A] - pow5[120 + B] == X)
            {
                printf("%d %d", A, B);
                return 0;
            }
            else if (pow5[120 + A] + pow5[120 + B] == X)
            {
                printf("%d %d", A, -B);
                return 0;
            }
        }
    }
}


Measured memory_bytes: 1732