akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    s = input()
    cnt_0 = s.count('0')
    cnt_1 = s.count('1')
    print(min(cnt_0, cnt_1) * 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#!/usr/bin/env python3

import sys

input = iter(sys.stdin.read().splitlines()).__next__

MOD = 1000000007

def powmod(x, n):
   if n == 0: return 1
   if (n % 2) == 1:
      return (powmod((x*x) % MOD, n//2) * x) % MOD
   else:
      return powmod((x*x) % MOD, n//2)

N = int(input())

total = powmod(10, N)

#print(total)

cnt_without0 = powmod(9, N)
cnt_without9 = cnt_without0
cnt_without0nor9 =  powmod(8, N)

res = (total - cnt_without0 - cnt_without9 + cnt_without0nor9) % MOD
if res < 0:
   res += MOD

print(res)



Measured memory_bytes: 9044
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        String x = scanner.nextLine();
        int r = 3;
        int s = 0;

        for(int i = 0;i < r;i++){
            if(x.charAt(i) == '1'){
                s++;
            }
        }
        System.out.println(s);
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
int n, k, d, t;
std::vector<int> vec;
int main() {
  std::cin >> n >> k;
  vec.assign(n, 0);
  for (int i = 0; i < k; i++) {
  	std::cin >> d;
    for (int u = 0; u < d; u++) {
      std::cin >> t;
      vec[--t] = 1;
    }
  }
  std::cout << std::count(vec.begin(), vec.end(), 0) << std::endl;
}


Measured memory_bytes: 3616
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    int k, n; cin >> k >> n;
    vector<long long> a(n); for (int i=0; i<n; i++) cin >> a[i];
    vector<long long> d(n); for (int i=0; i<n-1; i++) d[i] = a[i+1] - a[i];
    d[n-1] = k - a[n-1] + a[0];

    long long ans = 0;
    long long _max = 0;

    for (int d_i: d) {
        _max = _max > d_i ? _max : d_i;
        ans += d_i;
    }

    ans -= _max;
    cout << ans << endl;
    return 0;
}



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

N = int(input())

# 素因数分解
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

# 約数の個数
def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a

if N < 105:
    print(0)
else:
    ans = 0
    for i in range(N, 104, -1):
        if i % 2 != 0:
            tmp = divisor_num(i)
            if tmp == 8:
                ans += 1
    print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
  long long count=0;
  int i,n;

  scanf("%d", &n);

  for(i=1; i<=n; i++){
    if (i%3 == 0 || i%5 ==0)
      continue;
    else
      count += i;
  }
  printf("%lld", count);

  return 0;
}


Measured memory_bytes: 1720
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
 
using namespace std;
typedef long int ll;
const ll mod = 1000000007;
const ll lim = 100000 + 1;
 
ll solve(void);
 
int main(void) {
     
    cout << solve() << endl;
 
    return 0;
 
}
 
ll solve(void) {
 
    ll N, T;
    cin >> N >> T;
 
    vector<ll> count(lim, 0);
    vector<ll> v(lim,0);
    vector<ll> w(lim, 0);
    vector<ll> num;
 
    for (int i = 0; i < N; i++) {
        int j;
        cin >> j;
        count[j] ++;
    }
 
    for (int i = 0; i + 1 < lim; i++) {
        v[i + 1] += v[i] + count[i+1];
    }
 
    for (int i = T+1; i < lim; i++) {
        w[i] = v[i-T-1];
    }
 
    for (int i = 0; i < lim; i++)
        for( int j = 0; j < count[i]; j++)
            num.push_back(i);
 
    ll ans = 1;
     
    for (ll i = 1; i < num.size(); i++) {
        ll j = i + 1;
        ans = (ans * (j - w[num[i]])) % mod;
    }
 
    return ans;
 
}

Measured memory_bytes: 6232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
const ll MOD=1e9+7;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    char ch;
    cin>>ch;ch++;
    cout<<ch;
}


Measured memory_bytes: 256
import itertools

N = int(input())
A = list(map(int,input().split()))
A.sort()

Acomb = list(itertools.combinations(A, 3))

ans = 0
for tri in Acomb: 
  if tri[0] < tri[1] and tri[1] < tri[2] and tri[0] + tri[1] > tri[2]:
    ans += 1
print(ans)

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

#define NUM 10000

int main(){
  int n;
  cin >> n;
  int a[NUM];
  int c = 0;
  cin >> a[0];
  for (int i = 1; i < n; i++){
    cin >> a[i];
    if (a[i] == a[i-1]){
      a[i] = 0;
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

keys = ['M', 'A', 'R', 'C', 'H']
chars = dict(zip(keys, [0]*5))
for i in range(n):
    if s[i][0] in keys:
        chars[s[i][0]] += 1
# print(chars)

ans = 0
for i in range(1<<5):
    if bin(i).count('1') != 3:
        continue
    num = 1
    for j in range(5):
        if i&1 == 1:
            num *= chars[keys[j]]
        i >>= 1
    ans += num
print(ans)


Measured memory_bytes: 9752
//提出 #4996265を参考
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	ll ans = 1;
	int n;
	string s;
	cin >> n >> s;
	ll cnt[26] = {};
	REP(i, n){
		cnt[s[i] - 'a']++;
	}

	REP(i, 26) ans = (ans * (cnt[i] + 1)) % MOD;

	cout << (ans - 1 + MOD) % MOD << endl;

}


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

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

    string next;
    // push_back関数で要素の追加が行える
    next.push_back(A.at(0));

    int a{}, b{}, c{};
    while(true){
        if(next == "a"){
            if(A.empty()){
                cout << "A" << endl;
                break;
            }
            //*はポインタを表す
            next = *A.begin();
            A.erase(A.begin());
            a++;
        }
        if(next == "c"){
            if(C.empty()){
                cout << "C" << endl;
                break;
            }
            //*はポインタを表す
            next = *C.begin();
            C.erase(C.begin());
            c++;
        }
        if(next == "b"){
            if(B.empty()){
                cout << "B" << endl;
                break;
            }
            //*はポインタを表す
            next = *B.begin();
            B.erase(B.begin());
            b++;
        }
    }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),M=in();

	out(M>=N?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

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

    vector<int> p(N),q(N);

    rep(i, N) cin >> p[i];

    rep(i, N) q[i] = p[i];

    sort(p.begin(), p.end());

    int j = 0;

    rep(i, N) if (q[i] != p[i]) { ++j; }

    if (j == 2 || j == 0) { cout << "YES" << endl; }
    else { cout << "NO" << endl; }
}

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

int main(){
  string str;
  string s[102];
  int n;
  map<string,vector<int> > word;
  int i=0;
  
  while(cin>>str>>n){
    if(!word.count(str)){
      word[str].push_back(n);
      s[i]=str;
      i++;
    }
    else word[str].push_back(n);
  }
  
  
  for(int cnt=0;cnt<i;cnt++)sort(word[s[cnt]].begin() , word[s[cnt]].end());
  
  for(int cnt=0;cnt<i;cnt++){
    for(int j=0;j<i-1;j++){
      if(s[j]>s[j+1])swap(s[j],s[j+1]);
    }
  }

  for(int cnt=0;cnt<i;cnt++){
    cout<<s[cnt]<<endl;
    for(int j=0;j<word[s[cnt]].size();j++){
      if(j)cout<<" ";
      cout<<word[s[cnt]][j];
    }
    cout<<endl;
  }

  return(0);
}

Measured memory_bytes: 1244
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        a: i64, b: i64, t: i64
    }

    println!("{}", (t / a) * b);
}


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

