akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int INF = INT_MAX;

int n, g[3], l[8];

int dfs(int a, int b, int c, int idx) {
  int m = inf;
  if(a > 0 && b > 0 && c > 0) {
    m = abs(a - g[0]) + abs(b - g[1]) + abs(c - g[2]);
  }
  if(idx >= n) {
    return m;
  }
  m = min(m, dfs(a, b, c, idx + 1));
  m = min(m, (a == 0 ? 0 : 10) + dfs(a + l[idx], b, c, idx + 1));
  m = min(m, (b == 0 ? 0 : 10) + dfs(a, b + l[idx], c, idx + 1));
  m = min(m, (c == 0 ? 0 : 10) + dfs(a, b, c + l[idx], idx + 1));
  return m;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for(int i = 0; i < 3; ++i) {
    cin >> g[i];
  }
  for(int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"

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

template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N, K;
ll a[1010];
vector<ll> A;

signed main(){
    cin >> N >> K;
    REP(i, N) cin >> a[i];
    REP(i, N){
        ll sum = 0;
        FOR(j, i, N){
            sum += a[j];
            A.push_back(sum);
        }
    } 
    ll ans = 0;
    for(ll i = 40; i >= 0; i--){
        int cnt = 0;
        for(auto a : A){
            if(((ans + (1LL << i)) & a) == ans + (1LL << i)) cnt++;
        }
        if(cnt >= K) ans += (1LL << i);
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 5872
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a ;
		int cnt = 1;
		
		while(true) {
			a = sc.nextInt();
			if (a!=0) {
				System.out.println("Case "+cnt+": "+a);
			}else {
				break;
			}
			cnt++;
		}
		
		
	}

}



Measured memory_bytes: 42460
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,l;
    cin>>n>>l;
    VL aji(n);
    REP(i,n)aji[i] = l+i-1+1;
    LL sum = 0;
    REP(i,n)sum += aji[i];
    LL ans = 10000000000;
    LL min_abs = 1000000000;
    REP(i,n){
        LL sum2 = sum - aji[i];
        if(min_abs > abs(sum - sum2)){
            ans = sum2;
            min_abs = abs(sum - sum2);
        }
    }

    PUTS(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main() {
  int n;
  cin >> n ;
  int ans = n*800 - n/15*200;
  cout << ans << endl;
  return 0;
}  


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int isprime(int);

int main(){
  int n,p,i,S = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&p);
    if(isprime(p) == 1) S += 1;
  }
  
  printf("%d\n",S);
  
  return 0;
}

int isprime(int x){
  int i;
  
  if(x == 2) return 1;

  if(x < 2 || x%2 == 0)
    return 0;

  i = 3;
  while(i <= sqrt(x)){
    if(x%i == 0) return 0;
    i += 2;
  }
  return 1;
}

Measured memory_bytes: 596
use std::collections::HashMap;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let  (n,k) = {
        let t = read_vec::<i64>();
        (t[0],t[1])
    };
    let mut an:Vec<(_,_)> = read_vec::<i64>().into_iter().fold(HashMap::new(),|mut map,x|{
        let y = map.get(&x).map(|i| i+1).unwrap_or(1);
        map.insert(x,y);
        map
    }).into_iter().collect();
    an.sort_by_key(|v|v.1);
    let len = an.len() as i64;
    let ans =if len < k {
        0
    } else{
        an.into_iter().take((len -k) as usize).fold(0,|y,x| y + x.1)
    };
    println!("{}",ans);
}

Measured memory_bytes: 17872
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

type ReadType = u64;
fn to_vec(s: String, offset: ReadType) -> Vec<ReadType> {
    s.split_whitespace()
        .map(|s| s.parse::<ReadType>().unwrap() - offset)
        .collect()
}

fn evaluate(x: u64, y: u64, w: u64, h: u64) -> (f64, u64) {
    let mid = (w / 2, h / 2);
    let is_mid = w % 2 == 0 && h % 2 == 0 && mid.0 == x && mid.1 == y;
    (w as f64 * h as f64 / 2_f64, if is_mid { 1 } else { 0 })
}

fn main() {
    let v = to_vec(read_line(), 0 as ReadType);
    let (w, h, x, y) = (v[0], v[1], v[2], v[3]);

    let result = evaluate(x, y, w, h);

    println!("{} {}", result.0, result.1);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout << "square1001" << endl;
	return 0;
}



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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i <= _##i poi  i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i < _##i poi  i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i >= _##i poi  i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i > _##i poi  i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

/*#define do {*/
#define end }

#define val const auto
#define var auto

