akhauriyash/Code-Regression huggingface dataset:
// ABC155_B
#include <algorithm>
#include <bitset>  // static_cast<std::bitset<8>>
#include <cctype>  // std::isdigit()
#include <climits>  // INT_MIN
#include <cmath>
#include <cstring>  // std::memset
#include <functional>  // std::greater<T>()
#include <iomanip>
#include <iostream>
#include <iterator>
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <sstream>  // std::stringstream
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>  // std::swap()
#include <vector>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    // input(sunippets: inpv, inpn, inps)
    ll N;
    cin >> N;
    vector<ll> vec(N);
    rep(i, N) cin >> vec[i];
    
    // calculation
    rep(i, N) {
        if (vec[i]%2 == 0) {
            if (vec[i]%3 == 0 || vec[i]%5 == 0) {
                
            } else {
                cout << "DENIED" << "\n";
                return 0;
            }
        }
    }
    
    cout << "APPROVED" << "\n";
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            int a = int.Parse (str[0]);
            int b = int.Parse (str[1]);

            if (a > b)
            {
                Console.WriteLine ("a > b");
            }
            else if (a < b)
            {
                Console.WriteLine ("a < b");
            }
            else
            {
                Console.WriteLine ("a == b");
            }
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}


Measured memory_bytes: 15952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long n = in.nextLong();
			int a = (int)Math.sqrt(n);
			int b = 0;
			for (int i = a; i > 0; i--) {
				if (n % i == 0) {
					a = i;
					b = (int) (n / a);
					break;
				}
			}
			System.out.println(Math.max(String.valueOf(a).length(),String.valueOf(b).length()));

		}

	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 22868
s = 'AKIHABARA'

import itertools

A = []
for i in range(1, len(list(s))+1):
    B = itertools.combinations(s, i)
    for j in B:
        string = "".join(j)
        if 'K' in string and 'I' in string and 'H' in string and 'B' in string and 'R' in string:
            A.append(string)
if input() in A:
    print("YES")
else:
    print("NO")

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

#define rep(x, n) for(int i = x; i < (n); ++i)

using namespace std;
using ll = long long;

