akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
	public static long MOD = 998244353;
	public static void main(String[] args)throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int h= sc.nextInt();
		int w= sc.nextInt();
		int k =sc.nextInt();
		int board[][] = new int[h][w];
		for(int i=0; i<h; ++i) {
			String str = sc.next();
			for(int j=0; j<w; ++j) {
				if(str.charAt(j)=='#') {
					board[i][j] = 1;
				}else{
					board[i][j] = 0;
				}
			}
		}
		int ans = 0;
		for(int i=0; i<1<<h; ++i) {
			for(int j=0; j<1<<w; ++j) {
				int cnt = 0;
				for(int a=0; a<h; ++a) {
					if(((1<<a)&i)>=1)continue;
					for(int b=0; b<w; ++b) {
						if(((1<<b)&j)>=1)continue;
						cnt+=board[a][b];
					}
				}
				if(cnt==k) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		out.close();
	}
	static class FastIO {
		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;
		public FastIO(String fileName) throws IOException {
			dis = new FileInputStream(fileName);
		}
		public FastIO(InputStream is) throws IOException {
			dis = is;
		}
		int nextInt() throws IOException {
			int ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
 
			return (negative) ? -ret : ret;
		}
		long nextLong() throws IOException {
			long ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
			return (negative) ? -ret : ret;
		}
		byte nextByte() throws IOException {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}
		String next() throws IOException {
			StringBuffer ret = new StringBuffer();
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}
 
			return ret.toString();
		}
	}
}


Measured memory_bytes: 35896
N, Y = gets.split.map(&:to_i)

0.upto(Y / 10000) do |x|
  0.upto((Y - 10000 * x) / 5000) do |y|
    z = (Y - 10000 * x - 5000 * y) / 1000
    if x + y + z == N
      puts [x, y, z].join(' ')
      exit
    end
  end
end

puts '-1 -1 -1'

Measured memory_bytes: 1788
import math
c = 0
l = [0] * 500000
r = [0] * 500000


def merge(a, left, mid, right):
    global c
    n1 = mid - left
    n2 = right - mid
    for i in range(n1):
        l[i] = a[left + i]
    for i in range(n2):
        r[i] = a[mid + i]
    l[n1] = math.inf
    r[n2] = math.inf
    i, j = 0, 0
    cnt = 0
    for k in range(left, right):
        c += 1
        if l[i] <= r[j]:
            a[k] = l[i]
            i += 1
        else:
            a[k] = r[j]
            j += 1
            cnt += n1 - i
    return cnt


def mergeSort(a, left, right):
    cnt = 0
    if (left + 1) < right:
        mid = (left + right) // 2
        cnt += mergeSort(a, left, mid)
        cnt += mergeSort(a, mid, right)
        cnt += merge(a, left, mid, right)
    return cnt


n = int(input())
*s, = map(int, input().split())

print(mergeSort(s, 0, n))



Measured memory_bytes: 36776
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int res = 1;
		for (int i=0; i<N; i++) {
			res = Math.min(res*2, res+K);
		}
		System.out.println(res);
	}
}


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

