akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

ll r, c;

ll f(ll x, ll y) {
  if (y == 0) return x;
  if (x == r) return r + y;
  if (y == c) return r + c + (r - x);
  if (x == 0) return r + c + r + (c - y);
  return -1;
}

void solve(ll R, ll C, ll N, vector<vector<ll>> x, vector<vector<ll>> y) {
  r = R, c = C;
  vector<pair<ll,int>> l;
  REP(i,N) {
    ll a = f(x[i][0], y[i][0]), b = f(x[i][1], y[i][1]);
    if (a != -1 && b != -1) {
      l.emplace_back(a, i);
      l.emplace_back(b, i);
    }
  }
  sort(ALL(l));
  vector<int> st;
  for (auto p: l) {
    if (!st.empty() && st.back() == p.second) st.pop_back();
    else st.push_back(p.second);
  }
  cout << (st.empty()) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	ll R;
	ll C;
	scanf("%lld", &R);
	scanf("%lld", &C);
	scanf("%lld", &N);
	vector<vector<ll>> y(N-1+1,vector<ll>(2-1+1));
	vector<vector<ll>> x(N-1+1,vector<ll>(2-1+1));
	for (int i = 0 ; i <= N-1 ; i++) {
	  for (int j = 0 ; j <= 2-1 ; j++) {
	    scanf("%lld", &x[i][j]);
	    scanf("%lld", &y[i][j]);
	  }
	}
	solve(R, C, N, x, y);
	return 0;
}


Measured memory_bytes: 28272
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();

        String ans =  "No";
        for(int i=0;i<=k;i++){
            int B = b;
            for(int count=0; count<i;count++){
                B = B*2;
            }
            for(int j=0;j<=k-i;j++){
                int C = c;
                for(int count=0; count<j;count++){
                    C = C*2;
                }
                if(a < B && B < C){
                    ans = "Yes";
                }
            }
        }
        System.out.println(ans);
    }
}   

Measured memory_bytes: 35792
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int c = sc.nextInt();
		int[][] list = new int [100001][c];

		int max = 0;
		for(int i = 0; i < n; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int ch = sc.nextInt();

			int j = 0;
			for(j = s; j <= t; j++) {
				list[j][ch-1] = 1;
			}
			max = Math.max(max, j-1);
		}

		int ans = 0;
		for(int i = 0; i <= max; i++) {
			int num = 0;
			for(int j = 0; j < c; j++) {
				if(list[i][j] == 1)
					num++;
			}
			ans = Math.max(ans, num);
		}
		System.out.println(ans);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


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

using namespace std;

typedef long long ll;

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

int n,i,hit=0;
cin>>n;
int arr[n+1];
int check[n+1]={0};
for(i=1;i<=n;i++)
{
  cin>>arr[i];
}

for(i=1;i<=n;i++)
{
  if(check[arr[i]]!=1)
  { 
  if(arr[i]>i-hit)
  {
     hit++;
  } 
  else check[arr[i]]++;   // to check reptition for those jinka future me chance h bane rehne ka.
  }
  else hit++;
}

if(hit>=n) cout<<-1<<"\n";
else cout<<hit<<"\n";
return 0;
}
     


    

    

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

using namespace std;
typedef long long ll;
int main() {
  int N, K; cin>>N>>K;
  vector<ll> h(N), dp(N, 0);
  for(int i = 0; i < N; i++) cin>>h[i];
  for(int i = 1; i < N; i++) {
    dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    for(int k = 2; k <= K; k++) {
      if(i-k >= 0) {
        dp[i] = min(dp[i], dp[i-k] + abs(h[i] - h[i-k]));
      }
    }
  }
  cout << dp[N-1] << endl;
  return 0;
}


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

int n;
bool b[100010],a[100010];

