akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

from collections import *

def prime_fact(n):
    prime = Counter()
    m = 0

    while not n % 2: 
        prime[2] += 1
        n //= 2
        m += 1

    x = 3
    while x**2 <= n: 
        c = 0
        while not n % x: 
            prime[x] += 1
            n //= x
            c += 1
        m = max(m, c)
        x += 2

    if n > 1: prime[n] += 1

    return prime, m

MOD = 10**9+7

class Comb:
    def __init__(self, N):
        self.fac = [1] * (N+5)
        for i in range(2, N+5): self.fac[i] = self.fac[i-1] * i % MOD

    def pow(self, a, b):
        res = 1
        while b:
            if b & 1: res = res * a % MOD
            a = a**2 % MOD
            b >>= 1
        return res

    def comb(self, n, r):
        if r < 0 or r > n: return 0
        return (self.fac[n] * self.pow(self.fac[r], MOD-2)) % MOD * self.pow(self.fac[n-r], MOD-2) % MOD

def main():
    N, M = list(map(int, input().split()))
    prime, m = prime_fact(M)

    comb = Comb(N-1+m)
    ans = 1

    for v in prime.values():
        ans = ans * comb.comb(N-1+v, v) % MOD

    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7276
s = input()
if 0 < int(s[:2]) <= 12 :
  if 0 <int(s[2:]) <= 12 :
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0 < int(s[2:]) <= 12 :
    print("YYMM")
  else:
    print("NA")

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

