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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define VIN(x) for(auto&youso_: (x) )cin>>youso_
#define VOUT(x, delim) for(auto&youso_: (x) )cout<<youso_<<delim;cout<<endl

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) i64 __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    CIN(N, D);
    vector<i64> X(N), Y(N);
    i64 cnt = 0;
    REP(i, N) {
        CIN(x, y);
        if ((x * x + y * y) <= (D * D)) cnt++;
    }
    COUT(cnt);

    return 0;
}


Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main (){

ll n,a[100009],dp[100009];
cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
dp[n-2]=abs(a[n-1]-a[n-2]);
dp[n-1]=0;
for(int i=n-3;i>=0;i--)
dp[i]=min(abs(a[i+2]-a[i])+dp[i+2],abs(a[i+1]-a[i])+dp[i+1]);

cout<<dp[0]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {

  int attendance[30];

  int n;

  for(int i=0;i<30;i++) attendance[i]=0;

  for(int i=0;i<28;i++) {

    cin >> n;

    attendance[n-1]=1;

  }

  for(int i=0;i<30;i++) {

    if(attendance[i]==0) cout << i+1 << endl;

  }

  return 0;

}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	int[] ball;
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for (int i = 0; i < n; i++) {
			ball = new int[10];
			for (int j = 0; j < 10; j++) {
				ball[j] = scan.nextInt();
			}
			if (bfs(0, 0, 0))
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
	boolean bfs(int l, int r, int d) {
		if (d == 10) return true;
		if (l < ball[d]) {
			return bfs(ball[d], r, d+1);
		} else if (r < ball[d]) {
			return bfs(l, ball[d], d+1);
		} else {
			return false;
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26124
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  int r,D,x2000; cin >> r >> D >> x2000;
  vector<int> x(11); x[0]=x2000;
  
  for (int i=0; i<10; i++){
    x[i+1]=r*x[i]-D;
    cout << x[i+1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
mod = 10**9+7
s = int(input())
n = 700
if s < 3:
    print(0)
    exit()
DP = [1]*(s+1)
DP[0] = DP[1] = DP[2] = 0

ans = 0
for i in range(n):
    ans += DP[-1]
    ans %= mod
    cs = [0]
    for j in DP:
        cs.append((cs[-1]+j)%mod)
    for j in range(3, s+1):
        DP[j] = cs[j-2]
print(ans%mod)

Measured memory_bytes: 68188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int i;
  long max_vec;
  long sum_dai_height;
  
 
  cin >> a ;
  
  vector <int>vec(a);
  for(i=0;i<a;i++){
    cin >> vec.at(i);
    }
  max_vec = vec.at(0);
  sum_dai_height = 0;
  
  for(i=0;i<a;i++){
  if(vec.at(i)>max_vec){
    max_vec = vec.at(i);
  }
    else {
      sum_dai_height = sum_dai_height + max_vec - vec.at(i);
    }
  }

    
  
   

  
 
  cout << sum_dai_height <<endl;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  int m,n;
  cin >> n >> m;
  int cnt=0;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  double sum;
  sum=accumulate(a.begin(), a.end(),0);
//  cout << sum/(4*m) << " "<< 4*m << endl;
  rep(i,n){
    if(a[i] >= sum/(4*m)) cnt++;
  }
  if(cnt>=m) cout <<"Yes";
  else cout <<"No";
}

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

int i, j, k, l, m, n;
char s[5][55];
long long ans = 1;

int main() {
	scanf("%d", &n);
	scanf("%s%s", s[0], s[1]);
	if(s[0][0] == s[1][0]) {
		ans = 3;
		k = 1;
	} else {
		ans = 6;
		k = 2;
	}
	while(k < n) {
		if(s[0][k - 1] == s[1][k - 1]) {// B?
			ans = (ans * 2) % MOD;
			if(s[0][k] == s[1][k]) ++k;
			else k += 2;
		} else if(s[0][k] == s[1][k]) {// AB
			++k;
		} else {
			k += 2;
			ans = (ans * 3) % MOD;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()

for i in range(n):
    data[i] = data[i] - (i + 1)

ave = statistics.median(data)



ans = 0

for i in range(n):
    ans += abs(data[i] - ave)

print(int(ans))

Measured memory_bytes: 35160
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

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


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    n = int(input())
    #n, k = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    #s = input()
    if n < 3:
        print(0)
        continue
    a=[1,1,1]
    while len(a) <= n:
        a += [(a[-1]+a[-3])%(10**9+7)]
    print(a[-4])

Measured memory_bytes: 65080
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(){
        //入力を受け取る
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int x1,y1,x2,y2;
        x1 = input[0];
        y1 = input[1];
        x2 = input[2];
        y2 = input[3];
        /* (x3,y3)の導出
            (x3,y3) = (x2,y2) + (-(y2 - y1),x2 - x1)
        */
        int x3 = x2 - (y2 - y1);
        int y3 = y2 + (x2 - x1);
        /* (x4,y4)の導出
            (x4,y4) = (x1,y1) + (-(y2 - y1),x2 - x1)
        */
        int x4 = x1 - (y2 - y1);
        int y4 = y1 + (x2 - x1);
        //答えの出力
        Console.WriteLine("{0} {1} {2} {3}",x3,y3,x4,y4);
    }
}

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

long long n,q,a[100001],b[100001],c[100001],amount[100001],sum;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i = 1;i <= n;i++){
		cin>>a[i];
		amount[a[i]]++;
		sum = sum + a[i];
	}
	cin>>q;
	for(int i = 1;i <= q;i++){
		cin>>b[i]>>c[i];
		sum = sum + ((c[i] - b[i]) * amount[b[i]]);
		amount[c[i]] = amount[c[i]] + amount[b[i]];
		amount[b[i]] = 0;
		cout<<sum<<endl;
	}
}


Measured memory_bytes: 6772
#include <iostream>

using namespace std;

int main()
{
 string s;
 cin>>s;
  int cnt=0;
  for(int i=0; i<s.size(); i++)
  {
   if(s[i]=='+')
   cnt++;
    else
      cnt--;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

//ミョ(-ω- ?)
int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> graph(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        //0-indexed
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    //各頂点に対して0まで行けるかどうかを調べながらいくとよさげ
    vector<vector<int>> route(n);
    queue<int> st;
    st.push(0);
    while(!st.empty()){
        ll origin = st.front();
        st.pop();
        for(auto a : graph[origin]){
            if(route[a].empty())st.push(a);
            route[a].push_back(origin);
        }
    }
    vector<int> res(n);
    for(int i = 1;i<n;i++){
        if(route[i].empty()){
            cout << "No\n";
            return 0;
        }else {
            res[i] = route[i][0]+1;
        }
    }
    cout << "Yes\n";
    for(int i =1;i<n;i++)cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 16752
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(m)]

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1 for _ in range(n)]
 
    def same(self, x, y):
        return self.root(x)==self.root(y)
 
    def root(self, x):
        if self.par[x]<0:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]
 
    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
 
        if self.par[x] > self.par[y]:
            x,y = y,x
 
        self.par[x] += self.par[y]
        self.par[y] = x
 
    def size(self,x):
        return -self.par[self.root(x)]
    
uf = UnionFind(n)

C = []
tmp = n * (n - 1) // 2
for i in range(m - 1, -1, -1):
    C.append(tmp)
    a, b = AB[i]
    a -= 1
    b -= 1
    if uf.same(a, b):
        continue
    else:
        tmp -= uf.size(a) * uf.size(b)
        uf.unite(a, b)
    #print(C)
    
C.reverse()
for c in C:
    print(c)

Measured memory_bytes: 28412
from collections import Counter
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
def prime_factorize(n):
    N = n
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= N:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
prime = [0] * (10**6+5)
for i in range(N):
    c = Counter(prime_factorize(A[i]))
    for j in c.items():
        prime[j[0]] = max(j[1],prime[j[0]])
lcm = 1
for i in range(10**6+2):
    if prime[i] > 0:
        lcm *= pow(i,prime[i])
        lcm %= MOD

ans = 0
for i in range(N):
    ans += lcm * pow(A[i],MOD-2,MOD)
    ans %= MOD
print(ans)


Measured memory_bytes: 83860
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int x,y;
    int sum = 0;
	cin >> x >> y;
    vector<int> vec(y);
    for(int i =0; i<y;i++){
      cin >> vec.at(i);
      sum += vec.at(i);
    }
  
    if(x-sum>=0){
      cout << x-sum << "\n";
    }else{
      cout << -1 << "\n";
    }
  
}

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

signed main(){
	int N,M; cin>>N>>M;
	vector<vector<int>> V(N);
	vector<int> H(N);
	vector<pair<int,int>> hei(N);
	for(int i=0;i<N;i++){
		cin>>H[i];
		hei[i].first=H[i];
		hei[i].second=i;
	}
	for(int i=0;i<M;i++){
		int a,b; cin>>a>>b; a--; b--;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	int ans=0;
	for(int i=0;i<N;i++){
		int d=V[i].size();
		int now=H[i];
		int tmp=1;
		for(int j=0;j<d;j++){
			if(now<=H[V[i][j]]){
				tmp=0;
				break;
			}
		}
		ans+=tmp;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 11388
from collections import deque
import numpy as np

N = int(input())
graph = {i:[] for i in range(N)}
for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

# グラフのうち最も遠い2点の距離(木の直径)を求める
# 1. 適当な点からの最も遠い点uを求める
# 2. uから最も遠い点を求める
# 全探索×2

def bfs(graph,root):
    distance  = [0]*N
    visited = set()
    queue = deque([root])
    while queue:
        vertex = queue.popleft()
        for neighbour in graph[vertex]:
            if neighbour not in visited:
                distance[neighbour] = distance[vertex] + 1
                visited.add(neighbour)
                queue.append(neighbour)

    farthest_node = np.argmax(distance)
    farthest_dist = distance[farthest_node]
    return farthest_node, farthest_dist

u, _ = bfs(graph, root=0)
_, diamiter = bfs(graph, root=u)

if diamiter%3==1:
    ans = 'Second'
else:
    ans = 'First'
print(ans)

Measured memory_bytes: 88232
# coding:utf-8
n = int(input())
count = 0

for i in range(n):
    d1, d2 = map(int, input().split())

    if d1 == d2:
        count += 1
    else:
        count = 0

    if count == 3:
        print('Yes')
        exit()


print('No')


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define INF 1000000000000
typedef long long ll;

int main() {
	int n, ans = 0;
	cin >> n;
	n = n % 1000;
	if(n!=0)
		ans = 1000 - n;
	cout << ans;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)
template<class T>
class segtree {
private:
  ll n=1;
  T unit;
  std::vector<T> dat;
  std::function<T(T,T)> func;
public:
  segtree(){}
  segtree(std::vector<T>& a,T v,std::function<T(T,T)> f){
    build(a,v,f);
  }
  void build(std::vector<T>& a,T v,std::function<T(T,T)> f){
    ll sz=a.size();
    unit=v;
    func=f;
    while(n<sz)n<<=1LL;
    dat.resize(2*n-1,unit);
    for(int i=0;i<sz;++i)dat[i+n-1]=a[i];
    for(int i=n-2;i>=0;--i){
      dat[i]=func(dat[i*2+1],dat[i*2+2]);
    }
  }
  void update(ll idx,ll val){
    idx+=n-1;
    dat[idx]=val;
    while(idx){
      idx--;idx>>=1LL;
      dat[idx]=func(dat[idx*2+1],dat[idx*2+2]);
    }
  }
  T query(ll a,ll b,ll k=0,ll l=0,ll r=-1){
    if(r<0)r=n;
    if( b<=l || r<=a )return unit;
    if( a<=l && r<=b )return dat[k];
    else{
      auto left=query(a,b,2*k+1,l,(l+r)/2);
      auto right=query(a,b,2*k+2,(l+r)/2,r);
      return func(left,right);
    }
  }
};

main(){

  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];

  auto sum = [](auto a,auto b){return a+b;};
  segtree<ll> seg(a,0,sum);

  ll ans = (1LL<<60);
  for(ll i=1;i<n;++i){
    ll x,y;
    x = seg.query(0,i);
    y = seg.query(i,n);
    ll t = abs(x-y);
    ans = min(ans,t);
  }
  cout<<ans<<endl;

}

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

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (c >= a && c <= b)
               Console.WriteLine( "Yes");
            else
            Console.WriteLine("No");
            Console.ReadKey();
                
        }
    }
}

Measured memory_bytes: 13140
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):

    logical_max = [1]
    prev = 1
    for a in A:
        prev = (prev - a)*2
        logical_max.append(prev)
    for l in logical_max:
        if l < 0:
            print(-1)
            return

    logical_max = logical_max[:-1]


    nodes_at_depth = [0] * (N+1)
    d = N
    nodes = 0
    for lg_max, a in zip(logical_max[::-1], A[::-1]):

        nodes += a
        if nodes > lg_max:
            nodes = lg_max
            
        nodes_at_depth[d] = nodes
        d -= 1

    print(sum(nodes_at_depth))

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 0 + 1)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 689460
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N;
    cin >> N;
    vector<bitset<30>> a(N);
    ll A;
    vector<ll> bits(30);
    for(size_t i=0;i<N; i++)
    {
        cin >> A;
        a[i] = bitset<30>(A);
        for(ll b=29;b>=0; b--)
        {
            bits[b]+=a[i][b];
        }
    }
    ll count = 0;
    //while(pow(2, count) < pow(10, 9)) count++;
    //cerr << count << ":" << pow(2,count) << endl;
    //for(auto i:a) cerr << i << endl;
    //for(ll i=29;i>=0; i--)
    //{
    //    cerr << bits[i];
    //}
    //cerr << endl;
    for(size_t i=0;i<N; i++)
    {
        string bit = "000000000000000000000000000000";
        for(ll b=29;b>=0; b--)
        {
            if(bits[b] % 2 == 0)
            {
                if(a[i][b]) bit[29 - b] = '1';
            }
            else
            {
                if(!a[i][b]) bit[29 - b] = '1';
            }
        }
        //cerr << bit << endl;
        cout << bitset<30>(bit).to_ullong() << " ";
    }
    cout << endl;
    //std::bitset<8> bs("00000011");
    //std::bitset<8> bs2("00000101");
    //cout << (bs^bs2).to_ullong() << endl;
    // 1の数が偶数回(0)でるか奇数回(1)かで値が変わる
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#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 all(a) (a).begin(), (a).end()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 60;
constexpr double EPS = 1e-10;

struct edge {
  int t, c;
  edge() {}
  edge(int t, int c) : t(t), c(c) {}
};

int N, M;
int p[200010], q[200010], c[200010];
map<pii, int> mp;
int dis[500010];
vector<edge> g[500010];

void dijkstra(int s) {
  fill(dis, dis+500010, INF);
  dis[mp[pii(s, 0)]] = 0;
  priority_queue<pii, vector<pii>, greater<pii>> que;
  que.emplace(0, mp[pii(s, 0)]);
  while (!que.empty()) {
    int dd, cv;
    tie(dd, cv) = que.top(); que.pop();
    for (edge e : g[cv]) {
      int nv = e.t;
      if (dis[nv] > dis[cv] + e.c) {
        dis[nv] = dis[cv] + e.c;
        que.emplace(dis[nv], nv);
      }
    }
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;

  vector<pii> v;
  rep(i, 0, N) v.eb(i, 0);
  rep(i, 0, M) {
    cin >> p[i] >> q[i] >> c[i];
    p[i]--; q[i]--;
    v.eb(p[i], c[i]);
    v.eb(q[i], c[i]);
  }
  sort(all(v));
  v.erase(unique(all(v)), v.end());
  rep(i, 0, sz(v)) mp[v[i]] = i;

  int l = 0, r = 0;
  while (l < sz(v)) {
    while (r < sz(v) && v[r].first == v[l].first) {
      if (l != r) {
        int a = mp[v[l]];
        int b = mp[v[r]];
        g[a].eb(b, 1);
        g[b].eb(a, 1);
      }
      r++;
    }
    l = r;
  }
  rep(i, 0, M) {
    int a = mp[pii(p[i], c[i])];
    int b = mp[pii(q[i], c[i])];
    g[a].eb(b, 0);
    g[b].eb(a, 0);
  }
  dijkstra(0);
  int ans = dis[mp[pii(N-1, 0)]];
  cout << (ans == INF ? -1 : ans/2) << endl;

  return 0;
}

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

int main (){
  int N ;
  cin >> N ;
  vector<int> vec(N) ;
  for (int i = 0 ; i < N ; i++){
    cin >> vec.at(i) ;
  }

  int sum = 0 ;
  int add ;
  for (int j = 0 ; j < N ; j++) {
    for (int k = 0 ; k < N ; k++){
      if (k == j) continue ;
      add = vec.at(j) * vec.at(k) ;
      sum += add ;
    }
  }
  cout << sum / 2 << endl ;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
int x[MAX_N], y[MAX_N];

/////////////////////////////////////////////////////////
// node in { 0, ... }
class UnionFind {
 public:
  static const int MAX_N_LIB = (int)(2e5 + 100);

  int uf_par[MAX_N_LIB];
  int uf_rank[MAX_N_LIB];
  int uf_size[MAX_N_LIB];

  UnionFind(int n) { init(n); }

  void init(int n) {
    for (int i = 0; i < n; ++i) {
      uf_par[i] = i;
      uf_rank[i] = 0;
      uf_size[i] = 1;
    }
  }

  int find(int x) {
    if (uf_par[x] == x)
      return x;
    else {
      return uf_par[x] = find(uf_par[x]);
    }
  }

  void unite(int leaf_x, int leaf_y) {
    int x = find(leaf_x);
    int y = find(leaf_y);

    if (x == y) return;

    if (uf_rank[x] < uf_rank[y]) {
      uf_par[x] = y;
      uf_size[y] += uf_size[x];
    } else if (uf_rank[x] > uf_rank[y]) {
      uf_par[y] = x;
      uf_size[x] += uf_size[y];
    } else {
      uf_par[y] = x;
      uf_size[x] += uf_size[y];
      uf_rank[x] += 1;
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return uf_size[find(x)]; }
};
/////////////////////////////////////////////////////////

int main(void) {
  // Here your code !

  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &(x[i]), &(y[i]));
  }

  UnionFind uf(MAX_N * 2 + 20);

  for (int i = 0; i < n; ++i) {
    int node_x = x[i];
    int node_y = y[i] + MAX;

    uf.unite(node_x, node_y);
  }

  unordered_map<int, int> conn2edgenum;

  for (int i = 0; i < n; ++i) {
    int node_x = x[i];
    conn2edgenum[uf.find(node_x)] += 1;
  }

  unordered_set<int> xs;
  for (int i = 0; i < n; ++i) {
    int node_x = x[i];
    xs.insert(node_x);
  }

  unordered_map<int, ll> conn2xnodenum;
  for (auto &e : xs) {
    conn2xnodenum[uf.find(e)] += 1LL;
  }

  unordered_set<int> ys;
  for (int i = 0; i < n; ++i) {
    int node_y = y[i] + MAX;
    ys.insert(node_y);
  }

  unordered_map<int, ll> conn2ynodenum;
  for (auto &e : ys) {
    conn2ynodenum[uf.find(e)] += 1LL;
  }

  ll ans = 0LL;

  for (auto &e : conn2edgenum) {
    int key = e.first;

    ans += conn2xnodenum[key] * conn2ynodenum[key] - (ll)(conn2edgenum[key]);
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 10612
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

vector<string> vec;
int h,w;

bool dfs(int x, int y){
  if(x==h-1 && y==w-1) return true;
  if(vec[x][y]=='.') return false;
  // migi
  if(y+1<w && vec[x][y+1]=='#' && dfs(x, y+1)) return true;
  else if(x+1<h && vec[x+1][y]=='#' && dfs(x+1,y)) return true;
  return false;
}

int main(){
  cin>>h>>w;
  vec.resize(h);
  rep(i,h) cin>>vec[i];

  int cnt=0;
  rep(i,h) rep(j,w) if(vec[i][j]=='#') cnt++;

  if(cnt!=h+w-1 || !dfs(0,0)){
    cout<<"Impossible"<<endl;
  } else {
    cout<<"Possible"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void multi_table();

int main(){

	multi_table();
	
	return 0;	
}

void multi_table(){
	int i, j, a[9];

	for(i=0; i<9; ++i){
		a[i] = i+1;
	}

	for(i=0; i<9; ++i){
		for(j=0; j<9; ++j){
			printf("%dx%d=%d\n", a[i], a[j], a[i]*a[j]);
		}
	}
}

Measured memory_bytes: 524
word=str(input())
count=int(input())
for i in range(count):
	com=list(map(str,input().split()))
	if com[0]=='print':
		print(word[int(com[1]):int(com[2])+1])
	elif com[0]=='replace':
		word=word[:int(com[1])]+com[3]+word[int(com[2])+1:]
	elif com[0]=='reverse':
		word=word[:int(com[1])]+word[int(com[1]):int(com[2])+1][::-1]+word[int(com[2])+1:]
		

Measured memory_bytes: 6728
#include <iostream>
using namespace std;
int n;
int a[101];

int min(int a[101],int n){
  
	int min = 1000000000;
  
  	for(int i = 0; i < n;i++){
      
    	if(min > a[i]) min = a[i];
      
    }
  	
  	return(min);
  
}

int max(int a[101],int n){
  
	int  max = 0;
  
  	for(int i = 0; i < n;i++){
      
    	if(max < a[i]) max = a[i];
      
    }
  	
  	return(max);
  
}

int main(){
  
	cin >> n;
  
    for(int i = 0; i < n; i++) cin >> a[i];
  	
	cout <<max(a,n)-min(a,n)<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  ll X;
  cin>>X;
  for(int i = 0;i<1000;i++){
    for(int k = 0;k<1000;k++){
      if((i*i*i*i*i-k*k*k*k*k) == X){
        cout << i << " " << k << endl;
        return 0;
      }
    }
  }
  for(int i = 0;i<1000;i++){
    for(int k = 0;k<1000;k++){
      if((i*i*i*i*i+k*k*k*k*k) == X){
        cout << i << " " << -k << endl;
        return 0;
      }
    }
  }
  return -1;
}

Measured memory_bytes: 3604
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

Vec2<ll> graph;
Vec ans;

void bfs(ll node){
	queue<P> que;
	que.push({node, -1});
	while(!que.empty()){
		P p = que.front(); que.pop();
		if(ans[p.fs] != LINF) continue;
		ans[p.fs] = p.sc;
		for(auto i : graph[p.fs]) que.push({i, p.fs});
	}
}

int main(void){
	ll n, m;
	cin >> n >> m;
	graph.resize(n);
	ans.assign(n, LINF);
	rep(i, m){
		ll a, b;
		cin >> a >> b;
		a--, b--;
		graph[a].pb(b);
		graph[b].pb(a);
	}

	bfs(0);

	puts("Yes");
	rep(i, n){
		if(!i) continue;
		co(ans[i] + 1);
	}

	return 0;
}


Measured memory_bytes: 17056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt() - 1;
		int y = sc.nextInt() - 1;
		int[][] dist = new int[n][n];
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				dist[i][j] = Math.min(j - i, Math.abs(i - x) + Math.abs(j - y) + 1);
				dist[j][i] = Math.min(j - i, Math.abs(i - x) + Math.abs(j - y) + 1);
			}
		}
		int[] ans = new int[n];
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				ans[dist[i][j]]++;
			}
		}
		for(int i = 1; i < n; i++) {
			System.out.println(ans[i]);
		}
	}

}


