akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
bool custom(pair<int, int> x, pair<int, int> y){
  if(x.second == y.second) return x.first < y.first;
  return x.second < y.second;
}
int main(){
  int n; cin >> n;
  vector<pair<int, int>> vp(n);
  for(int i = 0, x, l; i < n; ++i){
    cin >> x >> l;
    vp[i].first = x - l;
    vp[i].second = x + l;
  }
  sort(vp.begin(), vp.end(), custom);
  int ans = 0;
  int crr = vp[0].second;
  for(int i = 1; i < n ; ++i){
    if(crr > vp[i].first){
      ans++;
    }
    else crr = vp[i].second;
  }
  cout << n - ans << endl;
}

Measured memory_bytes: 1024
data_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(data_list[k - 1])


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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
ll n,k;
ll dp[100010];
ll arr[100010];

int main(){
	fast;
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		cin>>arr[i];
	}
	memset(dp,0,sizeof(dp));
	for(ll i=1;i<n;i++){
		if(i==1){
			dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
		}
		else{
			dp[i]=(dp[i-1]+abs(arr[i]-arr[i-1]));
			for(ll j=2;j<=k;j++){
				if(i-j>=0){
					dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
				}
				else{
					break;
				}
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

sl, tl = map(int, input().split())
s = input()
t = input()

m = lcm(sl,tl)

mps = m // sl
mpt = m // tl

tmp = 0
width = max(mps,mpt)
ans = True

while tmp < m:
    if tmp % mps == 0 and tmp % mpt == 0:
        if s[tmp//mps] != t[tmp//mpt]:
            ans = False
            break
    tmp += width

if ans:
    print(m)
else:
    print(-1)

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N;
vector<ll> h;
vector<ll> a;

template <typename T>
struct SegTree {
   const T INF = numeric_limits<T>::max();
   int n;
   vector<T> dat;
   SegTree(int n_): n(), dat(n_ * 4, 0) {
      int x = 1;
      while (n_ > x) {
         x *= 2;
      }
      n = x;
   }

   void update(int i, T x) {
      i += n - 1;
      dat.at(i) = x;
      while (i > 0) {
         i = (i - 1) / 2;
         dat.at(i) = max(dat.at(i * 2 + 1), dat.at(i * 2 + 2));
      }
   }

   T query(int a, int b) {return query_sub(a, b, 0, 0, n);}
   T query_sub(int a, int b, int k, int l, int r) {
      if (r <= a || b <= l) return 0;
      else if (a <= l && r <= b) return dat.at(k);
      else {
         T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
         T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
         return max(vl, vr);
      }
   }
};


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

    cin >> N;
    h.resize(N);
    a.resize(N);

    REP(i, N) cin >> h[i];
    REP(i, N) cin >> a[i];

    SegTree<ll> st(1 << 18);

    for (int i = 0; i < N; i++) {
        ll tmp = st.query(0, h[i]) + a[i];
        st.update(h[i], tmp);
    }

    cout << st.query(0, N + 1) << endl;

    return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  string S;
  int w;
  cin >> S >> w;

  string ans;
  for (int i=0; i<(int)S.size(); i+=w) ans.push_back(S[i]);

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main() {
    long long int N;
    cin >> N;

    long long int n = N * (N+1) * (N+2) / 6;
	
  	long long int u, v;
    for(int i = 0; i < N - 1; i++) {
      	cin >> u >> v;
      	if ( u < v) n -= u * (N + 1 - v);
        if ( u > v) n -= v * (N + 1 - u);
    }

    cout << n;
}


Measured memory_bytes: 3160
#include <stdio.h>
#include <math.h>

/*                                                                              
 *                                                                              
 */
int combi(int n, int x) {                                                       
    int i, count = 0;                                                           
    if (n > x * 9)                                                              
        return 0;                                                               
    if (x == 2) {                                                               
        if (n < 19)                                                             
            return 10 - abs(n - 9);                                             
        else                                                                    
            return 0;                                                           
    }                                                                           
    if (x == 1) {                                                               
        if (n < 9)                                                              
            return 1;                                                           
        else                                                                    
            return 0;                                                           
    }                                                                           
    for (i = 0; i <= n && i < 10 ; i++) {                                       
        count += combi(n - i, x - 1);                                           
    }                                                                           
                                                                                
    return count;                                                               
}

int main(void) {                                                                
    int n;                                                                      
                                                                                
    while(scanf("%d", &n) != EOF) {                                             
        printf("%d\n", combi(n, 4));                                            
    }                                                                           
                                                                                
    return 0;                                                                   
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define double ld
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ifstream in("input.txt");ofstream out("output.txt");
const int inf=1e18;
vector<vector<int> > dp;
vector<vector<char> > par;
string a;
string b;
int go(int i,int j)
{
    if(i<0||j<0)
        return 0;
    if(dp[i][j]!=inf)
        return dp[i][j];
    int ans=0;
    int up=go(i-1,j);
    int left=go(i,j-1);
    if(up>left)
    {
        par[i][j]='u';
        ans=go(i-1,j);
    }
    else
    {
        par[i][j]='l';
        ans=go(i,j-1);
    }
    if(ans<go(i-1,j-1)+(a[i]==b[j]))
    {
        ans=go(i-1,j-1)+(a[i]==b[j]);
        par[i][j]='d';
    }
    return dp[i][j]=ans;
}

signed main()
{
    cin>>a>>b;
    int n=a.size();int m=b.size();
    dp.resize(n,vector<int>(m,inf));
    par.resize(n,vector<char>(m,'a'));
    dp[0][0]=(a[0]==b[0]);
    int maxi=0;
    int maxj=0;
    int maxm=-1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(maxm<go(i,j))
            {
                maxi=i;
                maxj=j;
                maxm=go(i,j);
            }
        }
    }
//    for(int i=0;i<n;i++)
//    {
//        for(int j=0;j<m;j++)
//            cout<<dp[i][j]<<" ";
//        cout<<"\n";
//    }
//    return 0;
    string ans;
    while(maxi>=0&&maxj>=0&&par[maxi][maxj]!='a')
    {
        if(a[maxi]==b[maxj])
        {
            ans.push_back(a[maxi]);
            maxi--;
            maxj--;
        }
        else if(par[maxi][maxj]=='l')
            maxj--;
        else if(par[maxi][maxj]=='u')
            maxi--;
    }
    if(maxi>=0&&maxj>=0&&a[maxi]==b[maxj])
        ans.push_back(a[maxi]);
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}













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

int main(){
	string v;
	cin >> v;
	pair<char, int> one;
	pair<char, int> two;
	one.first = v[0];
	one.second = 1;
	two.first = 'z';
	two.second = 2;           
	for(int i = 1; i < 4; i++){
		if(one.first != v[i] && two.first == 'z'){
			two.first = v[i];
			two.second--;
			continue;
		}
		if(v[i] != one.first && two.first != v[i]){
			 cout << "No" << endl;
			 return 0;
		}
		if(v[i] == one.first)
			one.second--;
		if(v[i] == two.first)
			two.second--;	
	}
	if(one.second == two.second)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;	
	return 0;
}

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

int main() {
	string S;

	cin >> S;

	vector<int> cnt(2, 0);

	for (int i = 0; i < S.size(); i++) {
		cnt['1' - S[i]]++;
	}
	int ans = min(cnt[0], cnt[1]) * 2;

	cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n;
const int maxn=1e5+7;
struct node{
	int p;
	int w;
}s[maxn];
bool cmp(node a,node b){
	return a.w<b.w;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i].w;
		s[i].p=i;
	}
	sort(s+1,s+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(i!=n)
		cout<<s[i].p<<" ";
		else cout<<s[i].p;
	}
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  long double A;
  map<pair<int, int>, int> MA;
  long ans = 0;
  while (cin >> A) {
    long a = A * 1e9 + 0.5;
    int x = 0, y = 0;
    while (a % 2 == 0) a /= 2, x++;
    while (a % 5 == 0) a /= 5, y++;
    x = min(18, x);
    y = min(18, y);
    for (auto [a, b] : MA) {
      if (x + a.first >= 18 && y + a.second >= 18) ans += b;
    }
    MA[{x, y}]++;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

ll fac[120020], invfac[120020];

ll lpow(ll p, ll q) {
	ll ans = 1;
	ll pp = p;
	while (q) {
		if (q % 2) {
			ans *= pp;
			ans %= MOD;
		}
		q /= 2;
		pp *= pp;
		pp %= MOD;
	}
	return ans;
}

ll com(ll n, ll r) {
	if (n < r || n < 0 || r < 0)return 0;
	ll ans = 1;
	ll k = n - r;

	ans *= fac[n] * invfac[r];
	ans %= MOD;
	ans *= invfac[k];
	ans %= MOD;

	return ans;
}

void precom(int n) {
	rep(i, n + 1) {
		if (i == 0)fac[i] = 1;
		else fac[i] = (fac[i - 1] * i) % MOD;
		invfac[i] = lpow(fac[i], MOD - 2);
	}
	return;
}

int s[100020];
vi prime(0);

int main() {

	ll n, m;
	cin >> n >> m;

	if (m == 1 || n == 1) { cout << 1 << endl;return 0;
	}
	rep(i, 100020)s[i] = 1;
	rep1(i, 100000) {
		if (i < 2)continue;
		if (s[i] != 1)continue;

		prime.push_back(i);
		s[i] = i;
		int ii = i;
		while (ii <= 100000) {
			if (s[ii] == 1)s[ii] = i;
			ii += i;
		}
	}
	precom(120000);

	vi mp(0);

	int mm = m;
	int k = 0;
	while (mm>1&&k<prime.size()) {
		if (mm % prime[k])k++;
		else { mm /= prime[k];mp.push_back(prime[k]); }
	}
	if(mm>1)mp.push_back(mm);

	k = 1;
	ll ans = 1;
	rep(i, mp.size() - 1) {
		if (mp[i + 1] == mp[i])k++;
		else {
			ans *= com(n - 1 + k, k);
			ans %= MOD;
			k = 1;
		}
	}
	ans *= com(n - 1 + k, k);
	ans %= MOD;
	cout << ans << endl;

}

Measured memory_bytes: 2560
#include <stdio.h>
 
int main(void)
{
    int i, n;

	for(;;)
	{
		scanf("%d%d",&i,&n);

    if(i !=0&&n !=0)
	{
	for(int x=0;x<i;x++)
	{
	for(int y=0;y<n;y++)
	{
		printf("#");
	}
		printf("\n");
	}
	    printf("\n");
	}
	else{
		break;
	}
	}
    return 0;
}

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

int main (){
  int K, S;
  cin >> K >> S;
  
  int res = 0;
  
  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
      int k = S - i - j;
        if(0 <= k && k <= K) res++;
    }
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unordered_set<ll> uset;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=0;i<=n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
#define base 2100
bool ok[3][base*2];
void calc(ll id,string a,string b){
	for(int i=-base;i<base;i++){
		bool same=1;
		for(int j=0;j<a.size();j++){
			int k=j-i;
			if(0<=k&&k<b.size()){
				if(a[j]!='?'&&b[k]!='?'&&a[j]!=b[k]){
					same=0;
					break;
				}
			}
		}
		ok[id][i+base]=same;
	}
}
ll solve(string a,string b,string c){
	calc(0,a,b);
	calc(1,a,c);
	calc(2,b,c);
	int ans=1e9;
	for(int i=-base;i<base;i++)for(int j=-base;j<base;j++){
		if(ok[0][i+base]&&ok[1][j+base]){
			int d=j-i;
			if(-base<=d&&d<base&&ok[2][d+base]==0)continue;
			 int l=0; chmin(l,min(i,j));
			 int r=a.size(); chmax(r,max(i+(int)b.size(),j+(int)c.size()));
			 chmin(ans,r-l);
		}
	}
	return ans;
}
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	ll ans=solve(a,b,c);
	chmin(ans,solve(b,a,c));
	chmin(ans,solve(c,a,b));
	cout<<ans<<endl;
}


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

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

typedef long long ll;

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

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

    if(x>=30){
        cout<<"Yes"<<endl;

    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3672
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))

MOD = 10 ** 9 + 7

dp = [[0] * (M+1) for _ in range(N+1)]
dp_cum = [[0] * (M+1) for _ in range(N+1)]

for x in range(N):
    for y in range(M):
        if S[x] == T[y]:
            dp[x + 1][y + 1] += dp_cum[x][y] + 1
            dp[x + 1][y + 1] %= MOD

        dp_cum[x + 1][y + 1] = (dp_cum[x+1][y] % MOD) \
            + (dp_cum[x][y + 1] % MOD) \
            - (dp_cum[x][y] % MOD) \
            + (dp[x + 1][y + 1] % MOD)

        dp_cum[x + 1][y + 1] %= MOD

        #print("---x,y", x, y, "----")
        #print("dp:", dp)
        #print("dp_cum", dp_cum)


ans = dp_cum[N][M] + 1
print(ans)


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

template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}





int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    ll div = 0;
    cin >> a >> b >> c;
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        cout << 0 << endl;
        return 0;
    }else{
        div = min({a * b, b * c, c * a});
    }

    cout << div << endl;
    return 0;  
}

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

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; }

