akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
#define rep(i, n) for(ll i = 0;i < n;i++)

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

  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  int ans_s = 0;
  int ans_w = A*100;
  rep(a, 31) rep(b, 31) rep(c, 101) rep(d, 101) {
    int w = 100*A*a+100*B*b;
    int s = C*c+D*d;
    if (w == 0 || s*100 > E*w || s+w > F) continue;
    if (s*(ans_s+ans_w) > ans_s*(s+w)) {
      ans_s = s;
      ans_w = w;
    }
  }

  cout << ans_s+ans_w << " " << ans_s << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	a, s := readInt(), readString()
	if a >= 3200 {
		fmt.Println(s)
	} else {
		fmt.Println("red")
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void) 
{
    int a,b;
    
    scanf("%d%d\n",&a,&b);
    
    if(a>b) {
        printf("a > b\n");
}
    else if(a==b) {
        printf("a == b\n");
}
    else {
        printf("a < b\n");
}
    
    return 0;
}

Measured memory_bytes: 584
#include <iostream>
 #include <cmath>

using namespace std;
typedef long long ll;
int main(void){
ll a,b,c;

cin >> a >> b >> c;

ll d = c - a - b;
if(d > 0 && d * d > 4 * a * b){
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//-------------------------------------------MACROS---------------------------------------------
#define 	TIEMPO_CORRIDA		cerr << "tiempo: "<<1.0*clock()/CLOCKS_PER_SEC <<" seg.\n";
#define 	FILES				freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define 	FORIT(it,e)			for(it = e.begin() ; it != e.end() ; it++)
#define 	FOR(i,a,b)			for(i = a ; i < b ; i++)
#define 	RFOR(i,a,b)			for(i = a ; i >= b ;i--)
#define 	FORSW(i,a,b,sw)		for(i = a ; i < b && sw ; i++)
#define 	RFORSW(i,a,b,sw)	for(i = a ; i >= b && sw ; i--)
#define 	fast 				ios::sync_with_stdio(false),cin.tie(),cout.tie();
#define 	to_int(x) 			atoi(x.data())
#define 	to_long(x) 			atoll(x.data())
#define 	ALL(x) 				x.begin(),x.end()
#define 	RALL(x) 			x.rbegin(),x.rend()
typedef 	long long 			ll;
typedef 	pair<int,int> 		ii;
typedef 	pair<ll,ll> 		pl;
const		int 				modN = 1e9+7;
const		double 				PI = 3.1415926535897932384626433832795028841;
int mov_x[4]={0,0,1,-1};
int mov_y[4]={1,-1,0,0};
//---------------------------------------------------------------------------------------------
const int oo = 2e9+2;
int n,w;
ii item[102];//{peso,valor}
ll memo[102][100002];
int sum = 0;

void dp(){
	memset(memo,-1,sizeof memo);
	int i,v;
	memo[0][0]=0;
	memo[0][item[0].second]=item[0].first;
	FOR(i,0,n-1){
		FOR(v,0,sum+1){
			if(memo[i][v]!=-1){
				ll a = memo[i][v];//peso antes
				ll b = memo[i][v]+item[i+1].first;//peso despues
				if(a<=w){
					if(memo[i+1][v]==-1) memo[i+1][v]=a;
					else memo[i+1][v]=min(memo[i+1][v],a);
				}
				if(b<=w){
					if(memo[i+1][v+item[i+1].second]==-1)memo[i+1][v+item[i+1].second]=b;
					else memo[i+1][v+item[i+1].second] = min(memo[i+1][v+item[i+1].second],b); 
				}
			}
		}
	}	
}

int main(){
	int i,j;
	while(scanf("%d %d",&n,&w)==2){
		FOR(i,0,n) scanf("%d %d",&item[i].first,&item[i].second),sum+=(item[i].second);
		dp();		
		RFOR(i,sum,0) if(memo[n-1][i]<=w && memo[n-1][i]>-1) break;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 83520
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

vector<ll> cnt[4];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n, w;
	cin >> n >> w;
	vector<ll> a(n), b(n);
	cnt[0].pb(0);
	cnt[1].pb(0);
	cnt[2].pb(0);
	cnt[3].pb(0);
	rep(i, n){
		cin >> a[i] >> b[i];
		cnt[a[i] - a[0]].pb(b[i]);
	}
	sort(cnt[0].begin() + 1, cnt[0].end());
	sort(cnt[1].begin() + 1, cnt[1].end());
	sort(cnt[2].begin() + 1, cnt[2].end());
	sort(cnt[3].begin() + 1, cnt[3].end());
	reverse(cnt[0].begin() + 1, cnt[0].end());
	reverse(cnt[1].begin() + 1, cnt[1].end());
	reverse(cnt[2].begin() + 1, cnt[2].end());
	reverse(cnt[3].begin() + 1, cnt[3].end());
	repn(i, 1, cnt[0].size()) cnt[0][i] += cnt[0][i - 1];
	repn(i, 1, cnt[1].size()) cnt[1][i] += cnt[1][i - 1];
	repn(i, 1, cnt[2].size()) cnt[2][i] += cnt[2][i - 1];
	repn(i, 1, cnt[3].size()) cnt[3][i] += cnt[3][i - 1];
	ll ans = 0;
	rep(i, cnt[0].size()) rep(j, cnt[1].size()) rep(k, cnt[2].size()) rep(l, cnt[3].size()){
		if(((i * a[0]) + (j * (a[0] + 1)) + (k * (a[0] + 2)) + (l * (a[0] + 3))) <= w){
			ll cur = cnt[0][i] + cnt[1][j] + cnt[2][k] + cnt[3][l];
			ans = max(ans, cur);
		}
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <stdio.h>

int main(){
   char s[100001];
   int r,b,i;
    
   scanf("%s",s);
   for (r=i=0;s[i]!='\0';i++)
      if (s[i]=='0') r++;
   b=i-r;
   if (r>b) printf("%d\n",b*2);
   else     printf("%d\n",r*2);
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll ans = INF;
    FOR(i,-2000,2000){
        ll res = 0;
        rep(j,N){
            res += (i-A[j])*(i-A[j]);
        }
        ans = min(ans,res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());
            String[] array = reader.readLine().split(" ");
            int[] A = new int[N + 1];
            for (int i = 1; i <= N; i++) {
                A[i] = Integer.parseInt(array[i - 1]);
            }

            List<Integer> list = new ArrayList<>();
            int[] S = new int[N + 1];
            for (int i = N; i >= 1; i--) {
                if (A[i] != (S[i] % 2)) {
                    list.add(i);

                    for (int n = 1; n <= Math.sqrt(i); n++) {
                        if (i % n == 0) {
                            S[n]++;
                            int n2 = i / n;
                            if (n != n2) {
                                S[n2]++;
                            }
                        }
                    }
                }
            }

            Collections.sort(list);

            StringBuilder sb = new StringBuilder();
            sb.append(list.size());
            if (list.size() > 0) {
                sb.append("\n").append(list.get(0));
                for (int i = 1; i < list.size(); i++) {
                    sb.append(" ").append(list.get(i));
                }
            }
            System.out.println(sb.toString());
        }
    }

}


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

#define PrintLn(X) cout << X << endl
int main(void)
{
	int x, y;
	cin >> x >> y;
	int arr[] = {1, -2, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1};
	cout << ((arr[x - 1] == arr[y - 1]) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
dist = Counter(d)
mod = 998244353
if d[0] != 0 or dist[0] != 1:
    print(0)
    exit()
ans = 1
for i in range(n-1):
    ans = (ans * pow(dist[i], dist[i + 1], mod)) % mod
print(ans)


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

int N, A, B, C;
vector<int> bamboo;

int DFS(int n, int a, int b, int c) {
  if (n == N) {
    if (min(min(a, b), c) > 0) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    else return 10000000;
  }
  int no_use = DFS(n + 1, a, b, c);
  int a_use = DFS(n + 1, a + bamboo[n], b, c) + 10;
  int b_use = DFS(n + 1, a, b + bamboo[n], c) + 10;
  int c_use = DFS(n + 1, a, b, c + bamboo[n]) + 10;
  return min(min(min(no_use, a_use), b_use), c_use);
}

int main() {
  cin >> N >> A >> B >> C;
  for (int i=0; i<N; i++) {
    int l;
    cin >> l;
    bamboo.push_back(l);
  } 
  int cost = DFS(0, 0, 0, 0);
  cout << cost << endl;
}


Measured memory_bytes: 256
#!/usr/bin/python3

import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys


def main():
    while True:
        N, M = read_ints()
        if (N, M) == (0, 0):
            break
        P = [read_ints() for _ in range(M)]
        print(solve(N, M, P))


def solve(N, M, P):
    T = [[P[j][i] for j in range(M)] for i in range(N)]
    return max([sum(t) for t in T])


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9416
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string N;
    cin >> N;
    if ((N[0] == N[1] || N[2] == N[3]) && N[1] == N[2]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
    #include<bits/stdc++.h>
    using namespace std;

    typedef long long int ll;
    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef map<int,int> mi;
    typedef set<int> si;
    typedef queue<int> qi;
    typedef stack<int> sti;

    #define  mod 1000000007 
    #define  endl '\n'
    #define  F first
    #define  S second
    #define  pb push_back
    #define  mp make_pair
    #define  mt make_tuple
    #define f(i,a,b) for(int i=a;i<n;i++)
    #define f1(i,a,b) for(int i=a;i<=b;i++)

    template <typename T> void debug(T x) {  cout<<x<<endl;}
    template <typename T> void debug(T x,T y) { cout<<x<<" "<<y<<endl;}
    template <typename T> void debug(T a[]) { for(int i=0;i<a.size();i++) { cout<<a[i]<<" ";} cout<<endl; }
    template <typename T> void debug(vector<T> a) { for(int i=0;i<a.size();i++) { cout<<a[i]<<" ";} cout<<endl; }
    template <typename T> void debug(set<T> s) { for(T x:s) {  cout<<x<<" ";} cout<<endl;}
    template <typename T> void debug(map<T,T> m) { for(auto i=m.begin();i!=m.end();i++) { cout<<i->first<<" "<<i->second;cout<<endl; }}
    template <typename T> void debug(set<pair<T,T>> p) {for(auto x:p){     cout<<x.first<<" "<<x.second; cout<<endl; } }
    template<typename T>  void debug(stack<T> s) { while(!s.empty()) {cout<<s.top()<<" "; s.pop();} cout<<endl; }
    template <typename T> void debug(queue<T> q) {  while(!q.empty()) { cout<<q.front()<<" "; q.pop();}  cout<<endl; }

    //                                        ****modulo operation****

    inline ll add(ll a,ll b) { a+=b; if(a>=mod) return a-mod; return a; }
    inline ll sub(ll a,ll b) { a-=b;  if(a-b<0)   return a+mod;  return a; }
    inline ll mul(ll a,ll b)  {  return (a*b)%mod; }
    inline ll divide(int a,int b) {  b=pow(b,mod-2); return (a*b)%mod; }
    inline ll power(ll x,ll y) { ll ans=1; while(y) { if(y&1) ans*=x; x=x*x; y>>=1;} return ans;}
    inline ll inv(ll x) {  return power(x,mod-2); }  

    //*****************************************  code starts from here   ********************************************


    void solve()
    {
        int n;
        cin>>n;
        map<string,int> m;
        while(n--)
        {
            string s;
            cin>>s;
            m[s]++;
        }
        cout<<"AC x "<<m["AC"]<<endl;
        cout<<"WA x "<<m["WA"]<<endl;
        cout<<"TLE x "<<m["TLE"]<<endl;
        cout<<"RE x "<<m["RE"]<<endl;
    }
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++)
        {
            solve();
        }
        
    }

Measured memory_bytes: 3648
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
解説PDFの英語版に従い実装
"""

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
A = list(map(int, input().split()))

A_sum = sum(A)
removed_unit = N * (N + 1) // 2

if A_sum % removed_unit:
    print('NO')
else:
    k = A_sum / removed_unit
    for i in range(N):
        d = A[(i + 1) % N] - A[i]
        if k - d >= 0 and (k - d) % N == 0:
            pass
        else:
            print('NO')
            sys.exit(0)
    print('YES')


Measured memory_bytes: 17420
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    ll q;
    ll a[100010], b[100010], c[100010], d[100010];
    cin >> S >> T;
    cin >> q;
    rep(i,0,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--; c[i]--; d[i]--;
    }
    ll ssum[100010] = {};
    ll tsum[100010] = {};
    ll sn = S.size();
    ll tn = T.size();
    rep(i,0,sn){
        if(S[i] == 'A'){
            ssum[i+1] = ssum[i] + 1; 
        }else{
            ssum[i+1] = ssum[i] + 2;
        }
    }
    rep(i,0,tn){
        if(T[i] == 'A'){
            tsum[i+1] = tsum[i] + 1;
        }else{
            tsum[i+1] = tsum[i] + 2;
        }
    }
    rep(i,0,q){
        if((ssum[b[i]+1] - ssum[a[i]] - tsum[d[i]+1] + tsum[c[i]]) % 3 == 0){
            print("YES");
        }else{
            print("NO");
        }
    }
}


Measured memory_bytes: 5584
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
#include <complex>


int main() {
	long long int height, width; std::cin >> height >> width;
	if (height % 3 == 0 || width % 3 == 0) {
		std::cout << 0 << '\n';
		return 0;
	}
	long long int min_diff = std::min(height, width);
	for (auto i = 1; i < height; ++i) {
		const auto first = width * i;
		const auto second = (width >> 1) * (height - i);
		const auto third = height * width - first - second;
		min_diff = std::min(min_diff, std::max({ first, second, third }) - std::min({ first, second, third }));
	}
	for (auto i = 1; i < width; ++i) {
		const auto first = height * i;
		const auto second = (height >> 1) * (width - i);
		const auto third = height * width - first - second;
		min_diff = std::min(min_diff, std::max({ first, second, third }) - std::min({ first, second, third }));
	}
	std::cout << min_diff << std::endl;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
using ll = long long;

const ll mod = 1e9+7;
char grid[1004][1004];
ll a[1004][1004];

int main() {
	ll n, m; cin>>n>>m;
	for(ll i = 1; i <= n; i++){
	    for(ll j = 1; j <= m; j++){
	        cin>>grid[i][j];
	    }
	}
	a[1][1] = 1;
	for(ll i = 1; i <= n; i++){
	    for(ll j = 1; j <= m; j++){
	        if(grid[i][j] == '#'){continue;}
	        a[i][j] += (a[i-1][j] + a[i][j-1]);
	        a[i][j] %= mod;
	    }
	}
	cout<<a[n][m];
	return 0;
}

Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  ll H,W;
  cin >> H >> W;
  ll ans = 1e9;
  if(H%3 == 0 || W%3 == 0) ans = 0;
  else if(H == 2 && W == 2) ans = 1;
  else{
    ans = min(H,W);
    for(ll i = 1;i < H;i++){
      ll M = max((H-i)*W,max(i*(W/2),i*(W-W/2)));
      ll m = min((H-i)*W,min(i*(W/2),i*(W-W/2)));
      ans = min(ans,M-m);
    }
    for(ll i = 1;i < W;i++){
      ll M = max((W-i)*H,max(i*(H/2),i*(H-H/2)));
      ll m = min((W-i)*H,min(i*(H/2),i*(H-H/2)));
      ans = min(ans,M-m);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N, A, B, C, D = (int(i) for i in input().split())
    S = input()
    if "##" in S[A:C] or "##" in S[B:D]:
        return print("No")
    if D < C and (S[D-2] == "#" or S[D] == "#"):
        if (S[B-2] == "#" or S[B] == "#") and "..." not in S[B-1:D]:
            return print("No")
    print("Yes")


if __name__ == '__main__':
    main()


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


def solve(A: int, B: int, C: int, K: int):
    if(K%2 == 0):
        print(A-B)
    else:
        print(B-A)
    return


# Generated by 1.1.4 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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

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

  string s; cin >> s;
  if(s[0] == '7' || s[1] == '7' || s[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cmath>
#include <set>

using namespace std;

int n, x[1002], y[1002], r[1002];
double d[1002][1002], v[1002];
set<pair<double, int>> q;
set<pair<double, int>>::iterator qq[1002];

int main() {
    scanf("%i %i %i %i %i", x, y, x+1, y+1, &n);
    d[0][1] = d[1][0] = sqrt(pow(x[0] - x[1], 2) + pow(y[0] - y[1], 2));
    for (int i = 2; i < n + 2; ++i) {
        scanf("%i %i %i", x + i, y + i, r + i);
        for (int j = 0; j < i; ++j) {
            d[j][i] = d[i][j] = max((double)0, sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2)) - r[i] - r[j]);
        }
    }
    for (int i = 1; i < n + 2; ++i) v[i] = 1e11, qq[i] = q.end();
    qq[0] = q.emplace(0, 0).first;
    while (q.size()) {
        auto p = *q.begin();
        q.erase(q.begin());
        qq[p.second] = q.end();
        for (int i = 0; i < n + 2; ++i) {
            double w = p.first + d[i][p.second];
            if (w < v[i]) {
                if (qq[i] != q.end()) q.erase(qq[i]);
                qq[i] = q.emplace(v[i] = w, i).first;
            }
        }
    }
    printf("%.10f\n", v[1]);
    return 0;
}


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

int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string a, b, c;
  cin >> a >> b;
  int A, B;
  cin >> A >> B;
  cin >> c;
  if(c[0] == a[0])
    --A;
  else
    --B;
  cout << A << " " << B << "\n";
  return 0;
}

Measured memory_bytes: 256
//#define NDEBUG
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
static constexpr double PI = 3.1415926535897932;

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

template<class T>bool bmaxi(T&a, const T&b) { if (b<a)return 0;a = b;return 1; }
template<class T>bool bmini(T&a, const T&b) { if (a<b)return 0;a = b;return 1; }
template<class T>bool nmaxi(T&a, const T&b) { if (a<b) { a = b;return 1; }return 0; }
template<class T>bool nmini(T&a, const T&b) { if (b<a) { a = b;return 1; }return 0; }
template<typename T>auto scan(T&d)->typename std::enable_if<std::is_same<T, std::string
>::value>::type {
	d.clear();int c = fgetc(stdin);while (c<'a' || 'z'<c)c = fgetc(stdin);
	while ('a' <= c&&c <= 'z') { d.push_back(c);c = fgetc(stdin); }
}
template <typename T>auto scan(T&d)->
typename std::enable_if<std::is_same<T, double>::value>::type {
	scanf("%lf", &d);
}
template <typename T>auto scan(T&d)->typename std::enable_if<std::is_signed<T>::value
	== std::is_same<T, std::string>::value>::type {
	d = 0;int c = fgetc(stdin);
	while (c<'0' || '9'<c)c = fgetc(stdin);while ('0' <= c&&c <= '9') { d = d * 10 + c - '0';c = fgetc(stdin); }
}
template <typename T>auto scan(T&d)->typename std::enable_if<std::is_signed<T>::value
	!= std::is_same<T, double>::value>::type {
	d = 0;int c = fgetc(stdin);bool f = 0;while (c<'0' || '9'<c)
	{
		if (c == '-')f = 1;c = fgetc(stdin);
	}while ('0' <= c&&c <= '9') { d = d * 10 + c - '0';c = fgetc(stdin); }if (f)d = -d;
}
template<typename F, typename...R>void scan(F&f, R&...r) { scan(f);scan(r...); }



int main(void) {
	uint64 n, k;
	scan(n, k);
	uint64 ans = 0;
	if (!k) {
		printf("%lu\n", n*n);return 0;
	}
	for (uint32 i = k + 1;i <= n;++i) {
		ans += n / i*(i - k);
		if (n%i >= k)ans += n%i - k+1;
	}
	printf("%lu\n", ans);
	return 0;
}

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

template<typename T>
struct BIT{
    private:
        vector<T> array;
        const int n;
    public:
        BIT(int _n) : array(_n + 1, 0), n(_n) {}
        // [1, i], i is 1-indexed
        T sum(int i){
            T s = 0;
            while(i > 0){
                s += array[i];
                i -= i & -i;
            }
            return s;
        }
        // [i, j), i and j are 1-indexed
        T sum(int i, int j){
            T ret_i = sum(i-1);
            T ret_j = sum(j);
            return ret_j - ret_i;
        }
        // i is 1-indexed
        void add(int i, T x){
            while(i <= n){
                array[i] += x;
                i += i & -i;
            }
        }

        // debug
        void print(){
            for(int i = 1; i < (int)array.size(); ++i){
                cout << sum(i, i+1) << " ";
            }
            cout << endl;
        }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> s(n+1, 0);
    rep(i,n){
        ll a;
        cin >> a;
        s[i+1] = s[i] + (a - k);
    }
    vector<ll> ss = s;
    sort(ss.begin(), ss.end());
    ss.erase(unique(ss.begin(), ss.end()), ss.end());
    ll ans = 0;
    BIT<ll> bit(n+10);
    for(int i = 0; i <= n; ++i){
        int id = lower_bound(ss.begin(), ss.end(), s[i]) - ss.begin();
        ans += bit.sum(id+1);
        bit.add(id+1, 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

class dice{
  int* me;
public:
  dice(int me_[6]){
    me = me_;
  }
  int Top(){
    return me[0];
  }
  void East(){
    swap(me[0], me[3]);
    swap(me[3], me[5]);
    swap(me[5], me[2]);
  }
  void West(){
    swap(me[0], me[2]);
    swap(me[2], me[5]);
    swap(me[5], me[3]);
  }
  void North(){
    swap(me[0], me[1]);
    swap(me[1], me[5]);
    swap(me[5], me[4]);
  }
  void South(){
    swap(me[0], me[4]);
    swap(me[4], me[5]);
    swap(me[5], me[1]);
  }
};


int main(){ _;
  int me[6];
  REP(i,6) cin>>me[i];
  dice d{me};
  char c;
  while(cin>>c){
    if(c=='E'){
      d.East();
    }else if(c=='W'){
      d.West();
    }else if(c=='N'){
      d.North();
    }else if(c=='S'){
      d.South();
    }
  }
  cout<<d.Top()<<endl;
}

Measured memory_bytes: 1192
//
// Created on 2020/03/28.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    ll ans = 0;
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    vector<int>A(a);
    for (int i = 0; i < a; ++i) {
        cin>>A[i];
    }
    vector<int>B(b);
    for (int i = 0; i < b; ++i) {
        cin>>B[i];
    }
    vector<int>C(c);
    for (int i = 0; i < c; ++i) {
        cin>>C[i];
    }
    sort(rall(A));
    sort(rall(B));

    vector<int>D;
    for (int j = 0; j < x; ++j) {
        D.push_back(A[j]);
    }
    for (int k = 0; k < y; ++k) {
        D.push_back(B[k]);
    }
    for (int l = 0; l < c; ++l) {
        D.push_back(C[l]);
    }
    sort(rall(D));
    for (int m = 0; m < x+y; ++m) {
        ans += D[m];
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    rep(i, s.size()){
        if(s[i] != t[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3652
n = gets.chomp.to_i
t, a = gets.chomp.split.map(&:to_i)
hs = gets.chomp.split.map(&:to_i)

num = -1
t_num = 100000
hs.each_with_index do |h, i|
  tt = a - (t - h * 0.006)
  if tt.abs < t_num.abs
    t_num = tt 
    num = i
  end
end
puts num + 1

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define INF     1e9
#define ld      long double
#define lli     long long int
#define PI 	    acos(-1)
#define read    freopen("in.txt","r",stdin)
#define uu		first
#define vv		second
#define write   freopen("out.txt","w",stdout)
#define pii     pair<int,int>
using namespace std;
lli n,k,ara[100];
int main()
{
    //write;
	scanf("%lld",&k);
	//for(lli i=0;i<50;i++) ara[i]=i;
	n=50;
	lli tmp=k/n;
	for(lli i=0;i<n;i++) ara[i]=tmp+i;
	tmp=k%n;
	for(lli i=0;i<n;i++) {

		if(i<tmp) ara[i]+=(n+1);
		ara[i]-=(tmp);
	}
	printf("%lld\n",n);
	for(lli i=0;i<n;i++) printf("%lld ",ara[i]);
	return 0;
}


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

int main(void){
    int n;
    cin>>n;
    map<int,int> cnt;
    rep(i,n){
        int a;
        cin>>a;
        cnt[a-1]++;
        cnt[a]++;
        cnt[a+1]++;
    }
    int res = 0;
    for(auto x:cnt){
        res = max(x.second,res);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4736
import java.math.BigInteger;
import java.util.Scanner;
import java.io.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner cin = new Scanner(System.in);
        int n,i=1,x,t=1008,k;
        BigInteger a,b,c;
        n=cin.nextInt();
        k=cin.nextInt();
        c=BigInteger.ONE ;
        b=BigInteger.ONE ;
        a=BigInteger.ZERO;
        b=BigInteger.valueOf(k-1);
        c=b.pow(n-1);
        b=BigInteger.valueOf(k);
        a=b.multiply(c);
            System.out.println(a);
        }
    
}


Measured memory_bytes: 23892
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for(int n=0; n<N; n++) A[n] = sc.nextLong();

        long allXor = 0;
        for(int n=0; n<N; n++) allXor ^= A[n];

        for(int n=0; n<N; n++){
            System.out.print(allXor^A[n]);
            if(n+1<N) System.out.print(" ");
            else System.out.println();
        }
        
    }
}


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

bool comp(pair<int,int> lhs, pair<int,int> rhs)
{
    if(lhs.second != rhs.second){  // 通常は second を昇順に並べる
        return lhs.second < rhs.second;
    }else{  // second が同じものは first の降順で並べる
        return lhs.first > rhs.first;
    }
}


int main()
{
    int N;
    cin >> N;
    vector<pair<int,int>> task(N);
    for( int i = 0; i < N; ++i ) cin >> task[i].first >> task[i].second;


    sort(task.begin(), task.end(), comp);

    int t = 0;
    bool ans = true;
    for( int i = 0; i < N; ++i ){
        //cout << task[i].first << " " << task[i].second << endl;
        t += task[i].first;
        if( t > task[i].second){
            ans = false;
            break;
        }
    }
    
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		if ((a + b) % 2 == 1) {
			System.out.println("IMPOSSIBLE");
		} else {
			System.out.println((a + b) / 2);
		}
		sc.close();
	}
}

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

using namespace std;

#define fo(i,CApiTaL_N) for(int i=0; i<CApiTaL_N; i++)
#define Fo(i,k,CApiTaL_N) for(int i=k; i<CApiTaL_N; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int t;
int n;
const int mxN=1e5, mod=1e9+7;
vvi tree(mxN+1);
vvl dp(mxN+1,vl(2));

ll mul_self(ll a, ll b){
    return (a*b)%mod;
}

ll add_self(ll a, ll b){
    return (a+b)%mod;
}

void dfs(int node, int par){
    if(tree[node].size()==1&&tree[node][0]==par){
        dp[node]={1,1};
        return;
    }
    ll wt=0, blk=1;
    for(auto child:tree[node]){
        if(child!=par){
            dfs(child,node);
            auto temp=blk;
            blk=mul_self(blk,dp[child][1]);
            wt=add_self(mul_self(temp,dp[child][0]), mul_self(wt,add_self(dp[child][0],dp[child][1])));
            // cout<<child<<" "<<blk<<" "<<wt<<endl;
        }
    }
    dp[node]={blk,wt+blk};
}

void test_case(){
    cin>>n;
    fo(i,n-1){
        int a,b;
        cin>>a>>b;
        tree[a].pb(b);
        tree[b].pb(a);
    }
    dfs(1,-1);
    cout<<add_self(dp[1][0],dp[1][1])<<endl;
}

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

    t=1;
    while(t--){
        test_case();
    }
    
    return 0;
}

Measured memory_bytes: 23772
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

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

    int n; cin>>n;
    vector<int> l(n);
    for(int i=0; i<n; i++) cin>>l[i];

    sort(all(l));

    ll ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int sum = l[i] + l[j];
            int cnt = lower_bound(all(l), sum) - l.begin() - 1 - j;
            ans += max(0, cnt);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'

using namespace std;
typedef vector<ll>   vll;
typedef vector<int>   vi;
typedef set<ll>      sll;
typedef set<int>      si;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

ll i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}

// #define cerr if(0)cerr
void solve()
{
  ll w,h,x,y; cin>>w>>h>>x>>y;
  
  cout<<fixed<<setprecision(10)<<double(w*h)/2<<" ";
  if(w%2==0 && x==w/2 && h%2==0 && y==h/2)
   cout<<"1\n";
   else cout<<"0\n"; 
}

Measured memory_bytes: 256
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s,c = s+j,c+1
        j+=1
    x[c][s]+=1

while 1:
    n,s = map(int, raw_input().split())
    if n==0 and s==0: break
    print 0 if s>=50 else x[n][s]

Measured memory_bytes: 4248
def solve():
    from sys import stdin
    f_i = stdin
    
    n = int(f_i.readline())
    
    items = (f_i.readline().split() for i in range(n))
    items = [(int(v), int(w), t, int(d), n) for v, w, t, d, n in items]
    items.sort()
    items = (' '.join(map(str, i)) for i in items)
    
    print('\n'.join(items))

solve()


Measured memory_bytes: 46128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<int> mp(vector<int> s) {
  int n = s.size();
  vector<int> ret(n + 1);
  ret[0] = -1;
  int j = -1;
  rep(i, n) {
    while (j >= 0 && s[i] != s[j]) j = ret[j];
    ret[i + 1] = ++j;
  }
  return ret;
}

vector<int> kmp(vector<int> str, vector<int> word) {
  vector<int> table = mp(word), ret;
  int m = 0, i = 0, n = str.size();
  while (m + i < n) {
    if (word[i] == str[m + i]) {
      if (++i == (int)(word.size())) {
        ret.push_back(m);
        m = m + i - table[i];
        i = table[i];
      }
    }
    else {
      m = m + i - table[i];
      if (i > 0) i = table[i];
    }
  }
  return ret;
}

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

  vector<int> c(n * 2), d(n);
  rep(i, n) {
    c[i] = a[i] ^ a[(i + 1) % n];
    c[i + n] = c[i];
  }
  rep(i, n) d[i] = b[i] ^ b[(i + 1) % n];

  vector<int> res = kmp(c, d);
  rep(i, res.size()) {
    int k = res[i];
    if (k >= n) break;
    int x = a[k] ^ b[0];
    cout << k << " " << x << endl;
  }


  
  return 0;
}

Measured memory_bytes: 9140
import bisect
N,Q = map(int,input().split())
A = list(map(int,input().split()))
X = [int(input()) for i in range(Q)]
A.reverse()

cums = [0]
cums_e = [0]
for i,a in enumerate(A):
    cums.append(cums[-1] + a)
    cums_e.append(cums_e[-1] + (0 if i%2 else a))

borders = []
scores = []
for i in range(1,N//2+N%2):
    b = (A[i] + A[2*i])//2 + 1
    borders.append(b)
    s = cums[i] + cums_e[-1] - cums_e[2*i]
    scores.append(s)
if N%2:
    scores.append(cums[N//2+1])
else:
    scores.append(cums[N//2])

borders.reverse()
scores.reverse()

ans = []
for x in X:
    i = bisect.bisect(borders, x)
    ans.append(scores[i])
print(*ans, sep='\n')

Measured memory_bytes: 29344
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;

#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x)
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = (ll)5e16;
const ld eps = 1e-12;
const ll N = 1000005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll power(ll a, ll b, ll m) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}
ll n, m, d[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    f(i, m)
    {
        ll u, v;
        cin >> u >> v;
        d[u]++;
        d[v]++;
    }
    rep(i, 1, n) cout << d[i] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

int main() {
    ios_base::sync_with_stdio(false);

    cin.tie(0);
    li a, b, c;
    cin >> a >> b >> c;

    li move = min(a - b, c);
    cout << c - move << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc139_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            int r = 0;
            int rm = 0;

            for (int i = 0; i < N - 1; i++)
                if (H[i] < H[i + 1])
                {
                    r = 0;
                }
                else
                {
                    r++;
                    if (rm < r) rm = r;
                }

            Console.WriteLine(rm);
        }
    }
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

inline int64 modPow(int64 x, int64 n)
{
  if(n == 0) return(1);
  int64 ret = modPow(x, n / 2);
  (ret *= ret) %= mod;
  if(n & 1) (ret *= x) %= mod;
  return(ret);
}
inline int64 modInv(int64 a)
{
  return(modPow(a, mod - 2));
}
inline int64 modCombination(int p, int q)
{
  static int64 fact[202020], rfact[202020];
  if(fact[0] == 0) {
    fact[0] = rfact[0] = 1;
    for(int i = 1; i < 102020; i++) {
      fact[i] = fact[i - 1] * i % mod;
      rfact[i] = modInv(fact[i]);
    }
  }
  if(q < 0 || p < q) return(0);
  return(fact[p] * rfact[q] % mod * rfact[p - q] % mod);
}
inline int64 count1_3(int n, int k)
{
  if(n < k) return(0);
  int64 ret = 0;
  for(int i = 1; i <= k; i++) {
    // i 個以下の箱に n 個の玉を入れる場合の数
    int64 tmp = modCombination(k, i) * modPow(i, n) % mod;
    if((k - i) & 1) ret = (ret - tmp + mod) % mod;
    else (ret += tmp) %= mod;
  }
  return(ret);
}

int main() {
  int N, K;
  cin >> N >> K;
  cout << count1_3(N, K) << endl;
}






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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, l, s = 0, s1 = 0;
    int menor = 100000;
    int res;
    cin >> n >> l;
    for(int i = 1; i <= n; i ++){	
		s += l + i - 1;
	}
	for(int i = 1 ; i <= n; i++){	
		s1 = (l + i - 1);
		if(abs(s1) < menor){	
			res = s - s1;
			menor = abs(s1);
		}
	}
	cout << res;
    return 0;
}


Measured memory_bytes: 256
package main

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

const (
	none = iota
	inc
	dec
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	var ans, i int
	for i+1 < len(a) {
		var j, k int
		for j = i; j+1 < len(a); j++ {
			if a[j] <= a[j+1] {
				continue
			} else {
				break
			}
		}
		for k = i; k+1 < len(a); k++ {
			if a[k] >= a[k+1] {
				continue
			} else {
				break
			}
		}
		i += max(j-i, k-i) + 1
		ans++
	}
	// fmt.Println("d00 - i", i)
	if i < len(a) {
		ans++
	}
	fmt.Println(ans)
}
func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int H,W,i,k;
  while(true)
  {
    cin>>H>>W;
      if(H==0 && W==0){break;}
    for(i=0;i<H;i++)
    {
      for(k=0;k<W;k++)
      {
        cout<<"#";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3096