akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
bool check[maxn];
main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        if(x!=i)check[i]=1;
    }
    int cnt=0;
    for(int i=1;i<n;i++)
    {
        if(!check[i])cnt++,check[i]=1,check[i+1]=1;
    }
    if(!check[n])cnt++;
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int main(){
	int x,a,b;
	cin>>x>>a>>b;
	int ax=abs(a-x);
	int bx=abs(b-x);
	if(ax>bx){
		cout<<"B"<<endl;
	}else if(ax<bx){
		cout<<"A"<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n,m;
    cin >> n >>m;
    priority_queue<int > q;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        q.push(a);
    }
    for(int i=0;i<m;i++){
        int a=q.top();q.pop();
        q.push(a/2);
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=q.top();q.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scanf("%d", &x)

	var ans int
	if x >= 500 {
		ans += (x / 500) * 1000
		x %= 500
	}
	if x >= 5 {
		ans += (x / 5) * 5
		x %= 5
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
start = 0
prev_t = 0
for i in range(N):
    if t[i] - prev_t > T:
        ans += prev_t + T - start
        start = t[i]
    if i == N - 1:
        ans += t[i] + T - start
    prev_t = t[i]

print(ans)

Measured memory_bytes: 26836
use std::collections::HashMap;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v: Vec<u32>
        = s.trim().split_whitespace().map(|n| n.parse().unwrap()).collect();
    let _ = v[0];
    let k = v[1];
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();

    let mut h: HashMap<u32, u32> = HashMap::new();
    for k in s.trim().split_whitespace().map(|n| n.parse::<u32>().unwrap()) {
        let c = match h.get(&k) {
            Some(&c) => c,
            None     => 0,
        };
        h.insert(k, c + 1);
    }

    let mut v: Vec<(u32, u32)> = h.iter().map(|(k, v)| {
        (*k, *v)
    }).collect();

    v.sort_by(|a, b| b.1.cmp(&a.1));

    let mut c = 0;
    loop {
        let l = v.len();
        if l <= k as usize {
            break;
        }
        let (_, t1) = v.remove(l - 1);
        v[0].1 += t1;
        c += t1;
    }
    println!("{}", c);
}

Measured memory_bytes: 13100
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N;
	string A, B, C;
	cin >> N >> A >> B >> C;
	int an = 0;
	for (int i = 0; i < N; i++)
	{
		if ((A[i] != B[i]) && (A[i] != C[i]) && (B[i] != C[i])) an += 2;
		else if (A[i] == B[i] && A[i] == C[i]);
		else an++;
	}
	cout << an << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N, K, i;
  int height; 
  int counter = 0;
  
  cin >> N >> K;

  for(i=0;i<N;i++){
    scanf("%d",&height);
    if(height >= K) counter++;
  }

  cout << counter; 
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main () {
	char h1, h2, h3;
	scanf ("%c%c%c", &h1, &h2, &h3);
	
	if (h1 == h2 && h1 != h3) {
		puts("Yes");
	}
	else if (h1 == h3 && h1 != h2) {
		puts("Yes");
	}
	else if (h2 == h3 && h1 != h2) {
		puts("Yes");
	}
	else {
		puts ("No");
	}
	return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h> 
 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define pie pair<int,int>
using namespace std;

int32_t main(){

	int n,a,b;
	cin>>n>>a>>b;
	int c=a+b;
	int num=n%c;
	cout<<(n/c)*a+min(num,a)<<endl;
}

Measured memory_bytes: 256
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String s = r.readLine();        // 文字列の入力
        if (s.startsWith("YAKI"))
            System.out.println("Yes");
        else
           System.out.println("No");
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
	int a,b,c;  
	cin >> a >> b >> c;
    int A[3] = {a,b,c};
    sort(A, A + 3);
    if((A[0] + A[1] )== A[2])  cout << "Yes";
    else cout << "No";
      
	return 0;
}

Measured memory_bytes: 256
X,K,D=map(int,input().split())
if X>=0:
    if K<int(X/D):
        print(abs(X-K*D))
    else:
        if abs(X-(int(X/D)+1)*D)<abs(X-int(X/D)*D):
            A=X-(int(X/D)+1)*D
            if (K-(int(X/D)+1))%2==0:
                print(abs(A))
            else:
                if abs(A+D)<abs(A-D):
                    print(abs(A+D))
                else:
                    print(abs(A-D))
        else:
            A=X-(int(X/D))*D
            if (K-(int(X/D)))%2==0:
                print(abs(A))
            else:
                if abs(A+D)<abs(A-D):
                    print(abs(A+D))
                else:
                    print(abs(A-D))
else:
    if K<int(abs(X)/D):
        print(abs(X+K*D))
    else:
        if abs(X+(int(abs(X)/D)+1)*D)<abs(X+int(abs(X)/D)*D):
            A=X+(int(abs(X)/D)+1)*D
            if (K-(int(abs(X)/D)+1))%2==0:
                print(abs(A))
            else:
                if abs(A+D)<abs(A-D):
                    print(abs(A+D))
                else:
                    print(abs(A-D))
        else:
            A=X+(int(abs(X)/D))*D
            if (K-(int(abs(X)/D)))%2==0:
                print(abs(A))
            else:
                if abs(A+D)<abs(A-D):
                    print(abs(A+D))
                else:
                    print(abs(A-D))

Measured memory_bytes: 9344
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	char s[101];
	cin>>s;
	int i,l=strlen(s),ans=0;
	for(i=0;i<l/2;i++){
		if(s[i]!=s[l-i-1]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	int x,y;
	cin>>x>>y;
	
	for(int i=0;i<=x;i++){
		if(2*i+4*(x-i)==y){
			cout<<"Yes";
			return 0;
		}
	}
	
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3624
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

x, y = getList()
ans = abs(abs(x)-abs(y))
if x >= 0:
    if y > 0:
        if x > y:
            ans += 2
    elif y == 0:
        ans += 1
    else:
        ans += 1
else:
    if y > 0:
        ans += 1
    else:
        if x > y:
            ans += 2

print(ans)

Measured memory_bytes: 3064
n = int(input())

# n % k = 1 の数
m = n - 1
i = 2
ans = 1
while i * i <= m:
    if m % i == 0:
        num = 1
        while m % i == 0:
            num += 1
            m //= i
        ans *= num
    i = i + 1
if m != 1:
    ans *= 2
ans -= 1

# n % k = 0 の場合
# nを素因数分解する
m = n
import numpy as np
i = 2
factor = []
while i * i <= n:
    if n % i == 0:
        l = []
        num = 1
        l.append(num)
        while n % i == 0:
            num *= i
            l.append(num)
            n //= i
        factor.append(np.array(l))
    i = i + 1
if n > 1:
    factor.append(np.array([1, n]))

# 直積を求めることでnの全約数を得る
divisor = factor[-1]
for i in range(len(factor) - 1):
    divisor = np.outer(divisor, factor[i])
divisor = np.outer(np.array(1), divisor)

# 判定
for i in divisor[0]:
    if i == 1:
        continue
    n = m
    while n % i == 0:
        n //= i
    if n % i == 1:
        ans += 1

print(ans)

Measured memory_bytes: 18464
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($($args),*), ($($args),*));
    };
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();

    let mut a = vec![vec![0; n]; n];
    for i in 0..n {
        for j in 0..n {
            let x: u64 = sc.cin();
            a[i][j] = x;
        }
    }

    let mut b = a.clone();
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
            }
        }
    }

    let mut ans = true;
    for i in 0..n {
        for j in 0..n {
            if a[i][j] != b[i][j] {
                ans = false;
                break;
            }
        }
    }

    if !ans {
        println!("-1");
        return;
    }

    let mut sum = 0;

    for i in 0..n {
        for j in (i+1)..n {
            let mut ok = true;
            for k in 0.. n {
                if k == i || k == j { continue }
                if b[i][j] == b[i][k] + b[k][j] {
                    ok = false;
                    break;
                }
            }
            if ok {
                sum += b[i][j];
            }
        }
    }

    println!("{}", sum);
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


