akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;


void pre(){

}

void solve(){
  ll n; cin>>n;
  ll a[n];
  ll x=0;

  rep(i,n){
    cin>>a[i];
    x=x^a[i];
  }

  rep(i,n){
    cout<<(x^a[i])<<" ";
  }

  cout<<"\n";
}

int main(){
  // #ifndef ONLINE_JUDGE
  //   freopen("in.txt","r",stdin);
  // #endif
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}


Measured memory_bytes: 5120
h,w=map(int,input().split())
s=[input() for ri in range(h)]
table=[0]*(h*w)
for i in range(h):
    p=0
    pre=0
    for j in range(w):
        if s[i][j]=="#":
            if p==0:continue
            for x in range(pre,j):
                table[w*i+x]+=p
            p=0
        else:
            if p==0:
                pre=j
            p+=1
    else:
        if p:
            for x in range(pre,w):table[w*i+x]+=p

for j in range(w):
    p=0
    pre=0
    for i in range(h):
        if s[i][j]=="#":
            if p==0:continue
            for x in range(pre,i):
                table[j+w*x]+=p
            p=0
        else:
            if p==0:pre=i
            p+=1
    else:
        if p:
            for x in range(pre,h):table[j+w*x]+=p
        p=0

print(max(table)-1)

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n; cin >> n;
  vi a(n), b(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  for(int i=0;i<n;++i) {
    cin >> b[i];
  }

  vvi dp((1<<n)+1, vi(55, INF));
  dp[0][0] = 0;
  for(int i=0;i<(1<<n);++i) {
    int cnt = __builtin_popcount(i);

    int iter = cnt;
    vector<P> v;
    for(int j=0;j<n;++j) {
      if(!((i>>j)&1)) v.push_back({j, iter++});
    }

    for(int j=0;j<=50;++j) {
      if(dp[i][j] >= INF) continue;
      for(auto &p: v) {
        int ns = -1;
        if(abs(p.first - cnt) % 2 == 0) ns = a[p.first];
        else ns = b[p.first];

        if(ns >= j) {
          dp[i | (1<<p.first)][ns] = min(dp[i | (1<<p.first)][ns], dp[i][j] + abs(p.second - cnt));
        }
      }
    }
  }
  int res = INF;
  for(int i=0;i<=50;++i) {
    res = min(res, dp[(1<<n)-1][i]);
  }
  cout << (res < INF ? res : -1) << endl;

}


Measured memory_bytes: 67968
import numpy as np

H, W, K = list(map(int, input().split()))
C = []
for i in range(H) :
  C.append(list(map(lambda c : 1 if c == "#" else 0, input())))
C = np.array(C)
ans = 0
for i in range(2**H) :
  for j in range(2**W) :
    C_copy = C.copy()
    for ii in range(H+1) :
      if i & int(2**(ii)) :
        C_copy[ii-1, :] = 0
    for jj in range(W+1) :
      if j & int(2**(jj)) :
        C_copy[:, jj-1] = 0
    if np.sum(C_copy) == K :
      ans += 1
    
  
print(ans)
  


Measured memory_bytes: 27264
#include <stdio.h>

int main(void) {
	int S[14]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	int H[14]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	int C[14]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	int D[14]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	int n,i,j,num;
	char sym;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++){
	scanf(" %c %d",&sym,&num);
	if(sym == 'S'){
		S[num-1]=0;
	}else if(sym == 'H'){
		H[num-1]=0;
	}else if(sym == 'C'){
		C[num-1]=0;
	}else if(sym == 'D'){
		D[num-1]=0;
	}
	}
	
	for(j=0;j<=13;j++){
		if(S[j]==j+1){
			printf("S %d\n",j+1);
		}
	}
	for(j=0;j<=13;j++){
		if(H[j]==j+1){
			printf("H %d\n",j+1);
		}
	}
	for(j=0;j<=13;j++){
		if(C[j]==j+1){
			printf("C %d\n",j+1);
		}
	}
	for(j=0;j<=13;j++){
		if(D[j]==j+1){
			printf("D %d\n",j+1);
		}
	}
	return 0;
}


