akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
	int a, b, c, x, d = 0;
	int i, j, k;
	do
		scanf("%d%d%d%d", &a, &b, &c, &x);
	while (c < 0 | b < 0 | a < 0 | a>50 | b>50 | c>50 | a + b + c < 1 | x < 50 | x>20000 | x % 50);
	for (i = 0; i <= a; i++)
		for (j = 0; j <= b; j++)
			for (k = 0; k <= c; k++)
				if (i * 500 + j * 100 + k * 50 == x)
					d++;
	printf("%d", d);
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 128
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
A,B = map(int,input().split())

# 100x100 で 上半分を".", 下半分を"#"で塗る
X = []
for i in range(100):
    if i<50:
        X.append(["."]*100)
    else:
        X.append(["#"]*100)

# 白
A = A-1 # 上半分が白なので, 白は既に1連結成分ある
# 下半分の黒エリアについて, 4x4 のうち1マスを必要な分だけ白で塗っていく
q,r = A//50, A%50
for i in range(q):
    for j in range(50):
        X[99-i*2][j*2] = "."
for i in range(r):
    X[51][i*2] = "."

# 黒
B = B-1 # 下半分が黒なので, 黒は既に1連結成分ある
# 上半分の白エリアについて, 4x4 のうち1マスを必要な分だけ黒で塗っていく
q,r = B//50, B%50
for i in range(q):
    for j in range(50):
        X[i*2][j*2] = "#"
for i in range(r):
    X[48][i*2] = "#"

print(100,100)
for x in X:
    print("".join(x))


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

void dpupd( int &ate, int cost ){
    ate = min( ate , cost );
}

int main() {

    int N,K;
    int h[100002];
    int dp[100002] = {};
    Scd2(N,K);
    Rep(i,N){
        Scd(h[i]);
    }
    fill(dp+1,dp+N,INF);
    // 貰うDP ( dp[ni] <- dp[ni-di] )
    Repe(ni,N,1){
        Rep(di,K){
            if( di+1 > ni ) break;
            dpupd( dp[ni] , dp[ni-di-1] + abs( h[ni] - h[ni-di-1] ));
        }
    }

    printf ("%d\n", dp[N-1] );

    return 0;
}




Measured memory_bytes: 1024
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

template<class T>
bool chmin(T &a, T b) {
    if(b<a) {
        a=b;
        return true;
    }
    return false;
}

ll H,W,L;
string maze[110];
struct State {
    int dir,y,x;
    ll cnt;
    State(int dir,int y,int x,ll cnt) :
        dir(dir),y(y),x(x),cnt(cnt){}
};

void solve(P &ans_p,int &ans_dir) {
    queue<State> que;
    map<char,int> dir;
    dir['E']=0;
    dir['S']=1;
    dir['W']=2;
    dir['N']=3;
    ll d[4][110][110];
    rep(y,110) rep(x,110) d[0][y][x]=d[1][y][x]=d[2][y][x]=d[3][y][x]=INF;
    rep(y,H) rep(x,W) if(maze[y][x]!='.'&&maze[y][x]!='#') {
        d[dir[maze[y][x]]][y][x]=0;
        que.push(State(dir[maze[y][x]],y,x,0));
    }

    while(que.size()) {
        State s=que.front(); que.pop();
        //printf("%d %d %d : %d\n",s.dir,s.y,s.x,s.cnt);
        if(L==s.cnt) {
            ans_p=P(s.y,s.x);
            ans_dir=s.dir;
            return;
        }
        if(d[s.dir][s.y][s.x]!=s.cnt) {
            //printf("%d %d %d : %d %d\n",s.dir,s.y,s.x,s.cnt,d[s.dir][s.y][s.x]);
            ll diff=abs(s.cnt-d[s.dir][s.y][s.x]);
            ll t=(L-s.cnt)/diff;
            if(t>0&&diff>0) {
                s.cnt+=(t-1)*diff;
            }
            //printf("\t%d\n",s.cnt);
        }
        int ny=s.y+dy[s.dir];
        int nx=s.x+dx[s.dir];
        if(!(0<=ny&&ny<H&&0<=nx&&nx<W)) {
            que.push(State((s.dir+1)%4,s.y,s.x,s.cnt));
            chmin(d[(s.dir+1)%4][s.y][s.x],s.cnt);
        }
        else {
            if(maze[ny][nx]=='#') {
                que.push(State((s.dir+1)%4,s.y,s.x,s.cnt));
                chmin(d[(s.dir+1)%4][s.y][s.x],s.cnt);
            }
            else {
                que.push(State(s.dir,ny,nx,s.cnt+1));
                chmin(d[s.dir][ny][nx],s.cnt+1);
            }
        }
    }
}

