akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int A[200000],n;
	cin>>n;
	 
	int i,j;
	
	for(i=0;i<n;i++)
	{
		cin>>A[i];
	}
	int maxv=-1000000000;
	int minv=A[0];
	for(i=1;i<n;i++)
	{
		maxv=max(maxv,A[i]-minv);
		minv=min(minv,A[i]);
		
	}
	cout<<maxv<<endl;
	return 0;
} 

Measured memory_bytes: 3892
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
S1 = input()
S2 = input()

if 1 < N and S1[0] == S1[1]:
	ans = 6
	tmp = 2
	flg = 1
else:
	ans = 3
	tmp = 1
	flg = 0


while tmp < N:
	if tmp < N-1 and S1[tmp] == S1[tmp+1]:
		if flg:
			ans *= 3
		else:
			ans *= 2
		flg = 1
		tmp += 2

	else:
		if flg:
			ans *= 1
		else:
			ans *= 2
		flg = 0
		tmp += 1
	ans %= mod


print(ans)




Measured memory_bytes: 10572
import java.util.*;

class Main
{
    public static void main(String [] args)
    {
       Scanner sc = new Scanner(System.in);
       int n;
       while((n = sc.nextInt())!=0)
        {
            Double sum=0.0, m=0., SD=0., temp=0.;
            Double s[] = new Double[n];
            for (int i = 0; i<n; i++)
            {
               s[i] = sc.nextDouble();
               sum += s[i]; 
            } 
            m = sum/n;
            for(int i = 0; i<n;i++)
            {
                temp += Math.pow((s[i]-m), 2);
            }
            SD = Math.sqrt(temp/n);
            System.out.printf("%.4f\n",SD);
        }
    }
}


Measured memory_bytes: 40548
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    String n = scan.nextLine();
    String s = scan.nextLine();

    String result = s.replaceAll("ABC", "0");

    int i = 0;
    int count = 0;
    while (i < result.length()) {
      if ("0".equals(String.valueOf(result.charAt(i)))) {
        count++;
      }
      i++;
    }
    System.out.println(count);

    scan.close();
  }
}

Measured memory_bytes: 21844
def resolve():
    import sys
    
    readline = sys.stdin.readline

    N, W = map(int, readline().split())
    lst = [list(map(int, readline().split())) for _ in [0] * N]
    
    dp = [[0] * (W + 1) for _ in [0] * N]

    for i in range(N):
        w, v = lst[i][0], lst[i][1]
        for sum_w in range(W + 1):
            if sum_w >= w:
                dp[i][sum_w] = max(dp[i][sum_w],
                                   dp[i - 1][sum_w - w] + v)
            dp[i][sum_w] = max(dp[i][sum_w], dp[i - 1][sum_w])
    print(max(dp[-1]))


resolve()


Measured memory_bytes: 151600
# Input
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
t = len(s)

a__ = [0]*(t+1)
ab_ = [0]*(t+1)
abc = [0]*(t+1)

MOD = 10**9 + 7
q = 0
for i, si in enumerate(s):
    if si == 'A':
        a__[i+1] = a__[i] + pow(3,q,MOD)
        ab_[i+1] = ab_[i]
        abc[i+1] = abc[i]

    elif si == 'B':
        a__[i+1] = a__[i]
        ab_[i+1] = ab_[i] + a__[i]
        abc[i+1] = abc[i]

    elif si == 'C':
        a__[i+1] = a__[i]
        ab_[i+1] = ab_[i]
        abc[i+1] = abc[i] + ab_[i]

    elif si == '?':
        a__[i+1] = 3 * a__[i] + pow(3,q,MOD)
        ab_[i+1] = 3 * ab_[i] + a__[i]
        abc[i+1] = 3 * abc[i] + ab_[i]

        q += 1


    a__[i + 1] %= MOD
    ab_[i + 1] %= MOD
    abc[i + 1] %= MOD

print(abc[t])

Measured memory_bytes: 15216
#include <stdio.h>

int main(){
	int i, j, n, m, sum=0, dummy;
	scanf("%d %d",&n,&m);
	int a[n];
	for(i=0;i<n;i++) {
      scanf("%d",&a[i]);
	 sum+=a[i];
    }
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[i]<a[j]) {
				dummy = a[i];
				a[i] = a[j];
				a[j] = dummy;
			}
		}
	}
	if(4*m*a[m-1]<sum) puts("No");
	else puts("Yes");
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int main()
{
	float n,i,j,k,ans=0;
	string x;
	cin>>i;
	cin>>j;
	ans=j*2-i;
	cout<<ans;
	return 0;
}
	


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        new Solver().solve(new Scanner(System.in));
//        new Solver().solve(new Scanner(ex));
    }

    private static final String ex = "?tc????\n" +
        "coder";