Measured memory_bytes: 4352
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
b = LIST()
ans = deque()

while b:
    m = len(b)
    for i in range(m-1, -1, -1):
        if b[i] == i + 1:
            ans.appendleft(b.pop(i))
            break
    else:
        print(-1)
        exit()
for x in ans:
    print(x)

Measured memory_bytes: 10304
#include<iostream>
#include<cassert>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2*N-1], dneg[2*N-1];

bool X[N][N];

void initialize(){
    for(int i=0; i<N; i++){
        row[i] = FREE;
        col[i] = FREE;
    }
    for(int i=0; i<2*N-1; i++){
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

void printBoard(){
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(X[i][j]){
                if(row[i] != j) return;
            }
        }
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cout << ((row[i] == j) ? "Q" : ".");
        }
        cout << endl;
    }
}

void recursive(int i){
    if(i == N){
        printBoard();
        return;
    }

    for(int j=0; j<N; j++){
        if(NOT_FREE == col[j] || 
                NOT_FREE == dpos[i+j] ||
                NOT_FREE == dneg[i-j+N-1]) continue;
        
        row[i] = j;
        col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;

        recursive(i+1);

        row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;    
    }
}

int main(){
    initialize();
    
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            X[i][j] = false;
        }
    }

    int k;
    cin >> k;
    for(int i=0; i<k; i++){
        int r, c;
        cin >> r >> c;
        X[r][c] = true;
    }

    recursive(0);

    return 0;
}




Measured memory_bytes: 3116
import sys

if sys.platform =='ios':
	sys.stdin=open('input_file.txt')
	
#+++++
import fractions
a,b = map(int, input().split())
#n = int(input().strip())
#s,t=input().split(' ')
ans = a*b//fractions.gcd(a,b)
print(ans)


Measured memory_bytes: 5048
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, K; cin >> N >> K;

    int lim = (N % 2 == 1 ? N / 2 + 1 : N / 2);
    if(K <= lim) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/maxflow>

