akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int ans = 0;
  int tmp = 0;
  REP(i, n-1) {
    if (h[i]>=h[i+1]) tmp++;
    else {
      chmax(ans, tmp);
      tmp = 0;
    }
  } 
  chmax(ans, tmp);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
N=int( input() )
#XU= []
X=[]
for i in range(N):
    x,u = input().split() # x: 100 u: JPY
    if u=="JPY":
        x=float(x)
    else:
        x=float(x)
        x=x*380000
    #XU.append( [x, u] )
    X.append(x)

print(sum(X))


Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split()))

ans = 0
flag = False

while(1):
    for i in range(len(a)):
        if a[i] % 2 == 0:
            a[i] = a[i] / 2
        else:
            flag = True
            break;
    if flag:
        break;
    ans += 1

print(ans)



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

using namespace std;

const int INF=1e9;
int dp[1<<26];

int main(){
        string s;
        int n, bit=0;
        cin>>s;
        n=s.size();
        for(int i=0;i<(1<<26);i++){
                dp[i]=INF;
        }
        dp[0]=0;
        for(int i=0;i<n;i++){
                bit^=1<<(s[i]-'a');
                for(int j=0;j<26;j++){
                        dp[bit]=min(dp[bit], dp[bit^(1<<j)]+1);
                }
        }
        //答えが0になる時は答えを1にするようにする。
        cout<<max(1, dp[bit])<<endl;
        return 0;
}


Measured memory_bytes: 262660
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	vector<int> a(3); rep(i, 3) cin >> a[i];
	int K; cin >> K;

	sort(ALL(a));
	cout << a[0] + a[1] + a[2] * pow(2, K) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
const int mod=1e9+7;

int main(){
	int n,x;
	cin>>n;
	  cin>>x;
	    int i=x-n+1;
	    int j=n+x-1;
	      while(i<=j)
	      {cout<<i<<" ";
			  i++;
		  }
  }
    


Measured memory_bytes: 256
from collections import deque

N = int(input())
A = list(map(int,input().split()))
allsum = 0
sums_list = deque()
sums = 0
for i in range(N-1, 0, -1):
  sums = (sums + A[i]) % (10**9 + 7)
  sums_list.appendleft(sums)
for i in range(N-1):
  allsum = (allsum + A[i] * sums_list[i]) % (10**9 + 7)
print(allsum)


Measured memory_bytes: 32384
#include <algorithm>
#include <sstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	string s;
	cin >> s;
	reverse(s.begin(), s.end());

	cout << s << endl;
}



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

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

    vector<ll> a(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    reverse(a.begin(), a.end());

    for (size_t i = 0; i < n; i++)
    {
        cout << a[i];
        if (i != n - 1)
        {
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 3088
N=int(input())
S=input()
L=len(S)

cnt=0
for i in range(1000):
    key=str(i).zfill(3)
    if key[0] in S:
        idx1=S.index(key[0])
    else:
        continue
    if key[1] in S[idx1+1:L-1]:
        idx2=S[idx1+1:L-1].index(key[1])+idx1+2
    else:
        continue
    if key[2] in S[idx2:L]:
        cnt+=1
    else:
        continue

print(cnt)


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
  int n,k,i;
  char s[100];
  scanf("%d",&n);
  scanf("%s",&s);
  k=0;
  if((n%2)!=0)k++;
  else if(n==0)k++;
  else
  {
    for(i=0;i<(n/2);i++)
    {
      if(s[i]!=s[(n/2)+i])k++;
    }
  }
  if(k>0)printf("No");
  else if(k==0) printf("Yes");
  return 0;
}
  
  

Measured memory_bytes: 128
#include <iostream>
#include <queue>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  int a[N];
  rep(i, N) {
    in(a[i]);
    --a[i];
  }
  bool visited[N];
  fill(visited, visited+N, false);
  queue<int> q;
  q.push(0);
  int ans = 0;
  while (!q.empty()) {
    int p = q.front(); q.pop();
    if (visited[p])
      break;
    if (p + 1 == 2) {
      out(ans);
      return 0;
    }
    ++ans;
    visited[p] = true;
    q.push(a[p]);
  }
  out(-1);

  return 0;
}


Measured memory_bytes: 768
from collections import Counter
n = int(input())
V = list(map(int, input().split()))

c1 = Counter(V[::2])
c2 = Counter(V[1::2])
c1_items = sorted(c1.items(), key=lambda x: -x[1])
c2_items = sorted(c2.items(), key=lambda x: -x[1])

if c1_items[0][0] == c2_items[0][0]:
    if len(c1_items) == 1 and len(c2_items) == 1:
        ans = n // 2
    elif len(c1_items) == 1:
        ans = n - c1_items[0][1] - c2_items[1][1]
    elif len(c2_items) == 1:
        ans = n - c1_items[0][1] - c2_items[1][1]
    else:
        v1 = n - c1_items[0][1] - c2_items[1][1]
        v2 = n - c1_items[1][1] - c2_items[0][1]
        ans = min(v1, v2)
else:
    ans = n - c1_items[0][1] - c2_items[0][1]
print(ans)


Measured memory_bytes: 21184
# Binary Indexed Tree (Fenwick Tree)
class BIT():
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, i, value):
        i = i + 1
        while i <= self.n:
            self.bit[i] += value
            i += i & -i

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def sum(self, l, r):
        return self._sum(r) - self._sum(l)