Measured memory_bytes: 54740
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

ll solve()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll ans = 0;
    for1 (i,N) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<ll>());

    for1 (i,N) {
        if (A[i] == A[i+1]) {
            if (ans == 0) {
                ans = A[i];
                i += 1;
            } else {
                ans *=  A[i];
                return ans;
            }
        }
    }

    return 0;
}

int main()
{
    do {
        cout << solve() << endl;
    } while (DEBUG);
}


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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3548
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline ll read()
{
	ll out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
ll solve(ll n,ll a,ll b)
{
	if((b-a)%2==0)
		return (b-a)/2;
	return a+solve(n,1,b-a);
}
int main()
{
	ll n=read(),a=read(),b=read();
	cout<<min(solve(n,a,b),solve(n,n+1-b,n+1-a));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    ll x, y;
    cin >> x >> y;
    int ans=0;
    while(true){
        ans ++;
        y /=2;
        if(x>y){
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N;
  cin >> N;
  string S;
  cin >> S;
  vi RR(N, 0), GG(N, 0), BB(N, 0);
  int counter = 1;
  for(int i = 0; i < N; i++){
    if(S.at(i) == 'R') RR.at(i) = 1;
    else if(S.at(i) == 'G') GG.at(i) = 1;
    else BB.at(i) = 1;
  }
  vi Rsum(N+1, 0), Gsum(N+1, 0), Bsum(N+1, 0);
  for(int i = 0; i < N; i++){
    Rsum.at(i+1) = Rsum.at(i) + RR.at(i);
    Gsum.at(i+1) = Gsum.at(i) + GG.at(i);
    Bsum.at(i+1) = Bsum.at(i) + BB.at(i);
  }
  ll ans = 0;
  for(int i = 0; i < N-2; i++){
    for(int j = i+1; j < N-1; j++){
      if(S.at(i) == S.at(j)) continue;

      if(S.at(i) != 'R' && S.at(j) != 'R'){
        ans += Rsum.at(N) - Rsum.at(j+1);
        int k = j + (j-i);
        if(k < N){
          if(S.at(k) == 'R') ans--;
        }
      }
      else if(S.at(i) != 'G' && S.at(j) != 'G'){
        ans += Gsum.at(N) - Gsum.at(j+1);
        int k = j + (j-i);
        if(k < N){
          if(S.at(k) == 'G') ans--;
        }
      }
      else if(S.at(i) != 'B' && S.at(j) != 'B'){
        ans += Bsum.at(N) - Bsum.at(j+1);
        int k = j + (j-i);
        if(k < N){
          if(S.at(k) == 'B') ans--;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a,b,c,d,e,m=0,sum=0,i;
    cin >> a >> b;
    map<double,int>mp;
    for(i=1;i<=a;i++)
    {
        cin >> c >> d;
        sum=sqrt(c*c + d*d);
        if(sum <=b)
        {
            m++;
        }

    }
    cout << m << endl;
}


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

int main() {
  int N; cin >> N;
  vector<pair<int, int>> red(N);
  vector<pair<int, int>> blue(N);
  for (int i = 0; i < N; i++) cin >> red[i].second >> red[i].first;
  sort(red.begin(), red.end());
  reverse(red.begin(), red.end());
  for (int i = 0; i < N; i++) {
    int a = red[i].first;
    red[i].first = red[i].second;
    red[i].second = a;
  }
  for (int i = 0; i < N; i++) cin >> blue[i].first >> blue[i].second;
  sort(blue.begin(), blue.end());
  
  vector<bool> seen(N, false);
  
  int ans = 0;
  for (int i = 0; i < N; i++) { //blue
    for (int j = 0; j < N; j++) {
      if (red[j].first < blue[i].first && red[j].second < blue[i].second && !seen[j]) {
        seen[j] = true;
        ans++;
        break;
      }
    }
  }
  
  cout << ans << endl;        
}

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

int main() {
	string s, t;
	cin >> s >> t;
	int x = s.size(), y = t.size();
	int dp[x + 1][y + 1] = { 0 };
	int a = 0, b = 0;
	for (int i = 0; i <= x; i++) {
		dp[i][0] = a;
		a++;
	}
	for (int i = 0; i <= y; i++) {
		dp[0][i] = b;
		b++;
	}
	int c[3] = { 0 };
	for (int i = 1; i <= x; i++) {
		for (int j = 1; j <= y; j++) {
			c[0] = dp[i - 1][j] + 1;
			c[1] = dp[i][j - 1] + 1;
			if (s.at(i - 1) == t.at(j - 1)) {
				c[2] = dp[i - 1][j - 1];
			}
			else {
				c[2] = dp[i - 1][j - 1] + 1;
			}
			sort(c, c + 3);
			dp[i][j] = c[0];
		}
	}
	cout << dp[x][y] << endl;
}


Measured memory_bytes: 7112
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題160

            string[] line = Console.ReadLine().Split(' ');

            int n = int.Parse(line[0]);
            int m = int.Parse(line[1]);

            int ans = n * (n - 1) / 2 + m * (m - 1) / 2;

            Console.WriteLine(ans);

        }

    }





    
}


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

using namespace std;

typedef long long int ll;

vector <ll> primes;

void ESieve(ll n)
{
    vector <bool> sieve(n+1, true);

    sieve[0] = sieve[1] = false;

    for (ll i = 2; i <= n; i++)
    {
        if (!sieve[i])
            continue;

        primes.push_back(i);

        for (ll j = i*i; j <= n; j += i)
            sieve[j] = false;
    }
}

vector <pair<ll, int>> find_divisors(ll n)
{
    vector <pair<ll, int>> divisors;

    for (int p: primes)
    {
        int exp = 0;
        while (n % p == 0)
        {
            n = n / p;
            exp++;
        }

        if (exp)
            divisors.push_back(make_pair(p, exp));
    }

    if (n > 1)
        divisors.push_back(make_pair(n, 1));

    return divisors;
}

int main()
{
    ESieve(1000000);

    ll n, p;

    cin >> n >> p;

    vector <pair<ll, int>> divisors = find_divisors(p);

    ll ans = 1;

    for (auto d: divisors)
    {
        ll m = d.second / n;

        for (ll i = 1; i <= m; i++)
            ans = ans * d.first;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1528
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;
 
string YA(string ans);
string YJ(string ans);
string YC(string ans);
string YE(string ans);
string YP(string ans);
string YM(string ans);


int main(){

	int n;
	string R;
	string ans;

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

	cin>>R;
	cin>>ans;

	for(int i=R.size()-1;i>=0;i--){
		if(R[i]=='A')ans=YA(ans);
		if(R[i]=='J')ans=YJ(ans);
		if(R[i]=='C')ans=YC(ans);
		if(R[i]=='E')ans=YE(ans);
		if(R[i]=='P')ans=YP(ans);
		if(R[i]=='M')ans=YM(ans);
	}

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

string YA(string ans){
	string t=ans;
	int x=ans.size()-1;
	for(int i=0;i<ans.size();i++)
		ans[i]=t[x-i];

	return ans;
}
string YC(string ans){
	string t=ans;
	int x=ans.size()-1;
	for(int i=0;i<ans.size()-1;i++)
		ans[i]=t[i+1];
	ans[x]=t[0];
	return ans;
}
string YJ(string ans){
	string t=ans;
	int x=ans.size()-1;
	for(int i=0;i<ans.size()-1;i++)
		ans[i+1]=t[i];
	ans[0]=t[x];
	return ans;
}
string YM(string ans){
	for(int i=0;i<ans.size();i++){
		if(ans[i]>='0'&&ans[i]<'9'){
			ans[i]+=1;
		}
		else if(ans[i]=='9')ans[i]='0';
	}
	return ans;
}
string YP(string ans){
	for(int i=0;i<ans.size();i++){
		if(ans[i]>'0'&&ans[i]<='9'){
			ans[i]-=1;
		}
		else if(ans[i]=='0')ans[i]='9';
	}
	return ans;
}
string YE(string ans){
	string t=ans;
	int x=(ans.size())/2;
	int N=x;
	if(ans.size()%2==1)N++;
	for(int i=0;i<x;i++)
		ans[i]=t[N+i];
	
	for(int i=N;i<ans.size();i++) 
	ans[i]=t[i-N];
	//ans=Q+t;
	return ans;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


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

  V v;
  v.push_back(1);
  int c = a[0];
  rep2(i, 1, n) {
    if (c == a[i]) ++v.back();
    else {
      v.push_back(1);
      c = a[i];
    }
  }

  int ans = 0;
  for (auto e : v) ans += e/2;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3560
#include <stdio.h>

int main(){

  int f[44],n,i;
  
  scanf("%d",&n);

  f[0]=f[1]=1;
  
  for(i=2;i<=n;i++){
    f[i]=f[i-2]+f[i-1];
  }

  printf("%d\n",f[n]);

  return 0;
}



Measured memory_bytes: 2112
using System;

public class Program
{
	public static void Main()
	{
		string T = Console.ReadLine();
		string P = Console.ReadLine();
		for (int i = 0; i < T.Length - P.Length + 1; i++)
		{
			if (T.Substring(i, T.Length - i).StartsWith(P))
			{
				Console.WriteLine(i);
			}
		}
	}
}

Measured memory_bytes: 10124
"use strict";
    
function lowerBound(arr, n) {
    var first = 0, last = arr.length - 1, middle;
    while (first <= last) {
        middle = 0 | (first + last) / 2;
        if (arr[middle] < n) first = middle + 1;
        else last = middle - 1;
    }
    return first;
}

function upperBound(arr, n) {
    var first = 0, last = arr.length - 1, middle;
    while (first <= last) {
        middle = 0 | (first + last) / 2;
        if (arr[middle] <= n) first = middle + 1;
        else last = middle - 1;
    }
    return first;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    const B = arg[2].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    const C = arg[3].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    
    let answer = 0;
    
    for(let i=0; i<N; i++) {
        let top = lowerBound(A, B[i]);
        let bottom = upperBound(C, B[i]);
        
        answer += top * (N - bottom)
        
        // console.log("top:" + top);
        // console.log("bottom:" + bottom);
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    string s; cin >> s;
    ll k = 0;
    ll o = 0;
    for(ll i = 0; i < s.length(); i++){
        if(s[i] == 'A'){
            k = i;
            break;
        }
    }

    for(ll i = s.length()-1; i >= 0; i--){
        if(s[i] == 'Z'){
            o = i;
            break;
        }
    }

    cout << o - k + 1 << endl;

}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int N = 2010;
ll a[N];
ll tbl[N][N];

int main(void){
  int n;
  ll x;
  cin >> n >> x;
  REP(i, 0, n) {
    cin >> a[i];
    REP(j, 0, n) {
      tbl[i][j] = a[i];
    }
  }
  REP(i, 1, n) {
    REP(j, 0, n) {
      tbl[j][i] = min(tbl[j][i], tbl[(j + 1) % n][i - 1]);
    }
  }
  ll mi = 1e16;
  REP(i, 0, n) {
    ll sum = x * i;
    REP(j, 0, n) {
      sum += tbl[j][i];
    }
    mi = min(mi, sum);
  }
  cout << mi << endl;
}


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

int main(){
  int n; cin>>n;
  long long mod=1000000007;
  long long a=1,b=1,c=1;
  for (int i=0; i<n; i++){
    a*=10;
    b*=9;
    c*=8;
    a%=mod;
    b%=mod;
    c%=mod;
  }
  long long ans=(a-b-b+c)%mod;
  ans=(ans+mod)%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
	int angka[5];
	int a = 0;
	int b = 0;
	scanf("%d %d %d",&angka[0],&angka[1],&angka[2]);fflush(stdin);
	int out = angka[0];
	if(out > angka[1]){
		out = angka[1];
		a = 1;
	}
	if(out > angka[2]){
		out = angka[2];
		a = 2;
	}
	
	if(a == 0){
		out = angka[1];
		b = 1;
	}else
		out = angka[0];
	for(int i = 0; i < 3; i++){
		if(out > angka[i] && i != a){
			out = angka[i];
			b = i;
		}
	}
	printf("%d",angka[a]+angka[b]);	
	return 0;
}

Measured memory_bytes: 128