Measured memory_bytes: 2108
def rle(s):
    run_s, run_length, compressed_s = s[0], 1, []
    for next in range(1, len(s)):
        if run_s == s[next]:
            run_length += 1
        else:
            compressed_s.append((run_s, run_length))
            run_s = s[next]
            run_length = 1
    compressed_s.append((run_s, run_length))
    return compressed_s

s = input()
gathered = [0] * len(s)
separating_index = -1
rle_s = rle(s)
for i in range(len(rle_s) // 2):
    separating_index += rle_s[2*i][1]
    gathered[separating_index] = ((rle_s[2*i][1] + 1) // 2) + (rle_s[2*i + 1][1] // 2)
    gathered[separating_index + 1] = (rle_s[2*i][1] + rle_s[2*i + 1][1]) - gathered[separating_index]
    separating_index += rle_s[2*i + 1][1]

for i in range(len(s)):
    print(gathered[i], end=' ')

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int L = A + B;
  int R = C + D;
  
  if ( L > R ){
   cout << "Left" << endl; 
  }
  else if ( L < R ){
   cout << "Right" << endl; 
  }
  else {
   cout << "Balanced" << endl;
  }
  
}

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[[] for i in range(n)]
for i in range(n):
    a=I()
    for j in range(a):
        lis[i].append(LI())
#print(lis)
ans=[]
for x in product([0,1],repeat=n):
    count=0
    flag=True
    for j in range(n):
        if x[j]==1:
            count+=1
            for k in range(len(lis[j])):
                if x[lis[j][k][0]-1]!=lis[j][k][1]:
                    flag=False
    if flag==True:
        ans.append(count)
print(max(ans))
        
        
        
            
        

                

Measured memory_bytes: 75380
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
flag=False
cnt=0
for i in range(n):
    if arr[i][0]==arr[i][1]:
        cnt+=1
        if cnt==3:
            flag=True
            break
    else:
        cnt=0
if flag==True:
    print('Yes')
else:
    print('No')

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n)cin>>a[i];
	ll sum = 0;
	rep(i,n) sum += a[i];
	// sum の約数が出来る候補
	set<ll> candidates;
	for(int i = 1; i * i <= sum; i++){
		if(sum % i == 0){
			candidates.insert(i);
			candidates.insert(sum/i);
		}
	}

	ll ans = 1;
	for (ll x:candidates) {
		ll need;
		{	// calc need
			vector<ll> r(n);
			rep(i,n) r[i] = a[i]%x;
			sort(r.begin(),r.end());
			ll B = 0;
			rep(i,n) B += x - r[i];
			ll A = 0; // 区切り位置を左から1個ずつ試す
			need = 1e18;
			rep(i,n){
				A += r[i];
				B -= x-r[i];
				need = min(need, max(A,B));
			}
		}
		if (need <= k) ans = max(ans, x);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3552
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc162/tasks/abc162_e

//参考：
//https://kmjp.hatenablog.jp/entry/2020/04/12/1000

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const {
    return ModInt(*this) += p;
  }
  ModInt operator-(const ModInt &p) const {
    return ModInt(*this) -= p;
  }
  ModInt operator*(const ModInt &p) const {
    return ModInt(*this) *= p;
  }
  ModInt operator/(const ModInt &p) const {
    return ModInt(*this) /= p;
  }
  bool operator==(const ModInt &p) const {
    return x == p.x;
  }
  bool operator!=(const ModInt &p) const {
    return x != p.x;
  }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ans(1), mul(x);
    while(n) {
      if(n & 1) ans *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ans;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

LL N,K;

ModInt<mod> ans = 0;

void solve(){
	vector<ModInt<mod>> dp(K+1,0);
	for(int i=K;i>=1;i--){
		dp[i] = ModInt<mod>(K/i).pow(N);
		for(int j=i*2;j<=K;j+=i) dp[i] -= dp[j];
		ans += ModInt<mod>(i)*dp[i];
	}
}

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

    solve();

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

Measured memory_bytes: 3140
from collections import defaultdict
from typing import List, Tuple


def pf(n: int) -> List[Tuple[int,int]]:
    r = []
    for p in range(2, n):
        if p * p > n:
            break
        e = 0
        if n % p == 0:
            while(n % p == 0):
                n //= p
                e += 1
            r.append((p, e))
    if n != 1:
        r.append((n, 1))
    return r


d = defaultdict(int)
n = int(input())
for i in range(1,n+1):
    r = pf(i)
    for p,e in r:
        d[p] += e

mod = 10**9+7
ans = 1
for ei in d.values():
    ans *= ei+1
    ans %= mod
print(ans)


Measured memory_bytes: 10272
N = int(input())
lst = []
for i in range(N):
  s, p = input().split()
  lst.append([s, int(p), i+1])
lst = sorted(lst, key = lambda x: x[1], reverse=True)
lst = sorted(lst, key = lambda x: x[0])
for j in range(N):
  print(lst[j][2], end=" ")

Measured memory_bytes: 9192
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
	
		Scanner scn=new Scanner(System.in);
		Map<String,String> list=new HashMap<String,String>();
		
		list.put("Sunny","Cloudy");
		list.put("Cloudy","Rainy");
		list.put("Rainy","Sunny");
		
		String str=scn.next();
		
		if(str.contains("Sunny")) {
			System.out.println(list.get(str));
		}
		if(str.contains("Cloudy")) {
			System.out.println(list.get(str));
		}
		if(str.contains("Rainy")) {
			System.out.println(list.get(str));
		}
		
		scn.close();
	}
}