n = int(input())
S = input()
q = int(input())
Query = [input().split() for _ in range(q)]

bits = [BIT(n) for i in range(26)]
s = []
for i,c in enumerate(S):
    bits[ord(c) - ord("a")].add(i,1)
    s.append(c)

for q_type,fr,to in Query:
    if q_type == "1":
        i = int(fr)-1
        bits[ord(s[i]) - ord("a")].add(i,-1)
        bits[ord(to) - ord("a")].add(i,1)
        s[i] = to
    else:
        l,r = int(fr)-1,int(to)
        tmp = 0
        for i in range(26):
            if bits[i].sum(l,r):
                tmp += 1
        print(tmp)



Measured memory_bytes: 237104
a = int(input())
b = int(input())
c = int(input())
x = int(input())

total = 0
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            total = 500*i+100*j+50*k
            if total==x:
                ans += 1
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] tmp = scanner.nextLine().split(" ");
		Long k 	     = Long.parseLong(tmp[0]);
		int  n 	     = Integer.parseInt(tmp[1]);

		String[] tp  = scanner.nextLine().split(" ");
		long[] list  = new long[n];
		for(int i = 0; i < n; i++) list[i] = Long.parseLong(tp[i]);

		long ans = 0;

		for(int j = 0; j < n; j++) {

			if(j != n - 1) ans = Math.max(ans, list[j + 1] - list[j]);
			else ans = Math.max(ans, Math.abs(list[0] +  (k- list[j])));


		}

		System.out.println(k - ans);



	}
}

