akhauriyash/Code-Regression huggingface dataset:
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int arr[MAX];

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

    int n;

    cin>>n;

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

    ll ans = 0, sum = 0;
    for(int i = n - 2; i >= 0; i--) {
        sum = (sum + arr[i+1]) % MOD;
        ans = (ans + (1LL * arr[i] * sum) % MOD) % MOD;
        ans %= MOD;
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 166, task , 2020/05/03
//ms,
/*
*/

int main(void){
  int64_t N, M;
  vector<int64_t> height(100000);
  int64_t A, B;
  vector<vector<int64_t>> connect(100000);
  int ans=0;

  cin >>N >>M;
  for(int64_t i=0;i<N;i++) cin >>height[i];
  for(int64_t i=0;i<M;i++){
    cin >>A >>B;
    connect[A-1].push_back(B-1);
    connect[B-1].push_back(A-1);
  }

  for(int64_t i=0;i<N;i++){
    for(size_t j=0;j<connect[i].size();j++){
      //cout <<i <<j <<endl;
      if(height[i]<=height[connect[i][j]]) goto NEXT_LOOP;
    }
    ans++;
    //cout <<i <<endl;
    NEXT_LOOP:continue;
  }

  cout <<ans <<endl;

  return 0;
}
/*
*/


Measured memory_bytes: 9804
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n;
    cin >> n;

    const int K = 28;

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

    vector<int> c(n), d(n);
    int r = 0;
    for (int k = 0; k <= K; k++) {
        int64_t p[2][2];
        int64_t qa[2], qb[2];
        int mask = (1 << k) - 1;
        for (int h = 0; h < 2; h++) {
            int m = 0;
            for (int i = 0; i < n; i++) {
                if ((b[i] >> k & 1) == h) d[m++] = b[i] & mask;
            }
            sort(d.begin(), d.begin() + m);
            qb[h] = m;

            for (int j = 0; j < 2; j++) {
                int l = 0;
                for (int i = 0; i < n; i++) {
                    if ((a[i] >> k & 1) == j) c[l++] = a[i] & mask;
                }
                sort(c.begin(), c.begin() + l, greater<>());
                qa[j] = l;

                int64_t s = 0;
                int x = 0;
                for (int i = 0; i < l; i++) {
                    for (; x < m; x++) {
                        if (c[i] + d[x] > mask) break;
                    }
                    s += x;
                }
                p[h][j] = s;
            }
        }
        int64_t y = 0;
        for (int h = 0; h < 2; h++) {
            for (int j = 0; j < 2; j++) {
                int64_t t0 = qa[j] * qb[h];
                int64_t t1 = p[h][j];
                 
                if (!(h + j & 1)) y += t0 - t1; else y += t1;
            }
        }
        if (y & 1) r ^= 1 << k;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int n,m;
    cin>>n>>m;
    int x=1;
    int y=1;
    for(int i=0;i<n;i++){
        x=x*2;
    }
    for(int i=0;i<m;i++){
        y=y*2;
    }
    int a[x][y];
    for(int I=1;I<x;I++){
        for(int J=1;J<y;J++){
            int i=I;
            int j=J;
            while(i%2==0&&j%2==0){i=i/2;j=j/2;}
            if((i+j)%2==0){a[I][J]=1;}
            else{a[I][J]=0;}
        }
    }
    for(int i=1;i<x;i++){
        for(int j=1;j<y;j++){
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}

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

int main() {
  
  int n, d;
  cin >> n >> d;
  
  cout << (n+d*2)/(d*2+1) << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>



using ll = long long;


using namespace std;
int gcd(int a, int b) {
	if (a < b) {
		int t = a;
		a = b;
		b = t;
	}
	
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int factorial(ll n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else
		return 1;
}
int main()
{/*13日目*/
	int x, n;
	cin >> x >> n;
	vector<int> pp(n);
	
	int min = 100;
	int ans;
	
	for (int i = 0;i < n;i++) 
		cin >> pp[i];
	for (int i = 0;i < 102;i++) {
		bool ok = true;
		for (int j = 0;j < n;j++) {
			if (i == pp[j])
				ok = false;

		}
		if (ok) {
			if (min > abs(x - i)) {
				min = abs(x - i);
				ans = i;
			}
			
		}
	}cout << ans;
		



}

Measured memory_bytes: 3624
#include <stdio.h>

int main()
{

int a[10000], min, max, n, i;
long long sum = 0;
scanf("%d", &n);
for(i = 0; i < n; i++){
scanf("%d", &a[i]);
sum += a[i];
}
max = min = a[0];
for(i = 1; i < n; i++){
if(a[i] > max)max = a[i];
if(a[i] < min)min = a[i];
}
printf("%d %d %lld\n", min, max, sum);

return 0;
}


Measured memory_bytes: 2120
import java.util.*;
import java.io.*;
import java.math.*;
class Main{
    public static void main(String[] args) {
        MyScanner sc=new MyScanner();
        long a=sc.nextLong();
        long b=sc.nextLong();
        long c=(long)Math.round((a+b)/2.0);
        System.out.println(c);
    }


    private static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int nextInt() {
          return Integer.parseInt(next());
      }

      long nextLong() {
          return Long.parseLong(next());
      }

      double nextDouble() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

Measured memory_bytes: 20944
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  map<int, vector<pair<int, char> > > amap;
  map<int, vector<pair<int, char> > > bmap;
  map<int, vector<pair<int, char> > > cmap;
  map<int, vector<pair<int, char> > > dmap;
  int X, Y;
  char U;
  vector<int> aarr, barr, carr, darr;
  for(int i=0;i<N;++i) {
    cin>>X>>Y>>U;
    if(amap[X+Y].size()==0) aarr.push_back(X+Y);
    amap[X+Y].push_back(mp(X, U));
    if(bmap[X-Y].size()==0) barr.push_back(X-Y);
    bmap[X-Y].push_back(mp(X, U));
    if(cmap[X].size()==0) carr.push_back(X);
    cmap[X].push_back(mp(Y, U));
    if(dmap[Y].size()==0) darr.push_back(Y);
    dmap[Y].push_back(mp(X, U));
  }
  for(int i=0;i<aarr.size();++i) sort(amap[aarr[i]].begin(), amap[aarr[i]].end());
  for(int i=0;i<barr.size();++i) sort(bmap[barr[i]].begin(), bmap[barr[i]].end());
  for(int i=0;i<carr.size();++i) sort(cmap[carr[i]].begin(), cmap[carr[i]].end());
  for(int i=0;i<darr.size();++i) sort(dmap[darr[i]].begin(), dmap[darr[i]].end());
  int u, r, d, l;
  int ans = inf;
  for(int i=0;i<aarr.size();++i) {
    u = -1;
    r = -1;
    d = -1;
    l = -1;
    for(int j=0;j<amap[aarr[i]].size();++j) {
      if(amap[aarr[i]][j].se=='U') {
        if(r!=-1) ans = min(ans, (amap[aarr[i]][j].fi-r)*10);
      }
      if(amap[aarr[i]][j].se=='R') {
        r = amap[aarr[i]][j].fi;
      }
      if(amap[aarr[i]][j].se=='D') {
        d = amap[aarr[i]][j].fi;
      }
      if(amap[aarr[i]][j].se=='L') {
        if(d!=-1) ans = min(ans, (amap[aarr[i]][j].fi-d)*10);
      }
    }
  }
  for(int i=0;i<barr.size();++i) {
    u = -1;
    r = -1;
    d = -1;
    l = -1;
    for(int j=0;j<bmap[barr[i]].size();++j) {
      if(bmap[barr[i]][j].se=='U') {
        u = bmap[barr[i]][j].fi;
      }
      if(bmap[barr[i]][j].se=='R') {
        r = bmap[barr[i]][j].fi;
      }
      if(bmap[barr[i]][j].se=='D') {
        if(r!=-1) ans = min(ans, (bmap[barr[i]][j].fi-r)*10);
      }
      if(bmap[barr[i]][j].se=='L') {
        if(u!=-1) ans = min(ans, (bmap[barr[i]][j].fi-u)*10);
      }
    }
  }
  for(int i=0;i<carr.size();++i) {
    u = -1;
    for(int j=0;j<cmap[carr[i]].size();++j) {
      if(cmap[carr[i]][j].se=='U') {
        u = cmap[carr[i]][j].fi;
      }
      if(cmap[carr[i]][j].se=='D') {
        if(u!=-1) ans = min(ans, (cmap[carr[i]][j].fi-u)*5);
      }
    }
  }
  for(int i=0;i<darr.size();++i) {
    r = -1;
    for(int j=0;j<dmap[darr[i]].size();++j) {
      if(dmap[darr[i]][j].se=='R') {
        r = dmap[darr[i]][j].fi;
      }
      if(dmap[darr[i]][j].se=='L') {
        if(r!=-1) ans = min(ans, (dmap[darr[i]][j].fi-r)*5);
      }
    }
  }
  if(ans==inf) cout<<"SAFE"<<endl;
  else cout<<ans<<endl;
}



Measured memory_bytes: 72032
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    n = len(s)

    subss = [""]
    subs = ""
    res = 0
    for i in range(n):
        subs += s[i]
        if subss[-1] != subs:
            subss.append(subs)
            res += 1
            subs = ""

    print(res)


if __name__ == '__main__':
    resolve()


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

int main() {
	int s;
	cin >> s;
	map<int,int> a;
	int now = s;

	rep(i,1000000){
		if(a[now] == 0) a[now]++;
		else{
			cout << i+1 << endl;
			return 0;
		}

		if(now&1){
			now = 3*now+1;
		}else{
			now = now/2;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<string, bool> gacha;
int n, d=0; string s;
int main() {
	cin >> n;
  	while (n--) {
       	cin >> s;
      	if (!gacha[s]) {
          gacha[s]=1; d++;
        }
    }
  	cout << d;
}

Measured memory_bytes: 19260
#include<iostream>
using namespace std;
int main(){
  int a,b,cnt;
  cin >> a >> b;
  cnt = 0;
  if(a>=b){
    cnt+=a;
    a--;
  }else{
    cnt+=b;
    b--;
  }
  if(a>=b){
    cnt+=a;
    a--;
  }else{
    cnt+=b;
    b--;
  }
  cout << cnt <<endl;
}



Measured memory_bytes: 256
# 2020/07/25
# M-SOLUTIONS プロコンオープン 2020 - B

# Input
a, b, c = map(int,input().split())
k = int(input())

# Calc
idx = 0
while idx < k:
    if a >= b:
        b = b * 2
    elif b >= c:
        c = c * 2
    else:
        break
    idx = idx + 1

if a < b and b < c:
    ans = 'Yes'
else:
    ans = 'No'

# Output
print(ans)


Measured memory_bytes: 9052
#include <stdio.h>

int main(void) {
	long int n, i, x, y;
	scanf("%ld %ld", &x, &y);
	n = y;
	while(n != 0){
		long int b = n;
		n = x%n;
		x = b;
	}
	printf("%ld\n", x);
	return 0;
}

Measured memory_bytes: 592
#include <cstdio>
#include <algorithm>
#define rep(i,j,k) for (i=j;i<=k;i++)
#define edge(j) for (j=fst[x];j;j=nxt[j])
using namespace std;
const int N=1e5+5;
int n,m,i,j,u,v,from,trans;
int odd,even,ans,delta;
int pn,p[N],s[N],bw[2],cnt[2];
int En,fst[N],vis[N],col[N],nxt[N*2],to[N*2],have[N];
void add(int u,int v) {
	En++; nxt[En]=fst[u]; fst[u]=En; to[En]=v;
}
void dfs(int x,int fa,int flg)
{
	int j,v;
	vis[x]=1; col[x]=flg; cnt[flg]++;
	edge(j)
	{
		v=to[j];
		if (v==fa) continue;
		if (vis[v]) {
			trans=v; from=x;
			if (col[x]==col[v]) odd=1;
			else even=1;
			continue;
		}
		dfs(to[j],x,flg^1);
	}
}
void dfs2(int x,int fa)
{
	int j,v;
	if (trans==x && even) have[x]=1;
	edge(j)
	{
		v=to[j];
		if (x==from && v==trans) continue;
		if (x==trans && v==from) continue;
		if (v==fa) continue;
		dfs2(v,x);
		if (have[v]) have[x]=1;
		s[x]+=s[v];
	}
	if (x!=from) {
		if (have[x]) p[++pn]=s[x];
		else ans+=abs(s[x]);
	}
}
int main()
{
	//freopen("reverse.in","r",stdin);
	//freopen("reverse.out","w",stdout);
	scanf("%d%d",&n,&m);
	rep(i,1,m)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
	}
	dfs(1,1,0);
	bw[0]=0; bw[1]=1;
	if (cnt[0]<cnt[1]) swap(bw[0],bw[1]); //to ensure num[black]<=num[white]
	rep(i,1,n) {
		col[i]=bw[col[i]];
		if (col[i]) s[i]=1;
		else s[i]=-1;
	}
	
	if (odd) {
		delta=abs(cnt[0]-cnt[1]);
		if (delta%2) { printf("-1\n"); return 0; }
		ans+=delta/2;
		s[trans]+=delta/2;
	}
	else if (cnt[0]!=cnt[1]) { printf("-1\n"); return 0; }
	
	if (!from) from=1;
	dfs2(from,from);
	
	if (even) {
		p[++pn]=0; //abs(x) should be counted 
		sort(p+1,p+1+pn);
		rep(i,1,pn) ans+=abs(p[i]-p[pn/2+1]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8704
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        // 入力
        String sss = sc.next();
        // 出力
        int val = Integer.parseInt(sss);
        int len = sss.length();
        int num = 0;
        for (int i = 0; i < len; i++) {
            num += val & 0x01;
            val >>= 1;
        }
        System.out.println(num);
        sc.close();
    }
}


Measured memory_bytes: 21844
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
a = sorted(list(set(a)))
from fractions import gcd
lc = a[0]
if n != 1:
  for num,i in enumerate(a[1:]):
    if lc == 0:
      break
    lc = lc * i // gcd(lc, i)
    if gcd(lc, i) == min(i,lc):
      for j in a[:num+1]:
        if (i/j)%2 == 0:
          lc = 0
          break 
if lc == 0:
  print(0)
else:
  print((m+lc//2)//lc)

Measured memory_bytes: 77664
def Next(i):
    if i == "a":
        return 0
    if i == "b":
        return 1
    if i == "c":
        return 2

Cards = []
for i in range(3):
    Cards.append(list(input()))

trush = Cards[0].pop(0)
NextTurn = Next(trush)

while True:
    if Cards[NextTurn] == []:
        print("A" if NextTurn == 0 else "B" if NextTurn == 1 else "C")
        break
    else:
        trush = Cards[NextTurn].pop(0)
        NextTurn = Next(trush)

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

int main(){
	string s, t;
	cin >> s >> t;  
  	int a, b;
  	cin >> a >> b;
  	string u;
  	cin >> u;
  	if(s == u) a--;
  	else b--;
  	cout << a << " " << b <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int Tile(int, int, int); 

int main(){
  int i, n, k, a, b, x, ans;

  scanf("%d %d", &n, &k);

  for(i=0; i<k; i++){
    scanf("%d %d", &a, &b);
    x = Tile(n, a, b);
    ans = x%3;
    if(ans == 0) ans = 3;
    printf("%d\n", ans);
  }

  return 0;
}

int Tile(int n, int i, int j){
  if(n%2 == 0){
    if(i > n/2) i = n-i+1;
    if(j > n/2) j = n-j+1;
  }else{
    if(i > n/2+1) i = n-i+1;
    if(j > n/2+1) j = n-j+1;
  }

  if(i < j) return i;
  else return j;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m; cin>>n>>m;
    if (n*2>m){
        cout<<m/2<<endl;
        return 0;
    }
    cout<<n+(m-n*2)/4<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll n, k;
    cin >> n >> k;
    vll used(n);
    ll d;
    REP(i, k) {
        cin >> d;
        ll a;
        REP(j, d) {
            cin >> a;
            a--;
            used[a] = 1;
        }
    }
    ll res = 0;
    REP(j, n) {
        if (used[j] == 0) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3640
N=int(input())
L=list(map(int,input().split()))
cnt=0
for i in range(0,N-2,1):
    for j in range(i+1,N-1,1):
        for k in range(j+1,N,1):
            if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i] and L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]:
                cnt=cnt+1
print(cnt)


Measured memory_bytes: 9184
n = int(input())

price = {1}
for i in range(1, 100):
    tmp = 6**i
    if tmp > 10**5:
        break
    price.add(tmp)

for i in range(1, 100):
    tmp = 9**i
    if tmp > 10**5:
        break
    price.add(tmp)

price = list(price)
price.sort(reverse=True)

INF = 1 << 60

dp = [INF] * 2 * 10**5
dp[0] = 0
dp[1] = 1

for i in range(n + 1):
    for p in price:
        dp[i + p] = min(dp[i] + 1, dp[i + p])

print(dp[n])

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a == b){
        cout << "a == b" << endl;
    }else if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a < b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
class Chokudai
    MAX = 40
    def initialize()
        @divided = []
    end

    def count(x, mask)
        xm = x % mask
        result = [0, xm - (mask / 2) + 1].max + (x - xm) / 2
        return result
    end
    def solve(a, b)
        mask = 2
        MAX.times do |i|
            bit = (self.count(b, mask) - self.count(a - 1, mask)).abs % 2
            @divided.unshift(bit.to_s)
            mask <<= 1
        end
    end

    def answer()
        puts(@divided.join("").to_i(2))
    end
end
inputs = STDIN.readlines.map{|line|line.strip.split()}
input = inputs.shift
a = input[0].to_i
b = input[1].to_i
max = (10 ** 12).to_s(2).size
chokudai = Chokudai.new
chokudai.solve(a, b)
chokudai.answer


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  while(K--){
    int ai,bi;
    cin >> ai >> bi;
    cout << (min(min(ai-1,N-ai),min(bi-1,N-bi)))%3+1 << endl;
  }
}

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

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(string, S);

    string  ans = "Good";
    if ( S[0] == S[1] || S[1] == S[2] || S[2] == S[3] ) {
        ans = "Bad";
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    vector<pair<int, int>> A(N);
    for (int i = 0; i < N; i++) {
        int p; cin >> p; A[i] = { p, i };
    }
    multiset<int> S = { -1, -1, N, N };
    sort(rbegin(A), rend(A));
    long long ans = 0;
    for (auto &p : A) {
        int val, idx; tie(val, idx) = p;
        auto it = S.insert(idx);
        long long L1 = *prev(it), L2 = *prev(prev(it));
        long long R1 = *next(it), R2 = *next(next(it));
        ans += ((L1 - L2) * (R1 - idx) + (idx - L1) * (R2 - R1)) * val;
    }
    cout << ans << '\n';
    return 0;
}


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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a&&c>0)
    {
      c-=b;
      if(c<=0)
      {
          cout<<"Yes";
          break;
      }
      a-=d;
      if(a<=0)
      {
          cout<<"No";
          break;
      }
    }

    return 0;
}


Measured memory_bytes: 3620
my $n=<>;chomp $n;
my $numbers=<>;chomp$numbers;
my @a=split(/ /,$numbers);
my @sorted=sort{ $a <=> $b } @a;
my@t;my $sorted;my $t;
if($n%2==0){foreach(1..$n/2) {push(@t,$_*2-1,$_*2-1);}$n=$n/2;}
		else{push(@t,0);foreach(1..($n-1)/2){push(@t,$_*2,$_*2);}$n=($n-1)/2;}

$sorted=join('/',@sorted);$t=join('/',@t);
my $answer=0;my $counter=0;
if($sorted eq $t){$answer++;while($counter<$n){$answer=$answer*2%(10**9+7);$counter++;}}
print $answer;


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

int mod = 1000000007;
long long dp[100005];;

long long gcd(long long a,long long b){

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


 int main(){

 long long a,b;
 long long ans = 1;
 cin>>a>>b;

  if(a>0 && b>0)
    cout<<"Positive"<<endl;
  else if(a<0 && b<0){

     long long diff = abs(a-b)+1;

     if(diff%2 == 1)
       cout<<"Negative"<<endl;
     else if(diff%2 == 0)
       cout<<"Positive"<<endl;
  }
  else if(a<0 && b>0 )
          cout<<"Zero"<<endl;
 return 0;
 }


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
 int a,b;
 char buf[1000];
  
  fgets(buf,sizeof(buf),stdin);
  sscanf(buf,"%d %d",&a,&b);
  if(a*b%2 == 0) printf("Even");
  else printf("Odd");
 
  return 0;
}

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

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n+2);
	vector<ll> d(n+2);
	a[0] = 1;
	d[0] = 1;
	ll f = 0;
	ll k = 0;
	ll ans = 0;
	ll dm = 1;
	rep(i, n+1){
		ll in;
		cin >> in;
		a[i] -= in;
		if(i != n) a[i+1] = a[i]*2;
		if(i > 0) d[i] = a[i-1];
		rep(j, in){
			while(d[k] <= 0){
				if(k == i) break;
				k++;
			}
			if(k == i && d[k] == 0){ f = 1; break;}
			ll mi = min(d[k], in-j);
			d[k] -= mi;
			j += mi - 1;
			ans += (i - k + 1)*mi;
		}
		if(f == 1) break;
	}
	if(f == 0){
		cout << ans << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int a,b,k;
  cin >> a >> b >> k;
  int i;
  for(i = a;i <= b;++i){
    if(i <= a+k-1 || i>= b-k+1){
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl
int gcd(int x, int y){
    if ((x==1)||(y==1)) {
        return 1;
    }
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}
int main() {
    IN(int, n);
    vector<int> a(n,0);
    REP(i, n-1){
        IN(int, k);
        a[k-1]++;
    }
    REP(i, n){
        COUT(a[i]);
    }
}




Measured memory_bytes: 4052
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

S = input()

j = 0
flag = 0
ans = [0 for i in range(len(S))]
for i in range(len(S)):
    if S[i] == "L" and flag == 0:
        ans[i-1] += (i -j + 1) // 2
        ans[i] += (i-j) // 2
        j = i
        flag = 1
    if S[i] == "R" and flag == 1:
        ans[j-1] += (i-j) // 2
        ans[j] += (i-j+1) // 2
        j = i
        flag = 0
ans[j-1] += (len(S)-j) // 2
ans[j] += (len(S)-j+1) // 2

ans = map(str, ans)
print(" ".join(ans))

Measured memory_bytes: 93956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int n;
int main() {
  //  freopen("test.txt","r",stdin);
    int n,k;
    int a[maxn];
    cin>>n>>k;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    ll ans=0;
    for(int i=1;i<=(n-k);i++) {
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
int main(){
 int n;
 scanf("%d",&n);
 int F[50];
 F[0]=F[1]=1;
 for(int i=2;i<=n;i++)F[i]=F[i-1]+F[i-2];
 printf("%d\n",F[n]);
 return 0;
}


Measured memory_bytes: 2664
#aのn乗を計算
def pow(a,n):
  if n==0:
    return 1
  else:
    k=pow(a*a,n//2)
    if n%2==1:
      k=k*a
  return k

h=int(input())
cnt=0
while h>1:
  h=h//2
  cnt=cnt+1
  
print(2*pow(2,cnt)-1)


Measured memory_bytes: 9060
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long plus = 0, minus = 0, sum = 0;
  long abs, min = -1, min_i;
  for (long i = 0; i < n; i++) {
    if (a[i] >= 0) {
      plus++;
      abs = a[i];
    } else {
      minus++;
      abs = -a[i];
    }
    sum += abs;
    if (min == -1 || abs < min) {
      min = abs;
      min_i = i;
    }
  }
  if (plus == 0 || minus == 0) {
    sum -= min*2;
  }
  printf("%ld\n", sum);
  if (plus == 0) {
    for (long i = 0; i < n; i++) {
      if (i == min_i) {
        continue;
      }
      printf("%ld %ld\n", a[min_i], a[i]);
      a[min_i] -= a[i];
    }
  } else if (minus == 0) {
    long other;
    for (long i = 0; i < n; i++) {
      if (i != min_i) {
        other = i;
        break;
      }
    }
    for (long i = 0; i < n; i++) {
      if (i != min_i && i != other) {
        printf("%ld %ld\n", a[min_i], a[i]);
        a[min_i] -= a[i];
      }
    }
    printf("%ld %ld\n", a[other], a[min_i]);
  } else {
    long p_1,m_1;
    for (long i = 0; i < n; i++) {
      if (a[i] >= 0) {
        p_1 = i;
        break;
      }
    }
    for (long i = 0; i < n; i++) {
      if (a[i] < 0) {
        m_1 = i;
        break;
      }
    }
    for (long i = 0; i < n; i++) {
      if (i != p_1 && i != m_1) {
        if (a[i] >= 0) {
          printf("%ld %ld\n", a[m_1], a[i]);
          a[m_1] -= a[i];
        } else {
          printf("%ld %ld\n", a[p_1], a[i]);
          a[p_1] -= a[i];
        }
      }
    }
    printf("%ld %ld\n", a[p_1], a[m_1]);
  }

  return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

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

int main() {

    ll H,W,h,w;
    cin >> H >> W >> h >> w;
    ll out = H*W - (h*W+H*w-h*w);
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC_BC
{
    class Program
    {
        static int _Mod = 1000000007;

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            long Nf = Factorial(N)[N];
            long[] s = new long[N];
            for (int i = 0; i < N; i++) //i:距離
            {
                long val = (Nf * InverseElement(i+1)) % _Mod;
                if (i == 0) s[i] = val;
                else s[i] = (s[i - 1] + val) % _Mod;
            }

            long sum = 0;
            for (int i = 0; i < N; i++)
            {
                //減算により負になる場合があるので一旦正値にする必要がある
                long ss = s[N - i - 1] + s[i] - s[0];ss += _Mod; ss %= _Mod;
                long val = A[i] * ss; val %= _Mod;
                sum += val; sum %= _Mod;
            }
            Console.WriteLine(sum);
        }

        //階乗n!(mod p)のベクトル
        public static List<long> Factorial(int n)
        {
            long x = 1;
            List<long> list = new List<long>();
            list.Add(x);
            for (int i = 1; i <= n; i++)
            {
                x = (x * i) % _Mod;
                list.Add(x);
            }
            return list;
        }

        //累乗(a^n) O(logn)
        public static long ModPow(long a, int n)
        {
            long res = 1;
            while (n > 0)
            {
                if (n % 2 == 1) res = (res * a) % _Mod;
                a = (a * a) % _Mod;
                n >>= 1;
            }
            return res;
        }


        //逆元1/n(mod p) (1<=n<p)
        public static long InverseElement(long n)
        {
            return ModPow(n, _Mod - 2);
        }

    }
}


Measured memory_bytes: 22240
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

ans = 0

for i in range(N):
    A = list(map(int, input().split()))
    
    l = 0
    for a, b in zip(A, B):
        l += a * b
    
    if l + C > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
#define F first
#define S second
#define PB push_back

typedef long long int ll;
constexpr int kN = int(5E1 + 10);
constexpr ll kInf = ll(1E16 + 10);

string s[kN];
int c[kN], sz[kN], idx[kN][kN];
vector<pair<int, ll>> graph[kN * kN];
ll dp[kN * kN];

int main() {
	int n, now, tot = 0, lpos, rpos;
	ll ans = kInf;
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
	pair<ll, int> nxt;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> s[i] >> c[i];
	for (int i = 1; i <= n; i++) sz[i] = int(s[i].size());
	for (int i = 1; i <= n; i++) for (int j = 0; j <= (sz[i] << 1) + 1; j++) idx[i][j] = ++tot;
	for (int i = 1; i <= n; i++) for (int j = 0; j < sz[i]; j++) {
		for (int k = 1; k <= n; k++) {
			now = 0;
			while (now < sz[k] && now + j < sz[i]) {
				if (s[i][now + j] == s[k][sz[k] - 1 - now]) now++;
				else break;
			}
			if (now == sz[k]) graph[idx[i][j]].PB({idx[i][now + j], c[k]});
			else if (now + j == sz[i]) graph[idx[i][j]].PB({idx[k][now + sz[k] + 1], c[k]});

			now = 0;
			while (now < sz[k] && now + j < sz[i]) {
				if (s[i][sz[i] - now - j - 1] == s[k][now]) now++;
				else break;
			}
			if (now == sz[k]) graph[idx[i][j + sz[i] + 1]].PB({idx[i][now + j + sz[i] + 1], c[k]});
			else if (now + j == sz[i]) graph[idx[i][j + sz[i] + 1]].PB({idx[k][now], c[k]});
		}
	}
	for (int i = 1; i <= tot; i++) dp[i] = kInf;
	for (int i = 1; i <= n; i++) pq.push({dp[idx[i][0]] = c[i], idx[i][0]});
	
	while (!pq.empty()) {
		nxt = pq.top();
		pq.pop();
		if (dp[nxt.S] < nxt.F) continue;
		for (pair<int, ll> i : graph[nxt.S]) if (dp[i.F] > nxt.F + i.S) {
			dp[i.F] = nxt.F + i.S;
			pq.push({dp[i.F], i.F});
		}
	}


	for (int i = 1; i <= n; i++) ans = min(ans, dp[idx[i][sz[i]]]);
	for (int i = 1; i <= n; i++) ans = min(ans, dp[idx[i][sz[i] << 1 | 1]]);

	for (int i = 1; i <= n; i++) for (int j = 0; j < sz[i]; j++) {
		lpos = j, rpos = sz[i] - 1;
		while (lpos < rpos) {
			if (s[i][lpos] == s[i][rpos]) lpos++, rpos--;
			else break;
		}
		if (lpos >= rpos) ans = min(ans, dp[idx[i][j]]);
		
		lpos = j, rpos = sz[i] - 1;
		while (lpos < rpos) {
			if (s[i][sz[i] - 1 - lpos] == s[i][sz[i] - 1 - rpos]) lpos++, rpos--;
			else break;
		}
		if (lpos >= rpos) ans = min(ans, dp[idx[i][j + sz[i] + 1]]);
	}

	if (ans == kInf) ans = -1;
	cout << ans << '\n';
}


Measured memory_bytes: 3796
#include <stdio.h>

int main(int argc, char *argv[])
{
    int i, H, W;
    char buf[256];
    scanf("%d %d\n", &H, &W);
    for ( i = 0; i < H; i++ ){
        fgets(buf, sizeof(buf), stdin);
        printf("%s", buf);
        printf("%s", buf);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
int a[114];
signed main() {
	int n,cnt=0,ans=0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cnt += a[i];
	if (cnt % 10 != 0)cout << cnt << endl;
	else {
		sort(a, a + n);
		for (int i = 0; i < n; i++) {
			if (a[i] % 10 == 0)ans++;
			if (a[i] % 10 == 0)continue;
			cnt -= a[i];
			if (a[i] % 10 != 0)break;
		}
		if (ans == n)cout << 0 << endl;
		else cout << cnt << endl;
	}
	ll
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ans := 1
	var a int
	jt := 0
	fmt.Scan(&a)
	for i := 1; i < n; i++ {
		var b int
		fmt.Scan(&b)
		if a != b {
			if jt == 0 {
				if a < b {
					jt = 1
				} else {
					jt = -1
				}
			} else {
				if a < b {
					if jt == -1 {
						ans++
						jt = 0
					}
				} else {
					if jt == 1 {
						ans++
						jt = 0
					}
				}
			}
		}
		a = b
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
import itertools
n = int(input())
l = []
for i in range(n):
    x,y = map(int, input().split())
    l.append((x, y))
perm = list(itertools.permutations(range(n),n))
ans = 0
for p in perm:
    for i in range(n-1):
        ans += ((l[p[i]][0] - l[p[i+1]][0])**2 +(l[p[i]][1] - l[p[i+1]][1])**2)**0.5
ans /=len(perm)
print(ans)

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

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

  if (a % 2 == 1 && b % 2 == 1 ) {
    cout << "Odd" << endl;
  } else {
    cout << "Even" << endl;
  }
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string ans="";
	int anssize=0;
	rep(i,s.size()){
		if(s.at(i)=='1' || s.at(i)=='0'){
			ans+=s.at(i);
			anssize++;
		}
		else if(s.at(i)=='B' && anssize>0){
			ans=ans.substr(0,anssize-1);
			anssize--;
		}
	}
	cout << ans << endl;
}

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

deque<int> Q;
int N,arr[200000];
int main(){
  cin >> N;
  for (int i=0;i<N;i++){
    cin >> arr[i];
  }
  
  Q.push_front(arr[0]);
  for (int i=1;i<N;i++){
    if (i%2 == 1){
      Q.push_back(arr[i]);
    }
    else{
      Q.push_front(arr[i]);
    }
  }
  int n = bool(N%2);
  for (int i=0;i<N;i++){
    if (n == 0){
      cout << Q.back() << " ";
      Q.pop_back();
    }
    else{
      cout << Q.front() << " ";
      Q.pop_front();
    }
  }
  
  return 0;
}

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

using namespace std;

const int N = 105;

int a[N];
int b[N];

void del(int id) {
	for (int i = id; i < N - 1; ++i) {
		b[i] = b[i + 1];
	}
}

int main() {
	int n; 
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> b[i];
	}
	for (int i = n; i > 0; --i) {
		int id = -1;
		for (int j = 1; j <= i; ++j) {
			if (b[j] == j) {
				id = j;
			}
		}
		if (id == -1) {
			puts("-1");
			return 0;
		}
		del(id);
		a[i] = id;
	}
	for (int i = 1; i <= n; ++i) {
		printf("%d\n", a[i]);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,t;
    cin>>a>>b>>t;
    int sum=0;
    for (int i=1;i<=t;i++) {
        if (i%a==0) {
            sum+=b;
        }
    }
    cout<<sum<<endl;
}


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


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(auto& a : A){
    cin >> a;
  }
  // max_1 <= max_2
  int max_1 = min(A[0], A[1]);
  int max_2 = max(A[0], A[1]);
  for(int ii=2; ii<N; ii++){
    if(A[ii] > max_2){
      max_1 = max_2;
      max_2 = A[ii];
    }else if(A[ii] > max_1){
      max_1 = A[ii];
    }
  }
  for(auto& a : A){
    if(max_1==max_2){
      cout << max_2 << endl;
    }else if(a==max_2){
      cout << max_1 << endl;      
    }else{
      cout << max_2 << endl;      
    }
  }
  return 0;
}


Measured memory_bytes: 2432
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    k,x=map(int,input().split())
    print("Yes" if(500*k>=x) else "No")
resolve()

Measured memory_bytes: 38256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();

		List<Integer> p = new ArrayList<>();

		for (int i = 0; i < N; i++)
			p.add(sc.nextInt());

		int count = 0;

		for (int i = 0; i < p.size(); i++) {
			if (p.get(i) != i + 1)
				count++;
		}

		System.out.println(count == 2 || count == 0 ? "YES" : "NO");

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22484
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  double L;
  cin >> L;

  cout << (L / 3) * (L / 3) * (L / 3) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

int main(){
  int M;
  int H;
  std::string str;
  std::string temp;

  std::cin >> str;

  while(str != "-"){
    std::cin >> M;  // number of shuffle

    for(int i=0; i<M; i++){
      std::cin >> H;

      for(int j=0; j<H; j++){
        temp[j] = str[j];
        str.push_back(temp[j]);
      }
      str.erase(0, H);
    }
    std::cout << str << std::endl;
    std::cin >> str;
  }
  return 0;
}



Measured memory_bytes: 3204
import sys
def main():
    for line in sys.stdin:
        H, W = map(int, line.split())
        if H == 0 and W == 0:
            break
        else:
            for x in range(H):
                if x == 0 or x == H - 1:
                    for y in range(W):
                        print("#", end = "")
                    print()
                else:
                    for y in range(W):
                        if y == 0:
                            print("#", end = "")
                        elif y == W - 1:
                            print("#")
                        else:
                            print(".", end = "")
            print()



if __name__ == "__main__":
    main()

Measured memory_bytes: 9124
// Brijesh Panara (201601074)
// DAIICT (India)
#include <bits/stdc++.h>
#include <time.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FILL(a,b) memset((a),(b),sizeof((a)))
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> > 
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"   "<<#y<<" : "<<y<<"  "<<#z<<" : "<<z<<endl;

#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define RANDOM srand(time(NULL));

#define MOD 1000000007
#define NAX 1000005
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN


//---------------------------------------------------------------------------//

//returns (x^(y))
ll pow(ll x, ll y)
{
    ll ans = 1;  
    while (y > 0)
    {
        if(y & 1)
        ans = (ans*x);
        y = y>>1;
        x = (x*x);  
    }
    return ans;
}

//returns (x^(y))%p
ll modpow(ll x, ll y, ll p=MOD)
{
    ll ans = 1;  
    x = x % p;  
    while (y > 0)
    {
        if(y & 1)
        ans = (ans*x) % p;
        y = y>>1;
        x = (x*x) % p;  
    }
    return ans;
}

//store gcd of a,b in ggg
//store solution of a*xxx + b*yyy = ggg in xxx,yyy
//if gcd(a,b)=1 then xxx = a^(-1)(mod b) and yyy = b^(-1)(mod a)
ll xxx,yyy,ggg;
void extendedEuclid(ll a, ll b)
{
    if(b==0)
    {
        ggg = a;xxx = 1;yyy = 0;
    }
    else
    {
        extendedEuclid(b,a%b);
        ll temp = xxx;
        xxx = yyy;
        yyy = temp-(a/b)*yyy;
    }
}

// return modulo inverse of a wrt modulo p
// retunt -1 if modulo inverse does not exist
ll modinverse(ll a, ll p=MOD)
{
    extendedEuclid(a,p);
    if(ggg==1 && p!=1)
        return (xxx+p)%p;
    else
        return -1;
}

ll madd(ll a,ll b,ll m=MOD) { return ((a%m)+(b%m))%m; }

ll msub(ll a,ll b,ll m=MOD) { return ((a%m)-(b%m)+m)%m; }

ll mmult(ll a,ll b,ll m=MOD) { return ((a%m)*(b%m))%m; }

ll mdiv(ll a,ll b,ll m=MOD) { return ((a%m)*modinverse((b%m),m))%m; }

//---------------------------------------------------------------------------//


ll solve()
{
	ll n;
	cin>>n;

	ll a[n];
	FOR(i,0,n)
	cin>>a[i];

	map<ll,ll> hm;
	hm[-1]=3;

	ll ans = 1;
	FOR(i,0,n)
	{
		ll temp = hm[a[i]-1];
		ans = mmult(ans,temp);
		hm[a[i]-1]--;
		hm[a[i]]++;
	}

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


int main()
{
    FAST;
    
    ll t=1;
    // cin>>t;
    
    while(t--!=0)
    {
        ll stat = solve();
    }
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s,t ;
  cin >> s >> t;
  int cnt;
  rep(i,3){
    if(s.at(i) == t.at(i)) cnt++;
  }
  cout << cnt << endl;
  }


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize
    }
    if a % 2 == 0 || b % 2 == 0 || c % 2 == 0 {
        println!("0");
    } else {
        println!("{}", min(min(a * b, b * c), c * a));
    }
}


Measured memory_bytes: 4352