akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	sort.Ints(A)
	L := -INF
	R := INF
	for abs(L-R) > 1 {
		M := (L + R) / 2
		sum := 0
		for i := 0; i < N; i++ {
			if A[i] < 0 {
				l := i
				r := N
				for abs(l-r) > 1 {
					mid := (l + r) / 2
					if A[i]*A[mid] <= M {
						r = mid
					} else {
						l = mid
					}
				}
				sum += N - r
			} else {
				l := i
				r := N
				for abs(l-r) > 1 {
					mid := (l + r) / 2
					if A[i]*A[mid] <= M {
						l = mid
					} else {
						r = mid
					}
				}
				sum += l - i
			}
		}
		if sum < K {
			L = M
		} else {
			R = M
		}
	}
	fmt.Fprintln(wtr, R)
}


Measured memory_bytes: 6528
#include<iostream>
using namespace std;
static const int N = 100;

int main(){
  int M[N][N];
  int n,u,k,v;

  cin >> n;

  for(int i = 0; i < n; i++){
    for(int j = 0; j <n; j++)M[i][j]=0;
  }

  for(int i = 0;i <n; i++){
    cin >> u >> k;
    u--;
    for(int j =0; j <k; j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  for( int i =0;i<n;i++){
    for(int j =0;j<n;j++){
      if(j)cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

int main() {
    int a;
    cin>>a;
    vector<int> v(a);
    for(auto &s:v){
		cin>>s;
	}
	int lk=0;
	for(int i=0;i<a;i++){
		if(v[i]==(lk+1)) lk++;
	}
	if(lk==0){
		 cout<<"-1"<<endl;
		return 0;
	}
	cout<<a-lk<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int x,a,b;
  cin>>x>>a>>b;
   int z=x+a; //zは限界
  
  if(b<a+1){
    cout<< "delicious"<<endl;
  }
  if(b<z+1){
    if(!(b<a+1)){
    cout<< "safe"<<endl;
    }
  }
  if(b>z){
  cout<< "dangerous"<<endl;
  }
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, M, h, w;

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

    cout << (N - h) * (M - w) << endl;
    return 0;
}


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

class Main{
    final static long MOD = 1000000007;
    FastScanner sc = new FastScanner();

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve(){

        String s = sc.next();

        if(s.equals("SAT")) System.out.println(1);
        if(s.equals("FRI")) System.out.println(2);
        if(s.equals("THU")) System.out.println(3);
        if(s.equals("WED")) System.out.println(4);
        if(s.equals("TUE")) System.out.println(5);
        if(s.equals("MON")) System.out.println(6);
        if(s.equals("SUN")) System.out.println(7);

    }

    long gcd(long a, long b){ // return aとbの最大公約数
        if(b == 0){
          return a;
        }
        return gcd(b, a % b);
    }

    long pow_mod(long a, long r){ // return a^r (mod MOD)
        long sum = 1;
        while(r > 0){
            if((r & 1) == 1){
                sum *= a;
                sum %= MOD;
            }
            a *= a;
            a %= MOD;
            r >>= 1;
        }
        return sum;
    }



}



class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr < buflen){
            return true;
        }else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }catch(IOException e){
                e.printStackTrace();
            }
            if(buflen <= 0){
                return false;
            }
        }
        return true;
    }
    private int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c){ return 33 <= c && c <= 126;}
    public boolean hasNext(){ while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next(){
        if(!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong(){
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b){
            throw new NumberFormatException();
        }
        while(true){
            if('0' <= b && b <= '9'){
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt(){
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble(){ return Double.parseDouble(next());}
}


Measured memory_bytes: 21204
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

 
  llong n;
  cin >> n;


  string ans = "";
  while(n > 0){
    n--;
    char c = 'a' + (n % 26);
    ans = c + ans;
    n /= 26;
  }

  cout << ans << endl;

  return 0;

}





Measured memory_bytes: 3132
#include<stdio.h>
#define MAX 2000000000

int H, A[MAX];

void maxHeapify(int i){
  int l, r, largest,keep;
  l = 2*i;
  r = 2*i+1;
  if( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if( r <= H && A[r] > A[largest] ) largest = r;
  if( largest != i){
    keep = A[i];
    A[i] = A[largest];
    A[largest] = keep;
    maxHeapify(largest);
  }
}

int main(){
  int i;
  scanf("%d", &H);
  for( i = 1 ; i <= H ; i++ ){
    scanf("%d", &A[i]);
  }
  for( i = H/2 ; i >= 1 ; i-- ) maxHeapify(i);
  for( i = 1 ; i <= H ; i++ ){
    printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int x = scanner.nextInt();
    
    if(x < 1200) {
      System.out.println("ABC");
    } else {
      System.out.println("ARC");
    }
  }
}


Measured memory_bytes: 35652
/**
 *    author:  math2do
 *    created: 24.11.2019 17:55:09
**/

#include <bits/stdc++.h>

using namespace std;

map <string, int> mp = {{"SUN", 0}, {"MON", 1}, {"TUE", 2}, {"WED", 3}, {"THU", 4}, {"FRI", 5},{"SAT", 6}};
                       
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  string day;
  cin >> day;
  cout << 7 - mp[day] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n+1];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<k;i++)
  {
      sum += a[i];
  }
  cout<<sum<<endl;
  return 0; 
}  

Measured memory_bytes: 3600
N,M = map(int, input().split())
X = [0]*(N+2)
for i in range(M):
    l,r = map(int, input().split())
    X[l] += 1
    X[r+1] -= 1

for i in range(N):
    X[i+1] += X[i]
ans = X.count(M)
print(ans)

Measured memory_bytes: 6900
n = int(input())
height = [int(i) for i in input().split()]

cost = [0]
cost.append(abs(height[0]-height[1]))

for i in range(2,n):
    c = min(cost[i-2] + abs(height[i]-height[i-2]), cost[i-1] + abs(height[i]-height[i-1]) )
    cost.append(c)
print(cost[-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,C,a,b;
    vector<pair<int,int>> XV;
    cin >> N >> C;
    REP(i,N){
        cin >> a >> b;
        XV.push_back({a,b});
    }
    
    int Ans=0;
    
    vector<pair<int,int>> YV;
    RREP(i,N){
        YV.push_back({C-XV[i].first,XV[i].second});
    }
    
    
    vector<pair<int,int>> X,Y;
    int sum=0;
    REP(i,N){
        sum+=XV[i].second;
        X.push_back({XV[i].first,sum});
    }
    sum=0;
    REP(i,N){
        sum+=YV[i].second;
        Y.push_back({YV[i].first,sum});
    }
    
    /*REP(i,N){
        cout << X[i].first MM X[i].second << endl;
    }*/
    
    //直線取り
    REP(i,N){
        Ans=max(Ans,X[i].second-X[i].first);
    }
    REP(i,N){
        Ans=max(Ans,Y[i].second-Y[i].first);
    }
    
    vector<int> X1,X2,Y1,Y2;
    X1.push_back(0);
    X2.push_back(0);
    Y1.push_back(0);
    Y2.push_back(0);
    
    int numx1=0,numx2=0,numy1=0,numy2=0;
    REP(i,N){
        numx1=max(numx1,X[i].second-X[i].first);
        numx2=max(numx2,X[i].second-2*X[i].first);
        numy1=max(numy1,Y[i].second-Y[i].first);
        numy2=max(numy2,Y[i].second-2*Y[i].first);
        
        X1.push_back(numx1);
        X2.push_back(numx2);
        Y1.push_back(numy1);
        Y2.push_back(numy2);
    }
    
    /*REP(i,N+1){cout << X1[i] << " ";}cout << endl;
    REP(i,N+1){cout << X2[i] << " ";}cout << endl;
    REP(i,N+1){cout << Y1[i] << " ";}cout << endl;
    REP(i,N+1){cout << Y2[i] << " ";}cout << endl;*/
    
    reverse(Y1.begin(),Y1.end());
    reverse(Y2.begin(),Y2.end());
    REP(i,N+1){
        int num=0;
        //Xで引き返しYに行く
        num=X2[i]+Y1[i];
        Ans=max(Ans,num);
        num=X1[i]+Y2[i];
        Ans=max(Ans,num);
    }
    
    
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 11888
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        k: i64,
        a: [i64; n],
    }
    let mut l = 0;
    let mut r = *a.iter().max().unwrap();
    while l + 1 != r {
        let m = (l + r) / 2;
        let cuts: i64 = a.iter().map(|&x| (x + m - 1) / m - 1).sum();
        if cuts <= k {
            r = m;
        } else {
            l = m;
        }
    }

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


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

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

// Union-Find 木 (Verified: AtCoder Typical Contest 001 B)
struct UnionFind {
private:
    const int n;
    int __size;
    vector<int> uf;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1) {}
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    // 集合はいくつあるか
    int size()      {return __size;}
    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        __size--;
        if(uf[y] < uf[x]) swap(x, y);
        uf[x] += uf[y]; uf[y] = x;
    }
};

signed main() {
    int N, M; cin >> N >> M;
    UnionFind uf(N);
    for(int i=0; i<M; i++) {
        int u, v, z; cin >> u >> v >> z;
        u--; v--;
        uf.unite(u, v);
    }
    cout << uf.size() << endl;
    return 0;
}


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

using namespace std;

int main() {
    // Input
    int A, B, C;
    cin >> A >> B >> C;

    // Process
    string ans;
    if (A + B + C == 17){
        ans = "YES";
    } else {
        ans = "NO";
    }

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x


using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int n;cin>>n;
    vector<int> A(n);cin>>A;
    
    ll ev = 0;
    ll od = 0;
    
    if(A[0]%2==0){
        ev = 1;
        od = 2;
    }else{
        ev = 2;
        od = 1;
    }
    
    for(auto i = 1; i<n;i++){
        
        if(A[i]%2==0){
            ev = ev*3 + od;
            od = 2*od;
        }else{
            ev = ev*3 + 2*od;
            od = od;
        }
        
        
    }
    
    cout<<ev<<endl;
    

    return 0;
    
    
}




Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts, OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

main = do
  [c1,c2] <- words <$> getLine
  putStrLn $ if c1 == c2 then "=" else if c1 < c2 then "<" else ">"


-- util
getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine



Measured memory_bytes: 380
from collections import deque
n=int(input())
a=[int(i) for i in input().split()]
b=deque()
for i in range(n):
    if i%2==0:
        b.appendleft(a[i])
        
    else:
        b.append(a[i])

if n%2==0:
    b.reverse()

for i in range(n):
    if i!=n-1:
        print(b[i],end=" ")
    else:
        print(b[i])

Measured memory_bytes: 25412
using System;

namespace abc136B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int Ans = 0;
            for(int i = 1; i <= N; i++)
            {
                string M = i.ToString();
                if (M.Length % 2 == 1)
                    Ans = Ans + 1;
            }
            Console.WriteLine(Ans);
        }
    }
}