Measured memory_bytes: 71564
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main() {
int N;
cin >> N;
if(N%10 == 3){
  cout << "bon" << endl;
}
else if((N%10 == 0) || (N%10 == 1) || (N%10 == 6) || (N%10 == 8) ){
  cout << "pon" << endl;
}
else{
  cout << "hon" << endl;
}
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>  // use "abs" function.

// non-recursive algorithm.
#define N 4
#define N2 16

int main()
{
	int MDT[N2][N2];   // Manhattan Distance Table.
	int dx[4] = {0, -1, 0, 1};  // move.
	int dy[4] = {1, 0, -1, 0};

	int i, j;
	for(i = 0; i < N2; i++){
		for(j = 0; j < N2; j++){
			MDT[i][j] = abs((i / N) - (j / N)) + abs((i % N) - (j % N));
		}
	}
	int pre_f[N2], f[N2], pre_space, space, pre_MD, MD, depth;
	for(i = 0; i < N2; i++){
		scanf("%d", &pre_f[i]);
		if(pre_f[i] == 0) pre_space = i;
	}

	pre_MD = 0;
	for(i = 0; i < N2; i++){
		if(pre_f[i] != 0){
			pre_MD += MDT[i][pre_f[i] - 1];
		}
	}

	int level, sx, sy, tx, ty, diff, trail[101], s, r, rev_sp;

	for(level = pre_MD; level < 50; level++, level++){  // DFS.
		for(i = 0; i < N2; i++) f[i] = pre_f[i];
		space = pre_space;
		MD = pre_MD;
		depth = 0;
		trail[0] = 4;
		s = 0;

		while(depth >= 0 && MD > 0)
		{
			sx = space / N;
			sy = space % N;
			for(r = s; r < 4; r++){
				if((trail[depth] ^ r) == 2) continue;  // go forward.
				tx = sx + dx[r];
				ty = sy + dy[r];

				if(tx < 0 || tx >= N || ty < 0 || ty >= N) continue;
				diff = MDT[sx * N + sy][f[tx * N + ty] - 1] - MDT[tx * N + ty][f[tx * N + ty] - 1];
				if(depth + 1 + MD + diff > level) continue;  // branch cut.

				break;
			}
			if(r < 4){  // next direction.
				swap(f[sx * N + sy], f[tx * N + ty]);
				space = tx * N + ty;
				MD += diff;
				depth++;
				trail[depth] = r;
				s = 0;
			}else{
				// back-track.
				r = trail[depth] ^ 2;
				s = trail[depth] + 1;
				depth--;
				if(depth >= 0){
					rev_sp = space + N * dx[r] + dy[r];
					MD += MDT[space][f[rev_sp] - 1] - MDT[rev_sp][f[rev_sp] - 1];
					swap(f[space], f[rev_sp]);
					space = rev_sp;
				}
			}
		};
		if(depth >= 0) break;
	}
	printf("%d\n", depth);

	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>


using namespace std;

void solve()
{
	double r;
	cin >> r;
	printf("%.6f %.6f\n", r * r * M_PI, 2 * M_PI * r);
}

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

Measured memory_bytes: 1240
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    int Q;
    cin >> N >> S >> Q;
    vector<int> K(Q);
    for (auto& k : K) {
        cin >> k;
    }
    for (auto& k : K) {
        ll d_cnt = 0;
        ll m_cnt = 0;
        ll dm_cnt = 0;
        ll ans = 0;
        rep(i, 0, N) {
            if (i >= k) {
                if (S[i - k] == 'D') {
                    --d_cnt;
                    dm_cnt -= m_cnt;
                } else if (S[i - k] == 'M') {
                    --m_cnt;
                }
            }
            if (S[i] == 'D') {
                ++d_cnt;
            } else if (S[i] == 'M') {
                ++m_cnt;
                dm_cnt += d_cnt;
            } else if (S[i] == 'C') {
                ans += dm_cnt;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  
  int cnt = 0, mxcnt = 0;
  for(int i=0; i<n-1; i++){
    if(h[i] >= h[i+1]){
      cnt++;
      if(cnt > mxcnt){
        mxcnt = cnt;
      }
    }
    else{
      cnt = 0;
    }
  }
  
  cout << mxcnt << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for (int i=1; i<=(n); ++i)
#define drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
//#define pu push_back
//#define po pop_back
#define pi (acos(-1))
#define fast ios::sync_with_stdio(false); cin.tie(0)
//#define pii pair<int,int>
//#define pll pair<ll,ll>
//#define vec vector
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> P;
const int INF = 1001001001;

// Gcd & Lcm
ll gcd (ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}
ll lcm (ll a, ll b) {
  return a/gcd(a,b)*b;
}

int main(void) {
  string s;
  cin >> s;
  for (int i=2; i<20; i++) {
    cout << s.substr(i-2,3) << endl;
    return 0;
  }
  return 0;
}







  



Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <climits>

using namespace std;

int main()
{
    int H, A;
    cin >> H >> A;
    
    cout << ceil(1.0 * H / A) << '\n';
}


Measured memory_bytes: 256
#include<iostream>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
    int N;

    cin >> N;

    ll a[N][N];
    bool f[N][N];

    REP(i,N)REP(j,N)cin >> a[i][j];
    REP(i,N)REP(j,N)f[i][j] = true;

    REP(k,N)REP(i,N)REP(j,N){
        if(a[i][k] + a[k][j] < a[i][j]){
            cout << -1 << endl;
            return 0;
        }else if(a[i][k] + a[k][j] == a[i][j] && i != k && k != j){
            f[i][j] = false;
        }
    }

    ll ans = 0;
    REP(i,N)REP(j,N){
        if(f[i][j])ans+=a[i][j];
    }

    cout << ans / 2 << endl;
}

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

#define sz(x) static_cast<int>((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using ld = long double;

template<class T> bool cmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool cmx(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string inp;
	cin >> inp;
	vector<int> vec(26);
	for(char x: inp) vec[x - 'a']++;
	if(all_of(all(vec), [](int x) {return x % 2 == 0; })) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

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

int main() {
    int n, m, s, t;
    cin >> n >> m;
    //vector<vector<int>> way(n+10, vector<int>(m+10, 0));
    vector<int> way[n+10];

    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        way[s].push_back(t);
        way[t].push_back(s);
    }

    for (int i = 0; i < way[1].size(); i++) {
        int rp = way[1][i];
        for (int j = 0; j < way[rp].size(); j++) {
            if (way[rp][j] == n) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;

}

Measured memory_bytes: 15100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1505,p=1000000007;
int read(){
	int f=1,g=0;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,f[N][N],d[N][N];
typedef unsigned short us;
us a[N][N],l[N][N],r[N][N];
ll ans;
char ch[N];
inline void chkmin(us &x,us y){if (x>y) x=y;}
inline void chkmax(us &x,us y){if (x<y) x=y;}
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		scanf(" %s",ch+1);
		for (int j=1;j<=n;j++)
		a[i][j]=(ch[j]=='#') ? 0 : (ch[j]-'0');
	}
	memset(l,0x3f,sizeof(l));
	for (int i=n;i;i--)
	for (int j=n;j;j--)
	if (a[i][j]){
		int t=f[i+1][j]+f[i][j+1];
		d[i][j]=max(max(d[i][j+1],d[i+1][j]),i);
		if (!a[i][j+1]){l[j][i]=r[j][i]=j;}
		else if (!a[i+1][j]){
			memcpy(l[j]+i,l[j+1]+i,(n-i+1)*2);
			memcpy(r[j]+i,r[j+1]+i,(n-i+1)*2);
			l[j][i]=j;
		}
		else{
			l[j][i]=j;r[j][i]=r[j+1][i];
			us las=0;
			for (int x=i+1;x<=d[i][j];x++){
				if ((l[j+1][x]<=r[j][x])&&(las<l[j+1][x])) t-=f[x][l[j+1][x]];
				chkmax(las,r[j][x]);
				chkmin(l[j][x],l[j+1][x]);chkmax(r[j][x],r[j+1][x]);
			}
		}
		ans+=a[i][j]*t;
		f[i][j]=a[i][j]+t;
	}
	else{memset(l[j]+i,0x3f,(n-i+1)*2);memset(r[j]+i,0,(n-i+1)*2);}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 31232
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
  ll n,x;
  cin>>n>>x;
  if(x==1||x==2*n-1){
      cout<<"No"<<"\n";
      return 0;
  }
  cout<<"Yes"<<"\n";
  V<bool> used(2*n,false);
  V<ll> ans(2*n-1,-1);
  used[x-1]=used[x]=used[x+1]=true;
  ans[(2*n-1)/2]=x;
  ans[(2*n-1)/2-1]=x-1;
  ans[(2*n-1)/2+1]=x+1;
  ll id=1;
  for(int i=0;i<2*n-1;i++){
      if(ans[i]==-1){
      while(id<=2*n-1&&used[id])id++;
      ans[i]=id;
      id++;
      }
      cout<<ans[i]<<"\n";
  }
}

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

int main() {
    int A, B;

    cin >> A >> B;

    int max = A * B;

    if(max < A + B){
        max = A + B;
    }
    if(max < A - B){
        max = A - B;
    }
    cout << max << endl;
}


Measured memory_bytes: 256
a, v = map(int,input().split())
b, w = map(int,input().split())
t =int(input())

s = abs(b-a)
y = (v-w)

if y <= 0:
    print('NO')
else:
    m = s % y
    u = s //y
    if m == 0 and u <= t:
            print('YES')
    elif m != 0 and u + 1 <= t:
            print('YES')
    else:
        print('NO')  

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

using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll long long int
#define INF 1000000000 
#define fill(space,a) memset(space,a,sizeof(space))

#define optimize() ios_base::sync_with_stdio(0);
#define MAXN 100005
int n;
vector <int> a,b,c;

int dp[MAXN][3];

int main()
{
	optimize();
	//freopen("input.txt", "r", stdin);
	cin >> n;
	a.resize(n + 1);b.resize(n + 1); c.resize(n + 1);
	a[0] = b[0] = c[0] = 0;
	for (int i = 1; i <= n; i++) 
		cin >> a[i] >> b[i] >> c[i];
	
	dp[1][0] = a[1]; dp[1][1] = b[1]; dp[1][2] = c[1];
	for (int i = 2; i <= n; i++) {
		dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
		dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
		dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
	}
	
	cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    ll n,x,len,tra;
    cin >> n >> x;

    if(x > n/2)x = n - x;
    len = n - x;
    tra = n;
    while(len % x != 0){
        tra += (len / x * 2) * x;
        ll me = len;
        len = x;
        x = me % x;
    }
    if(len) tra += (len / x * 2 - 1) * x;
    cout << tra << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0; i<N; i++){
    cin >> X.at(i);
  }
  sort(X.begin() , X.end());//小さい順に
  
  int min = 10000000;
  for (int i=X.at(0); i<=X.at(N-1); i++){ //iは試す座標
    int ans=0;
    for (int j=0; j<N; j++){ //jは人
      ans += (X.at(j) - i) * (X.at(j) - i);
    }
    if(ans < min){
      min = ans;
    }
  }
  cout << min << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc064_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  vector<int> clr(10, 0);
  rep(i, N) {
    if (c[i] < 400) {
      clr[0]++;
    } else if (c[i] < 800) {
      clr[1]++;
    } else if (c[i] < 1200) {
      clr[2]++;
    } else if (c[i] < 1600) {
      clr[3]++;
    } else if (c[i] < 2000) {
      clr[4]++;
    } else if (c[i] < 2400) {
      clr[5]++;
    } else if (c[i] < 2800) {
      clr[6]++;
    } else if (c[i] < 3200) {
      clr[7]++;
    } else {
      clr[8]++;
    }
  }

  int min = 0;
  int max = 0;
  rep(i, 8) { min += clr[i] != 0; }
  max = min + clr[8];
  if (min == 0) {
    min++;
  }

  cout << min << ' ' << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5,MOD=1e9+7;
int n,u,v,tmp;
int size[N],f[N];
int cnt,head[N];
struct edge{int next,to;}e[N<<1];

inline int pow(int a,int n)
{
	int res=1;
	while (n)
	{
		if (n&1ll) res=res*a%MOD;
		a=a*a%MOD;
		n>>=1ll;
	}
	return res;
}

inline void add(int u,int v)
{
	cnt++;
	e[cnt].next=head[u];
	e[cnt].to=v;
	head[u]=cnt;
}

void dfs(int u,int fa)
{
	size[u]=1;
	for (register int i=head[u]; i; i=e[i].next)
	if (e[i].to!=fa)
	{
		dfs(e[i].to,u);
		size[u]+=size[e[i].to];
	}
	f[1]=f[1]*size[u]%MOD;
}

void dp(int u,int fa)
{
	for (register int i=head[u]; i; i=e[i].next)
	if (e[i].to!=fa)
	{
		f[e[i].to]=f[u]*pow(size[e[i].to],MOD-2)%MOD*(n-size[e[i].to])%MOD;
		dp(e[i].to,u);
	}
}

signed main(){
	scanf("%lld",&n);
	for (register int i=1; i<n; ++i) scanf("%lld%lld",&u,&v),add(u,v),add(v,u);
	f[1]=1; dfs(1,0);
	dp(1,0);
	tmp=1;
	for (register int i=1; i<=n; ++i) tmp=tmp*i%MOD;
	for (register int i=1; i<=n; ++i) 
	{	
		f[i]=tmp*pow(f[i],MOD-2)%MOD;
		printf("%lld\n",f[i]);
	}
return 0;	
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n = s.size();
    int ans=INF;
    REP(i,n-1){
        if(s[i]!=s[i+1]) ans = min(ans,max(i+1,n-i-1));
    }
    if(ans==INF) ans=n;
    cout<<ans<<endl;
}

Measured memory_bytes: 512
N = int(input())
inputbox =[0]*N
X = [0]*N
Y = [0]*N
for i in range(0,N):
    inputbox[i] = input()

for j in range(N):
    a = inputbox[j]
    b = a.split()
    X[j]=float(b[0])
    Y[j]=float(b[1])

sum = 0
for s in range (N):
    for t in range (N):
        kyori = ((X[s]-X[t])**2+(Y[s]-Y[t])**2)**(1/2)
        sum = sum + kyori
ans = sum/N
print(ans)

Measured memory_bytes: 3064
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let mut counter = 1;
    loop {
        let num:u32 =sc.read();
        if num > 0 {
            println!("Case {}: {}", counter, num);
            counter = counter + 1;
        }else {
            break;
        }
    }
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<list>
#include<map>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

signed main() {
	int a; cin >> a;
	int ans = a / 11*2;
	a -= a / 11 * 11;
	if (a > 6)ans += 2;
	else if (a != 0)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 764
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#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 trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=5e5 + 5;
const int MOD=1e9 + 7;

struct node{
	int l;
	int r;
	int idx;
};

int bit[N];
int n,q;
int ans[N];
vector<node> queries[N];
int lastSeen[N];

void update(int idx, int val)
{
	while(idx<=n)
	{
		bit[idx]+=val;
		idx+=idx&-idx;
	}
}

// returns sum int the array from  position 1 to idx
int prefSum(int idx)
{
	int ans=0;
	while(idx>0)
	{
		ans+=bit[idx];
		idx-=idx&-idx;
	}
	return ans;
}

int rangeSum(int l, int r)
{
	return prefSum(r) - prefSum(l-1);
}

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		cin >> n >> q;
		memset(bit,0,sizeof(bit));
		clr(lastSeen,-1);
		int a[n+5];
		rep(i,1,n)
			cin >> a[i];
		rep(i,1,q)
		{
			node p;
			cin >> p.l >> p.r;
			p.idx = i;
			queries[p.l].push_back(p);
		}
		brep(i,n,1)
		{
			if(lastSeen[a[i]]!=-1)
				update(lastSeen[a[i]],-1);		
			lastSeen[a[i]] = i;
			update(lastSeen[a[i]],1);
			for(auto it: queries[i])
			{
				int cur = rangeSum(it.l,it.r);
				ans[it.idx] = cur;
			}
		}
		rep(i,1,q)
			cout << ans[i] << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rep3(i, m, n) for(ll i=m;i<=(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

// 素因数分解
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

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

void solve_abc_d() {
	ll n, m;
	ll a, b;
	ll x, y, z;
	//ll h, w;
	ll k;
	string s, rs;
	ll l_ans = 0;

	cin >> a >> b;

	x = gcd(a, b);

	map<ll, ll> mv;

	mv = prime_factor(x);

	l_ans = mv.size() + 1;
	
	cout << l_ans << "\n";

	return;
}

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

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;
const ll MOD=1000000007;

template <class type> void printVector(vector<type> vec){
    stringstream ss;
    ll n=vec.size();
    for(ll i=0;i<n;i++)
    {
        ss<<vec[i]<<" ";
        if(i!=n-1)ss<<" ";
    }
    cout<<ss.str()<<endl;
}

template <class type> void inputVector(vector<type>& vec){
    for(ll i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
}

template<ll MOD> struct Fp {
    ll val;
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr ll getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
        //return val ? Fp(MOD - val) : Fp(0); これじゃだめ？
    }//負の数
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(this->val) += r; }//ここでthisなのは？->コピーコンストラクタが自動生成されているから ここでFp()なのは自身の値は変わらないから
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(this->val) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(this->val) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(this->val) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;//1bit目が1=奇数,1ならここは2になる。
        return t;
    }
};

using mint = Fp<MOD>;

mint calc(ll N, ll K) {
    mint res = 1;
    for (ll n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }//Cの計算
    return res;
}

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    mint res = modpow(mint(2), N) - 1;
    res -= calc(N, A) + calc(N, B);
    cout << res << endl;
}

Measured memory_bytes: 3636
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 924844033;
 
////////////////////////////////////////////////////////////////////
 
const int N = 2e3 + 5;

int F[N], DP[N][N], M[N];

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
			
 	F[0] = 1;
	for (int i = 1; i < N; i++) F[i] = 1LL * i * F[i - 1] % MOD;
	DP[0][0] = 1;
	for (int i = 1; i < N; i++) {
		DP[i][0] = 1;
		for (int j = 1; j <= i / 2; j++) DP[i][j] = (DP[i - 1][j] + DP[i - 2][j - 1]) % MOD;
	}
	int n, k; cin >> n >> k;
	M[0] = 1;
	for (int i = 0; i < min(n, 2 * k); i++) {
		int p = (n - 1 - i) / k + 1;
		if (i >= k) p++;
		for (int j = N - 1; j >= 0; j--) for (int l = 1; l <= j && l <= p / 2; l++) 
		    M[j] = (M[j] + 1LL * M[j - l] * DP[p][l] % MOD) % MOD;
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		int z = (i & 1) ? -1 : +1;
		ans = (ans + 1LL * z * M[i] * F[n - i] % MOD + MOD) % MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 15596
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N, K;
    string S;
    cin >> N >> S >> K;
    for(auto aaa: S){
        if(aaa!=S[K-1]) cout << '*';
        else cout << aaa;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;     
 int main()
{
    int n,i;
    cin >> n;
    int arr[n];
    for(i=0;i<n;i++)
        cin >> arr[i];
    int dp[n];
    dp[0]=0,dp[1]=abs(arr[0]-arr[1]);
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
    }
    cout << dp[n-1];
    
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			long a = sc.nextLong();
			long b = sc.nextLong();
			String and = Long.toBinaryString(a & b);
			String or = Long.toBinaryString(a | b);  //左シフト
			String xor = Long.toBinaryString(a ^ b);  //右シフト
			and = to32(and);
			or = to32(or);
			xor = to32(xor);
			System.out.println(and + '\n' + or+ '\n' + xor);
		}
	}


	//桁数を32にする
	static String to32(String s) {
		int a = 32-s.length();
		if (a != 0)	for (int i=0; i<a; i++)	s = '0' + s;
		if (a < 0) s = s.substring(s.length()-32);
		return s;
	}
}


Measured memory_bytes: 26368
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskATG1 solver = new TaskATG1();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskATG1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] l = new int[2 * n];

            int sum = 0;
            for (int i = 0; i < 2 * n; i++) {
                l[i] = in.nextInt();
            }
            Arrays.sort(l);
            for (int i = 1; i <= 2 * n; i++) {
                if (i % 2 != 0) {
                    sum += l[i - 1];
                }
            }
            out.println(sum);
        }

    }
}


