akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>

using namespace std;

static const int N = 100;

void output(int input[], int n){
	for(int i = 0; i < n; i++ ){
		if(i > 0) printf(" ");
		printf("%d",input[i]);
	}
	printf("\n");
}


int main(void){
	int n,input[N],selectNumber;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> input[i];

	}

	output(input,n);
	for(int i = 1; i < n; i++ ){
		selectNumber = input[i];
		int j = i - 1;
		while(j >= 0 && input[j] > selectNumber){
			input[j+1] = input[j];
			j--;
		}
		input[j+1] = selectNumber;
		output(input,n);
	}
	return 0;
}

Measured memory_bytes: 1148
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#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 rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % M;
        x=(x*x) % M;
        n=n/2;
    }
    return result % M;
}
 
signed main()
{
    tezz

    int x;
    cin>>x;

    for(int i=-2000;i<=2000;i++){
        for(int j=-2000;j<=2000;j++){
            if(power(i, 5) == (x + power(j, 5)) % M){
                cout<<i<<' '<<j;
                return 0;
            }
        }
    }
} 

Measured memory_bytes: 3656
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String format = "%d %d %d %d";
		int[][] a = new int[H][W];
		for(int i = 0; i< H; i++)
			for(int j = 0; j < W; j++)
				a[i][j] = sc.nextInt();
		
		List<String> list = new ArrayList<>();
		
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W-1; j++) {
				if(a[i][j] %2 == 0)
					continue;
				
				a[i][j+1]++;
				a[i][j]--;
				list.add(String.format(format, i+1,j+1,i+1,j+2));
			}
		}
		for(int i = 0; i < H -1; i++) {
			if(a[i][W-1] % 2 == 0)
				continue;
			
			a[i][W-1]--;
			a[i+1][W-1]++;
			list.add(String.format(format, i+1, W, i+2, W));
		}
		System.out.println(list.size());
		list.stream().forEach(System.out::println);
	}
}

Measured memory_bytes: 171700
#include<stdio.h>

int main(void)
{
  int a[26],i=0;
  char w[101];
  scanf("%s",w);
  for(i=0;i<26;i++)
    {
      a[i] = 0;
    }
  i=0;
  while(w[i] != '\0')
    {
      a[(int)w[i]-97]++;
      i++;
    }
  for(i=0;i<26;i++)
    {
      if(a[i]%2 != 0)
	{
	  printf("No\n");
	  return 0;
	}
    }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include<cstring>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    char c;
    int i=0;
    while(scanf("%c",&c)!=EOF)
    {
        if(i%2==0)cout<<c;
        i++;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i;  //???????????¨?????°
    int n = 0; //?????????
    int x[10000];//????????????????????¨?????????????????????
    
    while(1){ //0?????\?????????????????§?????????
        scanf("%d",&x[n]); //??\???
        if( x[n] == 0 ){
            break;
        }
        n++;
    }
    for(i = 0; i < n; i++){//0?????\??????????????§?????°
        printf("Case %d: %d\n",i+1,x[i]); //??????
    }
    return 0;
}

Measured memory_bytes: 1784
#include <stdio.h>

int main(void)
{
	int n, b, f, r, v;
	int room[4][3][10];
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				room[i][j][k] = 0;
			}
		}
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		room[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				printf(" %d", room[i][j][k]);
			}
			printf("\n");
		}
		if (i < 3) {
			printf("####################\n");
		}
	}
}



Measured memory_bytes: 2028
OFFSET = 80*80

class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)

  def initialize
    @h, @w = gets.split.map { |v| v.to_i }
    @a = Array.new(h) { gets.split.map { |v| v.to_i } }
    @b = Array.new(h) { gets.split.map { |v| v.to_i } }
    @c = Array.new(h){ |y| Array.new(w){ |x| a[y][x] - b[y][x] } }
  end
  
  def each_grid
    h.times do |y|
      w.times do |x|
        yield y - 1, x, y, x if y != 0
        yield y, x - 1, y, x if x != 0
      end
    end
  end

  def solve
    dp = Array.new(h) { Array.new(w, 0) }
    dp[0][0] |= 1 << (OFFSET + c[0][0])
    dp[0][0] |= 1 << (OFFSET - c[0][0])
    
    each_grid do |y, x, ny, nx|
      dp[ny][nx] |= dp[y][x] << c[ny][nx].abs
      dp[ny][nx] |= dp[y][x] >> c[ny][nx].abs
    end
    
    dp[-1][-1]
  end  

  def show(ans)
    0.upto(OFFSET) do |i|
      if (ans >> (OFFSET + i)) & 1 == 1 || (ans >> (OFFSET - i)) & 1 == 1
        puts i
        exit
      end
    end
  end  