int main()
{
    int N, M, X;

    int A[100];

    cin >> N >> M >> X;

    for (int j = 1; j <= M; j++)
    {
        cin >> A[j];
    }

    int c1 = 0;
    int c2 = 0;

    for (int j = 1; j <= M; j++)
    {
        if (A[j] > X) c1++;

        else c2++;
    }

    cout << min(c1, c2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include <cmath> 
using namespace std;
const int p=31;
const int m=1e9+9;
typedef long long ll;
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
//return res.empty() ? "0" : res;
/* istringstream ss(text);
    string s;
    while(ss>>s)*/
static auto speedup = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return nullptr;
}();

int main (){

    #ifndef ONLINE_JUDGE					
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    int t=60*h+m;
    double th= (double)(11*t)/2;
    cout<< fixed << setprecision(100)<<sqrt(a*a+b*b-2*a*b*cos(th*PI/180.0));

}


Measured memory_bytes: 4244
/// Updated! https://www.youtube.com/watch?v=U07_n9xGIlM
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int maxn = 2e5+100;

const ll inf = 1e18;

int main()
{
    ll n , k;
    vector < ll > arr;
    cin >> n >> k;
    for(int i = 1; i<=n; i++){
        ll k; cin >> k; arr.push_back(k);
    }
    sort(arr.begin() , arr.end());
    reverse(arr.begin(),arr.end());

    ll sum = 0;
    if(k >= n)cout << 0 << endl;
    else{
        for(int i = k; i<n; i++){
            sum += arr[i];
        }
        cout << sum << endl;
    }

    return 0;
}
/*



*/



Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string S, T;
    cin >> S >> T;

    vector<ll> s(26,0), t(26,0);
    rep(i, 0, S.size()) s[S[i]-'a']++;
    rep(i, 0, T.size()) t[T[i]-'a']++;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    rep(i, 0, s.size()){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 1000000007;

const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列を計算
long long PER(int n,int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return (fac[n] * finv[n-k]) % MOD;
}

//nが10**9でもkが小さかったら計算できるコンビネーション
long long COM_small_k(ll n,ll k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        k = min(k,n-k);
        ll res = 1;
        for(int i=1;i <= k;i++){
                res = (res * (n-i+1))%MOD;
        }
        
        res = (res * finv[k]) %MOD;
        return res;
}

//nが10**9でもrが小さかったら計算できる順列
long long PER_small_k(ll n,ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    ll res = 1;
    for(ll i=n;i>=n-k+1;i--){
        res = (res * i) % MOD;
    }
    return res;
}

/*最大２の3０乗までの数なら計算できる.繰り返し二乗法*/
long long modpow(long long a, long long b,long long mod){
        bitset<30> bit(b);
        string s = bit.to_string();
        long long ret = 1;
        for (int i = 0;i< s.length(); ++i){
                ret = (ret * ret) % mod;
                if(s[i]-'0') ret = (ret * a) % mod;
        }
        return ret;
}


/*繰り返し二乗法でxのmod逆元を取る*/
long long inverse(long long x,long long mod){
    return modpow(x,mod-2,mod);
}


int main(){
    COMinit();
    int n,a,b;
    cin >> n >> a >> b;
    ll res = (modpow(2,n,MOD) - 1 + MOD) % MOD;
    res = (res - COM_small_k(n,a) + MOD) % MOD;
    res = (res - COM_small_k(n,b) + MOD) % MOD;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 23680
#include<stdio.h>
int main(){	
	int a,b;	
	char s;	
	scanf("%d\n",&a);	
	scanf("%c",&s);	
	scanf("%d",&b);	
	if(s=='+')	  
	printf("%d\n",a+b);	
	else	  
	printf("%d\n",a-b);	
	return 0;
}


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

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin >> a >> b;

    if(a > b)
        cout << a - 1 << endl;
    else
        cout << a << endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;

int inf = (1 << 30);
int mod = 1e9;
long long long_inf = (1LL << 60);

int main(){

    string S;
    cin >> S;

    int ans_b = 0;
    string black = S;
    if(black.front() == '1'){
        black.front() = '0';
        ans_b++;
    }
    for(int i = 1; i < black.length(); i++){
        if(black[i - 1] == black[i]){
            if(black[i - 1] == '0') black[i] = '1';
            else black[i] = '0';
            ans_b++;
        }
    }

    int ans_w = 0;
    string white = S;
    if(white.front() == '0'){
        white.front() = '1';
        ans_w++;
    }
    for(int i = 1; i < white.length(); i++){
        if(white[i - 1] == white[i]){
            if(white[i - 1] == '0') white[i] = '1';
            else white[i] = '0';
            ans_w++;
        }
    }

    cout << min(ans_b, ans_w) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

typedef long long ll;


void go(string S, int n, char last) {
    if(S.length() == n) {
        cout << S << endl;
        return;
    }
    for(char l = 'a'; l <= last; l++) {
        go(S + l, n, last);
    }
    go(S + char(last + 1), n, char(last + 1));
}


int main() {
    int n;
    cin >> n;
    go("a", n, 'a');
    
    return 0;
}

Measured memory_bytes: 1536
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    string S;
    cin >> S;
    int month = 10 * (S[5] - '0') + S[6] - '0';
    if (month <= 4)
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
int main() {
  long long L,R; cin >>L>>R;
  long long kotae=L*R%2019;
  if(R-L==1){
    cout<<kotae<<endl;
    return 0;
  }else{
    for(long long i=L;i<=R;i++){
      for(long long j=L;j<=R;j++){
        if(i!=j){
          kotae=min(kotae,i*j%2019);
        }
        if(i*j%2019==0){
          cout<<kotae<<endl;
          return 0;
        }
      }
    }
    cout<<kotae<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
n, a, b=map(int,input().split())
i_sum = 0
result = 0

for i in range(1, n+1):
    i_length = len(str(i))
    i_list = list(str(i))
    
    for j in range(i_length):
        i_sum += int(i_list[j])

    if a <= i_sum and i_sum <= b:
        result += i
    i_sum = 0
    
print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;

int main() {
	long long int n, d=0, q, qu[550000] = {}, de[550000] = {}, leng = 0,goal,two=0,three=0;

	cin >> n;
	if (n == 3) { cout << "2 5 63"; return 0; }
	if (n == 4) { cout << "2 5 20 63"; return 0;}
	if (n == 5) { cout << "2 3 4 6 9"; return 0;}
	if (n == 6) { cout << "2 4 6 12 3 9"; return 0; }
	if (n <= 30000) {

		
		if (n % 3 == 0) { three += 6; two += n - 6; }
		if (n % 3 == 1) { three += 4; two += n - 4; }
		if (n % 3 == 2) { three += 2; two += n - 2; }
		while (two > 15000) {
			two -= 6;
			three += 6;
		}

		if (n==19999) { three = 5000; two =14999; }
		if (n == 19998) { three = 4998; two = 15000; }
		if (n == 19997) { three = 4998; two = 14999; }
		if (n == 19996) { three = 4996; two = 15000; }
		if (n == 19995) { three = 4996; two = 14999; }
		if (n == 19994) { three = 4994; two = 15000; }
		for (int i = 1; i <= two; i++) {
			cout << 2 * i << " ";
			
		}
		for (int i = 1; i <= three; i++) {
			cout << 6 * i - 3 << " ";
			
		}
		return 0;
	}

}

Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))

import math 

ans = a[0]
for i in range(1, n):
    ans = math .gcd(ans, a[i])

if ans!=1:
    #print(ans)
    print("not coprime")
    exit()
else:
    checked=[0]*(int(max(a))+1)
    #print(checked)
    for item in a:
        for j in range(1,int(item**0.5)+1):
            if item%j==0 and j*j<=item:
                if checked[j]==0:
                    if j!=1:
                        checked[j]+=1
                    
                    if j*j!=item:
                        if checked[item//j]==0:
                            checked[item//j]+=1
                        else:
                            #print(item,j,checked)
                            print("setwise coprime")
                            exit() 
                else:
                    #print(item,j,checked)
                    print("setwise coprime")
                    exit()
print("pairwise coprime")





Measured memory_bytes: 197884
n, k = map(int, input().split())
if k > n:
    if k % 2 == 0 and k // 2 <= n:
        print(1)
        quit()
    else:
        print(0)
        quit()
if k % 2 == 0:
    #ans = 1
    p1 = n // k
    p2 = (n + k // 2) // k
    ans = p1 ** 3 + p2 ** 3
    print(ans)
    quit()
p1 = n // k
print(p1 ** 3)


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

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

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};


int main() {
	int n;
	cin >> n;
	hei(llint) a(n),x(n);
	llint sum = 0;
	rep(i, 0, n) {
		cin >> a[i];
		sum += a[i];
	}
	llint s = 0;
	for (int i = 1; i < n;i+=2)s += a[i];
	x[0] = sum-(s*2);
	rep(i, 1, n)x[i] = (2 * a[i - 1]) - x[i - 1];
	rep(i, 0, n)cout << x[i] << endl;
	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
int main(void)
{
    int p[3],j[2];
    int i;
    int p_ans,j_ans=0,ans=0;

    p_ans = 2000;

    for(i = 0;i < 3; i++){
        scanf("%d",&p[i]);
        if(p_ans > p[i])p_ans = p[i];
        }
    for(i = 0;i < 2; i++)scanf("%d",&j[i]);
    if(j[0] > j[1]) j_ans = j[1];
    else j_ans = j[0];

    ans = p_ans + j_ans - 50;

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 592
from collections import deque
d = deque()
S = input()
d.append(S)
N = int(input())
direct = 0
for i in range(N):
  X = input().split()
  if len(X) == 1:
    direct = 1 - direct
  else:
    if (X[1] == "1" and direct == 0) or (X[1] == "2" and direct == 1):
      d.appendleft(X[2])
    else:
      d.append(X[2])
      
S = "".join(list(d))
print(S) if direct == 0 else print(S[::-1])

Measured memory_bytes: 6900
#include <iostream>
#include <string>
using namespace std;
int main()
{
	double w, x[10] = {91.00, 81.00, 75.00, 69.00, 64.00, 60.00, 57.00, 54.00, 51.00, 48.00};
	string r[11] = {"heavy", "light heavy", "middle", "light middle", "welter", "light welter", "light", "feather", "bantam", "fly", "light fly"};
	bool f = false;
	while (cin >> w)
	{
		if (cin.eof()) break;
		for (int i = 0; i < 10; i++)
		{
			if (w > x[i])
			{
				cout << r[i] << endl;
				f = true;
				break;
			}
		}
		if (!f) cout << r[10] << endl;
		f = false;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <deque>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 * 1e9 + 100;

vector<ll> pr, xr;
vector<ll> vec;
int main() {
    fastInp;

    ll n;
    cin >> n;
    pr.push_back(0);
    xr.push_back(0);

    vec.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> vec[i];
        pr.push_back(pr.back() + vec[i]);
        xr.push_back(xr.back() ^ vec[i]);
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        int l = i, r = n;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (pr[mid + 1] - pr[i] == (xr[mid + 1] ^ xr[i])) {
                l = mid;
            }
            else {
                r = mid;
            }
        }
        ans += (l - i + 1);
    }

    cout << ans;
    

    return 0;
}



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

int main() {
    const string endLine = "END OF INPUT";
    while (true) {
        string line;
        getline(cin, line);
        if (line == endLine) {
            break;
        }
        while (line.length() > 0) {
            int spacePos = (int) line.find_first_of(' ');
            if (spacePos == (int) string::npos) {
                cout << line.length();
                line.clear();
            } else {
                cout << spacePos;
                line.erase(0, spacePos + 1);
            }
        }
        cout << endl;
    }
}

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


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;
const int limit=50;

int n,m;
int a[limit],b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
    visited[v]=true;
    for(int v2=0;v2<n;v2++){
        if(graph[v][v2]==false)continue;
        if(visited[v2]==true)continue;
        dfs(v2);
    }
}

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

    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }

    int ans=0;

    for(int i=0;i<m;i++){
        //一旦非連結にする
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;

        for(int j=0;j<n;j++){
            visited[j]=false;
        }
        dfs(0);//グラフを全て辿ることで連結を確かめるdfs

        bool bridge=false;
        for(int j=0;j<n;j++){
            if(visited[j]==false)bridge=true;
        }
        if(bridge)ans+=1;

        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }

    cout<<ans<<endl;
 return 0;
}
/*
7 7
1 3
2 7
3 4
4 5
4 6
5 6
6 7

4

3 3
1 2
1 3
2 3

0


6 5
1 2
2 3
3 4
4 5
5 6

5

*/

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    ll N;
    cin >> N;
    ll last=N-1;
    if(last==0){
        P(0);
    }else if(last%2==0){
        P((1+last)*(last/2));
    }else{
        P((1+last)*(last/2)+((last/2)+1));
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;
const int inf = 1e9;
int main(){
    ll n, w, s = 0; 
    cin >> n >> w;
    vector<ll> val(n), wei(n);
    rep(i,n){
        cin >> wei[i] >> val[i];
        s += val[i];
    }
    
    vector<vector<ll> > dp(n+1, vector<ll>(s+1, inf));
    dp[0][0] = 0;
    rep(i,n)rep(j,s+1){
        dp[i+1][j] = dp[i][j];
        if(j >= val[i])dp[i+1][j] = min(dp[i+1][j], dp[i][j-val[i]] + wei[i]);
    }
    
    for(int i=s;i>=0;i--){
        //cout << dp[n][i] << " ";
        if(dp[n][i] <= w){
            cout << i << endl;
            return 0;
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 80256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    cout << (a1 + a2 + a3 >= 22 ? "bust" : "win") << endl;
}


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

namespace abc107_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nums = Console.ReadLine().Split(' ');
            int h = int.Parse(nums[0]);
            int w = int.Parse(nums[1]);

            char[,] grid = new char[100, 100];
            bool[] existBlackRow = new bool[100];
            bool[] existBlackCol = new bool[100];

            for(int i = 0; i < h; ++i)
            {
                string row = Console.ReadLine();

                for(int j = 0; j < w; ++j)
                {
                    grid[i, j] = row[j];
                }
            }

            for(int i = 0; i < h; ++i)
            {
                for (int j = 0; j < w; ++j)
                {
                    if (grid[i, j] == '#')
                    {
                        existBlackRow[i] = true;
                        existBlackCol[j] = true;
                    }
                }
            }

            for (int i = 0; i < h; ++i)
            {
                if (existBlackRow[i])
                {
                    for (int j = 0; j < w; ++j)
                    {
                        if(existBlackCol[j])
                        {
                            Console.Write(grid[i, j]);
                        }
                    }
                    Console.WriteLine();
                }
            }
        }
    }
}


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

#define ll long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const ll N = 1e6+5;
ll arr[N];

void build(){
	for(ll i = 1; i <= 105;i++){
		for(ll j = 1;j <= 105;j++){
			for(ll k = 1;k <= 105;k++){
				if(i*i+j*j+k*k+i*j+j*k+k*i <= N) arr[i*i+j*j+k*k+i*j+j*k+k*i]++;
			}
		}
	}
}

int main(){
	fastio
	ll n;
	cin >> n;
	build();
	for(ll i = 1;i <= n;i++){
		cout << arr[i] << "\n";
	}
}

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

int main(){
  int N;
  cin >> N;
  map<int,int> mp;
  rep(i,N) {
    int a;
    cin >> a;
    mp[a]++;
  }
  ll res = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    if(itr->second < itr->first) res += itr->second;
    else res += itr->second - itr->first;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

vector<ll> m(1001,0);

int main(){

    ll n,h,a,b,ans = 0; cin >> n >> h;
    vector<pair<ll,char>> v(2*n+1,make_pair(-1,'a'));

    rep(i,n){
        cin >> a >> b;

        v[i].first = a;
        v[i].second = 'a';

        v[i+n].first = b;
        v[i+n].second = 'b';
    }

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

    for(int i = v.size()-1; i >= 0; i --){
        //cout << v[i].second << " " << v[i].first<< endl;
        if(v[i].second == 'b'){
            ans ++;
            h -= v[i].first;
        }else{
            ans += (h/v[i].first) + ((h%v[i].first == 0)?0:1);
            break;
        }
        if(h <= 0) break;
    }

    cout << ans;


    return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  set<ll> ans;
  vector<ll> b(n);
  for(ll i=n;i>0;i--) {
    ll c=0;
    for(ll j=i*2;j<=n;j+=i) {
      c+=b[j-1];
    }
    b[i-1]= c%2!=a[i-1];
    if(b[i-1]) ans.insert(i);
  }
  cout << ans.size() << endl;
  for(auto p:ans) {
    if(*ans.begin()!=p) {
      cout << " ";
    }
    cout << p;
  }
  if(ans.size()) {
    cout << endl;
  }
}

Measured memory_bytes: 9856
a = list(map(int,input().split()))

left = 0
right = 0
for i, _a in enumerate(a):
    if i < 2:
        left = left + _a
    else:
        right = right + _a

if left > right:
    print('Left')
elif left < right:
    print('Right')
else:
    print('Balanced')


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (x/d >= k) {
        x = x - k*d;
        cout << x;
        return 0;
    }
    long long s = x / d;
    x = x % d;
    k = k - s;
    if (k % 2 == 0) {
        cout << x; 
    } else {
        cout << d - x; 
    }
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;

int main()
{
	while(1){
		int n;
		scanf("%d", &n);
		if(n==0) return 0;
		int w[300];
		for(int i=0; i<n; i++){
			scanf("%d", &w[i]);
		}
		if(n==1){
			printf("%d\n", 0);
			continue;
		}
		int ans[301][301];
		for(int i=0; i<=n; i++){
			ans[i][i]=0;
			if(i+1<=n) ans[i][i+1]=0;
		}
		for(int d=2; d<=n; d++){
			for(int i=0; i+d<=n; i++){
				ans[i][i+d]=ans[i+1][i+d];
				for(int j=i+1; j<i+d; j++){
					if(abs(w[i]-w[j])<=1 && 2*ans[i+1][j]==j-i-1){
						if(ans[i][i+d]<ans[i+1][j]+1+ans[j+1][i+d]) ans[i][i+d]=ans[i+1][j]+1+ans[j+1][i+d];
					}
				}
			}
		}
		printf("%d\n", 2*ans[0][n]);
	}
	return 0;
}


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

struct Interval {
  int start, slutt;
};
bool operator<(Interval a, Interval b) {
  return a.start < b.start;
}

Interval input[1000000];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  ll n,k,ans;
  ll h;
  cin >> h;
  ll yn=1;
  k=0;
  while(h>1){
    k+=yn;
    yn*=2;
    h=h/2;
  }

  cout<<yn+k<<endl;	  

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#define PI 3.141592653589793238462643383279


void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int gcd(int a, int b)
{
    int c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}
int main(void){
	int n, k;
	double ans=0.0;
	double temp=0.0;
	
	scanf("%d %d", &n, &k );
	
	for(int i=1; i<=n;i++){
		temp=(double)ceil( log2( (double)k / (double)i ) );
		if(temp<=0.0)	temp=0.0;
		
		ans += 1 / pow( 2.0, temp );
	}
	ans /= (double)n;
	
	printf("%1.11f", ans);
	
	return 0;
}


Measured memory_bytes: 128
N = int(input())
mod = pow(10,9)+7
S = []
A = [True]*(N+1)
A[0] = A[1] = False
for i in range(2,N+1):
    if A[i]:
        S.append(i)
        A[i::i] = [False]*(N//i)
B = [1]*(N+1)
for i in range(2,N+1):
    n = i
    for s in S:
        while n%s==0:
            B[s]+=1
            n//=s
ans = 1
for b in B:ans*=b
print(ans%mod)

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

int main(void)
{
    int N,M;
    int tmp;
    cin >> N >> M;
    map<int,int> mp;

    rep(i, N){
        mp[i] = 0;
    }
    rep(i,M){
        cin >> tmp;
        mp[tmp]++;
        cin >> tmp;
        mp[tmp]++;
    }

    rep(i,N){
        cout << mp[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    int a[3][3];
    int n;
    bool aflag[3][3];
    int flag = 0;
    string ans[] = {"No", "Yes"};
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin>>a[i][j];
            aflag[i][j] = false;
        }
    }
    cin>>n;
    int b[n];
    for (int i = 0; i < n; i++){
        cin>>b[i];
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 3; k++){
                if (b[i] == a[j][k]){
                    aflag[j][k] = true;
                }
            }
        }
    }

    for (int i = 0; i < 3; i++){
        //縦横
        if (aflag[i][0] && aflag[i][1] && aflag[i][2]){
            flag = 1;
        }
        if (aflag[0][i] && aflag[1][i] && aflag[2][i]){
            flag = 1;
        }
    }
    //斜め
    if (aflag[0][0] && aflag[1][1] && aflag[2][2]){
        flag = 1;
    }
    if (aflag[0][2] && aflag[1][1] && aflag[2][0]){
        flag = 1;
    }
    cout<<ans[flag]<<endl;
}

Measured memory_bytes: 256
import bisect
from collections import deque
N=int(input())

que=deque([-1])
for i in range(N):
    a=int(input())
    
    if que[0]<a:
        i=bisect.bisect_left(que, a)
        que[i-1]=a
    else:
        que.appendleft(a)

print(len(que))
#print(que)

Measured memory_bytes: 7284
class Node():
    def __init__(self, value):
        self.value = value
        self.parent = -1
        self.left = -1
        self.right = -1

def preorder(tree, root):
    if root == -1:
        pass
    else:
        print(' %d' % root, end='')
        preorder(tree, tree[root].left)
        preorder(tree, tree[root].right)

def inorder(tree, root):
    if root == -1:
        pass
    else:
        inorder(tree, tree[root].left)
        print(' %d' % root, end='')
        inorder(tree, tree[root].right)

def postorder(tree, root):
    if root == -1:
        pass
    else:
        postorder(tree, tree[root].left)
        postorder(tree, tree[root].right)
        print(' %d' % root, end='')

if __name__ == '__main__':
    n = int(input())
    tree = {}
    root = -1
    for _ in range(n):
        datas = [int(num) for num in input().split(' ')]
        nodeid = datas[0]
        if nodeid not in tree.keys():
            tree[nodeid] = Node(nodeid)
        tree[nodeid].left = left = int(datas[1])
        tree[nodeid].right = right = int(datas[2])
        if left != -1:
            if left not in tree.keys():
                tree[left] = Node(left)
            tree[left].parent = nodeid
        if right != -1:
            if right not in tree.keys():
                tree[right] = Node(right)
            tree[right].parent = nodeid

    for i in range(n):
        if tree[i].parent == -1:
            # this is root
            root = i
            break
            
    print('Preorder')
    preorder(tree, root)
    print()

    print('Inorder')
    inorder(tree, root)
    print()

    print('Postorder')
    postorder(tree, root)
    print()


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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define mset(a,x) memset(a,x,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define mp make_pair

string s;

int main() {
    cin >> s;
    int n = s.size();
    s += "???????????????";

    int i = 0;
    bool f = true;
    while(i < n){
        if(s[i] == 'd') {
            if(s.substr(i, 7) == "dreamer"){
                i += 7;
                if(s.substr(i, 4) == "aser"){
                    i += 4;
                }
                else if(s.substr(i, 3) == "ase"){
                    i += 3;
                }
            } else if(s.substr(i,5) == "dream"){
                i += 5;
            }
            else {
                f = false; break;
            }
        }
        else if(s[i] == 'e'){
            if(s.substr(i, 6) == "eraser"){
                i += 6;
            } else if(s.substr(i,5) == "erase"){
                i += 5;
            }
            else{
                f = false; break;
            }
        }
        else {
            f = false; break;
        }
    }

    cout << (f ? "YES" : "NO") << "\n";

    return 0;
}


Measured memory_bytes: 512
N=int(input())
a=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(1,N+1):
  S[i]=S[i-1]+a[i-1]
  
ans=float("Inf")
for i in range(1,N):
  tmp=abs(S[N]-S[i]*2)
  ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 24832
n = int(input())
lim = 10**18
ans,exc = 1,False
a = list(map(int,input().split()))
# print(a)
if 0 in a:
  print(0)
else:
  for x in a:
    ans *= x
    if ans > lim:
      exc = True
      print("-1")
      break
  if not exc:
    print(ans)

Measured memory_bytes: 21780
n=int(input())
x=list(map(float,input().split(' ')))
y=list(map(float,input().split(' ')))

l=[]
for i in range(n):
  if x[i]-y[i]>0:
    l.append(x[i]-y[i])
  else:
    l.append(y[i]-x[i])

D1=0
D2=0
D3=0
Dinf=max(l)

for i in range(n):
  D1+=l[i]
  D2+=l[i]**2
  D3+=l[i]**3
  
D2=D2**(1/2)
D3=D3**(1/3)

print(D1)
print(D2)
print(D3)
print(Dinf)



Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;


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

    vector<ll> a(3 * N);
    for(int i=0;i<3 * N;i++){
        cin >> a[i];
    }

    vector<ll> first(3 * N, -1);
    priority_queue<ll, vector<ll>, greater<ll>> first_que;
    ll s = 0;
    for(int i=0;i<3 * N;i++){
        first_que.push(a[i]);
        s += a[i];
        if(first_que.size() > N){
            s -= first_que.top();
            first_que.pop();
        }
        if(first_que.size() == N){
            first[i] = s;
        }
    }

    vector<ll> second(3 * N, -1);
    priority_queue<ll> second_que;
    s = 0;
    for(int i=3*N-1;i>=0;i--){
        second_que.push(a[i]);
        s += a[i];
        if(second_que.size() > N){
            s -= second_que.top();
            second_que.pop();
        }
        if(second_que.size() == N){
            second[i] = s;
        }
    }

    ll ans = -10000000000000000LL;
    for(int i=0;i<3*N-1;i++){
        if(first[i] != -1 && second[i+1] != -1){
            ans = max(ans, first[i] - second[i+1]);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9588
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

// 逆ポーランド記法で与えられた数式の計算結果を出力

 class Main {
	public static void cal(int i, int[] a,String op) {
		switch(op) {
		case "+" :
			a[i-1]=a[i-1]+a[i];
			a[i]=0;
			break;
		case "-" :
			a[i-1]=a[i-1]-a[i];
			a[i]=0;
			break;
		case "*" :
			a[i-1]=a[i-1]*a[i];
			a[i]=0;
			break;
		}
	}
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String op = null;
		int[] r = new int [100];
		int j = 0;
		String a = stdIn.nextLine();
		
		String[] copy = a.split(" ");
		for(int i = 0; i < copy.length;i++) {
			try {
				r[j] = Integer.parseInt(copy[i]);
				j++;
				
			}catch(NumberFormatException e) {
				op = copy[i];
				j--;
				cal(j, r, op);
			}
		}
		System.out.println(r[0]);
	}
}



Measured memory_bytes: 26216
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残すな
//数値計算 基本はdouble
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}   // 

ll f(ll n) {
	if (n % 2 == 0) return n / 2;
	else return 3 * n + 1;
}

int main() {
	int s; cin >> s;
	map<int, int> p;
	int a = s;
	p[a]++;
	int cnt = 1;
	while (1) {
		a = f(a);
		p[a]++;
		cnt++;
		if (p[a] == 2) {
			cout << cnt << endl;
			return 0;
		}
	}
}

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

int main(){
	// sengen
	string s;
	// nyuryoku
	cin >> s;
	// keisan
	for(int i=0;i<3;i++){
		if(s[i] == '1'){
			cout << '9';
		}else{
			cout << '1';
		}
	}
	// syutsuryoku
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0; i<N; i++) {
        cin >> H[i];
    }

    for(int i=N-1; i>=0; i--) {
        if(H[i-1] == H[i]+1) {
            H[i-1]--;
        } else if(H[i-1] > H[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
import Control.Monad (replicateM)
import Data.List (transpose)

main = do
    n <- readLn
    if n == 0 then return () else do
        input n >>= return . solve >>= output
        main

input :: Int -> IO ([Int],[Int])
input n = do
    lines <- replicateM n getLine
    let
        [as,bs] = transpose $ map (map read . words) lines
    return (as,bs)

output :: (Int,Int) -> IO ()
output (a,b) = putStrLn $ unwords $ map show [a,b]

solve :: ([Int],[Int]) -> (Int,Int)
solve (as,bs) = solve' as bs 0 0
    where
    solve' [] [] pa pb = (pa,pb)
    solve' (a:as) (b:bs) pa pb
        | a == b = solve' as bs (pa+a) (pb+b)
        | a < b  = solve' as bs pa (pb+a+b)
        | a > b  = solve' as bs (pa+a+b) pb

Measured memory_bytes: 9188
import Data.List (sort)
import Data.Char (toLower)

readIntLine :: IO ([Int])
readIntLine = do
    x <- getLine
    return $ map (read :: String -> Int) $ words x

main :: IO ()
main = do
    [n,k] <- readIntLine
    s <- getLine
    putStrLn $ lowered s k

lowered :: String -> Int -> String
lowered s k =
    let p1 = take (k-1) s
        p2 = toLower $ head $ drop (k-1) s
        p3 = drop k s
      in p1 ++ [p2] ++ p3


Measured memory_bytes: 508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_5_b
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = new string[2];
                str = Console.ReadLine().Split(' ');

                int i = int.Parse(str[0]);
                int n = int.Parse(str[1]);
                if (i == 0 && n == 0)
                {
                    break;
                }

                for (int c = 0; c < n; c++)
                {
                    Console.Write('#');
                }
                Console.Write("\n");
                for (int a = 2; a < i; a++)
                {
                    Console.Write('#');
                    for (int b = 2; b < n; b++)
                    {
                        Console.Write('.');
                    }
                    Console.Write('#');
                    Console.Write("\n");

                }  

                for (int c = 0; c < n; c++)
                {
                    Console.Write('#');
                }
                Console.Write("\n");
                Console.Write("\n");
            }
        }
    }
}



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

int lastStoneWeight(vector<int> &stones) {

	sort(stones.begin(), stones.end());
	while (1) {
		int dd = stones[stones.size() - 1] - stones[stones.size() - 2];
		stones.erase(stones.begin() + stones.size() - 1);
		stones.erase(stones.begin() + stones.size() - 2);
		stones.push_back(dd);
		if (stones.size() == 1)
			break;
		sort(stones.begin(), stones.end());

	}
	return stones[0];
}
int main() {
	int n, k;
	cin >> n >> k;
	set<int> ss;
	for (int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		int temp;
		for (int j = 0; j < d; ++j) {
			cin >> temp;
			ss.insert(temp);
		}

	}
	cout << n - ss.size();

}


Measured memory_bytes: 3608
s = input()

d = {}
for c in s:
    if c not in d:
        d[c] = 1
    else:
        d[c] += 1

for k, v in d.items():
    if v != 2:
        print('No')
        exit()

if len(d) == 2:
    print("Yes")
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int  INF= 1e9+5;
int main(){
	fastio();

 	int n;cin>>n;
 	
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int> dp(n);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
    	dp[i]=min(   dp[i-1]+abs(h[i]-h[i-1])   ,  dp[i-2]+abs(h[i]-h[i-2]) );
    	


    }
    cout<<dp[n-1]<<endl;





    return 0;

}
	

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
vector<pair<ii, int> > vl, vr;
int was[100000];

bool lsl (pair<ii, int> a, pair<ii, int> b) {
	re a.fi.se < b.fi.se;
}

bool lsr (pair<ii, int> a, pair<ii, int> b) {
	re a.fi.fi > b.fi.fi;
}

int get (int x, ii y) {
	if (y.se < x) re y.se;
	if (y.fi > x) re y.fi;
	re x;
}

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n; i++) {
		int l, r;
		scanf ("%d%d", &l, &r);
		vl.pb (mp (mp (l, r), i));
		vr.pb (mp (mp (l, r), i));
	}
	sort (all (vl), lsl);
	sort (all (vr), lsr);
	ll ans = 0;
	{
		memset (was, 0, sizeof (was));
		int pos = 0, i = 0, j = 0;
		ll cur = 0;
		while (true) {
			while (i < n && was[vl[i].se]) i++;
			int tmp = get (pos, vl[i].fi);
			if (i < n && tmp < pos) {
				cur += pos - tmp;
				pos = tmp;
				was[vl[i].se] = 1;
			}
			while (j < n && was[vr[j].se]) j++;
			tmp = get (pos, vr[j].fi);
			if (j < n) {
				cur += abs (pos - tmp);
				pos = tmp;
				was[vr[j].se] = 1;
			}
			if (i == n && j == n) break;
		}
		cur += abs (pos);
		ans = max (ans, cur);
	}
	{
		memset (was, 0, sizeof (was));
		int pos = 0, i = 0, j = 0;
		ll cur = 0;
		while (true) {
			while (j < n && was[vr[j].se]) j++;
			int tmp = get (pos, vr[j].fi);
			if (j < n && tmp > pos) {
				cur += tmp - pos;
				pos = tmp;
				was[vr[j].se] = 1;
			}
			while (i < n && was[vl[i].se]) i++;
			tmp = get (pos, vl[i].fi);
			if (i < n) {
				cur += abs (pos - tmp);
				pos = tmp;
				was[vl[i].se] = 1;
			}
			if (i == n && j == n) break;
		}
		cur += abs (pos);
		ans = max (ans, cur);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3244
#include<cstdio>
#include<iostream>
#include<cstring>

using namespace std;

int n;
int size=0;
int b[50001];

bool check(){
	for(int i=0;i<size;i++){
		if(b[i]!=i+1)return false;
	}
	return true;
}

void shif(int x){
	for(int i=x;i<size;i++){
		b[i]=b[i+1];
	}
	b[size]=0;
	size--;
}

int block(){
	size=n;
	for(int lo=0;lo<=10000;lo++){
		if(check())return lo;
		if(lo==10000)break;
		int cnt=0;
		for(int i=0;i<size;i++)b[i]--,cnt++;
		b[size]=cnt;
		size++;
		//for(int i=0;i<size;i++)printf("%d ",b[i]);
		//printf("\n");
		for(int i=0;i<size;i++){
			if(b[i]==0){
				shif(i);
				i--;
			}
		}
		//for(int i=0;i<size;i++)printf("%d ",b[i]);
		//printf("\n");
	}
	return -1;
}

int main(void){
	while(1){
		cin >> n;
		if(n==0)break;
		memset(b,0,sizeof(b));
		for(int i=0;i<n;i++)cin >> b[i];
		printf("%d\n",block());
	}
	
	return 0;
}

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

int main() {
	int a,b;
	cin >> a >> b;
	if(b == 1){
		cout << 0 << '\n';
		return 0;
	}
	int c = 0;
	int ans = 0;
	for(int i=0; i<=b; i++){
		if(i == 0){
			c += 1;
		}
		c += a - 1;
		ans += 1;
		if(c >= b){
			break;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256