#define fuwafuwa(n, c) dokidoki((n) + (c) - 1, c)
#define dokidoki(n, c) ((n) / (c) * (c))

template<class T> bool read(T& t){
    return cin >> t poi
}
template<class T, class...U> bool read(T& t, U&... u){
    unless(cin >> t) return false poi
    return read(u...) poi
}

bool include_word(const string& s, const string& find){
    if(s.size() < find.size()) return false poi
    if(s == find) return true poi
    if(s.substr(0, find.size() + 1) == find + " " || s.substr(s.size() - find.size() - 1) == " " + find) return true poi
    times(s.size() - find.size() - 2, i)
        if(s.substr(i, find.size() + 2) == " " + find + " ") return true poi
    return false poi
}

int main(){
    char c[100] poi
    while(cin.getline(c, 100)){
        string s = c poi
        loop{
            if(include_word(s, "the") || include_word(s, "this") || include_word(s, "that")){
                cout << s poipoi poi
                break;
            }

            for(char& c : s) if('a' <= c && c < 'z') c++poi else if(c == 'z') c = 'a' poi
        }
    }
    return 0 poi
}

Measured memory_bytes: 1176
#p a = (0..6).to_a.map{|j| [6 ** j, 9 ** j] }.flatten.sort.uniq
a = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049, 531441]

n, dp = gets.to_s.to_i, [0]

(1..n).each do |i|
  cans = a.select {|j| i - j >= 0 }.map{|j| i - j }
  dp.push(cans.map{|j| dp[j] }.min + 1)
end

p dp.last