end  

Problem.new.instance_eval do
  show(solve)
end  


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


//#define int long long 


const int N = 18;

int v[1 << N], w[1 << N]; long long dp[1 << 10][100001];

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> v[i] >> w[i];
		if(i >= 1024) {
			continue;
		}
		for(int j = 0; j <= 100000; j++) {
			dp[i][j] = dp[i / 2][j];
			if(j >= w[i]) {
				dp[i][j] = max(dp[i][j], dp[i / 2][j - w[i]] + v[i]);
			}
		}
	}

	int q; cin >> q;
	for(int i = 1; i <= q; i++) {
		int vv, l; cin >> vv >> l;
		if(vv < 1024) {
			cout << dp[vv][l] << "\n";
		} else {
			vector <int> idx; int u = vv;
			while(u >= 1024) {
				idx.push_back(u);
				u /= 2;
			}
			long long ans = 0;
			for(int j = 0; j < (1 << (int)idx.size()); j++) {
				long long ww = 0, vvv = 0;
				for(int k = 0; (1 << k) <= j; k++) if((j >> k) & 1) {
					ww += w[idx[k]];
					vvv += v[idx[k]];
				}
				if(ww <= l) {
					ans = max(ans, dp[u][l - ww] + vvv);
				}
			}
			cout << ans << "\n";
		}
	}
	
}


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

int main(){
    string s;
    cin >> s;

    if(s == "SUN"){
        cout << 7 << endl;
    }
    else if(s == "MON"){
        cout << 6 << endl;
    }
    else if(s == "TUE"){
        cout << 5 << endl;
    }
    else if(s == "WED"){
        cout << 4 << endl;
    }
    else if(s == "THU"){
        cout << 3 << endl;
    }
    else if(s == "FRI"){
        cout << 2 << endl;
    }
    else if(s == "SAT"){
        cout << 1 << endl;
    }

    // cout << 'cnt' << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  cout << (n - (n / 2)) / (double)n << endl;
}

Measured memory_bytes: 256
class Dice

  def initialize(surfaces)
    @surfaces = surfaces.dup 
  end

  def top
    @surfaces[0]
  end

  def front
    @surfaces[1]
  end

  def right
    @surfaces[2]
  end

  def N
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[1]
    @surfaces[1] = @surfaces[5]
    @surfaces[5] = @surfaces[4]
    @surfaces[4] = tmp
    self
  end

  def E
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[3]
    @surfaces[3] = @surfaces[5]
    @surfaces[5] = @surfaces[2]
    @surfaces[2] = tmp
    self
  end

  def S
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[4]
    @surfaces[4] = @surfaces[5]
    @surfaces[5] = @surfaces[1]
    @surfaces[1] = tmp
    self
  end

  def W
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[2]
    @surfaces[2] = @surfaces[5]
    @surfaces[5] = @surfaces[3]
    @surfaces[3] = tmp
    self
  end

  def adjust_front(front)
    4.times do
      self.N
      return if self.front == front
    end

    self.E
    adjust_front(front)
  end

  def equal_surfaces(other)
    (0..5).all?{|n| surface_val(n) == other.surface_val(n) }
  end

  def surface_val(num)
    @surfaces[num]
  end

  def has_value?(v)
    @surfaces.include?(v)
  end
end

dice1 = Dice.new(gets.chomp.split.map(&:to_i))
dice2 = Dice.new(gets.chomp.split.map(&:to_i))

unless dice2.has_value?(dice1.front)
  puts 'No'
  exit
end

dice2.adjust_front(dice1.front)
4.times do
  dice2.E

  if dice1.equal_surfaces(dice2)
    puts 'Yes'
    exit
  end
end

puts 'No'

Measured memory_bytes: 8752
macro_rules! input {
     (source = $s:expr, $($r:tt)*) => {
         let mut iter = $s.split_whitespace();
         input_inner!{iter, $($r)*}
     };
     ($($r:tt)*) => {
         let s = {
             use std::io::Read;
         let mut s = String::new();
         std::io::stdin().read_to_string(&mut s).unwrap();
         s
     };
     let mut iter = s.split_whitespace();
     input_inner!{iter, $($r)*}
     };
}
     
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap,};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
fn main() {
    input!{
        n: i64,
        a: i64,
        b: i64,
    }
    let (mut a, mut b) = (a, b);
    if a > b { swap(&mut a, &mut b); }
    if (b - a) % 2 == 0 { println!("{}", (b - a) / 2); }
    else {
        let x = min(a - 1, n - b);
        println!("{}", x + (b - a + 1) / 2);
    }
}


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