using ll = long long;

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> v(N);
  for(int i = 1; i <= N-1; i++){
    for(int j = i+1; j <= N; j++) {
      int l=min(j-i, min(abs(X-i)+abs(Y-j)+1, abs(Y-i)+abs(X-j)+1));
      v.at(l)++;
    }
  }
  for(int i = 1; i < N; i++) {
    cout << v.at(i) << endl;
  }
}
  

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[-1]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = map(int,readline().rstrip().split())
        tes[i][x-1] = y

cnt = 0
for i in range(2**N):
    hon = [0]*N
    for j in range(N):
        if (i>>j)&1:
            hon[j] = 1
    flag = True
    for j in range(N):
        if hon[j]:
            for k in range(N):
                if tes[j][k] == -1:
                    continue
                if tes[j][k] != hon[k]:
                    flag = False
                    break
            if not flag:
                break
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)

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

#define ll long long int

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

    vector<int> arr(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }

    vector<int> occ(100001, 0);
    vector<pair<int, int>> evens, odds;
    for (int i = 1; i <= n - 2; i += 2) {
        occ[arr[i]]++;
    }
    occ[arr[n - 1]]++;

    for (int i = 0; i < 100001; i++) {
        if (occ[i]) odds.push_back({occ[i], i});
    }

    sort(odds.begin(), odds.end(), greater<pair<int, int>>());

    for (int i = 0; i < 100001; i++) occ[i] = 0;

    for (int i = 2; i <= n - 2; i += 2) {
        occ[arr[i]]++;
    }
    occ[arr[n]]++;
    for (int i = 0; i < 100001; i++) {
        if (occ[i]) evens.push_back({occ[i], i});
    }

    sort(evens.begin(), evens.end(), greater<pair<int, int>>());

    /*
    for (auto p : odds) {
        cout << p.second << " occ " << p.first << endl;
    }
    cout << "----" << endl;
    for (auto p : evens) {
        cout << p.second << " occ " << p.first << endl;
    }
    */

    if (evens[0].second == odds[0].second) {
        int evens1 = evens[0].first, odds1 = odds[0].first, evens2, odds2;
        
        if (evens.size() <= 1) evens2 = 0;
        else evens2 = evens[1].first;

        if (odds.size() <= 1) odds2 = 0;
        else odds2 = odds[1].first;

        int ans = min(n - evens1 - odds2, n - evens2 - odds1);

        cout << ans << endl;
    } else {
        int ans = (n / 2 - evens[0].first) + (n / 2 - odds[0].first);
        cout << ans << endl;
    }
}


