akhauriyash/Code-Regression huggingface dataset:
height, width = map(int, input().split())
table = []
for i in range(height):
    table.append(list(map(int, input().split())))
    table[i].append(sum(table[i]))
table.append([0 for i in range(width + 1)])
for i in range(height):
    for j in range(width + 1):
        table[-1][j] += table[i][j]
    print(*table[i])
print(*table[-1])


Measured memory_bytes: 6228
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define LL long long
int N, K;
LL L;
int a[200010];

bool judge(int x){
	LL cnt = 0;//x以下となる区間を数える
	vector<int> sum = { 0 };//sum[i]には区間[1, i]までのｘ以下の数の個数を保存
	for(int i = 1; i <= N; i++){
		sum.push_back(sum[i - 1]);
		if(a[i] <= x) sum[i]++;
		if(sum[i] - K < 0) continue;

		LL r = upper_bound(sum.begin(), sum.end(), sum[i] - K) - sum.begin();
		r = min(r, 1LL * (i - K + 1));
		cnt += r;
	}
	return cnt >= L;
}

int solve(){
	vector<int> as = {0};
	for(int i = 1; i <= N; i++){
		as.push_back(a[i]);
	}
	sort(as.begin(), as.end());
	as.erase(unique(as.begin(), as.end()), as.end());
	int lb = 0; int ub = as.size() - 1;
	while(ub - lb > 1){
		int mid = (ub + lb) / 2;
		if(judge(as[mid])){
			ub = mid;
		}else{
			lb = mid;
		}
	}
	return as[ub];
}


void input(){
	cin >> N >> K >> L;
	for(int i = 1; i <= N; i++){
		cin >> a[i];
	}
}

int main(){
	input();
	cout << solve() << endl;
	return 0;
}


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

using namespace std;

#define ll long long
#define all(x) (x).begin(),(x).end()
#define desc greater<int>()
#define pb(x) push_back(x)
ll gcd(ll a, ll b) { return (!a)?b:gcd(b%a,a);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
void pArr(int arr[], int s);
void pVec(vector<int> v);
bool isPrime(int x);
int binarySearch(int arr[], int l, int r, int x);
int vBinarySearch(vector<ll> v, int l, int r, ll x);
int nChoosek( int n, int k );
int mod=1e9+7;

void solve(){
    int n;
    cin >> n;
    if (n%1000==0){
        cout << 0 << endl;
    }
    else{
        cout << 1000-n%1000 << endl;
    }
}


int main(){
/*
    string temp;
    int t;
    cin >> t;
    getline(cin, temp);
    while (t--){
        solve();
    }
*/
    solve();
    return 0;
}


void pArr(int arr[], int s){
    for (int i=0;i<s;i++){
        cout << arr[i] << " ";
    }
    cout << endl;
}
void pVec(vector<int> v){
    for (int i=0;i<v.size();i++){
        cout << v.at(i) << " ";
    }
    cout << endl;
}
bool isPrime(int x){
    if (x==1){
        return false;
    }
    if(x==2){
        return true;
    }
    for (int i=2;i<=(int)(pow(x,0.5));i++){
        if (x%i==0){
            return false;
        }
    }
    return true;
}

int vBinarySearch(vector<ll> v, int l, int r, ll x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
        if (v.at(m) == x)
            return m;
        if (v.at(m) < x)
            l = m + 1;
        else
            r = m - 1;
    }
    //bigger
    return r+1;
}

int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
        if (arr[m] == x)
            return m;
        if (arr[m] < x)
            l = m + 1;
        else
            r = m - 1;
    }
    //smaller
    return r;
}

int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;
    
#define EPS (1e-7)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p,q,r;
    cin>>p>>q>>r;
    int tmp = min(p+q,p+r);
    cout<<min(tmp,q+r)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
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] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
        prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}


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

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

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    double mid_min = 0;
    double mid_max = 0;

    if(N % 2 == 0) {
        mid_min = (A[N/2] + A[N/2 - 1]) /2.0;
        mid_max = (B[N/2] + B[N/2 - 1]) /2.0;
    } else {
        mid_min = A[(N-1)/2];
        mid_max = B[(N-1)/2];
    }


    if(N % 2 == 0) {
        cout << (ll) ((mid_max - mid_min + 0.01) * 2.0  + 1.0)<< endl;
    } else {
        cout << (ll) ((mid_max - mid_min + 0.01)   + 1.0)<< endl;
    }






    return 0;    
}