int main() {
    while(cin>>H>>W>>L) {
        if(H==0) break;
        rep(y,H) cin>>maze[y];
        P ans;
        int dir=-1;
        solve(ans,dir);
        if(dir==-1) int a=1/0;
        char d;
        if(dir==0) d='E';
        if(dir==1) d='S';
        if(dir==2) d='W';
        if(dir==3) d='N';
        printf("%d %d %c\n",ans.fr+1,ans.sc+1,d);
    }
    return 0;
}

Measured memory_bytes: 1624
#include<stdio.h>

int main(){
	int N, i = 0, M, sel;
	double s = 0;
	scanf("%d %d", &N, &M);
	sel = 0;
	int a[N];
	for(i = 0; i < N; i++){	
		scanf("%d", &(a[i]));
	}
	for(i = 0; i < N; i++){
		s += a[i];
	}
	s = s / (4 * (double)M);
	for(i = 0; i < N; i++){	
		if( s <= a[i]) sel++;
	}
	if(sel >= M){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
double L;
int main()
{
    scanf("%lf", &L);
    printf("%10f", pow(L/3.0, 3.0));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int> > Matrix;
const int MOD = 1e9+7;


int main(){
  int n; cin>>n;
  string s,t,res=""; cin>>s>>t;

  REP(i,n){
   res+=s[i];
     res+=t[i];
  }
  cout<<res<<endl;
  
}

Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(2):
  a=list(map(int,input().split()))
  A.append(a)

dp=[[0 for i in range(N)] for j in range(2)]

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

dp[1][0] = A[0][0]+A[1][0]
for j in range(1,N):
  dp[1][j]=A[1][j]+max(dp[1][j-1],dp[0][j])

print(dp[1][N-1])

Measured memory_bytes: 9216
import java.util.*
 
fun main(args: Array<String>) {
  
  var line = readLine()!!.split(" ")!!
  var a = line[0].toInt()!!
  var b = line[1].toInt()!!

  if ((a+b)%2 == 0){
    println((a+b)/2)
  }else {
    println("IMPOSSIBLE")
  }
 
}

Measured memory_bytes: 37736
import heapq
N, M = map(int, input().split())
A = list(map(lambda a: int(a) * (-1), input().split()))
heapq.heapify(A)
for m in range(M):
    tmp = heapq.heappop(A)
    tmp = int(tmp / 2)
    heapq.heappush(A, tmp)
print(sum(A) * -1)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int N, H, W, A, B;
  cin >> N >> H >> W;

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    cin >> A >> B;
    if (A >= H && B >= W) cnt++;
  }

  cout << cnt << endl;
}

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

int main() {
    int n;

    while(1) {
        cin >> n;
        if(n == 0) break;

        string str[n];
        vector<vector<int>> vec(10);

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

        if(n == 1) {
            cout << str[0] << endl;
            continue;
        }

        for(int i = n-1; i >= 0; i--) {
            int l = str[i].length()-1;
            if(str[i][l] == '+' || str[i][l] == '*') {
                int tmp;
                if(str[i][l] == '+') {
                    tmp = 0;
                    for(int j = 0; j < vec[l+1].size(); j++) {
                        tmp += vec[l+1][j];
                    }
                }
                else if(str[i][l] == '*') {
                    tmp = 1;
                    for(int j = 0; j < vec[l+1].size(); j++) {
                        tmp *= vec[l+1][j];
                    }
                }
                vec[l].push_back(tmp);
                vec[l+1].clear();
            }
            //数字の時
            else {
                vec[l].push_back((int)(str[i][l]-'0'));
            }        
        }
        cout << vec[0][0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
N = int(input())
A = [0 for n in range(N)]
XY = [0 for n in range(N)]
count_max = 0

for i in range(N):
  A[i] = int(input())
  xy = []
  for j in range(A[i]):
    x_y = list(map(int,input().split()))
    xy.append(x_y)
  XY[i] = xy

for i in range(2 ** N):
  op = [0]*N
  for j in range(N):  # ポイント１
    if ((i >> j) & 1):
      op[N-1-j] = 1
      
  flag = True
  
  for k in range(len(op)):
    if op[k] == 1:
      for l in range(A[k]):
        if XY[k][l][1] != op[XY[k][l][0]-1]:
          flag = False
        
  if flag:
    if sum(op) > count_max:
      count_max = sum(op)

print(count_max)

Measured memory_bytes: 9236
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n=int(input())

if n==1:
    print(0)
else:
    result=factorization(n)
    primes=len(result)
    
    ans=0
    for i in range(primes):
        tmp=result[i][1]
        cnt=0
        j=1
        while 1:
            tmp-=j
            if tmp>=0:
                cnt+=1
            else:
                break
            j+=1
        
        ans+=cnt

    print(ans)

Measured memory_bytes: 63372
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(), T = sc.nextInt(), A = sc.nextInt();
        int ans = 0;
        double min = 1e9;
        for (int n = 0; n < N; n++) {
            int h = sc.nextInt();
            double t = (double)T - (double)h * 0.006;
            double f = Math.abs(A - t);
            if (min > f) { min = f; ans = n + 1; }
        }
        sc.close();
        System.out.println(ans);
    }
}

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

using namespace std;

bool isValidVect(vector<int> &A){

  int s = A.size();
  int i0 = s % 2;

  if(i0 == 1 && A[0] != 0){
    return false;
  }

  for(int i = i0; i < s; i+=2){
    if(A[i] != i+1 || A[i+1] != i + 1){
      return false;
    }
  }

  return true;

}

int main() {
  int N;
  cin >> N;
  vector<int> A;

  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    A.push_back(a);
  }

  sort(A.begin(), A.end());
  if(!isValidVect(A)){
    cout << 0 << endl;
  } else {
    int p = A.size() / 2;
    long result = 1;
    for(int i = 0; i < p; i++){
      result *= 2;
      if(result > 1000000007){
        result %= 1000000007;
      }
    }
    cout << result << endl;
  }

  return 0;
}

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

const int T=1000000;

int main(){
    int n,k,i;
    int max=0;
    int A[T];
    scanf("%d %d", &k,&n);
    for(i=0;i<n;i++) scanf("%d", &A[i]);
    for(i=0;i<n-1;i++){
        if(max<A[i+1]-A[i]) max=A[i+1]-A[i];
    };
    if(max<k-(A[n-1]-A[0])) max=k-(A[n-1]-A[0]);

    printf("%d\n", k-max);
    return 0;
}

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

int main(){
  int k, s;
  cin >> k >> s;

  int cnt=0;
  for(int x=0; x<=k; x++){
    for(int y=0; y<=k; y++){
      if(0<=s-(x+y) && s-(x+y)<=k) cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
use std::collections::HashSet;

fn main() {
    let v = read_vec::<i32>();
    let a = v[0];
    let b = v[1];
    let k = v[2];

    let mut hs = HashSet::new();
    for i in 0..k {
        if a + i > b {
            break;
        }
        hs.insert(a+i);
    }
    for j in 0..k {
        if b - j < a {
            break;
        }
        hs.insert(b-j);
    }
    let mut ans = hs.into_iter().collect::<Vec<_>>();
    ans.sort();
    for x in ans {
        println!("{}", x);
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

MOD = 10**9+7
N = int(input())
dic = defaultdict(int)
zero = 0
for i in range(N):
    a, b = map(int, input().split())
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b == 0:
        zero += 1
        continue
    elif a == 0:
        b = 1
    elif b == 0:
        a = 1
    g = math.gcd(a, b)
    a //= g
    b //= g
    dic[a,b] += 1
done = set()
ans = 1
for a,b in dic:
    k = (a, b)
    if k in done: continue
    c, d = -b, a
    if d <= 0:
        c = -c
        d = -d
    rk = (c, d)
    done.add(k)
    done.add(rk)
    c = pow(2, dic[k], MOD)-1
    if rk in dic:
        c += pow(2, dic[rk], MOD)-1
    c += 1
    ans *= c
    ans %= MOD
print((ans+zero-1)%MOD)


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

  for(long long i = 0; i < N; i++) { 
    cin >> A[i];
    if(A[i] == 0) { cout << 0; return 0; }
  }

  unsigned long long ans = 1;

  for(int i = 0; i < N; i++) {
    if(1000000000000000000 / ans < A[i]) {
      cout << -1; return 0;
    }
    else {
      ans *= A[i];
    }
  }

  cout << ans;


  return 0;
  }

Measured memory_bytes: 3956
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
#define MAX 200010

int main(){
  int n;
  scanf("%d",&n);
  int i,a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);    
  }
  int dp0[n],dp1[n];
  dp0[0]=0;
  for(i=1;i<n;i++){
    dp0[i]=dp0[i-1]<a[i-1]?a[i-1]:dp0[i-1];
  }
  dp1[n-1]=0;
  for(i=n-2;i>=0;i--){
    dp1[i]=dp1[i+1]<a[i+1]?a[i+1]:dp1[i+1];
  }
  for(i=0;i<n;i++){
    printf("%d\n",dp0[i]<dp1[i]?dp1[i]:dp0[i]);
  }
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n, k;
    string s;
    cin >> n >> s >> k;

    char p = s[k-1];
    rep(i, n){
        if(s[i] != p) s[i] = '*';
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner((System.in));
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        if(k==1){
            System.out.println("0");
        }else{
            System.out.println(n- k);
        }
    }
}


Measured memory_bytes: 21844
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

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

  if (a == b && b == c) {
    if (a % 2 == 0) cout << -1 << endl;
    if (a % 2 == 1) cout <<  0 << endl;
  }
  else {
    int res = 0;
    while (true) {
      if((a&1) || (b&1) || (c&1)) { cout << res << endl; return 0; }
      res++;
      int A = (b+c)/2;
      int B = (c+a)/2;
      int C = (a+b)/2;

      a = A; b = B; c = C;
    }
  }
  return 0;
}

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

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


Measured memory_bytes: 3120
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N, K, Q;
    cin >> N >> K >> Q;
    vl people(N, 0);
    rep(i, Q){
        ll a;
        cin >> a;
        a--;
        people[a]++;
    }
    rep(i, N){
        if(0 >= K - (Q-people[i])){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
}

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

int N;
vector<int> v;
int ub;

int f(int n, int rest, int i) {
  if(n > ub) return ub;
  if(rest == 0) return n;
  if(i == v.size()) return 1e9;
  int ans = 1e9;
  for(int j = 0; j*v[i] <= rest; j++) {
    ans = min(ans, f(n+j, rest-j*v[i], i+1));
  }
  return ans;
}

int main () {
  cin >> N;

  v.push_back(1);
  for(int x = 6; x <= N; x *= 6) {
    v.push_back(x);
  }
  for(int x = 9; x <= N; x *= 9) {
    v.push_back(x);
  }
  sort(v.begin(), v.end());

  ub = 0;
  int m = N;
  while(m > 0) {
    int i = distance(v.begin(), upper_bound(v.begin(), v.end(), m)) - 1;
    m -= v[i];
    ub++;
  }

  cout << f(0, N, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
a = [None]*n
b = [None]*m
for i in range(n):
  a[i] = input()
for j in range(m):
  b[j] = input()
r = 'No'
for i in range(n - m + 1):
  end_yoko = i + m
  a_t = [s[i:end_yoko] for s in a]
  for j in range(n - m + 1):
    end_tate = j + m
    if a_t[j:end_tate] == b:
      r = 'Yes'
print(r)

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

int main() {
  int g;
  vector<int> v;
  while (cin >> g) {
    while (g) {
      int i = 1;
      while (g >= i * 2) {
        i *= 2;
      }
      v.push_back(i);
      g -= i;
    }
    
    for (int i = v.size() - 1; i >= 0; i--) {
      if (!i) {
        cout << v.at(i) << endl;
      } else {
        cout << v.at(i) << " ";
      }
    }
    v.clear();
  }
}



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

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

    int num = 0;
    for(int i=0;i<N;i++){
        if(a[i] == num + 1)
            num++;
    }

    if(num == 0)
        cout << -1 << endl;
    else
        cout << N - num << endl;

}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    static int MOD = 1000000007;
	static int INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        sc.close();

        String res = "";
        for (int i = 0; i < n; i++) {
            res += String.valueOf(s.charAt(i)) + String.valueOf(t.charAt(i));
        }
        
        System.out.println(res);
    }
}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();

		if(A + B < 10) {
			System.out.println(A + B);
		}else {
			System.out.println("error");
		}
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)
int main()
{
	int n, d[105],s=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&d[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			s+=d[i]*d[j];
		}
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 888
import queue

H,W=map(int,input().split())
c=["#"*(W+2)]+["#"+input()+"#" for _ in range(H)]+["#"*(W+2)]

ans=0
e=True
for i in range(1,H+1):
    for g in range(1,W+1):
        if c[i][g]==".":
            MAX=0
            dist=[[-1]*(W+2) for _ in range(H+2)]
            que=queue.Queue()
            que.put((i,g))
            dist[i][g]=0

            while not que.empty():
                h,w=que.get()
                direction=[(0,-1),(0,1),(1,0),(-1,0)]
                for y,x in direction:
                    if c[h+y][w+x]=="." and dist[h+y][w+x]==-1:
                        que.put((h+y,w+x))
                        dist[h+y][w+x]=dist[h][w]+1
                        MAX=max(MAX,dist[h+y][w+x])
            ans=max(MAX,ans)
print(ans)

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

#define LL long long
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    LL n, m; cin >> n >> m; int a[m];
    map<int, int> mp;
    for(int &i : a) cin >> i, mp[i]++;
    LL dp[n+1]={};

    dp[0] = 1LL; dp[1] = !(mp[1]);
    for(int i = 2; i <= n; i++) {
        if(mp[i]) continue;
        (dp[i] += dp[i-1] + dp[i-2]) %= mod;
    }    
    cout << dp[n];
}

Measured memory_bytes: 9488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),Q = in();
    vector<int> A(N+1);
    char before = 'd';
    string S = in<string>();
    REP(i,N){
        if(before == 'A' && S[i] == 'C'){
            A[i+1] = A[i] + 1;
        }else{
            A[i+1] = A[i];
        }
        before = S[i];
    }
    REP(i,Q){
        int f = in(),l = in();
        cout << A[l] - A[f] << "\n";
    }
}