Measured memory_bytes: 2168
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <cmath>
#define INF 1000000007
using namespace std ;

int main(int argc, char const *argv[])
{

	int n ;
	cin>>n ;

	for(int i = 0 ; i < n ; i++)
	{
		int temp ;
		cin>>temp ;

		if(temp % 2 == 0)
		{
			if(temp % 3 != 0 &&  temp % 5 != 0){cout<<"DENIED"<<endl ; return 0 ;}
		}
	}

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

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;

fn next_permutation(a: &mut Vec<usize>) -> bool {
  let N: usize = a.len();
  for i in (0..N-1).rev() {
    if a[i] < a[i + 1] {
      a[i + 1..].reverse();
      for j in i + 1..N {
        if a[i] < a[j] {
          a[i] = a[i] ^ a[j];
          a[j] = a[i] ^ a[j];
          a[i] = a[i] ^ a[j];
          return true;
        }
      }
    }
  }
  false
}

fn main() {
  input! {
    N: usize,
    P: [Usize1; N],
    Q: [Usize1; N],
  }
  let mut v = vec![0; N];
  for i in 0..N {
    v[i] = i;
  }
  let mut a: i32 = -1;
  let mut b: i32 = -1;
  let mut cnt: i32 = 0;
  loop {
    if a == -1 && P == v {
      a = cnt;
    }
    if b == -1 && Q == v {
      b = cnt;
    }
    cnt += 1;
    if !next_permutation(&mut v) {
      break;
    }
  }
  println!("{}", i32::abs(a - b));
}

Measured memory_bytes: 2196
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>
 
using namespace std;
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (ll)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


void solve(){
    ll n, k;
    cin >> n >> k;
    map <ll, ll> m;
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        m[a] += b;
    }
    ll cur = 0;
    for(auto i : m){
        if(k > cur && k <= cur + i.second){
            cout << i.first;
            break;
        }
        cur += i.second;
    }
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 4224
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    char ban = 'L';
    bool ng = false;
    for (char c : S) {
        if (c == ban) ng = true;
        ban = ban == 'L' ? 'R' : 'L';
    }
    cout << (ng ? NO : YES) << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
d = []
A = []

for _ in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

cnt = {}
for i in range(N):
    cnt.setdefault(str(i + 1), 0)

for Ai in A:
    for Aij in Ai:
        cnt[str(Aij)] += 1

ans = 0
for key, val in cnt.items():
    if val == 0: ans += 1

print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n;
	cin >> n;
	cout << n * n * n << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
l = [0 for _ in range(n)]
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in a:
        if l[i-1] == 0:
            l[i-1] = 1
ans = 0
for i in l:
    if i == 0:
        ans += 1
print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int b = 1;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += a.at(i) - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
for i in range(10**5):
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        break
    else:
        for i in range(h):
            ans = ""
            if i %2 == 0:
                mode = 0
            else:
                mode = 1
            if mode == 0:
                for j in range(w):
                    if j%2 == 0:
                        ans += "#"
                    else:
                        ans += "."
                print(ans)
            else:
                for j in range(w):
                    if j%2 == 0:
                        ans += "."
                    else:
                        ans += "#"
                print(ans)
        print("")


Measured memory_bytes: 5616
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		for (int i=1; ; i++) {
			int x;
			if((x = stdIn.nextInt()) == 0)
				break;
			System.out.println("Case "+i+": "+x);
		}
	}
}