Measured memory_bytes: 9684
#include<bits/stdc++.h>
#define pi 3.141592654
using namespace std;
int main()
{
   int n,m,a,sum=0;

   cin>>n>>m;
   for(int i=0;i<m;i++)
   {
       cin>>a;
       sum+=a;
   }
   if(sum>n)
    cout<<"-1"<<endl;
   else
    cout<<(n-sum)<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include<algorithm>
using namespace std;
struct Card{
    char suit,value;
};
const int MAX =  100;
void bubble(struct Card A[] , int N)
{
    for(int i  = 0; i < N;i++)
    {
        for(int j = N-1;j>=i+1;j--)
        {
            if(A[j].value<A[j-1].value)
            {
                Card t = A[j];A[j] = A[j-1];A[j-1]=t;
            }
        }
    }
}


void selection(struct Card A[] , int N)
{
    for(int i = 0;i < N;i++)
    {
        int minj = i;
        for(int j = i;j<N;j++)
        {
            if(A[j].value<A[minj].value)
                minj = j;
        }
        Card t = A[i];A[i] = A[minj];A[minj]=t;
    }
}

void print(struct Card A[] , int N)
{

    for(int i = 0;i<N;i++)
    {
        if(i>0)cout<<" ";
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;
}


bool isStable(struct Card Cl[] , struct Card C2[], int N)
{
    for(int i = 0;i<N;i++)
    {
        if(Cl[i].suit != C2[i].suit)return false;
    }
    return true;
}
int main()
{
    int n;
    Card a[MAX],b[MAX];
    cin>>n;
    char ch;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i].suit>>a[i].value;
    }

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

    bubble(a,n);
    selection(b,n);

    print(a,n);
    cout<<"Stable"<<endl;
    print(b,n);
    if(isStable(a,b,n)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }

    return 0;
}

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

