akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

const int N = 1e5 + 11;
const int M = 1e6 + 11;
const int MOD = 1e9 + 7;
const double PI = 3.1415926;

int main(){
    //freopen("in.txt", "r", stdin);
    double r; cin >>r;
    cout << 2 * PI * r<<"\n";
return 0;
}


Measured memory_bytes: 3784
//============================================================================
// Name        : AOJ.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>

using namespace std;

int main() {

	int x,y;
	cin>>x>>y;
	int n=x+y;
	for(int i=1;i<x;++i){
		if((i*y)%x==0)--n;
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 3092
def dijkstra s, g
	current, cost, close, open = s, 0, {s=>0}, {}
	while true
		@arr[current].each{|to, c| open[to] = cost + c if !close[to] && (!open[to] || open[to] > cost + c)}
		min = nil
		open.to_a.each{|to, c| min = [to, c] if min.nil? || min[1] > c}
		current, cost = min
		open.delete(current)
		close[current] = cost
        break if current == g
	end
	close[g]
end

n = gets.to_i
m = gets.to_i
@arr = Array.new(n + 1){[]}
m.times{
    a, b, c, d = gets.chomp.split(',').map(&:to_i)
    @arr[a] << [b, c]
    @arr[b] << [a, d]
}
s, g, v, p = gets.chomp.split(',').map(&:to_i)
puts v - p - dijkstra(s, g) - dijkstra(g, s)



Measured memory_bytes: 6876
#include <stdio.h>

double yu(int x, int y)
{
	
	if (x <= y){
		x += y;
		y = x - y;
		x -= y;
	}
	
	while(1){
		
		x = x % y;
		
		x += y;
		y = x - y;
		x -= y;
		
		if (y == 0){
			break;
		}
	}
	return (x);
}

int main(void)
{
	double x, y;
	double gcd, lcm;
	
	while(scanf("%lf %lf", &x, &y) != EOF){
		
		gcd = yu(x, y);
		lcm = (x * y) / gcd;
		
		printf("%.0lf %.0lf\n", gcd, lcm);
		
	}
	
	return (0);
}

Measured memory_bytes: 644
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(i, ini));
    return move(vec);
}
template <typename T>
vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    int N = In<int>(); 
    int M = In<int>();
    priority_queue<ll> queue;
    for(int n = 0; n < N; n++) {
        queue.push(In<ll>());
    }

    for(int m = 0; m < M; m++){
        ll a = queue.top();
        queue.pop();
        queue.push(a/2);
    }

    ll sum = 0;
    while(!queue.empty()) {
        sum += queue.top();
        queue.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 1400
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int L = sc.nextInt();
    String[] a = new String[N];
    for(int i = 0; i < N; i++){
      a[i] = sc.next();
    }
    Arrays.sort(a);
    StringBuilder sb = new StringBuilder();
    for(int i = 0; i < N; i++){
      sb.append(a[i]);
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 23636
import sys
import math

data =[0 for i in range(4000)]
p_data = []
while True:
	n = int(input())
	count = 0
	if n == 0:
		break
	for i in range(n):
		e,p,q = map(int, input().split())
		data[e] = data[e] + p * q
		if p_data.count(e) == 0:
			p_data.append(e)
	for i in range(len(p_data)):
		if data[p_data[i]] >= 1000000:
			print(p_data[i])
			count = count + 1
			data[p_data[i]] = 0
		elif data[p_data[i]] != 0:
			data[p_data[i]] = 0
	if count == 0:
		print('NA')
	p_data.clear()

Measured memory_bytes: 7888
N, K = int(input()), int(input())
p = N // 2 if N & 1 == 0 else N // 2 + 1
for i in range(K):
    a, b = map(int, input().split())
    x = N + 1 - a if a > p else a
    y = N + 1 - b if b > p else b
    mod = x % 3 if x <= y else y % 3
    print((mod + 2) % 3 + 1)



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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int max_x = -10000, min_y = 10000;
  int x, y;
  rep(i, 0, N) {
    cin >> x;
    max_x = max(max_x, x);
  }

  rep(i, 0, M)  {
    cin >> y;
    min_y = min(min_y, y);
  }

  bool flag = false;

  rep(z, X+1, Y+1) {
    if (max_x < z && z <= min_y) {
      flag = true;
      break;
    }
  }

  if (flag) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
};


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $N, $K);
$diff = $N - $K;
$mul = intdiv($diff, $K);
$N -= $mul * $K;
$m[$N] = 1;
while(true) {
    $N = abs($N - $K);
    if (isset($m[$N])) {
        break;
    } else {
        $m[$N] = 1;
    }
}
printf("%d", min(array_keys($m)));