const int INF = 2e9;

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    string s; cin >> s;
    while (s.length() < 15) s += 'o';
    cout << (count(all(s), 'o') >= 8 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main()
{
    fastio;
    
    ll n, k;
    cin >> n >> k;
    ll arr[n];
    for (auto &x : arr)
        cin >> x;
    sort(arr, arr + n);
    ll ans = 0;
    //print(arr);
    for (int i = 0; i < n - k; i++)
    {
        ans += arr[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<vin> vvin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int MOD=1e9+7;

int main(){
  ll n;cin>>n;
  vll dp(n+1,1);
  rep(i,2,n+1){
    dp[i]=dp[i-2]+dp[i-1];
  }
  cout<<dp[n]<<endl;
}



Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ABC121B
{
    public partial class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var M = ss.Next(int.Parse);
            var C = ss.Next(int.Parse);

            var B = ss.Next(int.Parse, M);
            var A = ss.Next(int.Parse, M, N);

            var ans = 0;

            for (var i = 0; i < N; i++)
            {
                var calc = C;

                for (var j = 0; j < M; j++)
                {
                    var a = A[i][j];
                    var b = B[j];
                    calc += a * b;
                }

                if (calc > 0) ans++;
            }

            sw.WriteLine(ans);
            //---------------------------------
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = { ' ' };
        readonly StreamReader streamReader;

        string[] line = new string[0];
        int index = 0;

        public StreamScanner(Stream stream)
        {
            this.streamReader = new StreamReader(stream);
        }

        public string Next()
        {
            return Next(s => s);
        }

        public string[] Next(int x)
        {
            return Next(s => s, x);
        }

        public string[][] Next(int x, int y)
        {
            return Next(s => s, x, y);
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = streamReader.ReadLine()?.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }

    public partial class Program
    {
        static void Main()
        {
            Excute(Console.OpenStandardInput(), Console.OpenStandardOutput());
        }

        public static void Excute(Stream input, Stream output)
        {
            var ss = new StreamScanner(input);
            var sw = new StreamWriter(output);
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }
}

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

int main(void)
{
    string S, T;
    cin >> S >> T;
    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) count++;
    }
    cout << count << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<vector>

using namespace std;

int W,H;

int g[7][7];
int cg[7][7];
int ly,lx;

bool inside(int y,int x){
  return 0<=y&&y<H&&0<=x&&x<W;
}

bool neighbor(int y,int x){
  return abs(y-ly)+abs(x-lx)==1;
}
  
void ff(int y,int x){
  if(inside(y,x)&&cg[y][x]==0){
    for(int i=0;i<4;i++){
      cg[y][x]=1;
      ff(y+(~i&i-1),x+(i?2-i:0));
    }
  }
}

bool dfs(int y,int x,int r){
  if(r==1)return neighbor(y,x);
  g[y][x]=1;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(g[i][j]==0){
	// copy(g[0],g[7],cg[0]);
	// ff(i,j);
	// for(int k=0;k<H;k++){
	//   for(int l=0;l<W;l++){
	//     if(cg[k][l]==0){
	//       goto fail;
	//     }
	//   }
	// }
	for(int i=0;i<4;i++){
	  int ny=y+(~i&i-1);
	  int nx=x+(i?2-i:0);
	  if(inside(ny,nx)&&g[ny][nx]==0){
	    for(int j=0;j<4;j++){
	      if(i==j)continue;
	      int oy=y+(~j&j-1);
	      int ox=x+(j?2-j:0);
	      if(inside(oy,ox)&&g[oy][ox]==0&&!neighbor(oy,ox)){
		int c=0;
		for(int k=0;k<4;k++){
		  int ony=oy+(~k&k-1);
		  int onx=ox+(k?2-k:0);
		  c+=inside(ony,onx)&&g[ony][onx]==0;
		}
		if(c<2)goto next;
	      }
	    }
	    if(dfs(ny,nx,r-1))return true;
	  next:
	    ;
	  }
	}
	goto fail;
      }
    }
  }
 fail:
  g[y][x]=0;
  return false;
}
    

int main(){
  while(cin>>W>>H,W){
    int c=0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>g[i][j];
	if(g[i][j]==0){
	  ly=i;
	  lx=j;
	  c++;
	}
      }
    }
    cout<<((c&&dfs(ly,lx,c))?"Yes":"No")<<endl;
  }
}

 

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        int N = Integer.parseInt(arr[0]);
        int M = Integer.parseInt(arr[1]);
        int C = Integer.parseInt(arr[2]);
        List<Integer> list = Arrays.stream(br.readLine().split(" "))
                .map(Integer::parseInt)
                .collect(Collectors.toList());
        int ans = 0;
        for (int i = 0; i < N; i++) {
            List<Integer> l = Arrays.stream(br.readLine().split(" "))
                .map(Integer::parseInt)
                .collect(Collectors.toList());
            int sum = 0;
            for (int j = 0; j < M; j++) {
                sum += list.get(j) * l.get(j);
            }
            if (sum + C > 0) {
                ans++;
            }
        }
        out.println(ans);
        out.close();
    }
}


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