using namespace std;

#define LIMIT 100
typedef pair<int64_t, int64_t> ii;

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;

  cin >> n;
  int a[100];

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

  for (int i = -100; i <= 100; ++i) {
    int64_t cost = 0;
    for (int j = 0; j < n; ++j) {
      cost += (a[j]-i)*(a[j]-i);
    }
    miCost = min<int64_t>(cost, miCost);
  }
  std::cout << miCost << std::endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  string S;
  cin >> S;
  if (S == "AAA" || S == "BBB") {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}



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

using namespace std;

typedef long long ll;

// combination
// O(n)
const ll MOD = 1e9 + 7;
const ll max_n = 2020202;
ll fact[max_n];
bool fact_init = false;

ll pow(ll a, ll b){
	if(b == 0) return 1;
	if(b % 2 == 1) return a * pow(a, b - 1) % MOD;

	ll d = pow(a, b / 2) % MOD;
	return d * d % MOD;
}

ll comb(ll n, ll k){
	if(!fact_init){
		fact[0] = 1;
		fact[1] = 1;

		for(ll i = 2; i < max_n; i++){
			fact[i] = fact[i-1] * i;
			fact[i] %= MOD;
		}

		fact_init = true;
	}

	ll ret = fact[n];
	ret *= pow(fact[k],MOD-2);
	ret %= MOD;
	ret *= pow(fact[n-k],MOD-2);
	ret %= MOD;
	return ret;

	// X^(-1) = X^(p-2) (mod p) (Fermat's little theorem)
}

