akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <cerrno>
#include <cfenv>
#include <math.h>
#include <iomanip>
#include <limits>
#define ll long long int

using namespace std;

int main(){

    int n;

    while(true){

        vector<int> data(1000);

        cin >> n;

        if(n==0){
            break;
        }

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

        sort(data.begin(),data.begin()+n);

        vector<int> dis(1000);

        for(int i=0;i<n-1;i++){
            dis[i] = data[i+1]-data[i];
        }

        sort(dis.begin(),dis.begin()+n-1);

        cout << dis[0] << endl;

    }

    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    string S;
    cin >>S;
    int ans=753;
    REP(i,S.size()-2){
        string z=S.substr(i,3);
        int a=stoi(z);
        ans=min(ans,abs(a-753));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    ll res = 0;
    for (ll i = 0; i < n; i++) {
        res += (i + 1LL) * (n - i);
    }
    for (int i = 0; i < n - 1; i++) {
        ll u, v;
        cin >> u >> v;
        --u;
        --v;
        if (u > v) swap(u, v);
        res -= (u + 1LL) * (n - v);
    }
    cout << res << newl;
}

Measured memory_bytes: 3672
bound_num, line_length = map(int, input().split())
l = list(map(int, input().split()))

bound = 1
length_sum = 0
for i in range(bound_num + 1):
    if(i == bound_num):
        print(len(l)+1)
        exit()
    if(length_sum + l[i] <= line_length):
        bound += 1
    else:
        print(bound)
        exit()
    length_sum += l[i]


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


int main() {
    int h,w,n;
    cin >> h >> w >> n;

    if (h >= w){
        if (n%h == 0){
            cout << n/h << endl;
        }

        else{
            cout << n/h+1 << endl;
        }
    }

    if (h < w){
        if (n%w == 0){
            cout << n/w << endl;
        }

        else{
            cout << n/w+1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
int p[200005];
int b[200005];
int col[200005];
queue<int> q;
bool check(int X){
    memset(col,-1,sizeof(col));
    for (int i = 0; i < 2*n-1; i++){
        p[i] = a[i]>=X?1:0;
        //printf("%d ",p[i]);
    }
    //printf("IN\n");
    int ct = 1;
    int last = 0;
    for (int i = 1; i < 2*n-1; i++){
        if ((p[i] != p[i-1])){
            if (ct >= 2 || last == 0){
                col[last] = p[last];
                q.push(last);
                last = i-1;
                col[last] = p[last];
                q.push(last);
            }
            ct = 1;
            last = i;
        }
        else ct++;
    }
    col[last] = p[last];
    q.push(last);
    last = 2*n-2;
    col[last] = p[last];
    q.push(last);
    while (q.size()){
        int u = q.front(); q.pop();
        //printf("at %d\n",u);
        if (u >= 1 && col[u-1] == -1){
            col[u-1] = col[u];
            q.push(u-1);
        }
        if (u+1 < 2*n-1 && col[u+1] == -1){
            col[u+1] = col[u];
            q.push(u+1);
        }
    }
    /*for (int i = 0; i < 2*n-1; i++){
        printf("%d ",col[i]);
    }
    printf("OUT\n");*/
    return col[n-1];
}
int main(){
    scanf("%d",&n);
    for (int i = 0; i < 2*n-1; i++){
        scanf("%d",&a[i]);
    }
    int lo = 1, hi = 2*n-1;
    while (lo < hi){
        int X = (lo+hi+1)/2;
        if (check(X)) lo = X;
        else hi = X-1;
    }
    printf("%d ",lo);


}


Measured memory_bytes: 3072
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=500005;
int n,a,b,c,d;
int main(){
	scanf("%d",&n);
	a=n/1000;n%=1000;
	b=n/100;n%=100;
	c=n/10;c%=10;d=n;
	if(a==b||b==c||c==d)
		printf("Bad\n");
	else printf("Good\n");
}

Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	string s; cin >> s;
	for (int i = 0; i <= (int)s.length() - 2; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";

	return 0;
}

Measured memory_bytes: 3116
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
puts K*((K-1)**(N-1))

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
    int n;
    cin >> n;

    vector<int> a;
    for (int i=0; i < n; i++)
    {
        int val;
        cin >> val;
        a.push_back(val);
    }
    a.push_back(1e9 + 1);


    int prev = 0 ,count = 0, max = 0;
    for (auto val: a)
    {
        if (val <= prev)
        {
            count++;
        }
        else
        {
            if (count > max)
            {
                max = count;
            }
            count = 0;
        }
        prev = val;
    }

    cout << max << endl;
    return 0;
}


Measured memory_bytes: 892
class UnionFind():
    # 作りたい要素数nで初期化
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    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.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズ
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


import sys
input = sys.stdin.buffer.readline
from operator import itemgetter

N, M = map(int, input().split())
W = list(map(int, input().split()))
ABY = [list(map(int, input().split())) for _ in range(M)]

ABY.sort(key=itemgetter(2))

uni = UnionFind(N)
dic = {}
for i, w in enumerate(W):
    dic[i] = (w, 0)

for a1, a2, y in ABY:
    a1 -= 1; a2 -= 1
    r1 = uni.Find_Root(a1)
    r2 = uni.Find_Root(a2)
    w1, c1 = dic[r1]
    w2, c2 = dic[r2]
    if r1 == r2:
        c = 0 if y <= w1 else c1 + 1  
        dic[r1] = (w1, c)
    else:
        w = w1 + w2
        c = 0 if y <= w else c1 + c2 + 1
        uni.Unite(r1, r2)
        r = uni.Find_Root(r1)
        dic[r] = (w, c)

r = uni.Find_Root(0)
_, ans = dic[r]
print(ans)

Measured memory_bytes: 114228
#include <iostream>
#include <map>
using namespace std;
int main(){
  int A, cnt=0;
  for(int i=0;i<3;i++){
    cin>>A;
    if(A==5) cnt++;
    else if(A==7) cnt--;
  }
  cout << (cnt==1?"YES":"NO") << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}
		int max = a[0];
		for(int i=0; i<n; i++){
			if(a[i]>max)max = a[i];
		}
		int r = a[0];
		if(max%2 == 0){
			for(int j=0; j<n; j++){
				if(Math.abs(max/2 - a[j])<=Math.abs(max/2 - r) && a[j]<max)r = a[j];
			}
		}
		else{
			for(int j=0; j<n;j++){
				if(Math.min(Math.abs((max-1)/2 - a[j]),Math.abs((max+1)/2 - a[j]))<=Math.min(Math.abs((max-1)/2 - r),Math.abs((max+1)/2 - r)) && a[j]<max)r = a[j];
			}
		}
		System.out.println(max + " " + r);
	}
}

Measured memory_bytes: 50392
(N,M) = (int(s) for s in input().split(" "))
s = input()
is_ac = [False,False]
total = [0,0]
for i in range(1,len(s)):
	if s[i-1:i+1] == "AC":
		total.append(total[-1]+1)
		is_ac.append(True)
	else:
		total.append(total[-1])
		is_ac.append(False)
for i in range(M):
	(l,r) = (int(t) for t in input().split(" "))
	ans = total[r] - total[l-1]
	if is_ac[l]:
		ans-=1
	print(ans)




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

using namespace std;
const int maxn = 2 * 1e5 + 20;
int dp[maxn];
string s;
int main()
{

	cin >> s;
	
	dp[1] = 1;
	int l = s.size();
	s = '#' + s;
	
	if(s[1] == s[2])
	{
		dp[2] = 1;
	}
	else dp[2] = 2;
	for(int i = 3; i <= l; i++)
	{
	 if (s[i] != s[i - 1])
	 {
	 	dp[i] = dp[i - 1] + 1;
	 }
		else
		{
			dp[i] = dp[i - 3] + 2;
		}
	}

	cout << dp[l] << endl;
	return 0;
}

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

int main(){

int N;
scanf("%d",&N);
int x[N];
int y[N];
for (int i = 0; i < N; i++)
{
  scanf("%d %d",&x[i],&y[i]);
}

int d_num = (N-1)*N/2;
double d[d_num];
int k = 0;
for (int i = 0; i < N-1; i++){
  for (int j = i+1; j < N; j++){
    d[k++]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
  }
}

double d_sum = 0;
for (int i = 0; i < k; i++){d_sum += d[i];}

printf("%.10f",d_sum*(N-1)/d_num);


return 0;

}

Measured memory_bytes: 2212
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

a, b, c, d = map(int, input().split())
cnt = (b // c + b // d - b // lcm(c, d)) - ((a - 1) // c + (a - 1) // d - (a - 1) // lcm(c, d))
print((b - a + 1) - cnt)

Measured memory_bytes: 5560
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#define endl "\n"
using namespace std;

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

  int a, b, c, d;

  cin >> a >> b >> c >> d;

  if (a * b >= c * d)
  {
    cout << a * b << endl;
  }
  else
  {
    cout << c * d << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//OPTIMIZATIONS
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
//#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//OPTIMIZATIONS
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long uu;
typedef long long int lll;
typedef unsigned long long int uuu;
using namespace std;

#define watch(x) cerr << "\n" \
					  << (#x) << " is " << (x) << endl
#define cel(x, y) 1 + ((x - 1) / y)
const double PI = 3.141592653589793238463;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;

/*
$alil03

URL: url

Solution Begins here
*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	lll a, b;
	cin >> a >> b;
	cout << (lll)a * (lll)b / (lll)__gcd(a, b);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, b;

	scanf("%d", &a) ;
	scanf("%d", &b) ;
	
	if( a < b ) printf("a < b\n") ;
	if( a > b ) printf("a > b\n") ;
	if( a == b ) printf("a == b\n") ;

	return 0 ;
}

Measured memory_bytes: 580
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b, t) = listOfInt()
    println((t / a) * b)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37904
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    vector<long long> sa(a), sb(b);
    vector<long long> sma, smb;
    sma.push_back(0);
    smb.push_back(0);
    for (long long i = 0; i < a; i++)
    {
        cin >> sa[i];
        sma.push_back(sma[i] + sa[i]);
    }
    for (long long i = 0; i < b; i++)
    {
        cin >> sb[i];
        smb.push_back(smb[i] + sb[i]);
    }
    long long ans = 0, j = b;
    for (long long i = 0; i <= a; i++)
    {
        if (sma[i] > k)
            break;
        while (smb[j] > k - sma[i])
        {
            j -= 1;
        }
        ans = max(ans, i + j);
    }
    cout << ans;
}

Measured memory_bytes: 11024
<?php

list($n, $q) = explode(' ', trim(fgets(STDIN)));

$nextNodesByNode = [];

for ($i=1;$i<$n;++$i) {
    list($a, $b) = explode(' ', trim(fgets(STDIN)));
    $a = (int) $a;
    $b = (int) $b;
    $nextNodesByNode[$a][] = $b;
    $nextNodesByNode[$b][] = $a;
}

$scores = array_fill_keys(range(1, $n), 0);

$scoreToAddByNode = [];
for ($j=1;$j<=$q;++$j) {
    list($p, $x) = explode(' ', trim(fgets(STDIN)));
    if (isset($scoreToAddByNode[$p])) {
        $scoreToAddByNode[$p] += $x;
    } else {
        $scoreToAddByNode[$p] = $x;
    }
}

$operatedNodes = [];
operate(1, 0);

echo implode(' ', $scores);

function operate(int $node, int $num)
{
    global $scoreToAddByNode;
    global $operatedNodes;
    global $nextNodesByNode;
    global $scores;

    if (isset($operatedNodes[$node])) {
        return;
    }

    $num += $scoreToAddByNode[$node] ?? 0;

    $scores[$node] += $num;
    $operatedNodes[$node] = true;

    foreach (($nextNodesByNode[$node] ?? []) as $next) {
        operate($next, $num);
    }
}


Measured memory_bytes: 199160
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    A = [list(input()[:-1]) for _ in range(N)]
    B = [list(input()[:-1]) for _ in range(M)]

    for i in range(N-M+1):
        for j in range(N-M+1):
            flg = True
            for y in range(M):
                for x in range(M):
                    if A[i+y][j+x]!=B[y][x]:
                        flg = False
            if flg:
                print('Yes')
                return
    print('No')
    
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
  int n, m, x, l=0, r=0;
  cin >> n >> m >> x;

  for (int i=0; i<m; i++) {
    int a;
    cin >> a;
    if (a<x) l++;
    else r++;
  }

  printf("%d\n", l>r ? r: l);
  return 0;
}

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

int main() {
  int a,b,c,x=0;
  cin >> a >> b >> c;
  for(int i=0; i<=c; i++){
    if(a<=i && i<=b && c%i==0){
      x++;
  }
  }
  cout << x << endl;
}



Measured memory_bytes: 3100
import sys
from collections import Counter
from itertools import accumulate
read = sys.stdin.read

N, K, *A = map(int, read().split())
a = list(accumulate([0] + A))
a = [(a[i] - i) % K for i in range(N + 1)]

answer = 0
if N < K:
    for i in Counter(a).values():
        answer += i * (i - 1) // 2
else:
    dic = Counter(a[:K])
    for i in dic.values():
        answer += i * (i - 1) // 2
    here = K
    for i, x in enumerate(a[K:]):
        dic[a[i]] -= 1
        answer += dic[x]
        dic[x] += 1

print(answer)

Measured memory_bytes: 41752
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 55;
char c[maxn][maxn];
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,-1,0,1};
int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	memset(c,'.',sizeof(c));
	for(int i = 1;i <= n; ++i)
	{
		for(int j = 1;j <= m; ++j)
		{
			cin>>c[i][j];
		}
	}
	for(int i = 1;i <= n; ++i)
	{
		for(int j = 1;j <= m; ++j)
		{
			if(c[i][j] == '.')
			{
				continue;
			}
			bool flag = 0;
			for(int k = 0;k < 4; ++k)
			{
				int nx = i + dx[k];
				int ny = j + dy[k];
				if(c[nx][ny] == '#')
				{
					flag = 1;
					break;
				}
			}
			if(!flag)
			{
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            int[][] set = new int[1000000][];

            while (true)
            {
                set[i] = new int[2];
                string[] input = Console.ReadLine().Split(' ');
                set[i][0] = int.Parse(input[0]);
                set[i][1] = int.Parse(input[1]);
                if (set[i][0] == 0 & set[i][1] == 0) break;
                i++;
            }
            for (int k = 0; k < i; k++)
            {


                for (int t = 0; t < set[k][0]; t++)
                {

                    if (t == 0 | t == set[k][0] - 1)
                    {
                        for (int p = 0; p < set[k][1]; p++)
                        {
                            Console.Write("#");
                        }
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.Write("#");
                        string a = new string('.', set[k][1] - 2);
                        Console.Write(a);
                        Console.WriteLine("#");
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;
int N;
int A[MAX_N], B[MAX_N];

signed main()
{
  cin >> N;
  int cnt = 0;
  int sumA = 0;
  int minA = INF_INT_MAX;
  int minB = INF_INT_MAX;
  bool flag = true;

  REP(i,N) {
    cin >> A[i] >> B[i];
    if(A[i] > B[i]) {
      if(minB == INF_INT_MAX) {
        minB = B[i];
      } else if(minB > B[i]) {
        minB = B[i];
      }
    }
    if(A[i] != B[i]) {
      flag = false;
    }
  }

  if(flag) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  flag = true;
  REP(i,N) {
    if(B[i] == minB && flag) {
      ans += A[i] - B[i];
      flag = false;
    } else {
      ans += A[i];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
struct data{
    int n,m;
    data(int a,int b){
        n=a;m=b;
    }
    data(){}
    bool operator<(const data &d)const{
        if(m!=d.m)return (m<d.m);
        else return (n>d.n);
    }

};
int main(){
    int n;
    cin>>n;
    data Max(100000,0);
    for(int i=0;i<n;i++){
        int p,q;
        cin>>p>>q;
        Max=max(Max,data(p,q));
    }
    cout<<Max.n<<" "<<Max.m<<endl;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,r,g,b,ans;
string s;
int main(){
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='R')r++;
		if(s[i]=='G')g++;
		if(s[i]=='B')b++;
	}
	ans=r*g*b;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n,2*j-i<n;j++){
			if(s[i]!=s[j]&&s[j]!=s[2*j-i]&&s[i]!=s[2*j-i]) ans--;				
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3644
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

ll n,w;
ll we[107],v[107];
ll dp[107][100007];

ll fun(ll x, ll curr)
{
	if(dp[x][curr]!=-1)
		return dp[x][curr];
	if(x==n)
	{
		if(curr-we[x] >=0)
			dp[x][curr] = v[x];
		else
			dp[x][curr] = 0; 
	}else {
	if(curr-we[x]>=0)
		dp[x][curr] = max(fun(x+1,curr),fun(x+1,curr-we[x]) + v[x]);
	else
		dp[x][curr] = fun(x+1,curr);
}
//	deb3(x,curr,dp[x][curr]);
	return dp[x][curr];
}

int main()
{
	fastio
	cin >> n >> w;
	for(ll i=1;i<=n;i++){
		cin >> we[i] >> v[i];
	}
	for(ll i=1;i<=n;i++)
		for(ll j=0;j<=w;j++)
			dp[i][j]=-1;

	cout << fun(1,w) << endl;;
	return 0;	
}


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

int main() {
  long long n; cin >>n;
  vector<long long>a(n+1);
  for(long long i=0;i<=n;i++)cin>>a[i];
  if(n==0){
    if(a[0]==1){
      cout<<1<<endl;
      return 0;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }
  if(a[0]==1){
    cout<<-1<<endl;
    return 0;
  }
  vector<long long>wa(n+1,0);
  wa[n]=a[n];
  for(long long i=n-1;i>=0;--i){
    wa[i]+=a[i]+wa[i+1];
  }
  long long kotae=1;
  long long chouten=1;
  for(long long i=1;i<n+1;i++){
    if(chouten>=LLONG_MAX/2){
      chouten==LLONG_MAX;
    }else{
      chouten*=2;
    }
    kotae+=min(chouten,wa[i]);
    //cout<<i<<" "<<chouten<<" "<<wa[i]<<" "<<kotae<<endl;
    if(a[i]!=0){
      chouten-=a[i];
      if(chouten<0){
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 4840
// inputに入力データ全体が入る
function Main(input) {
  
    var S = input;
    console.log('%s', '2018' + S.substr(4, 6));
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
using ll = long long;

//経路復元なしDijkstra法
template<class T> 
vector<T> dijkstra(int start, T INF, const vector<vector<pair<int,T>>>& Hen){
    int N = Hen.size();
    vector<T> dist(N, INF);
    vector<bool> seen(N);
    dist[start] = 0;
    priority_queue<pair<T,int>, vector<pair<T,int>>, greater<pair<T,int>>> que;
    que.emplace(0, start);

    while(que.size()) {
        int ver = que.top().second;
        T cost = que.top().first; que.pop();
        if(seen[ver])continue;
        seen[ver] = true;
        for(auto i : Hen[ver]) {
            if(dist[i.first] > cost + i.second) {
                dist[i.first] = cost + i.second;
                que.emplace(dist[i.first], i.first);
            }
        }
    }

    return dist;

}


int main()
{
    vector<tuple<double, double, double>> pos;
    {
        double xa, ya, xb, yb; cin >> xa >> ya >> xb >> yb;
        pos.push_back({xa, ya, 0}), pos.push_back({xb, yb, 0});
    }
    int n; cin >> n;

    for(int i = 0; i < n; i++) {
        double x, y, r; cin >> x >> y >> r;
        pos.push_back({x, y, r});
    }

    vector<vector<pair<int,double>>> hen(n + 2);
    for(int i = 0; i < n + 2; i++) {
        for(int j = i + 1; j < n + 2; j++) {
            double xa, ya, ra, xb, yb, rb, dist;
            tie(xa, ya, ra) = pos[i], tie(xb, yb, rb) = pos[j];
            dist =  sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)) - (ra + rb);
            dist = max(dist, 0.0);
            hen[i].push_back({j, dist});
            hen[j].push_back({i, dist});
        }
    }

    cout << fixed <<setprecision(12) << dijkstra(0,1e18,hen)[1] << '\n';


}

Measured memory_bytes: 23784
#include <iostream>

using namespace std;

int main()
{
    int x{};
    cin >> x;
    int y{};
    cin >> y;
    if (x==y)
        cout << "Draw";
    else if (x==1 && y!=1)
        cout << "Alice";
    else if (y==1 && x!=1)
        cout << "Bob";
    else
    {
        if (x<y)
            cout << "Bob";
        else if (x>y)
            cout << "Alice";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
using namespace std;
int main()

{
    FastRead
    ll int a,b,i;
    cin>>a>>b;
    f(i=0;i<max(a,b);i++)
    {
        cout<<min(a,b);
    }
    return 0;

}


Measured memory_bytes: 3624
import java.math.BigDecimal;
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //long start = System.currentTimeMillis();
        final long MOD = (long)Math.pow(10,9)+7;
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuilder sb = new StringBuilder(s);
        if (s.substring(s.length()-1,s.length()) .equals("s")) sb.append("es");
        else sb.append("s");

        System.out.println(sb.toString());
        sc.close();
//        long end = System.currentTimeMillis();
//        System.err.println((end-start)+"ms");
    }
}

Measured memory_bytes: 27024
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

ll lcm(ll a, ll b)
{
   return a / gcd(a, b) * b;
}

int main()
{
  ll n;
  cin >> n;
  vector<ll> x(n),y(n);
  rep(i,n) cin >> x[i];
  rep(i,n) y[i] = x[i];

  sort(ALL(y));
  ll a = y[(n-2)/2];
  ll b = y[n/2];

  vector<ll> ans(n);

  rep(i,n){
    if(x[i] < a) ans[i] = b;
    else if(x[i] == a) ans[i] = b;
    else if(x[i] == b) ans[i] = a;
    else ans[i] = a;
  }
  rep(i,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 6912
import numpy as np
H, W = map(int, input().split())
mat = []
for _ in range(H):
    a = list(input())
    ca = [0 if i == '.' else 1 for i in a]
    mat.append(ca)
amat = np.array(mat)

mask1 = []
for i in range(H):
    if np.sum(amat[i]) != 0:
        mask1.append(i)
amat1 = amat[mask1]

mask2 = []
for i in range(W):
    if np.sum(amat1[:,i]) != 0:
        mask2.append(i)
amat2 = amat1[:,mask2]

ans = []
for i in range(amat2.shape[0]):
    temp = ''
    for s in amat2[i]:
        if s == 1:
            temp += '#'
        else:
            temp += '.'
    ans.append(temp)
print(*ans, sep='\n')


Measured memory_bytes: 27056
N,M=map(int,input().split())
A=[[] for i in range(N)]

for i in range(M):
    x,y=map(int,input().split())
    A[x-1].append(y)
    A[y-1].append(x)

color=["W" for i in range(N)]

clear=["B" for i in range(N)]

def path(x,d):
    if color[x-1]=="B":
        return False
        
    color[x-1]="B"

    if color==clear:
        color[x-1]="W"
        return True
    
    ans=0
    for i in range(len(A[x-1])):
        ans+=int(path(A[x-1][i],d+1))

    color[x-1]="W"
    return ans

print(path(1,0))


Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    vector<int> a(N);
    FOR(i,0,N) cin>>a[i];
    sort(a.begin(),a.end());
    int b=0;
    FOR(i,0,N){
        if(abs(2*a[i]-a[N-1])<abs(2*b-a[N-1])) b=a[i];
    }
    cout << a[N-1] << " " << b << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

string S;
int i;

ll dfs() {
  ll ret = 0;
  i++;

  if('0' <= S[i] && S[i] <= '9') {
    while('0' <= S[i] && S[i] <= '9') {
      ret = ret * 10 + (S[i] - '0');
      i++;
    }
    ret = (ret + 1) / 2;
  } else {
    vector<ll> x;
    while(S[i] == '[') x.push_back(dfs());
    sort(x.begin(), x.end());
    REP(j, 0, (x.size() + 1) / 2) ret += x[j];
  }

  i++;
  return ret;
}

int main(void) {
  ll N;
  cin >> N;
  REP(j, 0, N) {
    cin >> S;
    i = 0;
    cout << dfs() << endl;
  }
}




Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;

int main(){
  string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else{
    cout<<"Sunny"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int array[] = new int[n];
		long sum = 0;
		long mod = ((long)Math.pow(10,9) + 7);
		for(int i=0;i<n;i++){
			array[i] = sc.nextInt();
			sum += array[i];
			sum %= mod;
		}
		long x = 0;
		for(int i=0;i<n;i++){
			sum -= array[i];
			if (sum < 0)
				sum += mod;
			x += array[i] * sum;
			x %= mod;
		}
		System.out.println(x);
		sc.close();
	}
}


Measured memory_bytes: 60988
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        long[][] a = new long[26][s.length];
        a[s[0] - 'a'][0] = 1;
        for (int i = 1; i < s.length; i++) {
            for (int j = 0; j < 26; j++) a[j][i] = a[j][i-1];
            a[s[i] - 'a'][i]++;
        }
        long ans = 1;
        for (int i = 0; i < s.length; i++) {
            int len = s.length -1 - i;
            int idx = s[i] - 'a';
            ans += len - (a[idx][s.length-1] - a[idx][i]);
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 70596
triangle = []
n = int(input())
for i in range(n):
    try:
        (a,b,c) = input().split(" ")
        triangle.append((a,b,c))
    except:
        break
for (a,b,c) in triangle:
    if (int(a)**2 + int(b)**2 == int(c)**2) or (int(b)**2 + int(c)**2 ==int(a)**2) or (int(a)**2 + int(c)**2 == int(b)**2) :
        print("YES")
    else:
        print("NO")
                        

Measured memory_bytes: 7800
## input
N = int(input())
An_list = list( map(int, input().split()) )

## define
class ColorRank():
    def __init__(self, color, low, high):
        self.color = color
        self.low = low
        self.high = high
        self.cnt = 0

rate_list = [ ColorRank( "hai", 1, 399 )
             ,ColorRank( "cha", 400, 799 )
             ,ColorRank( "midori", 800, 1199 )
             ,ColorRank( "mizu", 1200, 1599 )
             ,ColorRank( "ao", 1600, 1999 )
             ,ColorRank( "ki", 2000, 2399 )
             ,ColorRank( "daidai", 2400, 2799 )
             ,ColorRank( "aka", 2800, 3199 )
             ,ColorRank( "top", 3200, 4800 )
             ]

## main
for an in An_list:
    for i,rate in enumerate( rate_list ):
        if rate.low <= an <= rate.high:
            rate_list[i].cnt += 1
            break

rateN = len([ color_rank for color_rank in rate_list if color_rank.cnt > 0 and color_rank.color != "top" ])
N_min = 1 if rateN == 0 and rate_list[8].cnt > 0 else 0
N_max = rate_list[8].cnt if rate_list[8].cnt > 0 else 0
rateN_min = rateN + N_min
rateN_max = rateN + N_max
print( ' '.join( [ str(rateN_min), str(rateN_max) ] ) )

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    string s,t;
    cin >>s >>t;
    ll ans = 0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)==t.at(i))ans++;
    }
    cout<<ans<<endl;
}
    



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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};



int main(){
  
  vector<vector<int>> v(3,vector<int>(3,0));
  REP(i,3)REP(j,3)cin >> v[i][j];
  vector<int> b(3);
  REP(i,3)b[i] = v[0][i];
  bool flag = true;
  for(int i = 1;i < 3;i++){
      if(v[i][0] - b[0] != v[i][1] - b[1])flag = false;
      if(v[i][2] - b[2] != v[i][1] - b[1])flag = false;
      if(v[i][1] - b[1] != v[i][2] - b[2])flag = false;
  }
  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;


  


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
    int i;
    char S[101];
    scanf("%s",S);
 
    for(i=0;S[i]!='\0';i++){
        
       
    }
    printf("%c%d%c",S[0],i-2,S[i-1]);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll MOD = 1e9+7;

ll ncr[2005][2005];

ll comb(ll n,ll k){
  ll m,c,kk,nmk,ii;
  m=1;
  kk=1;
  nmk=1;
  c=1;
  for(ii=n;ii>=1;ii--){
    m *= ii;
  }
  for(ii=k;ii>=1;ii--){
    kk *= ii;
  }
  for(ii=n-k;ii>=1;ii--){
    nmk *= ii;
  }

  c = kk*nmk;
  return m/c;
}

int main(){
  ll n,k,n1,k1,n2,k2;
  cin >> n >> k;

  vector<ll> ret;
  ret.resize(k);

  memset(ncr,0,sizeof(ncr));
  
  ncr[1][1] = 1;

  ncr[2][1] = 1;
  ncr[2][2] = 2;
  ncr[2][3] = 1;

  int ii,jj;
  ncr[0][0] = 1;
  for(ii=1;ii<=2000;ii++){

    ncr[ii][0] = 1;
    
    for(jj=1;jj<=ii+1;jj++){

      //ncr[ii][jj] = (ncr[ii-1][jj-1] + ncr[ii-1][jj]) % MOD;
      ncr[ii][jj] = (ncr[ii-1][jj-1] + ncr[ii-1][jj]) % MOD;
      //printf("ii=%4d jj=%4d ncr=%4d ncr=%d\n",ii,jj,ncr[ii-1][jj-1],ncr[ii-1][jj]);
      //printf("ii=%4d jj=%4d ncr=%4d\n",ii,jj,ncr[ii][jj]);
      
    }

  }

  
  for(ii=1;ii<=k;ii++){
    n1 = n - k + 1;
    k1 = ii;

    n2 = k -1;
    k2 = ii -1;

//    if(n1<k1 || n2 <k2){
//      ret[ii-1] = 0;
//    }
//    else{
    ret[ii-1] = (ncr[n1][k1] % MOD) * (ncr[n2][k2] %MOD ) % MOD;//comb(n1,k1)* comb(n2,k2);
      //    }
//    cout << "n1:" << n1 << "  k1:" << k1;
//    cout << "  n2:" << n2 << "  k2:" << k2;
//    cout << "  n1 k1:" << ncr[n1][k1+1] << "  n2 k2:" << ncr[n2][k2+1] << endl;;
    //cout << "n1 k1:" << comb(n1,k1) << "n2 k2:" << comb(n2,k2) << endl;;
    //cout << "n-k+ii-1:" << n-k+ii << "ii" << ii << endl;
    
  }

  for(ii=1;ii<=k;ii++){
    cout << ret[ii-1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll r, g, b, n;
string s;
void calc(int i){
	if(s[i]=='R') r++;
    else if(s[i]=='G') g++;
    else b++;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;
    r=g=b=0;
    for(int i=0;i<n;i++)calc(i);
    ll ans = r*g*b;
    for(int i=0;i<n;i++){
    	for(int k=i+2;k<n;k+=2){
    		r=g=b=0;
    		int j = (i+k)/2;
    		calc(i),calc(j),calc(k);
    	    ans -= r*g*b;
    	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
// AOJ 2662: Soccer
// 2018.1.3 bal4u@uu

#include <stdio.h>
#include <math.h>

int f[101], a[101], t[101], x[101], y[101];
int lmax[2], tmin[2];

int main()
{
	int n, i, d;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d%d%d%d%d", f+i, a+i, t+i, x+i, y+i);
 
	lmax[0] = lmax[1] = -1;
    for (i = 1; i < n; i++) if (t[i] == t[i-1] && a[i] != a[i-1]) {
		d = (x[i]-x[i-1])*(x[i]-x[i-1]) + (y[i]-y[i-1])*(y[i]-y[i-1]);
		if (d > lmax[t[i]]) lmax[t[i]] = d, tmin[t[i]] = f[i]-f[i-1];
		else if (d == lmax[t[i]]) {
			if (tmin[t[i]] > f[i]-f[i-1]) tmin[t[i]] = f[i]-f[i-1];
		}
    }

    for (i = 0; i < 2; i++) {
		if (lmax[i] < 0) puts("-1 -1");
        else printf("%.8lf %.8lf\n", sqrt(lmax[i]), tmin[i]/60.0);
    }
	return 0;
}



Measured memory_bytes: 1824
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>
#include <functional>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

int main(void)
{
	int n;
	vector<int> arr;
	vector<int> dis;
	cin >> n;
	int stk;
	for (int i = 0; i < n; i++) {
		cin >> stk;
		arr.push_back(stk);
		dis.push_back(stk - 1 - i);
	}
	sort(dis.begin(), dis.end());
	lli total = 0;
	int b = n % 2 == 0 ? dis[n / 2] : dis[(n - 1) / 2];
	for (int i = 1; i <= n; i++) {
		total += abs(arr[i - 1] - b - i);
	}
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 2036
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    REP(i,n)cin >> a[i];
    vector<ll>b(n);
    SORT(a);
    if(n%2){
        int left = 0;
        int right = n-1;
        FOR(i,1,n-1){
            if(i%2==0){
                b[i] = a[left];
                left++;
            }else{
                b[i] = a[right];
                right--;
            }
        }
        b[0] = a[left];
        b[n-1] = a[right];

        ll answer = 0;
        REP(i,n-1){
            answer+=llabs(b[i]-b[i+1]);
        }

        left = 0;
        right = n-1;

        FOR(i,1,n-1){
            if(i%2){
                b[i] = a[left];
                left++;
            }else{
                b[i] = a[right];
                right--;
            }
        }
        b[0] = a[left];
        b[n-1] = a[right];

        ll answer2 = 0;
        REP(i,n-1){
            answer2+=llabs(b[i]-b[i+1]);
        }
        cout << max(answer,answer2) << endl;
    }else{
        int left = 0;
        int right = n-1;
        FOR(i,1,n-1){
            if(i%2==0){
                b[i] = a[left];
                left++;
            }else{
                b[i] = a[right];
                right--;
            }
        }
        b[0] = a[left];
        b[n-1] = a[right];

        ll answer = 0;
        REP(i,n-1){
            answer+=llabs(b[i]-b[i+1]);
        }
        cout << answer << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4812
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<cstring>    //for memset
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define lli                      int long long
#define ull                      unsigned long long
#define ld                       long double
#define pi                       acos(-1)
#define pb                       push_back
#define pbk                      pop_back
#define mp                       make_pair
#define ff                       first
#define ss                       second
#define pii                      pair<int,int>
#define gcd(a,b)                 __gcd(a,b)
#define lcm(a,b)                (a/gcd(a,b))*b
#define READ                     freopen("in.txt","r",stdin);
#define WRITE                    freopen("outer.txt","w",stdout);
#define sort(t)                  sort(t.begin(),t.end())
#define mem(a,b)                 memset(a,b,sizeof a)
#define TEST_CASE(t)             for(int z=1;z<=t;z++)
#define PRINT_CASE               printf("Case %d: ",z)
#define LINE_PRINT_CASE          printf("Case %d:\n",z)
#define ordered_set              tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sf                       scanf
#define pf                       printf
#define dist(ax,ay,bx,by)        sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define EQUAL_RANGE(set)    pair<set<int>::const_iterator,set<int>::const_iterator> ret; ret=myset.equal_range(30);
#define MX                       2005
#define inf                      10000000000000000+7
#define Mod                        1000000007
#define MINI                     -1000000003
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move

//int kx[]={+2,+2,-2,-2,+1,+1,-1,-1};     //Knights move
//int ky[]={+1,-1,+1,-1,+2,-2,+2,-2};     //Knights move


//#define for(i,a,n)    for(int i=a;i<n;i++)
//it=myset.find(20);
//int a[8]= {0,0,-1,1,-1,1,-1,1};
//int b[8]= {-1,1,0,0,-1,1,1  ,-1};

lli c[MX][MX];

void dp()
{
  for(int i=0;i<2005;i++)
  {
      for(int j=0;j<=i;j++)
      {
          if(i==0 || j==i) c[i][j]=1;
          else c[i][j]=(c[i-1][j-1]+c[i-1][j])%Mod;
      }
  }
}

int main()
{
    //WRITE
    lli n,k,i,j;
    dp();
    cin>>n>>k;
    for(i=1;i<=k;i++)
    {
        lli h=(c[n-k+1][i]*c[k-1][i-1])%Mod;
        h=(h+Mod)%Mod;
        cout<<h<<endl;
    }
    return 0;
}



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

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	vector<bool> row(h, false), col(w, false);
	for(int i=0; i < h; i++)
		cin >> s.at(i);
	for(int i=0; i < h; i++) {
		for(int j=0; j < w; j++) {
			if(s.at(i).at(j) == '#') {
				row.at(i) = true;
				col.at(j) = true;
			}
		}
	}

	for(int i=0; i < h; i++) {
		if(row.at(i)) {
			for(int j=0; j < w; j++) {
				if(col.at(j))
					cout << s.at(i).at(j);
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 256