int main(){

int a;
cin >> a;
vector<int> vec(a);

for(int i=0; i<a ;i++){
    cin >> vec.at(i);
}

sort(vec.begin(),vec.end());

int count =1;

for(int i = 0; i <a-1; i++){
    if(vec.at(i) < vec.at(i+1)) count++;
}
    cout << count <<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] H = new int[N];
        for(int n=0; n<N; n++) H[n] = sc.nextInt();
 
        boolean[] highest = new boolean[N];
        Arrays.fill(highest, true);
 
        for(int m=0; m<M; m++){
            int A = sc.nextInt()-1;
            int B = sc.nextInt()-1;
            if(H[A] <= H[B]) highest[A] =false;
            if(H[A] >= H[B]) highest[B] =false;
        }
 
        int ans = 0;
        for(int n=0; n<N; n++) if(highest[n]) ans++;
        System.out.println(ans);
    }
}

Measured memory_bytes: 59428
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto a = readln.chomp.split.to!(int[]);

  if (a[0] <= a[2] && a[1] >= a[2]) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool used[4][50][50][1000];
signed main(){
  memset(used,0,sizeof(used));
  int h,w;
  cin>>h>>w;
  string s[h],o;
  for(int i=0;i<h;i++) cin>>s[i];
  cin>>o;
  stack<int> si;
  int r[2][1000];
  memset(r,-1,sizeof(r));
  for(int i=0;i<(int)o.size();i++){
    if(o[i]=='[') si.push(i);
    if(o[i]==']'){
      int k=si.top();si.pop();
      r[0][k]=i+1;
    }
  }
  for(int i=0;i<(int)o.size();i++){
    if(o[i]=='{') si.push(i);
    if(o[i]=='}'){
      int k=si.top();si.pop();
      //cout<<k<<" "<<i<<endl;
      r[1][k]=i+1;
      r[1][i]=k;
    }
  }
  
  int cnt=0;
  int d=0,x,y,p=0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(s[i][j]=='s') y=i,x=j;

  int ax[]={0,1,0,-1};
  int ay[]={-1,0,1,0};
  while(1){
    //cout<<cnt<<" "<<o[p]<<endl;
    //cout<<d<<" "<<y<<" "<<x<<" "<<p<<endl;
    if(p==(int)o.size()||used[d][y][x][p]){
      cout<<-1<<endl;
      return 0;
    }
    used[d][y][x][p]=1;
    if(s[y][x]=='g'){
      break;
    }
    if(o[p]=='^'){
      if(s[y+ay[d]][x+ax[d]]!='#'){
	y+=ay[d];
	x+=ax[d];
      }
      cnt++;
      p++;
      continue;
    }
    if(o[p]=='v'){
      if(s[y+ay[(d+2)%4]][x+ax[(d+2)%4]]!='#'){
	y+=ay[(d+2)%4];
	x+=ax[(d+2)%4];
      }
      cnt++;
      p++;
      continue;
    }
    if(o[p]=='<'){
      (d+=3)%=4;
      p++;
      cnt++;
      continue;
    }
    if(o[p]=='>'){
      (d+=1)%=4;
      p++;
      cnt++;
      continue;
    }
    bool f=0;
    if(o[p]=='['||o[p]=='{'){
      int pp=p;
      p++;
      while(o[p]=='~') p++,f=!f;
      if(o[p]=='T'){
	f^=1;
      }
      if(o[p]=='N'){
	f^=d==0;
      }
      if(o[p]=='E'){
	f^=d==1;
      }
      if(o[p]=='S'){
	f^=d==2;
      }
      if(o[p]=='W'){
	f^=d==3;
      }
      if(o[p]=='C'){
	f^=s[y+ay[d]][x+ax[d]]=='#';
      }
      if(!f) p=r[o[pp]=='{'][pp];
      else p++;
      continue;
    }
    if(o[p]=='}'){
      p=r[1][p];
      continue;
    }
    if(o[p]==']'){
      p++;
      continue;
    }
  }

  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 12984
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws Exception{
        String str[], ans;
        int a, b;
        int d, r;
        String f;
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        str = br.readLine().split(" ");
        a = Integer.parseInt(str[0]);
        b = Integer.parseInt(str[1]);
        
        d = a / b;
        r = a % b;
        f = String.format("%.5f", ((double)a / (double)b));
        System.out.println(d + " " + r + " " + f);
    }
}