using namespace std;
using namespace atcoder;

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

    vector<string> grid(n);
    for (int i = 0; i < n; i++) {
        cin >> grid[i];
    }

    /**
     * generate (s -> even grid -> odd grid -> t) graph
     * grid(i, j) correspond to vertex (i * m + j)
     **/
    mf_graph<int> g(n * m + 2);
    int s = n * m, t = n * m + 1;

    // s -> even / odd -> t
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (grid[i][j] == '#') continue;
            int v = i * m + j;
            if ((i + j) % 2 == 0) {
                g.add_edge(s, v, 1);
            } else {
                g.add_edge(v, t, 1);
            }
        }
    }

    // even -> odd
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if ((i + j) % 2 || grid[i][j] == '#') continue;
            int v0 = i * m + j;
            if (i && grid[i - 1][j] == '.') {
                int v1 = (i - 1) * m + j;
                g.add_edge(v0, v1, 1);
            }
            if (j && grid[i][j - 1] == '.') {
                int v1 = i * m + (j - 1);
                g.add_edge(v0, v1, 1);
            }
            if (i + 1 < n && grid[i + 1][j] == '.') {
                int v1 = (i + 1) * m + j;
                g.add_edge(v0, v1, 1);
            }
            if (j + 1 < m && grid[i][j + 1] == '.') {
                int v1 = i * m + (j + 1);
                g.add_edge(v0, v1, 1);
            }
        }
    }

    cout << g.flow(s, t) << endl;

    auto edges = g.edges();
    for (auto e : edges) {
        if (e.from == s || e.to == t || e.flow == 0) continue;
        int i0 = e.from / m, j0 = e.from % m;
        int i1 = e.to / m, j1 = e.to % m;

        if (i0 == i1 + 1) {
            grid[i1][j1] = 'v';
            grid[i0][j0] = '^';
        } else if (j0 == j1 + 1) {
            grid[i1][j1] = '>'; grid[i0][j0] = '<';
        } else if (i0 == i1 - 1) {
            grid[i0][j0] = 'v';
            grid[i1][j1] = '^';
        } else {
            grid[i0][j0] = '>'; grid[i1][j1] = '<';
        }
    }

    for (int i = 0; i < n; i++) {
        cout << grid[i] << endl;
    }

    return 0;
}

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

int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s/100;
  s2 = s/10 - s/100 * 10;
  s3 = s%10;
  cout << s1 + s2 + s3 << endl;
}


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

using ll = long long;

const int mod = 1000000007;
class modint {
public:
    ll a = 0;
    modint(ll x = 0) {while(x < 0)x += mod;a = x%mod;}
    modint(const modint &r) {a = r.a;}
    modint operator -(){return modint(-a);}
    modint operator +(const modint &r) {return modint(*this)+=r;}
    modint operator -(const modint &r) {return modint(*this)-=r;}
    modint operator *(const modint &r) {return modint(*this)*=r;}
    modint &operator +=(const modint &r){
        a += r.a;
        if(a >= mod) a -= mod;
        return *this;
    }
    modint &operator -=(const modint &r) {
        a -= r.a;
        if(a < 0) a += mod;
        return *this;
    }
    modint &operator *=(const modint &r) {
        a = a * r.a % mod;
        return *this;
    }
    modint pow(ll r) const {
        if (!r) return 1;
        modint x = pow(r >> 1);
        x *= x;
        if (r & 1) x *= *this;
        return x;
    }
    modint inverse() const {
        return pow(mod-2);
    }
    modint& operator/=(const modint r) {
        return (*this) *= r.inverse();
    }
    modint operator/(const modint r) const {
        modint res(*this);
        return res /= r;
    }
};
istream &operator>>(istream &is, modint &x) {
    ll t;
    is >> t;
    x = t;
    return is;
}
ostream &operator<<(ostream &os, const modint& x) {
    return os << x.a;
}
const int MAX = 500000;
modint fac[MAX], inv[MAX], finv[MAX];
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * modint(i);
        inv[i] = - inv[mod%i] * modint(mod/i);
        finv[i] = finv[i-1] * inv[i];
    }
}
modint Com(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
modint Per(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k];
}
using Mint = modint;