Measured memory_bytes: 6440
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b;
   cin >> a >> b;
   int p = a*b;
   int gc = __gcd(a,b);
   p = p/gc;
   cout << p << '\n';
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2 == 1) {
		cout << "No\n";
		return 0;
	}
	string p = s.substr(0, n / 2);
	if (p + p == s) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, q; cin >> n >> q;
    
    vector<vector<int>> G(n, vector<int>());
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<int> ans(n, 0);
    
    for (int i = 0; i < q; i++) {
        int p, x; cin >> p >> x; p--;
        ans[p] += x;
    }
    
    stack<pair<int, int>> s;
    for (auto v : G[0]) s.push(make_pair(0, v));
    vector<bool> checked(n, false);
    checked[0] = true;
    while (!s.empty()) {
        int from = s.top().first;
        int to = s.top().second;
        s.pop();
        if (!checked[to]) {
            checked[to] = true;
            ans[to] += ans[from];
            for (int v : G[to]) {
                if (!checked[v]) s.push(make_pair(to, v));
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        cout << ans[i];
        if (i != n - 1) cout << " ";
        else cout << endl;
    }

    return 0;
}


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

const int MAXN = 1e5 + 5;
string s, t;
int ans = 1e9;

int main() {
    cin >> s >> t;
    for (int i = 0; i < s.size() - t.size() + 1; i++) {
        int tmp = 0;
        for (int j = 0; j < t.size(); j++)
            if (t[j] != s[i + j]) tmp++;
        ans = min(ans, tmp);
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;
	long long maxx=0;
	//bool flag=false,flag2=false;
//	if(n>a||n>b||n>c||n>d||n>e)flag=true;
//	if(flag==true&&(n<=a||n<=b||n<=c||n<=d||n<=e))flag2=true;
	maxx=max(n/a+((n%a)>0),maxx);
	maxx=max(n/b+((n%b)>0),maxx);
	maxx=max(n/c+((n%c)>0),maxx);
	maxx=max(n/d+((n%d)>0),maxx);
	maxx=max(n/e+((n%e)>0),maxx);
	
//	if(flag2)maxx++;
	cout<<maxx+4;
	return 0;
} 

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	xx := make([]int, m)
	yy := make([]int, m)
	zz := make([]int, m)
	uf := make([]int, n)
	for i := 0; i < n; i++ {
		uf[i] = i
	}
	for i := 0; i < m; i++ {
		xx[i] = getNextInt(scanner) - 1
		yy[i] = getNextInt(scanner) - 1
		zz[i] = getNextInt(scanner)
		rx := root(xx[i], uf)
		ry := root(yy[i], uf)
		if rx == ry {
			continue
		}
		uf[ry] = rx
	}
	mm := map[int]int{}
	for i := 0; i < n; i++ {
		mm[root(i, uf)] = 1
	}
	fmt.Fprintln(writer, len(mm))
}

func root(i int, uf []int) int {
	if i == uf[i] {
		return i
	}
	uf[i] = root(uf[i], uf)
	return uf[i]
}


Measured memory_bytes: 9472
use std::f64;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: f64 = read();
    let b: f64 = read();
    let c: f64 = read();
    let c_radian: f64 = (c / 180.0) * f64::consts::PI;
    println!("{}", a * b * c_radian.sin() * 0.5);
    println!(
        "{}",
        a + b + (a.powf(2.0) + b.powf(2.0) - 2.0 * a * b * c_radian.cos()).sqrt()
    );
    println!("{}", b * c_radian.sin());
}