Measured memory_bytes: 24860
// In the name of God

#include <bits/stdc++.h>

using namespace std;

long long ans;

const int mod = (int)1e9+7;

vector<int> adj[(int)1e5+5];
vector<int> dist2[(int)1e5+5];
int n, k, c[(int)1e5+5];
bool vis[(int)1e5+5];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;
	for(int i=0; i<n-1; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	ans = 1;
	queue< pair<int,int> > q;
	q.push( make_pair(0, 0) );
	while(!q.empty()) {
		int now = q.front().first;
		int par = q.front().second;
		q.pop();
		int cnt = k;
		if(par == now) {
			ans *= cnt;
			for(auto v : adj[now]) q.push(make_pair(v, now));
			continue;
		}
		cnt = cnt - 1 - c[par];
		if(par != 0) cnt--;
		c[par]++;
		ans *= cnt;
		ans %= mod;
		for(auto v : adj[now]) {
			if(v == par) continue;
			q.push( make_pair(v, now) );
		}
	}
	cout << ans % mod;
	return 0;
}


Measured memory_bytes: 9336
function main()
  
  (N,M) = map(x -> parse(Int,x), split(readline()))
  
  AC = zeros(Int,N)
  WA = zeros(Int,N)
  count = 0
  
  for i in 1:M
    
    (p,s) = split(chomp(readline())," ")
    
    p = parse(Int,p)
    
    if s == "AC"
      AC[p] = 1
    elseif AC[p] == 0
      WA[p] += 1
    end
    
  end
  
  for i in 1:N
    if AC[i] == 1
      count += WA[i]
    end
  end
  
  println(sum(AC), " ", count)
  