Measured memory_bytes: 1488
import java.util.*;

class Main {
        public static void main(String args[]) {
                boolean[] prime = new boolean[1000001];
                prime[0] = true;
                prime[1] = true;
                for (int i = 0; i < 1000001; i++) {
                        if (!prime[i]) {
                                int j = 2;
                                while (i * j < 1000001) {
                                        prime[i * j] = true;
                                        j++;
                                }
                        }
                }
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                long n = sc.nextLong(), x = sc.nextLong();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                long ans = -1;
                                boolean[] vs = new boolean[(int)x + 1];
                                vs[0] = true;
                                for (long i = 0; i < n; i++) {
                                        long v = sc.nextLong();
                                        for (long j = 0; j <= x - v; j++) {
                                                if (vs[(int)j]) {
                                                        vs[(int)(j + v)] = true;
                                                        if (!prime[(int)(j + v)]) {
                                                                ans = Math.max(j + v, ans);
                                                        }
                                                }
                                        }
                                }
                                if (ans == -1) {
                                        System.out.println("NA");
                                } else {
                                        System.out.println(ans);
                                }
                        }
                }
        }
}

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

using namespace std;
int main(void){
   int n,a;
   std::vector<int> v;
   cin >> n;
   for (int i=0;i<n;i++) {
       cin >> a;
       v.push_back(a);
   }
   for (int j=0;j<n;j++) {
       if (j!=n-1) {
           cout << v[n-1-j] << " ";
       } else {
           cout << v[0] << endl;
       }
   }
}