//    private static final String ex = "?t?????\n" +
//        "coder";
//    private static final String ex = "??p??d??\n" +
//            "abc\n";
}

class Solver {
    void solve(Scanner scanner) {
        char[] S = scanner.nextLine().toCharArray();
        char[] T = scanner.nextLine().toCharArray();

        for (int i = S.length - 1; i >= 0; i --) {
            if ((S[i] == '?' || S[i] == T[0]) && i + T.length <= S.length) {
                boolean flag = true;
                for (int j = 0; j < T.length; j ++) {
                    if (!(S[i + j] == T[j] || S[i + j] == '?')) {
                        flag = false;
                    }
                }
                if (flag) {
                    for (int j = 0; j < T.length; j ++) {
                        S[i + j] = T[j];
                    }

                    for (int k = 0; k < S.length; k++) {
                        if (S[k] == '?') S[k] = 'a';
                    }
                    System.out.println(new String(S));
                    System.exit(0);
                }
            }
        }

        System.out.println("UNRESTORABLE");
    }

    private int[] splitInt(String s) {
        String[] split = s.split(" ");
        int[] splitInt = new int[split.length];
        for (int i = 0; i < split.length; i ++) {
            splitInt[i] = Integer.parseInt(split[i]);
        }
        return splitInt;
    }

    private long[] splitLong(String s) {
        String[] split = s.split(" ");
        long[] splitLong = new long[split.length];
        for (int i = 0; i < split.length; i ++) {
            splitLong[i] = Long.parseLong(split[i]);
        }
        return splitLong;
    }
}


Measured memory_bytes: 21844
#include <string>
#include <iostream>
#include <sstream>

long long unsigned int __gcd(long long unsigned int a, long long unsigned int b)
{
//    std::cout << "in __gcd\n";
//    std::cout << "a: " << a << "\nb: " << b << '\n';
    if (b % a == 0) {
//        std::cout << "returning " << a << '\n';
        return a;
    } else {
        return __gcd(b % a ,a);
    }
}

long long unsigned int gcd(long long unsigned int a, long long unsigned int b)
{
    if (a > b)
        return __gcd(b, a);
    return __gcd(a, b);
}

long long unsigned int lcm(long long unsigned int a, long long unsigned int b)
{
    return a * b / gcd(a, b);
}