end

main()

Measured memory_bytes: 168472
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    for (int i = 0; i <= 9; ++i) {
        for (int j = 0; j <= 9; ++j) {
            for (int k = 0; k <= 9; ++k) {
                int c = 0;
                for (int l = 0; l < s.size(); ++l) {
                    if (c == 0 && s[l] - '0' == i) {
                        ++c;
                        continue;
                    }
                    if (c == 1 && s[l] - '0' == j) {
                        ++c;
                        continue;
                    }
                    if (c == 2 && s[l] - '0' == k) {
                        ++ans;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
dat_a = map(int, input().split())
dat_a = list(dat_a)
o = e = 0
for i in range(n):
    if dat_a[i] % 2 == 0:
        e += 1
    else:
        o += 1
#print()
#print("o,e:{0}, {1}".format(o,e))

if o % 2 == 1:
    print("NO")
else:
    e += o // 2
    #print()
    #print("o,e:{0}, {1}".format(o, e))
    print("YES")


Measured memory_bytes: 63472
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <float.h>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;
typedef long long ll;
#define loop(i, N) for(int i=0; i<N; ++i)

int a, b;

int main(void) {
	cin >> a >> b;
	int ans = a-2*b;
  	if(ans<0) ans = 0;

	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;
 
typedef long long ll;

#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
 
string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
constexpr int mod = 1e9 + 7;
ll POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

ll power(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans * a) % mod;
		}
		a = (a * a) % mod;
		b /= 2;
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (a == 0) {
		return b;
	}
	return gcd(b % a,a);
}
ll lcm(ll a, ll b) {
	return (a * b) / gcd(a,b);
}
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			return 0;
		}
	}
	return 1;
}

ll power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans * a) % mo;
		}
		a = (a * a) % mo;
		b /= 2;
	}
	return ans;
}     

int main() {
	int l , r ,d;
	cin >> l >> r >> d;
	int cnt = 0;
	for (int i = l; i <= r; ++i) {
		if (i % d == 0) {
			cnt++;
		}
	}
	cout  <<cnt;
}