Measured memory_bytes: 3072
#include <iostream>

using namespace std;

template<typename T>
class DoubleLinkList
{
private:
	struct Node
	{
		T value;
		Node* pNext;
		Node* pPrev;
	};
public:
	DoubleLinkList()
	{
		m_pHead = new Node();
		m_pTail = new Node();
		
		m_pHead->pPrev = 0;
		m_pHead->pNext = m_pTail;
		m_pTail->pPrev = m_pHead;
		m_pTail->pNext = 0;

		m_size = 0;
	}

	~DoubleLinkList()
	{
		Node* pCurrent = m_pHead;
		while (pCurrent)
		{
			Node* pNext = pCurrent->pNext;
			delete pCurrent;
			pCurrent = pNext;
		}

		m_pHead = 0;
		m_pTail = 0;
	}

	void Insert(const T& value)
	{
		Node* pNew = new Node();
		pNew->value = value;

		m_pHead->pNext->pPrev = pNew;
		pNew->pPrev = m_pHead;

		pNew->pNext = m_pHead->pNext;
		m_pHead->pNext = pNew;

		++m_size;
	}

	void Delete(const T& value)
	{
		if (!m_pHead) return;

		Node* pCurrent = m_pHead->pNext;
		while (pCurrent)
		{
			if (value == pCurrent->value)
			{
				Node* pPrev = pCurrent->pPrev;
				Node* pNext = pCurrent->pNext;
				pPrev->pNext = pNext;
				pNext->pPrev = pPrev;
				delete pCurrent;
				break;
			}
			pCurrent = pCurrent->pNext;
		}

		--m_size;
	}