int main()
{
	ios::sync_with_stdio(false);
    cin>>n;
	for(int i=1;i<=n;i++){
		char c;
		cin>>c;
		if(c=='o') b[i]=true;
	}
	for(int k=0;k<=1;k++){
		for(int i=0;i<=1;i++){
			a[1]=k;a[2]=i;
			for(int j=2;j<n;j++){
				if(b[j]) a[j+1]=a[j-1];
				else a[j+1]=!a[j-1];
				if(!a[j]) a[j+1]^=1;
			}
			if(((a[1]==b[1]&&a[2]==a[n])||(a[1]!=b[1]&&a[2]!=a[n]))&&((a[n]==b[n]&&a[1]==a[n-1])||(a[n]!=b[n]&&a[1]!=a[n-1]))){
				for(int j=1;j<=n;j++){
					if(a[j]) cout<<"S";
					else cout<<"W";
				}
				cout<<endl;
				return 0;
			}
			/*for(int j=1;j<=n;j++){
					if(a[j]) cout<<"S";
					else cout<<"W";
				}
				cout<<endl;*/
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 512
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	mod := int(1e+9) + 7
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	ans := 1
	n := N - 1
	set := make(map[int]int)
	if N%2 == 0 {
		for i := 0; i < N; i++ {
			set[A[i]]++
		}
		ok := true
		for i := 1; i <= n; i += 2 {
			if set[i] != 2 {
				ok = false
				break
			}
			ans *= 2
			ans %= mod
		}
		if !ok {
			ans = 0
		}
	} else {
		for i := 0; i < N; i++ {
			set[A[i]]++
		}
		ok := true
		for i := 0; i <= n; i += 2 {
			if i == 0 {
				if set[i] != 1 {
					ok = false
					break
				}
			} else {
				if set[i] != 2 {
					ok = false
					break
				}
				ans *= 2
				ans %= mod
			}
		}
		if !ok {
			ans = 0
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>

using namespace std;

template<typename T> 
void show(T a){
  for(auto i : a){ cout << i << " "; }
  cout << endl;
}
template<typename T> 
void showmatrix(T a){
  for(auto j: a){for(auto i : j){ cout << i; }cout << endl;}
  cout << endl;
}


int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  if(m <= 1) {cout << "0" << endl; return 0;}
  if(n >= m) {cout << "0" << endl; return 0;}
  for(int& i : v){
    cin >> i;
  }
  sort(v.begin(), v.end());
  int start = *v.begin();
  int end = *v.rbegin();
  int length = end - start;
  
  vector<int> lenlist;
  for(int i = 1; i < m; i++){
    lenlist.push_back(v[i]-v[i-1]);
  }
  sort(lenlist.begin(), lenlist.end());
  
  for(int i = m-1; i >=m-n; i--){
    length -= lenlist[i];
  }
  cout << length << endl;

}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*
    int t;
    cin>>t;
    while(t--)
    {
        
    }*/
    int d,s,t;
    
    cin>>d>>t>>s;
    float time=(d*1.00)/(s);
  //  cout<<time<<"\n";
    if(t>=time)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;

int n;
vint par;
vint depth;

void init (int n) {
    rep(i,n) {
        par[i] = i;
        depth[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
    return 0;
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (depth[x] < depth[y]) par[x] = y;
    else {
        par[y] = x;
        if (depth[x] == depth[y]) depth[x]++;
    }
}

bool same(int x, int y) {return find(x) == find(y);};

int main() {
    int q;
    cin >> n >> q;
    par.resize(n); depth.resize(n);
    init(n);
    rep(i,q) {
        int a, b, c;
        cin >> a >> b >> c;
        if (a == 0) unite(b,c);
        else {
            if (same(b,c)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3192
sx, sy, tx, ty = map(int, input().split())

sx_list = [sx, sx+1, sx, sx-1]
sy_list = [sy+1, sy, sy-1, sy]
tx_list = [tx-1, tx, tx+1, tx]
ty_list = [ty, ty-1, ty, ty+1]


U1 = ty_list[0]-sy_list[0]+1
R1 = tx_list[0]-sx_list[0]+1
D1 = ty_list[1]-sy_list[1]+1
L1 = tx_list[1]-sx_list[1]+1

D2 = 1
R2 = tx_list[2]-sx_list[2]
U2 = ty_list[2]-sy_list[2]
L2 = 1

U3 = 1
L3 = tx_list[3]-sx_list[3]
D3 = ty_list[3]-sy_list[3]
R3 = 1

ans = str()

for i in range(U1):
    ans += 'U'
for i in range(R1):
    ans += 'R'
for i in range(D1):
    ans += 'D'
for i in range(L1):
    ans += 'L'
    
for i in range(D2):
    ans += 'D'
for i in range(R2):
    ans += 'R'
for i in range(U2):
    ans += 'U'
for i in range(L2):
    ans += 'L'
    
for i in range(U3):
    ans += 'U'
for i in range(L3):
    ans += 'L'
for i in range(D3):
    ans += 'D'
for i in range(R3):
    ans += 'R'

print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
long long a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
int main()
{
	cin>>a>>b;
	if((a%3==0)||(b%3==0)||((a+b)%3==0))
	cout<<"Possible"<<endl;
	else 
	cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
#define MOD 1000000007
typedef long long ll;

int pow(int a, int n) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = 1LL * res * a % MOD;
    a = 1LL * a * a % MOD;
    n >>= 1;
  }
  return res;
}

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

  map<int, int> d;
  for (int i = 0; i < n; i++) {
    int x = a[i], p = 0, c = 0;
    for (int j = 2; j*j <= a[i]; j++) {
      if (x % j == 0) {
        if (j == p) c++;
        else {
          if (p) d[p] = d.count(p) ? max(d[p], c) : c;
          p = j;
          c = 1;
        }
        x /= j;
        j--;
      }
    }
    if(p) d[p] = d.count(p) ? max(d[p], c) : c;
    if (x > 1) d[x] = d.count(x) ? max(d[x], 1) : 1;
  }

  ll lcm = 1;
  for (pair<int, int> p : d) {
    lcm = lcm * pow(p.first, p.second) % MOD;
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans = (ans + lcm * pow(a[i], MOD-2) % MOD) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

   

int main(){
lint N;
cin>>N;
lint x[N];
rep(i,N){
    cin>>x[i];
}
lint y[N];
lint j=0;
rep(i,N/2){
    if(N%2==1&&i==(N-1))break;
    y[i]=x[N-i-1-j];
    y[N-i-1]=x[N-i-2-j];
  j++;
}
if(N%2==1)y[N/2]=x[0];
rep(i,N){
    cout<<y[i]<<" ";
}
}


Measured memory_bytes: 5248
import java.util.Scanner;

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

		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());

		int[][] c = new int[10][10];
		int[] a = new int[10];

		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				c[i][j] = Integer.parseInt(sc.next());
			}
		}

		int b;
		for (int i = 0; i < h * w; i++) {
			b = Integer.parseInt(sc.next());
			if (b != -1)
				a[b]++;
		}

		for (int k = 0; k < 10; k++) {
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < 10; i++) {
			ans += a[i] * c[i][1];
		}

		System.out.println(ans);

	}

}


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

int main() {
  int n;
  cin>>n;
  vector<int> s(n);
  rep(i,n) cin>>s[i];
  int min=250000,counter=0;
  rep(i,n) {
    if (i==0) {
      min=s[i];
      counter++;
    }
    else if (s[i]<min) {
      min=s[i];
      counter++;
    }
  }
  cout<<counter<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;

struct pt {
   int c, x, y;
};

int c[4][4][4], N;
bool s[100];

int check(int card, int x, int y) {
	int i;

   for (i=0; i<N; i++) if (s[c[card][x][i]] == false) break;
	if (i == N) return x;

   for (i=0; i<N; i++) if (s[c[card][i][y]] == false) break;
	if (i == N) return N + y;

	if (x == y) {
	   for (i=0; i<N; i++) if (s[c[card][i][i]] == false) break;
		if (i == N) return 2*N;
	}

	if (N-1-x == y) {
		for (i=0; i<N; i++) if (s[c[card][N-1-i][i]] == false) break;
		if (i == N) return 2*N+1;
	}
	return -1;
}

int main() {

int C, i, j, k, S, tmp, cur, BESTS, D, tmpi, d[4];
bool num[100], flag;
vector<int> v;
vector<pt> pos[100];
pt tmppt;

srand(time(0));

cin >> C;
cin >> N;

do {

for (i=0; i<100; i++) pos[i].clear();
memset(num, false, sizeof(num)); v.clear();
for (k=0; k<C; k++) {
   for (i=0; i<N; i++) {
		for (j=0; j<N; j++) {
			cin >> c[k][i][j];
			tmppt.c = k; tmppt.x = i; tmppt.y = j;
			pos[c[k][i][j]].push_back(tmppt);
			if (num[c[k][i][j]] == false) {
				num[c[k][i][j]] = true;
				v.push_back(c[k][i][j]);
			}
		}
	}
}

BESTS = 101;
for (j=0; j<10000; j++) {

	S = D = 0; flag = true;
	memset(s, false, sizeof(s));
	memset(d, -1, sizeof(d));

	while (1) {
   	tmp = rand()%(v.size()-S);
	   cur = v[tmp]; s[cur] = true;
   	tmpi = v[v.size()-S-1];
		v[v.size()-S-1] = v[tmp];
		v[tmp] = tmpi;
		S++;

//		cout << "salio el " << cur; for (i=0; i<C; i++) cout << ' ' << d[i]; cout << endl;

		for (i=0; i<pos[cur].size(); i++) {
			if (d[pos[cur][i].c] == -1) {
				d[pos[cur][i].c] = check(pos[cur][i].c, pos[cur][i].x, pos[cur][i].y);
				if (d[pos[cur][i].c] != -1) {
					D++;
					if (D == 4) break;
					else if (pos[cur][i].c > 0 && d[pos[cur][i].c-1] == -1) {flag = false; break;}
				}
			}
		}
		if (i<pos[cur].size()) {
			if (flag == true) {
				memset(s, false, sizeof(s)); S = 0;
//				cout << "SALIERON ";
//				for (i=0; i<C; i++) cout << d[i] << ' ';
//				cout << " CON LOS NUMEROS ";
				for (i=0; i<C; i++) {
					for (k=0; k<N; k++) {
						if (d[i] < N) tmp = c[i][d[i]][k];
						else if (d[i] < 2*N) tmp = c[i][k][d[i]-N];
						else if (d[i] == 2*N) tmp = c[i][k][k];
						else tmp = c[i][N-1-k][k];
						if (s[tmp] == false) {
//							cout << tmp << ' ';
							s[tmp] = true;
							S++;
						}
					}
				}
//				cout << endl;
				if (BESTS > S) BESTS = S;
			}
			break;
		}
	}
//	cout << "sacamos " << S << " numeros y el resultado fue " << flag << endl << endl;

}
if (BESTS < 101) cout << BESTS << endl;
else cout << 0 << endl;

cin >> C;
cin >> N;

} while (N!=0 || C!=0);

return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(ll *a,ll cnt,ll l,ll r)
{
	ll beg = 0,last = cnt-1 , mid , ans1 = -1;
	while(beg<=last)
	{
		mid = (beg + last)/2;
		if(a[mid]>=l)
		{
			ans1 = mid;
			last = mid - 1;
		}
		else
		{
			beg = mid + 1;
		}
	}
	
	beg = 0 ,last = cnt-1;
	ll ans2 = -1;
	while(beg<=last)
	{
		mid = (beg + last)/2;
		if(a[mid]>=r)
		{
			
			last = mid - 1;
		}
		else
		{
			ans2 = mid;
			beg = mid + 1;
		}
	}
	
	if(ans1==-1||ans2==-1)
	{
		cout<<0<<endl;
	}
	else
	{
		if(ans2>=ans1&&r-l>=1)
		{
			cout<<ans2-ans1+1<<endl;
		}
		else
		{
			cout<<0<<endl;
		}
		
	}
}
int main() {
	// your code goes here
	ll n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	ll hash[n];
	ll cnt = 0;
	for(ll i=0;i<n-1;i++)
	{
		if(s[i]=='A'&&s[i+1]=='C')
			hash[cnt++] = i;
	}
	while(q--)
	{
		ll l,r;
		cin>>l>>r;
		
		solve(hash,cnt,l-1,r-1);
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<int>> sum(20, vector<int>(n+1));
    rep(i,n){
        rep(j,20) if(a[i] >> j & 1) sum[j][i+1]++;
        rep(j,20) sum[j][i+1] += sum[j][i];
    }

    ll ans = 0;
    rep(i,n){
        int cnt = 1e9;
        rep(j,20){
            int idx = upper_bound(sum[j].begin(), sum[j].end(), sum[j][i]+1) - sum[j].begin();
            cnt = min(cnt, idx-1-i);
        }
        ans += cnt;
    }
    cout << ans << endl;
}

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

const int maxn=5005;

constexpr int mdn=1000000007;
struct mint{
    int v;
    inline operator int()const{return v;}
    inline mint(int v=0):v(v){}
    inline bool operator==(const mint&a)const{return v==a.v;}
    inline bool operator!=(const mint&a)const{return v!=a.v;}
    inline mint operator~ ()const{int r=1,b=v;for(int i=1;i<=(mdn-2);i<<=1){if((mdn-2)&i)r=static_cast<long long>(r)*static_cast<long long>(b)%mdn;b=static_cast<long long>(b)*static_cast<long long>(b)%mdn;}return mint(r);}
    inline mint operator- ()const{return mint(v==0?0:mdn-v);}
    inline mint operator+ (const mint&a)const{mint c(v+a.v);if(c.v>=mdn)c.v-=mdn;return c;}
    inline mint operator- (const mint&a)const{mint c(v-a.v);if(c.v<0)c.v+=mdn;return c;}
    inline mint operator* (const mint&a)const{long long c=static_cast<long long>(v)*static_cast<long long>(a.v);return mint(c%mdn);}
    inline mint operator/ (const mint&a)const{return (*this)*~a;}
    inline mint&operator++(){v++;if(v==mdn)v=0;return*this;}
    inline mint&operator--(){v--;if(v==-1)v=mdn-1;return*this;}
    inline mint&operator+=(const mint&a){v+=a.v;if(v>=mdn)v-=mdn;return*this;}
    inline mint&operator-=(const mint&a){v-=a.v;if(v<0)v+=mdn;return*this;}
    inline mint&operator*=(const mint&a){long long c=static_cast<long long>(v)*static_cast<long long>(a.v);v=c%mdn;return*this;}
    inline mint&operator/=(const mint&a){long long c=static_cast<long long>(v)*static_cast<long long>((~a).v);v=c%mdn;return*this;}
    friend istream&operator>>(istream&s,mint&a){s>>a.v;return s;}
    friend ostream&operator<<(ostream&s,const mint&a){s<<a.v;return s;}
};

int n;
vector<int> adj[maxn];
mint dp[maxn][maxn];
mint w[maxn],dp2[maxn];
int sz[maxn];

void dfs(int u,int f){
    dp[u][1]=1;
    sz[u]=1;
    for(int i=0;i<adj[u].size();i++){
        int v=adj[u][i];
        if(v!=f){
            dfs(v,u);
            for(int i=0;i<=sz[u]+sz[v];i++)dp2[i]=0;
            for(int i=1;i<=sz[u];i++){
                for(int j=0;j<=sz[v];j++){
                    dp2[i+j]+=dp[u][i]*dp[v][j];
                }
            }
            for(int i=1;i<=sz[u]+sz[v];i++)dp[u][i]=dp2[i];
            sz[u]+=sz[v];
        }
    }
    for(int i=2;i<=sz[u];i+=2)dp[u][0]-=dp[u][i]*w[i];
}
int main(){
    cin>>n;
    for(int i=1;i<n;i++){int u,v;cin>>u>>v;adj[u].push_back(v);adj[v].push_back(u);}
    w[0]=1;
    for(int i=2;i<=n;i+=2)w[i]=w[i-2]*(mint)(i-1);
    dfs(1,0);
    mint ans=-dp[1][0];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 98944
pub fn calc(num: u32) -> u32 {
    num + num*num + num*num*num
}

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

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

fn main() {
    let v = read_vec::<u32>();
    let num = v[0];
    let result = calc(num);
    println!("{}", result)
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=2e3 + 5;
const int M=1e9 + 7;

int a[N];
int b[N];
int cache[N][N];
int n,m;

int solve(int i, int j)
{
	if(i>n || j>m)
		return 0;
	int &ans = cache[i][j];
	if(ans!=-1)
		return ans;
	if(a[i] == b[j])
		ans = 1+ solve(i+1,j)+ solve(i,j+1);
	else
		ans = solve(i+1,j) + solve(i,j+1) - solve(i+1,j+1);
	ans += M;
	ans %= M;
	return ans;
}

int32_t main()
{
	IOS;
	cin >> n >> m;
	memset(cache,-1,sizeof(cache));
	rep(i,1,n)
	{
		cin >> a[i];
	}
	rep(i,1,m)
	{
		cin >> b[i];
	}
	int ans= solve(1,1);
	ans++;
	ans %= M;
	cout << ans << endl;
}


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

int a, b, c, d, cnt;
double e;
stack<int>S;

void dfs(double p, int q, int r) {
	if (p < -1e-12 || q < 0) {
		S.pop();
		return;
	}
	if (p <= 1e-12) {
		cnt++; S.pop(); return;
	}
	for (int i = S.top(); i <= c / r; i++) {
		S.push(i);
		dfs(p - (1.0 / i), q - 1, r * i);
	}
	S.pop();
	return;
}

int main() {
	while (true) {
		cnt = 0;
		cin >> a >> b >> c >> d;
		if (a == 0 && b == 0) { break; }
		e = 1.0 * a / b;
		S.push(1);
		dfs(e, d, 1);
		cout << cnt << endl;
		while (!S.empty()) { S.pop(); }
	}
}

Measured memory_bytes: 1200
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

int main()
{
  int N;
  std::cin >> N;
  std::vector<unsigned long long> A(N);
  for(auto& val: A)
    std::cin >> val;
  std::sort(A.begin(), A.end());
  auto f = [](unsigned long long x)
  {
    int ans = 0;
    x /= 10;
    while(x > 0)
    {
      x /= 10;
      ++ans;
    }
    return ans;
  };
  unsigned long long ans = A[0];
  bool flag = false;
  for(int i = 1; i < A.size(); ++i)
  {
    auto prev = ans;
    int d = f(ans);
    int e = f(A[i]);
    if(d + e > 18)
    {
      flag = true;
      break;
    }
    ans *= A[i];
    if(ans > 1000000000000000000 || ans / A[i] != prev)
    {
      flag = true;
      break;
    }
  }
  std::cout << (flag || ans > 1000000000000000000 ? -1 : (long long)ans) << std::endl;

  return 0;
}



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

using namespace std;

const int N = 10;

int dis[N][N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i <= 9; ++i) {
    for (int j = 0; j <= 9; ++j) {
      scanf("%d", &dis[i][j]);
    }
  }
  for (int k = 0; k <= 9; ++k) {
    for (int i = 0; i <= 9; ++i) {
      for (int j = 0; j <= 9; ++j) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      int x;
      scanf("%d", &x);
      if (x != -1 && x != 1) {
        res += dis[x][1];
      }
    }
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 384
/*
*
*   Bismillah Hir Rahman Nir Raheem
*   Name: Jaied Al Sabid
*
*/
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define pf printf
#define sf scanf
#define elif else if
#define unint unsigned int
#define sint short int
#define lint long long int
#define Size 1000000000

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    double x, res = 0;
    cin>>x;
    res = x*3.14159*2.0;
    cout<<setprecision(4)<<fixed<<res<<endl;
    return 0;
}


Measured memory_bytes: 3792
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.io.InputStreamReader;
import java.io.BufferedReader;
 
public class Main {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt(); // Scanner has functions to read ints, longs, strings, chars, etc.
        int k = in.nextInt();
        in.nextLine();

        int[] res = new int[2];  //res[0] is ac, res[1] is wa
        int[] arr = new int[n + 1];
        boolean[] ac = new boolean[n + 1];
        for (int i = 0; i < k; i++) {
            String s = in.nextLine();
            String[] str = s.split(" ");
            int index = Integer.parseInt(str[0]);
            boolean correct = str[1].equals("AC");
            if (correct && !ac[index]) {
                ac[index] = true;
                res[0]++;
                res[1] += arr[index];
                continue;
            }

            if (!correct && !ac[index]) {
                arr[index]++;
            }
        }

        System.out.println(res[0] + " " + res[1]);
    }

}


Measured memory_bytes: 96600
package main

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

/* ======IO====== */
var (
	InputString func() string
)

func init() {
	InputString = newInputString(os.Stdin)
}

func newInputString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("error scan")
		}
		return r.Text()
	}
}

func InputInt() int {
	return int(readInt64())
}
func InputInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func InputInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func InputInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(InputString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func InputIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = InputInt()
	}
	return b
}

func InputFloat64() float64 {
	return float64(inputFloat64())
}

func inputFloat64() float64 {
	f, err := strconv.ParseFloat(InputString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func InputFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = InputFloat64()
	}
	return b
}

func InputRuneSlice() []rune {
	return []rune(InputString())
}

/* ======Math====== */
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

/* ======Util====== */

func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic("strtoi error")
	} else {
		return i
	}
}

//
//type sortable [][]int
//
//func (s sortable) Len() int { return len(s) }
//
//func (s sortable) Less(i, j int) bool { return s[i][0] < s[j][0] }
//
//func (s sortable) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

func main() {
	N, K, Q := InputInt3()
	as := make([]int, N)
	//for i, _ := range as {
	//	as[i] = 0
	//}

	for i := 0; i < Q; i++ {
		a := InputInt()
		as[a-1] += 1
	}

	for _, x := range as {
		makeCount := Q - x
		if makeCount >= K {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}
	}
}


Measured memory_bytes: 3968
#include <algorithm>
#include <iostream>
#include <list>
#include <cstdint>
#include <cstring>
#include <vector>

using namespace std;

const int INF = 1001001001;

int main()
{
    int h, n;
    // int dp[10001];

    cin >> h >> n;
    vector<int> dp(h+1, INF);

    // for (int i = 0; i <= h; i++) {
    //     dp[i] = 2000000;
    // }

    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        for (int j = 0; j < h; j++) {
            int nj = min(j + a, h);
            dp[nj] = min(dp[j] + b, dp[nj]);
        }
    }
    cout << dp[h] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back
#define pp pair<int,int>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define int long long
#define mod 1000000007
string s;
int n;
int d;
int memo[10005][105][2];
int rec(int ind,int left,int rest)
{
	if(ind == n)
	{
		if(left == 0)  return 1;
		return 0;
	}
	if(memo[ind][left][rest]!=-1) return memo[ind][left][rest];
	int ans = 0;
	if(rest == 0)
	{
		rep(i,0,10)
		{
			ans += rec(ind+1,((left-i%d)%d+d)%d,0);
			ans %= mod;
		}
	}
	else
	{
		rep(i,0,s[ind]-'0')
		{
			
			ans += rec(ind+1,((left-i%d)%d+d)%d,0);
			ans %=mod;
		}
		ans += rec(ind+1,((left-(s[ind]-'0')%d)%d+d)%d,1);
		ans %=mod;
	}
	return memo[ind][left][rest] = ans;


}
 main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt.txt","r",stdin);
	// freopen("output.txt.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>s>>d;
	n = s.size();
	rep(i,0,n+1)
	{
		rep(j,0,d+1)
		{
			rep(k,0,2)
			memo[i][j][k] = -1;
		}

	}
	cout << (rec(0,0,1)+mod-1)%mod << endl;



}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    set<int> st;
    rep(i, N) {
        if (st.count(P[i] - 1)) {
            st.erase(st.find(P[i] - 1));
        }
        st.insert(P[i]);
    }

    int ct = 0;
    int mlen = 0;
    for (auto itr : st) {
        chmax(mlen, itr - ct);
        ct = itr;
    }

    cout << N - mlen << endl;
    return 0;
}

Measured memory_bytes: 13484
n, k = list(map(int, input().split()))

win_ratio = 0
nn = n
for saikoro in range(1,n+1):
    nn = saikoro
    coin_cnt = 0
    while True:
        if nn  >= k:
            break
        nn = nn * 2
        coin_cnt += 1
    win_ratio += (1/n) * (1/(pow(2, coin_cnt)))

print(win_ratio)

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

#define ll long long
#define mod 1000000007

using namespace std;



int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    ll r,g,b,k;
    cin>>r>>g>>b>>k;
    while(k--){
        if(b>g&&g>r){
            cout<<"Yes\n";return 0;
        }
        else if(g<=r)g*=2;
        else if(b<=g)b*=2;
    }
    if(b>g&&g>r){
        cout<<"Yes\n";return 0;
    }
    else cout<<"No\n";
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;

#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif
#define out(v) cout<<v<<"\n"
#define _overload3(_1,_2,_3,name,...) name
#define _all1(a) (a).begin(),(a).end()
#define _all2(a,n) (a),(a)+n
#define all(...) _overload3(__VA_ARGS__,42,_all2,_all1,)(__VA_ARGS__)
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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; }
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

  if (A > K) {
    cout << A-K << " " << B << endl;
  } else {
    cout << 0 << " " << max(0LL, B-(K-A)) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    long N=0,K,i;
    string S,T;
    cin >> S>>T;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i]){
            N++;
        }
    }
    cout << N;
}