int main(void)
{
  int x[4], y[4];
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  x[2] = x[1] - (y[1] - y[0]);
  y[2] = y[1] + (x[1] - x[0]);
  x[3] = x[0] - (y[1] - y[0]);
  y[3] = y[0] + (x[1] - x[0]);
  rep(2, 4) cout << x[i] << " " << y[i] << " ";
  cout << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
double a,b,x;

double from_rad_to_dosu(double x){
  return x*180/M_PI;
}

double katamuki_syo(double kakudo){
  return a*a*(2*b-a*tan(kakudo))/2;
}

double katamuki_dai(double kakudo){
  return a*b*b/(2*tan(kakudo));
}

int main(){
  cin>>a>>b>>x;
  double ans=0,min=0,max=M_PI/2,kakudo,ze_gosa=1,so_gosa=1;
  while(ze_gosa>0.00000001||so_gosa>0.00000001){
    double tmp;
    kakudo=(min+max)/2;
    if(tan(kakudo)<b/a) tmp=katamuki_syo(kakudo);
    else tmp=katamuki_dai(kakudo);
    if(x<tmp) min=kakudo;
    else max=kakudo;
    ze_gosa=abs(tmp-x);
    so_gosa=abs((tmp-x)/x);
  }  
  cout<<fixed<<setprecision(12)<<from_rad_to_dosu(kakudo);
}

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

using namespace std;

const int N_ = int(1.1e5);

const int MOD = int(1e9) + 7;

struct modint {
  int v;
  int operator*() { return v; }
  modint(long long v_ = 0): v((v_ + MOD) % MOD) { }
  modint operator+ (modint m) {
    return modint(v + m.v);
  }
  modint operator+= (modint m) {
    return (*this) = (*this) + m;
  }
  modint operator- (modint m) {
    return modint(v - m.v);
  }
  modint operator-= (modint m) {
    return (*this) = (*this) - m;
  }
  modint operator* (modint m) {
    return modint((long long)v * m.v);
  }
};

int N, A[N_];

int freq[N_];
int target;

modint fac[N_], invfac[N_];

modint comb(int n, int r) {
  //printf(" > %d %d\n", n,r);
  if(r < 0 || r > n) return 0;
  return fac[n] * invfac[r] * invfac[n-r];
}

long long mypow (long long a, long long b) {
  long long ret = 1;
  while(b > 0) {
    if(b & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return ret;
}

int main() {
#ifdef IN_MY_COMPUTER
  freopen("d.in", "r", stdin);
#endif

  fac[0] = invfac[0] = 1;

  scanf("%d", &N);
  for(int i = 1; i <= N+1; i++) {
    scanf("%d", &A[i]);
    if(++freq[A[i]] == 2) {
      target = A[i];
    }
    fac[i] = fac[i-1] * i; 
    invfac[i] = invfac[i-1] * mypow(i, MOD - 2);
  }
  
  int x = 0, y = 0;
  for(int i = 1; i <= N+1; i++) {
    if(A[i] == target) {
      if(x == 0) x = i;
      else y = i;
    }
  }


  assert(x > 0 && y > 0);

  for(int k = 1; k <= N+1; k++) {
    modint ans = 0;

    ans += comb(N-1, k); // no target

    // one target
    if(k >= 1) {
      ans += comb(N-1, k-1) * 2;
      ans -= comb((x-1) + (N+1-y), k-1);
    }

    // two targets
    if(k >= 2) {
      ans += comb(N-1, k-2);
    }

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

  return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int h, w;
    bool check;
    sc(h) sc(w)
    vector<vector<char> > G(h, vector<char>(w));
    vector<bool> row(h, false), col(w, false);
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) cin >> G[i][j];
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (G[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) if (row[i] && col[j]) cout << G[i][j];
        if (row[i]) cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	double c,x,y,a,b,t,d,e,f;
		while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
			x=(c*e-b*f)/(a*e-b*d);
			y=(d*c-a*f)/(b*d-a*e);
			if(x==-0)
				x=0;
			if(y==-0)
				y=0;
			printf("%.3f %.3f\n",x,y);
		}
}


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

N,K=map(int,input().split())
A=sorted(map(int,input().split()))

M=[]
Z=[]
P=[]

for a in A:
    if a<0:
        M.append(-a)
    elif a==0:
        Z.append(a)
    else:
        P.append(a)

M.reverse()

MINUS=len(M)*len(P)
PLUS=len(P)*(len(P)-1)//2+len(M)*(len(M)-1)//2
ZERO=N*(N-1)//2-PLUS-MINUS

if MINUS<K and K<=MINUS+ZERO:
    print(0)
    sys.exit()

if K<=MINUS:
    OK=10**18
    NG=0

    while OK-NG>1:
        mid=(OK+NG)//2

        ANS=0
        NOW=len(P)-1

        for i in range(len(M)):
            while NOW>=0 and mid<M[i]*P[NOW]:
                NOW-=1
            ANS+=len(P)-NOW-1

        if ANS>=K:
            NG=mid

        else:
            OK=mid

    print(-OK)

else:
    OK=0
    NG=10**18
    K-=MINUS+ZERO

    while NG-OK>1:
        mid=(OK+NG)//2

        ANS=0
        NOW=len(P)-1

        for i in range(len(P)):
            while NOW>0 and mid<=P[i]*P[NOW]:
                NOW-=1
            ANS+=max(0,NOW-i)

        NOW=len(M)-1

        for i in range(len(M)):
            while NOW>0 and mid<=M[i]*M[NOW]:
                NOW-=1
            ANS+=max(0,NOW-i)

        if ANS>=K:
            NG=mid

        else:
            OK=mid

    print(OK)


Measured memory_bytes: 89220
#include<bits/stdc++.h>
#define fint register int
#define h 5001
#define p 438705
using namespace std;
int f[p],siz[p];
inline int findx(int x);
inline void unions(int x,int y);
int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	for(fint i=1;i<=n;i++)
	f[i]=i,siz[i]=1;
	int x,y;
	for(fint i=1;i<=m;i++)
	cin>>x>>y,unions(x,y);
	int ans=0;
	for(fint i=1;i<=n;i++)
	ans=max(siz[i],ans);
	cout<<ans;
	return 0;
}

inline int findx(int x)
{
	if(f[x]==x)
	return x;
	return f[x]=findx(f[x]);
}

inline void unions(int x,int y)
{
	int fx=findx(x),fy=findx(y);
	if(fx!=fy)
	f[fx]=fy,siz[fy]+=siz[fx];
	return ;
}

Measured memory_bytes: 5224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define mod 1000000007

int n, m, i;
ll ans;

int main()
{
   // freopen("test.in","r",stdin);

    scanf("%d%d", &n, &m);
    if (n > m) swap(n, m);

    if (m - n > 1) {
        printf("0");
        return 0;
    }

    ans = 1;
    for (i = 1; i <= n; i++) ans = (ans * i) % mod;
    for (i = 1; i <= m; i++) ans = (ans * i) % mod;

    if (m == n)
        printf("%lld", (ans * 2) % mod);
    else
        printf("%lld", ans);


    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	cin>>n;
	if(n < 1000)printf("ABC\n");
	else printf("ABD\n");
	return 0;
}


Measured memory_bytes: 384
m, k= map(int, input().split())

if 2**m <= k:
    print(-1)
    exit()

if m == 1:
    if k == 0:
        print("0 0 1 1")
    if k == 1:
        print(-1)
    exit()

li = []
for i in range(2**m):
    if i != k:
        li.append(i)
li = li + [k] + list(reversed(li)) + [k]
print(" ".join(map(str, li)))

Measured memory_bytes: 27400
h, w, k = map(int, input().split())

x = 1
cakes = []
no_strawberry_line = []
for hi in range(h):
  cake_line = []
  for c in list(input()):
    if c == '#':
      cake_line.append(x)
      x += 1
    else:
      cake_line.append(c)
  
  if list(set(cake_line)) == ['.']:
    no_strawberry_line.append(hi)
  cakes.append(cake_line)

for x, cl in enumerate(cakes):
  if x in no_strawberry_line:
    continue
  n = 0
  for y, c in enumerate(cl):
    if c != '.':
      n = c
    if c == '.' and n != 0:
      cakes[x][y] = n
for x, cl in enumerate(cakes):
  if x in no_strawberry_line:
    continue
  n = 0
  i = len(cl) - 1
  for y, c in enumerate(cl):
    if cl[i] != '.':
      n = cl[i]
    if cl[i] == '.' and n != 0:
      cakes[x][i] = n
    i -= 1

def find_up(cakes_line):
  for i, c in enumerate(cakes_line):
    if list(set(c)) != ['.']:
      return i
    
for i, c in enumerate(cakes):
  if list(set(c))[0] == '.':
    if i == 0:
      continue
    cakes[i] = cakes[i - 1]

index = len(cakes) - 1
for i, c in enumerate(cakes):
  if list(set(cakes[index]))[0] == '.':
    if index == len(cakes) - 1:
      continue
    cakes[index] = cakes[index + 1]
  index -= 1

for c in cakes:
  print(' '.join(map(str, c)))
  

Measured memory_bytes: 7156
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, a[100010];

    cin >> n;
    for (int i=0; i<n; i++) scanf("%d", &a[i]);

    sort(a, a+n);

    int num = a[0], cont = 0, ret = 0;
    for (int i=0; i<n; i++) {
        if (a[i] == num) {
            cont++;
        }
        else {
            if (num < cont) ret += cont - num;
            else if (num > cont) ret += cont;

            cont = 1;
            num = a[i];
        }
    }

    if (num < cont) ret += cont - num;
    else if (num > cont) ret += cont;

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    int ans=1;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        ans=fmin(ans*2,ans+k);
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
map<int,int>p;
/*struct knd{
	int x,y,z;
}s[200000];*/ 
int a[200000];
int main()
{
	int m,n,i,j,t,k;
	cin>>n;
	/*for(i=1;i<=n;i++)
	{
		cin>>a[i];
	 } */
	 t=0;
	 while(t<n)
	 {
	 	t+=1000;
	 	
	 }
	 cout<<t-n;
	 
 } 

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		int S = scanner.nextInt();
		int s = S%60;
		int temp = S/60;
		int m = temp%60;
		int h = temp/60;
		System.out.println(h + ":" + m + ":" + s);
		scanner.close();
	}

}


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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