Measured memory_bytes: 32964
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i;
        for (i = 1; ; i++) {
            int x = sc.nextInt();
            if (x == 0) {
                break;
            }
            System.out.println("Case " + i + ": " + x);
        }
    }
}



Measured memory_bytes: 41284
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int t;
    cin >> t;
    int x = 1000 - (t % 1000);
    cout << (x == 1000 ? 0 : x) << endl;
}


Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int A[3];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	if (A[0] == A[1] && A[1] != A[2])
		cout << "Yes";
	else if (A[0] != A[1] && A[1] == A[2])
		cout << "Yes";
	else cout << "No";
}

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





int main(){
  int H,W,N;

  cin>>H>>W>>N;
  vector<long> a(N);

  for(int i=0;i<N;i++) cin>>a[i];
vector<vector<long>> ans(H,vector<long>(W));

int nh=0,nw=0;
for(int i=0;i<N;i++){
  int now=0;
  while(now<a[i]){
    if(nh%2==0){
      ans[nh][nw]=i+1;
    }
    else{
      ans[nh][W-nw-1]=i+1;
    }
    nw++;
    if(nw>=W) nh++,nw=0;
    now++;
  }
}

for(int i=0;i<H;i++) {
  for(int j=0;j<W;j++){
    cout<<ans[i][j]<<" ";
  }
  cout<<endl;
}


}