ll inv(ll a){
	return pow(a, MOD - 2);
}

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

	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	ll ans = 0;
	for(ll i = r1; i <= r2; i++){
		ans += comb(i + c2 + 1, c2);
		ans %= MOD;
		ans += MOD - comb(i + c1, c1 - 1);
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;

  if ((N- (N / 1000) * 1000) % 111 == 0  || (N- N % 10) % 1110 == 0 ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
result = []
ans = dict((s, False) for s in range(1, N+1))
pen = dict((s, 0) for s in range(1, N+1))

for _ in range(M):
    s, d = input().split()
    if d == "AC":
        ans[int(s)] = True
        continue

    if d == "WA" and not ans[int(s)]:
        pen[int(s)] += 1

ans_result = 0
for _, v in ans.items():
    if v:
        ans_result += 1

pen_result = 0
for k, v in pen.items():
    if ans[k]:
        pen_result += v

print(ans_result, pen_result)


Measured memory_bytes: 27368
#3

N=int(input())
act=[0]+[[int(x) for x in input().split()] for i in range(N)]

dp=[[0,0,0] for i in range(N+1)]


for i in range(1,N+1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            dp[i][j]=max(dp[i][j],dp[i-1][k]+act[i][j])
print(max(dp[N]))

Measured memory_bytes: 77144
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int dp[110][10010];

int main(){
    int N,W;
    cin>>N>>W;
    vector<int> w(N),v(N);
    for (int i = 0; i < N; ++i) {
        cin>>v[i]>>w[i];
    }

    memset(dp,0, sizeof(dp));
    for (int i = 1; i <=N ; ++i) {
        for (int j = 0; j <=W; ++j) {
            dp[i][j]=dp[i-1][j];
            if(j>=w[i-1]){
                dp[i][j]=max(dp[i][j],dp[i][j-w[i-1]]+v[i-1]);
            }
        }
    }

    int ans=-1;

    for (int i = 0; i <= W; ++i) {
        ans=max(ans,dp[N][i]);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 7408
import itertools

N = int(input())
P = str(input()).split(" ")
Q = str(input()).split(" ")

#順列の組み合わせすべてを生成して数値として格納
All = []

for i in itertools.permutations(P):
    stack = ""
    for j in i :
        stack = stack + j
    All.append(int(stack))

All.sort()

#Pを数値化
stack = ""
for i in P:
    stack = stack + i
P = int(stack)
#Qを数値化
stack = ""
for i in Q:
    stack = stack + i
Q = int(stack)

#インデックスを取得
P = All.index(P)+1
Q = All.index(Q)+1

print(abs(P-Q))

Measured memory_bytes: 4888
flag = True
while flag == True:
    numbers = [int(i) for i in input().split()]
    x = numbers[0]
    y = numbers[1]
    if x == 0 and y == 0:
        flag == False
        break
    elif x > y :
        print(y, x)
    else :
        print(x, y)
    


Measured memory_bytes: 5620
h,w,k=map(int,input().split())
a=[input() for _ in range(h)]
ans=0
for H in range(2**h):
    for W in range(2**w):
        c=0
        for i in range(h):
            for j in range(w):
                if H>>i&1 and W>>j&1 and a[i][j]=="#":
                    c+=1
        if c==k:
            ans+=1
print(ans)

Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;

struct SegTree{
	int size;
	vector<int> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = 0;
	}
	
	void update(int i, int val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = seg[i*2] + seg[i*2+1];
		}
	}

	int query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return 0;
		if(a <= l && r <= b) return seg[k];
		int lval = query(a, b, k*2, l, (l+r)/2);
		int rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return lval + rval;
	}
	int query(int a, int b)
	{
		if(a > b) return 0;
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint n;
llint a, b;
llint p[5005], pos[5005];
llint dp[5005][5005];
SegTree seg(13);

int main(void)
{
	cin >> n >> a >> b;
	for(int i = 1; i <= n; i++){
		cin >> p[i];
		pos[p[i]] = i;
	}
	
	for(int i = 1; i <= n; i++) seg.update(i, 1);
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= n; j++){
			if(pos[i+1] <= j) dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			else{
				dp[i+1][j] = min(dp[i+1][j], dp[i][j] + b);
				dp[i+1][pos[i+1]] = min(dp[i+1][pos[i+1]], dp[i][j] + a*seg.query(j+1, pos[i+1]-1));
			}
		}
		seg.update(pos[i+1], 0);
	}
	
	/*for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	
	
	llint ans = inf;
	for(int i = 0; i <= n; i++) ans = min(ans, dp[n][i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 195968
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>

#define REP(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;

int main() {
    string str;
    int a[4];
    cin >> str;

    REP(i, 0, 4) {
        a[i] = str[i] - '0';
    }
    REP(i, 0, 8) {
        int b[4], k;
        b[0] = a[0];
        k = i;
        REP(j, 1, 4) {
            if ((k % 2) == 1) {
                b[j] = -1 * a[j];
            } else {
                b[j] = a[j];
            }
            k = k >> 1;
        }
        if (b[0]+b[1]+b[2]+b[3] == 7) {
            cout << b[0];
            REP(s, 1, 4) {
                if (b[s] >= 0) {
                    cout << '+' << b[s]; 
                } else {
                    cout << '-' << -1 * b[s];
                }
            }
            cout << "=7" << '\n';
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int, input().split(" "))))
counter = [0 for i in range(10 ** 5 + 2)]
ans = 0

for i in range(n):
  counter[a[i]] += 1
#print(counter)
for i in range(1, 10 ** 5 + 1):
  temp = sum(counter[i-1:i+2])
  ans = max(ans, temp)
print(ans)

Measured memory_bytes: 20764
#include <iostream>

#define MAX_H 50

int H, W;
std::string s[MAX_H];

char compute(int i, int j) {
    int dx[] = {-1, -1,  0,  1,  1,  1,  0, -1};
    int dy[] = { 0, -1, -1, -1,  0,  1,  1,  1};
    int res = 0;
    if (s[i][j] == '#') return '#';
    for (int k=0; k<8; ++k) {
        int x = i+dx[k], y = j+dy[k];
        if (0 <= x && x < H && 0 <= y && y<W && s[x][y] == '#') ++res;
    }
    return '0' + res;
}

void solve() {
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            std::cout << compute(i, j);
        }
        std::cout << std::endl;
    }
}

int main() {
    std::cin >> H >> W;
    for (int i=0; i<H; ++i) std::cin >> s[i];
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 1e6 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, a[N], f[N], inv[N], lst[N];

int bp(int a, int n) {
  int ans = 1;
  while(n) {
    if (n & 1) ans = mult(ans, a);
    a = mult(a, a);
    n >>= 1;
  }
  return ans;
}

int cnk(int n, int k) {
  int ans = mult(f[n], inv[k]);
  ans = mult(ans, inv[n - k]);
  return ans;
}

void solve() {
  cin >> n;
  f[0] = inv[0] = 1;
  for (int i = 1;i <= n + 1;i++) {
    f[i] = mult(f[i - 1], i);
    inv[i] = bp(f[i], mod - 2);
  }
  int len = 0;
  for (int i = 1;i <= n + 1;i++) {
    cin >> a[i];
    if (lst[a[i]]) {
      len = i - lst[a[i]] + 1;
    }
    lst[a[i]] = i;
  }
  len = n + 1 - len;
  for (int i = 1;i <= n + 1;i++) {
    int tmp = cnk(n + 1, i);
    if (i - 1 <= len) add(tmp, mod - cnk(len, i - 1));
    cout << tmp << endl;
  } 
}

int main() {
  #ifdef wws
   freopen("in", "r", stdin);
  // freopen("out", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
        cin>>n;
        if(n>=30)
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    return 0;
}

Measured memory_bytes: 3632
require "prime"
def gcd(a,b)
  if b == 0
    a
  else
    gcd(b,a%b)
  end
end

def divisors(n)
  b = Array.new
  for i in 1..((n**0.5))
    if n % i == 0
      b.push(i)
    end
  end
  len = b.length
  len.times{|i|
    if n/b[len-1-i] != b[len-1-i]
      b.push(n/b[len-1-i])
    end
  }
  b
end

a, b = gets.chomp.split(" ").map(&:to_i)
gcd = gcd(a,b)
divisors = divisors(gcd)
ans = 0
divisors.each do |x|
  if Prime.prime?(x)
    ans += 1
  end
end
puts ans + 1

Measured memory_bytes: 4348
#include <iostream>

using namespace std;

int dp[101][10001];
int main()
{
  int N, W, i, j, ans = 0;
  cin >> N >> W;
  int v[N + 1], w[N + 1];

  for (i = 0; i < N; i++){
    cin >> v[i] >> w[i];
  }
  for (i = 0; i < N; i++){
    for (j = 0; j <= W; j++){
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    }
    for (j = 0; j <= W; j++){
      if (j + w[i] <= W){
        dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
      }
    }
  }
  for (i = 0; i <= W; i++){
    ans = max(ans, dp[N][i]);
  }
  cout << ans << endl;

  return (0);
}

Measured memory_bytes: 5072
#include <iostream>

int main()
{
  long long H, W;
  std::cin >> H >> W;
  if (H > 1 && W > 1) {
	  if ((H*W) % 2 == 0) std::cout << H*W / 2 << std::endl;
	  else std::cout << 1 + H*W / 2 << std::endl;
  }
  else std::cout << 1 << std::endl;
  return 0;
}


Measured memory_bytes: 3556
import bisect
A, B, Q = [int(x) for x in input().split()]
INF = 10**18
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
x = [int(input()) for _ in range(Q)]

for q in range(Q):
    xx = x[q]
    b, d = bisect.bisect_right(s, xx), bisect.bisect_right(t, xx)
    res = INF
    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            d1, d2 = abs(S-xx) + abs(T-S), abs(T-xx) + abs(S-T)
            res = min(res, d1, d2)
    print(res)


Measured memory_bytes: 16144
N = int(input())
S = input()


left = [0] * N
right = [0] * N

for i in range(0, N):
    if i == 0:
       if S[i] == 'W':
           left[i] = 1
    else:
        if S[i] == 'W':
            left[i] = left[i-1] + 1
        else:
            left[i] = left[i-1]

for i in reversed(range(0, N)):
    if i == N - 1:
        if S[i] == 'E':
            right[i] = 1
    else:
        if S[i] == 'E':
            right[i] = right[i+1] + 1
        else:
            right[i] = right[i+1]

ans = 300010
for i in range(0,N):
    if i == 0:
        ans = min(ans, right[i+1])
    elif i == N -1:
        ans = min(ans, left[i-1])
    else:
        ans = min(ans, left[i-1] + right[i+1])


print(ans)

Measured memory_bytes: 17640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_130
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }
        static void Main(string[] args)
        {
            var NX = Sarray();
            var N = NX[0];
            var X = NX[1];
            var Li = Sarray();

            var Di_1 = 0;
            for (var i = 0; i < N; ++i)
            {
                var Di = Di_1 + Li[i];
                if (X < Di)
                {
                    WriteLine(i + 1);
                    return;
                }
                Di_1 = Di;
            }
            WriteLine(N + 1);
        }
    }
}

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

constexpr long long MOD = 1'000'000'007;

class binomial_coefficients {
	long long MAX_VAL;
	vector<long long> fac, mmi;

public:

	binomial_coefficients(){
	}
	
	binomial_coefficients(long long num){
		init(num);
	}
	
	~binomial_coefficients(){
		
	}
	
	void init(long long num){
		MAX_VAL = num+1; 
		fac.resize(MAX_VAL);
		mmi.resize(MAX_VAL);
		
		factorial_mod();
		modular_multiplicatibe_inverse();
	}
	
	void factorial_mod(){
		 fac[0] = 1;
		for(long long i = 1; i < MAX_VAL; fac[i] %= MOD, i++)
			fac[i] = fac[i - 1] * (i % MOD);
	}
	
	long long power(long long x, long long n){
		long long ans = 1;
		for(;n;n >>= 1, x *= x, ans %= MOD, x %= MOD)
			if(n&1)ans*=x;
		return ans % MOD;
	}
	
	void exgcd(long long a, long long b, long long &x, long long &y){
		if(b == 0){
			x = 1;
			y = 0;
			return ;
		}
		exgcd(b, a % b, y, x);
		y -= a / b * x;
	}
	
	void modular_multiplicatibe_inverse(){
		long long x, y;  
		exgcd(fac[MAX_VAL - 1], MOD, x, y);
		mmi[MAX_VAL-1] = (x % MOD + MOD) % MOD;
		// mmi[MAX_VAL-1] = power(fac[MAX_VAL-1], MOD-2);
		for(long long i = MAX_VAL - 2; i >= 0; mmi[i]%=MOD, i--)
			mmi[i] = mmi[i + 1] * ((i + 1) % MOD);
	}
	
	long long combination(long long n, long long r){
		return r < 0 ? 0 :n < r ? 0 :fac[n] * (mmi[r] * mmi[n-r] % MOD) % MOD;
	}
};


int main(){
	
	long long n, k;
	long long ans = 0;
	binomial_coefficients bc;
	vector<long long> dp;
	
	cin>>n>>k;
	
	if(n <= k) ans = 1;
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3116
#include <iostream>

using std::cin;
using std::cout;

int main(int argc, char* argv[]) {
  int n, k;
  cin >> n >> k;

  int count = 0;
  for (int i = 0; i < n; ++i) {
    int h;
    cin >> h;
    if (h >= k) {
      ++count;
    }
  }

  cout << count;

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{

int a[10000], min, max, n, i;
long long sum = 0;
scanf("%d", &n);//1以上が入力されるものとします
for(i = 0; i < n; i++){
scanf("%d", &a[i]);
sum += a[i];
}
max = min = a[0];//とりあえず最初の要素をセットしておく
for(i = 1; i < n; i++){//2番目以降の要素と比較
if(a[i] > max)max = a[i];
if(a[i] < min)min = a[i];
}
printf("%d %d %lld\n", min, max, sum);

return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 1000000
#define NIL -1

typedef struct{
  int pre;
  int left;
  int right;
} Node;

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].pre);
  printf("depth = %d, ",D[u]);

  if(T[u].pre == NIL) printf("root, ");
  else if(T[u].left == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = T[u].left; c != NIL; i++, c = T[c].right){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u, int p){
  D[u] = p;
  if(T[u].right != NIL) rec(T[u].right, p);
  if(T[u].left != NIL) rec(T[u].left, p+1);
}

int main(){
  int i, j, d, v, c, l, r;

  scanf("%d",&n);
  for(i = 0; i < n; i++) T[i].pre = T[i].left = T[i].right = NIL;

  for(i = 0; i < n; i++){
    scanf("%d%d",&v,&d);
    for(j = 0; j < d; j++){
      scanf("%d",&c);
      if (j == 0) T[v].left = c;
      else T[l].right = c;
      l = c;
      T[c].pre = v;
    }
  }

  for(i = 0; i < n; i++){
    if(T[i].pre == NIL) r = i;
  }

  rec(r,0);
  for(i = 0; i < n; i++) print(i);
  
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
struct Input {
    ll h, p;
    ll val() const {
        return h + p;
    }
};
bool operator<(const Input& in1, const Input& in2) {
    return in1.val() < in2.val();
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<Input> v;
    rep(i, n) {
        ll h, p; cin >> h >> p;
        v.pb({h, p});
    }
    sort(all(v));
    vector<vector<ll>> dp(n+1, vector<ll>(n+1, linf));
    dp[0][0] = 0;
    rep(i, n) rep(j, n+1) {
        if (dp[i][j] == linf) continue;
        chmin(dp[i+1][j], dp[i][j]);
        if (v[i].h >= dp[i][j]) {
            chmin(dp[i+1][j+1], dp[i][j]+v[i].p);
        }
    }
    ll ans = 0;
    rep(i, n+1) if (dp[n][i] < linf) chmax(ans, i);
    cout << ans << endl;
}


Measured memory_bytes: 198016
#include <iostream>
#include <string>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;

int main(){
  string s;
  cin >> s;
  int a[26];
  bool flag = false;
  
  rep(i,26){
	a[i] = 0;
  }
  
  rep(i,s.size()){
    a[s[i]-97]++;
  }
  
  rep(i,26){
	if(a[i] % 2 != 0){
		flag = true;
    }
  }
  
  if(flag){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
  return 0;
}
  
  
  

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

int main() {
	// your code goes here
	char x,y;
	cin >> x >> y;
	if(x-y>0){
		cout << ">" << endl;
	}
	else if(x==y){
		cout << "=" << endl;
	}
	else cout << "<" << endl; 
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <stdexcept>
// #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; i++)
#define rep1(i,h) for(int i = 0; i <= h; i++)
#define rep2(i,n,h) for(int i = n; i < h; i++)
#define rep3(i,n,h) for(int i = n; i <= h; i++)

using namespace std;


int main(void) {
  ll a,b,c,d,gcd;
  cin >> a >> b >> c >> d;
  ll sum = b - a + 1, cd = c * d;
  ll maxMulOfC = b / c, maxMulOfD =  b / d;
  ll minMulOfC = (a - 1) / c, minMulOfD = (a - 1) / d;
  if(c > d) {
      ll r = c % d;
      while(r != 0) {
          c = d;
          d = r;
          r = c % d;
      }
       gcd = d;
  } else {
      ll r = d % c;
      while(r != 0) {
          d = c;
          c = r;
          r = d % c;
      }
       gcd = c;
  }

  // Least common multiple(lcm)　* Greatest common divisor(gcd)　= a * b
    ll lcm = cd / gcd;
    ll maxMulOfAB = b / lcm;
    ll minMuxOfAB = (a-1) / lcm;
  ll ans = sum - (maxMulOfC - minMulOfC) - (maxMulOfD - minMulOfD) + (maxMulOfAB - minMuxOfAB);
  cout << ans << endl;
    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,a;

int main(){
	cin>>n>>a;
	cout<<n*n-a<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    char a;
    cin >> a;
    if(a > 93) {
        cout << 'a' << endl;
    } else {
        cout << "A" << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<string, string> P;

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

    string s1 = s.substr(0, N);
    string s2 = s.substr(N, N);
    reverse(s2.begin(), s2.end());

    //cout << s1 << " " << s2 << endl;

    map<P, ll> mp;

    //s1
    for(int msk = 0; msk < (1 << N); msk++){
        string red = "";
        string blue = "";
        for(int i = 0; i < N; i++){
            if(msk & (1 << i)){
                red += s1[i];
            } else {
                blue += s1[i];
            }
        }

        mp[P(red, blue)]++;
    }

    ll ans = 0;

    //s2
    for(int msk = 0; msk < (1 << N); msk++){
        string red = "";
        string blue = "";
        for(int i = 0; i < N; i++){
            if(msk & (1 << i)){
                red += s2[i];
            } else {
                blue += s2[i];
            }
        }

        ans += mp[P(red, blue)];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 91904
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pque = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

int main() {
	ll n, s;
	cin >> n >> s;
	for (ll i = 2; i <= ten(6); i++) {
		ll sum = 0;
		ll tmp = n;
		while (tmp > 0) {
			sum += tmp % i;
			tmp /= i;
		}
		if (sum == s) {
			cout << i << '\n';
			return 0;
		}
	}
	for (ll i = ten(6); i >= 1; i--) {
		ll c = s - i;
		ll b = n - c;
		if (b % i != 0 || c < 0) continue;
		b /= i;
		if (i >= b || c >= b) continue;
		cout << b << '\n';
		return 0;
	}
	if (n == s) {
		cout << n + 1 << '\n';
		return 0;
	}
	fail();
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans=0;
    int i=0;
    while(1){
        i++;
        if(i*i<=n)ans=i*i;
        else break;
    }
    
    cout << ans;
    
	return 0;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 20:41:22 2020

@author: liang
"""
"""
float => int への変換誤差あり。
scipy.special.comb()は返り値がfloat
math.factorial()で自分で実装する。（大きな値のとき）
"""
#from scipy.special import comb
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#D
key = 10**9 + 7
S = int(input())

#かご
n = S//3

ans = 0
for i in range(1,n+1):
    #玉
    a = S - 3*i 
    #tmp = int(comb(i-1+a,i-1))
    tmp = combinations_count(i-1+a,i-1)
    tmp %= key
    ans += tmp
    ans %= key
    #print("print:",i,ans,tmp)
print(ans)

Measured memory_bytes: 9212
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A[200000], B[200000], B_mod[200000];
    cin >> N;
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    
    int ans = 0;
    REP(k, 29) {
        REP(i, N) B_mod[i] = B[i] % (1 << (k + 1));
        sort(B_mod, B_mod + N);

        int count = 0;
        REP(i, N) {
            int a_mod = A[i] % (1 << (k + 1));
            count += lower_bound(B_mod, B_mod + N, ((1 << k) * 2) - a_mod)
                   - lower_bound(B_mod, B_mod + N, ((1 << k)    ) - a_mod);
            count += lower_bound(B_mod, B_mod + N, ((1 << k) * 4) - a_mod)
                   - lower_bound(B_mod, B_mod + N, ((1 << k) * 3) - a_mod);
        }
        ans |= (count & 1) << k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, alice=0, bob=0;

	cin>>n;

	vi a(n);

	rep(i, n) cin>>a[i];

	sort(all(a)); reverse(all(a));

	rep(i, n){
		if(i%2){
			bob+=a[i];
		}else{
			alice+=a[i];
		}
	}
	cout<<alice-bob<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define PI acos(-1)

int main(){
    int x,y,x2,y2;
    int x_d,y_d;
    cin >> x >> y >> x2 >> y2;
    x_d = x - x2;
    y_d = y - y2;
    cout << x2 + y_d << " " << y2 - x_d << " " << x + y_d << " " << y - x_d <<  endl;
}


Measured memory_bytes: 256
n,y=map(int,input().split())

en=False
for i in range(n+1):
    for q in range(n-i+1):
        cal=i*10000+q*5000+(n-i-q)*1000
        if cal==y:
            print(i,q,n-i-q)
            en=True
            break
    if en:
        break
if not en:
    print("-1 -1 -1")

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3][3], c[3][3];
    for(int i =0; i < 3;i++)
    {
        for(int j =0; j < 3; j++)
        {
            cin >> a[i][j];
            c[i][j] = 0;
        }
    }
    int n;
    cin >> n;
    int b;
    for(int i =0; i < n; i++)
    {
        cin >> b;
        int flag = 0;
        for(int k =0; k < 3; k++ )
        {
            for(int j =0; j < 3; j++)
            {
                if(a[k][j]==b && c[k][j]==0)
                {
                    c[k][j] = 1;
                    flag = 1;
                    break;
                }
            }
            if(flag == 1)
            {
                break;
            }
        }
    }
    bool res = false;
    for(int i =0; i < 3; i++)
    {
        if(c[i][0] == 1 && c[i][1] == 1 && c[i][2] == 1)
        {
            res = true;
            break;
        }
    }
    for(int i =0; i < 3; i++)
    {
        
        if(c[0][i] == 1 && c[1][i] == 1 && c[2][i] == 1)
        {
            res = true;
            break;
        }
    }
    if(c[0][0]==1 && c[1][1]== 1 && c[2][2]==1)
    {
        res = true;
    }
    else if(c[0][2]==1 && c[1][1]==1 && c[2][0]==1)
    {
        res = true;
    }
    if(res == true)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q;
    cin >> q;
    set<int> se;
    map<int, int> mp;
    int sum = 0;
    while(q--) {
        int t, x;
        cin >> t >> x;
        if(t == 0) {
            se.insert(x);
            sum++;
            cout << sum << '\n';
            mp[x]++;
        } else if(t == 1) {
            set<int>::iterator itr = se.find(x);
            cout << (itr != se.end()?mp[x]:0) << '\n';
        } else if(t == 2) {
            sum -= mp[x];
            se.erase(x);
            mp.erase(x);
        } else {
            int r;
            cin >> r;
            auto itr = se.lower_bound(x);
            for(;*itr <= r and itr != se.end(); itr = next(itr)) {
                rep(i, mp[*itr]) {
                    cout << *itr << '\n';
                }
            }
        }
    }
}


Measured memory_bytes: 16172
#include<stdio.h>
    int main(void){
    int a,b;
    
    scanf("%d",&a);
    scanf("%d",&b);
    
    if(a==b){
    printf("a == b\n");
    }
    else if(a>b){
    printf("a > b\n");
    }
    else{
    printf("a < b\n");
    }
    
    return 0;
    }



Measured memory_bytes: 1940
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;

  int x = a1 + a2 + a3;
  string ans;
  if (x <= 21) ans = "win";
  else ans = "bust";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((0<=(x-r) && (x+r)<=W && 0<=(y-r) && 0<=(y-r) && (y+r)<=H)){
		
		printf("Yes\n");
	}
	else{
		
		printf("No\n");
	}
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<=(n); i++)
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define gsort(x,n) sort(x,x+n,greater<int>())
#define rv(s) reverse((s).begin(),(s).end())
#define abs(a) llabs(a)
#define int int64_t
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define INF 1000000000;
     
int n,h[100005],mem[100005];

signed dp(int i){
    if(i == 1) return 0;
    if(i < 1) return INF;
    if(mem[i] != -1) return mem[i];

    int a1 = dp(i - 1) + abs(h[i-1] - h[i]);
    int a2 = dp(i - 2) + abs(h[i-2] - h[i]);
    
    return mem[i] = min(a1,a2);
}

signed main(){
    int n;
    cin >> n;
    
    memset(mem,-1,sizeof(mem));

    reps(i,n){
        cin >> h[i];
    }

    cout<<dp(n)<<'\n';
    return 0;
}


Measured memory_bytes: 4992