template<typename T>
void chmin(T &a, const T &b){ a = min(a, b); }

template<typename A, size_t N, typename T>
void static_fill(A (&arr)[N], const T &val){
    fill((T*)arr, (T*)(arr+N), val);
}

const int INF = 1e6;
int dp[1<<18][51];
int bit_count[1<<18];

void renum(vector<int> &A, vector<int> &B) {
    vector<int> v = A;
    v.insert(v.end(), B.begin(), B.end());
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for (int &a: A) a = lower_bound(v.begin(), v.end(), a) - v.begin();
    for (int &b: B) b = lower_bound(v.begin(), v.end(), b) - v.begin();
}

void bit_init() {
    for (int i=0; i<(1<<18); ++i) {
        bit_count[i] = __builtin_popcount(i);
    }
}

int main() {
    bit_init();
    static_fill(dp, INF);

    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i=0; i<N; ++i) cin >> A[i];
    for (int i=0; i<N; ++i) cin >> B[i];
    renum(A, B);

    int M = max(*max_element(A.begin(), A.end()), *max_element(B.begin(), B.end()));

    // 位置iにあるカードを位置jに置くときの表の数字
    auto face = [&](int i, int j){
        return abs(i-j) % 2 ? B[i] : A[i];
    };

    for (int i=0; i<N; ++i) {
        dp[1<<i][face(i, 0)] = 0;
    }
    for (int mask=1; mask<(1<<N); ++mask) {
        for (int i=0; i<=M; ++i) {
            if (dp[mask][i] == INF) continue;
            for (int j=0; j<N; ++j) {
                if ((mask >> j) & 1) continue;
                
                int p = bit_count[mask];
                if (i <= face(j, p)) {
                    int inv = bit_count[mask / (1<<(j+1))];
                    chmin(dp[mask|(1<<j)][face(j, p)], dp[mask][i] + inv);
                }
            }
        }
    }
    int res = INF;
    for (int i=0; i<=M; ++i) {
        res = min(res, dp[(1<<N)-1][i]);
    }
    cout << (res == INF ? -1 : res) << endl;

    return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )

typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int X;
    cin >> X;
    if(X>=30) {
        cout << "Yes" <<endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int a, b;
	cin >> a >> b;
	if (a <= b) cout << a << endl;
	else cout << a - 1 << endl;
	return 0;
}


Measured memory_bytes: 3596
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [usize; n]
    }
    let mut tab: Vec<usize> = vec![0; k + 1];
    let vm = *v.iter().min().unwrap();
    for i in vm..k + 1 {
        for j in 0..n {
            if i < v[j] {
                continue;
            }
            if tab[i - v[j]] == 0 {
                tab[i] = 1;
                break;
            }
        }
    }
    println!("{}", if tab[k] == 1 {"First"} else {"Second"});
}


Measured memory_bytes: 4352
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var: ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        r: usize,
        d: usize,
        x: usize,
    }
    let mut ans = x;
    for _ in 0..10 {
        ans = r * ans - d;
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
// Bismillah .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const ll mx = 1e18;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    ll ans = n+n*n+(n*n)*n;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3660
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

using Graph = vector<vector<int> >;
vector <int> depth;
vector <int> parent;

// トポロジカルソートする
void rec(int v, const Graph &G, vector<bool> &seen, vector<int> &order) {
    seen[v] = true;
    for (auto next : G[v]) {
        if (seen[next]) continue; // 既に訪問済みなら探索しない
        rec(next, G, seen, order);
    }
    order.push_back(v);
}

void dfs(const Graph& graph, int v, int p, int d) {
	if (parent[v] == -1){	//初訪問のとき
		parent[v] = p;
		depth[v] = d;
		for (auto nv : graph[v]){
			if (nv == p) continue;
			dfs(graph, nv, v, d + 1);
		}
	} else {	//初訪問でないとき
		int orgP = parent[v];
		int orgD = depth[v];
		bool cond1 = (orgP != p);
		bool cond2 = (orgD < d);

		if (cond1){
			if (cond2){
				parent[v] = p;
				depth[v] = d;
				for (auto nv : graph[v]){
					if (nv == p) continue;
					dfs(graph, nv, v, d + 1);
				}
			}
		} else {
			if (cond2){
				depth[v] = d;
				for (auto nv : graph[v]){
					if (nv == p) continue;
					dfs(graph, nv, v, d + 1);
				}				
			}
		}
	}
}

int main() {
    int N, M;
    cin >> N >> M;
    Graph G(N+M-1);
    Graph R(N+M-1);    
    for (int i = 0; i < N+M-1; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        R[b].push_back(a);
    }

    // トポロジカルソート
    vector<bool> seen(N, 0);
    vector<int> order;
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue;
        rec(v, G, seen, order);
    }
    // reverse(order.begin(), order.end());

    //orderには葉から順に並んでいる
    vector<int> dummy(N);
    for (int ii = 0; ii < N; ++ii){
    	dummy[order[ii]] = ii;
    }


	parent.assign(N, -1);
	for (int ii = 0; ii < order.size(); ++ii){
		int v = order[ii];
	    //nvの中でorderが最小のものを求める
	    int minV = 100100100;
	    for (auto nv : R[v]) {
	    	minV = min(minV, dummy[nv]);
	    }
	    if (minV != 100100100){
	    	parent[v] = order[minV];
	    }
	}

 //    //探索
 //    int root = order[0];
	// depth.assign(N, 0);
	// parent.assign(N, -1);
	// dfs(G, /*v=*/root, /*p=*/-1, /*d=*/0);

	for (int ii = 0; ii < N; ++ii){
		cout << parent[ii] + 1 << endl;
	}

}


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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>


