akhauriyash/Code-Regression huggingface dataset:
N, X = map(int, input().split())
L2 = [1]
j = 1
for i in range(N+2):
    j *= 2
    L2.append(j)
Y = 0
for i in range(N+1):
    if L2[N+1-i] - 1 == X:
        Y += L2[N-i]
        print(Y)
        break
    elif L2[N+2-i] - 3 == X:
        Y += L2[N+1-i] - 1
        print(Y)
        break
    elif L2[N+1-i] - 1 < X:
        Y += L2[N-i]
        X -= L2[N+1-i] - 1
    else:
        X -= 1
else:
    print(Y)


Measured memory_bytes: 3064
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    let c: i64 = input();
    println!("{}", if a + b >= c { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 3*(int)1e5 + 10;

int solve(int x){
   if (x == 0){
      return 0;
   }
   int rem = x % __builtin_popcountll(x);
   return 1 + solve(rem);
}

int getRemainder(string s, vector<int>& pw2, int cnt){
   int n = (int)(s.size());
   int remainder = 0;
   for (int i = n-1, j = 0; i >= 0; --i, ++j)
   {
      if(s[i] == '1'){
         remainder += pw2[j];
         remainder %= cnt;
      }
   }
   return remainder;
}

vector<int> getPw(int rem){
   vector<int> pw;
   pw.push_back(1);
   for (int i = 0; i < N; ++i)
   {
      pw.push_back(pw.back() * 2 % rem);
   }
   return pw;
}

int32_t main(){_

   int n;
   cin >> n;

   string s;
   cin >> s;


   int cnt = count(s.begin(), s.end(), '1');
   int store = cnt;
   
   vector<int> pw3;
   vector<int> pw1;
   int remainder2, remainder3, remainder1;

   if (cnt - 1 >= 1){
      pw1 = getPw(cnt-1);
      remainder1 = getRemainder(s, pw1, cnt-1);
   }

   pw3 = getPw(cnt + 1);
   remainder3 = getRemainder(s, pw3, cnt+1);

   for (int i = 0; i < n; ++i)
   {
      cnt = store;
      
      if(s[i] == '1'){
         s[i] = '0';
         --cnt;
      }
      else{
         s[i] = '1';
         ++cnt;
      }

      if (cnt == 0){
         cout<<0<<endl;
         continue;
      }

      assert(cnt != store);
      int curr = 0;
      if (cnt == store-1){
         curr = remainder1;
         if (s[i] == '1'){
            curr += pw1[n-1-i];
            tr(curr, pw1[n-1-i]);
            curr %= cnt;
         }
         else{
            curr -= pw1[n-1-i];
            curr %= cnt;
            curr += cnt;
            curr %= cnt;
            tr(curr, pw1[n-1-i]);
         }
      }
      else{
         assert(cnt == store + 1);
         curr = remainder3;
         if (s[i] == '1'){
            curr += pw3[n-1-i];
            curr %= cnt;
            // tr(s, curr, pw1[n-1-i]);
         }
         else{
            curr -= pw3[n-1-i];
            curr %= cnt;
            curr += cnt;
            curr %= cnt;
         }
      }

      int ans = 1;
      ans += solve(curr);
      cout<<ans<<endl;
      tr(i, s, curr, ans, cnt, remainder1, remainder3);

      if(s[i] == '0'){
         s[i] = '1';
      }
      else{
         s[i] = '0';
      }
   }

   return 0;
}

Measured memory_bytes: 11788
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
	int N, M;
	map<string, int> times;

	cin >> N;
	for (int i = 0; i < N; i++){
		string temp;
		cin >> temp;
		if(times.find(temp) != times.end()){
			times[temp]++;
		} else {
			times[temp] = 1;
		}
	}
	cin >> M;
	for (int i = 0; i < M; i++){
		string temp;
		cin >> temp;
		if(times.find(temp) != times.end()){
			times[temp]--;
		} else {
			times[temp] = -1;
		}
	}

	int timesmax = -200;
	for (map<string, int>::iterator itr = times.begin(); itr != times.end(); itr++){
		if(timesmax < itr->second){
			timesmax = itr->second;
		}
	}

	cout << max(timesmax, 0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	int n;
	cin >> n;
	vector<LLI> cnt(100001, 0);
	LLI sum = 0;
	REP(i, n)
	{
		LLI a;
		cin >> a;
		sum += a;
		cnt[a]++;
	}

	int q;
	cin >> q;


	REP(i, q)
	{
		LLI b, c;
		cin >> b >> c;

		sum += cnt[b] * (c - b);
		cnt[c] += cnt[b];
		cnt[b] = 0;

		cout << sum << endl;

	}
	return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  int x=0,t=1;
  cin>>a>>b;
  a+=b;
  reverse(a.begin(),a.end());
  for(int i=0;i<a.size();i++){
    x+=(a[i]-'0')*t;
    t*=10;
  }
  for(int i=1;i<=100000;i++){
    if(i*i==x){
      cout<<"Yes"<<endl;
      return(0);
    }
  }
  cout<<"No"<<endl;
  return(0);
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	ll n,t,a;
	cin >> n >> t;
	ll time[n];
	cin >> time[0];
	ll sum=t;
	for(ll i=1; i < n;i++){
		cin >> time[i];
		if(time[i]-time[i-1] < t) sum+=time[i]-time[i-1];
		else sum+=t;
	}
	cout << sum;
	

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
static const int MAX = 1e9 + 1;
int main(){
    int n; sc(n)
    int A[n];
    map<int, int, greater<int>> mp;
    for (int i = 0; i < n; i++) sc(A[i]);
    for (int i = 0; i < n; i++){
        ++mp[A[i]];
    }
    ll max1 = -1, max2 = -1;
    for (auto it = mp.begin(); it != mp.end(); it++){
        if (it->second >= 4){
            if (max1 == -1) max1 = it->first;
            max2 = it->first;
            break;
        }
        if (it->second >= 2){
            if (max1 == -1) max1 = it->first;
            else {
                max2 = it->first;
                break;
            }
        }
    }
    if (max1 == -1 || max2 == -1) cout << 0 << endl;
    else cout << max1 * max2 << endl;
    return 0;
}

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

#define f first 
#define s second 
#define pb push_back               
#define all(x) x.begin(), x.end())

using namespace std;                    

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)1e5 + 123, mod = (int)1e9 + 7, inf = (int)1e9, LOG = 18;
const ll INF = (ll)1e8;
const double eps = 1e-9;

int n, a[N][3], val[N], pos[N], cnt[2];
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i][0];
	for(int i = 1; i <= n; i++)
		cin >> a[i][1];
	for(int i = 1; i <= n; i++)
		cin >> a[i][2];

	for(int i = 1; i <= n; i++)
    	if(max(a[i][0], max(a[i][1], a[i][2])) == a[i][1] || min(a[i][0], min(a[i][1], a[i][2])) == a[i][1] || max(a[i][0], max(a[i][1], a[i][2])) - min(a[i][0], min(a[i][1], a[i][2])) != 2 )
			cout << "No", exit(0);
	for(int i = 1; i <= n; i++){
    	int x = (min(a[i][0], min(a[i][1], a[i][2])) - 1) / 3; 
		if(min(a[i][0], min(a[i][1], a[i][2])) != a[i][0])
			cnt[i&1] ^= 1;
		val[i] = x + 1;
		pos[x + 1] = i;
		if( (x ^ i ^ 1)&1)
        	cout << "No", exit(0);
	}

	for(int i = 1; i <= n; i++){
    	if(val[i] == i)
			continue;
		
		int p = pos[i];
		int j = val[i];

		cnt[i&1^1] ^= 1;
		
		pos[i] = i;
		pos[j] = p;
		
		val[i] = i;
		val[p] = j;    
	}

	if(cnt[0]|cnt[1])
		cout << "No";
	else
		cout << "Yes";
}


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