using namespace std;

long long f(long long x) {return (x == 1 ? 1 : 2 * f(x/2) + 1);}
long long x;
int main() {
  	ios_base::sync_with_stdio(0); cin.tie(0);
  	
  	cin >> x;
  	cout << f(x) << '\n';
  
	return 0; 
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)
typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

void b_sort(ll a[],ll num[],ll n){
  int  tmp;
  for(int i = 0;i < n-1;i++){
    for(int j = 0;j < n-1;j++){
      if(a[num[j]] > a[num[j+1]]){
        tmp = num[j];
        num[j]=num[j+1];
        num[j+1]=tmp;
      }
    }
  }
}

/*
vector<vector<int> > f(int i,vector<int> &a,vector<int> &b,vector<int>&c){
    if(i == a.size()){
        return vector<vector<int> > (1,vector<int>());
    }
    vector<vector<int> > d = f(i,a,b,c);
    vector<vector<int> > ret = vector<vector<int> > (1,vector<int>());
    for(int p = 0;p <  d.size();p++){
        vector<int> tempA = d[i],tempB = d[i],tempC = d[i];

        tempA.push_back(a[i]);
        tempB.push_back(b[i]);
        tempC.push_back(c[i]);


        ret.push_back(tempA);
        ret.push_back(tempB);
        ret.push_back(tempC);
    }
    return ret;
}



int main(){
    int n;
    cin >> n;
    vector <int> a(n),b(n),c(n);
    rep(i,0,n) cin >> a[i] >> b[i] >> c[i];

    rep(i,0,n) rep(j,0,n) cout << f(0,a,b,c)[i][j] << endl;
}
*/
ll calxor(ll n){
    /*
    if(n%4 == 0) return 0;
    if(n%4 == 2) return 1;
    if(n%4 == 1 || n%4 == 3)  return n;
    return 0;
*/
    
    ll x = ((n+1)/2)%2;
    if(n%2 == 0) x = x^n;
    return x;
    
}

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

    ll fa,fb;

    fa = calxor(a-1);
    fb = calxor(b);

    fa = fa^fb;
    cout << fa << endl;
}

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