long long int gcd(long long int x, long long int y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

long long int lcm(long long int x, long long int y) { return abs(x-y)/gcd(x,y); }


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

  if(n>1 && m>1) { ans = (n-2)*(m-2); }
  else if(n==1) { ans = abs(m-2); }
  else if(m==1) { ans = abs(n-2); }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    int d[1000];
    cin >> n;
    rep(i, n){
        cin >> d[i];
    }

    ll sum = 0;
    rep(i, n){
        reps(j, i+1, n){
            sum += d[i]*d[j];
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
long long x,k;
cin>>x>>k;
long long n;
if(x>=k)
{
n=x/k;
cout <<min(x-n*k,abs(x-(n+1)*k));
}

else
{
cout <<min(x,abs(x-k));
}

}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
s=input()
t=input()
if(len(s)==len(t)):
    ans=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            ans+=1
    print(ans)
else:
    ans=1e9
    for i in range(len(s)-len(t)):
        tmp=0
        for j in range(len(t)):
            if s[i+j]!=t[j]:
                tmp+=1
        ans=min(ans,tmp)
    print(ans)

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

int main(void)
{
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    int max_x = x + r,min_x = x - r,max_y = y + r,min_y = y - r;
    if(0 <= min_x && max_x <= W && 0 <= min_y && max_y <= H)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define _GLIBCXX_DEBUG
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  int n;cin >> n;
  n %= 10;
  if(n == 3) cout << "bon" << endl;
  else if(n == 0||n == 1) {
    cout << "pon" << endl;
  }
  else if(n == 6||n == 8) {
      cout << "pon" << endl;
  }
  else cout << "hon" << endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;
typedef struct edge{
    int to;
    ll dist;
} E;

using namespace std;

int main()
{
    int N;
    cin >> N;
    // Gは無向グラフ
    vector<E> G[N];
    REP(i, N - 1)
    {
        int a, b;
        ll c;
        E edgeA, edgeB;
        cin >> a >> b >> c;
        a--;
        b--;
        edgeA.to = b;
        edgeA.dist = c; 
        G[a].push_back(edgeA);
        edgeB.to = a;
        edgeB.dist = c; 
        G[b].push_back(edgeB);
    }

    int Q, K;
    cin >> Q >> K;
    K--;
    int x[Q], y[Q];
    REP(i, Q)
    {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }

    // bfs で頂点K から各頂点の最短距離を計算する
    ll dist[N];
    bool visited[N] = {false};
    queue<int> bfsQ;
    int st = K;
    dist[st] = 0;
    visited[st] = true;
    bfsQ.push(st);

    while(!bfsQ.empty())
    {
        int now = bfsQ.front();
        bfsQ.pop();
        REP(i, G[now].size())
        {
            int next = G[now][i].to;
            if (!visited[next])
            {
                dist[next] = dist[now] + G[now][i].dist;
                visited[next] = true;
                bfsQ.push(next);
            }
        }
    }

    REP(i, Q)
    {
        ll ans = dist[x[i]] + dist[y[i]];
        cout << ans << endl;
    }
}


Measured memory_bytes: 10880
s = []
ac = 0
wa = 0
tle = 0
re = 0

gets.to_i.times do
  s << gets.chomp
end

s.each do |_s|
  case _s
  when 'AC'
    ac += 1
  when 'WA'
    wa += 1
  when 'TLE'
    tle += 1
  when 'RE'
    re += 1
  end
end

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

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

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

	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		int d_in;
		cin >> d_in;
		d.at(i) = d_in;
	}

	int sum = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			int heal = d.at(i) * d.at(j);
			sum += heal;
		}
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
#include<cstdio>

int h,w,n,mat[110][110], a[10010];

int main()
{
    scanf ("%d%d",&h,&w);
    scanf ("%d",&n);
    for (int i=1;i<=n;i++) scanf ("%d",&a[i]);
    int i=1, j=1;
    for (int p=1;p<=n;p++)
    {
        while (a[p]--)
        {
             //printf ("asdfsdf %d %d\n",i,j);
            mat[i][j]=p;
            if ((h==i) && (j%2)) j++;
            else
            if ( (i==1) && (!(j%2)) ) j++;
            else
            if (j%2) i++;
            else i--;

        }
    }
    //printf ("%d %d\n",h,w);
    for (int p=1;p<=h;p++)
    {
        for (int q=1;q<=w;q++) printf ("%d ",mat[p][q]);

        printf ("\n");
    }
    return 0;
}


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

int main()
{
  set<int> s;

  int i,x;
  int N;
  cin >> N;
  int ans=0;
  set<int>::iterator ite;;
  for (i=0;i<N;i++)
  {
    cin >> x;
    ite = s.find(x);
    if(ite == s.end()) {
      s.insert(x);
      ans += 1;
    }
    else {
      s.erase(x);
      ans -= 1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
  int x, y, size;
  int map[10][10] = {0};

  while (~scanf("%d,%d,%d", &x, &y, &size)){
    if ((0 <= x && x <= 9) && (0 <= y && y <= 9)) map[y][x]++;
    switch (size){
      case 1:
        if (0 <= y - 1 && y - 1 <= 9) map[y-1][x]++;
        if (0 <= y + 1 && y + 1 <= 9) map[y+1][x]++;
        if (0 <= x - 1 && x - 1 <= 9) map[y][x-1]++;
        if (0 <= x + 1 && x + 1 <= 9) map[y][x+1]++;
        break;
      case 2:
        if (0 <= y - 1 && y - 1 <= 9) map[y-1][x]++;
        if (0 <= y + 1 && y + 1 <= 9) map[y+1][x]++;
        if (0 <= x - 1 && x - 1 <= 9) map[y][x-1]++;
        if (0 <= x + 1 && x + 1 <= 9) map[y][x+1]++;
        if ((0 <= x - 1 && x - 1 <= 9) && (0 <= y - 1 && y - 1 <= 9)) map[y-1][x-1]++;
        if ((0 <= x - 1 && x - 1 <= 9) && (0 <= y + 1 && y + 1 <= 9)) map[y+1][x-1]++;
        if ((0 <= x + 1 && x + 1 <= 9) && (0 <= y - 1 && y - 1 <= 9)) map[y-1][x+1]++;
        if ((0 <= x + 1 && x + 1 <= 9) && (0 <= y + 1 && y + 1 <= 9)) map[y+1][x+1]++;
        break;
      case 3:
        if (0 <= y - 1 && y - 1 <= 9) map[y-1][x]++;
        if (0 <= y + 1 && y + 1 <= 9) map[y+1][x]++;
        if (0 <= x - 1 && x - 1 <= 9) map[y][x-1]++;
        if (0 <= x + 1 && x + 1 <= 9) map[y][x+1]++;
        if ((0 <= x - 1 && x - 1 <= 9) && (0 <= y - 1 && y - 1 <= 9)) map[y-1][x-1]++;
        if ((0 <= x - 1 && x - 1 <= 9) && (0 <= y + 1 && y + 1 <= 9)) map[y+1][x-1]++;
        if ((0 <= x + 1 && x + 1 <= 9) && (0 <= y - 1 && y - 1 <= 9)) map[y-1][x+1]++;
        if ((0 <= x + 1 && x + 1 <= 9) && (0 <= y + 1 && y + 1 <= 9)) map[y+1][x+1]++; 
        if (0 <= x + 2 && x + 2 <= 9) map[y][x+2]++;
        if (0 <= x - 2 && x - 2 <= 9) map[y][x-2]++;
        if (0 <= y + 2 && y + 2 <= 9) map[y+2][x]++;
        if (0 <= y - 2 && y - 2 <= 9) map[y-2][x]++;
        break;
    }
  }
  int w = 0, max = 0;
  for (int i = 0; i < 10; i++){
    for (int j = 0; j < 10; j++){
      if (!map[i][j]) w++;
      if (max < map[i][j]) max = map[i][j];
    }
  }
  printf("%d\n%d\n", w, max);

  return (0);
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>

int main() {
  int n;
  long long k;
  std::cin >> n >> k;
  std::vector <int> a(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
    a[i] -= 1;
  }
  int x = 0;
  std::vector <int> u(n, -1);
  int move = 0;
  u[0] = 0;
  while (k > 0) {
    //std::cerr << "x=" << x << " k=" << k << " move=" << move << " u[x]=" << u[x] << std::endl;

    x = a[x];
    move += 1;
    k -= 1;

    if (u[x] != -1) {
      k %= (move - u[x]);
      //std::cerr << "k <- " << k << std::endl;
    } else {
      u[x] = move;
    }
  }
  std::cout << (x + 1) << std::endl;
  return 0;
}


Measured memory_bytes: 4844
#include<stdio.h>

int main(void)
{
	int a;
	int b;
	int count;
	int num;
	
	while(scanf("%d %d", &a, &b) != EOF){
		num = a + b;
		count = 0;
		
		while (num > 0){
			count++;
			num /= 10;
		}
		
		printf("%d\n", count);
	}
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,j,k,l,m,n,b=0;
    string a;
    cin>>a;
    for(i=0;i<=a.size()-1;i++){
        if(a[i]=='C'){
            m=i;
            for(j=m;j<=a.size()-1;j++){
                if(a[j]=='F'){
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

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

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        d: usize,
        mat: [[f64; d]; n],
    }
    let mut cnt = 0;
    for i in 0..n {
        for j in i+1..n {

            let acc = mat[i].iter().zip(mat[j].iter()).map(|(a, b)| (a-b) * (a-b) ).sum::<f64>().sqrt();
 
            if acc.fract() == 0.0 {
                cnt += 1;
            }
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A * B, C * D) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;
long long fact[100005];
void initfact(){
	fact[0] = 1;
	for(long long i = 1; i < 100005; ++i){
		fact[i] = fact[i-1]*i;
		fact[i]%=mod;
	}
}
long long modpow(long long a, long long b){
	if(b == 1){
		return a%mod;
	}
	else{
		long long tmp = modpow(a,b/2);
		tmp*=tmp;
		tmp%=mod;
		if(b%2){
			tmp*=a;
			tmp%=mod;
		}
		return tmp;
	}
}
long long modinv(long long a){
	return modpow(a,mod-2);
}
long long nCr(long long n, long long r){
	//n!/(r!(n-r)!)
	if(n < r){
		return 0;
	}
	long long num = fact[n];
	long long den = fact[r]*fact[n-r];
	den%=mod;
	den = modinv(den);
	num*=den;
	num%=mod;
	return num;
}
int main(){
	initfact();
	long long minsums = 0;
	long long maxsums = 0;
	int n,k;
	cin >> n >> k;
	vector<long long>arr(n);
	for(int i = 0; i < n; ++i){
		cin >> arr[i];
	}
	sort(arr.begin(), arr.end());
	//checking for when they will be minimum
	for(int i = 0; i < n; ++i){
		long long other = n-i-1;
		long long numt = nCr(other,k-1);
		//cout << arr[i] <<" will be a minimum " << numt << " times \n";
		numt%=mod;
		numt*=arr[i];
		numt%=mod;
		minsums+=(numt);
		minsums%=mod;
	}
	//checking when they will be max
	for(int i = 0; i < n; ++i){
		long long other = n-i-1;
		long long numt = nCr(i,k-1);
		//cout << arr[i] << " will be a max "<<numt<<" times \n";
		numt%=mod;
		numt*=arr[i];
		numt%=mod;
		maxsums+=(numt);
		maxsums%=mod;
	}
	maxsums-=minsums;
	while(maxsums < 0){
		maxsums+=mod;
	}
	while(maxsums > mod){
		maxsums-=mod;
	}
	cout << maxsums <<"\n";
	return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

public class Main {

	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int L=sc.nextInt(),R=sc.nextInt();
		int ans=2019;
		int MOD=2019;
		for(int i=L;i<R && ans>0;i++)
			for(int j=i+1;j<=R && ans>0;j++) {
				int test=(int) (i*1L*j%MOD);
				ans=Math.min(ans, test);
				
			}
		out.println(ans);
		out.close();

	}
	
	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

}

Measured memory_bytes: 21076
a, b, c = map(int, input().split())
k = int(input())
count = 0
while True:
    if b > a:
        break
    b *= 2
    count += 1
while True:
    if c > b:
        break
    c *= 2
    count += 1

if count <= k:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9096
N = int(input())
F = []
for i in range(N):
    f = list(map(int,input().split()))
    F.append(f)


P = []
for i in range(N):
    p = list(map(int,input().split()))
    P.append(p)

ans = -(10**9)

"""
自分の店が開く時間帯の組み合わせを用意する.itertools?
その組み合わせの時間帯に営業している店を調べる。for文
店ごとにciをカウントしていく.for文
最後にansに店ごとのPを加算していき、マックスの値を調べる。ans = max(ans,~)
"""
#開いてる時間帯を1、開いてない時間帯を0とすると組み合わせは2**10通り
for i in range(2**10):
    check = [0]*10
    tmp = 0
    for j in range(10):
        if (i>>j)&1: #10個の時間帯で開いてる時間帯を探す
            check[j] = 1
    if any(check)==False:
        continue
    for k in range(N):
        cnt = 0 #同時間帯に営業している数
        for l in range(10):
            if F[k][l] == 1 and check[l] == 1:
                cnt += 1
        tmp += P[k][cnt]
    ans = max(ans,tmp)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu

const ll INF=1e9+7;
const ll N = 10002;
ll a,b,c,ans=INF,x,y;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c>>x>>y;
	for(ll i=0;i<200001;i+=2){
		ll w=i*c;
		ll aa=x-i/2;
		ll bb=y-i/2;
		if(aa>0)w+=aa*a;
		if(bb>0)w+=bb*b;
		ans=min(ans,w);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){

  int H, W;
  cin >> H >> W;
  string ans = "";
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      string s;
      cin >> s;
      if(s == "snuke"){
          ans += char(65+j) + to_string(i+1);
          cout << ans << endl;
          exit(0);
      }
    }
  }


}


Measured memory_bytes: 256
//

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int h, w, H, W;

int main() {
    cin >> H >> W;
    cin >> h >> w;
    cout << (H-h) * (W-w) << endl;

    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+') cout << a + b << endl;
	else cout << a - b << endl;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }

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

int main(){
    ll x;
    cin >> x;
    cout << (x^1) << endl;
    return 0;
}


Measured memory_bytes: 3588
# 各けたの和
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

x = int(input())

L = digitSum(x)

if L % 9 == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 11116
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#define FOR(i, a, b)  for(int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i, 1, n)
#define FORP(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i <(n); ++i)
#define SZ(x) ((int)(x).size )
#define ALL(x) (x).begin(), (x.end())
#define MSET(a, x) memset(a, x, sizeof(a))
using namespace std;


typedef long long int ll;
typedef pair<int, int> P;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
const double pi=3.14159265358979323846264338327950288L;
const double eps=1e-6;
const int mod = 998244353;
const int INF = 0x3f3f3f3f;
const int MAXN = 505;
const int xi[] = {0, 0, 1, -1};
const int yi[] = {1, -1, 0, 0};



int main() {
    int a, b, h;
    scanf("%d%d%d", &a, &b, &h);
    printf("%d\n", (a+b)*h/2);
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#define MAX_LEN 200000
using namespace std;
typedef long long llong;

int BinarySearch(llong A[], int n, int max_p, llong k){
    long long left = 0;
    long long right = max_p;
    long long middle;
    bool is_ok = false;
    while (left + 1< right){
        middle = (left + right) / 2;
        // printf("%lld %lld %lld\n", middle, left, right);
        is_ok = k < A[middle];
        if (is_ok){
            // printf("yes");
            right = middle;
        }else{
            // printf("no");
            left = middle;
        }
    }
    return left; // leftはk以下の値が降納されている最大のindexを指す
}

int main(){
    int n,i, index, check;
    llong half, money=0, tmp_money=0;

    check = scanf("%d", &n);

    llong A[n], B[n];

    for(i=0;i<n;i++){
        check = scanf("%lld", &A[i]);
        if(i>0){
            B[i] = A[i] + B[i-1];
        }else{
            B[i] = A[i];
        }
    }

    if(B[n-1] % 2 == 1){
        B[n-1] += 1;
        money += 1;
        half = B[n-1]/2;
        index = BinarySearch(B, n, n, half);

        money += 2*min((half-B[index]), B[index+1]-half);
        B[n-1] -= 2;
        tmp_money = 1;
        half --;
        index = BinarySearch(B, n, n, half);
        tmp_money += 2*min(half-B[index], B[index+1]-half);
        money = min(tmp_money, money);
    }else{
        half = B[n-1]/2;
        index = BinarySearch(B, n, n, half);
        money += 2*min(half-B[index], B[index+1]-half);
    }

    printf("%lld\n", money);
    return 0;

}

Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class BIT(object):
    def __init__(self,A,dot,e,inv=None):
        n=len(A)
        self.__n=n
        self.__dot=dot
        self.__e=e
        self.__inv=inv
        self.__node=['$']+A # 1-indexed
        for i in range(1,n+1):
            j=i+(i&-i)
            if(j<=n): self.__node[j]=dot(self.__node[i],self.__node[j])

    def add(self,i,w=1):
        i+=1
        while(i<=self.__n):
            self.__node[i]=self.__dot(self.__node[i],w)
            i+=i&-i

    def sum(self,i):
        i+=1
        res=self.__e
        while(i>0):
            res=self.__dot(res,self.__node[i])
            i-=i&-i
        return res

    def range_sum(self,l,r):
        assert(self.__inv)
        return self.__inv(self.sum(r-1),self.sum(l-1))

    def bisect_left(self,w,increase=True):
        n=self.__n
        k=2**((self.__n-1).bit_length())
        res=0
        now=self.__e
        while(k):
            if(res+k<=n and self.__dot(now,self.__node[res+k])<w and increase):
                now=self.__dot(now,self.__node[res+k])
                res+=k
            elif(res+k<=n and self.__dot(now,self.__node[res+k])>w and (not increase)):
                now=self.__dot(now,self.__node[res+k])
                res+=k
            k//=2
        return res

def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    idx=[0]*n
    for i,a in enumerate(A):
        idx[a-1]=i

    from operator import add
    bit=BIT([0]*n,add,0)

    ans=0
    for k in range(n,0,-1):
        i=idx[k-1]
        bit.add(i)
        s=bit.sum(i)
        l0=bit.bisect_left(s-1)-(s<=1)
        l1=bit.bisect_left(s-2)-(s<=2)
        r0=bit.bisect_left(s+1)
        r1=bit.bisect_left(s+2)
        ans+=k*((i-l0)*(r1-r0)+(l0-l1)*(r0-i))
    print(ans)
resolve()

Measured memory_bytes: 64924
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;


typedef pair<ll,ll> p;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;
  
int main() {
  int N;
  cin >> N;
  int zero=0;
  map<p,P> mp;
  rep(i,N) {
    ll a,b;
    cin >> a >> b;
    if(a==0&&b==0) {
      zero++;
      continue;
    }
    ll g = __gcd(a,b);
    a /= g;
    b /= g;
    if(b<0) {
      a *= -1;
      b *= -1;
    }
    if(a<=0) {
      ll tmp = a;
      a = b;
      b = -tmp;
      mp[p(a,b)].first++;
    } else {
      mp[p(a,b)].second++;
    }
  }
  mint ans = 1;
  for(auto now:mp) {
    int x = now.second.first;
    int y = now.second.second;
    mint acc = mint(2).pow(x)-1;
    acc += mint(2).pow(y)-1;
    acc += 1;
    ans *= acc;
  }
  ans += zero;
  ans -= 1;
  cout << ans.x << endl;
  return 0;
}

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

int main()
{
	long long int s = 0;
	int a[200001] = {0};
	int n;
	int x[200000];
	int i;
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%d", x + i);
		a[x[i]]++;
	}
	for(i = 1; i <= n; i++)
	{
		s += (long long int) a[i]*(a[i]-1)*0.5;
	}
	for(i = 0; i < n; i++)
	{
		printf("%lld\n", s - a[x[i]] + 1);
	}
	
	
}

Measured memory_bytes: 4096
#include <cstdio>
#include <cstring>
#include <algorithm>
 
using std::inplace_merge;
using std::sort;
 
const int MAXN=200005;
int n;
int a[MAXN],b[MAXN];
 
void mge_sort(int a[],long long mid){
	int pos=n;
	for(int i=0;i<n;++i){
		if(pos==n&& a[i]>=mid) pos=i;
		a[i]&=mid-1;
	}
	inplace_merge(a,a+pos,a+n);
}
 
inline long long cal(long long lim){
	long long ret=0;
	for(int i=0,cur=n-1;i<n;++i){
		while(cur>=0 && a[i]+b[cur]>=lim)
			--cur;
		ret+=n-1-cur;
	}
	return ret;
}
 
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)
		scanf("%d",&a[i]);
	for(int i=0;i<n;++i)
		scanf("%d",&b[i]);
	sort(a,a+n),sort(b,b+n);
	int ans=0;
        long long tmp;
	for(int i=29;i>=0;--i){
		mge_sort(a,2LL<<i),mge_sort(b,2LL<<i);
		tmp=cal(1LL<<i)-cal(2LL<<i)+cal(3LL<<i);
		ans|=(tmp&1)<<i;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

#define M 500000
#define S 1000000000
void Merge(int[],int,int,int);
void Mergesort(int[],int,int);
int SS[M];
int count = 0;

main(){

  int n;
  int i;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d",&SS[i]);
  }

  Mergesort(SS,0,n);

  for(i = 0 ;i <= n - 2 ; i++ ){
    printf("%d ",SS[i]);
  }

  printf("%d\n",SS[n - 1]);
  printf("%d\n",count);

  return 0;

}



void Mergesort(int SS[],int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    Mergesort(SS, left, mid);
    Mergesort(SS, mid, right);
    Merge(SS, left, mid, right);
  }
}


void Merge(int SS[],int left,int mid,int right){
  int n1,n2,i = 0,j = 0,k = 0;
  int L[M],R[M];

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1 ; i++){
    L[i] = SS[left + i];
  }

  for(j = 0 ; j < n2 ;j++ ){
   R[j] = SS[mid + j];
  }



//L[n1] = S;                                                                            
  //R[n2] = S;                                                                            




  i = 0;
  j = 0;
  L[n1] = S;
  R[n2] = S;


  for(k = left ; k < right; k++){
    if(L[i] <= R[j]){
      SS[k] = L[i];
      count++;
      i++;
    }
    else{
      SS[k] = R[j];
      count++;
      j++;
    }
  }
}

Measured memory_bytes: 5580
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    stack<int> stk;
    for(int i=0; i<n; ++i){
        int d;
        cin >> d;
        if(a <= d)
            stk.push(d);
        else
            break;
    }

    if(n - (int)stk.size() < m){
        while(!stk.empty() && stk.top() <= b)
            stk.pop();
    }
    cout << stk.size() << endl;

    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
vector<int> A;
int cnt;
void insertionSort(int n,int g){
    int j,v;
    for (int i = g; i< n;i++){
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
    
}
void shellSort(int n){
    cnt = 0;
    int siz=0;
    vector<int> G;
    while(1){
        siz=siz*3+1;
        if(siz>=n&&siz!=1)break;
        G.push_back(siz);
    }
    cout << G.size() <<endl;
    for(int i =G.size()-1;i>=0;i--){
        insertionSort(n, G[i]);cout <<G[i] <<((i!=0)?" ":"\n");
    }
}

int main(void){
    int n,t;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> t;
        A.push_back(t);
    }
    shellSort(n);
    cout << cnt<<endl;
    for(int i:A){
        cout << i<<endl;
    }
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, A, B; cin >> N >> A >> B; swap(A, B);

	if (A + B == N + 1) {
		vi arr (N);
		F0R(i, B - 1) arr[i] = 1 + i;
		FOR(i, B - 1, N) arr[i] = N - (i - B + 1);
		for (int x : arr) cout << x << " ";
		cout << endl;
		return 0;
	}
	
	if (A + B > N + 1) {
		cout << -1 << endl;
		return 0;
	}

	vi arr (N);
	int onLeft = 0;
	while (true) {
		F0R(i, A) arr[onLeft * A + i] = A - i + onLeft * A;
		--B;
		if (B < 0) {
			cout << -1 << endl;
			return 0;
		}
		++onLeft;
		if (N - onLeft * A - B < A) break;
	}
	int gap = N - onLeft * A - B;
	if (gap > 0 && B == 0) {cout << -1 << endl; return 0;}
	F0R(i, B) {
		arr[N-1-i] = N - i - gap;
	}
	
	int hi = N;
	for (int x = onLeft * A; x < N && arr[x] == 0; ++x) {
		arr[x] = hi; --hi; 
	}

	for (int x : arr) cout << x << " ";
	cout << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
  int main() {
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(s==u)
      cout<<a-1<<" "<<b<<endl;
    else if(t==u)
      cout<<a<<" "<<b-1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

const int L = 200005;

int n, k, a[L], tot = 0, cnt;
int b[L];

int main()
{
	scanf("%d%d", &n, &k);
	char c = getchar();
	while (c < '0' || c > '1') c = getchar();
	while (c == '0' || c == '1')
		a[tot++] = c - '0', c = getchar();
	if (n == 1)
	{
		printf("1");
		return 0;
	}
	int sec = a[0], bc = 1;
	if (a[0] == 1) cnt = 0;
	else cnt = 1;
	for (int s = 1; s < n; s++)
	{
		if (a[s] != sec)
		{
			b[cnt++] = bc;
			bc = 1, sec = a[s];
		}
		else bc++;
	}
	b[cnt++] = bc;
	int cn0;
	if (a[0] == 1) cn0 = cnt >> 1;
	else cn0 = (cnt+1) >> 1;
	if (cn0 <= k)
	{
		printf("%d", n);
		return 0;
	}
	int len = k << 1 | 1;
	int ans = 0, sum = 0;
	for (int s = 0; s < len; s++) sum += b[s];
	ans = sum;
	for (int s = 2; s + len <= n+1; s += 2)
	{
		sum = sum - b[s-2] - b[s-1] + b[s+len-2] + b[s+len-1];
		ans = max(ans, sum);
	}
	printf("%d", ans);
}


Measured memory_bytes: 1024
import itertools
mod=10**9+7
n,k=map(int,input().split())
A=range(n+1)
b = [0] + list(itertools.accumulate(A))
ans=0
for i in range(k,n+2):
    ans+=b[-1]-b[-1-i]-b[i]+1
print(ans%mod)

Measured memory_bytes: 20904
#include<stdio.h>
int main()
{
    int i,j,n,m,t;
    scanf("%d",&n);

    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&m);
    int b[m];
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    t=0;
    for(i=0;i<n&&i<m;i++){
        if(a[i]<b[i]){
            t=1;
        break;}
        else if(a[i]>b[i]){
            t=0;
            break;}
        else if(a[i]==b[i])
            t=2;
       }
        if(t==1)
            printf("1\n");
        else if(t==0)
            printf("0\n");
        else if(t==2){
            if(m>n)
                printf("1\n");
            else
                printf("0\n");
        }
   return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int a[5][200];
int ans[5][200];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= 2; ++i) {
		for (int j = 1; j <= n; ++j) {
			cin >> a[i][j];
		}
	}
	
	for (int i = n; i >= 1; --i) {
		ans[2][i] = ans[2][i + 1] + a[2][i];
	}
	
	for (int i = n; i >= 1; --i) {
		ans[1][i] = max(ans[2][i] , ans[1][i + 1]) + a[1][i];
	}

	printf("%d", ans[1][1]);
	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val list = readInputLine().split(" ").map { it.toInt() }

    for (i in 0..2) {
        if (list.count { it == list[i] } == 1) {
            println(list[i])
            return
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}


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

count = 0
yes = False

for i in range(N):
  a , b = map(int, input().split())
  
  if a==b:
    count +=1
    if count >= 3:
      print("Yes")
      yes = True
      break
  else:
    count = 0

if not(yes):
  print("No")

Measured memory_bytes: 9180
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{ return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{ return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

void swap(int *a, int *b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);

  int a[100001], used[100001];
  rep(i, n) {
    scanf("%d", &a[i]);
    used[i] = a[i];
  }

  qsort(used, n, sizeof(int), des);

  int i, j;
  for (i = 0; i < m;) {
    used[0] /= 2;
    i++;
    for (j = 0; j < n - 1; j++) {
      if (used[j] < used[j + 1] && i < m) {
        used[j + 1] /= 2;
        swap(&used[j], &used[j + 1]);
        i++;
      }
      else break;
    }
    qsort(used, n, sizeof(int), des);
    if (used[0] == 0) break;
  }

  long long int sum = 0;
  rep(i, n) {
    sum += used[i];
  }
  printf("%lld\n", sum);
  return 0;
}


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

// definitions
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define pb push_back
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dq;
typedef long long int lli;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;


// standard functions
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 


ll modexp(ll x, ll ex, ll modp) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x)%modp;
        ex >>= 1ll;
        x = (x * x)%modp;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}

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

const ll MAXSIEVE=(1e3);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

// code beigns in main
int main()
{
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        ld r;
        cin >> r;

        ld area=M_PI*r*2;
        cout << area << endl;
    }
}



Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,Ma,Mb;
int a[45],b[45],c[45],d[45];
map<int,int> m;
int main(){
	cin >> N >> Ma >> Mb;
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]*=Mb;
		b[i]*=Ma;
		d[i]=a[i]-b[i];
	}
	int M = N/2;
	int ans = INF;
	for(int i=1;i<(1<<M);i++){
		int s = 0, cost = 0;
		for(int j=0;j<M;j++){
			if((i>>j)&1){
				s+=d[j];
				cost+=c[j];
			}
		}
		map<int,int>::iterator it = m.find(s);
		if(s==0)ans = min(ans,cost);
		if(it==m.end())m[s]=cost;
		else (it->sec)=min((it->sec),cost);
	}
	for(int i=1;i<(1<<(N-M));i++){
		int s = 0, cost = 0;
		for(int j=0;j<(N-M);j++){
			if((i>>j)&1){
				s+=d[j+M];
				cost+=c[j+M];
			}
		}
		int tar = -s;
		map<int,int>::iterator it = m.find(tar);
		if(tar==0)ans = min(ans,cost);
		if(it!=m.end()){
			ans = min(ans,cost+(it->sec));
		}
	}
	if(ans==INF)ans = -1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string a,b;
    cin >> a;
    cin >> b;
    if (a.size() > b.size())
        cout << "GREATER" << endl;
    else if (a.size() < b.size())
        cout << "LESS" << endl;
    else{
        for (int i = 0; i < a.size(); ++i){
            if (a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }
            else if (a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
}

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

typedef long long ll;
ll N,M;
ll inf = 1e9+7;
int main(){
	cin >> N >> M;
	if(abs(N-M)>1){
		cout << 0 << endl;
		return 0;
	}
	ll fact[100010] = {0};
	for(int i=0;i<=max(N,M);i++){
		if(i==0) fact[i] = 1;
		else fact[i] = (fact[i-1]*i)%inf;
	}
	if(N==M){
		cout << (fact[N]*fact[M]*2)%inf << endl;
	}else{
		cout << (fact[N]*fact[M])%inf << endl;
	}
}

Measured memory_bytes: 1024
import java.util.*;
import javax.lang.model.util.ElementScanner6;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int l = sc.nextInt();

        // 処理
        double part = l / 3.0;
        double out = part * part * (l - 2 * part);

        // 出力
        //System.out.println(out);
        System.out.println(String.format("%.10f", out));
    }
}

Measured memory_bytes: 21972
N = int(input())
x = y = 0
for i in range(N):
	t, nx, ny = map(int, input().split())
	d = abs(nx - x) + abs(ny - y)
	if t < d or (t - d) % 2 == 1:
		print("No")
		break
else:
	print("Yes")


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

int main() {

    int n, d;
    cin >> n >> d;

    int m = 2 * d + 1;
    int ans = 0;
    if(n % m == 0){
        ans = n / m;
    }
    else{
        ans = (n + m) / m;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

cnt = 0
import itertools
for i in itertools.combinations(range(N), 2):
  dist = 0
  for j in range(D):
    dist += (X[i[0]][j] - X[i[1]][j]) ** 2
  if is_integer_num(dist ** (1/2)):
    cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define um(a,b) unordered_map<a,b>
#define vv(a) vector<a>
#define pp(a,b) pair<a,b>
ll power(ll a,ll b,ll mod){  ll ans=1;  while(b>0){
  if(b&1){ ans=(ans*a)%mod;} a=(a*a)%mod;  b=b/2; } return ans;}
#define imax 100
int main(){
FIO
 string s,r;
 cin>>s>>r;
 ll count=0;
 for(int i=0;i<s.length();i++){
    if(s[i]!=r[i])
        count++;
 }
 cout<<count<<endl;
}


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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n+1), ans(n+1);
	for(int i=1; i<=n; i++) {
		cin >> a[i];	
	}
	for(int i=(n+2)/2; i<=n; i++) {
		ans[i] = a[i];
	}
	for(int i=(n+2)/2-1; i>=1; i--) {
		int sum = 0;
		for(int j=i*2; j<=n; j+=i)
			sum += ans[j];
		ans[i] = sum%2 != a[i];
	}
	int t = 0;
	for(int i=1; i<=n; i++)
		t += ans[i];
	cout << t << '\n';
	for(int i=1; i<=n; i++) {
		if(ans[i])
			cout << i << ' ';
	}
}

Measured memory_bytes: 2560