#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)


typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

vector<int> Iv;
vector<int> Jv;
int N;
int main() {
	cin>>N;
	int X = N;
	if(N%2 == 0)X = N+1;

	int cnt =0;
	rep1(i,N+1)rep1(j,N+1){
		if(i<j)if(i+j!=X){
			cnt++;
			Iv.push_back(i);
			Jv.push_back(j);
		}
	}

	cout<<cnt<<endl;

	rep(i,cnt){
		cout<<Iv[i]<<' '<<Jv[i]<<endl;
	}
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // int N, K;
  // cin >> N >> K;
  int N = 3;
  vector<int> A(N);
  int res = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int sum;
  sum = 0;
  for (int i = 0; i < N;i++){
    sum += A[i];
  }
  if(sum>21){
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }

  return 0;

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
C = {i:0 for i in range(0,10**5)}
for i in range(N):
    C[A[i]] += 1
cmax = 0
for x in range(1,10**5-1):
    cnt = C[x]+C[x-1]+C[x+1]
    cmax = max(cmax,cnt)
print(cmax)

Measured memory_bytes: 98352
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
inputs = [int(s) for s in input().split()]
a = inputs[0]
b = inputs[1]
c = inputs[2]
d = inputs[3]
count = 0
minCD = min(c, d)
maxCD = max(c, d)

x0 = b-a+1
x1 = b//minCD - (a-1)//minCD
x2 = b//maxCD - (a-1)//maxCD
lcm = minCD * maxCD // gcd(minCD, maxCD)
x3 = b//lcm - (a-1)//lcm
if maxCD % minCD == 0:
    print(x0-x1)
else:
    print(x0-(x1+x2-x3))

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

const long long MOD = 5;
const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long C) {
    ll tmp = 0;
    rep(i, 100) {
        tmp += A % B;
        tmp %= B;
        if (tmp == C) {
            cout << "YES" << endl;
            return;
        }
    }
    cout << "NO" << endl;
    return;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  vector<string>lis={"dream","dreamer","erase","eraser"};
  int l=s.length();
  vector<vector<int>>edge(l);
  rep(i,l){
    rep(j,4){
      int ll=lis[j].length();
      int f=1;
      if(i+ll>l)continue;
      rep(k,ll){
        if(s[i+k]!=lis[j][k])f=0;
      }
      if(f){edge[i].push_back(i+ll);}
    }
  }
  vector<int>used(l+1);
  function<bool(int)>dfs=[&](int now){
    if(now==l)return true;
    used[now]=1;
    bool res=0;
    for(auto nn:edge[now]){
      if(used[nn])continue;
      res|=dfs(nn);
    }
    return res;
  };
  if(dfs(0))cout<<"YES"<<endl;
  else cout<<"NO"<<endl;




  return 0;

}


