akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    int a = Integer.parseInt(r.readLine());
    int b = Integer.parseInt(r.readLine());
    int c = Integer.parseInt(r.readLine());
    int d = Integer.parseInt(r.readLine());

    System.out.println(Math.min(a, b) + Math.min(c, d));
  }

}


Measured memory_bytes: 23124
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
H = [int(x) for x in input().split()]

dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
  dp[i] = min(dp[i - k] + abs(H[i] - H[i - k]) for k in [1, 2])

ans = dp[-1]
print(ans)

Measured memory_bytes: 13884
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, A, B = list(map(int, sys.stdin.buffer.readline().split()))

a = abs(A - B)
if a  % 2== 1:
    print('Borys')
else:
    print('Alice')


Measured memory_bytes: 22820
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        int p;
        cin>>p;
        a[i]=p;
    }
    int cnt=1;
    
    for(int i=2;i<=n;i++){
    if(a[i]<=a[i-1]){
        cnt++;
    }
    }
    
    cout<<cnt<<endl;
    cout<<n<<endl;
    
}


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

int main()
{
    int x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3592
/*
	Author: Dinesh Verra
	College: ABV-IIITM
	Date: 20/06/2020
*/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cu continue
#define br break
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first
#define S second
#define vll vector <ll>
#define vpll vector <pll>
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define all(v) v.begin(),v.end()
#define nl cout<<'\n'

template <typename A1>
void prn(A1&& arg)
{
	cout<<arg<<'\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args)
{
	cout<<arg<<' ';
	prn(args...);
}

#define N 100005

ll f[N];

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

	ll n;
	cin>>n;
	ll x[n],s=0,a[n];
	for(ll i=0;i<n;i++)
		cin>>x[i];
	for(ll i=0;i<n-1;i++) s^=x[i];
	a[n-1]=s;
	for(ll i=n-2;i>=0;i--)
	{
		a[i]=a[i+1]^(x[i]^x[i+1]);
	}
	for(ll i=0;i<n;i++) cout<<a[i]<<' ';
	nl;

}



Measured memory_bytes: 6692
def main():
    N = int(input())
    S = []
    for i in range(N):
        s = input()
        s = sorted(s)
        s = ''.join(s)
        S.append(s)
    S.sort()
    SS = sorted(list(set(S)))
    SN = []
    M = len(SS)
    l = 0
    r = len(S)
    for i in range(M):
        for j in range(l, r):
            if S[j] != SS[i]:
                r = j
                break
        SN.append(r - l)
        l = r
        r = len(S)        

    res = 0
    for sn in SN:
        res += sn * (sn - 1) // 2

    print(res)
if __name__ == "__main__":
    main()

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

int N;
vector<long long> a;

int main(){
    cin>>N;
    a.resize(N);
    for (int i=0;i<N;i++)cin>>a[i];
    long long res=0;
    for(int i=0;i<N;i++){
        int tmp=0;
        while(a[i]%2==0){
            ++tmp;
            a[i]/=2;
        }
        res+=tmp;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n;
	cin >> n;
	str s;
	cin >> s;
	int e, w;
	e = w = 0;
	rep(i, n)
	{
		e += (s[i] == 'E');
	}
	int ans = INT_MAX;
	rep(i, n)
	{
		e -= (s[i] == 'E');
		ans = min(e + w, ans);
		w += (s[i] == 'W');
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3892
#include <iostream>

int main() {
  uint32_t A = 0, B = 0, C = 0, X = 0, Y = 0;
  std::cin >> A >> B >> C >> X >> Y;

  uint32_t min_vol = (C * 2 <= A + B) * ((X <= Y) ? X : Y);
  uint32_t price = (X - min_vol) * (C * 2 <= A ? C * 2 : A) +
                   (Y - min_vol) * (C * 2 <= B ? C * 2 : B) + min_vol * C * 2;

  std::cout << price << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, p;
    std::cin >> n >> p;

    std::map<i64, i64> e;
    while (p % 2 == 0) {
        p /= 2;
        e[2]++;
    }

    for (i64 i = 3, q = p; i * i <= q; i += 2) {
        if (p % i) continue;
        while (p % i == 0) {
            p /= i;
            e[i]++;
        }
        if (p == 1) break;
    }

    if (p > 1) e[p]++;

    i64 ret = 1;
    for (auto& el : e) {
        el.second /= n;
        for (int i = 0; i < el.second; i++) ret *= el.first;
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const int INF{int(1e9)};

int main()
{
  int N, T;
  cin >> N >> T;
  
  int c, t;
  int ans{INF};
  rep(i, N) {
      cin >> c >> t;
    if (t<= T && c < ans) {
      ans = c;
    }
  }
 if (ans == INF) {
   cout << "TLE" << endl;
 }
  else cout << ans << endl;
}

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

int main() {
  string line;
  int a[3][3];
  int winner;
  cin >> line;
  while (1) {
    if (line == "0") {
      break;
    }
    for (int i=0; i<3; i++) {
      for (int j=0; j<3; j++) {
        char c = line[j];
        if (c == 'b') {
          a[i][j] = 1;
        } else if (c == 'w') {
          a[i][j] = -1;
        } else {
          a[i][j] = 0;
        }
      }
      cin >> line;
    }
    winner= 0;
    for (int i=0; i<3; i++) {
      if (a[i][0] && a[i][0] == a[i][1] && a[i][1] == a[i][2]) {
        winner = a[i][0];
      }
    }
    for (int j=0; j<3; j++) {
      if (a[0][j] && a[0][j] == a[1][j] && a[1][j] == a[2][j]) {
        winner = a[0][j];
      }
    }
    if (a[0][0] && a[0][0] == a[1][1] && a[1][1] == a[2][2]) {
      winner = a[0][0];
    }
    if (a[0][2] && a[0][2] == a[1][1] && a[1][1] == a[2][0]) {
      winner = a[0][2];
    }
    if (winner == 1) {
      cout << "b" << endl;
    } else if (winner == -1) {
      cout << "w" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1176
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    r: isize,
    d: isize,
    x: isize
    }
    let mut ans = x;
    for _ in 0..10 {
        let nx = r * ans - d;
        println!("{}", nx);
        ans = nx;
    }
}


Measured memory_bytes: 2140
package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)

	for a := 0; a <= N; a++ {
		for b := 0; b <= (N - a); b++ {
			c := N - (a + b)
			sum := a*10000 + b*5000 + c*1000
			if sum == Y {
				fmt.Println(a, b, c)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 1772
my @c1 = ('R', 'U', 'D');
my @c2 = ('L', 'U', 'D');
my $i = 0;
foreach my $w (split(//o, <STDIN>)) {
  chomp($w);
  if ( $w ne '' ) {
    $i++;
    if ( $i%2 ) {
      if ( ! grep { $_ eq $w } @c1 ) {
        print "No";
        exit 0;
      }
    } else {
      if ( ! grep { $_ eq $w } @c2 ) {
        print "No";
        exit 0;
      }
    }
  }
}
print "Yes";

Measured memory_bytes: 512
#include <iostream>

using namespace std;

const int INF = 1000000;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    int a = -INF, b = INF;
    for (int i = 0; i < m; ++i)
    {
        int l, r;
        cin >> l >> r;
        a = max(a, l);
        b = min(b, r);
    }
    if (a <= b)
        cout << b - a + 1;
    else
        cout << "0";
    return 0;
}


Measured memory_bytes: 384
// B - Shift only

#include <bits/stdc++.h>
using namespace std;

int N;

int main() {
  // ここにプログラムを追記
  int a, b;
  int num = 0;

  cin >> N;
  for(int i =0; i<N; i++){
    cin >> a >> b;
    num += b-a+1;
  }
  cout << num <<endl;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n,m;
	cin >> n >> m;
	
	map<int,int>f;
	int ans = 0;
	f(i,0,n)
	{
		int s;
		cin >> s;
		int a;
		f(j,0,s)
		{
			cin >> a;
			f[a]++;
			if(f[a] ==n)
				ans++;
		}
	}
	cout << ans;
}



Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line, int.Parse);
            Array.Sort(a);
            var diff = 10000000;
            for (int i = 1; i < n; i++)
                diff = Math.Min(diff, a[i] - a[i - 1]);
            Console.WriteLine(diff);
        }
    }
}

Measured memory_bytes: 9632
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;

int power(int b, int n){
  if(n <= 0) return 1;
  return power(b, n - 1) * b;
}

int main() {
  int N, L;
  while(cin >>N >>L && N){
    vector<int> l(L + 1, 0), r(L + 1, 0);
    REP(i, N){
      char d; int p; cin >>d >>p;
      if(d == 'R') r[p] = i + 1;
      else l[p] = i + 1;
    }
    int t = -1, cnt = 0, last = -1;
    while(cnt < N){
      if(r[L] != 0) { last = r[L]; r[L] = 0; ++cnt; }
      if(l[0] != 0) { last = l[0]; l[0] = 0; ++cnt; }
      vector<int> nl(L + 1, 0), nr(L + 1, 0);
      FOR(i, 1, L){
        int nra = r[i - 1], nla = l[i + 1];
        if(nra != 0 && nla != 0) { nl[i] = nra; nr[i] = nla; }
        else { nl[i] = nla; nr[i] = nra; }
      }
      nl[0] = l[1]; nr[L] = r[L - 1];
      l = nl; r = nr;
      ++t;
    }
    cout <<t <<" " <<last <<endl;
  }
  return 0;
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    string s;
    cin>>s;
    
    if(s<="2019/04/30")cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a;*/


	int h, n;
	cin >> h >> n;
	int s = 0;
	int a;
	rep(i, n) {
		cin >> a;
		s += a;
	}
	if (s >= h)puts("Yes");
	else puts("No");



	return 0;
}

Measured memory_bytes: 256
s = [ord(i) for i in input()]
k = int(input())
for i in range(len(s)):
    if s[i] == 97: continue
    if 123 - s[i] <= k:
        k -= 123 - s[i]
        s[i] = 97
        if k == 0:
            break
if k != 0:
    s[-1] = s[-1] + k % 26
print("".join([chr(i) for i in s]))

Measured memory_bytes: 4796
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

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; }
const int INF = 1LL << 60;

signed main() {
	int n, W;
	cin >> n >> W;
	vector<int> w(n), v(n);
	for(int i = 0; i < n; i++) cin >> w[i] >> v[i];

	vector<vector<int>> dp(n + 1, vector<int>(W + 1, 0));
	for(int i = 1; i < n + 1; i++) {
		for(int j = 0; j < W + 1; j++) chmax(dp[i][j], dp[i - 1][j]);
		for(int j = 0; j < W + 1; j++) {
			if(j + w[i - 1] <= W) chmax(dp[i][j + w[i - 1]], dp[i - 1][j] + v[i - 1]);
		}
	}

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


Measured memory_bytes: 80256
#include<stdio.h>
#include<string.h>

#define M 1000001
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
    if ( ch == 'A') return 1;
    else if ( ch == 'C') return 2;
    else if ( ch == 'G') return 3;
    else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for ( i = 0; i < strlen(str); i++ ){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return (key % (M-1)) + 1; }

int find(char str[]){
    long long s = getKey(str);
    int h_1 = h1(s);
    int h_2 = h2(s);
    int k, i = 0;

    while(i < M){
        k = (h_1 + i * h_2) % M;
        if(H[k][0] == '\0') return 0;
        else if(strcmp(H[k], str) == 0) {
            return 1;
            break;
        }
        i++;
    }
    return 0;
}

int insert(char str[]){
    long long s = getKey(str);
    int h_1 = h1(s);
    int h_2 = h2(s);
    int k, i = 0;

    while(i < M){
        k = (h_1 + i * h_2) % M;
        if(H[k][0] == '\0'){
            strcpy(H[k], str);
            break;
        }
        i++;
    }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
        scanf("%s %s", com, str);

        if ( com[0] == 'i' ){
            insert(str);
        } else {
            if (find(str)){
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 14280
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


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

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(j < a && i < h-b){
                cout << 1;
            }
            else if(j >= a && i >= h-b){
                cout << 1;
            }
            else{
                cout << 0;
            }
        }
        cout << endl;
    }




    return 0;
}


Measured memory_bytes: 1280
n,p=map(int,input().split())
s=input()[::-1]
A=[0]*n
A[0]=int(s[0])%p
t=10
for i in range(1,n):
  A[i]=(int(s[i])*t+A[i-1])%p
  t=(t*10)%p
ans=0
import collections
D=collections.defaultdict(int)
D[0]=1
if p!=2 and p!=5:
  for i in range(n):
    ans+=D[A[i]]
    D[A[i]]+=1
  print(ans)
else:
  s=s[::-1]
  ans=0
  for i in range(n):
    if int(s[i])%p==0:
      ans+=i+1
  print(ans)





Measured memory_bytes: 12044
#include<bits/stdc++.h>
#include<cmath>
#define PB push_back
#define REP(i,a,b) for(int i=a; i<b; i++)
typedef long long ll;
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,d,ans=0;
	cin>>n>>d;
	d=d*d;
	for(int i=0; i<n; i++){
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d) ans++;
	}
	cout<<ans;
}








Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC147D();

#if 1
int main()
{
	ABC147D();
	fflush(stdout);
	return 0;
}
#endif

static void ABC147D()
{
	int N;
	getint(N);

	std::vector<LLONG> an(N, 0);
	for (int i = 0; i < N; i++) {
		getint(an[i]);
	}

	LLONG ans = 0;
	LLONG bit = 1, two_factor = 1;
	for (int shift = 0; shift < 60; shift++) {
		bit = 1LL << shift;
		LLONG one = 0, zero = 0;
		for (int i = 0; i < N; i++) {
			if (an[i] & bit) {
				one++;
			}
			else {
				zero++;
			}
		}
		ans = (ans + ((one * zero % MOD_NUM) * two_factor) % MOD_NUM) % MOD_NUM;
		two_factor = (two_factor * 2LL) % MOD_NUM;
	}
	printf("%lld\n", ans);
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  rep(i, W+2) {
    cout << '#';
  }
  cout << endl;
  
  rep(i, H) {
    string S;
    cin >> S;
    cout << "#" << S << "#" << endl;
  }
  
  rep(i, W+2) {
    cout << '#';
  }
}


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

#define rep(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define vec(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)

int main()
{
    //------------,----
    int n;
    cin >> n;
    vec(int, n, p, 0);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end(), greater<int>());
    cout << accumulate(p.begin(), p.end(), 0) - p[0] / 2 << endl;
    //----------------
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll ans = INF;
    for(ll x = -100; x <= 100; x++) {
        ll now = 0;
        rep(i, n) {
            now += (a[i] - x)*(a[i] - x);
        }
        chmin(ans, now);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A), q(B), r(C);
  for (ll i = 0; i < A; i++) cin >> p[i];
  for (ll i = 0; i < B; i++) cin >> q[i];
  for (ll i = 0; i < C; i++) cin >> r[i];
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend());
  p.erase(p.begin() + X, p.end());
  q.erase(q.begin() + Y, q.end());
  p.insert(p.end(), q.begin(), q.end());
  p.insert(p.end(), r.begin(), r.end());
  sort(p.rbegin(), p.rend());
  ll sum = 0;
  for (ll i = 0; i < X + Y; i++) sum += p[i];
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 8464
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif
    string s;
    while (cin >> s) {
        cout << (s == "AAA" || s == "BBB"? "No" : "Yes") << endl;
    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
// typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


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


  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = []
r = []

for i in range(n):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)
    
ans = 0
for i in range(n):
    ans +=r[i] - l[i] + 1
    
print(ans)

Measured memory_bytes: 3060
H, W = map(int, input().split())
A = [[1] * (W + 2)]
for _ in range(H):
    tmp = list(input())
    tmp = [1] + [0 if t == '.' else 1 for t in tmp] + [1]
    A.append(tmp)
A += [[1] * (W + 2)]

MOD = 10**9 + 7

dp = [[0] * (W + 2) for _ in range(H + 2)]
dp[H][W] = 1
# dp[H][W]
# dp[i][j] : (i, j)マスから(H, W)マスへいくのに通れる経路の数
# dp[i][j] : dp[i + 1][j] + dp[i][j + 1] ?
for i in range(H + 1, 0, -1):
    for j in range(W + 1, 0, -1):
        if A[i][j] == 0:
            dp[i][j] = (dp[i][j] + dp[i + 1][j] + dp[i][j + 1]) % MOD
ans = dp[1][1]
print(ans)


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

using namespace std;
using ll = long long;
int main() {
    int n;
    ll k;
    cin >> n >> k;
    int arr[n+1];
    int i;
    for(i=1;i<=n;i++)
        cin >> arr[i];
    int vis[n+1] = {0};
    int j = 1;
    vector<int> cycle;
    int par[n+1];
    par[1] = 1;
    while(!vis[j])
    {
        vis[j] = 1;
        cycle.push_back(j);
        par[arr[j]] = j;
        j = arr[j];
    }
    int tp = cycle.back();
    vector<int> ncyc;
    int sz = 1;
    while(j != tp)
    {
        ncyc.push_back(tp);
        tp = par[tp];
        sz++;
    }
    ncyc.push_back(j);
    reverse(ncyc.begin(), ncyc.end());
    int val = cycle.size() - sz;
    if(k >= val)
    {
        k = k - val;
        k=k%sz;
        cout << ncyc[k];
    }
    else
    {
        cout << cycle[k];
    }
}

Measured memory_bytes: 7880
def main():
    a_list = list(map(int, input().split()))
    a_list.sort()

    if a_list[0] == a_list[1] or a_list[1] == a_list[2]:
        if a_list[0] == a_list[2]:
            ans = 'No'
        else:
            ans = 'Yes'
    else:
        ans = 'No'
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll h,w,k;
  cin>>h>>w>>k;
  vector<string> vs;
  rep(i,0,h){
    string s;
    cin>>s;
    vs.pb(s);
  }
  ll ans = 0;
  rep(i,0,1<<h){
    rep(j,0,1<<w){
      ll c = 0;
      rep(y,0,h){
        rep(x,0,w){
          if(((i>>y)&1)==1)continue;
          if(((j>>x)&1)==1)continue;
          if(vs[y][x]=='#')c++;
        }
      }
      if(c==k)ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

ll a[101];
ll F(ll x,int n){
    ll cur=0;
    forn(i,0,n)
    cur+=(x-a[i])*(x-a[i]);
    
    return cur;
}

void solve(){
  int test;
  //cin>>test;
  test=1;
     
  while(test--){
        ll n;
        int a,b;
        cin>>n>>a>>b;
        
        if(n==2){
            cout<<0;
            return;
        }
        ll ans=power(2ll,n);
        ans=(ans-1+hell)%hell;
        
        ll val1=1,val2=1;
        
        for(int i=0;i<a;i++){
            val1=(val1%hell*(n-i)%hell)%hell;
            val1=(val1%hell*modinv(i+1)%hell)%hell;    
        }
        for(int i=0;i<b;i++){
            val2=(val2%hell*(n-i)%hell)%hell;
            val2=(val2%hell*modinv(i+1)%hell)%hell;    
        }
        ans=(ans-val1-val2+hell+hell)%hell;
        cout<<ans;
    }         
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

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


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,s,e;
    scanf("%lld%lld%lld",&n,&s,&e);
    printf("%lld\n",max(1LL*0,((n-1)*e+s)-((n-1)*s+e-1)));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int n,pos;
vector<int> pre,in,post;
void solve(int l,int r){
  if(l>=r)return ;
  int root=pre[pos++];
  int m=distance(in.begin(),find(in.begin(),in.end(),root));
 
  solve(l,m);
  solve(m+1,r);
  post.push_back(root);
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){int u;cin >> u;pre.push_back(u);};
  for(int i=0;i<n;i++){int u;cin >> u;in.push_back(u);}
  
  solve(0,pre.size());
  for(int i=0;i<n;i++){
    if(i)cout << " ";
    cout << post[i];
  }
  cout << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> C(26);
    for (auto &i : C) cin >> i;

    vector<vector<int>> S(D, vector<int>(26));
    for (auto &i : S) for (auto &j : i) cin >> j;

    vector<int> last(26);

    rep(d, D) {
        int max_score = -INF, max_type = 0;
        rep(i, 26) {
            int res = S[d][i];
            int old_last = last[i];
            last[i] = d+1;
            rep(j, 26) res -= C[j] * ((d+1) - last[j]);
            if (chmax(max_score, res)) max_type = i;
            last[i] = old_last;
        }
        last[max_type] = d+1;
        cout << max_type+1 << endl;
    }
}

Measured memory_bytes: 3676
#include<bits/stdc++.h> 
using namespace std; 
int main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL); 
  long long n,d;
  cin>>n>>d;
  int f=0;
  for(long long int i=0;i<n;i++){
    long long l,r;
    cin>>l>>r;
    if(l*l+r*r<=d*d){
      f++;
    }
  }
  cout<<f<<"\n";
  

} 

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

int main() {
  vector<int> A(5);
  rep(i, 5) {
    cin >> A[i];
  }
  rep(i, 5) {
    if (A[i] != i+1) cout << i+1 << endl;
  }

}

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



int main() {
    int a, b, t;
    cin >> a >> b >> t;
    
    cout << t / a * b << endl;
    
    
    return 0;
}


Measured memory_bytes: 3636
N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)

m = sum(V[:A])/A

cnts = []
cnt = 0
res = None
for i in range(N):
    if res is None or V[i] != res:
        if res is not None:
            cnts.append(cnt)
        cnt = 1
        res = V[i]
    else:
        cnt += 1
cnts.append(cnt)
fac = [1, 1]
for i in range(2, 51):
    fac.append(i*fac[-1])

if cnts[0] >= A:
    ans = 0
    for i in range(A, min(B, cnts[0])+1):
        ans += fac[cnts[0]]//fac[i]//fac[cnts[0]-i]
else:
    ans = 1
    for cnt in cnts:
        if cnt <= A:
            A -= cnt
            B -= cnt
        else:
            ans *= fac[cnt]//fac[A]//fac[cnt-A]
print(m)
print(ans)


Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
using namespace std;
long long n,d,a[200005];
typedef pair <int,int> P;
typedef pair <long long,P> PP; 
struct UF
{
	int par[200005],rank[200005];
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=0;
		}
	}
	int find(int x)
	{
		if(par[x]==x)
		    return x;
		return par[x]=find(par[x]);
	}	
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y)
			return;
		if(rank[x]<rank[y])
			par[x]=y;
		else
		{
			par[y]=x;
			if(rank[x]==rank[y])
				rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}	
}uf;
vector <PP> edge;
void solve(int l,int r)
{
	if(l==r)
	    return;
	//cout<<l<<' '<<r<<endl;
	int m=(l+r)/2;
	long long mn=2e18;
    int pl=-1;
    for(int i=l;i<=m;i++)
    {
    	long long vl=a[i]-d*(long long)i;
    	if(mn>vl)
    	{
    		mn=vl;
    		pl=i;
		}
	}
	mn=2e18;
	int pr=-1;
	for(int i=m+1;i<=r;i++)
	{
		long long vl=a[i]+d*(long long)i;
		if(mn>vl)
		{
			mn=vl;
			pr=i;
		}
	}
	for(int i=l;i<=m;i++)
	{
		long long vl=a[i]-d*(long long)i;
		long long vr=a[pr]+d*(long long)pr;
		edge.push_back(PP(vl+vr,P(i,pr)));
	}
	for(int i=m+1;i<=r;i++)
	{
		long long vl=a[pl]-d*(long long)pl;
		long long vr=a[i]+d*(long long)i;
		edge.push_back(PP(vl+vr,P(pl,i)));
	}
	solve(l,m);
	solve(m+1,r);
}
int main()
{
	scanf("%lld%lld",&n,&d);
	for(int i=0;i<n;i++)
	    scanf("%lld",&a[i]);
	solve(0,n-1);
	sort(edge.begin(),edge.end());
	uf.init(n+2);
	long long ret=0;
	for(int i=0;i<edge.size();i++)
	{
		P p=edge[i].second;
		//cout<<p.first<<' '<<p.second<<endl;
		if(!uf.same(p.first,p.second))
		{
			//cout<<p.first<<' '<<p.second<<endl;
			uf.unite(p.first,p.second);
			ret+=edge[i].first;
		}
	}
	cout<<ret;
	return 0;
}

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