int main() {
    int n, m;
    cin >> n >> m;
    set<int> a, b;
    for(int i = 0; i < n; i++) {
        int foo;
        cin >> foo;
        if(a.count(foo)) {
            cout << 0 << endl;
            return 0;
        }
        a.insert(foo);
    }
    for(int j = 0; j < m; j++) {
        int foo;
        cin >> foo;
        if(b.count(foo)) {
            cout << 0 << endl;
            return 0;
        }
        b.insert(foo);
    }
    Mint ans = 1;
    vector<int> p(a.begin(), a.end());
    vector<int> q(b.begin(), b.end());
    for(int i = n * m; i >= 1; i--) {
        bool A = a.count(i);
        bool B = b.count(i);
        if(A && B) continue;
        else if(A) {
            int bar = q.end() - upper_bound(q.begin(), q.end(), i); 
            ans *= (Mint) bar;
        } else if(B) {
            int bar = p.end() - upper_bound(p.begin(), p.end(), i);
            ans *= (Mint) bar;
        } else {
            int foo = p.end() - upper_bound(p.begin(), p.end(), i);
            int bar = q.end() - upper_bound(q.begin(), q.end(), i);
            ans *= (Mint) foo * bar - (n * m - i);
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 15412
'use strict'
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function hoge(input) {
  var arr = input.split(' ').map(Number)
  arr.sort(
    function(a, b) {
      return (a < b ? -1 : 1)
    }
  )
  console.log(arr.join(" "))
  return arr
})

Measured memory_bytes: 15512
#include<bits/stdc++.h>
#define rg register
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
const int N=2000000+10;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
    while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();
    return f*x;
}
struct node {
	int to,next,v;
}a[N<<2];
int X[N],Y[N],Z[N],head[N],f[N],dis[N],cnt,INF;
priority_queue<pair<int,int> >q;
set<int> S[N];
void add(int x,int y,int c){
    a[++cnt].to=y;
    a[cnt].next=head[x];
    a[cnt].v=c;
    head[x]=cnt;
}
void dij(int s){
 	q.push({0,s});
	memset(dis,127,sizeof(dis));
    INF=dis[s],dis[s]=0;
	while(!q.empty()){
		int now=q.top().second,z=-q.top().first;
		q.pop();
		if(dis[now]<z)continue;
		for(int i=head[now];i;i=a[i].next){
			int v=a[i].to,w=z+(!S[now].count(a[i].v));
			if(dis[v]>w){
				dis[v]=w,q.push({-w,v});
				S[v].clear();
				S[v].insert(a[i].v);
			}
			else if(dis[v]==w)
				S[v].insert(a[i].v);
		}
    }
}
int main(){
//	freopen("1.out","w",stdout);
	int n=read(),m=read();
	for(int i=1;i<=m;i++)
		X[i]=read(),Y[i]=read(),Z[i]=read(),add(X[i],Y[i],Z[i]),add(Y[i],X[i],Z[i]);
	dij(1);
	if(dis[n]==INF) puts("-1"),exit(0);
//	for(int i=1;i<=n;i++)
//		cout<<dis[i]<<" ";
//	cout<<dis[6];
	printf("%d",dis[n]);
}


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

int h, w;
char r[512][512], b[512][512];

int main()
{
  cin >> h >> w;

  char red = '#', blu = '.';
  for (int i = 0; i < h; i++){
    swap(red, blu);
    for (int j = 1; j + 1 < w; j++){
      r[i][j] = red;
      b[i][j] = blu;
    }
  }

  for (int i = 0; i < h; i++){
    r[i][0] = '#';
    b[i][0] = '.';
    r[i][w - 1] = '.';
    b[i][w - 1] = '#';
  }

  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      char a;
      cin >> a;
      if (a == '#'){
        r[i][j] = a;
        b[i][j] = a;
      }
    }
  }

  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      cout << r[i][j];
    }
    cout << endl;
  }

  cout << endl;

  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      cout << b[i][j];
    }
    cout << endl;
  }
}


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



int main()
{
	
ll n,op;
cin>>n>>op;
map<ll,pair<ll,ll>>m;
m[1]={1,1};
ll a,b;
for(ll i=2;i<=n;i++)
{
	m[i]={0,1};
}
for(ll i=0;i<op;i++)
{
	
	
	cin>>a>>b;
	
	if(m[a].first==1&&m[a].second>0)m[b]={1,m[b].second+1};
	else
	{	
		m[b].second+=1;
	}
	m[a].second-=1;
	
	if(m[a].second==0)m[a].first=0;
	
}
ll cnt=0;
for(auto x:m) 
{
	if(x.second.second>0)
	cnt+=x.second.first;
}

cout<<cnt;
}

Measured memory_bytes: 9752
class NationalBudget
  def initialize(n1, n2)
    @n1 = n1.to_s.split("").reverse
    @n2 = n2.to_s.split("").reverse
  end

  def plus
    max = (@n1.length < @n2.length) ? @n2.length : @n1.length
    up_flag = false
    @answer = []
    max.times do |i|
      temp = 0
      if !up_flag
        temp = @n1[i].to_i + @n2[i].to_i
      else
        temp = @n1[i].to_i + @n2[i].to_i + 1
      end
      up_flag = push_answer(temp)
    end
    @answer.push(1) if up_flag
  end

  def push_answer(n)
    if n >= 10
      @answer.push(n - 10)
      return true
    else
      @answer.push(n)
      return false
    end
  end

  def answer
    plus
    @answer.reverse.join("")
  end
end

n = gets.to_i

n.times do
  n1 = gets.to_i
  n2 = gets.to_i
  obj = NationalBudget.new(n1, n2)
  answer = obj.answer
  if answer.length > 80
    puts 'overflow'
  else
    puts answer
  end
end

Measured memory_bytes: 8708
#include<cstdio>
#include<cctype>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int l=1,x=0; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') l=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*l;
}
int main(){
	int x,n=read(),m=read(),k=read();
	For(i,0,n)
		For(j,0,m){
			x=i*m+j*n-2*i*j;
			if (x==k) {printf("Yes"); return 0;}
		}
	printf("No");
	return 0;
}

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

