akhauriyash/Code-Regression huggingface dataset:
a,b = map(int,input().split())

if b - a == 0:
    answer = a
else:
    answer = 0
    if a % 2 == 0:
        first_odd = a
    else:
        first_odd = a+1
    if b % 2 == 0:
        last_even = b-1
    else:
        last_even = b
    odd_even = int((last_even - first_odd + 1) // 2)
    if a % 2 == 1 and b % 2 == 0:
        answer += (odd_even + 1) % 2
        b2 = []
        while b > 0:
            b2.append(b % 2)
            b = int((b-b%2)//2)
        a2 = []
        for i in range(len(b2)):
            a2.append(a % 2)
            a = int((a-a%2)//2)
        for i in range(1,len(b2)):
            if a2[i]+b2[i] == 1:
                answer += 2**i
    elif a % 2 == 1:
        answer += (odd_even + 1) % 2 + a - 1
    elif b % 2 == 0:
        answer += odd_even % 2 + b
    else:
        answer += odd_even % 2

print(answer)


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

int main(){
  int n,max;
  cin >> n ;
  cin >> max;
  int ans = 1;

  vector<int> h(n);

  for(int i = 0; i < n-1; i++)
  {
    int h;
    cin >> h;

    if(h>=max){
        ans++;
        max = h;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

int main()
{
    int H, W, N;
    cin >> H >> W >> N;
    int a = max(H, W);
    cout << (N % a == 0 ? N / a : N / a + 1) << endl;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  int c = 1;
  int ans = 0;
  while (c < b)
  {
    c += a - 1;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int K, A, B;
    in(K); in(A); in(B);
    bool flag = false;
    for (int i=A; i<=B; i++) {
        if (i % K == 0) {
            flag = true;
        }
    }
    cout << ((flag)? "OK":"NG") << endl;

	return 0;
}


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

int main(void){
        int a,b;
        cin>>a>>b; //変数a,bにこの順番で整数を入力する。
        cout<<a*b;   
        cout<<" ";  //空白
        cout<<2*(a+b);
        cout<<endl;
}


Measured memory_bytes: 3100
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func nextString() string {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	return s
}

func checkRegexp(reg, str string) bool {
	return regexp.MustCompile(reg).Match([]byte(str))
}

func main() {
	sc.Split(bufio.ScanWords)
	var gachaMap = map[string]bool{}
	n := nextInt()
	for i := 0; i < n; i++ {
		s := nextString()
		if 1 <= len(s) && len(s) <= 10 {
			gachaMap[s] = true
		}
	}
	fmt.Println(len(gachaMap))
}


Measured memory_bytes: 14736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String n = scan.nextLine();
		int count = 0;
		for(int i = 0; i < n.length(); i++) {
			if(n.charAt(i) == '1') count++;
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 2010;
const ll bits = 30;
const ll mod = 998244353;



int main(){
    FASTIO;
    ll n,w;
    cin>>n>>w;

    vector< vector<ll> >dp(n+1,vector<ll>(w+1,0)),arr(n+1,vector<ll>(2,0));
    for(int i=1;i<=n;i++){
        cin>>arr[i][0]>>arr[i][1];
    }

    
    for(int i=1;i<=n;i++){
        for(int j=0;j<=w;j++){
            dp[i][j] = dp[i-1][j];
        }
        for(int j=0;j<=w && j+arr[i][0]<=w;j++){
            dp[i][j+arr[i][0]] = max({dp[i][j+arr[i][0]],dp[i-1][j]+arr[i][1]});
        }
    }

    // for(int i=1;i<=n;i++){
    //     for(int j=0;j<=w;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }

    ll ans =0;

    for(int i=0;i<=w;i++){
        ans = max(ans,dp[n][i]);
    }

    cout<<ans<<"\n";



    
}

Measured memory_bytes: 80256
from itertools import *
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   for t in[f"({a} {x} {b}) {y} ({c} {z} {d})",f"(({a} {x} {b}) {y} {c}) {z} {d}"]:
    if eval(t)==10:return'('+t+')'
 else:return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


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

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

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

}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time = (h2 - h1) * 60 + (m2 - m1);
    cout << time - k << endl;

    return 0;
}

Measured memory_bytes: 3172
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int K =sc.nextInt();
    String S =sc.next();
    int s =S.length();
    if(s<=K){System.out.println(S);}
    else{
      String T =S.substring(0,K);
      System.out.println(T+"...");}
  }
}

Measured memory_bytes: 38596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 100001

using namespace std;

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

int N;
vector<int> G[MAX_N];

int prv[MAX_N];

void bfs() {
    fill(prv, prv + N, -1);
    queue<int> que;
    prv[N - 1] = -2;
    que.push(N - 1);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (int i = 0; i < G[v].size(); ++i) {
            int nxt = G[v][i];
            if (prv[nxt] == -1) {
                prv[nxt] = v;
                que.push(nxt);
            }
        }
    }
}

int get_score(int s, int t) {
    int res = 0;
    bool used[MAX_N];
    fill(used, used + N, false);
    queue<int> que;
    
    used[s] = true;
    res++;
    que.push(s);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (int i = 0; i < G[v].size(); ++i) {
            int nxt = G[v][i];
            if (!used[nxt] && nxt != t) {
                used[nxt] = true;
                res++;
                que.push(nxt);
            }
        }
    }
    
    return res;
}

int main() {
    cin >> N;
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    
    bfs();
    vector<int> path;
    int n = 0;
    while (n != N - 1) {
        path.push_back(n);
        n = prv[n];
    }
    path.push_back(N - 1);
    
    int b, w, len = (int)path.size();
    if (len % 2 == 0) {
        b = len / 2 - 1;
    } else {
        b = (len + 1) / 2 - 1;
    }
    w = b + 1;
    
    int b_score = get_score(path[b], path[w]);
    int w_score = get_score(path[w], path[b]);
    
    if (b_score <= w_score) {
        cout << "Snuke" << endl;
    } else {
        cout << "Fennec" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 6780
import Control.Monad
import Control.Monad.Primitive (PrimState)
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    [n, k] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    mv <- MV.replicate 100002 0 :: IO (MV.MVector (PrimState IO) Int)
    replicateM_ n $ do
        [a, b] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
        MV.unsafeModify mv (+ b) (a - 1)
    v <- V.unsafeFreeze mv
    print $ fromJust $ V.findIndex (>= k) (V.scanl' (+) 0 v)


Measured memory_bytes: 1916
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int compare(const void *a, const void *b)
{
    int da = *( int*)a;
    int db = *(int*)b;
    int val = 0;
    if(da > db) {
        val = -1;
    } else if (da == db) {
        val = 0;
    } else {
        val = 1;
    }

    return val;
}

int main()
{
    int n,i;
    scanf("%d",&n);
    int a[100010];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(a[0]),compare);
    printf("%d",a[(n/2)-1]-a[(n/2)]);
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    string s,ans;
    cin >> s;
    cout << s.substr(0,4) << " " << s.substr(4,12) << endl;
    return 0;
}


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

using namespace std;

int main () {
    int N;
    cin>>N;
    int mx = 0;
    int mn = 1000;
    for (int i = 0; i < N; i++) {
        int a;
        cin>>a;
        mn = min(mn, a);
        mx = max(mx, a);
    }
    cout<<mx - mn<<endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  const args = input.trim().split("\n");

  let n = args.length;
  for (let i = 0; i < n; i++) {
    let tmp = args[i].split(" ").map((x) => Number(x));
    let h = tmp[0];
    let w = tmp[1];
    if (h === 0 && w === 0) {
      break;
    }
    let s = "";
    let t = "";
    for (let x = 0; x < w; x++) {
      if (x % 2 === 0) {
        s += "#";
        t += ".";
      } else {
        s += ".";
        t += "#";
      }
    }
    for (let y = 0; y < h; y++) {
      if (y % 2 === 0) {
        console.log(s);
      } else {
        console.log(t);
      }
    }
    console.log();
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17528
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair
/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------

int dx[4] = {0,0,-1,1};
int dy[4] = {1,-1,0,0};
const int MAXN = 1e4;
bitset<MAXN> f;

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

int main()
{
    Phuong_;
    int n,m;
    cin >> n >> m;
    int a[n+2][m+2];
    memset(a,0,sizeof(a));
    for(int i=1; i<=n; ++i)
        for(int j=1; j<=m; ++j)
    {
        char t;
        cin >> t;
        a[i][j] = (t=='.')?(1):(0);
    }

    int ans=0;
    for(int i=1; i<=n; ++i)
        for(int j=1; j<=m; ++j)
        if (a[i][j]==1)
        {
            int cnt=0;
            f.reset();
            queue<pii> q;
            int id = i*m + j-1;
            q.push(mp(id,0));
            while (!q.empty())
            {
                int u = q.front().first;
                int dcnt = q.front().second;
                q.pop();
                int x = u/m;
                int y = (u%m)+1;
                if (f[u]) continue;
                f[u]=true;
                ans = max(ans,dcnt);
                for(int k=0; k<4; ++k)
                {
                    int di = x + dx[k];
                    int dj = y + dy[k];
                    if (di<1 || di>n) continue;
                    if (dj<1 || dj>m) continue;
                    id = di*m + dj-1;
                    if (a[di][dj]==1 && f[id]==false)
                    {
                        q.push(mp(id,dcnt+1));
                    }
                }
            }
        }
    cout << ans;
    return 0;
}



Measured memory_bytes: 384
#C - Step
N = int(input())
A = list(map(int,input().split()))
DP = [0]
for i in range(1,N):
    if (A[i-1]+DP[i-1])-A[i] > 0:
        DP.append((A[i-1]+DP[i-1])-A[i])
    else:
        DP.append(0)
print(sum(DP))

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


def solve(D: int, N: int):
    ret = (100 ** D) * N
    if N == 100:
        ret = (100 ** D) * (N + 1)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(D, N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())

ans = 0
for i in range(1, N+1, 2):
    if i==1:
        continue
    count = 0
    for j in range(1, int(i**0.5)+1, 1):
        if i%j==0:
            count = count + 1
    if count==4:
        ans = ans + 1

print(ans)

Measured memory_bytes: 3060
import scala.io.StdIn._

object Main extends App {
  val n = readInt()
  val w = (1 to n).map(_ => readLine())
  if (w.toSet.toSeq.length == n && w.tail.zipWithIndex.forall { case (s, i) => s.startsWith(w(i).last.toString) })
    println("Yes")
  else
    println("No")
}


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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<int,int> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

string a, b;
int dp[3010][3010];

int solveR(int i, int j){
	if( (i < 0) or (j < 0) )
		return 0;
	if(dp[i][j] != -1)
		return dp[i][j];
	if(a[i] == b[j])
		return dp[i][j] = 1 + solveR(i-1, j-1);

	return dp[i][j] = max(solveR(i, j-1), solveR(i-1, j));
}

string recover(int x){
	string r;
	
	int i = sz(a)-1;
	int j = sz(b)-1;
	
	while( (i>=0) and (j>=0) ){
		if(a[i]==b[j]){
			r += a[i];
			i--;
			j--;
			
		}else if( (j>0) and (dp[i][j] == dp[i][j-1])){
			j--;
		}else{
			i--;
		}
	}
	
	return r;
}

int main() {
	memset(dp, -1, sizeof(dp));
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b;
	string res = recover(solveR(sz(a)-1, sz(b)-1) );
	reverse(all(res));
	
	cout << res << endl;
		
	return 0;	
}


Measured memory_bytes: 35968
# coding: utf-8
import fractions

n = int(input().rstrip())
numbers = [int(i) for i in input().rstrip().split(" ")]

l_list = [0 for i in range(n)]
l_list[0] = numbers[0]
for i in range(1, n):
    l_list[i] = fractions.gcd(l_list[i-1], numbers[i])

r_list = [0 for i in range(n)]
r_list[n-1] = numbers[n-1]
for i in reversed(range(0, n - 1)):
    r_list[i] = fractions.gcd(r_list[i+1], numbers[i])

ans = 0
for i in range(n):
    l = 0
    if i > 0:
        l = l_list[i - 1]
    r = 0
    if i < n - 1:
        r = r_list[i + 1]
    if l == 0:
        l = r
    if r == 0:
        r = l
    ans = max(ans, fractions.gcd(l, r))
print(ans)


Measured memory_bytes: 16164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

/**
 * Stove
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int N, K;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		K = parseInt(line.substring(line.indexOf(' ') + 1));

		int[] T = new int[N];
		int[] interval = new int[N - 1];

		for (int i = 0; i < N; i++) {
			T[i] = parseInt(br.readLine());
			if (i > 0) {
				interval[i - 1] = T[i] - T[i - 1] - 1;
			}
		}

		int ans = T[N - 1] - T[0] + 1;

		Arrays.sort(interval);

		for (int i = 0, j = N - 2; i < K - 1; i++, j--) {
			ans -= interval[j];
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 38096
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define ntuples(type1,type2,type3,v,n) vector<tuple<type1,type2,type3>> v(n);for(size_t i=0;i<(n);i++){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const &auto s, const &auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) acm(all(v),0l)

int main() {
  int n,k;
  cin>>n>>k;
  nvec(int, a, n);
  int i;
  for (i = 0; i < n; i++) {
    if(a[i]==1)break;
  }
  k-=1;
  cout<<ceil((n-1.0)/k);
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            int r = ReadInt();
            Console.WriteLine(r * r);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 int maxtime(int x){
   return ((x+9)/10)*10;
 }
 int diftime(int x){
   return maxtime(x) - x;
 }


int main() {
  int A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  int sum = 0;
 sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
 sum -= max({diftime(A),diftime(B),diftime(C),diftime(D),diftime(E)});
  cout << sum << endl;
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var a = next(), b = next(), m = next();
  var ai = nexts(a);
  var bi = nexts(b);
  var ans = Math.min(...ai) + Math.min(...bi);
  for(var i = 0; i < m; i++){
    var x = next(), y = next(), c = next();
    var t = ai[x-1] + bi[y-1] - c;
    if(t < ans)ans = t;
  }
  return ans;
}

Measured memory_bytes: 69712
N,M,V,P = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse= True)

def check(i):
  if i <= P-1:
    return True
  vote = (V-1)*M
  vote -= (N-1-i)*M
  vote -= (P-1)*M
  if vote <= 0:
    return A[i]+M >= A[P-1]
  else:
    for j in range(i-1,P-1,-1):
      if A[j] > A[i]+M:
        return False
      v = min(A[i]+M-A[j],M,vote)
      vote -= v
      if vote <= 0:
        break
    if vote <= 0:
      return A[i]+M >= A[P-1]
    else:
      return A[i]+M >= A[P-1]+vote

ok = -1
ng = N
while(ok+1 < ng):
  md = (ok+ng)//2
  if check(md):
    ok = md
  else:
    ng = md
print(ok+1)

Measured memory_bytes: 62640
#include <bits/stdc++.h>
using namespace std;
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;
}
using ll = long long;
 
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
//-------------------------------------
 
ll pow_mod(ll n, ll k, ll mod) {
    if(k == 0) {
        return 1;
    } else if(k % 2 == 1) {
        return pow_mod(n, k - 1, mod) * n % mod;
    } else {
        ll t = pow_mod(n, k / 2, mod);
        return t * t % mod;
    }
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, p=2019;
    //cin >> n ;
    string s;
    cin >> s;
n=s.size();
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) {
        a[i] = (ll)(s[i] - '0');
    }
    reverse(ALL(a));
    vector<int> sum(n + 1, 0);
    for(ll i = 0; i < n; i++) {
        sum[i + 1] = sum[i] + a[i] * pow_mod(10, i, p) % p;
        sum[i + 1] %= p;
    }
    map<ll, ll> mp;
    for(ll i = 0; i < n + 1; i++) {
        // cout << sum[i] << " ";
        mp[sum[i]]++;
    }
    // cout << endl;
    ll ans = 0;
    if(p == 2 || p == 5) {
        for(int i = 0; i < n; i++) {
            if(a[i] % p == 0) {
                ans += n - i;
            }
        }
        cout << ans << endl;
        return 0;
    }
    for(const auto &p : mp) {
        ans += (p.second - 1) * p.second / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5952
#include<stdio.h>

int main(){

int a,b;
scanf("%d",&a);
scanf("%d",&b);
if(a<b){
printf("a < b\n");
}

else if(a>b){
	printf("a > b\n");
}

else if(a==b){
	printf("a == b\n");
}

return 0;
}


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

const string MINUS_INF = "-";

void chmax(string &a, string b) {
  int a_sz = (int)a.size();
  int b_sz = (int)b.size();

  if(a == MINUS_INF) a = b;
  else if(a_sz < b_sz) a = b;
  else if(a_sz == b_sz) {
    if(a < b) a = b;
  }
}

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

  vector<int> matches{0,2,5,5,4,5,6,3,7,6};
  vector<int> a(m);
  rep(i,m) cin >> a[i];

  // dp[i]
  // マッチ棒をi本使った時にできる最大の数（文字列）
  vector<string> dp(n + 10, MINUS_INF);

  dp[0] = "";
  for (int i = 0; i <= n; i++) {
    if(dp[i] == MINUS_INF) continue;
    for (auto &it : a) {
      int match = matches[it];
      string number = to_string(it);
      chmax(dp[i + match], (dp[i] + number));
    }
  }
  cout << dp[n] << '\n';
}

Measured memory_bytes: 54648
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
int a[1050][1050];
int lastday[1050];
int stake[1050];
int main(){
	memset(lastday,0,sizeof(lastday));
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		stake[i]=1;
		for(int j=1;j<n;j++){
			cin>>a[i][j];
		}
	}
	int days=0;
	for(;;){
		days++;
		bool flag=0;
		for(int i=1;i<=n;i++){
			if(lastday[i]==days)continue;
			int j=a[i][stake[i]];
			if(lastday[j]==days||!j)continue;
			int r=stake[i],l=stake[j];
			if(stake[i]<n&&stake[j]<n&&a[j][l]==i){
				stake[i]=r+1,stake[j]=l+1;
				lastday[i]=days,lastday[j]=days;
				flag=1;
			}
		}
		if(!flag){
			days--;
			break;
		}
	}
	for(int i=1;i<=n;i++){
		if(stake[i]!=n){
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<days<<endl;
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

const int mod = 1e9+7;

struct Mod{
  int n;
  Mod() : n(0) {;}
  Mod(int m) : n(m){
    if(n>=mod) n%=mod;
    else if (n<0) n = (n%mod+mod)%mod;
  }
  operator int() {return n;}
};

Mod operator+=(Mod &a, Mod b) { a.n += b.n; if(a.n>=mod) a.n-=mod; return a; }
Mod operator-=(Mod &a, Mod b) { a.n -= b.n; if(a.n<0) a.n += mod; return a; }
Mod operator*=(Mod &a, Mod b) { a.n = ((long long)a.n * b.n) % mod; return a; }
Mod operator+(Mod a, Mod b) { return a+=b; }
Mod operator-(Mod a, Mod b) { return a-=b; }
Mod operator*(Mod a, Mod b) { return a*=b; }
Mod operator^(Mod a, int n) {
  if (n==0) return Mod(1);
  Mod res = (a*a) ^ (n/2);
  if (n%2) res = res * a;
  return res;
}
ll inv(ll a, ll p){
  return (a==1 ? 1 : (1-p*inv(p%a, a)) / a + p);
}
Mod operator/(Mod a, Mod b) { return a * Mod(inv(b.n, mod)); }
Mod fact[200005], factinv[200005];

void init(){
  fact[0] = Mod(1); factinv[0] = Mod(1);
  REP(i, 200004){
    fact[i+1] = fact[i] * Mod(i+1);
    factinv[i+1] = factinv[i] / Mod(i+1);
  }
}
Mod comb(int a, int b) {
  return fact[a] * factinv[b] * factinv[a-b];
}

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  init();
  Mod res(0);
  Mod N(n);
  Mod M(m);
  REP(i, n){
    Mod diff(n-i-1);
    res += comb(n*m-2, k-2) * diff * M * M * (N - diff);
  }
  REP(i, m){
    Mod diff(m-i-1);
    res += comb(n*m-2, k-2) * diff * N * N * (M - diff);
  }
  cout << int(res) << endl;
  return 0;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		int turnNum = 0;
		int player1Score = 0;
		int player2Score = 0;

		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));

		turnNum = Integer.parseInt(br.readLine());

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

			String[] playerAnimal = (br.readLine()).split(" ");

			int compareResult = playerAnimal[0].compareTo(playerAnimal[1]);

			if (compareResult > 0){
				player1Score += 3;
			} else if (compareResult < 0){
				player2Score += 3;
			} else if (compareResult == 0){
				player1Score += 1;
				player2Score += 1;
			}
		}
		System.out.println(player1Score + " " + player2Score);
	}
}

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

using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

#ifdef _LOCAL
struct Tester {
    Tester() { freopen("sample.in", "r", stdin); }
    ~Tester() { fprintf(stderr, "\nTime: %d ms\n", int(1000.0 * clock() / CLOCKS_PER_SEC)); }
} _tester;
#endif

const int INF = 0x3F3F3F3F;
const LL INFLL = 0x3F3F3F3F3F3F3F3FLL;
const int N = 1e5 + 10;
const int Q = 1e5 + 10;

map<string, int> mp;
string a[N];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sort(a[i].begin(), a[i].end());
        ++mp[a[i]];
    }
    LL ans = 0;
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        ans += 1LL * it->second * (it->second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N);

    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }

    ll ans = 0;
    for (int i = N-1; i >= 0; --i) {
        ll cost = 0;
        cost = (B[i] - ((A[i] + ans) % B[i])) % B[i];
        ans += cost;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1272
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int h,w;
  scanf("%d %d",&h,&w);
  char s[10];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      scanf("%s",s);
      if(strcmp(s,"snuke")==0)
        printf("%c%d\n",j+'A',i+1);
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>

// using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2*b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=510;
int n,m;
char s[N][N];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for (int i=1;i<=n;i++,puts(""))
	for (int j=1;j<=m;j++)
		putchar(j!=m&&(j==1||(i&1)||s[i][j]=='#')?'#':'.');
	puts("");
	for (int i=1;i<=n;i++,puts(""))
	for (int j=1;j<=m;j++)
		putchar(j!=1&&(j==m||!(i&1)||s[i][j]=='#')?'#':'.');
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

#include <iomanip>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > 12)
    {
        cout << b;
    }
    else if (a <= 12 && a >= 6)
    
    {
        cout << b / 2;
    }
    else if (a < 6 && a >= 0)
    {
        cout << 0;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

class Main {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int[] array = new int[N];
  long sum = 0;
  for( int i = 0; i < N; i++ ) {
   int x = sc.nextInt();
   array[i] = x;
   sum += x;
  }
  Arrays.sort(array);
  System.out.println(array[0] + " " + array[N-1] + " " + sum );
 }
} 


Measured memory_bytes: 41216
#include<stdio.h>
int main(){
	int a,cnt,x[5]={500,100,50,10,5},i,j;
	while(1){
		cnt=0;
		scanf("%d",&a);
		if(a==0)break;
		a=1000-a;
		for(i=0;i<5;i++){
			while(x[i]<=a){
				a=a-x[i];
				++cnt;
			}
		}
		
		printf("%d\n",cnt+a);
	}
	return 0;
}


Measured memory_bytes: 2012
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




int main() {
	string str,thr; cin >> str;
	int num, val,mins=10000;

	for (int i = 0; i < str.length()-2; i++) {
		thr = str.substr(i, 3);
		num = atoi(thr.c_str());
		mins = min(abs(num-753), mins);
	}
	cout << mins << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int ara[200009];
int ans[200009];
int val[200009];
    vector<int>v;
int divisors(int n)
{
    int z=sqrt(n);
    vector<int>v;
    for(int i=2;i*i<n;i++)
    {
        if(n%i==0)
        {
//            cout<<i<<"  "<<n/i<<endl;
            val[i]++;
            val[n/i]++;
        }
    }
    if(z*z==n)val[z]++;
}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>ara[i];
    for(int i=n;i>=2;i--)
    {
        if(val[i]%2!=ara[i])
        {
//            cout<<"i = "<<i<<endl;
            v.pb(i);
            divisors(i);
        }
    }
    if(ara[1]!=v.size()%2)v.pb(1);
    if(v.size()==0)cout<<0<<endl;
    else
    {
        cout<<v.size()<<endl;
        cout<<v[0];
        for(int i=1;i<v.size();i++)
        {
            cout<<" "<<v[i];
        }
        cout<<endl;
    }
}



Measured memory_bytes: 2808
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<atcoder/fenwicktree>
using namespace std;
using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n,q; cin >> n >> q;
    fenwick_tree<ll> fw(n);
    rep(i,n){
        int a; cin >> a;
        fw.add(i,a);
    }
    rep(i,q){
        int t; cin >> t;
        if(t == 0){
            int p,x; cin >> p >> x;
            fw.add(p,x);
        }
        else{
            int l,r; cin >> l >> r;
            cout << fw.sum(l,r) << "\n";
        }
    }
}



Measured memory_bytes: 8216
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL n = 0;

void dfs(string s, int m) {
    if(s.size() == n){
        PUTS(s);
        return;
    }
    REP(i, m + 1) {
        char c = 'a' + i;
        dfs(s + c, max(m, i + 1));
    }
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n;
    dfs("", 0);
}


Measured memory_bytes: 1536
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n,m;
    cin>>n>>m;
    vector<tuple<ll,ll,ll>> tp(m);
    rep(i,m){
        ll p,y;
        cin>>p>>y;
        tp[i]=mt(p,y,i);
    }
    sort(all(tp));
    vector<pair<ll,string>> P(m);
    ll cnt=1;
    rep(i,m){
        ll t=get<0>(tp[i]),digit=0;
        while(t!=0){
            digit++;
            t/=10;
        }
        rep(j,6-digit) P[i].sc+='0';
        P[i].sc+=to_string(get<0>(tp[i]));
        t=cnt;
        digit=0;
        while(t!=0){
            digit++;
            t/=10;
        }
        rep(j,6-digit) P[i].sc+='0';
        P[i].sc+=to_string(cnt);
        P[i].ft=get<2>(tp[i]);
        if(i<m-1){
            if(get<0>(tp[i])==get<0>(tp[i+1])) cnt++;
            else cnt=1;
        }
    }
    sort(all(P));
    rep(i,m) cout<<P[i].sc<<endl;
}

Measured memory_bytes: 11648
#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>;


const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//© 2020 GitHub, Inc.


int main() {
    int n;
    cin >> n;
    
    map<pair<ll,ll>,P> mp;
    
    int zero = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x==0 && y==0){
           zero++;
           continue;
        }
        
        ll g = gcd(x,y);
        x /= g;
        y /= g;
        
        if(y<0){
            x = -x;
            y = -y;
        }
        if (y==0 && x < 0){
            x = -x;
        }
        
        bool rot90 = false;
        if(x<=0){
            rot90 =true;
        }
        
        if(rot90){
            ll tmp = x;
            x=y;
            y= -tmp;
        }
        
        if(rot90){
            mp[{x,y}].first++;  
        }else{
            mp[{x,y}].second++;
        }
        
    }
    
    //ll mod = 1000000007;
    mint ans = 1;
    for(auto p:mp){
        int s = p.second.first;
        int t = p.second.second;
        mint now = 1;
        now += mint(2).pow(s) -1;
        //now = now % mod;
        now += mint(2).pow(t) -1;
        //now = now % mod;
        ans *= now;
        //ans = ans % mod;
    }
    
    ans -= 1;
    ans += zero;
    //ans = ans % mod;
    cout << ans << endl;

}


Measured memory_bytes: 16104
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {
  long data[8][1000];
  long ans = 0;
  int N, M;
  long tempx, tempy, tempz;
  long temp;
  scanf("%d%d", &N, &M);

  for (int i = 0; i < N; i++) {
    scanf("%ld%ld%ld", &tempx, &tempy, &tempz);
    data[0][i] = tempx + tempy + tempz;
    data[1][i] = tempx + tempy - tempz;
    data[2][i] = tempx - tempy + tempz;
    data[3][i] = tempx - tempy - tempz;
    data[4][i] = -tempx + tempy + tempz;
    data[5][i] = -tempx + tempy - tempz;
    data[6][i] = -tempx - tempy + tempz;
    data[7][i] = -tempx - tempy - tempz;
  }

  for (int loopcount = 0; loopcount < 8; loopcount++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; i + j < N - 1; j++) {
        if (data[loopcount][j] > data[loopcount][j + 1]) {
          temp = data[loopcount][j + 1];
          data[loopcount][j + 1] = data[loopcount][j];
          data[loopcount][j] = temp;
        }
      }
    }
    temp = 0;
    for (int i = 0; i < M; i++) {
      temp += data[loopcount][N - i - 1];
    }
    // for (int debug = 0; debug < N; debug++) {
    //   printf("%d ", data[loopcount][debug]);
    // }
    // printf("\n");
    if (ans < temp) ans = temp;
  }
  printf("%ld", ans);
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
dp = [[0, 0] for _ in range(N-1)]
dp[0][0] = A[0] + A[1]
dp[0][1] = -dp[0][0]

for i in range(1, N-1):
    dp[i][0] = max(dp[i-1][0] + A[i+1], dp[i-1][1] + A[i+1])
    dp[i][1] = max(dp[i-1][0] - 2 * A[i] - A[i+1], dp[i-1][1] + 2 * A[i] - A[i+1])

print(max(dp[-1]))


Measured memory_bytes: 24816
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define vi vector<ll>
#define pii pair<ll,ll>
#define bc __builtin_popcountll
#define vvi vector<vi> 
#define vpii vector<pair<ll,ll>>
#define mll unordered_map<ll,ll>
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define f(i,a,b) for(i=a;i<=b;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()-->returns an iterator to the k-th largest element (counting from zero)
//X.order_of_key()-->the number of items in a set that are strictly smaller than our item.
struct cmp
{
	bool operator() (ll a,ll b){
		return (a>b);
	}
};
ll mod=1000000007;
const ll N=100005;
int minimumChar(string S1, string S2) 
{ 
    int n = S1.size(), m = S2.size(); 
    int ans = INT_MAX; 
    for (int i = 0; i < m - n + 1; i++)
    { 
        int minRemovedChar = 0; 
        for (int j = 0; j < n; j++)
        { 
            if (S1[j] != S2[i + j])
            { 
                minRemovedChar++; 
            } 
        } 
        ans = min(minRemovedChar, ans); 
    } 
    return ans; 
} 
int main() 
{ 
    string S1,S2;
    cin>>S2>>S1;
  
    cout << minimumChar(S1, S2); 
  
    return 0; 
} 

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

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

	int N, K;
	scanf("%d %d", &N, &K);

	int tmp;
	vector<bool> D(10, true);
	for (int i = 0; i < K; i++) {
		scanf("%d", &tmp);
		D[tmp] = false;
	}

	int j, i10;
start:
	for (int i = 4; i >= 0; i--) {
		i10 = int(pow(10, i));
		if (i10 > N) {
			continue;
		}
		// printf("%d i10= %d\n", N, i10);
		while (true) {
			if (D[(N % (i10 * 10)) / i10] == true) {
				break;
			} else {
				N += i10;
				N = (N / i10) * i10;
				// N++;
				goto start;
			}
		}
	}

	printf("%d", N);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll a,b,c,d;
    cin >> a >> b>>c>>d;
    cout << min(a,b)+min(c,d) << endl;
    return 0;
}


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

for i in range(n):
    b, f, r, v = input().split()
    b = int(b)
    f = int(f)
    r = int(r)
    v = int(v)
    if info == []:
        info.append([b, f, r, v])
    else:
        for x in info:
            if b == x[0] and f  == x[1] and r == x[2]:
                x[3] += v
                isAdded = True
                break
            else:
                isAdded = False
        if isAdded == False:
            info.append([b, f, r, v])

for building in range(4):
    for floor in range(3):
        for room in range(10):
            print(" ", end = '')
            arePeople = False
            for y in info:
                if building + 1 == y[0] and floor + 1 == y[1] and room + 1 == y[2]:
                    print(y[3], end = '')
                    arePeople = True
            if arePeople == False:
                print("0", end = '')
        print('')
    if building < 3:
        print("####################")

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (b * 2 < a)
    {
        cout << (a - b * 2) << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256