Measured memory_bytes: 3864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;

int main(){
   int a,b,c;
   cin>>a>>b>>c;
   int sum=a+b+c;
   cout<<sum-max(max(a,b),c);
}

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

int main()
{
  while(1){
    int h,w;
    cin >> h >> w;
    if(h == 0 && w == 0) break;
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        int k = (i+j) % 2;
        if(k == 0) cout << "#";
        else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
import sys

N,K = [int(i) for i in input().split(" ")]

tmp = N

if N >= K:
    if N % K == 0:
        print(0)
        sys.exit()
    else:
        N = N % K

while True:
    #print(N)
    if abs(N - K) < tmp:
        N = abs(N - K)
    else:
        print(tmp)
        sys.exit()
    tmp = N
  

Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub, or_

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)



def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class SegmentTree:
    def __init__(self, array, operator, identity_element):
        _len = len(array)
        self.__op = operator
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [identity_element] * self.__size + \
            array + [identity_element] * (self.__size - _len)
        self.__ie = identity_element

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = operator(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__op(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def query(self, l, r):
        l += self.__size
        r += self.__size
        ret = self.__ie
        while l < r:
            if l & 1:
                ret = self.__op(ret, self.__tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.__op(ret, self.__tree[r])
            l //= 2
            r //= 2
        return ret


@mt
def slv(N, S, Q):
    st = SegmentTree([1 << (ord(c) - ord('a')) for c in S], or_, 0)

    for q in Q:
        if q[0] == '1':
            i = int(q[1]) - 1
            c = q[2]
            st.update(i, 1 << (ord(c) - ord('a')))
        if q[0] == '2':
            i = int(q[1]) - 1
            j = int(q[2]) - 1
            ans = 0
            v = st.query(i, j+1)
            for k in range(26):
                if (1 << k) & v:
                    ans += 1
            print(ans)
    # return ans


def main():
    N = read_int()
    S = read_str()
    Q = [read_str_n() for _ in range(read_int())]
    (slv(N, S, Q))

if __name__ == '__main__':
    main()


Measured memory_bytes: 55656
package main

import (
	"fmt"
)

func isPrime(N int) int{
	//H := false
	if N < 2 {
		return 0
	}
	if N == 2 {
		return 1
	} else if N % 2 == 0 {
		return 0
	}
	for i := 3; i*i <= N; i+=2 {
		if N % i == 0 {
			return 0
		}
	}
	return 1
}

func main(){
	var N, In int
	var count int
	fmt.Scanf("%d",&N);
	for i := 0; i < N; i++ {
		fmt.Scanf("%d",&In)

		count = isPrime(In) + count
	}

	
	fmt.Printf("%d\n",count)
}


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

namespace ConsoleApp20
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ABC = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int K = int.Parse(Console.ReadLine());
            Array.Sort(ABC);
            for (int i = 0; i < K; i++)
            {
                ABC[2] = ABC[2] * 2;
            }
            int ans = ABC[0] + ABC[1] + ABC[2];
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
 
struct Dsu {
  struct node_struct {
    int par, size;
    node_struct(int p, int s) : par(p), size(s) {}
    void merge(node_struct &b) {
      b.par = par;
      size += b.size;
    }
  };
  vector<node_struct> nodes;
  int compo = 0;
  Dsu(int n) {
    compo = n;
    nodes.reserve(n);
    for (int i = 0; i < n; ++i) nodes.emplace_back(i, 1);
  }
  int anc(int x) {
    while (x != nodes[x].par) x = nodes[x].par;
    return x;
  }
  bool unite(int x, int y) {
    int a = anc(x);
    int b = anc(y);
    if (a == b) return false;
    if (nodes[a].size < nodes[b].size) swap(a, b);
    nodes[a].merge(nodes[b]);
    --compo;
    return true;
  }
};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  long long M;
  int N, Q; cin >> N >> M >> Q;
  vector<tuple<int, int, int>> E;
  Dsu djs(N);
  for (int i = 0; i < Q; ++i) {
    int a, b, c; cin >> a >> b >> c;
    E.emplace_back(c, a, b);
  }
  sort(E.begin(), E.end());
  long long ub = 0; 
  for (auto T : E) {
    int c, a, b; tie(c, a, b) = T;
    if (c == 0) {
      ub += djs.unite(a, b);
    }
    else {
      if (djs.anc(a) == djs.anc(b)) cout << "No\n", exit(0);
    }
  }
  ub += 1ll * (djs.compo - 1) * djs.compo / 2;
  long long lb = N - 1 + (get<0>(E.back()));
  cout << (lb <= M and M <= ub ? "Yes\n" : "No\n");
}


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

map <string, int> mp;


int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, sum = 0; cin >> n;
	for(int i = 1; i <= n; i++) {
		string x; int d; cin >> x >> d;
		sum += d;
		mp[x] = sum;
	}
	string x; cin >> x;
	cout << sum - mp[x] << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int fibonach(int);
int recurFib(int);
 
int F[44];
 
int main()
{
  int n;
 
  scanf("%d", &n);
 
  printf("%d\n", fibonach(n));
 
  return 0;
}
 
int fibonach(int n)
{
  int i;
 
  for(i = 0; i <= n; i++)
    {
      F[i] = 0;
    }
 
  return recurFib(n);
}
 
  int recurFib(int n)
{
  if(n == 0 || n == 1)
    F[n] = 1;

 else if(F[n] == 0)
    F[n] = recurFib(n - 1) + recurFib(n - 2);
 
  return F[n];
}

Measured memory_bytes: 596
#include <cstdio>
#define N 50022
#define REP(i, a, b) for (int i = a; i < b; ++i)
bool p[N+1];
int main()
{
	REP(i, 0, N+1) p[i] = true;
	for (int i = 2; i * i <= N; ++i)
		if (p[i]) for (int j = 2 * i; j <= N; j += i)
			if (p[j]) p[j] = false;
	int n;
	while (scanf("%d", &n) == 1) {
		for (int i = n-1; i >= 2; --i) if (p[i]) { printf("%d ", i); break; }
		for (int i = n+1; i <= N; ++i) if (p[i]) { printf("%d\n", i); break; }
	}
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>

int main () {
  double r;
  double pi = 3.14159265;
  std::cin >> r;
  std::cout << std::fixed << std::setprecision(6) << r * r * M_PI << " " << 2 * r * M_PI << std::endl;
  return 0;
}


Measured memory_bytes: 3252
w, h, n = map(int, input().split())
points = [list(map(int, input().split())) for _ in range(n)]
_w = [0, w]
_h = [0, h]
for x, y, a in points:
    if a == 1 and _w[0] < x:
        _w[0] = x
    elif a == 2 and _w[1] > x:
        _w[1] = x
    elif a == 3 and _h[0] < y:
        _h[0] = y
    elif a == 4 and _h[1] > y:
        _h[1] = y
width = _w[1] - _w[0] if _w[1] - _w[0] > 0 else 0
height = _h[1] - _h[0] if _h[1] - _h[0] > 0 else 0
print(width * height)


Measured memory_bytes: 3064
// hi yhoam

#include <cstdio>
#include <algorithm>

using namespace std;

long long A[int(1e6)+5];

int main(){
    int N;
    scanf("%d",&N);
    for(int c = 0 ; c < N ; c++)
        scanf("%lld",&A[c]);
    sort(A, A+N);
    int sol = 1;
    long long run = A[0];
    for(int c = 1 ; c < N ; c++){
        if(run*2 >= A[c])
            sol++;
        else
            sol = 1;
        run += A[c];
        // printf("%d; %d %d\n",A[c],sol,run);
    }
    printf("%d\n", sol);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 200100
using namespace std;
double pb[N];
int main(){
	int n,d,x;
	double ans=0;
	scanf("%d%d%d",&n,&d,&x);
	for(int i=1;i<n;i++) pb[i]=pb[i-1]+0.5/(i+1);
	for(int i=0;i<n;i++){
		ans+=0.5*(d+i*2*x);
		ans+=0.5*(d+i*2*x+x);
		ans+=0.5*(pb[i]+pb[n-1-i])*(d+d+i*4*x+x);
	}
	printf("%.12f\n",ans);
	return 0;
}

Measured memory_bytes: 1792