Measured memory_bytes: 4604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] cs = S.toCharArray();

		int n = 0;
		for(int i=0; i<3; i++) {
			if(cs[i]=='R') {
				n++;
			}
		}

		if(n==2 && cs[1]=='S') {
			n=1;
		}

		System.out.println(n);


	}

}


Measured memory_bytes: 35624
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	if (b % a == 0) cout << a + b << endl;
	else cout << b - a << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    void Calc()
    {
        var sc = new Scanner();

        int s = sc.NextInt();
        int x = s;
        s %= 60;
        x /= 60;
        int m = x;
        m %= 60;
        x /= 60;
        int h = x;
        Console.WriteLine(h + ":" + m + ":" + s);

    }

    static void Main()
    {
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

Measured memory_bytes: 5616
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*n
        self.rank=[-1]*n

    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)

        if x==y:return
        elif self.rank[x]>self.rank[y]:
            self.root[x] +=self.root[y]
            self.root[y]=x
        else:
            self.root[y] +=self.root[x]
            self.root[x]=y
            if self.rank[x]==self.rank[y]:
                self.rank[y] +=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def Count(self,x):
        return -self.root[self.Find_Root(x)]

    def members(self,x):
        root=self.Find_Root(x)
        return [i for i in range(self.n) if self.Find_Root(i)==root]

    def address(self):
        return[i for i,j in enumerate(self.root) if j<0]

    def group_members(self):
        return {i: self.members(i) for i in self.address()}

    def size(self,x):
        return -self.root[self.Find_Root(x)]


n,m=map(int,input().split())
P=list(map(int,input().split()))
XY=[list(map(int,input().split())) for i in range(m)]
UnionFind=UnionFind(n)

for x,y in XY:
    UnionFind.Unite(x-1,y-1)

print(sum([UnionFind.isSameGroup(i,j-1) for i,j in enumerate(P)]))

Measured memory_bytes: 35276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