using namespace std;

long int dp[1000][123456];
long int A[1000][2];
int main(){
  int n,w;
  
  scanf("%d %d",&n,&w);
  
  for(int i=0;i<n;i++) scanf("%ld %ld",&A[i][0],&A[i][1]);
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<=w;j++){
    	if(i==0||j==0) dp[i][j]=0;
      	else if(j<A[i-1][0]) dp[i][j]=dp[i-1][j];
      	else{
        	dp[i][j]=max(A[i-1][1]+dp[i-1][j-A[i-1][0]],dp[i-1][j]);
        }
    }
  }
  printf("%ld\n",dp[n][w]);
  
  return 0;
}

Measured memory_bytes: 98176
#include <bits/stdc++.h>
using namespace std;
typedef pair<vector<int>,int> SWinfo;

int N,M;

int check(int SW[], SWinfo In[]){ // 電球i[0~M]が点灯しているかチェック
  for(int i=0;i<M;i++){
    int light=0;
    for(int a:In[i].first) light +=SW[a-1];
    if (light%2!=In[i].second) {
      return 0;
    }
  }
  return 1;
}

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

  SWinfo In[M]; // 各電球の点灯情報
  int k, num;
  for(int i=0;i<M;i++){
    cin >>k;
    for(int j=0;j<k;j++) {
      cin >>num;
      In[i].first.push_back(num);
    }
  }
  for(int i=0;i<M;i++) cin >>In[i].second;

  int ans=0;
  int SW[N];
  for(int i=0;i<pow(2,N);i++){
    for(int j=0;j<N;j++){
      SW[j]=i/int(pow(2,j))%2;
    }
  ans += check(SW, In);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    static Scanner sc;
    public static void main(final String[] args) {

        sc = new Scanner(System.in);
        final int N = parseInt();
        final int K = parseInt();

        System.out.println(findBaseK(N, K));

    }

    public static int findBaseK(int n, final int k) {
        if(n==0) return 1;

        int i = 0;
        while(n!=0){
            n = Math.floorDiv(n, k);
            i++;
        }


        return i;
    }

    public static int parseInt(){
        return Integer.parseInt(sc.next());
    }
}