int main() {
	char vowel[] = { 'a','e','i','o','u' };
	char s; cin >> s;
	for (int i = 0; i < 5; i++) {
		if (s == vowel[i]) {
			cout << "vowel" << endl;
			return 0;
		}
	}
	cout << "consonant" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> A(3 * N + 5, 0);
  ll pre_sum = 0, post_sum = 0;
  for (int i = 1; i <= 3 * N; ++i) {
    scanf("%lld", &A[i]);
    if (i <= N) { pre_sum += A[i]; }
    else if (i > 2 * N) { post_sum += A[i]; }
  }
  priority_queue<int, vector<int>, greater<int>> que1;
  for (int i = 1; i <= N; ++i) { que1.push(A[i]); }
  vector<ll> S(N + 5, -1);
  S[0] = pre_sum;
  for (int i = N + 1; i <= 2 * N; ++i) {
    int pos = i - N;
    que1.push(A[i]);
    ll val = que1.top(); que1.pop();
    S[pos] = max(S[pos - 1], S[pos - 1] + A[i] - val);
  }

  priority_queue<int> que2;
  for (int i = 2 * N + 1; i <= 3 * N; ++i) { que2.push(A[i]); }
  vector<ll> T(N + 5, -1);
  T[N + 1] = post_sum;
  for (int i = 2 * N; i >= N + 1; --i) {
    int pos = i - N;
    que2.push(A[i]);
    ll val = que2.top(); que2.pop();
    T[pos] = min(T[pos + 1], T[pos + 1] + A[i] - val);
  }

  ll ans = -1 * (ll)1e18;
  for (int i = N; i <= 2 * N; ++i) {
    ans = max(ans, S[i - N] - T[i - N + 1]);
  }
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

int main() {
  long long k, a, b;
  cin >> k >> a >> b;
  long long res = k + 1;

  k = max(0LL, k - (a - 1));
  res = max(res, a + (b - a) * (k / 2) + (k % 2));

  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(void){
    char s[101];
    char cpy[101];
    char p[101];
    int i;
    scanf("%s",s);
    scanf("%s",p);
    for(i=0;s[i]!='\0';i++)
        cpy[i]=s[i];
    strcat(s,cpy);
    if(strstr(s,p)!=NULL)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

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

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b;

  scanf("%d %d", &a, &b);

  if(a == 1) a = 14;
  if(b == 1) b = 14;

  if(a == b) printf("Draw");
  else if(a > b) printf("Alice");
  else           printf("Bob");

  return 0;
}

Measured memory_bytes: 128
H,W = map(int,input().split())
A = [input() for _ in range(H)]
A = list(filter(lambda a: any(x=='#' for x in a), A)) 
A = list(filter(lambda a: any(x=='#' for x in a), zip(*A)))

for a in zip(*A):
  print(''.join(a))

Measured memory_bytes: 3064
def search(n, d):
	if not len(d[n]):
		return n
	nn = d[n].pop(0)
	return search(nn, d)

def resolve():
	d = {}
	for i in ['a', 'b', 'c']:
		d[i] = list(input())
	c = search('a', d)
	print(c.capitalize())
resolve()

Measured memory_bytes: 3188
N=int(input())
M=10**9+7
A=[int(x) for x in input().split()]

ans=0
for i in range(60):
  one=sum([a>>i&1 for a in A])
  zero=N-one
  ans+=(one*zero)*pow(2,i,M)%M
  ans%=M
  #print(one,zero)
print(ans)

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    ll N, A, B;
    cin >> N >> A >> B;

    if (A * B < N || N + 1 < A + B) {
        cout << -1 << '\n';
        return;
    }

    vector<int> res;
    int f = B != 1 ? (N - A) / (B - 1) : N, m = B != 1 ? (N - A) % (B - 1) : 1;
    int cnt = 0, cur = B;
    while (cur <= N) {
        if (cnt < f) {
            for (int i=cur; i>cur-B; --i) res.push_back(i);
            if (cnt == f-1) cur += m+1;
            else cur += B;
        } else if (cnt == f) {
            for (int i=cur; i>=cur-m; --i) res.push_back(i);
            ++cur;
        } else {
            res.push_back(cur);
            ++cur;
        }
        ++cnt;
    }
    for (int i=0; i<N; ++i) {
        cout << res[i];
        if (i == N-1) cout << '\n';
        else cout << ' ';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 5280
from math import atan, sqrt, degrees

a,b,x = map(int, input().split())

ans = 0

if x <= a*a*b/2:
    ans = degrees(atan(a*b*b/(2*x)))
else:
    ans = degrees(atan((2*b-2*x/(a*a))/a))

print(ans)

Measured memory_bytes: 9256
// AtCoder ABC075 C - Bridge
// 2020.1.26 bal4u

#include <stdio.h>
#include <string.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define MAX 55
/* UNION-FIND library */
int id[MAX], size[MAX];
void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; }
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
int connected(int p, int q) { return root(p) == root(q); }
void unite(int p, int q) {
    int i = root(p), j = root(q); if (i == j) return;
//    if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
    if (i > j) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];

}

int N, M;
int a[MAX], b[MAX];
int ans;

void bridge(int n) {
	int i;
	
	memset(id, 0, sizeof(id));
	memset(size, 0, sizeof(size));
	init(N);
	for (i = 0; i < M; ++i) if (i != n) unite(a[i], b[i]);
	if (size[root(0)] != N) ans++;
}
		
int main()
{
	int i;
	
	N = in(), M = in();
	for (i = 0; i < M; ++i) a[i] = in()-1, b[i] = in()-1;
	for (i = 0; i < M; ++i) bridge(i);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
//////////////////////////////////////////////
//root@NULLCT$(☝ ՞ਊ ՞)☝  << "Be accept!!"//
//////////////////////////////////////////////
//#define BOOST
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int66_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   //setfill(char)
#include <ios>       //left,right
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#ifdef BOOST
#include <boost/multiprecision/cpp_int.hpp> // cpp_int
using namespace boost::multiprecision;
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int setup(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); return 0; }
int lenght(char* str) { int i = 0; while (str[i])i++; return i; }
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int iinput(void) { int a = 0; cin >> a; return a; }
int dinput(void) { double a = 0; cin >> a; return a; }
string sinput(void) { string a = ""; cin >> a; return a; }
int kuriup(double a) { int b = int(a); if (a != b) { return b + 1; } else { return b; } }
int kuridown(double a) { int b = int(a); return b; }
int run(void);
int main() { setup(); run(); return 0; }
int run(void) {

	string s = sinput();
	if (s[0] == s[1]) {
		if (s[1] == s[2]) {
			if (s[2] == s[0]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val x = sc.nextInt()
    println(problem087b(a, b, c, x))
}

fun problem087b(a: Int, b: Int, c: Int, x: Int): Int {
    val fiveHundred = 500
    val hundred = 100
    val fifty = 50
    var count = 0
    for (i in 0..a) {
        for (j in 0..b) {
            for(k in 0..c) {
                if (fiveHundred * i + hundred * j + fifty * k == x) {
                    count++
                }
            }
        }
    }
    return count
}

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

ll LCM(ll a, ll b) {
    ll t = a*b;
    return t/__gcd(a, b);
}

ll rangeDivisor(ll m, ll n, ll a, ll b) {
    ll lcm = LCM(a, b);
    ll a_divisor = n / a - (m - 1) / a;
    ll b_divisor = n / b - (m - 1) / b;
    ll common_divisor = n / lcm - (m - 1) / lcm;
    ll ans = a_divisor + b_divisor - common_divisor;
    return ans;
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll ret = rangeDivisor(A, B, C, D);
    //cout << ret << endl;
    cout << B-A+1 - ret << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

        Console.WriteLine(input[0]==input[1]?"Draw":input[0]==1?"Alice":input[1]==1?"Bob":input[0]>input[1]?"Alice":"Bob");

        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法

        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
}

Measured memory_bytes: 13268
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

# print(N, x)
# print(A)

count = 0
for i in range(N):
    if x >= A[i]:
        count += 1
        x -= A[i]
    else:
        break

if count == N and x != 0:
    count -= 1
print(count)

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

int main(){
  int n,item;
  while(1){
    cin >> n;
    int cou=0,flag=0;
    if(n == 0) break;
    for(int i=0;i<n;i++){
      cin >> item;
      if(item == 0){
	cou++;
      }
      if(item > 1){
	flag = 1;
      }
    }
    if(flag == 0){
      cout << "NA" << endl;
    }
    else{
      cout << n-cou+1 << endl;
    }
  }
}

Measured memory_bytes: 1164
from sys import stdin
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
s = str(stdin.readline().rstrip())
l = len(s)//2

count = 0

for i in range(l):
    if s[i] == s[-1-i]:
        pass
    else:
        count += 1

print(count)

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};
//UnionFind Uni(N);
//Uni.connect;

int main(){
  int n,k,l;
  cin >> n >> k >> l;
  UnionFind road(n),rail(n);
  rep(i,k){
    int p,q;
    cin >> p >> q;
    p--;q--;
    road.connect(p,q);
  }
  rep(i,l){
    int r,s;
    cin >> r >> s;
    r--;s--;
    rail.connect(r,s);
  }
  map<P,int> ma;
  rep(i,n){
    P p(road.root(i),rail.root(i));
    ma[p]++;
  }
  rep(i,n){
    P p(road.root(i),rail.root(i));
    cout << ma[p] << ' ';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	long long int ans=0;
	cin>>n;
	long long int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
    
    map<long long int,long long int> m1,m2;
    
    for(int i=0;i<n;i++)
    {
    m1[i+a[i]]++;
    m2[i-a[i]]++;
    }

    for(auto it:m1)
    {
    ans+=(it.second)*(m2[it.first]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 39364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++)
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
pair<ll,ll> a[200005];
int main()
{
	ll n,D,A; cin>>n>>D>>A;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].fi>>a[i].se;
	}
	sort(a,a+n);
	ll total=0;
	ll damage=a[0].se/A+(a[0].se%A?1:0);
	total=damage;
	damage*=A;
	ll i=1,temp=0;
	queue<pii>q;
	q.push({damage,a[0].fi+2*D});
	temp=damage;
	while(i<n)
	{
		while(!q.empty())
		{
			if(q.front().se<a[i].fi)
			{
				temp-=q.front().fi;
				q.pop();
			}
			else
			{
				break;
			}
		}
		if(temp>=a[i].se)
		{
			i++;
		}
		else
		{
			a[i].se-=temp;
			ll cnt=a[i].se/A+(a[i].se%A?1:0);
			total+=cnt;
			temp+=cnt*A;
			q.push({cnt*A,a[i].fi+2*D});
			i++;
		}
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 4224
N, A, B = map(int,input().split(' '))
S = input()

rankALL=1
rankb=1

for i in range(len(S)):
    if S[i]=='a':
        if (rankALL <= A + B ):
            ans = 'Yes'
            rankALL+=1
        else:
            ans='No'
    elif S[i]=='b':
        if (rankALL <= A+B) and (rankb <= B ):
            ans = 'Yes'
            rankALL+=1
            rankb+=1
        else:
            ans='No'
    elif S[i]=='c':
        ans='No'
    print(ans)

   

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  cout << d[N / 2] - d[N / 2 - 1];
  
  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    int dp[n][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            int t=a[i][j];
            if(j==0)
            {
               // cout<<k<<endl;
                dp[i][j]=max(t+dp[i-1][j+1],t+dp[i-1][j+2]);
                //cout<<k<<endl;
            }
            if(j==1)
            {
                //cout<<k<<endl;
                dp[i][j]=max(t+dp[i-1][j+1],t+dp[i-1][j-1]);
                //cout<<k<<endl;
            }
            if(j==2)
            {
                //cout<<k<<endl;
                dp[i][j]=max(t+dp[i-1][j-1],t+dp[i-1][j-2]);
                //cout<<k<<endl;
            }
        }

    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}


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

int main(){
  long long box[87];
  box[0] = 2LL;
  box[1] = 1LL;
  int N;
  scanf("%d", &N);
  
  for(int i = 2; i < N + 1; i++){
    box[i] = box[i - 1] + box[i - 2];
  }
  
  printf("%lld", box[N]);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int N;
   cin >> N;
   vector<long long> L(N+1);
   L[0] = 2;
   L[1] = 1;
   for(int i = 2; i <= N; i++){
       L[i] = L[i-1] + L[i-2];
   }
   cout << L[N] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,h,m;
  cin >>a>>b>>h>>m;
  double k=360*h/12+0.5*m,ku=6*m,d=ku-k;
  double aaa=abs(min(d,360-d));
   double ans_1=a*a+b*b-2*a*b*cos(M_PI/180*aaa);
  double ans=sqrt(ans_1);
  printf("%.15lf",ans);
  
}
  
  
  

Measured memory_bytes: 4136
def upperbound(zs, left, right, ok):
    if left + 1 >= right:
        return left
    m = (left + right) // 2
    if ok(zs[m]):
        return upperbound(zs, m, right, ok)
    else:
        return upperbound(zs, left, m, ok)

n = int(input())
xs = list(map(int, input().split()))

ds = sorted(xs)

a = ds[-1]
c = a / 2
zs = [d - c for d in ds[:-1]]

i = upperbound(zs, 0, len(zs)-1, lambda z: z<=0)

j = i+1 if i < len(zs)-1 else i

b = ds[i] if abs(zs[i]) < abs(zs[j]) else ds[j]

print(a, b)

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

#define mod 1000000007
#define inf 1000000000000000001;

using namespace std;

void solve(){
	int count=0;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		if(s[i] != t[i])
			count++;
	}
	cout<<count<<endl;
}


int main()
{
	std::ios::sync_with_stdio(false);

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		freopen("error.txt", "w", stderr);
	#endif


		solve();

	return 0;
}


Measured memory_bytes: 3952
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<50;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int K; cin >> K;
  vector<ll> A(K);
  for(int i=0; i<K; i++) cin >> A[i];
  
  reverse(A.begin(), A.end());
  ll aMax = 2, aMin = 2;
  for(int i=0; i<K; i++){
    ll lower = (aMin + A[i] - 1) / A[i] * A[i];
    ll upper = (aMax - aMax%A[i]);
    if(lower > aMax || upper < aMin){
      cout << -1 << endl;
      return 0;
    }
    aMax = upper+A[i]-1;
    aMin = lower;
  }
  cout << aMin << " " << aMax << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
const double pi = 3.14159265358979323846;
using namespace std;
int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);
	freopen("error.txt","w", stderr);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n ;cin>>n;
	cout<<2*pi*n<<"\n";
	return 0;
}

Measured memory_bytes: 3796
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
	const input1 = input[0].split(" ");
	const N = parseInt(input1[0]);
	const D = parseInt(input1[1]);
	const points = input.slice(1).map(x => x.split(" ").map(y => parseInt(y)));

	var count = 0;

	for (i = 0; i < N - 1; i++) {
		for (j = i + 1; j < N; j++) {
			var distance = 0;
			for (k = 0; k < D; k++) {
				distance += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]);
			}
			distance = Math.sqrt(distance);
			if (Number.isInteger(distance)) count++;
		}
	}
	console.log(count);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