Measured memory_bytes: 22868
// https://atcoder.jp/contests/abc149/tasks/abc149_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int N> struct calc_prime {
    bool b[N + 1];

    constexpr calc_prime() : b() {
        for (int_fast64_t i = 0; i <= N; ++i)
            b[i] = true;
        b[0] = b[1] = false;
        for (int_fast64_t i = 2; i <= N; ++i) {
            for (int_fast64_t j = i * i; j <= N; j += i)
                b[j] = false;
        }
    }
};
calc_prime<200000> prime;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X;
    cin >> X;
    while (true) {
        if (prime.b[X]) {
            cout << X << endl;
            break;
        }
        X++;
    }
    return 0;
}


Measured memory_bytes: 3700
using System;

namespace abc151_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string C = Console.ReadLine();
            char[] cChar = C.ToCharArray();

            int cInt = (int)cChar[0];
            cInt += 1;

            char cNext = (char)cInt;
            Console.WriteLine(cNext);
        }
    }
}


Measured memory_bytes: 25656
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

def printp():
  for q in p:
    print q

def if_in_paper(x,y):
  if 0 <= x and x < 10 and 0 <= y and y <10:
    return True
  else:
    return False

def pro(x,y,lis):
  for e in lis:
    px,py = x+e[0], y+e[1]
    if if_in_paper(px,py):
      p[py][px] += 1

p = [ [0]*10 for i in range(10)]

small = [[0,0],[1,0],[0,1],[-1,0],[0,-1]]
midium = small + [[1,1],[1,-1],[-1,1],[-1,-1]]
large = midium + [[2,0],[0,2],[-2,0],[0,-2]]
water_list = [small,midium,large]

for s in sys.stdin:
  d = map(int,s.split(","))
  pro( d[0], d[1], water_list[ d[2]-1 ] )

print sum( [ 1 for i in range(10) for j in range(10) if p[i][j] == 0] )
print max( [ max(q) for q in p] )

Measured memory_bytes: 4292
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n;