Measured memory_bytes: 35248
x, y = map(int, input().split())
a = 2 * x - (y / 2)
b = (y / 2) - x

if a.is_integer() and b.is_integer() and ((a >=1 and b >=0) or (a>=0 and b >= 1)):
    print('Yes')
else:
    print('No')

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

int main(){
double A,B,C,D,E,F,G,H,I;
while(cin>>A>>B>>C>>D>>E>>F>>G>>H){
if(A<C){I=A; A=C; C=I;}
if(B<D){I=B; B=D; D=I;}
if(E<G){I=E; E=G; G=I;}
if(F<H){I=F; F=H; H=I;}
if(E<C||G>A||F<D||H>B)cout<<"NO"<<endl;
else cout<<"YES"<<endl;}}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

struct RollingHash{
    static const long long base1=1007LL,base2=2009LL;
    static const long long MOD1=1000000007LL,MOD2=1000000009LL;
    vector<long long> hash1,hash2,pow1,pow2;
    RollingHash(const vector<ll> s /* ここを変える */){
        int sz=(int)s.size();
        hash1.assign(sz+1,0); hash2.assign(sz+1,0);
        pow1.assign(sz+1,1); pow2.assign(sz+1,1);
        for(int i=0;i<sz;i++){
            hash1[i+1]=(hash1[i]*base1+s[i]) % MOD1;
            hash2[i+1]=(hash2[i]*base2+s[i]) % MOD2;
            pow1[i+1]=(pow1[i]*base1) % MOD1;
            pow2[i+1]=(pow2[i]*base2) % MOD2;
        }
    }
    inline pair<long long,long long> query(int l,int r)const{
        if(l<0||r>=hash1.size()||r-l<0) return {0,0};
        long long ret1=hash1[r]-hash1[l]*pow1[r-l]%MOD1;
        ret1=(ret1+MOD1)%MOD1;
        long long ret2=hash2[r]-hash2[l]*pow2[r-l]%MOD2;
        ret2=(ret2+MOD2)%MOD2;
        return {ret1,ret2};
    }
    inline int lcp(const RollingHash &t,int a,int b)const{
        int len=min((int)hash1.size()-a,(int)hash2.size()-a);
        //cout<<len<<endl;
        int ok=0,ng=len;
        while(ng-ok>1){
            int mid=(ng+ok)>>1;
            if(query(a,a+mid)==t.query(b,b+mid)) ok=mid;
            else ng=mid;
        }
        return ok;
    }
};


signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    vector<ll> c(n),d(2*n);
    rep(i,n){
        c[i]=(b[i]^b[(i+1)%n]);
    }
    rep(i,2*n){
        d[i]=(a[i%n]^a[(i+1)%n]);
    }
    RollingHash rh1(c);
    RollingHash rh2(d);
    rep(i,n){
        //cout << rh1.lcp(rh2,0,i) << endl;
        if(rh1.lcp(rh2,0,i)==n){
            ll x = b[0]^a[i];
            cout << i << " " << x << endl;
        }
    }
    
}


Measured memory_bytes: 32928
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int mod=1e9+7;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	set<int> bad;
	for (int i=0; i<m; i++) {
		int x; cin>>x; bad.insert(x);
	}

	vector<int> dp(n+1,0);
	dp[0]=1;
	for (int i=1; i<=n; i++) {
		if(bad.count(i))
			continue;
		for (int j=1; j<=2; j++) {
			int k=i-j;
			if(k<0) continue;
			dp[i]=(dp[i]+dp[k])%mod;
		}
	}
	cout<<dp[n]<<"\n";
	return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>

int main(void){
    char s[6];
    scanf("%s",s);
    int i,counter = 0;
    for(i=0;i<4;i++){
        if(s[i] == '+'){
            counter ++;
        }
        else{
            counter --;
        }
    }
    printf("%d\n",counter);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define pb push_back


///Input/Output macros!
#define gi(x) scanf("%d", &x)
#define gi2(x, y) scanf("%d%d", &x, &y)
#define gi3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define gill(x) scanf("%lld", &x)
#define gill2(x, y) scanf("%lld%lld", &x, &y)
#define gill3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pill(x) printf("%lld\n", x)


///Basic Debugging macros!
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(ll __i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(ll __i__=0;__i__<r;__i__++){for(ll __j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}

using namespace std;

///Power of 2 till 2^31!
ll pow2[32] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648};

///Power function!
ll power(ll x,ll y)
{
        ll res = 1;
        while(y>0){
            if(y&1)
                res *= x;
            y>>=1;
            x*=x;
        }
        return res;
}
map<ll,ll> mp;
///Basic Sieve of Eratosthenes!
void Sieve(ll n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (ll p=2; p<=n; p++)
       if (prime[p])
        ++mp[p];
          //cout << p << " ";
}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

bool isPerfectSquare(ll x){ ll s = sqrt(x); return (s*s == x);}

bool isFibonacci(int n){return isPerfectSquare(5*n*n + 4) || isPerfectSquare(5*n*n - 4);}

bool isPrime(int n){if (n <= 1)return false;if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0)return false;
    return true;
}

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;


const int MOD = 1000000007;
const long double PI = 4*atan((long double)1);
const ll INF = 1e18;


int countZeros(int a[], int n)
{
    int count2 = 0, count5 = 0;
    for (int i = 0; i < n; i++) {
        while (a[i] % 2 == 0) {
            a[i] = a[i] / 2;
            count2++;
        }
        while (a[i] % 5 == 0) {
            a[i] = a[i] / 5;
            count5++;
        }
    }
    return (count2 < count5) ? count2 : count5;
}

int main()
{
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans = 0;
    if(n%2==0)
    for(ll i=10;n/i>=1;i*=5) ans += (n/i);
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc048/tasks/abc048_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#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 CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int A, B, X;
    cin >> A >> B >> X;
    cout << B / X - (A == 0 ? -1 : (A - 1) / X) << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define mod 1000000007
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} //log(a+b) complexity

void testcase(){
int  n,x,t;
cin>>n>>x>>t;
int  ans=n/x;
if(n%x==0){
	cout<<(ans*t)<<endl;
}
else{
	cout<<(ans+1)*t<<endl;
}

return;
}
int32_t main(){
ios_base::sync_with_stdio(false); 
   cin.tie(NULL);
 cout.tie(NULL); 
int t=1,k=1;
//cin>>t;
do{
//cout<<"Case #"<<k<<":"<<" ";
testcase();
k++;
t--;
}while(t>0);

return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
using namespace std;
const int mod = 1e9 + 7;
const int N = 1000010, inv3 = (mod + 1) / 3;
int n, ans, ba = 1;
int inv[N];

int main() {
	scanf("%d", &n), inv[0] = inv[1] = 1;
	rep(i, 2, n) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	rep(i, 1, n) {
		ba = 1ll * ba * inv3 % mod;
		ans = (ans + 1ll * inv[n - i + 1] * ba) % mod;
	}
	printf("%lld\n", 1ll * ans * inv[n] % mod);
	return 0;
}

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

int main() {
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> A;
    A.resize(q);
    for (int i = 0; i < q; i++) {
        cin >> A[i];
    }

    vector<int> num_correct(n, 0);
    for (int i = 0; i < q; i++) {
        num_correct[A[i] - 1]++;
    }

    vector<int> score(n, k);

    for (int i = 0; i < n; i++) {
        score[i] -= q - num_correct[i];
    }

    for (int i = 0; i < n; i++) {
        if (score[i] > 0) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;

constexpr ll INF = 1e18;
ll H, W;
vector<string> map;

p direction[4] = {p(0, -1), p(0, 1), p(-1, 0), p(1, 0)};

int main(void) {
    cin >> H >> W;
    vector<vector<ll> > board(H + 2, vector<ll>(W + 2, -1));

    string s;
    for (ll i = 0; i < H; i++) {
        cin >> s;
        map.push_back(s);
    }

    ll white = 0;
    for (ll h = 0; h < H; h++) {
        for (ll w = 0; w < W; w++) {
            if (map[h][w] == '.') {
                white++;
                board[h + 1][w + 1] = INF;
            }
        }
    }

    queue<p> que;
    que.push(p(1, 1));
    board[1][1] = 1;

    while (!que.empty()) {
        auto token = que.front(); que.pop();
        for (auto d : direction) {
            ll h = token.first;
            ll w = token.second;
            ll dh = h + d.first;
            ll dw = w + d.second;
            if (board[dh][dw] != -1 && board[dh][dw] > board[h][w] + 1) {
                board[dh][dw] = board[h][w] + 1;
                que.push(p(dh, dw));
            }
        }
    }

    if (board[H][W] == INF) {
        cout << -1 << endl;
    } else {
        cout << white - board[H][W] << endl;
    }

    return 0;
}



Measured memory_bytes: 384