def actual(n, x, L):
    bounce_list = [0]

    for l in L:
        bounce_list.append(bounce_list[-1] + l)

    return [height <= x for height in bounce_list].count(True)

n, x = map(int, input().split())
L = map(int, input().split())

print(actual(n, x, L))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5e3+5;
int d[N],t[N],k,q;
ll cal(int n,int x,int m) {
	ll s=0;
	for(int i=0;i<k;i++) {
		t[i]=d[i]%m;
		if(t[i]==0) t[i]=m;
		s+=t[i];
	}
	ll ans=x+s*((n-1)/k);
	for(int i=0;i<(n-1)%k;i++) {
		ans+=t[i];
	}
	return n-1-(ans/m-x/m);
}
int main() {
	//freopen("in.txt","r",stdin);
	scanf("%d%d",&k,&q);
	for(int i=0;i<k;i++) {
		scanf("%d",&d[i]);
	}
	for(int i=0,n,x,m;i<q;i++) {
		scanf("%d%d%d",&n,&x,&m);
		printf("%lld\n",cal(n,x,m));
	}
	return 0;
}


Measured memory_bytes: 384
import sys

N,M=map(int,input().split())
a=[]
for _ in range(M):
	aa=int(input())
	a.append(aa)
dp=[0]*(N+1)
for i in range(M):
	dp[a[i]]=-1