int main(void){
    cin >> n;
    vector<vector<lli>> f(n, vector<lli>(10)), p(n, vector<lli>(11));
    rep(i, n){
        rep(j, 10) cin >> f[i][j];
    }
    rep(i, n){
        rep(j, 11) cin >> p[i][j];
    }
    lli ans = -1e18;
    rep(b, 1<<10){
        if(b == 0) continue;
        lli v = 0;
        rep(i, n){
            lli c = 0;
            rep(j, 10){
                if(b>>j&f[i][j]) c++;
            }
            v+=p[i][c];
        }
        ans = max(ans, v);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  if(a==b){cout<<"Yes"<<endl;return 0;}
  for(int i=0;i<a.size();i++){
    string t=a.substr(a.size()-1,1);
    a.pop_back();
    a=t+a;
    if(a==b){cout<<"Yes"<<endl;return 0;}
  }
  cout<<"No"<<endl;
  return 0;
}


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

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

  string ans;
  for ( int bit = 0; bit < (1<<3); bit++ ) {
    ans = n[0];
    int seven = n[0]-'0';
    for ( int i = 0; i < 3; i++ ) {
      if ( bit & (1<<i) ) {
        ans += '+';
        ans += n[i+1];
        seven += n[i+1]-'0';
      } else {
        ans += '-';
        ans += n[i+1];
        seven -= n[i+1]-'0';
      }
    }
    if ( seven == 7 ) {
      ans += "=7";
      break;
    }
  }

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


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

int n, g, ans=0;
vector<int> a(500000);

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

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a.at(i);

    vector<int> l(n+1, 0);
    vector<int> r(n+1, 0);

    for (int i = 0; i < n; ++i)
        l.at(i+1) = gcd(l.at(i), a.at(i));

    for (int i = n-1; i >= 0; --i)
        r.at(i) = gcd(r.at(i+1), a.at(i));

    for (int i = 0; i < n; ++i)
        ans = max(gcd(l.at(i), r.at(i+1)), ans);
    
    cout << ans << endl;
}

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


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

    string s;
    cin >> s;
    if (s[s.size() - 1] == 's') {
        cout << s << "es" << endl;
    } else {
        cout << s << "s" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

using namespace std;



int main() {
	char S[4] = {};
	cin >> S;
	int l = strlen(S);
	if (l == 2) {
		cout << S;
	}
	else {
		for (int i = 2; i >= 0; i--) {
			printf("%c",S[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
 
int main()
{
	string S, T;
  	cin >> S >> T;
  
  	if(S.size()+1 != T.size())
      cout << "No";
  	else
    {
      T.erase(T.size()-1);
      if(T == S)
        cout << "Yes";
      else
        cout << "No";
    }
  	
 
	return 0;
}

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

typedef long long ll;
using namespace std;

int num[9];
bool f[10];
int ans;

void dfs(int n){
	if(n == 9){
		int a = num[0] + 10*num[1] + num[2] + 100*num[3] + 10*num[4] + num[5];
		int b = 100*num[6] + 10*num[7] + num[8];
		if(a == b) ans++;
		return;
	}
	if(num[n] != -1) dfs(n+1);
	else {
		for (int i = 1;i <= 9;i++){
			if(f[i]) continue;
			f[i] = true;
			num[n] = i;
			dfs(n+1);
			num[n] = -1;
			f[i] = false;
		}
	}
	return;
}

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

	for (int i = 0;i < 9;i++){
		cin >> num[i];
		if(num[i] != -1) f[num[i]] = true;
	}

	dfs(0);

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll inf=1001001001;
ll res=0;

ll merge_cnt(vector<ll> &a) {
    ll n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin()+n/2);
    vector<ll> c(a.begin()+n/2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    ll ai = 0, bi = 0, ci = 0;
    // merge の処理
    while (ai < n) {
        if ( bi < b.size() && (ci == c.size() || b[bi] <= c[ci]) ) {
            a[ai++] = b[bi++];
        } else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main(){
    ll n; cin>>n;
    vector<ll> s(n);
    rep(i,n) cin>>s[i];
    cout<<merge_cnt(s)<<endl;
    return 0;
}



Measured memory_bytes: 7708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int a;
	string s;
	stringstream ss,sss;
	cin>>s;
	ss<<s.substr(5,2);
	ss>>a;
	if(a<4)cout<<"Heisei"<<endl;
	else if(a>4)cout<<"TBD"<<endl;
	else
	{
		sss<<s.substr(8,2);
		sss>>a;
		if(a<=30)cout<<"Heisei"<<endl;
		else cout<<"TBD"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let n:usize = get_input().parse().unwrap();

    let mut ans = 0.;
    for _ in 0..n {
        let line = get_input();
        let mut split = line.split_whitespace();
        let x:f64 = split.next().unwrap().parse().unwrap();
        let v = split.next().unwrap();

        if v == "JPY" {
            ans += x;
        } else {
            ans += x * 380000.;
        }
    }

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

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

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

using namespace std;
typedef long long int ll;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }

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

int H, W;
char maps[1001][1001];
mint dp[1001][1001];
int main(void){
    cin >> H >> W;
    rep(i,H) scanf("%s",maps[i+1]+1);
    dp[0][1] = 1;

    for(int h=1;h<=H;h++) for(int w=1;w<=W;w++){
        if(maps[h][w] == '#') continue;
        dp[h][w] = dp[h-1][w] + dp[h][w-1];
    }

    cout << dp[H][W] << endl;
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    long nums[n];
    for(int i = 0; i < n; i++){
        cin >> nums[i];
    }
    long ans1 = 0, ans2 = 0;
    long sum1 = 0, sum2 = 0;
    for(int i = 0; i < n; i++){
        if(i % 2){
            ans1 += max(0l, 1 - (sum1 + nums[i]));
            sum1 += nums[i] + max(0l, 1 - (sum1 + nums[i]));
            ans2 += max(0l, sum2 + nums[i] + 1);
            sum2 += nums[i] - max(0l, sum2 + nums[i] + 1);
        }else{
            ans1 += max(0l, sum1 + nums[i] + 1);
            sum1 += nums[i] - max(0l, sum1 + nums[i] + 1);
            ans2 += max(0l, 1 - (sum2 + nums[i]));
            sum2 += nums[i] + max(0l, 1 - (sum2 + nums[i]));
        }
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define debug cout<<"****************"<<endl
using namespace std;
typedef long long ll;
inline void ju() {
	freopen("***.in","r",stdin);
	freopen("***.out","w",stdout);
}
inline ll rd() {
	ll x=0,f=1; char c=getchar();
	while((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') {
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	int n=rd(),i=rd();
	printf("%d\n",n-i+1);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Read()[0];
            for (char c = 'a'; c <= 'z'; c++)
            {
                if (a == c)
                {
                    Console.WriteLine("a");
                    return;
                }
            }

            Console.WriteLine("A");
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static string[] ReadArrayString() { return Read().Split(' '); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 25880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << #x << ": " << x << '\n';
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
const int mod = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<ll> vec(n + 1, 0);
  vector<bool> check(n + 1, true);
  for (int i = 0; i < m; ++i) {
    int a; cin >> a;
    check[a] = false;
  }
  
  vec[0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j <= min(n, i + 2); ++j) {
      if (check[j] == true) {
        vec[j] += vec[i];
        vec[j] %= mod;
      }
    }
  }
  cout << vec[n] % mod<< '\n';
}


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

#define rep(i,a,b) for (int i = (a); i < (b); i++ )

int main() {
	int  n;
	cin >> n;
	int a = n % 10;

	if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
		cout << "hon" << endl;
	}
	else if (a == 0 ||a == 1 || a == 6 || a == 8) {
		cout << "pon" << endl;
	}
	else if (a == 3) {
		cout << "bon" << endl;
	}
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(void){

// 宣言
    int input[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int k;
    int output;
    
    scanf("%d", &k);

    printf("%d\n", input[k-1]);

    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;

int n;
string s,s2;

int main()
{
    cin >> n;
    cout << 0 << endl;
    cin >> s;
    if(s == "Vacant") return 0;
    int a = 0, b = n;
    int m;
    while(1)
    {
        m = (a+b)/2;
        cout << m << endl;
        cin >> s2;
        if(s2 == "Vacant") return 0;
        if((m%2==0 && s!=s2) || (m%2==1 && s==s2))
        {
            b = m - 1;
        }
        else
        {
            a = m + 1;
        }
    }
}


Measured memory_bytes: 852
N = int(input())
S = input()

# Build LCP array by Z-algorithm
def build_lcp(s):
  lcp = [0]*len(s)
  j = 0
  for i in range(1,len(s)):
    if i+lcp[i-j] < j+lcp[j]:
      lcp[i] = lcp[i-j]
    else:
      k = max(0,j+lcp[j]-i)
      while i+k < len(s) and s[k] == s[i+k]:
        k += 1
      lcp[i] = k
      j = i
  lcp[0] = len(s)
  return lcp

ans = 0
for i in range(N):
  lcp = build_lcp(S[i:])
  #print('{}: {}'.format(i,S[i:]))
  #print('{}: {}'.format(i,lcp))
  for j in range(1,len(S[i:])):
    #print('    j={} lcp[j]={}  {}'.format(j,lcp[j],i+lcp[j]))
    if lcp[j] <= j:
      #print('    OK!')
      ans = max(ans,lcp[j])
print(ans)


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

int main(){
    int a,b;
    cin >> a >> b;
    if (a >= b){
        rep(i,a) cout << b;
    }
    if (a < b){
        rep(i,b) cout << a;
    }
}

Measured memory_bytes: 256
package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
        "strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func cmpStrNum(a, b string) bool {
        if a == "---" {
                return true
        }
        if len(a) < len(b) {
                return true
        } else if len(a) > len(b) {
                return false
        }
        return a < b
}

func main() {
        line := nextLine()

        spl := intSprit(line)

        N := spl[0]

        a := intSprit(nextLine())
        tb := []int{2, 5, 5, 4, 5, 6, 3, 7, 6}

        dp := make([]string, 100000)
        for i := 1; i < len(dp); i++ {
                dp[i] = "---"
        }
        dp[0] = ""

        for i := 0; i <= N; i++ {
                if dp[i] == "---" {
                        continue
                }
                for _, v := range a {
                        if cmpStrNum(dp[i+tb[v-1]], dp[i]+strconv.Itoa(v)) {
                                dp[i+tb[v-1]] = dp[i] + fmt.Sprint(v)
                        }
                }
        }
        fmt.Println(dp[N])
}


Measured memory_bytes: 131136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A=0,B=0,C=0,D,E;
  string S;
  cin >> S;
  A=S.size();
  vector<int>L(A,0),R(A,1);
  for(int i=0;i<A;i+=2){
    L[i]=1;
    R[i]=0;
  }
  for(int i=0;i<A;i++){
    if(S[i]-'0'!=L[i])B++;
    if(S[i]-'0'!=R[i])C++;
  }
  cout << min(C,B) << endl;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
	
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int ans = 0,cnt = 0,visiting = 1,a[1000],b[1000],n,m;
bool is_visited[8] = {false};

void dfs(){
	cnt++;
	if(cnt == n){
		ans++;
		return ;
	}
	
	rep(i,0,m){
		if(a[i] == visiting && !is_visited[b[i]-1]){
			visiting = b[i];
			is_visited[a[i]-1] = true;
			
			dfs();
			cnt--;
			visiting = a[i];
			is_visited[a[i]-1] = false;
			
		}
		else if(b[i] == visiting && !is_visited[a[i]-1]){
			visiting = a[i];
			is_visited[b[i]-1] = true;
			
			dfs();
			cnt--;
			visiting = b[i];
			is_visited[b[i]-1] = false;
			
		}
	}
	return;
}

int main(){
	cin >> n >> m;
	
	rep(i,0,m){
		cin >> a[i] >> b[i];
	}
	
	dfs();
	
	cout << ans << endl;
	
	
  	return 0;
}





Measured memory_bytes: 256
line_len = int(input())
s = input().rstrip().split(' ')
inns = []
ans = 1
for i in range(line_len):
    inns.append(int(s[i]))
for i in range(1,line_len):
    for x in range(i):
        total = 1
        if inns[x] > inns[i]:
            total = 0
            break
    ans = ans + total
print(ans)

Measured memory_bytes: 3064
import sys, collections
n = int(input())
uq = ["".join(sorted(x.rstrip())) for x in sys.stdin.readlines()]
chk = collections.Counter(uq)
ans = 0
for x in chk:
    if chk[x] != 1:
        ans += chk[x]*(chk[x]-1)//2
print(ans)

Measured memory_bytes: 21616
#include<stdio.h>
int main(void)
{
	int a, b, c, w, h;
	for (c = 1;;)
	{
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0)
			break;
		for (h = 1;h <= a;h++)
			if (h % 2 == 0)
			{
				for (w = 1;w <= b;w++)
				{
					if (w % 2 == 0)
						printf("#");
					else
						printf(".");
				}
				printf("\n");
			}
			else
			{
				for (w = 1;w <= b;w++)
				{
					if (w % 2==0)
						printf(".");
					else
						printf("#");
				}
				printf("\n");
			}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2044
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
static long[] f;
static long mod=(long)1e9+7;
//......................................@uthor_Alx..............................................
   static long dis(long x1,long y1){
   		return x1*x1+y1*y1;
   }
   public static void main(String[] args) throws  IOException{
				assign();
				int t=1;//int_v(read()),cn=1;
				while(t--!=0){
					int res=-1;
					int n=int_v(read());
					long m=0,pre=0,k=1;
					for(int i=0;i<5000000;i++){
						pre+=7l*k;
						if(pre%n==0){res=i+1;break;}
						k*=10;k%=n;
					}
					out.write(res+"");
				}
			    
			    out.flush();

	}
}

	       

	       


Measured memory_bytes: 36728
//#include <bits/stdc++.h>
// utility
#include <bitset>
#include <tuple>
#include <typeinfo>
// error handling
#include <cassert>
// string
#include <cctype>
#include <cstring>
#include <string>
// container
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
// algorithm
#include <algorithm>
// iterator
#include <iterator>
// math
#include <cmath>
#include <complex>
#include <numeric>
#include <random>
// i/o
#include <iostream>
#include <iomanip>
#include <cstdio>



using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
long long modpow(long long base, long long exponent, long long mod=1) {
  long long res = 1;
  while (exponent > 0) {
    if (exponent & 1)
      res = res * base % mod;
    base = base * base % mod;
    exponent >>= 1;
  }
  return res;
}

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

  string S; cin >> S;
  int K; cin >> K;
  int gosencho=5000000000000000ll;

  rep(i,0,S.size()){
    if(S[i]>'1'){
      cout<<S[i]<<endl;
      break;
    }
    else {
      K--;
      if(K==0){
        cout<<S[i]<<endl;
        break;
      }
    }
    



  }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
        int d=b+c-a;
        if(d<0){
            if(b>c){
                System.out.println(c+" "+0);   
            }else{
                System.out.println(b+" "+0);                
            }
        }else{
            if(b>c){
                    System.out.println(c+" "+d);   
                }else{
                    System.out.println(b+" "+d);                
                }
            }
	    }
	}


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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int r[n];
    rep(i,n)cin >> r[i];
    int min_v = r[0], max_v = (-1)*(pow(10,9) + 1);
    REP(i,1,n){
        max_v = max(max_v, r[i] - min_v);
        min_v = min(min_v, r[i]);
    }

    cout << max_v << endl;
    return 0;
}


Measured memory_bytes: 3864
def root(x):
    if r[x] < 0:
        return x
    else:
        r[x] = root(r[x])
        return r[x]

def unite(x, y):
    x = root(x)
    y = root(y)
    if x != y:
        if r[x] > r[y]:
            x,y = y,x
        r[x] += r[y]
        r[y] = x

def size(x):
    return -r[root(x)]
 
n,q = map(int,input().split())
r = [-1] * n 
for i in range(q):
    t,a,b = map(int, input().split())
    if t == 0:
        unite(a,b)
    else:
        if root(a) == root(b):
            print(1)
        else:
            print(0)

Measured memory_bytes: 11452
#include <stdio.h>
 
int main(void) {
    int h, w, i, j;
    while(scanf("%d %d", &h, &w)){
        if(h == 0 && w == 0)
            return 0;
             
        for(i=0;i<h;i++) {
            for(j=0;j<w;j++) {
                if(i==0 || i==h-1 || j==0 || j==w-1) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
     
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  int a, b = 0;
  for(int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  a = d.at(N/2-1);
  b = d.at(N/2);
  cout << b-a << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vi a(n);
    vi b(n);
    vi c(n);
    REP(i,0,n){
        cin>>a[i];
    }
    REP(i,0,n){
        cin>>b[i];
    }
    REP(i,0,n-1){
        cin>>c[i];
    }

    int ans=0;
    for(int i=0;i<n;i++){
        if(i==0){
            ans+=b[a[i]-1];
        }
        else{
            ans+=b[a[i]-1];
            if(a[i]==(a[i-1]+1)){
                ans+=c[a[i-1]-1];
            }
        }
    }
    cout<<ans<<"\n";


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,a=0,b=0,k=0;
	cin>>n;
    a=n%10;
    n=n/10;
    a+=(10*(n%10));
    n=n/10;
	
	b=n%10;
	n=n/10;
	b+=(10*(n%10));

	
	if(a>0&&a<13&&b>0&&b<13) cout<<"AMBIGUOUS";
	else if(a>0&&a<13) cout<<"YYMM";
	else if(b>0&&b<13) cout<<"MMYY";
	else cout<<"NA";
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define read(x) scanf("%d",&x)
using namespace std;
const int maxn = 1e5 + 10;

int n;
int p[maxn], pos[maxn];
multiset <int> s;
multiset<int>::iterator a1,a2,x,y,b1,b2;

int main()
{   
	cin>>n;
	for(int i=1;i<=n;i++) {
		read(p[i]);
		pos[p[i]] = i;
	}
	s.insert(0); s.insert(0);
	s.insert(n+1); s.insert(n+1);
	ll res = 0;
	for (int i=n;i>=1;i--){
		s.insert(pos[i]);
		x = y = s.lower_bound(pos[i]);  //第一个大于等于pos[i]
		a2 = --x; a1 = --x;
		b1 = ++y ; b2 = ++y;
		res += 1ll*(*a2-*a1)*(*b1-pos[i])*i;
		res += 1ll*(pos[i]-*a2)*(*b2-*b1)*i;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;
ll getss(ll x)
{
        if(x==0) return 0;
        if(x==-1) return 0;
        ll ok = x%4;
        if(ok==0) return x;
        if(ok==1) return x ^ (x-1);
        if(ok == 2) return (x + 1);
        if(ok == 3) return 0;
}
int main()
{
        ll a,b;
        cin >> a >> b;
        ll ans = getss(b);
        ans ^= getss(a-1);
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main (){
  int N;
  cin >> N;
  vector<pair<int ,pair <int,int>>> elem(N);
  for(int i = 0;i < N; i++){
    int t,x,y;
    cin >> t >> x >> y;
    elem[i] = make_pair(t, make_pair(x,y));
  }
  bool flag = true;
  for(int i = 0;i < N;i++){
    int dist = 0;
    int t = 0;
    if(i == 0){
      dist = abs(elem[0].second.first + elem[0].second.second);
      t = elem[i].first;
    }else{
      dist = abs(elem[i].second.first - elem[i-1].second.first) + abs(elem[i].second.second - elem[i-1].second.second);
      t = elem[i].first - elem[i-1].first;
    }
    if(dist == t || (dist < t && (t - dist)%2 == 0)){
      continue;
    }else{
      flag = false;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

#define pb push_back
#define sc scanf
#define pf printf
#define ll long long
#define sz size()

int main()
{
    int n,i,b,w,t;
    string s;
    while(cin>>s)
    {
        n= s.size();
        int cnt=0;
        for(i=0; i<n/2; i++)
        {
            if(s[i]!=s[n-1-i]) cnt++;
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005

int main()
{
    fastread;
    int n;
    cin>>n;
    long long ans = 0;
    for(int i = 1; i <= n; i++) {
    	if(i % 3 !=0  && i % 5 != 0) {
    		ans += i;
    	}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll  		long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define MAXN   10000001
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}

void ISO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main() {

	ISO();
	//online_judge();

	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int s = 10e5 + 1;
	int mark[s];
	for(int i =0;i<s;++i)
	{
		mark[i] = 1;
	}
	sort(a, a + n);
	for (int i = 0; i < n; ++i)
	{
		if (mark[a[i]])
		{
			for (int j = 2; j <= (a[n-1]/a[i]); j++)
			{
				mark[j*a[i]] = 0;
			}
		}


	}
	for (int i = 1; i < n; ++i)
	{
		if (a[i - 1] == a[i])
		{
			mark[a[i]] = 0;
		}
		//cerr << a[i] << " " << mark[a[i]] << "\n";
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if (mark[a[i]] == 1)
		{
			ans++;
		}
	}
	cout << ans << "\n";

	//cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
	return 0;
}

Measured memory_bytes: 8280
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String res = "" ;

        if(a.equals("ABC")){
            res = "ARC";
        } else {
            res = "ABC";
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 35704