int M , D;

int main() {
    cin >> M >> D;

    int ans = 0;
    for (int i = 1; i <= M; i++) {
        for (int j = 1; j <= D; j++) {
            int d10 = j / 10;
            int d1 = j - d10 * 10;

            if (d1 >= 2 && d10 >= 2) {
                if (i == d10 * d1) ans++;
            }
        }
    }

    cout << ans << endl;
   
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
ll dp[100005][101],n,w,val[105],wgh[105];
ll recurs(int pos,int w1)
{
	if(w1>w) return -1*(2e11);
	if(pos>n) return 0;
	if(w1==w) return 0;
	if(dp[w1][pos]!=-1) return dp[w1][pos];
	dp[w1][pos]=max((val[pos]+recurs(pos+1,w1+wgh[pos])),recurs(pos+1,w1));
//	cout<<pos<<" "<<w1<<" "<<dp[w1][pos]<<"\n";
	return dp[w1][pos];
}
int main()
{
    ios_base::sync_with_stdio(false);//this works only
    cin.tie(NULL);// when first all inputs are from user
    cout.tie(NULL);//you will see all outputs afterwards
    memset(dp,-1,sizeof(dp));
    cin>>n>>w;
    for (int i = 1; i <=n; ++i)
    {
    	cin>>wgh[i]>>val[i];
    }
    ll ans=recurs(1,0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 79232
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

int gcd2(int a, int b) {
	if (a < b) swap(a, b);
	int c;
	while (1) {
		c = a % b;
		if (c == 0) break;
		a = b;
		b = c;
	}
	return b;
}

int gcd3(int a, int b, int c) {
	return gcd2(a, gcd2(b, c));
}

int main(void) {
	int K;
	scanf("%d", &K);
	long ans = 0;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				ans += gcd3(i, j, k);
			}
		}
	}
	printf("%ld", ans);

	return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#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 all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll dp[110][100010];
int solve(){
  int n,w;
  cin>>n>>w;
  vector<ll>W(n),V(n);
  rep(i,n)cin>>W[i]>>V[i];
  rep(i,n){
    rep(j,w+1){
      if(j+W[i]<=w)dp[i+1][j+W[i]]=max(dp[i+1][j+W[i]],dp[i][j]+V[i]);
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
  }
  cout<<dp[n][w]<<endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 79360
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N, M; cin >> N >> M;
    ll res = 0;
    if (N * 2 <= M) {
        res += N;
        M -= 2 * N;
        N = 0;

        res += M/4;
    } else {
        res += M/2;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

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


// 68 11 55 - rank 3
// 69 12 19 - rank 3
// 70 12 34 - rank 100
// 71 12 58 - rank 4
// 72 13 24

ull gcd(ull a, ull b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    string line;
    cin >> line;
    for (int i = 0; i < line.size(); i += 2) {
        cout << line[i];
    }
    cout << "\n";

}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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


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

	int a,b,c;cin>>a>>b>>c;
	if(a>=c) cout<<0<<endl;
	else if(a+b<c) cout<<"NA"<<endl;
	else cout<<c-a<<endl;

	return 0;
}



Measured memory_bytes: 3220