int main() {
  int N;
  cin >> N;
  vec<ll> A(N);
  vec<ll> Gcd(N);
  rep(i,N) {
    cin >> A[i];
  }
  Gcd[N-1] = A[N-1];
  repr(i,N-1,0) {
    Gcd[i] = gcd(Gcd[i+1],A[i]);
  }
  if (Gcd[0] != 1) {
    print("not coprime");
    return 0;
  }
  vec<bool> num(1e6+1,false);
  rep(i,N) {
    if (num[A[i]]) {
      print("setwise coprime");
      return 0;
    }
    reps(j,2,sqrt((double)A[i])+0.01) {
      if (A[i]%j == 0) {
        int id = j;
        while (id<=1e6) {
          num[id] = true;
          id += j;
        }
      }
      while (A[i]%j == 0) {
        A[i] /= j;
      }
    }
    if (A[i] != 1) {
      int id = A[i];
      while (id<=1e6) {
        num[id] = true;
        id += A[i];
      }
    }
  }
  print("pairwise coprime");
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> difficulty(N);
  for(int i=0; i<N ; i++){
    cin >> difficulty.at(i);
  }
  sort(difficulty.begin(),difficulty.end());
  cout << difficulty.at(N/2) - difficulty.at((N/2)-1) << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<cmath>
using namespace std;
 
int main(void){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> req = vector<pair<int, int>>(m);
  for(int i = 0; i < m; i++){
    cin >> req[i].first >> req[i].second;
  }
  sort(req.begin(), req.end());
  
  vector<int> check_point = vector<int>(n + 1);
  vector<bool> is_done = vector<bool>(n + 1, false);
  stack<int> st;
  int result = 0;
  for(int i = 1, j = 0; i <= n; i++){
    if(check_point[i] != 0 && !is_done[check_point[i]]){
      is_done[check_point[i]] = true;
      int top = -1;
      while(!st.empty()){
        top = st.top();
        is_done[top] = true;
        st.pop();
      }
      result++;
    }
    
    if(req[j].first == i){
      st.push(i);
    }
    while(1){
      if(req[j].first != i) break;
      if(j >= m) break;
      check_point[req[j].second] = req[j].first;
      j++;
    }
  }
  cout << result << endl;
}

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


int main() {
    ll n;
    cin >> n;
    
    vector<pair<ll, ll>> pos;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            pos.push_back({i, n / i});
        }
    }

    ll res = 2e12;
    for (auto el: pos) {
        res = min(res, (el.first - 1) + (el.second - 1));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include<math.h>
#include <queue>
using namespace std;
#define Minf -1e9
#define scan(n) scanf("%lld",&n)
typedef long long ll;
const int maxn = 1*1e5+10;
const ll INF = 1e9+100;
const int mod = 998244353;

int a[maxn];
int main()
{
	int k;
	scanf("%d", &k);
	ll t = 0;
	int fmax = 1e7;
	int flag = 0;
	int i;
	for (i = 1; i <= fmax; i++){
		t = (t * 10 + 7) % k;
		if (t == 0){
			flag = 1;
			break;
		}
	}
	if (flag) cout << i << endl;
	else cout << "-1";
}

Measured memory_bytes: 3744
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli a,b,c,d;
    cin>>a>>b>>c>>d;
    a+=b;
    c+=d;
    if(a<c)
    {
        cout<<"Right";
    }
    else if(a>c)
    {
        cout<<"Left";
    }
    else
    {
        cout<<"Balanced";
    }
}


Measured memory_bytes: 764
r,c = map(int,input().split())
mat = [[i for i in map(int,input().split())] for _ in range(r)]
c_sum = [0 for _ in range(c+1)]
for i in mat :
    i.append(sum(i))
    for j in range(len(i)) :
        c_sum[j] += i[j]
    
mat.append(c_sum)
for i in mat :
    print(" ".join(list(map(str,i))))
    
    

Measured memory_bytes: 7680
import sys
import math
from pprint import pprint
import numpy as np

def solve(n, d, p):
  count = 0
  for i in range(n):
    for j in range(i, n):
      if i == j:
        continue
      #print(i, j)
      distance = math.sqrt(sum(map(lambda i: i ** 2, p[i] - p[j])))
      #pprint(distance)
      if float.is_integer(distance):
        count += 1

  return count


if __name__ == "__main__":
  n, d = map(int, sys.stdin.readline().rstrip().split(" "))
  p = []
  for _ in range(n):
    p.append(np.array(map(int, sys.stdin.readline().rstrip().split(" "))))

  #pprint(p)
  print solve(n, d, p)

Measured memory_bytes: 17772
##いろいろやってみよう
import functools
def mod(a,b):
  c=a%b
  return c
N=int(input())
*A,=map(int,input().split())
count=0
for j in range(len(bin(max(A)))-2):
  if 1 in map(functools.partial(mod,b=2),A):
    break
  else:
    A=[A[i]//2 for i in range(N)]
    count+=1
print(count)

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}