	void DeleteFirst()
	{
		if (IsEmpty()) return;

		Node* pDelete = m_pHead->pNext;
		Node* pPrev = pDelete->pPrev;
		Node* pNext = pDelete->pNext;
		pPrev->pNext = pNext;
		pNext->pPrev = pPrev;
		delete pDelete;

		--m_size;
	}

	void DeleteLast()
	{
		if (IsEmpty()) return;

		Node* pDelete = m_pTail->pPrev;
		Node* pPrev = pDelete->pPrev;
		Node* pNext = pDelete->pNext;
		pPrev->pNext = pNext;
		pNext->pPrev = pPrev;
		delete pDelete;

		--m_size;
	}

	bool IsEmpty()
	{
		return 0 == m_size;
	}

	void Print()
	{
		if (IsEmpty()) return;

		Node* pCurrent = m_pHead->pNext;
		while (pCurrent && pCurrent != m_pTail)
		{
			cout << pCurrent->value << (pCurrent->pNext == m_pTail ? "\n" : " ");
			pCurrent = pCurrent->pNext;
		}
	}

private:
	Node* m_pHead = 0;
	Node* m_pTail = 0;
	int m_size = 0;
};

int main()
{
	DoubleLinkList<int> intList;

	int n;
	cin >> n;
	string command;
	int value;
	for (int i = 0; i < n; ++i)
	{
		cin >> command;
		
		if ("insert" == command)
		{
			cin >> value;
			intList.Insert(value);
		}
		else if ("delete" == command)
		{
			cin >> value;
			intList.Delete(value);
		}
		else if ("deleteFirst" == command)
			intList.DeleteFirst();
		else if ("deleteLast" == command)
			intList.DeleteLast();
	}

	intList.Print();

	return 0;
}