int main() {
  map<string, int> m;
  int n, x;
  cin >> n;
  REP(i, n){
    string s;
    cin >> s;
    m[s]++;
  }
  cin >> x;
  REP(i, x){
    string s;
    cin >> s;
    m[s]--;
  }
  int ans = 0;
  for(auto i = m.begin(); i != m.end(); i++){
    ans = max(ans, i->second);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007LL;

ll ipow(ll base, ll exp)
{
    ll result = 1LL;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

struct DisjointSet {
    vector<int> parent, rank, size;
    DisjointSet(int n) : parent(n), rank(n, 1), size(n, 1) {
        for(int i = 0; i < n; ++i) 
            parent[i] = i;
    }

    int find(int u) {
        if(u == parent[u]) return u;
        return parent[u] = find(parent[u]);
    }

    void merge(int u, int v) {
        u = find(u); v = find(v);
        if(u == v) return;
        if(rank[u] > rank[v]) swap(u, v);
        parent[u] = v;
        if(rank[u] == rank[v]) ++rank[v];
        size[v] += size[u];
    }
};

int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;

int n, k;
string a;
vi b;

int main(void) {
    ios_base::sync_with_stdio(false); 
    cin.tie(0); 
    cout.tie(0);
    //freopen("in.txt", "r", stdin);
    cin >> n >> k;
    cin >> a;

    int cnt = 1;
    rep(i,1,n) {
        if(a[i] != a[i-1]) {
            b.pb(cnt);
            cnt = 1;
        } else {
            cnt++;
        }
    }
    b.pb(cnt);

    if(a[0] == '0') {
        b.insert(b.begin(), 0);
    }
    b.pb(0);
    
    int beginidx = 0;
    int endidx = min(sz(b), 2*k+1);
    ll ret = 0;
    ll sum = -1;
    while(endidx <= sz(b)) {
        if(sum == -1) {
            sum = 0;
            rep(i,beginidx, endidx) {
                sum += (ll)b[i];
            }
            ret = max(ret, sum);
            beginidx += 2;
            endidx += 2;
        } else {
            sum -= (ll)b[beginidx-1];
            sum -= (ll)b[beginidx-2];
            sum += (ll)b[endidx-1];
            sum += (ll)b[endidx-2];
            ret = max(ret, sum);
            beginidx += 2;
            endidx += 2;
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1020
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.Set;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();


		Set<Integer> adj[] = new HashSet[n+1];
		for(int i = 1; i<adj.length; i++) {
			adj[i] = new HashSet<Integer>();
		}


		for(int i = 0; i < m; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();

			adj[a].add(b);
			adj[b].add(a);
		}

		int[] dist = new int[n+1];
		dist[0] = 0;
		int[] ans = new int[n+1];

		boolean[] end = new boolean[n+1];
		end[1] = true;
		ArrayDeque<Integer> q = new ArrayDeque<>();
		q.add(1);

		while(!q.isEmpty()) {

			int v1 = q.poll();

			int tdist = dist[v1] + 1;

			Iterator<Integer> adjit = adj[v1].iterator();
			while(adjit.hasNext()) {
				int v2 = adjit.next();
				if(!end[v2]) {
					q.add(v2);
					end[v2] = true;

					dist[v2] = tdist;
					ans[v2] = v1;
				}
			}
		}

		System.out.println("Yes");
		for(int i = 2; i < n+1; i++) {
			System.out.println(ans[i]);
		}
	}

}


Measured memory_bytes: 97920
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();
            var N = cin.ReadLong();

            var min = long.MaxValue;
            for (long i = (long)Sqrt(N) + 1; i > 0; --i)
            {
                if (N % i == 0)
                {
                    var A = i;
                    var B = N / i;
                    min = Min(min, Func(A, B));
                }
            }
            WriteLine(min);
        }

        public int Func(long A, long B)
        {
            return Max((int)Log(A, 10), (int)Log(B, 10)) + 1;
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }

    public class Pair<T1, T2>
    {
        public T1 First;
        public T2 Second;
        public Pair() { First = default(T1); Second = default(T2); }
        public Pair(T1 f, T2 s) { First = f; Second = s; }
        public override string ToString() { return "(" + First + ", " + Second + ")"; }
        public override int GetHashCode() { return First.GetHashCode() ^ Second.GetHashCode(); }
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj)) return true;
            else if (obj == null) return false;
            var tmp = obj as Pair<T1, T2>;
            return (object)tmp != null && First.Equals(tmp.First) && Second.Equals(tmp.Second);
        }
    }

    #region HashMap
    public class HashMap<K, V> : Dictionary<K, V>
    {
        public HashMap() : base() { }
        public HashMap(int cap) : base(cap) { }
        public HashMap(IDictionary<K, V> dictionary) : base(dictionary) { }
        new public V this[K i]
        {
            get
            {
                V v;
                return TryGetValue(i, out v) ? v : base[i] = default(V);
            }
            set { base[i] = value; }
        }
    }
    #endregion
}


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

int main ()
{
    
    long long N;
    long long M;
    cin >> N >> M;
    long long i=1;
    long long ans;
    long long P=1;
    long long prevP=1;
    long long P2=1;
    //soinsubunkaisuru
    while(1){
        if(i*i>M)break;
        if(N*i>M)break;
        if(M%i==0){
            prevP=P;
            P=i;
            if(N*(M/i) <=M) P2=max(M/i,P2);
        }
        i++;
    }
    if(N*P>M) ans=max(prevP,P2);
    else ans=max(P,P2);
    cout << ans << endl;
    return 0;
}








Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
using namespace std;

int main() {
	int A, B, T;
	cin >> A >> B >> T;
	int C = (T + 0.5) / A;
	cout << C * B << endl;
}

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

using namespace std;

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

    int ans = 0;

    for (int i = 1; i < n - 1; i++) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main() {
    int N = readln.chomp.to!int;
    foreach(i; 0..N) {
        bfs(readln.split.to!(int[])).writeln;
    }
}