if N==1:
	print(1)
	sys.exit()

dp[0]=1
if dp[1]!=-1:
	dp[1]=1

for j in range(2,N+1):
	if dp[j]!=-1:
		dp[j]=0
		if dp[j-1]!=-1:
			dp[j]+=dp[j-1]
		if dp[j-2]!=-1:
			dp[j]+=dp[j-2]

print(dp[N]%1000000007)

Measured memory_bytes: 462708
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<map>
#include<queue>
#include<cmath>

using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef pair< int, int > Pi;
typedef pair< bool , Pi > Pii;
typedef long long int int64;

int M, N, K, sum[3][1000][1000] = {{{}}};
string temp = "JOI";

int main(){

  cin >> M >> N;
  cin >> K;
  for(int i = 1; i <= M; i++){
    for(int j = 1; j <= N; j++){
      char c;
      cin >> c;
      for(int k = 0; k < 3; k++){
        if(temp[k] == c) ++sum[k][i][j];
        sum[k][i][j] += sum[k][i - 1][j] + sum[k][i][j - 1] - sum[k][i - 1][j - 1];
      }
    }
  }
  while(K--){
    int ax, by, cx, dy;
    cin >> ax >> by >> cx >> dy;
    swap( ax, by), swap( cx, dy);
    for(int i = 0; i < 3; i++){
      int hoge = sum[i][dy][cx] + sum[i][by - 1][ax - 1] - sum[i][dy][ax - 1] - sum[i][by - 1][cx];
      cout << (i == 0 ? "" : " ") << hoge;
    }
    cout << endl;
  }     
}