Measured memory_bytes: 34268
import sys

stdin = sys.stdin

ni = lambda: int(ns())
ns = lambda: stdin.readline().rstrip()
na = lambda: list(map(int, stdin.readline().split()))

# code here
N = ni()
ans = 0
def dfs(n):
    global ans
    if n > N:
        return

    if '3' in str(n) and '5' in str(n) and '7' in str(n):
        ans += 1

    dfs(n*10+3)
    dfs(n*10+5)
    dfs(n*10+7)

dfs(0)
print(ans)

Measured memory_bytes: 3064
using System;

namespace A
{
    class Node
    {
        public int key=0;
        public int parent;
        public int left=0;
        public int right=0;
    }

    class Max{
        public void maxHeapify(ref Node[] node, int i)
        {
            int left = i*2, right = i*2+1, large=i;
            Node change = new Node();
            if (left < node.Length && node[left].key > node[i].key)
            {
                large = left;
            }
            if (right < node.Length && node[right].key > node[large].key)
            {
                large = right;
            }
            if (large != i)
            {
                change = node[large];
                node[large] = node[i];
                node[i] = change;
                maxHeapify(ref node, large);
            }
        }
    }

    class B
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            int n = int.Parse(input1), i;
            Node[] node = new Node[n + 1];
            string[] input2 = new string[n + 1];
            for (i = 0; i <= n; i++)
            {
                node[i] = new Node();
            }
            input2 = Console.ReadLine().Split(' ');
            for (i = 0; i < n; i++)
            {
                node[i + 1].key = int.Parse(input2[i]);
            }

            for (i = 1; i <= n; i++)
            {
                if (i / 2 > 0)
                {
                    node[i].parent = node[i / 2].key;
                }
                if (i * 2 <= n)
                {
                    node[i].left = i * 2;
                }
                if (i * 2 + 1 <= n)
                {
                    node[i].right = 2 * i + 1;
                }
            }

            Max max = new Max();
            for (i = n / 2; i > 0; i--)
            {
                max.maxHeapify(ref node, i);
            }

            for (i = 1; i <= n; i++)
            {
                Console.Write(" " + node[i].key);
            }
            Console.WriteLine();

        }
    }
}



Measured memory_bytes: 81876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N; cin >> N;
    priority_queue<float, vector<float>, greater<float>> v;
    for(int i = 0; i < N; i++) {
        int a; cin >> a;
        v.push(a);
    }

    while(v.size() > 1) {
        float a = v.top(); v.pop();
        float b = v.top(); v.pop();
        v.push((a+b)/2.0f);
    }

    cout << v.top();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=1e5+10;
ll n,m,f1[MAXN],f2[MAXN],up[MAXN];
vector <ll> pre[MAXN],suf[MAXN],node[MAXN];
void dfs_dp_init(int now,int fa)
{
	f1[now]=1;
	for(int i=0;i<node[now].size();i++)
	{
		ll to=node[now][i];
		if(to==fa)
			continue;
		dfs_dp_init(to,now);
		f1[now]=(f1[now]*(f1[to]+1))%m;
	}
	ll sum=1;
	for(int i=0;i<node[now].size();i++)
	{
		ll to=node[now][i];
		if(to!=fa)
			sum=(sum*(f1[to]+1))%m;
		pre[now].push_back(sum);
	}
	sum=1;
	for(int i=node[now].size()-1;i>=0;i--)
	{
		ll to=node[now][i];
		if(to!=fa)
			sum=(sum*(f1[to]+1))%m;
		suf[now].push_back(sum);
	}
}
void dfs_dp(int now,int fa)
{
	for(int i=0;i<node[now].size();i++)
	{
		ll to=node[now][i];
		if(to==fa)
			continue;
		f2[to]=f1[to],up[to]=up[now]+1;
		if(i)
			up[to]=(up[to]*pre[now][i-1])%m;
		if(i!=node[now].size()-1)
			up[to]=(up[to]*suf[now][node[now].size()-i-2])%m;
		dfs_dp(to,now);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		node[u].push_back(v);
		node[v].push_back(u);
	}
	dfs_dp_init(1,1);
	f2[1]=f1[1];
	dfs_dp(1,1);
	for(int i=1;i<=n;i++)
		printf("%lld\n",(f2[i]*(up[i]+1))%m);
	return 0; 
} 