int bfs(int[] ary) {
    auto list = DList!(Tuple!(int, int[]))(tuple(0, ary));
    while(!list.empty) {
        auto t = list.front;
        int depth = t[0];
        int[] vec = t[1];
        list.removeFront;
        if (check(vec)) return depth;
        if (depth>=8) continue;
        {
            int[] v = vec.dup;
            swap(v[0], v[27]);
            swap(v[1], v[28]);
            swap(v[2], v[29]);
            swap(v[14], v[15]);
            swap(v[18], v[20]);
            list.insertBack(tuple(depth+1, v));
        } {
            int[] v = vec.dup;
            swap(v[2], v[21]);
            swap(v[5], v[24]);
            swap(v[8], v[27]);
            swap(v[11], v[18]);
            swap(v[12], v[14]);
            list.insertBack(tuple(depth+1, v));
        } {
            int[] v = vec.dup;
            swap(v[0], v[23]);
            swap(v[3], v[26]);
            swap(v[6], v[29]);
            swap(v[9], v[20]);
            swap(v[15], v[17]);
            list.insertBack(tuple(depth+1, v));
        } {
            int[] v = vec.dup;
            swap(v[6], v[21]);
            swap(v[7], v[22]);
            swap(v[8], v[23]);
            swap(v[12], v[17]);
            swap(v[9], v[11]);
            list.insertBack(tuple(depth+1, v));
        }
    }
    return 8;
}

bool check(int[] ary) {
    return ary.group.map!(a => a[1]).array == [9, 3, 3, 3, 3, 9];
}

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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int H,W;
   cin>>H>>W;
   vector<string>A(H);
   for(int i=0;i<H;i++)cin>>A[i];
   vector<bool>tate(H,true),yoko(W,true);
   for(int i=0;i<H;i++){
      bool flg = true;
      for(int j=0;j<W;j++){
         if(A[i][j] == '#')flg = false;
      }
      if(flg)tate[i]=false;
   }
   for(int j=0;j<W;j++){
      bool flg = true;
      for(int i=0;i<H;i++){
         if(A[i][j] == '#')flg = false;
      }
      if(flg)yoko[j] = false;
   }

   for(int i=0;i<H;i++){
      if(tate[i]){
         for(int j=0;j<W;j++){
            if(yoko[j])cout<<A[i][j];
         }
         cout<<endl;
      }
   }
   return 0;
}


Measured memory_bytes: 256
N,D = map(int, input().split())
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i],Y[i] = map(int, input().split())
    
ans = 0
for i in range(N):
    if X[i]**2+Y[i]**2<=D**2:
        ans+=1
print(ans)

Measured memory_bytes: 24708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll MAX = 1e10;
constexpr int ma = 100000;
vector<int> v(ma+1);
vector<int> prime;

void erast(){
    for(int i=0;i<=ma;i++){
        v[i] = 1;
    }
    for(int i=2;i*i<=ma;i++){
        if(v[i]){
            for(int j=0;i*(j+2)<=ma;j++){
                v[i*(j+2)]=0;
            }
        }
    }
    v[1] = false;
    for(ll i=2;i*i*i<=MAX;i++){
        if(v[i]){
            prime.push_back(i);
        }
    }
}

using P = pair<int,int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    erast();
    cin >> N;
    int ans = 0;
    map<vec<P>,int> mp;
    bool cube = false;
    for(int i=0;i<N;i++){
        ll s;
        cin >> s;
        ll n = s;
        map<int,int> m;
        for(ll x:prime){
            if(x*x>s) break;
            while(n%x==0){
                n /= x;
                m[x]++;
            }
        }
        if(n!=1 && prime.back()>=n) m[n]++;
        if(n<=prime.back()){
            vec<P> v;
            bool iscube = true;
            for(auto& x:m){
                if(x.second%3) v.emplace_back(x.first,x.second%3);
                iscube &= x.second%3==0;
            }
            if(iscube) cube = true;
            else if(!v.empty()) mp[v]++;
        }else{
            ll a = sqrt(n);
            if(a*a==n || n<=ma){
                vec<P> v;
                for(auto& x:m) if(x.second%3) v.emplace_back(x.first,x.second%3);
                if(a*a==n) v.emplace_back(a,2);
                else v.emplace_back(n,1);
                mp[v]++;
            }else ans++;
        }
    }
    ans += cube;
    int ans2 = 0;
    for(auto& v:mp){
        vec<P> other;
        for(auto& x:v.first) other.emplace_back(x.first,3-x.second);
        if(!mp.count(other)) ans += v.second;
        else ans2 += max(v.second,mp[other]);
    }
    ans += ans2/2;
    cout << ans << "\n";
}

Measured memory_bytes: 12796
import java.util.Scanner

object Main {

  def check(input: Array[Array[Int]]): Int = {
    var ret = 0
    for (j <- 0 until input(0).length) {
      var N = 0
      for (i <- 0 until input.length) {
        N += input(i)(j)
      }
      ret += math.max(N, input.length - N)
    }
    ret
  }

  def check2(num: Int, input: Array[Array[Int]]): Int = {
    var ret = 0
    for (j <- 0 until input(0).length) {
      var N = 0
      for (i <- 0 until input.length) {
        if ((num >> i) % 2 == 1) {
          N += 1 - input(i)(j)
        } else {
          N += input(i)(j)
        }
      }
      ret += math.max(N, input.length - N)
    }
    ret
  }