Measured memory_bytes: 3068
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		StringBuilder P = new StringBuilder();
		for (int i = 0; i < N; i++) {
			P.append(sc.nextInt());
		}
		StringBuilder Q = new StringBuilder();
		for (int i = 0; i < N; i++) {
			Q.append(sc.nextInt());
		}

		List<String> list = new ArrayList<>();
		permutation(list, "12345678".substring(0, N), "");
		
		int a = 0, b = 0;
		for (int i = 0; i < list.size(); i++) {
			if (list.get(i).equals(P.toString())) {
				a = i;
			}
			if (list.get(i).equals(Q.toString())) {
				b = i;
			}
		}

		// 結果の出力
		System.out.println(Math.abs(a - b));

		sc.close();
	}

	public static List<String> permutation(List<String> list, String target, String ans) {
		if (target.length() <= 1) {
			list.add(ans + target);
		} else {
			for (int i = 0; i < target.length(); i++) {
				permutation(list, target.substring(0, i) + target.substring(i + 1), ans + target.charAt(i));
			}
		}
		return list;
	}
}


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

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

  // ?????????
  int A[100][100];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  int b[100];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }

  int c[100];
  for (int i = 0; i < n; i++) {
    c[i] = 0;
    for (int j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }

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

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int h,w;    cin >> h >> w;
    vector<string>s(h);
    rep(i, h)   cin >> s[i];
    vector<vector<int>>row_ptr(h, vector<int>(1, -1));
    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#')  row_ptr[i].push_back(j);
        }
        row_ptr[i].push_back(w);
    }
    vector<vector<int>>col_ptr(w, vector<int>(1, -1));
    rep(i, w){
        rep(j, h){
            if(s[j][i] == '#')  col_ptr[i].push_back(j);
        }
        col_ptr[i].push_back(h);
    }
    int ans = 0;
    rep(i, h)   rep(j, w){
        if(s[i][j] == '#')  continue;
        int tmp = 0;
        /*
         * row
         */
        int l = 0, r = row_ptr[i].size()-1;
        while(l+1<r){
            int m = (l+r)/2;
            if(row_ptr[i][m] > j)  r = m;
            else                l = m;
        }
        tmp += row_ptr[i][r]-row_ptr[i][l]-1;
        /*
         * col
         */
        l = 0;  r = col_ptr[j].size()-1;
        while(l+1<r){
            int m = (l+r)/2;
            if(col_ptr[j][m] > i)  r = m;
            else                l = m;
        }
        tmp += col_ptr[j][r]-col_ptr[j][l]-1;
        ans = max(ans, tmp-1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 43028
import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe

main :: IO ()
main = do
  ls <- words <$> getLine
  q  <- readLn
  fs <- map words <$> replicateM q getLine
  let ds = makeDice ("_" : ls)
  putStr $ unlines $ map (solve ds) fs

type Dice = [(String, [String])]

makeDice :: [String] -> Dice
makeDice ls = map f di
  where
    f (x, ys) = (ls !! x, map (ls !!) ys)
    di = [(1, [5, 3, 2, 4]),
          (2, [1, 3, 6, 4]),
          (3, [1, 5, 6, 2]),
          (4, [1, 2, 6, 5]),
          (5, [1, 4, 6, 3]),
          (6, [2, 3, 5, 4])]

solve :: Dice -> [String] -> String
solve ds [t, f] = ys !! (if topIndex == 0 then 3 else topIndex - 1)
  where
    ys = fromJust $ lookup t ds
    topIndex = fromJust $ elemIndex f ys



Measured memory_bytes: 3640
n, k = gets.strip.split.map(&:to_i)
xy = readlines.map {|line| line.strip.split.map(&:to_i) }

xs = xy.sort_by {|x,y| x }
ys = xy.sort_by {|x,y| y }

result = (ys[0][-1] - ys[-1][-1]) * (xs[0][0] - xs[-1][0])

n.times do |lxi|
  lx = xs[lxi]
  (lxi+1...n).each do |rxi|
    n.times do |byi|
      by = ys[byi]
      byy = ys[byi][1]
      (byi+1...n).each do |tyi|
        rx = xs[rxi]
        ty = ys[tyi]
        tyy = ys[tyi][1]


        next if !(lx[0]..rx[0]).include?(by[0]) || !(lx[0]..rx[0]).include?(ty[0])

        num=0
        xs[lxi..rxi].each do |x, y|
          num+=1 if byy <= y && y <= tyy
        end
        if num >= k
          current_result = (ty[-1] - by[-1]) * (rx[0] - lx[0])
          result = current_result if current_result < result
        end

      end
    end
  end
end

p result


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

int n;
int h[100010];
int maxi=0;

void solve(){
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>h[i];
        maxi=max(maxi, h[i]);
        if(maxi-h[i]>1){
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
}

signed main(){
    //while(1)
    solve();
}

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

using namespace std;

int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int ans = 0;
	int ans2 = 0;
	double w = 0.0;
	for (int i = 0; i < 35; i++) {
		for (int j = 0; j < 35; j++) {
			for (int k = 0; k < 110; k++) {
				for (int l = 0; l < 110; l++) {
					int p = 100 * (a*i + b*j) + c*k + d*l;
					if (p <= f && (c*k+d*l) <= (a*i+b*j)*e) {
						if (w*(double)p <= 100.0*(double)(c*k + d*l) && p != 0) {
							ans = p;
							ans2 = c*k + d*l;
							w = 100.0*(double)(c*k + d*l) / (double)p;
						}
					}
				}
			}
		}
	}
	cout << ans << ' ' << ans2 << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
li = list(map(int,input().split()))
Alice = []
Bob = []

li=sorted(li,reverse=True)
for i in range(N):
    if i%2 == 0:
        Alice.append(li[i])
    else:
        Bob.append(li[i])
print(sum(Alice)-sum(Bob))

Measured memory_bytes: 38384
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  n--;

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

  reverse(all(ans));
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3652
n=int(input())
t,a=map(int,input().split())
h=[t-int(i)*0.006 for i in input().split()]
ans=[-1,1000000000]
for i in range(n):
    if abs(h[i]-a)<abs(ans[1]-a):
        ans=[i,h[i]]
print(ans[0]+1)

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

N, K = map(int, input().split())
num = {}
cnt = 0
for i in range(N):
    a, b = map(int, input().split())
    if a in num: num[a] += b
    else: num[a] = b

for k, v in sorted(num.items()):
    cnt += v
    if K <= cnt:
        print(k)
        exit()


Measured memory_bytes: 20272
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,len,x,i=0;
	string s;
	cin>>a>>b;
	x=b;
	while(b!=0)
	{
		i++;b/=10;
	}
	x+=a*pow(10,i);
	for(int i=1;i<=1000;i++)
	if(i*i==x){cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import combinations as comb

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [0] * 5
    for _ in range(N):
        S = str(input().strip())
        if S[0] == 'M':
            A[0] += 1
        elif S[0] == 'A':
            A[1] += 1
        elif S[0] == 'R':
            A[2] += 1
        elif S[0] == 'C':
            A[3] += 1
        elif S[0] == 'H':
            A[4] += 1

    ans = 0
    C = list(comb(A, 3))
    for c in C:
        ans += c[0] * c[1] * c[2]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>



int main(int argc, char* argv[])
{
	using std::cin;
	using std::cout;
	std::ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin >> N;

	std::vector<int> A(N);
	for (auto& ai : A)
	{
		cin >> ai;
	}

	int64_t alternate_mid = 0;
	for (int i = 0; i < N - 2; ++i)
	{
		alternate_mid += ((i&1) ? -1 : +1) * A[i+1];
	}

	int x = (A.front() + A.back() - alternate_mid) / 2;
	cout << 2*x;
	for (int i = 0; i+1 < N; ++i)
	{
		x = A[i] - x;
		cout << ' ' << 2*x;
	}
	cout << std::endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){

  int n,a[200];
  cin >> n;
  for (int i = 0; i < n; i++){
  cin >> a[i];
  }
  
  for (int i = 0;;i++){
   for (int j = 0; j < n; j++){
     if (a[j] % 2 != 0){
     cout << i << endl;
     goto end;
     }
   }
    for (int j = 0; j < n; j++){
     a[j] /= 2;
   }
  
  }
  
end:  
return 0;
}

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i <= b; i++)

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

using namespace std;

int main()
{
    int N, L; cin >> N >> L;
    vector<string> S(N);
    rep (i, 0, N) {
        string in; cin >> in;
        S.push_back(in);
    }

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

    string ans = "";
    for (auto str : S) {
        ans += str;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
k = int(input())
a , b= map(int,input().split())
num_list = []
for i in range(a,b+1,1):
    num_list.append(i)
for i in num_list:
    flag = False
    if i % k == 0:
        flag = True
        break
    else:
        continue
if flag:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

vector<ll> enum_div(ll n){//yakusu
	vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i){
			if(n%i == 0){
				ret.push_back(i);
				ret.push_back(n/i);
			}
	}
	return ret;
}

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

	ll N,ans=0;
	cin >> N;
	set<ll> se;
	for(auto x:enum_div(N)){
		if(x==1)continue;
		if(se.count(x)==0){
			if((N/(x-1))==(N%(x-1)))ans+=(x-1);
		}
		se.insert(x);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main (void) {
    int N, N0;
    scanf("%d", &N);
    N0 = N;
    int SN = 0;
    while (N) {
        SN += N % 10;
        N /= 10;
    }

    printf(((N0 % SN) == 0)? "Yes": "No");

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
    int x,y,tmp;
    while(1){
        scanf("%d%d",&x,&y);
        if(x==0&&y==0) break;
        if(x>y){
            tmp=x;
            x=y;
            y=tmp;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll s[200500];
ll a[200500];
int main()
{
	
	ll n,min1=200500,max1=0;
	ll sum=0;
	scanf("%lld",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&s[i]);
		a[s[i]]++;
		min1=min(min1,s[i]);
		max1=max(max1,s[i]);
	}
	for(ll i=min1;i<=max1;i++)
	{	
		if(i==0)
			continue;
		sum+=a[i]*(a[i]-1)/2;
	}
	for(int i=0;i<n;i++)
	{
		ll g=sum-( a[s[i]]*(a[s[i]]-1)/2 )+( (a[s[i]]-1)*(a[s[i]]-2)/2);
		printf("%lld\n",g);
	}
	
	return 0;
}

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

int main()
{
   int n,k;cin>>n>>k;
   int a[n+1];
   unordered_map<int,int> mp;
   for(int i=0;i<k;i++)
   {
       int x;cin>>x;
       for(int j=0;j<x;j++)
       {
           int y;cin>>y;
           mp[y]++;
       }
   }
   int ans=0;
   for(int i=1;i<=n;i++)
   {
       if(!mp.count(i)) ans++;
   }
   cout<<ans<<"\n";
   
}

Measured memory_bytes: 3624
package main

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

func main() {
	sc := newScanner()
	var s = sc.readString()
	var s2, s3, s4, s5 rune
	for i, v := range s {
		if i == 2 {
			s2 = v
		}
		if i == 3 {
			s3 = v
		}
		if i == 4 {
			s4 = v
		}
		if i == 5 {
			s5 = v
		}
	}
	if s2 == s3 && s4 == s5 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

//////////////////
//////////////////
//////////////////

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

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1772
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template <class T> void out(const T &val) { cout << val << endl; }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n, k;
    cin >> n >> k;
    pr(n);prln(k);
    vector<ll> h(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    ll dp[310][310];
    for (int i = 0; i < 310; ++i) {
        for (int j = 0; j < 310; ++j) {
            dp[i][j] = 1e18;
        }
    }
    dp[0][0] = 0;
    for (int j = 1; j <= n - k; ++j) {
        for (int i = 1; i <= n; ++i) {
            for (int k = 0; k < i; ++k) {
                chmin(dp[i][j], dp[k][j - 1] + max(0ll, h[i] - h[k]));
            }
        }
    }
    ll ans = 1e18;
    prln(ans);
    rep(i, 0, n) {
        chmin(ans, dp[i][n - k]);
    }
    out(ans);
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

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


def selection_sort(seq, l):
    cnt = 0

    for head_i in range(l):
        flag = False

        min_i = head_i
        for target_i in range(head_i+1, l):
            if seq[target_i] < seq[min_i]:
                min_i = target_i
                flag = True
        if flag:
            seq[head_i], seq[min_i] = seq[min_i], seq[head_i]
            cnt += 1

    print(' '.join([str(n) for n in seq]))
    print(cnt)


def to_int(v):
    return int(v)


def to_seq(v):
    return [int(c) for c in v.split()]


if __name__ == '__main__':
    l = to_int(input())
    seq = to_seq(input())

    selection_sort(seq, l)

Measured memory_bytes: 7768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

#define pi acos(-1.0)
#define mod 1000000007

///Library
#define mem(a,b) memset(a,b,sizeof(a))
#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sq(x) (x)*(x)


///vector
#define Lower_bound(vec,value) lower_bound(vec.begin(),vec.end(),value)
#define Upper_bound(vec,value) upper_bound(vec.begin(),vec.end(),value)


/*template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
*/
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b;
    cin>>a>>b;
    if(a>=b)
    {
        for(int i=0; i<a; i++)
        {
            cout<<b;
        }
        cout<<endl;
    }
    else
    {
        for(int i=0; i<b; i++)
        {
            cout<<a;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll

int n;

signed main(){
  cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    a[i]-=i+1;
  }

  sort(all(a));

  int b = a[n/2];

  int res=0;
  rep(i,n){
    res+=abs(a[i]-b);
  }

  cout<<res<<endl;
}

Measured memory_bytes: 1792
#include<iostream>

#define	E	0
#define	N	1
#define	W	2
#define	S	3

using namespace std;

int wall_v[5][5];	// wall_v[a][b] : æañ ã©çbÔÚÌÇª é©Ç¤© ([a][4]ÍíÉ0)
int wall_h[5][5];	// wall_h[a][b] : æas ¶©çbÔÚÌÇª é©Ç¤© ([a][4]ÍíÉ0)

bool isRightWall(int x,int y,int dir){
	if(dir==N)	y--;
	if(dir==W)	x--;
	if(y<0 || 4<y || x<0 || 4<x)	return false;

	if(dir==E)	return wall_h[y][x];
	if(dir==N)	return wall_v[x][y];
	if(dir==W)	return wall_h[y][x];
	if(dir==S)	return wall_v[x][y];
}

bool isForwardWall(int x,int y,int dir){
	if(dir==E)	y--;
	if(dir==N)	x--;
	if(y<0 || 4<y || x<0 || 4<x)	return false;

	if(dir==E)	return wall_v[x][y];
	if(dir==N)	return wall_h[y][x];
	if(dir==W)	return wall_v[x][y];
	if(dir==S)	return wall_h[y][x];
}

bool isBackwardWall(int x,int y,int dir){
	if(dir==W)	y--;
	if(dir==S)	x--;
	if(y<0 || 4<y || x<0 || 4<x)	return false;

	if(dir==E)	return wall_v[x][y];
	if(dir==N)	return wall_h[y][x];
	if(dir==W)	return wall_v[x][y];
	if(dir==S)	return wall_h[y][x];
}

void goRight(int &x,int &y,int &dir){
	if(dir==E)	y++;
	if(dir==N)	x++;
	if(dir==W)	y--;
	if(dir==S)	x--;
	dir=(dir+3)%4;
}

void goForward(int &x,int &y,int &dir){
	if(dir==E)	x++;
	if(dir==N)	y--;
	if(dir==W)	x--;
	if(dir==S)	y++;
}

void goLeft(int &x,int &y,int &dir){
	if(dir==E)	y--;
	if(dir==N)	x--;
	if(dir==W)	y++;
	if(dir==S)	x++;
	dir=(dir+1)%4;
}

void goBackward(int &x,int &y,int &dir){
	if(dir==E)	x--;
	if(dir==N)	y++;
	if(dir==W)	x++;
	if(dir==S)	y--;
	dir=(dir+2)%4;
}

int main()
{
	for(int i=0;i<9;i++){
		char s[8];	cin>>s;
		if(i%2==0){
			for(int j=0;j<4;j++)	wall_h[i/2][j]=s[j]-'0';
		}
		else{
			for(int j=0;j<5;j++)	wall_v[j][i/2]=s[j]-'0';
		}
	}

	int x=0,y=0,dir=0;
	do{
		if(!isForwardWall(x,y,dir)){
			if(!isRightWall(x,y,dir)){
				if(!isBackwardWall(x,y,dir))
						goBackward(x,y,dir);
				else	goRight(x,y,dir);
			}
			else		goForward(x,y,dir);
		}
		else			goLeft(x,y,dir);

		switch(dir){
			case E:	cout<<'R';	break;
			case N:	cout<<'U';	break;
			case W:	cout<<'L';	break;
			case S:	cout<<'D';	break;
		}
	}while(!(x==0&&y==0));
	cout<<endl;

	return 0;
}

Measured memory_bytes: 0
from itertools import product
h, w, K = map(int, input().split())
c = [input() for _ in range(h)]
hpr = list(product([0, 1], repeat=h))
wpr = list(product([0, 1], repeat=w))
ans = 0
for hp in hpr:
    for wp in wpr:
        tf = [[False]*w for _ in range(h)]
        for i in range(h):
            for j in range(w):
                if hp[i]:
                    for k in range(w):
                        tf[i][k] = True
                if wp[j]:
                    for k in range(h):
                        tf[k][j] = True
        cnt = 0
        for i in range(h):
            for j in range(w):
                if not tf[i][j]:
                    if c[i][j] == '#':
                        cnt += 1

        if K == cnt:
            ans += 1
print(ans)

Measured memory_bytes: 9240
#include <iostream>

using namespace std;

#define MAX_N 100000

// 入力
int N;
long long x;
long long a[MAX_N + 1];

int main(void) {
    cin >> N >> x;
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
    }

    long long new_a[MAX_N + 1];
    for (int i = 1; i <= N; ++i) {
        new_a[i] = a[i];
    }

    if (new_a[1] > x) new_a[1] = x;

    for (int i = 1; i <= N - 1; ++i) {
        if (new_a[i] + new_a[i + 1] > x) {
            new_a[i + 1] = x - new_a[i];
        }
    }

    long long operationNum = 0;
    for (int i = 1; i <= N; ++i) {
//        cout << a[i] << " " << new_a[i] << endl;
        operationNum += a[i] - new_a[i];
    }

    cout << operationNum << endl;
    return 0;
}

Measured memory_bytes: 1792
def CinR(l):
    if l[2] - l[4] >= 0 and l[2] + l[4] <= l[0]:
        if l[3] - l[4] >= 0 and l[3] + l[4] <= l[1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


if __name__ == '__main__':
    N = input().split(" ")
    l = []
    for i in N:
        l.append(int(i))
    CinR(l)

Measured memory_bytes: 7688
n, t = map(int, input().split())
A = tuple(map(int, input().split()))
AI = [(i, a) for i, a in enumerate(A)]
AI = sorted(AI, key=lambda x: x[1])

# 小さい順に見ていく
count = 0
maxdiff = 0
visited = [0] * n
for i, a in AI:
    if visited[i]:
        continue
    visited[i] = 1

    for j in range(i+1, n):
        if visited[j]:
            break
        visited[j] = 1
        diff = A[j] - a
        if diff > maxdiff:
            count = 1
            maxdiff = diff
        elif diff == maxdiff:
            count += 1
print(count)


Measured memory_bytes: 97188
n = gets.chomp.to_i
array_n = n.to_s.split("").map { |e| e.to_i }
s = 0
for i in 0..array_n.length-1 do
  s += array_n[i]
end

if n % s == 0
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    if (X%Y == 0) {
      System.out.println(-1);
    } else {
      System.out.println(X);
    }
  }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int ans=s.size();
   for(int i=0;i<ans/2;i++)
   {
       if(s[i]==s[ans-i-1])
       {
           continue;
       }
       else
       {
           cout<<"No";
           return 0;
       }
   }
   for(int i=0;i<(ans-1)/4;i++)
   {
       if(s[i]==s[(ans-1)/2-i-1])
       {
           continue;
       }
       else
       {
           cout<<"No";
           return 0;
       }
   }
    for(int i=(ans+3)/2-1;i<(ans-2)/4;i++)
    {
        if(s[i]==s[ans-i-1])
       {
           continue;
       }
       else
       {
           cout<<"No";
           return 0;
       }
    }
    cout<<"Yes";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong(),a=sc.nextLong(),b=sc.nextLong();
		long count = 0;
		if((b-a)%2!=0) {
			if(a-1<=n-b) {
				count += a;//一番上の卓にいくまでの距離+そこで過ごす1ラウンド
			}else{
				count += n-b+1;//一番下の卓にいくまでの距離+そこで過ごす1ラウンド
			}
            count += (b-a-1)/2;//元々の差分から1ラウンド過ごす分を引いた差分
		    System.out.println(count);
		}else {
			System.out.println((b-a)/2);
		}
	}
}

Measured memory_bytes: 21712
import numpy as np

h, w = [int(x) for x in input().split()]
board = [input() for i in range(h)]
dellist = []
for i in range(h):
    if '#' not in board[i]:
        dellist.append(i)
for i in sorted(dellist, reverse=True):
    del board[i]

board = [list(x) for x in board]
board_t = np.array(board).T.tolist()
dellist2 = []
for i in range(w):
    if '#' not in board_t[i]:
        dellist2.append(i)
for i in sorted(dellist2, reverse=True):
    del board_t[i]

board_t_t = np.array(board_t).T

[print(''.join(x)) for x in board_t_t]

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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second
#define endl '\n'

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    string s;
    cin >> s;

    bool res = false;
    for (int i=0; i<int(s.size()); ++i) {
        if (s[i]=='9')
            res = true;
    }

    cout << (res?"Yes":"No") << endl;
}}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << '=' << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << ' '
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;


int main(){
    int N, diff;
    cin >> N;
    vector<ll> A(N+1),M(N+1);
    loop(i,N){
        cin >> A[i+1];
    }
    A[0] = A[N];
    M[1] = 0;
    for(int i = 2;i <= N;i++){
        M[i] = A[i-1] * 2 - M[i-1];
    }

    diff = (A[N]*2 - (M[N] + M[1]))/2;
    
    loop(i,N-1){
        cout << M[i+1] + diff << " ";
        diff *= -1;
    }
    cout << M[N] + diff << endl;
}

Measured memory_bytes: 2944
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#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()
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
typedef pair<ll, ll> LLARR;
#define INF 999999999

int w[100003];
int n,k;

ll check(ll p)
{
	ll ret = 0;
	ll tmp = 0;
	ll i = 0;
	REP(j, k)
	{
		ll s = 0;
		while (s + w[i] <= p)
		{
			s += w[i];
			i++;
			if (i == n)
				return n;
		}
	}
	return i;
}

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

	cin >> n >> k;
	REP(i, n)
	{
		cin >> w[i];
	}

	ll ma = 10000 * 100000;
	ll l = 0;
	ll r = ma;
	ll mid = 0;
	while (l + 1 < r)
	{
		mid = (l + r) / 2;
		if (check(mid) >= n)
		{
			r = mid;
		}
		else
		{
			l = mid;
		}
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 3460
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

  int N;
  cin >> N;
  vector<int> h(N);

  for(int i = 0; i < N; i++){
    cin >> h[i];
  }

  int ans = 0;
  int before = h[0];
  for(int i = 1; i < N; i++){
    int temp = h[i];
    if(temp >= before){
      before = temp;
    }
    else{
      ans += (before - temp);
      before = temp;
    }
  }

  ans += before;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;

LL n,m,k,tot;
LL a[500005],b[500005],c[500005],d[500005];
LL vis[500005] = {0};
string s;
map <LL,LL> mp;

LL fa[500005];
LL getf(LL x){
	if(fa[x] == x) return x;
	return fa[x] = getf(fa[x]);
}
void unionn(LL x,LL y){
	x = getf(x); y = getf(y);
	if(x == y) return;
	tot --; fa[x] = y;
}

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++){ cin >> a[i]; c[i] = a[i]; a[n + 1] ^= a[i]; }
	for(LL i = 1;i <= n;i ++){ cin >> b[i]; d[i] = b[i]; b[n + 1] ^= b[i]; }
	n ++; c[n] = a[n]; d[n] = b[n];
	sort(c + 1,c + 1 + n); sort(d + 1,d + 1 + n);
	for(LL i = 1;i <= n;i ++){
		if(c[i] != d[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	
	tot = 0;
	for(LL i = 1;i < n;i ++){
		if(a[i] != b[i]){
			if(mp.find(a[i]) == mp.end()) mp[a[i]] = ++ tot;
			if(mp.find(b[i]) == mp.end()) mp[b[i]] = ++ tot;
		}
	}
	if(mp.find(a[n]) == mp.end()) mp[a[n]] = ++ tot;
	if(mp.find(b[n]) == mp.end()) mp[b[n]] = ++ tot;
	for(LL i = 1;i <= n;i ++){
		a[i] = mp[a[i]];
		b[i] = mp[b[i]];
	}
	
	LL tmp = 0;
	for(LL i = 1;i <= tot;i ++) fa[i] = i;
	for(LL i = 1;i < n;i ++){
		if(a[i] != b[i]){
			tot ++; tmp = 1;
			unionn(a[i],b[i]);
			vis[a[i]] = 1; vis[b[i]] = 1;
		}
	}
	unionn(a[n],b[n]);
	tot --;
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 27264
N = input()
N_digit = len(N)
K = int(input())

# dp[i][k] := i番目みて、0でない数がk個出現しているときの通り数
# dp0 := N以下であることが未確定, dp1 := N以下であることが確定
dp0 = [[0] * (K + 1) for i in range(N_digit + 1)]
dp1 = [[0] * (K + 1) for i in range(N_digit + 1)]
dp0[0][0] = 1

for i, n in enumerate(N):
    for k in range(K + 1):
        if n == '0':
            dp0[i + 1][k] += dp0[i][k]
            dp1[i + 1][k] += dp1[i][k]
            if k < K:
                dp1[i + 1][k + 1] += 9 * dp1[i][k]

        else:
            if k < K:
                dp0[i + 1][k + 1] += dp0[i][k]
                dp1[i + 1][k + 1] += (int(n) - 1) * dp0[i][k]
                dp1[i + 1][k + 1] += 9 * dp1[i][k]

            dp1[i + 1][k] += dp0[i][k]
            dp1[i + 1][k] += dp1[i][k]

print(dp0[-1][K] + dp1[-1][K])


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
void solve_C();
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    solve_C();
    return 0;
}

void solve_C(){
    ll N,M,A,B; cin >> N >> M >> A >> B;
    if(2*A + 2*B > N*M){
        cout << "NO" << endl;
        return;
    }
    
    ll nN = N,nM = M;
    vector<vector<char>> c(N+1,vector<char>(M+1,'.'));
    if(N%2 == 1 && M%2 == 1){
        N--; M--;
        for(ll w = 1; w <= M; w+=2){
            if(A == 0) break;
            c[nN][w] = '<'; c[nN][w+1] = '>';
            A--;
        }
        for(ll h = 1; h <= N; h+=2){
            if(B == 0) break;
            c[h][nM] = '^'; c[h+1][nM] = 'v';
            B--;
        }
    }else if(N%2 == 1){
        N--;
        for(ll w = 1; w <= M; w+=2){
            if(A == 0) break;
            c[nN][w] = '<'; c[nN][w+1] = '>';
            A--;
        }
    }else if(M%2 == 1){
        M--;
        for(ll h = 1; h <= N; h+=2){
            if(B == 0) break;
            c[h][nM] = '^'; c[h+1][nM] = 'v';
            B--;
        }
    }
    
    if(2*A + 2*B > N*M){
        cout << "NO" << endl;
        return;
    }
    
//    cout << A << " " << B << endl;
//    cout << N << " " << M << endl;
//    for(ll jj = 1; jj <= nN;jj++){
//        for(ll kk = 1; kk <= nM; kk++){
//            cout << c[jj][kk];
//        }
//        cout << endl;
//    }
    
    for(ll i = 1; i <= N; i+=2){
        for(ll j = 1; j <= M; j+=2){
            if(A == 0 && B == 0) continue;
            if(i == N - 1 && j == M - 1 && nN%2 == 1 && nM%2 == 1 && A == 1 && B == 1){
                
                for(ll ii = N - 1; ii <= N+1; ii++){
                    for(ll jj = M - 1; jj <= M+1; jj++){
                        c[ii][jj] = '.';
                    }
                }
                
                c[N-1][M-1] = '^'; c[N][M-1] = 'v';
                c[N-1][M] = '<'; c[N-1][M+1] = '>';
                
                
                c[N][M+1] = '^'; c[N+1][M+1] = 'v';
                c[N+1][M-1] = '<'; c[N+1][M] = '>';
                A--; B--;
                continue;
            }
            
            if(A >= 2){
                c[i][j] = '<'; c[i][j+1] = '>';
                A--;
                c[i+1][j] = '<'; c[i+1][j+1] = '>';
                A--;
            }else if(B >= 2){
                c[i][j] = '^'; c[i+1][j] = 'v';
                B--;
                c[i][j+1] = '^'; c[i+1][j+1] = 'v';
                B--;
            }else if(A == 1){
                c[i][j] = '<'; c[i][j+1] = '>';
                A--;
            }else if(B == 1){
                c[i][j] = '^'; c[i+1][j] = 'v';
                B--;
            }
        }
    }
    if(A != 0 || B != 0){
        cout << "NO" << endl;
        return;
    }else{
        cout << "YES" << endl;
        for(ll i = 1; i <= nN;i++){
            for(ll j = 1; j <= nM; j++){
                cout << c[i][j];
            }
            cout << endl;
        }
    }
    return;
}


Measured memory_bytes: 2304