Measured memory_bytes: 5200
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] grid = new char[H][W];
		
		for (int i=0; i<H; i++) {
			char[] c = sc.next().toCharArray(); 
			for (int j=0; j<W; j++) {
				grid[i][j] = c[j];
			}
		}
		for (int i=0; i<H; i++) {
			StringBuffer sb = new StringBuffer();
			for (int j=0; j<W; j++) {
				sb.append(grid[i][j]);
			}
			System.out.println(sb);
			System.out.println(sb);
		}
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    pair<int, int> ans = make_pair(0, 0);

    for (int i = 0; i <= F / (100 * A); i++)
    {
        int f_a = F - (100 * A * i);
        for (int j = 0; j <= f_a / (100 * B); j++)
        {
            int water_coef = A * i + B * j;
            int e_available = min(E * water_coef, F - 100 * water_coef);
            int e_val = 0;
            for (int k = 0; k <= e_available / C; k++)
            {
                e_val = max(e_val, C * k + ((e_available - C * k) / D) * D);
            }
            if (e_val * ans.first >= (water_coef * 100 + e_val) * ans.second)
            {
                ans = make_pair(water_coef * 100 + e_val, e_val);
            }
        }
    }

    cout << ans.first << " " << ans.second << endl;

    return 0;
}


Measured memory_bytes: 256
#入力
n = int(input())
A = []
for i in range(n):
  A.append([])
  A[i].append(int(input()))
  for j in range(A[i][0]):
    A[i].append([int(_) for _ in input().split()])
    
def bit_count(num):
  cc = 0
  while num:
    cc += num & 1
    num >>= 1
  return cc

#bit全探索
res = 0
for bit in range(2 ** n):
  for i in range(n): #i番目の人の発言について検証
    if ((bit >> i) & 1) == 0: #i番目の人が正直者かそうでないか
      continue
    for j in range(A[i][0]):
      x, y = A[i][j+1]
      if (bit >> (x-1)) & 1 != y:
        break
    else:
      continue
    break
  else:
    res = max(res, bit_count(bit))
print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

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

	LL s;
	cin >> s;
	LL sq = LL(sqrt(s));
	if(sq * sq != s)
		++sq;
	LL added = sq * sq - s;
	while(LL(sqrt(s + added)) * LL(sqrt(s + added)) != s + added)
		++added;
	cout << "0 0 " << LL(sqrt(s + added)) << ' ' << (added ? 1 : 0) << ' ' << added << ' ' << LL(sqrt(s + added));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e16;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  string str1,str2;
  cin>>str1>>str2;
  ll c=0;
  for(ll i=0;i<str1.length();i++)
  {
    if(str1[i]!=str2[i])
      c++;
  }
  cout<<c;
  
  return 0;
}


Measured memory_bytes: 3816
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}


const int MAX_N = 110;

int N, K;


int main(int argc, char **argv) {
    std::cin >> N >> K;

    int max = ((N-1) * (N-2)) / 2;

    if (K > max) {
        std::cout << "-1" << std::endl;
        return 0;
    }

    std::vector<int> u, v;

    for (int i = 2; i <= N; i++) {
        u.push_back(1);
        v.push_back(i);
    }

    int cur = max;

    for (int i = 2; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            if (cur > K) {
                u.push_back(i);
                v.push_back(j);
                cur--;
            }
        }
    }

    std::cout << u.size() << std::endl;
    for (int i = 0; i < u.size(); i++) {
        std::cout << u[i] << " " << v[i] << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
    int p;
    scanf("%d",&p);
    if(p==1)
      printf("1");
    else if(p>=2 && p<=3)
      printf("2");
    else if(p>=4 && p<=7)
      printf("4");
    else if(p>=8 && p<=15)
      printf("8");
    else if(p>=16 && p<=31)
      printf("16");
    else if(p>=32 && p<=63)
      printf("32");
    else if(p>=64 && p<=100)
      printf("64");
}


Measured memory_bytes: 128
n = int(input())
s = list(input())
ok_list = []
min_length = 10**9
for i in range(len(s)+1):
    for j in range(len(s)+1):
        s_part = s
        s_part = ["("] * i + s_part + [")"] * j

        if s_part[0] == "(" and s_part[-1] == ")":
            f = 0
            fmin = 0
            ng = 0
            for k in s_part:
                if k == "(":
                    f += 1
                else:
                    f -= 1
                if f < 0:
                    ng = 1
            if f == 0 and ng == 0:
                ok_list.append("".join(s_part))

minl = min(map(len,ok_list))
ok_list = [ i for i in ok_list if len(i) == minl ]
print(sorted(ok_list)[0])