int main()
{
    int N,M;
    int L,R;
    cin >> N >> M;
    L = 1;R = N;
    _for(i,0,M){
        int l,r;
        cin >> l >> r;
        L = max(L,l);
        R = min(R,r);
    }
    int ans = R-L+1;
    ans = max(0,ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

const ll MOD = INF + 7;



int main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool f = false;
    if(a < b){
        if(a <= c && c <= b)f = true;
    }
    else {
        if(b <= c && c <= a)f = true;
    }
    cout << (f ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
typedef long long ll;
const int N=500005;
int m,n,a[N],mx[N],ans[N];
using namespace std;

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	scanf ("%d",&m),n=(1<<m);
	int i,j,x,y;
	for (i=0;i<n;i++) scanf ("%d",&a[i]);
	for (i=1;i<n;i++)
	{
		for (j=(i-1)&i,x=max(a[i],a[0]),y=min(a[i],a[0]);j;j=(j-1)&i)
		{
			if (a[j]>x) y=x,x=a[j];
			else if (a[j]>y) y=a[j];
		}
		ans[i]=x+y;
	}
	for (i=2;i<n;i++) ans[i]=max(ans[i],ans[i-1]);
	for (i=1;i<n;i++) printf ("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 6912
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, M;
  ci(N, M);
  ve<int> a(N), b(N), c(M), d(M);
  rep(i, N){
    ci(a.at(i), b.at(i));
  } 
  rep(i, M){
    ci(c.at(i), d.at(i));
  }
  ve<int> A(N, 0);
  rep(i, N){
    ll cnt = 2 * pow(10, 16);
    rep(j, M){
      ll x = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
      if(cnt > x){
        cnt = x;
        A.at(i) = j;
      }
    }
  }
  rep(i, N){
    co(A.at(i) + 1);
  }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s;
		while((s=br.readLine())!=null && !s.isEmpty())
		{
			int[] l = new int[10];
			int[] v = new int[2];
			int temp = 0;
			for (int i = 0; i < 10; i++) {
				l[i] = Integer.parseInt(s.split(",")[i]) + temp;
				temp = l[i];
			}
			for (int i = 10; i < 12; i++) {
				v[i-10] = Integer.parseInt(s.split(",")[i]);
			}
			System.out.println(calc(l,v));
		}
	}
	private static int calc(int[] l, int[] v)
	{
		double sum_l=l[9];
		double intersection;
		
		intersection = sum_l/(v[0]+v[1]) * v[0];
		int cnt=0;
		while(l[cnt]<intersection) {cnt++;}
		return cnt+1;
	}
}

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

int D,N;
int a[20];
LL Pow[20];

LL chec () {
	LL re = 1;
	for(int i = 1;i <= N / 2;++i) {
        LL yinzi = (10 - abs(a[i]));
		if(i == 1 && a[i] >= 0)
			yinzi--;
		re = re * yinzi;
	}
	if(N & 1) {
		LL yinzi = 10;
		if(N == 1)
			--yinzi;
		re = re * yinzi;
	}
	return re;
}

LL dfs (int u,LL lef) {
	if(u > N / 2) {
		if(lef != 0)
			return 0;
		return chec();
	}

	if(9 * (Pow[N - u] - Pow[u - 1]) < lef) {
		a[u] = 9;
		return dfs(u + 1,lef - 9 * (Pow[N - u] - Pow[u - 1]));
	}
	if(-9 * (Pow[N - u] - Pow[u - 1]) > lef) {
		a[u] = -9;
		return dfs(u + 1,lef + 9 * (Pow[N - u] - Pow[u - 1]));
	}
    if(lef % (Pow[N - u] - Pow[u - 1]) == 0) {
		a[u] = lef / (Pow[N - u] - Pow[u - 1]);
		return dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
    }
    LL re = 0;
    a[u] = abs(lef) / (Pow[N - u] - Pow[u - 1]);
    if(lef > 0) {
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
		a[u]++;
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
    }
	else {
		a[u] *= -1;
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
		a[u]--;
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
	}
	return re;
}

int main () {
	//freopen("1.txt","r",stdin);
	scanf("%d",&D);
	Pow[0] = 1;
	for(int i = 1;i <= 17;++i)
		Pow[i] = Pow[i - 1] * 10;

	LL pr = 0;
	for(int i = 1;i <= 18;++i) {
		N = i;
		pr += dfs(1,D);
	}
	printf("%lld\n",pr);
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include<cstdlib>


#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;

typedef long long ll;
using namespace std;

int main()
{
     ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
     int n,i,k,l,c=0,d,p,nl,np;
    int a[51],b;
   cin>>n;
   vector<int> v(n);

   REP(i,n)
   {
    cin>>v[i];

   }
   REP(i,n)
   {
       if(v[i]!=i+1)c++;

   }

   if(c<=2)cout<<"YES";
   else cout<<"NO";





}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> x[m];
    rep(i,m){
        int k;
        cin>>k;
        rep(j,k){
            int s;
            cin>>s;
            --s;
            x[i].push_back(s);
        }
    }
    int p[m];
    rep(i,m)cin>>p[i];

    int ans=0;

    rep(i,(1<<n)){
        int onlight=0;
        rep(j,m){
            int matchswitch=0;
            for(auto au:x[j]){
                if(i&(1<<au))matchswitch++;
            }
            if((matchswitch%2)==p[j])onlight++;
        }
        if(onlight==m)++ans;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n,m; ll x; cin>>n>>m>>x;
	VL c(n);
	vector<VL> a;
	rep(i,n){
		cin>>c[i];
		VL b(m); rep(j,m) cin>>b[j]; a.PB(b);
	}
	ll ans=LINF;
	rep(i,1<<n){
		VL r(m,0LL); ll tmp=0LL;
		rep(j,n){
			if(i&1<<j){
				tmp+=c[j];
				rep(k,m) r[k]+=a[j][k];
			}
		}
		bool flg=true;
		rep(j,m) if(r[j]<x) flg=false;
		if(flg) chmin(ans,tmp);
	}
	if(ans==LINF) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

mat f(4,vll(4));
mat g(4,vll(4));
lli md = 0;
const lli dx[] = {1,0,-1,0};
const lli dy[] = {0,1,0,-1};
lli lim = 0;
lli ans = 100;
lli x,y;

vll px,py;
vll fx,fy;
vll gx,gy;
map<mat,lli> m;
map<mat,lli> w;
bool flag = false;

bool isin(lli x,lli y){
    return x >= 0 && x < 4 && y >= 0 && y < 4;
}

lli m_dist(lli p,lli i,lli j){
    return abs(i-px[p]) + abs(j-py[p]);
}

void dfs(lli md,lli s,lli x,lli y){
    if(md+s > lim) return;
    if(m.find(f) != m.end()){
        if(m[f] > s) m[f] = s;
        else return;
    }else{
        m[f] = s;
    }
    if(s > lim/2) return;
    for(lli i = 0;i < 4;i++){
        if(isin(x+dx[i],y+dy[i])){
            swap(f[x+dx[i]][y+dy[i]],f[x][y]);
            dfs(md+m_dist(f[x][y],x,y)-m_dist(f[x][y],x+dx[i],y+dy[i]),s+1,x+dx[i],y+dy[i]);
            swap(f[x+dx[i]][y+dy[i]],f[x][y]);            
        }
    }
}

void dfs2(lli md,lli s,lli x,lli y){
    if(md+s > lim) return;
    if(w.find(g) != w.end()){
        if(w[g] > s) w[g] = s;
        else return;
    }else{
        w[g] = s;
    }
    if(m.find(g) != m.end()){
        ans = min(ans,s+m[g]);
        flag = true;
    }
    if(s > lim/2) return;
    for(lli i = 0;i < 4;i++){
        if(isin(x+dx[i],y+dy[i])){
            swap(g[x+dx[i]][y+dy[i]],g[x][y]);
            dfs2(md+m_dist(g[x][y],x,y)-m_dist(g[x][y],x+dx[i],y+dy[i]),s+1,x+dx[i],y+dy[i]);
            swap(g[x+dx[i]][y+dy[i]],g[x][y]);            
        }
    }
}


int main(){
    for(lli i = 0;i < 4;i++) for(lli j = 0;j < 4;j++) cin >> f[i][j];

    fx = vll(16);
    fy = vll(16);
    for(lli i = 1;i < 16;i++){
        fx[i] = (i-1)/4;
        fy[i] = (i-1)%4;
    }
    px = fx;py = fy;

    for(lli i = 0;i < 4;i++){
        for(lli j = 0;j < 4;j++){
            if(f[i][j]){
                md += m_dist(f[i][j],i,j);
            }else{
                x = i;
                y = j;
            }
        }
    }
    for(lli i = 0;i < 4;i++) for(lli j = 0;j < 4;j++) g[i][j] = (i*4+j+1)%16;
    gx = vll(16);
    gy = vll(16);
    for(lli i = 0;i < 4;i++){
        for(lli j = 0;j < 4;j++){
            gx[f[i][j]] = i;
            gy[f[i][j]] = j;
        }
    }

    for(lli i = md;i <= 46;i++){
        lim = i;
        m = map<mat,lli>();
        w = map<mat,lli>();
        px = fx;py = fy;
        dfs(md,0,x,y);
        px = gx;py = gy;
        dfs2(md,0,3,3);
        if(flag){
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 194836
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair





int main(){
    string a,b,ans;
    cin>>a>>b;
    for(int i=0;i<a.size()+b.size();i++){
        if(i%2==0){ans.push_back(a[i/2]);}
        else{ans.push_back(b[(i-1)/2]);}
    }
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

def na(): return map(int,stdin.readline().split())

def ns(): return stdin.readline().strip()

n,a,b=na()
v=list(na())
v.sort()
tot=0
last=0
for i in range(a):
    tot+=v[-(i+1)]
    last=v[-(i+1)]

com=[]
q=100
for i in range(q):
    com.append([0]*q)

for i in range(q):
    com[i][0]=1
    for j in range(1,q):
        com[i][j]=com[i-1][j-1]+com[i-1][j]

print("{:.9f}".format(tot/a))
lct=0
large=0
for w in v:
    if w>last:large+=1
    if w==last:lct+=1
ret=0
if large==0:
    for i  in range(a,b+1):
        if 0 <= i-large <= lct:
            ret+=com[lct][i-large]
else :
    ret=com[lct][a-large]
print(ret)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int ma=0, mi=1000000000;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int buf; cin >> buf;
			ma = max(ma, buf);
			mi = min(mi, buf);
			ans += buf;
		}
		cout << (ans - ma - mi) / (n - 2) << endl;
	}
}

Measured memory_bytes: 3008
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n;
	scanf("%c", &n);
	printf("%c\n", n + 1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
int N;
double p[3010];
double memo[3010][3010];



double dfs(int uranum,int nowcoin){
  if(nowcoin > -1 && memo[uranum][nowcoin] > -0.99){
    return memo[uranum][nowcoin];
  } else {
    if(nowcoin == N-1) {
      memo[uranum][nowcoin] = 1.0;
      return 1.0;
    }
    if(uranum >= (N - 1)/2){
      double omote = p[nowcoin+1] * dfs(uranum,nowcoin+1);
      memo[uranum][nowcoin] = omote;
      return omote;
    } else { 
      double omote =  p[nowcoin+1] * dfs(uranum,nowcoin+1);
      double ura =  (1.0 - p[nowcoin+1]) * dfs(uranum + 1,nowcoin+1);
      memo[uranum][nowcoin] = ura + omote;
      return ura + omote;
    }
  }
  
}

int main() {
  cin >> N;
  rep(i,N){
    rep2(j,N){
      memo[i][j] = -1.0;
    }
  }
  rep(i,N){
    cin >> p[i];
  }
  double ans = dfs(0,-1);
  cout << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 71040
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int x, y, z, len, count;
	while(scanf("%d %d %d", &x, &y, &z)!=EOF)
	{
		len = 0, count = 0;
		for(int i = 1; ; i++)
		{
			if(i % 2 != 0)
			{
				 len += z;
		    }
			else if(i % 2 == 0)
		    {
				 len += y;
				 if((len + z) <= x ) count++;
			}
	    	if(len >= x) break;
		}
		printf("%d\n", count);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000009;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
struct SegmentTree{
    int siz;
    vector<int> node;
    SegmentTree(int n,int init){
        siz=1;
        while(siz<n)siz<<=1;
        node.assign(2*siz,init);
    }

    void update(int k,int x){
        k+=siz-1;
        node[k]+=x;
        while(k>0){
            k=(k-1)/2;
            node[k]=node[2*k+1]+node[2*k+2];
        }
    }

    int query(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=siz;
        if(r<=a||b<=l)return 0;
        if(a<=l&&r<=b)return node[k];
        int vl=query(a,b,2*k+1,l,(l+r)/2);
        int vr=query(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }
};
int main(){
	int n,q;cin>>n>>q;
	SegmentTree seg(n,0);
	while(q--){
		ll com,x,y;cin>>com>>x>>y;
		if(com){
			cout<<seg.query(x-1,y)<<endl;
		}else{
			seg.update(x-1,y);
		}
	}
    return 0;
}



Measured memory_bytes: 3816
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <functional>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,a[100100];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int main()
{
    n=getint();
    repu(i,1,n)
        a[i]=getint();
    sort(a+1,a+1+n,greater<int>());
    repu(i,1,n)
    {
        if (a[i]==i)
        {
            int j=i;
            for (; j<n && a[j+1]==a[i]; ++j);
            puts((j-i)&1?"First":"Second");
            return 0;
        }
        if (a[i+1]==i)
        {
            int j=i+1;
            for (; j<n && a[j+1]==i; ++j);
            puts(((j-i)&1) || ((a[i]-i)&1)?"First":"Second");
            return 0;
        }
        if (a[i+1]<i)
        {
            puts((a[i]-i)&1?"First":"Second");
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 512
H, W = list(map(int, input().split()))
squareA = [list(input()) for i in range(H)]
squareB = [[squareA[i][j] for i in range(H)] for j in range(W)]
h = []
w = []
for i in range(H):
  if '#' not in squareA[i]:
    h.append(i)
for i in range(W):
  if '#' not in squareB[i]:
    w.append(i)
for i in range(H):
  if i not in h:
    for j in range(W):
      if j not in w:
        print(squareA[i][j], end = "")
    print(end = "\n")

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define FoR(i,x,y,z) for(int i=(x);i<=(y);i+=(z))
#define RoF(i,x,y,z) for(int i=(x);i>=(y);i-=(z))
#define Edge(x) for(int i=head[x],to=e[i].v;i;i=e[i].nxt,to=e[i].v)
typedef long long ll;
const int N=8005;
const int M=205;
const int mod=998244353;
using namespace std;

ll dp[M][N],g[N<<2],f[N<<2],fac[N],invf[N],G[N<<2][2],invl,ans=0;
int len,bit,rev[N<<2];

ll qpow(ll x,int y){ ll res=1; for(;y;y>>=1,(x*=x)%=mod) if(y&1) (res*=x)%=mod;return res; }
ll C(int x,int y){ return x>=y?fac[x]*invf[y]%mod*invf[x-y]%mod:0; }

void init(int n){
	fac[0]=fac[1]=invf[0]=invf[1]=1;
	For(i,2,n){
		fac[i]=1ll*fac[i-1]*i%mod;
		invf[i]=1ll*(1ll*mod-mod/i)*invf[mod%i]%mod;
	}
	For(i,2,n) (invf[i]*=invf[i-1])%=mod;
}

void FFT_init(int n){
	for(len=1,bit=0;len<=(n<<1)+2;len<<=1,++bit); invl=qpow(len,mod-2);
	For(i,0,len-1) rev[i]=(rev[i>>1]>>1)|((i&1)<<(bit-1));
	G[len][1]=qpow(3ll,(mod-1)/len),G[len][0]=qpow(G[len][1],mod-2);
	for(int i=(len>>1);i>=1;i>>=1){
		G[i][1]=G[i<<1][1]*G[i<<1][1]%mod;
		G[i][0]=G[i<<1][0]*G[i<<1][0]%mod;
	}
}
void FFT(ll *a,int f){
	For(i,0,len-1) if(rev[i]>i) swap(a[i],a[rev[i]]);
	FoR(i,2,len,i){
		ll omega=G[i][f];int mid=i>>1;
		FoR(j,0,len-1,i){
			ll w=1;
			For(k,j,j+mid-1){
				ll u=a[k],v=a[k+mid]*w%mod;
				a[k]=(u+v)%mod,a[k+mid]=(u-v+mod)%mod;
				(w*=omega)%=mod;
			}
		} 
	}
	if(!f) For(i,0,len-1) (a[i]*=invl)%=mod;
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	init(n+2);
	FFT_init(n);
	dp[0][0]=g[0]=1;
	FFT(g,1);
	For(j,1,m){
		dp[j][0]=1;
		For(i,0,len-1) f[i]=0;
		For(i,1,n) f[i]=invf[i+2];
		FFT(f,1);
		For(i,0,len-1) f[i]=f[i]*g[i]%mod;
		FFT(f,0);
		For(i,1,n) (dp[j][i]+=f[i])%=mod;
		For(i,1,n){
			(dp[j][i]*=fac[i+2])%=mod;
			(dp[j][i]+=(C(i+1,2)+1)%mod*dp[j-1][i])%=mod;
		}
		For(i,0,len-1) g[i]=0;
		For(i,0,n) g[i]=dp[j][i]*invf[i]%mod;
		FFT(g,1);
	}
	For(i,0,n) (ans+=dp[m][i]*C(n,i)%mod)%=mod;
	printf("%lld\n",ans);
}

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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define FORR(el,vecc) for(auto& el:vecc)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
    ll n;
    cin >>n;
    ll count =0;

    for (ll i = 1; i <10 && i <= n; ++i) {
        count++;
    }
    if(n >= 100)
        for (int i = 100; i <=999 && i<=n ; ++i) {
            count++;
        }
    if ( n >= 10000)
        for (int j = 10000; j <=99999 && j <= n ; ++j) {
            count++;
        }
   // if(n == 10000)count++;
    cout << count;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=310;
int n,k,f[N][N][N];
char s[N];
int main(){
	scanf("%s",s+1);
	scanf("%d",&k);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
		for(int j=0;j<=k;j++) f[i][i][j]=1;
	int l,r;
	for(int i=2;i<=n;i++)
		for(int j=1;j<=n-i+1;j++)
			for(int x=0;x<=k;x++){
				l=j,r=j+i-1;
				f[l][r][x]=max(f[l+1][r][x],f[l][r-1][x]);
				if(x) f[l][r][x]=max(f[l][r][x],f[l+1][r-1][x-1]+2);
				if(s[l]==s[r]) f[l][r][x]=max(f[l][r][x],f[l+1][r-1][x]+2);
			}
	printf("%d",f[1][n][k]);
	return 0;
}

Measured memory_bytes: 114560
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int A, B; cin >> A >> B;

    if (A + B < 10) cout << A + B << endl;
    else cout << "error" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set> 
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++)cin>>arr[i];
    ll cash=1000,stock=0;
    bool status[n+1];
    for(int i=1;i<n;i++){
        if(arr[i]<arr[i+1])status[i]=true;
        else status[i]=false;
    }
    for(int i=1;i<n;i++){
        if(status[i]){
            stock+=(cash/arr[i]);
            cash%=arr[i];
        }
        else {
            cash+=(stock*arr[i]);
            stock=0;
        }
    }
    cash+=(stock*arr[n]);
    cout<<cash<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
using namespace std;
int main(){
	string str, ord, p,ans;
	int m, a, b,y;
	cin >> str >> m;
	for (int i = 0; i < m; i++){
		cin >> ord;
		if (ord == "replace"){
			cin >> a >> b >> p;
			for (int k = 0; k < b - a + 1; k++){
				str[a + k] = p[k];
			}
		}
		if (ord == "reverse"){
			cin >> a >> b;
			for (int j = a; j < b ; j++){
				y = b;
				
				ans[j] = str[j];
				str[j] = str[y];
				str[y] = ans[j];
				b--;
			}
		}
		if (ord == "print"){
			cin >> a >> b;
			cout << str.substr(a,b-a+1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3228