Measured memory_bytes: 4800
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
int main() {
    string a;
    ll ans=0;
    cin >> a;
    for (int i=0;i<6;++i){
        if (a[i]=='1'){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int a;
    cin>>a;

    cout<<a + a*a + a*a*a<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, m;
pair<long long, int> p[N + N];

bool read() {
    if (!(cin >> n >> m))
        return false;

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

    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        p[n + i] = make_pair(x, 1);
    }

    return true;
}

void solve() {
    sort(p, p + n + m);
    auto ans = 0ll;
    int nn = n + 1, mm = m + 1;

    for (int i = 0; i < n + m; ++i) {
        if (p[i].second == 0) {
            --nn;
            ans += p[i].first * mm;
        } else {
            --mm;
            ans += p[i].first * nn;
        }
    }

    cout << ans << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 3328
function Main(input) {
  input = input.split("\n");
  var n = Number(input[0]);
  var d = Number(input[1].split(" ")[0]);
  var x = Number(input[1].split(" ")[1]);

  var eaten = 0;

  for (var i = 0; i < n; i++) {
    var a = input[i + 2];
    eaten += Math.ceil(d / a);
  }

  console.log(eaten + x);
  // console.log('%d %s', a , b , c, d);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
n = int(input())
sequence = [int(s) for s in input().split()]
s_min = sequence[0]
s_max = sequence[0]
s_sum = 0
for s in sequence:
    if s < s_min:
        s_min = s
    if s> s_max:
        s_max = s
    s_sum += s
print('{} {} {}'.format(s_min, s_max, s_sum))


Measured memory_bytes: 6600
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut table = make_table(iterator.next().unwrap().to_string());
    for _i in 1..n {
        let table2 = make_table(iterator.next().unwrap().to_string());
        subtract(&mut table, &table2);
    }

    make_string(&table)
}

fn make_table(s: String) -> [u8; 26] {
    let mut table = [0 as u8; 26];
    for c in s.chars() {
        let index = c as u8 - 'a' as u8;
        table[index as usize] += 1;
    }
    table
}

fn subtract(table1: &mut [u8; 26], table2: &[u8; 26]) {
    for i in 0..26 {
        table1[i] = min(table1[i], table2[i]);
    }
}

fn make_string(table: &[u8; 26]) -> String {
    let mut result = String::new();
    for i in 0..26 {
        let mut count = table[i];
        while count > 0 {
            let c = ('a' as u8 + i as u8) as char;
            result.push(c);
            count -= 1;
        }
    }
    result
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

//1-indexed
class BIT {
public:
  vector<ll> bit;
  ll M;
 
  BIT(ll M):
    bit(vector<ll>(M+1, 0)), M(M) {}
 
  //a[1] + a[2] + ... + a[i]を求める
  ll sum(ll i) {
    if (i==0) return 0;
    return bit[i] + sum(i-(i&-i));
  }
  //a[i] += x
  void add(ll i, ll x) {
    if (i > M) return;
    bit[i] += x;
    add(i+(i&-i), x);
  }
};

int main(){
  ll n; cin >> n;
  ll K = n*(n+1)/2/2 + 1;
  vector<ll> a(n);
  REP(i,n){
    cin >> a[i];
  }
  // m_{l,r}のうち，値がx以下の項がK個以上あるか？
  ll ng = 0, ok = 1e9;
  while(ng+1<ok){
    ll x = (ok+ng)/2;
    vector<ll> sum(n+1,0);
    REP(i,n) {
      sum[i+1] = sum[i] + (a[i]<=x ?  1 : -1);
    }
    // sum[l] < sum[r] (0<=l<r<=n)を満たす(l,r)がK個以上あるか？
    // -n<=sum<=nなので+n+1平行移動
    BIT b(2*n+1);
    ll cnt = 0;
    REP(i,n+1){
      ll t = sum[i]+n+1;
      b.add(t,1);
      cnt += b.sum(t-1);
    }
    if(cnt>=K) ok = x;
    else ng = x;
  }

  cout << ok << endl;
}

Measured memory_bytes: 3420
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

bool x[4];

signed main() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	rep(i, 2 * n) {
		if (i % 2 == 0) {
			cout << s[i / 2];
		}
		else {
			cout << t[i / 2];
		}
	}
	cout << endl;

	return 0;
}


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


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

#define mod 1000000007

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}



signed main(void){
	vector<char>c;
	vector<char>::iterator it;
	string s;
	cin >> s;
	const char* cstr = s.c_str();
	while (*cstr != '\0') {
		c.pb(*cstr);
		cstr++;
	}
	int q;
	cin >> q;
	bool rev = false;
	int t,f;
	char cc;
	rep(i, q) {
		cin >> t;
		if (t == 1) {
			rev = !rev;
		}
		if (t == 2) {
			cin >> f >> cc;
			if (f==1) {
				if (rev) c.pb(cc);
				else{
					it = c.begin();
					it = c.insert(it, cc);
				}
			}
			if (f == 2) {
				if (rev) {
					it = c.begin();
					it = c.insert(it, cc);
				}
				else c.pb(cc);
			}
		}
	}
	if(rev) reverse(begin(c), end(c));
	for (auto a : c) {
		cout << a ;
	}
	return 0;
}

Measured memory_bytes: 1144
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<typename T>
T gcd(T a, T b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

template<typename T>
T lcm(T a, T b){
  return a * b / gcd(a, b);
}
int main(){
    ull A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << (B - B / C - B / D + B / lcm(C, D)) - (A - 1 - (A -1)/ C - (A-1) / D + (A-1) / lcm(C, D)) << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

#define REP(i, n) for (int (i)=0; (i)<(n); (i)++)
#define SET(n, v) \
    do { \
        (v).resize(n); \
        REP(i, (n)) cin >> (v)[i]; \
    } while (false)

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

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

int main() {
    string oc[2] = {"Opened by ", "Closed by "};
    int N, M;
    hset<string> uid;

    string s;
    cin >> N;
    REP(i, N) {
        cin >> s;
        uid.insert(s);
    }

    int k=0;
    cin >> M;
    REP(i, M) {
        cin >> s;
        if (uid.find(s) == uid.end()) {
            cout << "Unknown " << s << endl;
        } else {
            cout << oc[k] << s << endl;
            k = (k+1) % 2;
        }
    }

    return 0;
}

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

int main() {
    long n,m;
    cin>>n>>m;

    long ans = n*m-(n*2+m*2-4);
    if(ans < 0)ans = -ans;

    cout<<ans;
    // 314*1592=499888
    // 496080 3808 1592*2=3184 -=624
    // n*m-(n*2+m*2-4) 7-(2+14-4) = -5
    //4-(4+4-4)=0
    //9-(6+6-4)=1
}





Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    double X;
    cin >> X;
    double x = 0.0, y = 0.0;
    double deg = 0.0;
    const double PI = 3.1415926535;
    double eps = 1e-4;
    ll K = 0;
    while(1){
        x += sin(deg);
        y += cos(deg);
        deg += PI * X / 180.0;
        K++;
        if(abs(x) < eps && abs(y) < eps){
            print(K);
            return;
        }
    }



}

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

Measured memory_bytes: 4036
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 100

#define NOT 0
#define VIS 1
#define COMP 2
bool mat[MAX][MAX];
ll stt[MAX];
stack<ll> sta;

void DFSearch(ll start) {
  sta.push(start);

  while (!sta.empty()) {
	temp = sta.top();

	if (stt[temp] == COMP) {
	  sta.pop();
	  continue;
	}

	if (stt[temp] == NOT) stt[temp] = VIS;

	flag = true;
	FOR(i, 0, n) {
	  if (mat[temp][i] && !stt[i]) {
		sta.push(i);
		flag = false;
		break;
	  }
	}

	if (flag) {
	  stt[temp] = COMP;
	}
  }
}

int main(void) {
  pll edge[MAX];
  cin >> n >> m;

  FOR(i, 0, m) {
	cin >> temp;
	temp--;
	edge[i].first = temp;
	cin >> temp;
	temp--;
	edge[i].second = temp;
  }

  FOR(i, 0, m) {
	FOR(j, 0, n) {
	  stt[j] = NOT;
	  FOR(k, 0, n) {
		mat[j][k] = false;
	  }
	}

	FOR(j, 0, m) {
	  if (i == j) continue;
	  mat[edge[j].first][edge[j].second] = true;
	  mat[edge[j].second][edge[j].first] = true;
	}

	DFSearch(0);

	FOR(j, 0, n) {
	  if (stt[j] == NOT) {
		ans++;
		break;
	  }
	}
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

#define ll long long int

int main() 
{
    ll n,i,j,k,p,q;
    cin>>n;
    ll dp[n+5][5],a[n+5],b[n+5],c[n+5];
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    ll m;
    if(dp[n-1][0]>dp[n-1][1])
        if(dp[n-1][0]>dp[n-1][2])
            m=dp[n-1][0];
        else
            m=dp[n-1][2];
    else
        if(dp[n-1][1]>dp[n-1][2])
            m=dp[n-1][1];
        else
            m=dp[n-1][2];
    cout<<m<<"\n";
    return 0;
}

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s
typedef pair<int, int> P;

int n;
int main()
{
	while (cin >> n, n)
	{
		int cnt = 0;
		FOR(i,1, n / 2 + 1)
		{
			int sum = 0;
			for (int j = i;;j++)
			{
				sum += j;
				if (sum == n && j != sum) cnt++;
				if (sum >= n) break;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
package main

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

func solution(T string) string {
        memo := make(map[int]string, 3)
        maxC := -1 << 31
        // all D
        out := make([]byte, len(T))
        for i := 0; i < len(T); i++ {
                if T[i] == '?' {
                        out[i] = 'D'
                } else {
                        out[i] = T[i]
                }
        }
        c := count(string(out))
        memo[c] = string(out)
        maxC = max(maxC, c)

        // all P
        out = make([]byte, len(T))
        for i := 0; i < len(T); i++ {
                if T[i] == '?' {
                        out[i] = 'P'
                } else {
                        out[i] = T[i]
                }
        }
        c = count(string(out))
        memo[c] = string(out)
        maxC = max(maxC, c)
        // P or D
        out = make([]byte, len(T))
        for i := len(T) - 1; i >= 0; i-- {
                if T[i] == '?' {
                        if i == len(T)-1 {
                                out[i] = 'D'
                        } else if out[i+1] == 'P' {
                                out[i] = 'D'
                        } else {
                                out[i] = 'P'
                        }
                } else {
                        out[i] = T[i]
                }
        }

        c = count(string(out))
        memo[c] = string(out)
        maxC = max(maxC, c)

        return memo[maxC]
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func count(s string) int {
        c := 0
        for i := 0; i < len(s); i++ {
                if s[i] == 'D' {
                        c++
                }
        }

        for i := 0; i < len(s)-1; i++ {
                if s[i:i+2] == "PD" {
                        c++
                }
        }
        return c
}
func main() {
        var fp *os.File = os.Stdin
        reader := bufio.NewReaderSize(fp, 1024)
        T := readLine(reader)
        fmt.Println(solution(T))
}

func readLine(reader *bufio.Reader) string {
        buf := make([]byte, 0, 1024)

        for {
                l, p, _ := reader.ReadLine()
                buf = append(buf, l...)

                if !p {
                        break
                }
        }
        return string(buf)
}

Measured memory_bytes: 5136
#include <stdio.h>


int search(int *a,int len,int key){
	int i=len/2+len%2;
	if(a[i]==key){
		return 1;
	}else if(a[i]<key){
		if(len==0){
			return 0;
		}else{
			return search(a+i,len-i,key);
		}
	}else if(a[i]>key){
		if(len==1){
			return 0;
		}else{
			return search(a,len-i,key);
		}
	}
	return 0;
}

int main(){
	int n,q;
	int S[100000];
	int T[50000];


	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&S[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&T[i]);
	}
	int count=0;
	for(i=0;i<q;i++){
		count+=search(S,n,T[i]);
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 1184
n = gets.to_i
input = n.times.map { gets.to_i }
ans = 0
i = -1
(input + [0]).each do |j|
  if j == i + 1
    i += 1
  elsif j <= i
    ans += i
    i = j
  else
    ans = -1
    break
  end
end
puts ans


Measured memory_bytes: 5428
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

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

    map<int, int> hash_map;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        hash_map[tmp] ^= 1;
    }

    int ans = 0;
    for(auto &kv : hash_map) {
        ans += kv.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4864
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 10000;
map<P,bool> unused;
void dfs(P ball,P v){
  unused[ball] = false;

  P to1(ball.first+v.first,ball.second+v.second);
  P to2(ball.first-v.first,ball.second-v.second);

  if(unused[to1] == true){
    dfs(to1,v);
  }

  if(unused[to2] == true){
    dfs(to2,v);
  }

  return;
} 
    

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

  if(n == 1){
    cout << 1 << endl;
    return 0;
  }

  vector<P> vec;
  vector<P> ball(n);

  for(int i = 0;i < n;i++){
    int x,y;
    cin >> x >> y;
    ball[i] = P(x,y);
  } 

  for(int i = 0;i < n - 1;i++){
    for(int j = i + 1;j < n;j++){
      int x1 = ball[i].first;
      int y1 = ball[i].second;
      int x2 = ball[j].first;
      int y2 = ball[j].second;
      vec.push_back(P(x1-x2,y1-y2));
    }
  }

  int ans = INF;
  for(P v:vec){
    int now = 0;
    for(int i = 0;i < n;i++)unused[ball[i]] = true;
    for(int i = 0;i < n;i++){
      if(unused[ball[i]] == true){
	dfs(ball[i],v);
	now++;
      }
    }
    ans = min(ans,now);    
  }        

  cout << ans << endl;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define INF 100005

int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
	int n,m;
	cin >> n >> m;
	vector<int>adj[INF];
	for(int i=0;i<m;i++)
	{
		int aa,bb;
		cin >> aa >> bb;
		adj[aa].push_back(bb);
		adj[bb].push_back(aa);
	}
	int level[INF]={0};
	bool vis[INF]={false};
	int parent[INF]={0};
	queue<int>q;
	q.push(1);
	level[1]=0;
	vis[1]=true;
	while(!q.empty())
	{
		int p=q.front();
		q.pop();
		for(int i=0;i<adj[p].size();i++)
		{
			if(vis[adj[p][i]]==false)
			{
				level[adj[p][i]]=level[p]+1;
				q.push(adj[p][i]);
				vis[adj[p][i]]=true;
				parent[adj[p][i]]=p;
			}
		}
	}
	int check=0;
	for(int i=2;i<=n;i++)
	{
		if(level[i]==0)
		{
			check=1;
			break;
		}
	}
	if(check==1)
	{
		cout << "No" << "\n";
		return 0;
	}
	cout << "Yes" << "\n";
	for(int i=2;i<=n;i++)
	{
		cout << parent[i] << "\n";
	}
}


Measured memory_bytes: 10936
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 405;
const ll MOD = 998244353;

int n,id;
int h[MAXN];

ll a[MAXN];
ll b[MAXN];
ll C[MAXN][MAXN];
ll pw2[MAXN];
ll f[MAXN << 2][2][MAXN];

queue<int> Q;

int newnode()
{
	int res = 0;
	if (!Q.empty())
	{
		res = Q.front();
		Q.pop();
	}
	else
		res = ++id;
	memset(f[res],0,sizeof(f[res]));
	return res;
}

int solve(int l,int r,int d)
{
	int x = newnode();
	if (l > r)
	{
		f[x][0][0] = f[x][1][0] = 1;
		return x;
	}
	for (int i = l;i <= r;i++)
		if (h[i] < d)
		{
			int u = solve(l,i - 1,d),v = solve(i + 1,r,d);
			for (int j = 0;j <= i - l;j++)
				for (int k = 0;k <= r - i;k++)
				{
					(f[x][0][j + k] += f[u][0][j] * f[v][0][k]) %= MOD;
					(f[x][1][j + k + 1] += f[u][1][j] * f[v][1][k]) %= MOD;
				}
			Q.push(u);
			Q.push(v);
			return x;
		}
	int u = solve(l,r,d + 1);
	for (int j = 0;j <= r - l + 1;j++)
	{
		(f[x][0][j] += f[u][1][j]) %= MOD;
		(f[x][1][j] += f[u][1][j]) %= MOD;
	}
	for (int j = 0;j <= r - l + 1;j++)
	{
		(f[x][0][j] += f[u][0][j] * (pw2[r - l + 1 - j] - 1)) %= MOD;
		(f[x][1][j] += f[u][1][j] * (pw2[r - l + 1 - j] - 1)) %= MOD;
	}
	for (int j = 1;j <= r - l + 1;j++)
		for (int k = 1;k <= j;k++)
		{
			(f[x][0][j - k] += f[u][0][j] * C[j][k] % MOD * pw2[r - l + 1 - j]) %= MOD;
			(f[x][1][j - k] += f[u][1][j] * C[j][k] % MOD * pw2[r - l + 1 - j]) %= MOD;
		}
	Q.push(u);
	return x;
}

int main()
{
	scanf("%d",&n);
	pw2[0] = 1;
	for (int i = 1;i <= n;i++)
		pw2[i] = pw2[i - 1] * 2 % MOD;
	for (int i = 0;i <= n;i++)
	{
		C[i][0] = 1;
		for (int j = 1;j <= i;j++)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
	}
	for (int i = 1;i <= n;i++)
		scanf("%d",&h[i]);
	solve(1,n,1);
	printf("%lld\n",f[1][0][0]);
	return 0;
}

Measured memory_bytes: 9728
// AOJ 1618: A Garden with Ponds
// 2017.12.25 bal4u@uu

#include <stdio.h>

#define MAX 9

int map[10][10];
int max[10][10][10][10];
int cap[10][10][10][10];

int main()
{
	int d, w, r, c, m, s, ans;
	int d1, w1, r1, c1, r2, c2;

	while (scanf("%d%d", &d, &w) && d > 0) {
		d1 = d-1, w1 = w-1;
		for (r= 0; r < d; r++) for (c = 0; c < w; c++) scanf("%d", &map[r][c]);

		// ?????¢???????¢??????????????????????????????¨?????§?????????????????????9??¨????????????????¨????
		for (r1 = 1; r1 < d1; r1++) for (c1 = 1; c1 < w1; c1++) {
			for (r2 = r1; r2 < d1; r2++) for (c2 = c1; c2 < w1; c2++) {
				m = 0, s = 0;
				for (r = r1; r <= r2; r++) for (c = c1; c <= c2; c++) {
					if (map[r][c] > m) m = map[r][c];
					s += MAX - map[r][c];
				}
				max[r1][c1][r2][c2] = m;
				cap[r1][c1][r2][c2] = s;
			}
		}

		ans = 0;
		// ???????????????????±?????¢????????????????
		for (r1 = 0; r1 < d; r1++) for (c1 = 0; c1 < w; c1++) {
			for (r2 = r1+2; r2 < d; r2++) for (c2 = c1+2; c2 < w; c2++) {
				m = MAX;
				for (r = r1; r <= r2; r++) if (map[r ][c1] < m) m = map[r ][c1];
				for (r = r1; r <= r2; r++) if (map[r ][c2] < m) m = map[r ][c2];
				for (c = c1; c <= c2; c++) if (map[r1][c ] < m) m = map[r1][c ];
				for (c = c1; c <= c2; c++) if (map[r2][c ] < m) m = map[r2][c ];
				if (max[r1+1][c1+1][r2-1][c2-1] >= m) continue;
				s = cap[r1+1][c1+1][r2-1][c2-1] - (MAX-m)*(r2-r1-1)*(c2-c1-1);
				if (s > ans) ans = s;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    int ans = 0;
    rep(i, s.length())
    {
        if (s[i] == t[i])
            continue;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    int a,b; cin >> a >> b;
    int coins = 0;

    for (int i =0; i<2; i++) {
        if (a >= b) {
            coins+=a;
            a--;
        } else {
            coins+=b;
            b--;
        }
    }

    cout << coins << endl;
    return 0;
}

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

#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() {
  int N, M;
  cin >> N >> M;

  int s[M], c[M];
  int ans[N];
  rep(i,N) {
    ans[i] = -1;
  }
  bool flag = true;
  rep(i,M) {
    cin >> s[i] >> c[i];
    if (ans[s[i]-1] != -1 && ans[s[i]-1] != c[i]) {
      cout << -1 << endl;
      flag = false;
    }
    ans[s[i]-1] = c[i];
  }

  if (ans[0] == 0 && flag) {
    if (N > 1) cout << -1 << endl;
    else cout << 0 << endl;
  } else if (flag) {
    rep(i,N) {
      if (ans[i] == -1) {
        if (i == 0 && N > 1) {
          cout << 1;
        } else {
          cout << 0;
        }
      } else {
        cout << ans[i];
      }
    }
    cout << endl;
  }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <numeric>
using namespace std;

const int MAX_N = 10;
const int MAX_S = 1<<13;

int S, N;
int ms[2][MAX_N];
bool win[2][MAX_N][MAX_S];

bool init(){
	scanf("%d%d", &N, &S);
	for(int i=0; i<N; i++){
		scanf("%d%d", ms[0]+i, ms[1]+i);
	}

	return N > 0;
}

bool solve(){

	for(int i=0; i<=S; i++){
		for(int k=0; k<2; k++){
			for(int j=0; j<N; j++){
				if(i == 0){
					win[k][j][i] = true;
					continue;
				}
				win[k][j][i] = false;
				int nxt = (k > 0 ? (j+1)%N : j);
				for(int t=1; t<=ms[k][j] && i-t>=0; t++){
					win[k][j][i] |= !win[k^1][nxt][i-t];
				}
			}
		}
	}

	return win[0][0][S];
}

int main(){
	while(init()){
		puts(solve() ? "1" : "0");
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 1000000007L;
	static final int INF = 50000000;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.ni();
		int[] ans = new int[N+1];
		for (int x = 1; x < 100; x++) {
			for (int y = 1; y < 100; y++) {
				for (int z = 1; z < 100; z++) {
					int v = x*x+y*y+z*z+x*y+x*z+y*z;
					if (v <= N)
						ans[v] += 1;
				}
			}
		}
		for (int i = 1; i <= N; i++)
			pw.println(ans[i]);
		pw.close();
	}
	
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            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 ni() { 
            return Integer.parseInt(next()); 
        }
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() {
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

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

const int A = 1000005;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(A);
  
  rep(i,n){
    cin >> a[i];
    ++b[a[i]];
  }
  
  bool ispw = true;
  //pairwise coprimeの判定
  for(int i=2; i<A; ++i){
    int cnt = 0;
    for(int j=i; j<A; j+=i){
      cnt += b[j];
    }
    if(cnt < 2) continue;
    ispw = false;
    break;
  }
  
  if(ispw){
    cout << "pairwise coprime" << endl;
    return 0;
  }
  
  //setwise coprimeの判定
  int g = 0;
  rep(i,n) g = gcd(g,a[i]);
  if(g == 1){
    cout << "setwise coprime" << endl;
    return 0;
  }
  
  cout << "not coprime" << endl;
  
  return 0;
}

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

int main(){
    vector<int> a(3);
    for(int i = 0; i < 3; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());

    cout << a.at(0) << " " << a.at(1) << " " << a.at(2) << endl;   
    return 0;
}





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

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

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

int main(int argc, char* argv[]){
    int N, M, X, tmp, cnta, cntb, ans = 100;
    bool A[101] = {};
    cin >> N >> M >> X;
    for(int i = 0; i < M; i++){
        cin >> tmp;
        A[tmp] = true;
    }
    cnta = 0;
    for(int i = X; i > 0; i--){
        if(A[i]) cnta++;
    }
    cntb = 0;
    for(int i = X; i <= N; i++){
        if(A[i]) cntb++;
    }
    cout << min(cnta, cntb) << endl;
}

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

public class B {
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        string[] line = Console.ReadLine().Split(' ');
        List<int> X = new List<int>();
        for (int i=0;i<N;i++)
        {
            X.Add(int.Parse(line[i]));
        }
        int minCount = 100*100*100;
        for (int i=1;i<=100;i++)
        {
            int sum = 0;
            for (int j=0;j<N;j++)
            {
                sum += GetPower(X[j], i);
            }
            if (minCount > sum)
            {
                minCount = sum;
            }
        }
        Console.WriteLine(minCount);
    }
    
    private static int GetPower(int X, int p)
    {
        int single = X-p;
        return single*single;
    }
}


Measured memory_bytes: 13140
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static long divCeil(long a, long b) {
		return (long) Math.ceil((double) a / b);
	}

	static void exec(MyScanner in, PrintWriter out) {
		long N = in.nextLong();
		long A = in.nextLong();
		long B = in.nextLong();
		long C = in.nextLong();
		long D = in.nextLong();
		long E = in.nextLong();
		long m = divCeil(N, A);
		m += (A <= B) ? 1 : 1 + divCeil(N, B) - m;
		m += (A <= C || B <= C) ? 1 : 2 + divCeil(N, C) - m;
		m += (A <= D || B <= D || C <= D) ? 1 : 3 + divCeil(N, D) - m;
		m += (A <= E || B <= E || C <= E || D <= E) ? 1 : 4 + divCeil(N, E) - m;
		out.println(m);
	}

	public static void main(String[] args) {
		PrintWriter w = new PrintWriter(System.out);
		exec(new MyScanner(System.in), w);
		w.flush();
	}

	static class MyScanner {
		static final int BUFFER_SIZE = 1024;
		private final InputStream in;
		private final byte[] buffer = new byte[BUFFER_SIZE];
		private int point;
		private int readLength;
		MyScanner(InputStream in) {
			this.in = in;
		}
		private int readByte() {
			if (point < readLength) {
				int result = buffer[point];
				point += 1;
				return result;
			}
			try {
				readLength = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (readLength == -1) {
				return -1;
			}
			point = 1;
			return buffer[0];
		}
		static boolean isPrintableCharExceptSpace(int c) {
			return 33 <= c && c <= 126;
		}
		String next() {
			StringBuilder b = new StringBuilder();
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			do {
				b.appendCodePoint(c);
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return b.toString();
		}
		long nextLong() {
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long result = 0L;
			do {
				if (!('0' <= c && c <= '9')) {
					throw new InputMismatchException();
				}
				result = result * 10L + (c - '0');
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return minus ? -result : result;
		}
		int nextInt() {
			long n = nextLong();
			if (Integer.MIN_VALUE <= n && n <= Integer.MAX_VALUE) {
				return (int) n;
			}
			throw new InputMismatchException();
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}


Measured memory_bytes: 23252