Measured memory_bytes: 3596
n,m = map(int,input().split())
ls = [[int(x) for x in input().split()] for _ in range(n)]

pm = [0,0,0]
ans = 0
for i in range(8):
    for j in range(3):
        if (i>>j)&1:
            pm[j]=1
        else:
            pm[j]=-1
    can = []
    for k in range(n):
        can.append(ls[k][0]*pm[0]+ls[k][1]*pm[1]+ls[k][2]*pm[2])
    can = sorted(can,reverse=True)
    can = can[0:m]
    can = sum(can)  
    ans = max(ans,can)
print(ans)

Measured memory_bytes: 40048
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
signed main() {
	int n, h, w, a, b, ans = 0;
	cin >> n >> h >> w;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a >= h && b >= w)ans++;
	}cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 50;
int n, k, a[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n) cin >> a[i];
  sort(a, a+n);
  reverse(a, a+n);
  int ans = 0;
  FOR(i, 0, k) ans += a[i];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include <map>

using namespace std;

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second > secondElof.second;
}

#define rep(i, s, n) for(int i = s;i<n;i++)
#define repe(i, s, n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};

int main(void) {
    int n;
    cin >> n;
    vector<string> vs;
    map<string, vpii> sp;

    for (int i = 0; i < n; ++i) {
        string s;
        int p;
        cin >> s >> p;
        if (std::find(vs.begin(), vs.end(), s) == vs.end()) {
            vs.pb(s);
        }
        sp[s].pb(pii(i+1,p));
    }

    sort(vs.begin(), vs.end());

    for (int i = 0; i < vs.size(); ++i) {
        sort(sp[vs[i]].begin(), sp[vs[i]].end(), pairCompare<int,int>);
    }

    for (int i = 0; i < vs.size(); ++i) {
        for (auto const e : sp[vs[i]]) {
            cout << e.first << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int>a(n), b(n), c(n);
	rep(i, n) {
		scanf("%d", &a[i]);
	}
	rep(i, n) {
		scanf("%d",& b[i]);
	}
	rep(i, n) {
		scanf("%d",&c[i]);
	}
	sort(all(a));
	sort(all(b));
	sort(all(c));
	vector<int>bc(n);
	rep(i, n) {
		int tmp=upper_bound(all(c), b[i])-c.begin();
		if (tmp < b.size()) {
			bc[i] = b.size() - tmp;
		}
	}
	vector<int>ab(n,n);
	rep(i, n) {
		int tmp = upper_bound(all(b), a[i])-b.begin();
		ab[i] = tmp;
	}
	vector<int>imos(n + 1);
	rep(i, n) {
		imos[ab[i]]++;
		imos[n]--;
	}
	ll count = 0;
	rep(i, n) {
		count += imos[i];
		imos[i] = count;
	}
	ll ans = 0;
	rep(i, n) {
		ans +=(ll) bc[i] * imos[i];
	}
	cout << ans << endl;

}


Measured memory_bytes: 2560
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxn=1e5+20;

int pre[maxn],suf[maxn];

int main()
{
	int n=read(),a[maxn],A[100020]={0},B[100020]={0};
	REP(i,1,n)a[i]=read();
	REP(i,1,n)if(i&1)A[a[i]]++;else B[a[i]]++;
	int mn=n;

	REP(i,1,1e5)pre[i]=max(pre[i-1],A[i]);
	DREP(i,1e5,1)suf[i]=max(suf[i+1],A[i]);
	
	REP(i,0,1e5)mn=min(mn,n-B[i]-max(pre[i-1],suf[i+1]));
	printf("%d\n",mn);
	return 0;
}



Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		for ( int i = 0 ; i < N ; i++ ) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		sc.close();

		double sum = 0.0;
		for ( int i = 0 ; i < N ; i++ ) {
			for ( int j = i + 1 ; j < N ; j++ ) {
				sum += Math.sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
			}
		}
		System.out.println(sum * 2 / N);
	}
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[10010];
    rep(i, H) cin >> S[i];
    bool usedH[1010] = {};
    bool usedW[1010] = {};
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') usedH[i] = true;
        }
    }
    rep(j, W) {
        rep(i, H) {
            if (S[i][j] == '#') usedW[j] = true;
        }
    }
    rep(i, H) {
        if (!usedH[i]) continue;
        rep(j, W) {
            if (usedW[j]) cout << S[i][j];
        }
        cout << endl;
    }



    return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define pb push_back