Measured memory_bytes: 30716
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b=0,d,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    char c;
    set<ll> s;
    map<ll,ll> m;
    cin>>n;
    rep(i,n){
        cin>>a;
        s.insert(a);
        m[a]++;
    }
    for(auto itr= s.begin();itr!=s.end();++itr){
        if(*itr<=m[*itr]){
            sum+=(m[*itr]-*itr);
        }else{
            sum+=m[*itr];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 14140
fun main(args: Array<String>) {
    val s = readLine()!!
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        println("-1")
        return
    }
    val range = 'a'..'z'
    if (s.length < 26) {
        for (c in range) {
            if (!s.contains(c)) {
                println(s + c)
                return
            }
        }
    }
    for (i in s.length - 1 downTo 0) {
        val sub = s.substring(0 until i)
        for (c in (s[i].inc())..'z') {
            if (!sub.contains(c)) {
                println(sub + c)
                return
            }
        }
    }
}

fun printYesOrNo(flag: Boolean) {
    println(if (flag) "Yes" else "No")
}

fun readIntList(): List<Int> = readLine()!!.split(' ').map { it.toInt() }

fun readInt(): Int = readLine()!!.toInt()

fun err(print: Any) {
    System.err.println(print)
}

Measured memory_bytes: 33820
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int w[110];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,k=0;
    cin>>n;
    for(int i=1,x;i<=n;i++) k=max(k,x=gi()),++w[x];
    for(int i=0;i<=k;i++) {
	int x=max(i,k-i);
	if(!w[x]) return puts("Impossible"),0;
	--w[x];
    }
    for(int i=1;i+i<=k+1;i++)
	if(w[i]) return puts("Impossible"),0;
    puts("Possible");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
#define all(a) a.begin(),a.end()
using namespace std;
int main(void){
	int cnt=0;
	string s;
	cin>>s;
	REP(i,s.size())cnt+=(s[i]-'0');
	if(cnt%9==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3748
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+4;
int n;
ll a[N];
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
inline bool cmp(int x,int y) {
	return x>y;
}
int main() {
	n=read();
	for (register int i=1;i<=n;++i) a[i]=read();
	sort(a+1,a+n+1,cmp);
	ll ans=a[1];
	int pos=2;
	for (int i=3;i<=n;++i) {
//		printf("%d %d\n",a[i],a[pos]);
		ans+=a[pos];
		if (!(i&1)) ++pos;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
#define pb push_back
//#define int long long
#define mod 1000000007
#define fi first
#define se second
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
int main()
{
	fast;
	ll n;
	cin>>n;
	ll a=n%500;
	ll a1=n/500;
	ll b=a%5,b1=a/5;
	cout<<a1*1000+b1*5;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 2010
#define MOD 1000000007
using namespace std;
typedef long long ll;
int n;
ll ans,mina,minb,maxa,maxb,x,y;
int main(){
	SF("%d",&n);
	SF("%lld%lld",&x,&y);
	ll a=x+y;
	ll b=x-y;
	mina=maxa=a;
	minb=maxb=b;
	for(int i=2;i<=n;i++){
		SF("%lld%lld",&x,&y);
		a=x+y;
		b=x-y;
		ll len1=max(abs(a-mina),abs(a-maxa));
		ll len2=max(abs(b-minb),abs(b-maxb));
		mina=min(mina,a);
		maxa=max(maxa,a);
		minb=min(minb,b);
		maxb=max(maxb,b);
		ans=max(ans,max(len1,len2));
	}
	PF("%lld",ans);
}

Measured memory_bytes: 1732
#include<iostream>
#include<cstdio>
#include<cstring>
namespace AM0200__o_o
{
	typedef long long ll;
	const int N=1010,MOD=1000000007;
	ll qpow(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}
	struct node
	{
		ll p,x,y,e;
		node(ll a=0,ll b=0,ll c=0,ll d=0){p=a,x=b,y=c,e=d;}
	};
	ll fucker;
	node operator * (node A,node B)
	{
		return 
			node(A.p*B.p%MOD,
				A.x*B.x%MOD,
				(A.p*B.y%MOD+B.x*A.y%MOD)%MOD,
				(A.p*B.e%MOD+B.x*A.y%MOD*fucker%MOD)%MOD);
	}
	node operator ^ (node a,ll b)
	{
		node c=a;b--;
		for(;b;b>>=1,a=a*a)
			if(b&1)c=c*a;
		return c;
	}
	bool s[N][N];
	int n,m;
	ll k;
	bool check_row()
	{
		for(int i=1;i<=n;i++)
			if(s[i][1] && s[i][m])
				return 1;
		return 0;
	}
	bool check_col()
	{
		for(int i=1;i<=m;i++)
			if(s[1][i] && s[n][i])
				return 1;
		return 0;
	}
	void detit()
	{
		int tmp=std::max(n,m);
		for(int i=1;i<=tmp;i++)
			for(int j=i;j<=tmp;j++)
				std::swap(s[i][j],s[j][i]);
		std::swap(n,m);
	}
	bool initialize()
	{
		static char tmp[N];
		scanf("%d%d%lld",&n,&m,&k);
		if(!k){printf("1\n");return 0;}
		for(int i=1;i<=n;i++)
		{
			scanf("%s",tmp+1);
			for(int j=1;j<=m;j++)
				s[i][j]=tmp[j]=='#';
		}
		bool fa=check_row(),fb=check_col();
		if(fa && fb){printf("1\n");return 0;}
		if(fb)detit();
		return 1;
	}
	void solve()
	{
		if(!initialize())return;
		ll p,x,y,e,h;
		p=x=y=e=0;
		for(int i=1;i<=n;i++)
		{
			if(s[i][1] && s[i][m])x++;
			for(int j=1;j<=m;j++)
			{
				p+=s[i][j];
				if(j<m && s[i][j] && s[i][j+1])y++;
			}
		}
		h=p;
		fucker=qpow(x,MOD-2);
		node ans=node(p,x,y,e);
		ans=ans^k;
		ll rans=((ans.p*qpow(h,MOD-2)%MOD-ans.e)%MOD+MOD)%MOD;

		printf("%lld\n",rans);
	}
	void test()
	{
		node a=node(6,2,2,0);
		a=a^10000000000;

		fucker=qpow(2,MOD-2);
		printf("%lld , %lld , %lld , %lld\n",a.p,a.x,a.y,a.e);

		printf("%lld\n",a.p*qpow(6,MOD-2)%MOD-a.e);
	}
}
int main()
{
//	freopen("f.in","r",stdin);
	AM0200__o_o::solve();
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>

int main(int argc, char const *argv[])
{
    std::string l;
    int s;
    std::cin >> l;
    std::cin >> s;
    for (auto i=l.begin(); i<l.end(); i+=s)
        std::cout << *i;
    return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll x;
    cin >> x;
    ll cnt = 0;
    cout << x / 500 * 1000 + (x % 500)/5 * 5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  int t, x;
  cin >> t >> x;
  double ans = (double)t / x;
  printf("%.5f\n", ans);
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

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

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
  string s;
  cin >> s;
  ll n = s.size();
  ll top = 0;
  for (auto c : s)
  {
    if (c == 'p')
      top++;
  }

  cout << n / 2 - top << endl;
  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
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;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

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

using namespace std;


void solve() {
    string s; cin >> s;
    int n = s.size();
    for (int i = 1; i < n; i++) {
        if (s[i-1]==s[i]) {
            cout << i << ' ' << (i+1); return;
        }
    }
    for (int i = 2; i < n; i++) {
        if (s[i-2] == s[i]) {
            cout << (i-1) << ' ' << (i+1); return;
        }
    }
    cout << "-1 -1";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int a = (s[0]-'0')*10 + s[1]-'0';
    int b = (s[2]-'0')*10 + s[3]-'0';
    if(0<a && a<13){
        if(0<b && b<13) cout<<"AMBIGUOUS"<<endl;
        else cout << "MMYY" << endl;
    }else
        if(0<b && b<13) cout<<"YYMM"<<endl;
        else cout<<"NA"<<endl;
}


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

void solv() {
    int Alice, Bob;
    cin >> Alice >> Bob;
    Alice -= 2;
    Bob -= 2;
    if( Alice < 0)
        Alice += 13;
    if( Bob < 0)
        Bob += 13;
    
    if( Alice > Bob)
        cout << "Alice";
    else if ( Alice == Bob)
        cout << "Draw";
    else
        cout << "Bob";
    cout << endl;
}

int main() {
    solv();
    return 0;
}

Measured memory_bytes: 256
x=int(input())
s=[list(map(int,list(input().split()))) for i in range(2)]
y=list(s)

for i in range(x-1):
	y[1][(x-2-i)]=y[1][(x-2-i)]+y[1][(x-1-i)]

y[0][(x-1)]=y[0][(x-1)]+y[1][(x-1)]

for i in range(x-1):
	if y[0][(x-i-1)]>=y[1][(x-i-2)]:
		y[0][(x-i-2)]=y[0][(x-i-2)]+y[0][(x-i-1)]
	else:
		y[0][(x-i-2)]=y[0][(x-i-2)]+y[1][(x-i-2)]
print(y[0][0])

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    int    a, b;
    double c;
    int    C;

    cin >> a >> b >> C;
    
    double S = (1.0 / 2.0) * a * b * sin(C * (double)M_PI / 180.0);
    
    c = (double)sqrt(a * a + b * b - 2 * a * b * (cos(C * (double)M_PI / 180.0)));

    double L = a + b + c;

    double h = 2.0 * S / a;

    cout << fixed << setprecision(13) << S << " " << setprecision(13) << L << " " 
                  << setprecision(13) << h << endl;
   
    return (0);
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int n;
    cin >> n;
    int cnt = (int)pow(3, n);
    int tmp = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0) {
            tmp *= 2;
        }
    }

    cout << cnt - tmp << endl;

    return 0;
}


Measured memory_bytes: 512