  //  /*
  def rev(num: Int, input: Array[Array[Int]]): Array[Array[Int]] = {
    Array.tabulate(input.length)(i => if ((num >> i) % 2 == 1) (Array.tabulate(input(i).length)(j => 1 - input(i)(j))) else (input(i)))
  }

  // */
  /*
def rev(num: Int, input: Array[Array[Int]]): Array[Array[Int]] = {
  for (i <- 0 until input.length) {
    if ((num >> i) % 2 == 1) (
      Array.copy(Array.tabulate(input(i).length)(j => 1 - input(i)(j)), 0, input(i), 0, input(i).length)
      )
  }
  input
}

//  */

  def make(input: Array[Array[Int]]): Int = {
    var max: Int = 0
    for (i <- 0 to (1 << (input.length - 2))) {
      max = math.max(max, check2(i, input.clone))
    }
    max
  }

  def solve(sc: Scanner): Boolean = {
    val R: Int = sc.nextInt
    val C: Int = sc.nextInt
    if (R != 0 && C != 0) {
      println(make(Array.fill(R)(Array.fill(C)(sc.nextInt))))

      true
    } else {
      false
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    while (solve(sc)) ()
  }
}

Measured memory_bytes: 166480
#include <bits/stdc++.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
inline int read() {
    int f=1,sum=0;
    char x=getchar();
    for(;(x<'0'||x>'9');x=getchar()) if(x=='-') f=-1;
    for(;x>='0'&&x<='9';x=getchar()) sum=sum*10+x-'0';
    return f*sum;
}

#define M 505
#define N 8000
int n;
ll a[M][M];
int prime[N+5];
bool notprime[N+5];

map <ll,bool> cc;

void get_prime() {
    for1(2,N,i) {
        if(!notprime[i]) prime[++prime[0]]=i;
        for1(1,prime[0],j) {
            if(i*prime[j]>N) break;
            notprime[i*prime[j]]=1;
            if(!(i%prime[j])) break;
        }
    }
}

inline ll gcd(ll x,ll y) {return y?gcd(y,x%y):x;}
inline ll Lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main () {
    //freopen("a.in","r",stdin);
    n=read();
    if(n==2) {
        puts("4 7");
        puts("23 10");
        return 0;
    }
    get_prime();
    for1(0,n+1,i) for1(0,n+1,j) a[i][j]=1;
    for1(1,n,i) for1(1,n,j) if(!(i+j&1)) a[i][j]=prime[(i+j)/2]*prime[1000-(i-j)/2-(n+1)/2+1];
    for1(1,n,i) for1(1,n,j) if(i+j&1) a[i][j]=Lcm(Lcm(a[i-1][j],a[i][j-1]),Lcm(a[i][j+1],a[i+1][j]))+1;
    for1(1,n,i) {
        for1(1,n,j) printf("%lld ",a[i][j]);
        puts("");
    }
}

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

const int MAX_N = 100005;
const int MAX = 2000000000;
int mem[MAX_N];
int hs[MAX_N];
int N;

int dp(int n) {
  if (n > N) return MAX;
  if (n == N) return 0;
  if (mem[n] != -1) return mem[n];
  mem[n] = MAX;
  if (n + 1 <= N)
    mem[n] = std::min(mem[n], dp(n + 1) +
      std::abs(hs[n] - hs[n + 1]));
  if (n + 2 <= N)
    mem[n] = std::min(mem[n], dp(n + 2) +
      std::abs(hs[n] - hs[n + 2]));
  return mem[n];
}

int main() {
  scanf("%d", &N);
  memset(mem, -1, sizeof(mem));
  for (int i = 0; i < N; ++i) {
    scanf("%d", hs + i + 1);
  }
  printf("%d\n", dp(1));
}


Measured memory_bytes: 9244
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

light = [0] * 4 * (W + 1) * (H + 1)

row = 4 * (W + 1)
col = 4

for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h + 1) + col * w + 1] = light[here + 1] + 1
            light[row * h + col * (w + 1) + 3] = light[here + 3] + 1

ans = 0
for h in range(H - 1, -1, -1):
    for w in range(W - 1, -1, -1):
        if grid[h][w] == '.':
            here = row * h + col * w
            light[row * (h - 1) + col * w + 0] = light[here + 0] + 1
            light[row * h + col * (w - 1) + 2] = light[here + 2] + 1
            ans = max(ans, sum(light[here: here + 4]) + 1)

print(ans)


Measured memory_bytes: 179332
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		
		
		double result = 0;
		
		for(int i = 1; i <= n; i++) {
			int times = 0;
			double start = i;
			
			while (start < k) {
				start *= 2;
				times++;
			}
//			System.out.println(times);
			
			result += 1.0/n*Math.pow(0.5, times);
		}
		
		System.out.printf("%.10f\n", result);
	}

}