Measured memory_bytes: 42092
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      h: usize,
      w: usize,
      d: usize,
      aa: [[usize; w]; h],
      q: i64,
      lrs: [(usize, usize); q]
    }
    let mut px = vec![0; 90001];
    let mut py = vec![0; 90001];
    let mut ss = vec![0; 90001];

    for hh in 0..h {
        for ww in 0..w {
            let a = aa[hh][ww];
            px[a] = hh as i64;
            py[a] = ww as i64;
        }
    }

    for i in d..(h*w+1) {
        ss[i] = ss[i-d] + (px[i] - px[i-d]).abs() + (py[i] - py[i-d]).abs();
    }

    for (l, r) in lrs {
        println!("{}", ss[r] - ss[l]);
    }
}


Measured memory_bytes: 9340
using System;

class P
{
public static void Main()
{
 //????????????????????????
            int n = Int32.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ');

            //??°?????????????????????
            int[] array = new int [n];

            for (int i = 0; i <= n - 1 ; i++)
            {
                array[i] = Int32.Parse(a[i]);
            }

            //??°?????????????????????
            Array.Reverse(array);

            //??¨???
            for (int k = 0; k <= n - 1; k++)
            {
                if (!(k == n - 1))
                {
                    Console.Write(array[k] + " ");
                }
                else 
                {
                    Console.Write(array[k] +"\n");
                }
            }
}
}

Measured memory_bytes: 9160
n, k = map(int, input().split())
prime_mod = 10**9+7
countgcd = [0]*k
for idx in range(k, 0, -1):
  num_multiples = k//idx
  num_sequences = pow(num_multiples, n, prime_mod)
  overcount = sum(countgcd[j*idx-1] for j in range(2, num_multiples+1))
  overcount = overcount%prime_mod
  countgcd[idx-1] = (num_sequences-overcount)%prime_mod
  # print(idx, num_multiples, num_sequences, overcount, num_sequences-overcount)
final_sum = 0
for idx in range(1, k+1):
  final_sum = (final_sum + idx*countgcd[idx-1])%prime_mod
print(final_sum)

Measured memory_bytes: 75840
N=int(input())
A=list(map(int,input().split()))
dp=[[0,0] for i in range(N)]
dp[0][0]=A[0]+A[1]
dp[0][1]=-1*dp[0][0]
for i in range(1,N-1):
    dp[i][0]=max(dp[i-1][0]+A[i+1],dp[i-1][1]+A[i+1])
    dp[i][1]=max(dp[i-1][0]-2*A[i]-A[i+1],dp[i-1][1]+2*A[i]-A[i+1])
print(max(dp[N-2]))

Measured memory_bytes: 24812
fun sort3(a:Int, b:Int, c:Int):String =
  if (a < b) {
    if (b < c) "$a $b $c"
    else if (a < c) "$a $c $b"
    else "$c $a $b"
  } else {
    if (a < c) "$b $a $c"
    else if (b < c) "$b $c $a"
    else "$c $b $a"    
  }

fun main(args: Array<String>) {
  val (a,b,c) = readLine()!!.split(' ').map(String::toInt)
  println(sort3(a,b,c))
}



Measured memory_bytes: 32140
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

//同じコードでそんなにばらつくんですか

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 100000, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}

bool NG[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), M = getint();
	int H[100001];
	rep1(i, N) H[i] = getint();
	rep(i, M) {
		int a = getint(), b = getint();
		if (H[a] >= H[b]) NG[b] = 1;
		if (H[a] <= H[b]) NG[a] = 1;
	}
	int kotae = N;
	rep1(i, N) kotae -= NG[i];

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
using namespace std;
#define INF 30001