int main(void)
{
    int a, b;
    std::string str;

    while (getline(std::cin, str)) {
        std::istringstream str_s(str);
        str_s >> a >> b;

        std::cout << gcd(a, b) << ' ' << lcm(a, b) << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
  	ll n,d;cin>>n>>d;
  	double x[n][d]; rep(i,0,n)rep(j,0,d) cin >> x[i][j];
  	
  	ll ans = 0;
  	rep(i,0,n){
        rep(j,i+1,n){
            ll d2 = 0;
            rep(k,0,d) d2 += pow(x[i][k] - x[j][k],2);
          	if(d2 == (ll)sqrt(d2)*(ll)sqrt(d2)) ans++;
        }
    }
    cout << ans << ednl;
   
}


Measured memory_bytes: 256
use std::collections::VecDeque;

const INF: u64 = 1e15 as u64;

const DX: [i64; 4] = [0, 0, 1, -1];
const DY: [i64; 4] = [1, -1, 0, 0];

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let h: usize = sc.read();
    let w: usize = sc.read();
    let k: u64 = sc.read();
    let s: Vec<Vec<char>> = (0..h).map(|_| sc.chars()).collect();
    let mut dist = vec![vec![INF; w]; h];
    let mut q = VecDeque::new();
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == 'S' {
                dist[i][j] = 0;
                q.push_back((i, j));
            }
        }
    }

    while let Some((i, j)) = q.pop_front() {
        if i == 0 || j == 0 || i == h - 1 || j == w - 1 {
            println!("1");
            return;
        }
        for d in 0..4 {
            let ni = (i as i64) + DX[d];
            let nj = (j as i64) + DY[d];
            if ni < 0 || nj < 0 || ni >= (h as i64) || nj >= (w as i64) {
                continue;
            }
            let ni = ni as usize;
            let nj = nj as usize;
            if dist[ni][nj] > dist[i][j] + 1 && s[ni][nj] != '#' && dist[i][j] + 1 <= k {
                dist[ni][nj] = dist[i][j] + 1;
                q.push_back((ni, nj));
            }
        }
    }

    for i in 0..h {
        for j in 0..w {
            if dist[i][j] != INF {
                dist[i][j] = k;
                q.push_back((i, j));
            }
        }
    }

    while let Some((i, j)) = q.pop_front() {
        if i == 0 || j == 0 || i == h - 1 || j == w - 1 {
            println!("{}", (dist[i][j] + k - 1) / k);
            return;
        }
        for d in 0..4 {
            let ni = (i as i64) + DX[d];
            let nj = (j as i64) + DY[d];
            if ni < 0 || nj < 0 || ni >= (h as i64) || nj >= (w as i64) {
                continue;
            }
            let ni = ni as usize;
            let nj = nj as usize;
            if dist[ni][nj] > dist[i][j] + 1 {
                dist[ni][nj] = dist[i][j] + 1;
                q.push_back((ni, nj));
            }
        }
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 12668
H,W = map(int,input().split())
S = []
for i in range(H):
    S.append(input())

a = [ [ 0 for i in range(W)] for j in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            a[i][j] = "#"
            for p in [-1,0,1]:
                for q in [-1,0,1]:
                    if i+p >= 0 and j+q >= 0 and i+p < H and j+q < W and S[i+p][j+q] != "#":
                        a[i+p][j+q] += 1


for i in range(H):
    print(''.join(map(str,a[i])))


Measured memory_bytes: 41712
def bubble(N, A):
  count = 0
  flag = True
  while flag:
    flag = False
    for i in range(N-1, 0, -1):
      if A[i-1] > A[i]:
        count += 1
        A[i], A[i-1] = A[i-1], A[i]
        flag = True

  return count, A

n = int(raw_input())
a = map(int, raw_input().split())
count, a = bubble(n,a)

print ' '.join(map(str, a))
print count


Measured memory_bytes: 4652
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#K, S = map(int, input().split())
N = int(input())
S = str(input())

m = 0
x = 0
for i in range(N) :
  if S[i] == "I" :
    x += 1
    m = max(m, x)
  else :
    x -= 1

print (m)


Measured memory_bytes: 39760
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
A = sorted([X[i][0] for i in range(N)])
B = sorted([X[i][1] for i in range(N)])
if N%2==1:
    a = A[N//2]
    b = B[N//2]
    print(b-a+1)
else:
    a = (A[N//2]+A[N//2-1])
    b = (B[N//2]+B[N//2-1])
    print(b-a+1)

Measured memory_bytes: 136284
N = int(input())
A = list(map(int, input().split()))
n = N
ans = -1
while n == N:
    n = 0
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] //= 2
            n += 1
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n';
int lim=1e5;
int inf=1e9+7;
bool solve(int val,int k,int n,ll* w,int* v,vector<vector<int> > &dp,vector<vector<ll> > &bt){
	if(k==n){
		if(val==0){
			return true;
		}else{
			return false;
		}
	}else if(dp[val][k]!=-1){
		return dp[val][k];
	}else{
		ll choose1=-1;
		bool a1=solve(val,k+1,n,w,v,dp,bt);bool a2=0;
		if(a1){
			if(k<n-1){
				choose1=bt[val][k+1];
			}else{
				choose1=0;
			}
		}
		ll choose2=-1;
		if(val>=v[k]){
			a2=solve(val-v[k],k+1,n,w,v,dp,bt);
			if(a2){
				if(k<n-1){
					choose2=w[k]+bt[val-v[k]][k+1];
				}else{
					choose2=w[k];
				}
			}
		}
		if(a1 and a2){
			dp[val][k]=1;
			if(choose1<choose2){
				bt[val][k]=choose1;
			}else{
				bt[val][k]=choose2;
			}
		}else if(a1){
			dp[val][k]=1;
			bt[val][k]=choose1;
		}else if(a2){
			dp[val][k]=1;
			bt[val][k]=choose2;
		}else{
			dp[val][k]=0;
		}
		return dp[val][k];
	}
}
int main()
{	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;cin>>n;
	ll W;cin>>W;
	ll w[n];int v[n];
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	} 
	vector<vector<int> > dp(lim+1,vector<int>(n,-1));
	vector<vector<ll> > bt(lim+1,vector<ll>(n,-1));
	for(int i=0;i<=lim;i++){
		for(int j=0;j<n;j++){
			dp[i][j]=solve(i,j,n,w,v,dp,bt);
		}
	}
	bool done=0;
	for(int i=lim;i>=0;i--){
		if(done){
			break;
		}
		for(int j=0;j<n;j++){
			if(dp[i][j] and (bt[i][j]<=W)){
				cout<<i<<ln;
				done=1;
				break;
			}
		}
	}
}

Measured memory_bytes: 127360
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,maxi = 0;
    cin >> n;
    int arr[n];
    for(int i = 0;i<n;i++){
        cin >> arr[i];
    }
    for(int i  = 0;i<n;i++){
        for(int j = i+1;j<n;j++){
            maxi = max(maxi,abs(arr[i]-arr[j]));
        }
    }
    cout << maxi <<endl;

}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


def solve():
    X = int(input())

    ans = (X // 500) * 1000
    X %= 500
    ans += (X // 5) * 5
    return ans


def main():
    print(solve())


if __name__ == '__main__':
    main()


Measured memory_bytes: 9844
n = int(input())
xy_array = [list(map(int, input().split())) for _ in range(n)]

th = pow(10, 9)
right_up_max = -th
left_down_min = th
left_up_max = -th
right_down_min = th

for x, y in xy_array:
    right_up_max = max(x + y, right_up_max)
    left_down_min = min(x + y, left_down_min)
    left_up_max = max(x - y, left_up_max)
    right_down_min = min(x - y, right_down_min)

ans = max(right_up_max - left_down_min, left_up_max - right_down_min)
print(ans)

Measured memory_bytes: 45324
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(string str) {
  int h[200][30];
  REP(i, 200) REP(j, 30) { h[i][j] = 10000; }

  for (int i = str.size() - 1; i >= 0; --i) {
    int base = str[i] - 'a';
    for (int j = i; j >= 0; --j) {
      h[j][base] = min(h[j][base], i - j);
    }
  }

  int ans = 10000;

  // bool f = true;
  // for (int i = 1; i < str.size(); ++i) {
  //   if (str[0] != str[i])
  //     f = false;
  // }
  // if (f) {
  //   cout << "0" << endl;
  //   return;
  // }

  REP(i, str.size()) {

    int mi = 1000;
    REP(k, 'z' - 'a' + 1) {
      int buf = 0;
      REP(j, str.size() - i) { buf = max(buf, h[j][k]); }
      mi = min(mi, buf);
      // cout << ((char)('a' + k)) << " " << buf << endl;
    }
    // cout << "i: " << i << endl << endl;

    if (i >= mi) {
      cout << (i) << endl;
      return;
    }
  }

  cout << str.size() - 1 << endl;
}

int main() {
  ios::sync_with_stdio(false);
  string str;
  cin >> str;
  solve(str);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int h, w;
    cin >> h >> w;
    vvint a(h, vint(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    
    string ans = "";
    int n = 0;
    rep(i, h) rep(j, w) {
        if (a[i][j] % 2 == 0) continue;
        bool c = false;
        if (j < w-1) {
            a[i][j+1]++;
            ans += to_string(i+1) + " ";
            ans += to_string(j+1) + " ";
            ans += to_string(i+1) + " ";
            ans += to_string(j+2) + "\n";
            n++;
            if (a[i][j+1] % 2 == 1) c = true;
        }
        else if (i < h-1 && c == false) {
            a[i+1][j]++; 
            ans += to_string(i+1) + " ";
            ans += to_string(j+1) + " ";
            ans += to_string(i+2) + " ";
            ans += to_string(j+1) + "\n";
            n++;
        }
    }

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

Measured memory_bytes: 5124
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename T,T MOD,T B>
struct RollingHash{
  using ll = long long;
  vector<T> hash,p;
  RollingHash(){}
  RollingHash(vector<T> vs){init(vs);}
  RollingHash(string &s){
    vector<T> vs;
    for(char c:s) vs.emplace_back(c);
    init(vs);
  }
  void init(vector<T> vs){
    int n=vs.size();
    hash.assign(n+1,0);
    p.assign(n+1,1);
    for(int i=0;i<n;i++){
      hash[i+1]=((ll)hash[i]*B+vs[i])%MOD;
      p[i+1]=(ll)p[i]*B%MOD;
    }
  }
  //S[l, r)
  T find(int l,int r){
    T res=(ll)hash[r]+MOD-(ll)hash[l]*p[r-l]%MOD;
    return res>=MOD?res-MOD:res;
  }
};


template<typename T,T MOD,T B1,T B2>
auto rectangle_hash(vector<string> vs,int r,int c){
  vector< RollingHash<T, MOD, B1> > hs;
  for(string s:vs) hs.emplace_back(s);

  int h=vs.size(),w=vs[0].size();
  vector< vector<T> > res(h-r+1,vector<T>(w-c+1));

  for(int j=0;j+c<=w;j++){
    vector<T> ts(h);
    for(int i=0;i<h;i++)
      ts[i]=hs[i].find(j,j+c);

    RollingHash<T, MOD, B2> rh(ts);
    for(int i=0;i+r<=h;i++)
      res[i][j]=rh.find(i,i+r);
  }
  return res;
}

//INSERT ABOVE HERE

int conv(char c){
  if(isupper(c)) return c-'A';
  if(islower(c)) return 26+c-'a';
  if(isdigit(c)) return 52+c-'0';
  if(c=='+') return 62;
  if(c=='/') return 63;
  assert(0);
}

vector<string> decode(vector<string> vs,int h,int w){
  vector<string> rs(h,string(w,'$'));
  for(int i=0;i<h;i++)
    for(int j=0;j<(int)vs[i].size();j++)
      for(int k=0;k<6&&j*6+k<w;k++)
        rs[i][j*6+k]=char('0'+((conv(vs[i][j])>>(5-k))&1));
  return rs;
}

signed main(){
  int w,h,p;
  while(cin>>w>>h>>p,w){
    vector<string> ss(h);
    for(int i=0;i<h;i++) cin>>ss[i];

    vector<string> ts(p);
    for(int i=0;i<p;i++) cin>>ts[i];

    const int MOD = 1e9+7;
    const int B1 = 1777771;
    const int B2 = 1e8+7;
    auto srh=rectangle_hash<int, MOD, B1, B2>(decode(ss,h,w),p,p);

    vector< vector<int> > found(h,vector<int>(w,0));

    auto pat=decode(ts,p,p);
    for(int rev=0;rev<2;rev++){
      for(int rot=0;rot<4;rot++){
        auto tmp(pat);
        for(int i=0;i<p;i++)
          for(int j=0;j<p;j++)
            pat[i][j]=tmp[j][p-(i+1)];

        auto val=rectangle_hash<int, MOD, B1, B2>(pat,p,p)[0][0];

        for(int i=0;i<h-p+1;i++)
          for(int j=0;j<w-p+1;j++)
            if(srh[i][j]==val) found[i][j]=1;
      }

      for(auto &s:pat)
        reverse(s.begin(),s.end());
    }

    int cnt=0;
    for(int i=0;i<h-p+1;i++)
      for(int j=0;j<w-p+1;j++)
        if(found[i][j]) cnt++;

    cout<<cnt<<"\n";
  }
  cout<<flush;
  return 0;
}



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

int main(){
  int X, A, B;
  cin >> X >> A >> B;

  if (A >= B){
    cout << "delicious" << endl;
  }
  else if ((B-A) <= X)
  {
    cout << "safe" << endl;
  }
  else
  {
    cout << "dangerous" << endl;
  }
  
  
}

Measured memory_bytes: 3608
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int w = scan.nextInt();
    int h = scan.nextInt();
    int x = scan.nextInt();
    int y = scan.nextInt();
    int r = scan.nextInt();
    if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 26208
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

lli ways[101][100001];

void solve(){
	lli n,k;
	cin>>n>>k;
	lli arr[n];
	fr(i,n)cin>>arr[i];
	ways[0][0]=1;
	fr(i,n){
		rep(j,0,k){
			if(ways[i][j]){
				ways[i+1][j]=(ways[i+1][j]+ways[i][j])%MOD;
				if(j+arr[i]+1<=k)ways[i+1][j+arr[i]+1]=(ways[i+1][j+arr[i]+1]-ways[i][j]+MOD)%MOD;

			}
		}
		rep(j,1,k){
			ways[i+1][j]=(ways[i+1][j-1]+ways[i+1][j])%MOD;
		}
	}
	cout<<ways[n][k]<<endl;
}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	pre();lli t=1;//cin>>t;
	for(lli i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

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

void swap(int &x, int &y) {
	int tmp;
	tmp = x;
	x = y;
	y = tmp;
}

int main() {
	int x, y;
	while (cin >> x >> y, x + y) {
		if (x > y) {
			swap(x, y);
		}
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

cnt=1
for i in range(N):
    if A[i]%2==0:
        # 自身が偶数なら似ている奇数は2つ
        cnt*=2
    else:
        # 自身が奇数なら1つ
        cnt*=1

# 全体 - 全ての項の積が奇数
print(3**N-cnt)


Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
N, M = list(map(int, input().split()))
a = list(map(int, input().split()))

count = 0
for i in range(N):
    if a[i] >= sum(a) * 1 / (4 * M):
        count += 1

if count >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; ll sum = 0;
  vl score(n); rep(i,n){ ll x; cin >> x; score[i] = x; sum += x;}
  
  sort(all(score));
  
  if((sum % 10) != 0) cout << sum << endl;
  else{
    ll ans = -1;
    for(ll i=0; i < n; i++){
      if((score[i] % 10) != 0){
        ans = score[i];
        break;
      }
    }
    
    if(ans == -1) cout << 0 << endl;
    else cout << sum - ans << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    Set<Integer> s=new HashSet<>(1000000);
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
      if(s.contains(a[i])){
        s.remove(a[i]);
      }else{
        s.add(a[i]);
      }
    }
    System.out.println(s.size());
  }
}

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

using namespace std;

using lint = long long;
using ldouble = long double;

bool solve() {
    int N, L, R;
    cin >> N >> L >> R;
    if (N == 0) return false;

    vector<int> A(N);
    for (auto& a : A) cin >> a;

    int ans = 0;
    for (int x = L; x <= R; ++x) {
        int i;
        for (i = 0; i < N; ++i) {
            if (x % A[i] == 0) break;
        }

        ans += (i % 2 == 0);
    }

    cout << ans << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
using namespace std;
long f[1<<17]={1},a[1<<17],n,M=1e9+7,c[1<<17],x,y;
long pow(long a,int b){return b?pow(a*a%M,b/2)*(b&1?a:1)%M:1;}
long com(long a,long b)
{
	if(a<b||b<0)return 0;
	else return f[a]*pow(f[a-b],M-2)%M*pow(f[b],M-2)%M;
}
main()
{
	cin>>n;
	for(int i=0;i<n+1;i++)
	{
		cin>>a[i];
		f[i+1]=f[i]*(i+1)%M;
		if(c[a[i]])
		{
			x=c[a[i]]-1;
			y=i;
		}
		else c[a[i]]=i+1;
	}
	for(int i=0;i++<=n;)
	{
		long ans=0;
		ans+=com(n-1,i);
		ans=(ans-com(x+n-y,i-1)+2*com(n-1,i-1)+M)%M;
		ans=(ans+com(n-1,i-2))%M;
		cout<<ans<<endl;
	}
}

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

#define SIZE 200000

using namespace std;

int main(void) {
	int n, max, min, tmp;

	cin >> n;
	
	cin >> tmp >> max;

	min = max;
	max -= tmp;
	min = (tmp < min) ? tmp : min;

	for (int i = 0; i < n-2; i++) {
		cin >> tmp;
		max = (max < tmp - min) ? (tmp - min) : max;
		min = (tmp < min) ? tmp : min;
	}

	std::cout << max << "\n";
	
	return 0;
}

Measured memory_bytes: 3104
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
d= [abs(x[i] - y[i]) for i in range(n)]
for i in range(1, 4):
    a = 0
    for j in d:
        a += j**i
    print("{:.6f}".format(a**(1/i)))
print("{:.6f}".format(max(d)))


Measured memory_bytes: 5656
#include <cstdlib>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
	int N;
	ll modi = 1e9 + 7;
	ll power = 1;
	cin >> N;
	
	rep(i, N)
	{
		power *= (i + 1);
		power = power % modi;
	}
	
	cout << power << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){ 
	map<string,int> m;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		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;

}



Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <utility>
using namespace std;
const int N = 1e5 + 100;
int n, l[N], r[N], p, q;
int my[N];
pair<int, int>k[N];
bool cmp(const pair<int,int>&x,const pair<int,int>&y) {
    if (x.first == y.first) return x.second > y.second;
    return x.first > y.first;
}
int main() {
    ios::sync_with_stdio(0);
    cin >> n;
  //  int mx = 1, mn = 1;
    p = q = 1;
    for (int i = 1; i <= n; i++) {
        cin >> l[i] >> r[i];
        if (l[i] > l[p]) p = i;
        if (r[i] < r[q]) q = i;
    }
  //  cout << p << " " << q << endl;
    int mx = 0;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        //if (i == p || i == q) continue;
        //x[i] =
        k[++cnt] = make_pair(max(r[i] - l[p] + 1, 0), max(r[q] - l[i] + 1, 0));
        if (r[i] - l[i] + 1 > mx) mx = r[i] - l[i] + 1;
    }
    sort(k + 1, k + cnt + 1, cmp);
    //for (int i = 1; i<= cnt; i++) cout << k[i].first << " " << k[i].second << endl;; cout << endl;
    my[cnt] = k[cnt].second;
    for (int i = cnt - 1; i; i--) my[i] = min(k[i].second, my[i + 1]);
    int ans = max(0, r[q] - l[p] + 1) + mx;
	if (p == q) {cout << ans << endl; return 0;}
   // cout << ans << endl;
    if (n <= 2) ans = 0;
    int tmp = k[1].first;
    for (int i = 1; i <= n - 1; i++) {
      //  cout << tmp << endl;
     //   tmp = min(tmp, k[i].first);
       // cout << tmp << " --- " << my[i + 1] << endl;;
        ans = max(ans, k[i].first + my[i + 1]);
    }
    cout << ans << endl;
}
    


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

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << b + min(a + b + 1, c);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=15;

char a[N][N],b[N][N];
int n,m,match[N],use[N];

inline int Equal(int x,int y) {
	for (int i=1;i<=n;i++) {
		if (b[i][x]!=b[n-i+1][y]) return 0;
	}
	return 1;
}

inline void check() {
	int res=m&1;
	memset(use,0,sizeof(use));
	int now=1;
	for (int i=1;i<=n;i++) {
		if (i==match[i]) {
			for (int j=1;j<=m;j++)
				b[(n+1)>>1][j]=a[i][j];
		}
		if (i<match[i]) {
			for (int j=1;j<=m;j++) {
				b[now][j]=a[i][j];
				b[n-now+1][j]=a[match[i]][j];
			}
			++now;		
		}
	}		
	for (int i=1;i<=m;i++) {
		if (use[i]) continue;
		for (int j=i+1;j<=m;j++)
			if (!use[j]&&Equal(i,j)) {
				use[i]=j; use[j]=i;
				break;
			}
		if (!use[i])
			if (--res<0) return;
	}
	puts("YES"); exit(0);
}

void dfs(int x,int res) {
	if (x==n+1) return (void) (check());
	if (match[x]) return (void) (dfs(x+1,res));
	if (res) {
		match[x]=x;
		dfs(x+1,0);
		match[x]=0;
	}
	for (int i=x+1;i<=n;i++) {
		if (!match[i]) {
			match[i]=x; match[x]=i;
			dfs(x+1,res);
			match[i]=0; match[x]=0;
		}
	}
}

int main() {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",a[i]+1);
	dfs(1,n&1);
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	b := make([]int, n)
	for i := range b {
		b[i] = scanInt()
	}

	ans := make([]int, 0, n)
	for {
		if len(b) == 0 {
			break
		}
		for i := len(b) - 1; i >= 0; i-- {
			if b[i] == i+1 {
				ans = append(ans, b[i])
				b = append(b[:i], b[i+1:]...)
				break
			}

			if i == 0 {
				fmt.Println(-1)
				return
			}
		}
	}

	wr := bufio.NewWriter(os.Stdout)
	for i := n - 1; i >= 0; i-- {
		wr.WriteString(strconv.Itoa(ans[i]) + "\n")
	}
	wr.Flush()
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  for (auto &a: A)
    cin >> a;
  int64_t S = 0;
  vector<int64_t> D(int(1e5 + 1));
	for (auto &a: A){
      D[a]++;
  		S += a;
}
  
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
  	int b, c;
    cin >> b >> c;
    S -= b * D[b];
    S += c * D[b];
    D[c] += D[b];
    D[b] = 0;
    cout << S << endl;
  }

}

Measured memory_bytes: 4144
#include<bits/stdc++.h>
typedef unsigned long long ullong;
const static ullong M = 1000000007;
// ullong res;

ullong power(ullong x, ullong n){
    ullong res = 1;
    if(n == 0){
        return 1;
    }
    res = power( (x * x)  % M, n / 2);
    if(n % 2 == 1){
        res = (res * x) % M;
    }
    return res;
}

int main(void){
    ullong a;
    ullong b;
    std::cin >> a >> b;
    
    std::cout << power(a, b) << std::endl;

    return 0;
}


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

int main() {
  int N, M; cin >> N >> M;
  string S; cin >> S;
  const int INF = 1000000007;
  vector<int> dp(N+1, INF);
  dp.at(N) = 0;
  queue<int> q;
  q.push(0);
  for (int i = N-1; i >= 0; i--) {
    while (1) {
      if (q.size() == 0) { cout << -1 << endl; return 0; }
      if (q.front() != INF && q.size() <= M) break;
      q.pop();
    }
    if (S.at(i) == '0') dp.at(i) = q.front() + 1;
    q.push(dp.at(i));
  }
  vector<int> ans;
  int x = 0;
  int rest = dp.at(0);
  while (x < N) {
    rest--;
    int i = 1;
    while (dp.at(x+i) != rest) i++;
    ans.push_back(i);
    x += i;
  }
  for (int i = 0; i < ans.size(); i++) {
    if (i) cout << " ";
    cout << ans.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 1528
T = int(input())
for _ in range(T):
    N = int(input())
    A = [int(i) for i in input().split()]
    S = input()

    B = []
    ans = 0
    for a, s in zip(reversed(A), reversed(S)):
        for b in B:
            a = a if a < a ^ b else a ^ b

        if a:
            if s == "1":
                ans = 1
                break
            B.append(a)

    print(ans)

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

using namespace std;


int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    
    int k;
    cin >> k;
    int cur = 7 % k;
    for (int i = 0; i < 3 * k; ++i) {
        if(!cur) {
            cout << i + 1;
            return 0;
        }
        cur = (cur * 10 + 7) % k;
    }
    cout << "-1";

}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;

signed main(){
  string s;
  cin>>s;
  int n;
  cin>>n;
  
  string ans;
  for(int i=0; i<s.size(); i++){
    if(i%n==0){
      ans+=s[i];
    }
  }
  
  cout<<ans<<en
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define x first 
#define y second

bool issafe(pair<int,int> p, pair<int,int> q){
  if( p.x == q.x || p.y == q.y ){ return false;}
  if( (p.x-q.x == p.y-q.y) || (p.x-q.x == q.y-p.y) ){ return false;}
  
  return true;
}
  

signed main(void){
  int N; cin >> N;
  map<pair<int,int>,bool> mp;
  for(int i = 0; i < N; i++){ 
    int r,c; cin >> r >> c;
    mp[{r,c}] = true;
  }
  vector<vector<char>> ans(8,vector<char>(8,'.'));
  vector<int> id(8);
  for(int i = 0; i < 8; i++){ id[i] = i;}
  do{
    vector<pair<int,int>> vec;
    int cnt = 0;
    for(int i = 0; i < 8; i++){ 
      vec.push_back({i,id[i]});
      if( mp[{i,id[i]}] ){ cnt++; }
    }
    
    if( cnt != N ){ continue;} 
    
    //暫定の配置が果たして可能かどうかを調べる
    
    bool flag = true;
    
    for(int i = 0; i < 8; i++){
      for(int j = i+1; j < 8; j++){
        
        auto p = vec[i]; auto q = vec[j];
        
        if(!issafe(p,q)){ flag = false;}
        
      }
      
    }
    
    if(flag){ 
      
      for(auto check : vec){
        ans[check.first][check.second] = 'Q';
      }
      
      for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
          cout << ans[i][j];
        }
        cout<< endl;
      }
      
      return 0;
      
    }//if-flag
    
  }while(next_permutation(id.begin(),id.end()));
  
  return 0;
}
  


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];

bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    return(b%a,a);
}

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}

int main()
{
    ios_base::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    ll hold = a-b;
    c = c-hold;
    if(c<0)
    {
        c=0;
    }
    show((c));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// ソースコードの数
        int m = sc.nextInt();// 整数の数
        int c = sc.nextInt();// 定数C

        int[] bArr = new int[m];
        int[][] aArr = new int[n][m];

        for (int i = 0; i < m; i++) {
            bArr[i] = sc.nextInt();
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                aArr[i][j] = sc.nextInt();
            }
        }

        int res = 0;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += aArr[i][j] * bArr[j];
            }
            sum += c;
            if (sum > 0) res++;
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 24148
"use strict";
const main = arg => {
  let Nums = arg.split("\n");
  let NumArr = Nums[1].split(" ").map(x=> x*1);
  let MotuerSum = 0;
  for(let i = 0; i < Nums[0]; i++){
  	MotuerSum += 1/NumArr[i];
  }
  console.log(1/MotuerSum);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	return S[top--];
}

int main() {
	int a, b;
	top = 0;
	char s[100];

	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			b = pop();
			a = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			b = pop();
			a = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}

	cout << pop() << endl;

	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

long long ruijou(int n, int k){
    if(k==0) return 1;
    int x=k/2;
    long long t=ruijou(n,x);
    
    if(k%2==1) return n*t*t;
    else return t*t;
}

int main(){
    vector<double> v;
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        double x;
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    double ans=0;

    for(int i=0;i<N;i++){
        if(i==0) ans+=(v.at(i)/ruijou(2,N-1));
        else ans+=(v.at(i)/ruijou(2,N-i));
    }

    cout<<setprecision(10)<<ans<<endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>

uintmax_t gcd(uintmax_t m, uintmax_t n) {
  while (n) std::swap(m%=n, n);
  return m;
}

// d..n..s..u..s..r..a..y..u..k..u..a..i..i..a..
// d....u....j....r....u....n....u....m....a....

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  char buf[131072];
  scanf("%s", buf);
  std::string s=buf;
  scanf("%s", buf);
  std::string t=buf;

  uintmax_t g=gcd(N, M);
  uintmax_t lcm=N/g*M;

  for (uintmax_t i=0; i<N; i+=lcm/M) {
    fprintf(stderr, "%c %c\n", s[i], t[i*M/N]);
    if (s[i] != t[i*M/N]) return !printf("-1\n");
  }

  for (uintmax_t i=0; i<M; i+=lcm/N) {
    fprintf(stderr, "%c %c\n", t[i], s[i*N/M]);
    if (t[i] != s[i*N/M]) return !printf("-1\n");
  }

  printf("%ju\n", lcm);
}


Measured memory_bytes: 512