Measured memory_bytes: 12892
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
x = 0

ans = sum(b)

for i in range(0, n-1):
  if a[i] +1 == a[i+1]:
    x = a[i] - 1
    ans = ans + c[x]

print(ans)

Measured memory_bytes: 3064
import java.math.BigDecimal

fun main() {
    var x = readLine()!!.toBigDecimal()

    var interest = 1.01.toBigDecimal()
    val hund = 100.toBigDecimal()
    var result = 0.toBigDecimal()
    var depo = 100.toBigDecimal()

    run loop@{
        while(true){
            depo = (depo * interest).setScale(0,BigDecimal.ROUND_DOWN)
            result += 1.toBigDecimal()
            if(depo >= x){
                return@loop
            }

        }
    }




    println(result)
}

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


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n,i,j;
    cin>>n;
    
    vector<vector<ll>> v(n,vector<ll>(3,0));
    
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
            cin>>v[i][j];
    }
    vector<vector<ll>> dp(n,vector<ll>(3,-1));
    dp[n-1][0]=v[n-1][0];
    dp[n-1][1]=v[n-1][1];
    dp[n-1][2]=v[n-1][2];
    for(i=n-2;i>=0;i--)
    {
        dp[i][0]=v[i][0]+max(dp[i+1][1],dp[i+1][2]);
        dp[i][1]=v[i][1]+max(dp[i+1][0],dp[i+1][2]);
        dp[i][2]=v[i][2]+max(dp[i+1][0],dp[i+1][1]);
    }
    cout<<max(dp[0][1],max(dp[0][0],dp[0][2]));
    
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    int v[100001] = {0};
    rep(i, n){
        int tmp;
        cin >> tmp;
        v[tmp]++;
    }

    int ans = 0;
    rep(i, 100001){
        if(i == 0){
            ans = max(ans, v[i]+v[i+1]);
        }
        else if(i == 100000){
            ans = max(ans, v[i]+v[i-1]);
        }
        else{
            ans = max(ans, v[i-1]+v[i]+v[i+1]);
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 640