Measured memory_bytes: 512
lis1=[1,3,5,7,8,10,12]
lis2=[4,6,9,11]
lis3=[2]
x,y=map(int,input().split())
if (x in lis1 and y in lis1) or (x in lis2 and y in lis2) or(x in lis3 and y in lis3):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define l strlen(a)
using namespace std;
char a[100000];int x;
int main()
{
	scanf("%s",&a);x=abs(a[0]-a[l-1]);
	if(l%2==1){cout<<"No\n";return 0;}
	for(int i=0;i<l/2;i++,x=abs(a[i]-a[l-i-1]))
	  if(x!=1&&x!=2){cout<<"No\n";return 0;}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		char[][] s = new char[3][3];
		String str;
		for(int i = 0;i < 3;i++){
			str = saori.nextHayami();
			for(int j = 0;j < 3;j++){
				s[i][j] =str.charAt(j);
			}
		}
		System.out.print(s[0][0]);
		System.out.print(s[1][1]);
		System.out.print(s[2][2]);
		System.out.println("");
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22864
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;

int main( void ){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int diffx = tx - sx, diffy = ty - sy;
	char x = 'R', y = 'U';
	rep( d, 0, 2 ){
		rep( i, 0, diffy ){
			cout << y;
		}
		rep( i, 0, diffx ){
			cout << x;
		}
		x = 'L';
		y = 'D';
	}

	x = 'R';
	y = 'U';
	char z = 'L', w = 'D';
	rep( d, 0, 2 ){
		cout << z;
		rep( i, 0, diffy + 1 ){
			cout << y;
		}
		rep( i, 0, diffx + 1 ){
			cout << x;
		}
		cout << w;
		x = 'L';
		y = 'D';
		z = 'R';
		w = 'U';
	}
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, t;
    cin >> a >> b >> c;
    if(a>b){
        t = a;
        a = b;
        b = t;
    }
    if(b>c){
        t = b;
        b = c;
        c = t;
    }
    if(a>b){
        t = a;
        a = b;
        b = t;
    }
    cout << a << " " << b << " " << c << endl;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, m, t[400001];

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

ll q(ll a, ll b, ll k, ll l, ll r) {
	if (r <= a || b <= l) return 0;
	if (a <= l && r <= b) return t[k];
	ll vl = q(a, b, k*2+1, l, (l+r)/2);
	ll vr = q(a, b, k*2+2, (l+r)/2, r);
	if (vl == 0) return vr;
	if (vr == 0) return vl;
	return gcd(vl, vr);
}

int main(int argc, char **argv) {
	cin >> n;
	for (m = 1; m < n; m *= 2);
	REP(i, n) cin >> t[m-1+i];
	FOR(i, n, m) t[m-1+i] = t[m+n-2];
	REPR(i, m-1) t[i] = gcd(t[i*2+1], t[i*2+2]);
	ll res = 1;
	REP(i, n) {
		if (i == 0) res = max(res, q(i+1, n, 0, 0, m));
		else if (i == n-1) res = max(res, q(0, i, 0, 0, m));
		else res = max(res, gcd(q(0, i, 0, 0, m), q(i+1, n, 0, 0, m)));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 5684
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int n;

	cin >> n;
	int p[n];

	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	int cnt = 0;

	for (int i = 1; i < n-1; i++)
	{
		if (p[i-1] < p[i] && p[i] < p[i+1])
			cnt++;
		else if (p[i-1] > p[i] && p[i] > p[i+1])
			cnt++;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/abc089/tasks/abc089_d

# queryがたくさんある系
# query一つにつきO(1)ぐらいで応答しないと行けない→前処理の必要あり

# あるマスについてはD倍したマスだけ把握しておけばいいんじゃない？
'''
D=2
1 4 3
2 5 7
8 9 6
'''
# だったらstart=1,2において、移動のスコアの累積和を入れていく
# Qに回答時は、L%D番目のstartの累積和において、L//Dにおいて累積和の差を求めれば良い
# ピッタリDだった場合に面倒なので-0.5して置くのは良いかもしれない

from collections import defaultdict
from itertools import accumulate
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def get_cost(i, j, x, y):
    return abs(x - i) + abs(y - j)


H, W, D = read_ints()
A = read_matrix(H)
ruiseki = defaultdict(lambda: [])
num_to_co = {}

for i, a in enumerate(A):
    for j, aa in enumerate(a):
        num_to_co[aa] = (i, j)

for num in range(1, D + 1):
    pre_i, pre_j = num_to_co[num]
    pre_num = num
    ruiseki[num].append(0)
    while W * H >= pre_num + D:
        now_num = pre_num + D
        i, j = num_to_co[now_num]
        cost = get_cost(pre_i, pre_j, i, j)
        ruiseki[num].append(cost)
        # 必要なもの、前のi,j今のi,j 今の番号
        # 更新するもの 前のi,j←今のi,j 今の番号を次の番号に
        pre_i, pre_j = i, j
        pre_num = now_num

    ruiseki[num] = list(accumulate(ruiseki[num]))
# print(ruiseki)

# Qに答える番だ
Q = int(input())
for _ in range(Q):
    L, R = read_ints()
    tmp = ruiseki[L % D if L % D != 0 else D]
    # print(tmp)
    # print((R - 1) // D, (L - 1) // D)
    print(tmp[(R - 1) // D] - tmp[(L - 1) // D])


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

#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


ll a, b, c, x;
ll num = 0;
int main() {
	cin >> a >> b >> c >> x;
	REP(i, a+1) {
		REP(j, b+1) {
			REP(k, c+1) {
				if (500 * i + 100 * j + 50 * k == x) num++;
			}
		}
	}

	cout << num << endl;

	return 0;
}

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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int d,t,s;
	cin >> d >> t >> s;
	if(t >= (d + s - 1)/s){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define inf 1000000007
using namespace std;
ll ans[1000009],plc[509];
int addnum(int st, int num, int ct,int mv){
	int cnt = 0;
	int cid = st;
	while( cnt < ct && cid>=0){
		if(ans[cid]==0){
			ans[cid] = num;
			cnt++;
		}
		cid += mv;
	}
	return cid;
}

signed main(){
	int n;
	cin>>n;
	vector< pair<int,int> > v,r;
	vector<int> chec;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		v.pb(mp(x,i));
		r.pb(mp(x,i));
		ans[x]=i;
		chec.pb(x);
	}
	sort(v.begin(),v.end());
	sort(r.begin(),r.end());
	reverse(r.begin(),r.end());
	ll cur = 1;
	for(int i=0;i<n;i++){
		cur = addnum(cur,v[i].second, v[i].second-1, 1);
	}
	cur = n*n;
	for(int i=0;i<n;i++){
		cur = addnum(cur,r[i].second,n-r[i].second,-1);
	}
	map<int,int> mope;
	for(int i=1;i<=n*n;i++){
		mope[ ans[i] ] ++ ;
		if(mope[ ans[i] ] == ans[i]){
			plc[ ans[i] ] = i;
			//cout<<ans[i]<<" "<<i<<endl;
		}
	}
	for(int i=1;i<=n;i++){
		if( plc[i] != chec[i-1]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=1;i<=n*n;i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;

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

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

int main()
{
	int a,b;
	cin >> a >> b;
	cout << ((a*b)%2!=0?"Yes":"No") << endl;


	return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (1e9+7)
#define INF (1e9)
#define LLINF (4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    string s; input(s);
    int ans = s.size();
    REP(i, s.size()-1) {
        if (s[i] != s[i + 1]) {
            ans = min(ans, max(i+1,(int)s.size()-i-1));
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 512
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var s = next();
  for(var i = 0; i < s.length; i++){
    if(i % 2 == 0){
      if(s[i] == "L"){
        myout("No");
        return;
      }
    }else{
      if(s[i] == "R"){
        myout("No");
        return;
      }
    }
  }
  myout("Yes");
}

Measured memory_bytes: 30004
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int A,B,X;
    cin >> A >> B >> X;
    X -= A;
    if(X<=B && X >= 0)cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

namespace AtCoder
{
	class Program
	{
    void _()
    {

      int a = Split.Int();
      int b = Split.Int(); 
      int c = Split.Int();

      var aa = new BigInteger(a);
      var bb = new BigInteger(b);
      var cc = new BigInteger(c);

      if (cc-aa-bb>=0)
      {
        if ((cc - aa - bb) * (cc - aa - bb) - 4 * aa * bb > 0)
        {
          Console.WriteLine("Yes");
          return;
        }
      }
       
      Console.WriteLine("No");
      
        
    }

		static void Main(string[] args)
		{
      new Program()._();
    }
	}
}
static class Split
{
  public static string String()
  {
    if (_ss.Count == 0)
    {
      var s = Console.ReadLine();
      if (s == null)
        return null;

      _ss = s.Split(_delim).ToList();
    }

    var ret = _ss[0];
    _ss.RemoveAt(0);
    return ret;
  }

  public static int Int()
  {
    var str = String();
    return int.Parse(str);
  }
  public static long Long()
  {
    var str = String();
    return long.Parse(str);
  }

  static List<string> _ss = new List<string>();
  static char[] _delim = new[] { '\t', ' ' };
}

Measured memory_bytes: 13396