Measured memory_bytes: 23764
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    while(1){
        int n,k;
        int x,li[100002]={0},blank=0;
        int cha[100002]={0},chax=0,chan=0;
        int ans=0;
        scanf("%d %d",&n,&k);
        if(n==0&&k==0)
            break;
        for(int i=0;i<k;i++){
            scanf("%d",&x);
            li[x]=1;
            if(!x)
                blank=1;
        }
        for(int i=0;i<=n;i++){
            if(li[i]==0)
                cha[chan]=0,chax=0,chan++;
            else{
                chax++;
                if(li[i+1]==0)
                    cha[chan]=chax,chan++;
            }
        }
        if(blank==1){
            ans=cha[1]+1;
            for(int i=1;i<=n;i++){
                if(cha[i]==0)
                    ans=max(ans,cha[i-1]+1+cha[i+1]);
            }
        }
        else{
            for(int i=0;i<=n;i++)
                ans=max(ans,cha[i]);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1976
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1e9
 
class Point{
public:
  double x,y;
 
  Point(double x = 0, double y = 0):x(x),y(y){}
 
  bool operator < (const Point &a)const{
    if(x != a.x) return x < a.x;
    return y < a.y;
  }
};
 
bool compare(Point a, Point b){
  return a.y < b.y;
}
 
double solve(Point *a, int n){
  if(n <= 1) return INF;
  int m = n / 2;
  double xx = a[m].x;
  double d = min(solve(a,m),solve(a+m,n-m));
  inplace_merge(a,a+m,a+n,compare);
 
  vector<Point> v;
  for(int i = 0 ; i < n ; i++){
    if(fabs(a[i].x - xx) >= d) continue;
    int len = (int)v.size();
    for(int j = 0 ; j < len ; j++){
      double dx = a[i].x - v[len-j-1].x;
      double dy = a[i].y - v[len-j-1].y;
 
      if(dy*dy >= d) break;
      d = min(d,dx * dx + dy * dy);
    }
    v.push_back(a[i]);
  }
  return d;
}
 
int main(){
  int n;
 
  cin >> n;
  Point p[n];
  for(int i = 0 ; i < n ; i++){
    cin >> p[i].x >> p[i].y;
  }
  sort(p,p+n);
  cout << solve(p,n) << endl;
 
  return 0;
}

Measured memory_bytes: 20504
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++){
        if(s[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    a--;
    ll tmpc=c; ll tmpd=d;
    c=max(tmpc,tmpd);
    d=min(tmpc,tmpd);
    ll r=c%d;
    while(r){
        c=d;
        d=r;
        r=c%d;
    }
    ll com=tmpc*tmpd/d;
    ll bans=b-(b/tmpc+b/tmpd-b/(com));
    ll aans=a-(a/tmpc+a/tmpd-a/(com));
    cout << bans-aans << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int D = (80+160+10)*80;
const int D2 = 2*D;
typedef bitset<D2> bs;
const int pm[2] = {-1,1};
int a[90][90];
bs dp[90][90];
int main(){
    int h,w; cin >> h >> w;
    

    rep(i,h)rep(j,w) cin >> a[i][j];
    rep(i,h)rep(j,w){
        int tmp;
        cin >> tmp;
        a[i][j] = abs(a[i][j]-tmp);        
    }

    rep(i,2) dp[0][0][D+pm[i]*a[0][0]] = 1;

    rep(i,h)rep(j,w){
        if(i){
            dp[i][j] |= dp[i-1][j]<<a[i][j];
            dp[i][j] |= dp[i-1][j]>>a[i][j];
        }
        if(j){
            dp[i][j] |= dp[i][j-1]<<a[i][j];
            dp[i][j] |= dp[i][j-1]>>a[i][j];
        }
    }
    int ans=D2;
    rep(i,D2){
        if (!dp[h-1][w-1][i])continue;
        if (abs(i-D)<ans) ans=abs(i-D);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 36992
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
    int n;
    cin >> n;
    char a[130][130];
    int cou=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> a[i][j];
            if(a[i][j]=='o'){
                if(i*j==0){
                    if(i==0 && j==0)cou++;
                    else if(i==0){
                        if(a[0][j-1]=='x')cou++;
                    }else if(j==0){
                        if(a[i-1][0]=='x')cou++;
                    }
                }else{
                    if(a[i][j-1]=='x' && a[i-1][j]=='x')cou++;   
                }
            }
        }
    }
    cout << (cou-1)/3 << endl;
    return 0;
}

Measured memory_bytes: 3132
import math

N = int(input())

if math.floor(math.floor((N) / 1.08) * 1.08) == N:
    print(math.floor((N) / 1.08))
elif math.floor(math.ceil((N) / 1.08) * 1.08) == N:
    print(math.ceil((N) / 1.08))
else:
    print(":(")

Measured memory_bytes: 3060