Measured memory_bytes: 13140
#include <stdint.h>

#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <set>

struct Line {
  int L;
  int R;
};

int main(int argc, char *argv[]) {
  int N;
  std::cin >> N;
  std::vector<Line> list;  // <count, <L, R>>
  for (int i = 0; i < N; i++) {
    int x, len;
    std::cin >> x >> len;
    const int l = x - len, r = x + len;
    list.push_back({l, r});
  }
  std::sort(list.begin(), list.end(), [](const Line &lhs, const Line &rhs) {
    return lhs.L < rhs.L;
  });
  std::set<std::pair<int, int>> best;  // <R, best_count>
  for (int i = 0; i < list.size(); i++) {
    auto it = best.lower_bound({list[i].L + 1, 0});
    if(it == best.begin()) {
      best.insert({list[i].R, 1});
      continue;
    }
    --it;
    int count = it->second + 1;
    it = best.insert({list[i].R, count}).first;
    ++it;
    while(it != best.end()) {
      if(it->second <= count){
        it = best.erase(it);
        continue;
      }
      ++it;
    }
  }

  int best_count = 0;
  for(auto &e : best) {
    if(e.second > best_count)
      best_count = e.second;
  }
  std::cout << best_count << std::endl;

  return 0;
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll inf = 3e18;
const char sp = ' ';

int N;
ll A[100000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	int L, R;
	L = -1;
	R = N;
	while (L + 1 != R) {
		int m = (L + R) / 2;
		ll t = 0;
		for (int i = 0; i <= m; i++) {
			t += A[i];
		}
		bool f = true;
		for (int i = m + 1; i < N; i++) {
			if (t + t >= A[i]) {
				t += A[i];
			}
			else {
				f = false;
				break;
			}
		}
		if (f) {
			R = m;
		}
		else {
			L = m;
		}
	}
	cout << N - R << endl;;
}

Measured memory_bytes: 1024
import sys
import heapq

sys.setrecursionlimit(10000000)

n,m= map(int,input().split())

jobs = [[] for _ in range(m) ]

for i in range(n):
    a,b= map(int,input().split())
    if a > m:continue
    jobs[m-a].append(b)
q=[]
heapq.heapify(q)
ans=0

for i in range(m-1,-1,-1):
    for b in jobs[i]:
        heapq.heappush(q,-b)

    if q:
        ans+= -heapq.heappop(q)

print(ans)

Measured memory_bytes: 18432
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

using namespace std;

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

  vector<P> v;
  rep(i, m) {
    int s, c;
    cin >> s >> c;
    v.push_back(make_pair(s, c));
  }

  rep(i, 1000) {
    string s = to_string(i);
    if (s.length() != n) continue;
    bool isOk = true;

    for_each(v.begin(), v.end(), [&](P& elem) {
      int index = elem.first;
      index--;
      if (s[index] - '0' != elem.second) {
        isOk = false;
        return;
      }
    });
    if (isOk) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
int main()
{
	/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif*/
ios_base::sync_with_stdio(0);
cin.tie(0);

int k;
cin>>k;
string s,a;
cin>>s;
if(s.size()<=k){
	cout<<s;
}
else{
	a=s.substr(0,k);
	cout<<a<<"...";
}




return 0;
}


Measured memory_bytes: 3604
package main

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

func main() {
    s := inputIO()
    res := strings.Split(s, " ")
    
    a, errA := strconv.Atoi(res[0])
    b, errB := strconv.Atoi(res[1])
    
    if errA != nil || errB != nil {
        panic("Atoi err")
    }
    
    fmt.Println(a * b, a * 2 + b * 2)
}

func inputIO() (result string) {
    scanner := bufio.NewScanner(os.Stdin)

    scanner.Scan()
    result = scanner.Text()
    return
}



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


bool non[200];
int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int N , K;
	cin >> N >> K;
	for (int i = 0 ; i < K ; i++)
	{
		int a;
		cin >> a;
		for (int j = 0 ; j < a ; j++)
		{
			int b;
			cin >>b;
			non[b] = true;
		}
	}
	int nb = 0;
	for (int i = 1 ; i <= N ; i++)
	{
		if (!non[i]) nb++;
	}
	cout<<nb<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
	string s;
	cin >> s;
	int ans = inf;
	for(char c='a'; c<='z'; c++){
		string t = s;
		int sub = 0;
		while(!t.empty()){
			bool all = true;
			for(int i=0; i<(int)t.length(); i++){
				if(t[i]!=c){
					all = false;
					break;
				}
			}
			if(all) break;
			for(int i=0; i<(int)t.length()-1; i++){
				if(t[i+1]==c) t[i]=c;
			}
			t.pop_back();
			sub++;
		}
		ans = min(ans, sub);
	}
	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 FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N, Y;
    cin >> N >> Y;
    Y /= 1000;

    vector< vector<int> > ans(Y+1, vector<int>(3, 0));
    // can, 5000, 10000
    ans[Y][0] = 1;
    for(int i=Y; i>=0; i--){
        if(ans[i][0]){
            if(i-4 >= 0 && !ans[i-4][0]){
                ans[i-4][0] = 1;
                ans[i-4][1] += ans[i][1]+1;
                ans[i-4][2] = ans[i][2];
            }
            if(i-9 >= 0 && !ans[i-9][0]){
                ans[i-9][0] = 1;
                ans[i-9][1] = ans[i][1];
                ans[i-9][2]+=ans[i][2]+1;
            }
        }
    }
    if(N > Y || !ans[N][0] || N-ans[N][1]-ans[N][2] < 0) cout << "-1 -1 -1" << "\n";
    else cout << ans[N][2] << " " << ans[N][1] << " " << N-ans[N][1]-ans[N][2] << "\n";
    return 0;
}

Measured memory_bytes: 1408
from collections import Counter
N, P = map(int, input().split())
ans = 1
prime_dict = Counter()
i = 2
while i**2 <= P:
    if P % i == 0:
        P //= i
        prime_dict[i] += 1
        continue
    i += 1
prime_dict[P] += 1
for k, v in prime_dict.items():
    ans *= k ** (v // N)
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
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; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    char s,l;
    cin >> s >> l;
    if (s==l){
        cout << "H" << endl;
    }else{
        cout << "D" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int N,M;

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

    int ans;
    if(N<=1){
        ans+=0;
    }else{
        ans+=N*(N-1)/2;
    }

    if(M<=1){
        ans+=0;
    }else{
        ans+=M*(M-1)/2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

x = [0] * n
y = [0] * n
z = [0] * n

for i in range(n):
    x[i], y[i], z[i] = map(int, input().split())

def score_sum(f):
    score = [0] * n
    for i in range(n):
        score[i] = f(x[i], y[i], z[i])
    score.sort(reverse=True)
    return sum(score[:m])

score_max = score_sum(lambda x, y, z: x + y + z)
score_max = max(score_sum(lambda x, y, z: x + y - z), score_max)
score_max = max(score_sum(lambda x, y, z: x - y + z), score_max)
score_max = max(score_sum(lambda x, y, z: x - y - z), score_max)
score_max = max(score_sum(lambda x, y, z: -1 * x + y + z), score_max)
score_max = max(score_sum(lambda x, y, z: -1 * x + y - z), score_max)
score_max = max(score_sum(lambda x, y, z: -1 * x - y + z), score_max)
score_max = max(score_sum(lambda x, y, z: -1 * x - y - z), score_max)
print(score_max)


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

signed main()
{
  double x1, x2, y1, y2;

  cin >> x1 >> y1 >> x2 >> y2;
  cout << fixed << setprecision(10) << sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) << endl;

  return (0);
}

Measured memory_bytes: 3248
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var n = Console.ReadLine().ToInt32();
        var an = Console.ReadLine().SplittedStringToInt32List();
        var num1 = an[0];
        foreach (var item in an)
        {
            num1 = Gcd(num1, item);
        }
        Console.WriteLine(num1);

        Console.ReadLine();
    }


    public static int Gcd(int a, int b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }
    public static BigInteger Gcd(BigInteger a, BigInteger b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }

    public static long f(long n,long b)
    {
        if (n < b)
        {
            return n;
        }
        else
        {
            return f((long)Math.Floor((double)n/b),b) + n % b;
        }
    }

    public static string N(long n,long b)
    {
        var sb = new StringBuilder();
        while (true)
        {
            sb.Append((n % b).ToString());
            n /= b;
            if (n < b)
            {
                sb.Append(n.ToString());
                break;
            }
        }
        return new string( sb.ToString().Reverse().ToArray() );
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    public const int Mod1e9 = 1000000007;
    

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 20832
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> t3;

using namespace std;

void solve()
{
    int n;
    cin >> n;
    set<ll> s;
    for(int i = 0;i < n;i++)
    {
        ll key;
        cin >> key;
        if(s.find(key) != s.end())
        {
            s.erase(key);
        }
        else
        {
            s.insert(key);
        }
    }
    cout << s.size() << endl;
    return;
}

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

Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	ll n, a, b[200003], ans=0;
	cin >> n;
	b[0]=0;
	for(int i=1; i<=n; i++){
		cin >> a;
		b[i]=b[i-1]+a;
	}
	sort(b, b+n+1);
	ll c=1;
	for(int i=1; i<=n; i++){
		if(b[i]==b[i-1]){
			c++;
		} else {
			ans+=c*(c-1)/2;
			c=1;
		}
	}
	ans+=c*(c-1)/2;
	cout << ans << endl;
	
	return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;

    long long x[N];
    long long y[N];
    long long sorted_x[N];
    long long sorted_y[N];
    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
        sorted_x[i] = x[i];
        sorted_y[i] = y[i];
    }
    sort(sorted_x, sorted_x + N);
    sort(sorted_y, sorted_y + N);

    long long ans = LONG_LONG_MAX;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = 0; j < N - 1; j++)
        {
            long long minx = sorted_x[i];
            long long miny = sorted_y[j];
            for (int k = i + 1; k < N; k++)
            {
                for (int l = j + 1; l < N; l++)
                {
                    long long maxx = sorted_x[k];
                    long long maxy = sorted_y[l];
                    int count = 0;
                    for (int m = 0; m < N; m++)
                    {
                        if (minx <= x[m] && x[m] <= maxx)
                        {
                            if (miny <= y[m] && y[m] <= maxy)
                            {
                                count++;
                            }
                        }
                    }
                    if (count >= K)
                    {
                        ans = min(ans, (maxx - minx) * (maxy - miny));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 256
n = int(input())
heights = list(map(int, input().split()))

def feedcount(heights):
    counter = 0
    hiszero = True
    for h in heights:
        if h != 0 and hiszero:
            hiszero = False
            counter += 1
        elif h == 0:
            hiszero = True
    return counter

def feedwater(heights):
    return list(map(lambda h: max(0,h-1), heights))

total = 0
while(feedcount(heights) != 0):
    total += feedcount(heights)
    heights = feedwater(heights)
print(total)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef long long               ll;
typedef long double             ld;
 
 
#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

///knight moves:
///int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2}; 
///int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};

 
ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
}
 
ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}
 
void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}


	
int solve()
{
	ll n;
	sll(n);
	vll v(n);
	forr(i,0,n) sll(v[i]);
	sort(all(v));
	ll p=n/2;
	p--;
	ll tot=v[p+1]-v[p];
	pll(tot);
   	return 0;
}
	
 
int main()
{   
 
//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();
}

 
 
///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


Measured memory_bytes: 1152
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-5,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  int N;
  ll A,B;
  cin >> N >> A >> B ;
  vvl dp(N+1,vl(N,LINF));
  dp[0][0] = 0;
  vl pos(N);
  rep(i,N){
    ll p;
    cin >> p ;
    pos[p-1] = i;
  }
  rep(i,N){
    vl mi(N+1,LINF);
    rep(j,N) mi[j+1] = min(mi[j],dp[i][j]);
    rep(j,N){
      // dp[i+1][j] = min_{k<=j}(dp[i][j]) + cost
      ll co;
      if(j==pos[i]) co = 0;
      else if(j>pos[i]) co = A;
      else co = B;
      dp[i+1][j] = mi[j+1] + co;
    }
  }
  cout << *min_element(ALL(dp[N])) << endl;
}

Measured memory_bytes: 195840
h, w = map(int, input().split())
a = [input() for _ in range(h)]
dp = [[0] * w for _ in range(h)]

for i in range(h):
    if a[i][0] == ".":
        dp[i][0] = 1
    else:
        break

for i in range(w):
    if a[0][i] == ".":
        dp[0][i] = 1
    else:
        break

for i in range(1, h):
    for j in range(1, w):
        if a[i][j] == "#":
            dp[i][j] = 0
        else:
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % (10 ** 9 + 7)

print(dp[h - 1][w - 1])


Measured memory_bytes: 43604
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


ll cost[400*400];

int main() {
    cin >> n >> m >> k;
    vp d(160000);
    REP(i,n) {
        REP(j,m) {
            cin >> cnt;
            d[cnt].first = i;
            d[cnt].second = j;
        }
    }
    FOR(i,k+1,n*m+1) {
        cost[i] = cost[i - k] + abs(d[i].first - d[i - k].first) + abs(d[i].second - d[i - k].second);
    }
    ll q;
    cin >> q;
    vp v(q);
    REP(i,q) {
        cin >> v[i].first >> v[i].second;
        cout << cost[v[i].second] - cost[v[i].first] << endl;
    }
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define INF 1e9
#define MOD 1000000007
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main(void){
    int N,M;cin>>N>>M;
    ll ans=0;
    priority_queue<ll> que;
    REP(i,N){
        ll a;cin>>a;
        que.push(a);
    }
    REP(i,M){
        ll x=que.top();
        que.pop();
        x/=2;
        que.push(x);
    }
    REP(i,N){
        ans+=que.top();
        que.pop();
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int B[105], dp[105], ans;
int main()
{
	int n; cin >> n;
	for (int i = 0; i < n-1; ++i) cin >> B[i];
	ans += B[0];
	for (int i = 0; i < n-1; ++i)
	{
		ans += min(B[i], B[i+1]);
	}
	ans += B[n-2];
	cout << ans;
}


Measured memory_bytes: 256
my($n,$M)=glob<>;
my$h=<>;chomp$h;my@h=split(/ /,$h);
my@h2=@h;my$c=0;my$a;my$b;my$numbers;
while($M>$c){$numbers=<>;chomp$numbers;($a,$b)=split(/ /,$numbers);
if($h[$a-1]>$h[$b-1]){splice(@h2,$b-1,1,('a'));}elsif($h[$a-1]<$h[$b-1]){splice(@h2,$a-1,1,('a'));} else{splice(@h2,$b-1,1,('a'));splice(@h2,$a-1,1,('a'));}$c++;}
foreach(@h2){$c{$_}++;}
my $A=$n-$c{'a'};
print $A;

Measured memory_bytes: 33260
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
int main () {
	int n;
	scanf ("%d", &n);
	rep (i, 1, 9) {
		if (n % i == 0 && (n / i) < 10) { printf ("Yes\n"); return 0; }
	}
	printf ("No\n");
	return 0;
}

Measured memory_bytes: 256
H = int(input())
A = list(map(int, input().split()))

def per(p):
    global parentkey
    if p%2 == 0:
        pk = p/2-1
    else:
        pk = p//2
    if pk >= 0:
        parentkey = 'parent key = {}, '.format(A[int(pk)])
    else:
        parentkey = ''


def left(l):
    l += 1
    global leftkey
    if 2*l <= H:
        leftkey = 'left key = {}, '.format(A[2*l-1])
    else:
        leftkey = ''


def right(r):
    r += 1
    global rightkey
    if 2*r+1 <= H:
        rightkey = 'right key = {}, '.format(A[2*r])
    else:
        rightkey = ''


for i in range(H):
    per(i)
    left(i)
    right(i)
    print('node {}: key = {}, {}{}{}'.format(i+1, A[i], parentkey, leftkey, rightkey))


Measured memory_bytes: 5628
#include<stdio.h>

int main(void) {
	int m1, m2, d1, d2;
	scanf("%d%d%d%d", &m1, &d1, &m2, &d2);
	if (m2 == (m1 + 1) && d2 == 1)
		printf("1\n");
	else
		printf("0\n");
	return 0;
}

Measured memory_bytes: 128
from collections import deque
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
dist = [[10**6 for _ in range(W)] for _ in range(H)]

dist[0][0] = 0

q = deque([(0, 0)])
while q:
	h, w = q.pop()

	if h < H-1:
		if s[h][w] == "." and s[h+1][w] == "#":
			if dist[h+1][w] > dist[h][w] + 1:
				dist[h+1][w] = dist[h][w] + 1
				q.appendleft((h+1, w))
		else:
			if dist[h+1][w] > dist[h][w]:
				dist[h+1][w] = min(dist[h+1][w], dist[h][w])
				q.append((h+1, w))

	if w < W-1:
		if s[h][w] == "." and s[h][w+1] == "#":
			if dist[h][w+1] > dist[h][w] + 1:
				dist[h][w+1] = dist[h][w] + 1
				q.appendleft((h, w+1))
		else:
			if dist[h][w+1] > dist[h][w]:
				dist[h][w+1] = dist[h][w]
				q.append((h, w+1))

#print(dist)
print(dist[H-1][W-1] + (s[0][0] == "#"))

Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <queue>

using namespace std;


int main()
{
	string s[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> s[i];
	}
	
	cout << s[0][0] << s[1][1] << s[2][2] << endl;

	return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p[1004];
int main() {
int N,K;
cin>>N>>K;
for(int i=0;i<N;i++){
	cin>>p[i];
}
sort(p,p+N);
int s=0;
for(int i=0;i<K;i++){
s+=p[i];
}
cout<<s;
	return 0;
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,x,t;
	cin>>n>>x>>t;
	int c=0;
	while(n>=x){
		n-=x;
		c+=t;
	}
	if(n!=0)
		c+=t;
	cout<<c<<'\n';
	return 0;
}

Measured memory_bytes: 3608
a,b,c,x,y=map(int,input().split())
ans=0
if a+b<2*c:
   ans+=a*x+b*y
else:
    if x>y:
        if 2*c>a:
            ans+=c*2*y+a*(x-y)
        else:
            ans+=c*2*x
    else:
        if 2*c>b:
            ans+=c*2*x+b*(y-x)
        else:
            ans+=c*2*y
print(ans)


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

int main() {
  int n;
  cin >> n;
  int l, r, ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    ans += r - l + 1;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256