#define ll long long
#define mp make_pair
ll mod = 1000000000000000001;
int main()
{
    ll a;
    long double b;
    cin >> a >> b;
    ll c = a * b;
    cout << c << endl;
    // your code goes here
    return 0;
}


Measured memory_bytes: 3732
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;

int main()
{
	int w, h;
  scanf("%d %d", &w, &h);
  vector<P> v;
  for(int i=0; i<w; i++){
    ll p;
    scanf("%lld", &p);
	v.push_back(P(p, 0));
  }
  for(int i=0; i<h; i++){
    ll q;
    scanf("%lld", &q);
    v.push_back(P(q, 1));
  }
  ll c0=0, c1=0;
  sort(v.begin(), v.end());
  ll ans=0;
  for(auto p:v){
    int t=p.second;
    ll x=p.first;
    if(t==0){
      ans+=(x*((ll)h+1-c1));
      c0++;
    }else{
      ans+=(x*((ll)w+1-c0));
      c1++;
    }
  }
  printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef unsigned long long ll;
ll MOD = 1000000007;
ll fuctorial[1000'000];

void f(int n){
  fuctorial[0] = 1;
  for(int i = 1; i <= n; i++){
    fuctorial[i] = i * fuctorial[i-1] % MOD;
  }
}

ll pow(ll x, ll n){
  ll ans = 1;
  while(n > 0){
    if((n & 1) == 1){
      ans = (ans * x) % MOD;
    }
    x = (x * x) % MOD;
    n >>= 1;
  }
  return ans;
}

ll combination(int n, int r){
  return (fuctorial[n] * (pow(fuctorial[r], MOD - 2)%MOD)) % MOD * (pow(fuctorial[n-r], MOD - 2)%MOD) % MOD;
}

int main(){
  ll X, Y;
  cin >> X >> Y;
  ll m = 2 * Y - X;
  ll n = 2 * X - Y;
  if(m % 3 != 0 || n % 3 != 0){
    cout << 0 << endl;
    return 0;
  }

  ll a = m / 3;
  ll b = n / 3;
  f(a+b);
  ll answer = combination(a + b, a) % MOD;
  cout << answer << endl;  
  return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int a , b;
  cin >> a >> b;
  if(a % 3 == 0 or b % 3== 0 or (a+b) % 3 == 0)cout << "Possible" <<endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        
        Arrays.sort(nums);
        
        boolean clear = true;
        int answer = 0;
        if (n % 2 == 0) {
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    if (nums[i] - 1 != i) {
                        clear = false;
                        break;
                    }
                } else {
                    if (nums[i] != i) {
                        clear = false;
                        break;
                    }
                }
            }
        } else {
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    if (nums[i] != i) {
                        clear = false;
                        break;
                    }
                } else {
                    if (nums[i] - 1 != i) {
                        clear = false;
                        break;
                    }
                }
            }
        }
        
        if (clear) {
            answer = 1;
            
            // answer = Math.pow(2, n / 2) % MOD;
            for (int i = 1; i <= n / 2; i++) {
                answer = answer * 2 % MOD;
            }
        }
        
        System.out.println(answer);
    }
    
    
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a(n+1);
  vll b(n);
  rep(i,n+1) cin>>a[i];
  rep(i,n) cin>>b[i];
  
  ll ans=0;
  rrep(i,n){
    ll tmp=max(a[i+1],0LL);
    a[i+1]-=b[i];
    if(a[i+1]>0){
      ans+=b[i];
    }else{
      ans+=tmp;
      b[i]-=tmp;
      tmp=a[i];
      a[i]-=b[i];
      if(a[i]>0){
        ans+=b[i];
      }else{
        ans+=tmp;
      }
    }
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, k;
    cin >> n >> k;
    string ans = "";
    
    while (n > 0) {
        int m = n % k;
        ans = ans + to_string(m);
        n /= k;
    }
    
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 256