int main()
{
  int N;
  string s;
  cin >> N >> s;
  if (N % 2 == 0)
  {
    for (int i = 0; i < N / 2; ++i)
    {
      if (s.at(i) != s.at(i + N / 2))
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  else
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  

}

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

int main() {
  int N, M; cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<long long> S(N+1);
  S.at(0) = 0;
  for (int i = 0; i < N; i++) S.at(i+1) = (S.at(i) + A.at(i)) % M;
  map<int, int> m;
  long long ans = 0;
  // 自分と同じ数字 (余り) が左に何個あるのか
  for (int i = 0; i <= N; i++) {
    if (m.count(S.at(i))) {
      ans += m[S.at(i)];
      m[S.at(i)]++;
    }
    else m[S.at(i)] = 1;
  }
  cout << ans << endl;
}

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

int flag[4];

bool Dis(int x){
  int i=0;
  while(x){
    flag[i]=x%10;
    x/=10;
    i++;
  }
  if(flag[0]==flag[1]&&flag[1]==flag[2]||flag[1]==flag[2]&&flag[2]==flag[3]) return 1;
  else return 0;
}

int main(){
  int N;
  cin>>N;
  if(Dis(N)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
const int N = 50;
int f(int a, int k) {
  int x = a / k, b = a % k;
  if (!b) return x;
  int t = (b + x) / (x + 1);
  return f(a - (x + 1) * t, k);
}
int main() {
  int n, a, k, ans = 0;
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &a, &k);
    ans ^= f(a, k);
  }
  puts(ans ? "Takahashi" : "Aoki");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n;cin >> n;
    vector<int> a(n);
    vector<int> x[n],y[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < a[i]; j++) {
            int p,q;cin >> p >> q;
            p--;
            x[i].pb(p);
            y[i].pb(q);
        }
    }
    int ans = 0;
    for (int k = 0; k < (1<<n); k++) {
        bool f = true;
        for (int i = 0; i < n; i++) {
            if((k>>i)&1){
                for (int j = 0; j < a[i]; j++) {
                    if((y[i][j])&&(!((k>>x[i][j])&1))) f = false;
                    if((!y[i][j])&&((k>>x[i][j])&1)) f = false;
                }
            }
        }
        if(f) ans = max(ans,(int)__builtin_popcount(k));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
es = [[] for _ in range(N)]
for i in range(N):
    a = int(input())
    for _ in range(a):
        x,y = map(int, input().split())
        es[i].append((x-1,y))

ans = 0
for bit in range(1 << N):
    flag = True
    for i in range(N):
        if bit & (1 << i):
            for x, y in es[i]:
                if y == 1 and not bit & (1 << x) or y == 0 and bit & (1 << x):
                    flag = False
    
    if flag:

        ans = max(ans, bin(bit).count("1"))

print(ans)

Measured memory_bytes: 3064
import sys
input=sys.stdin.readline
import math

def main():
    N = int(input())
    C = []
    S = []
    F = []
    for _ in range(N-1):
        c,s,f = map(int,input().split())
        C.append(c)
        S.append(s)
        F.append(f)
    
    for i in range(N-1):
        t = 0
        for j in range(i,N-1):
            k = max(0, math.ceil((t - S[j])/F[j]))
            t = S[j] + k*F[j] + C[j]
        print(t)
    print(0)

if __name__ == '__main__':
    main()


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

int n;
int a[100010] ;

int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		int temp;
		cin>>temp;//编号为i，名次temp
		a[temp]=i; 
	}
	for(int i=1; i<n; i++)
	    cout<<a[i]<<" ";
	cout<<a[n]<<endl;
	
	return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int h, w;
int b[110][110];

int bCount[110][110][2];	//i--h, j--w, k--0, 颜色变为0，1，颜色变为1 

char temp[110];

void doSolve(int r, int c, int nr, int nc) {
	int num = bCount[r][c][0];
	if (b[nr][nc] == 0) {
		if ((bCount[nr][nc][0] == -1) || (bCount[nr][nc][0] > num))
			bCount[nr][nc][0] = num;
		num++;
		if ((bCount[nr][nc][1] == -1) || (bCount[nr][nc][1] > num))
			bCount[nr][nc][1] = num;
	} else {
		num++;
		if ((bCount[nr][nc][0] == -1) || (bCount[nr][nc][0] > num))
			bCount[nr][nc][0] = num;
		if ((bCount[nr][nc][1] == -1) || (bCount[nr][nc][1] > num))
			bCount[nr][nc][1] = num;
	}
}

void doSolve1(int r, int c, int nr, int nc) {
	int num = bCount[r][c][1];
	if (b[nr][nc] == 1) {
		if ((bCount[nr][nc][1] == -1) || (bCount[nr][nc][1] > num))
			bCount[nr][nc][1] = num;
		num++;
		if ((bCount[nr][nc][0] == -1) || (bCount[nr][nc][0] > num))
			bCount[nr][nc][0] = num;
	} else {
		if ((bCount[nr][nc][0] == -1) || (bCount[nr][nc][0] > num))
			bCount[nr][nc][0] = num;	//切入已经做了一遍了，改出就不需要再做了 
		num++;
		if ((bCount[nr][nc][1] == -1) || (bCount[nr][nc][1] > num))
			bCount[nr][nc][1] = num;
	}
}

int main()
{
	scanf("%d%d\n", &h, &w);
	
	for (int r = 1 ; r <= h ; r++) {
		scanf("%s\n", temp);		
		for (int c = 0 ; c < w ; c++) {
			if (temp[c] == '.')
				b[r][c + 1] = 0;
			else
				b[r][c + 1] = 1;
		}
	}
	
	for (int r = 1 ; r <= h ; r++) {
		for (int c = 1 ; c <= w ; c++) {
			bCount[r][c][0] = -1;
			bCount[r][c][1] = -1;
		}
	}
	
	bCount[0][0][0] = 0;
	bCount[1][1][1] = 10000000;	//一个足够大的书 
	if (b[1][1] == 0) {
		bCount[1][1][0] = 0;
		bCount[1][1][1] = 1;
	} else {
		bCount[1][1][0] = 1;
		bCount[1][1][1] = 1;
	}
		
		
	for (int r = 1 ; r <= h ; r++) {
		for (int c = 1 ; c <= w ; c++) {
			int num;			
			int nr, nc;			
			//0
			nr = r + 1;
			nc = c;
			doSolve(r, c, nr, nc);
			
			nr = r;
			nc = c + 1;
			doSolve(r, c, nr, nc);
			
			//起点必须为白色 
//			if ((r == 1) && (c == 1)) {
//				continue;
//			}
			
			//1
			nr = r + 1;
			nc = c;
			doSolve1(r, c, nr, nc);
			
			nr = r;
			nc = c + 1;
			doSolve1(r, c, nr, nc);
		}
	}
	
	int ans = bCount[h][w][0];
	if (ans > (bCount[h][w][1]))
		ans = (bCount[h][w][1]);
	printf("%d\n", ans);
	
	return 0;
}
//每次变换，实际都需要，一个连续的同色块 
//否则就是左手倒右手的事情。 
//最终转换成切多少次
//5 5
//.#.#.
//.###.
//.#.#.
//.#.#.
//.#.#.

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

using namespace std;

int main() {
    int k = 0;
    long long i, o, t, j, l, s, z;
    long long rta = 0;
    cin >> i >> o >> t >> j >> l >> s >> z;
    if(i % 2 == 1) k++;
    if(j % 2 == 1) k++;
    if(l % 2 == 1) k++;
    if(min(min(i, j), l) > 0 && k >= 2) {
        rta = 3;
        i--;j--;l--;
    }
    rta += ( ( (i / 2) * 2 ) + o +  ( (j / 2) * 2 ) + ( (l / 2) * 2 ));
    cout << rta << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

float mean2(int x, int y)
{
    return (float)(x + y) / 2.0;
}

float mean3(int x, int y, int z)
{
    return (float)(x + y + z) / 3.0;
}

char grading(int p_math, int p_eng, int p_jpn)
{
    float mean_2 = mean2(p_math, p_eng);
    float mean_3 = mean3(p_math, p_eng, p_jpn);
    
    if ( p_math == 100 || p_eng == 100 || p_jpn == 100) {
        return 'A';
    } else if (mean_2 >= 90.0) {
        return 'A';
    } else if (mean_3 >= 80.0) {
        return 'A';
    } else if (mean_3 >= 70.0) {
        return 'B';
    } else if (mean_3 >= 50.0 && (p_math >= 80 || p_eng >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main(void)
{
    int i, p_math, p_eng, p_jpn, n_iteration;
    char grade;

    while (1) {
        scanf("%d", &n_iteration);

        if (n_iteration == 0) {
            break;
        }

        for (i = 0; i < n_iteration; i++) {
            scanf("%d %d %d", &p_math, &p_eng, &p_jpn);
            grade = grading(p_math, p_eng, p_jpn);
            printf("%c\n", grade);
        }
    }
    return 0;
}    

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

int main() {

    int a, b, h, m; cin >> a >> b >> h >> m;
    double degA, degB, deg;
    degA = 2 * M_PI * ((double)h / 12 + (double)m / 720);
    degB = 2 * M_PI * (double)m / 60;
    deg = abs(degA - degB);
    cout << fixed << setprecision(11) << sqrt((double)(a * a + b * b - 2 * a * b * cos(deg))) << endl;
    return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    int a,b,c;
    cin>>a>>b>>c;
    string ans="No";
    if(a==b && b!=c){
        ans="Yes";
    }
    else if(a!=b && b==c){
        ans="Yes";
    }
    else if(a==c && b!=a){
        ans="Yes";
    }
    cout<<ans<<endl;

    return 0;

}
/*


*/


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

int main(){
    string S="keyence";
    string A,T; cin >> A;
    
    rep(i,A.size()){
        rep(j,A.size()){
            T=A;
            T.erase(i,j);
            if (T==S){
                cout << "YES";
                return 0;
            }
        }
    }
    cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000

int rec(int A[],int N,int k){
    int sum = 0;
    REP1(i,N) sum += (A[i]-k)*(A[i]-k);
    return sum;
}

int rec2(int A[],int N){
    int mini = INF;
    for (int i = -100; i <= 100; i++) {
        mini = min(rec(A,N,i),mini);
    }
    return mini;
}

int main(){
    INT(N);
    int A[100];
    REP1(i,N) INPUT(A[i]);
    cout << rec2(A,N) << endl;
    return 0;
}

Measured memory_bytes: 256
def sieve(n):
    from math import sqrt
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = is_prime[1] = False
    for i in range(int(sqrt(n))+1):
        if is_prime[i]:
            for k in range(2, n//i+1):
                is_prime[i*k] = False
    return is_prime

def is_like2017(n):
    for i in range(n+1):
        if is_primeL[i]:
            #print(i, (i+1)//2)
            if is_primeL[(i+1)//2]:
                is_likeL[i] = True

n = 100000
is_primeL = sieve(n)
is_likeL = [False for _ in range(n+1)]
is_like2017(n)

from itertools import accumulate

cumL = list(accumulate(is_likeL))
cumL[0] = 0

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(cumL[r] - cumL[l-1])


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

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

int main(){
  
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n;
	cin>>n;
	double d,p=0,ans;
	for(int i=0; i<n; i++){
		cin>>d;
		p=p+1/d;
	}
	ans=1/p;
	cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		sum += r - l + 1;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int ans=0;
  string a,b;
  cin>>a;cin>>b;
  for(int i=0;i<a.size();i++)
  {
    if(a[i]!=b[i])	ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 3860
import java.util.Scanner;
public class Main {
  public static void main (String args[]) {
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    n = n%10;
    if(n==3){
      System.out.print("bon");
    }else if(n==0 || n==1 || n==6 || n==8){
      System.out.print("pon");
    }else{
      System.out.print("hon");
    }
  }
}

Measured memory_bytes: 27036
from decimal import Decimal, ROUND_FLOOR


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


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


def divisible_count(a, b, d):
    a = Decimal(str(a))
    b = Decimal(str(b))
    d = Decimal(str(d))

    x = (b / d).quantize(Decimal("0"), rounding=ROUND_FLOOR)
    y = ((a - 1) / d).quantize(Decimal("0"), rounding=ROUND_FLOOR)
    return int(x - y)


A, B, C, D = map(int, input().split())

x = divisible_count(A, B, C)
y = divisible_count(A, B, D)
z = divisible_count(A, B, lcm(C, D))

print(B - A + 1 - (x + y - z))


Measured memory_bytes: 5076
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
A,B = map(float,input().split())
if math.floor(A) == 0 or B <= 0.005:
    print(0)
else:
    A = int(A)
    B *= 100.0
    B = round(B)
    c = A*B
    c = round(c)
    print(c // 100)
    

    





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

const int MAXN = 100005;

struct node {
	int to, next;
} edge[MAXN*2];
int head[MAXN], top = 0;
inline void push(int i, int j)
{ edge[++top] = (node) {j, head[i]}, head[i] = top; }

int n, a, b;

int dp[MAXN], lg[MAXN];

inline int lowbit(int i)
{ return i&(-i); }

int lab[MAXN];

void dfs(int nd, int f)
{
	int past = 0, minv = 0;
	for (int i = head[nd]; i; i = edge[i].next) {
		int to = edge[i].to;
		if (to == f) continue;
		dfs(to, nd);
		minv = max(minv, lg[past&dp[to]]);
		past |= dp[to];
	}
	past >>= minv;
	lab[nd] = lg[lowbit(past+1)]+minv;
	dp[nd] = (past+1)<<minv;
}

int main()
{
	scanf("%d", &n);
	lg[1] = 0;
	for (int i = 2; i <= n; i++) lg[i] = lg[i>>1]+1;
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		push(a, b), push(b, a);
	}
	dfs(1, 0);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, lab[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9088
def f(xa, ya, xb, yb, xc, yc, xd, yd)
  ((yc-ya)*(xb-xa)-(yb-ya)*(xc-xa)) * ((yd-ya)*(xb-xa)-(yb-ya)*(xd-xa))
end

while gets
  xa,ya,xb,yb,xc,yc,xd,yd = $_.split(",").map(&:to_f)
  if [f(xa,ya,xb,yb,xc,yc,xd,yd),f(xb,yb,xc,yc,xd,yd,xa,ya),f(xc,yc,xd,yd,xa,ya,xb,yb),f(xd,yd,xa,ya,xb,yb,xc,yc)].min > 0
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 6120
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int x;
    cin >> x;
    cout << (x + 1) / 2 << endl;
    return 0;
}


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

#define int long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) (int) v.size()
#define TASK ""

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

signed main() {
#ifdef LOCAL
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
if (strlen(TASK) > 0)
	freopen(TASK".in", "r", stdin),
	freopen(TASK".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
  
  int a, b;
  cin >> a >> b;
  cout << min(string(a, char('0' + b)), string(b, char('0' + a))) << "\n";

	return 0;
}


Measured memory_bytes: 256
A,B,N=map(int,input().split())
def f(x):
    return ((A*x)//B)-A*(x//B)
if N<=10**6:
    ans=0
    for x in range(1,N+1):
        ans=max(ans,f(x))
    print(ans)
elif B<=10**6:
    ans=0
    for x in range(1,min(B+1,N+1)):
        ans=max(ans,f(x))
    print(ans)
elif B>=A:
    x=0
    ans=0
    y=0
    while(x<=N):
        ans=max(ans,f(x))
        y+=1
        x=-((-B*y)//A)
    print(ans)
else:
    ans=0
    for x in range(1,min(B+1,N+1)):
        ans=max(ans,f(x))
    print(ans)



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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int min_cor = 1;
  int minm = INT_MAX;
  for (int i = 1; i <= 100; ++i) {
    int curr_pos = i;
    int curr_sum = 0;
    for (int j = 0; j < n; ++j) {
      curr_sum += (arr[j] - curr_pos)*(arr[j] - curr_pos);
    }
    if (curr_sum < minm) {
      minm = curr_sum;
      min_cor = i;
    }
  }
  cout << minm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"

int32_t main(){
	boost;
	cout << setprecision(30) << fixed;
	int n, k;
	cin >> n >> k;
	double a[n + 1];
	for(int i = 1, x; i <= n; i++) {
		cin >> x;
		a[i] = log2(x);
	}

	double sum = 0, pre = 0;
	for(int i = 1; i <= n; i++) {
		sum += a[i];
		if(i > k) {
			if(sum > pre) 
				cout << "Yes" << endl;
			else
				cout << "No" << endl;
			pre = sum;
			sum -= a[i - k + 1]; 
		}
		else if(i == k) {
			pre = sum;
			sum -= a[i - k + 1];
		}
	}
}

Measured memory_bytes: 5388
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        System.out.printf("%d %d %f\n", a / b, a % b, (double) a / b);
    }
}

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

int main() {
    ll n, k, a[200500];
    cin >> n >> k;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=k; i<n; i++) {
        if(a[i - k] < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll K,A,B;
    string S;
    cin >> K>>A>>B;
    ll flag = 0;

    for (ll i = A; i <= B; i++) {
        if(i%K==0){
            flag = 1;
        }
    }
    if(flag==1){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3640