akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// union by size + path having
class UnionFind {
public:

    //素集合の要素の親（木構造の根）を配列*3で保持している．初期状態では頂点間の辺は存在せず，孤立した状態のため，自分自身を根として初期化している（par: parent の略）．
    vector <ll> par;

    // 各集合（木）の大きさ．根をたどるとその木の大きさが返されるように実装されている．この配列を用意しておくとある頂点の連結成分の大きさを簡単に求められる
    vector <ll> siz;

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    rep(i, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) {
            uf.merge(u, v);
        }
        else {
            if(uf.issame(u, v)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 6036
#include<bits/stdc++.h>
#define il inline
#define vd void
typedef long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int n,q;
struct Segtree{
	ll all_tag;
	ll mn[800010];
#define mid ((l+r)>>1)
	il vd update(int x,int l,int r,const int&p,const ll&d){
		mn[x]=std::min(mn[x],d);
		if(l==r)return;
		if(p<=mid)update(x<<1,l,mid,p,d);
		else update(x<<1|1,mid+1,r,p,d);
	}
	il vd Update(int p,ll d){d-=all_tag;update(1,1,n,p,d);}
	il ll query(int x,int l,int r,const int&L,const int&R){
		if(L<=l&&r<=R)return mn[x];
		if(L<=mid)
			if(mid<R)return std::min(query(x<<1,l,mid,L,R),query(x<<1|1,mid+1,r,L,R));
			else return query(x<<1,l,mid,L,R);
		else return query(x<<1|1,mid+1,r,L,R);
	}
	il ll Query(int l,int r){return query(1,1,n,l,r)+all_tag;}
	il vd Update_all(ll d){all_tag+=d;}
#undef mid
	il vd clear(){
		memset(mn,20,sizeof mn);
		all_tag=0;
	}
}A,B;// A f[i]+i B f[i]-i
int cx[200010];
il ll solve(int posA,int posB){
	A.clear(),B.clear();
	A.Update(posA,posA);
	B.Update(posA,-posA);
	int lst=posB,nx;
	for(int i=1;i<=q;++i){
		nx=cx[i];
		ll newf=B.Query(1,nx)+nx;
		if(nx!=n)newf=std::min(newf,A.Query(nx+1,n)-nx);
		A.Update_all(abs(nx-lst));
		B.Update_all(abs(nx-lst));
		A.Update(lst,newf+lst);
		B.Update(lst,newf-lst);
		lst=nx;
	}
	ll ans=9e18;
	for(int i=1;i<=n;++i)ans=std::min(ans,A.Query(i,i)-i);
	return ans;
}
int main(){
	n=gi(),q=gi();
	int posA=gi(),posB=gi();
	for(int i=1;i<=q;++i)cx[i]=gi();
	printf("%lld\n",std::min(solve(posA,posB),solve(posB,posA)));
	return 0;
}


Measured memory_bytes: 13568
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long MOD = (long)Math.pow(10, 9) + 7;
    long n = sc.nextLong();
    boolean[] is_p = new boolean[(int)(n + 1)];
    for(int i = 2; i <= (int)n; i++) {
      is_p[i] = true;
    }
    ArrayList<Long> p = new ArrayList<Long>();
    for(int i = 2; i <= (int)n; i++) {
      if(is_p[i]) {
        p.add((long)i);
        for(int j = (2 * i); j <= (int)n; j += i) {
          is_p[j] = false;
        }
      }
    }
    long ans = 1;
  //  ArrayList<Long> q = new ArrayList<Long>();
    for(int i = 0; i < p.size(); i++) {
      long P = p.get(i);
      long t = 0;
      for(int j = 1; j <= 10; j++) {
        long s = n / ((long)Math.pow(P, j));
        t += s;
      }
      ans = (ans * (t + 1)) % MOD;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n, k;
    cin >> n >> k;
    int d[k];
    map<int, int> m;
    rep(i, k) {
        cin >> d[i];
        rep(j, d[i]) {
            int enter;
            cin >> enter;
            m[enter]++;
        }
    }
    cout << n - m.size() << endl;
    return 0;
}

Measured memory_bytes: 3636
def g i,j,r;r<1?d(i+1):j<$n&&((!$f[j]&&$a[j]<=r&&($f[j]=1;t=g(i,j+1,r-$a[j]);$f[j]=$';t))||g(i,j+1,r))end
def d i;i==$n||$f[i]&&(g(i,i+1,$a[i])||d(i+1))end
($a=gets.split.map(&:to_i).sort.reverse;$f=[1];puts d(0)?:YES:"NO")while 0<$n=gets.to_i

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    string S;
    cin >> S;
    ll count=0;
    for(size_t i=0;i<N; i++)
    {
        if(S.substr(i, 3) == "ABC") count++;
    }
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3644
import std.stdio, std.conv, std.string, std.math;

void main(){
	auto ip = readln.split.to!(string[]);
	auto A = ip[0];
	auto B = ip[1];
	auto C = ip[2];
	if(A[$-1] == B[0] && B[$-1] == C[0]) "YES".writeln;
	else "NO".writeln;
}

Measured memory_bytes: 256
function main(input) {
    const args = input.split(' ');
    const a = args.map(n=>parseInt(n, 10));


    if ((a[0] * a[1]) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  k,x=LI()
  ans=[]
  for i in range(x-k+1,x+k):
    ans.append(i)

  return ' '.join([str(x) for x in ans])

# main()
print(main())


Measured memory_bytes: 6480
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a[26];
	string s;
	for(int i=0;i<26;i++){
			a[i]=0;
			}
	while(cin>>s){
		int b=s.size();
		for(int n=0;n<b;n++){
			for(int j=0;j<26;j++){
				if(s[n]>='A' && s[n]<='Z'){
					s[n]=s[n]+32;
					}
					if(s[n]=='a'+j){
						a[j]=a[j]+1;
					}
				}
			}
		}
		for(int j=0;j<26;j++){
			cout<<(char)('a'+j)<<" : "<<a[j]<<endl;
		}
}



Measured memory_bytes: 3140
n = int(input())
h = [int(i) for i in input().split()]
h[0] -= 1
if len(h) == 1:
    print('Yes')
else:
    for i in range(1, n):
        if h[i - 1] < h[i]:
            h[i] -= 1
        elif h[i - 1] > h[i]:
            print('No')
            exit()
    print('Yes')

Measured memory_bytes: 63984
#include <iostream>
#include <math.h>//累乗計算用
#include <cstring>//配列初期化
using namespace std;

bool field[ 10 ][ 10000 ];//せんべいの初期状態
bool binary[ 10 ];//2進数カウンタ
long flag;//解答の候補
int r ,c ,ans;//r,c:入力用  ans:答え

long FlagMake( void );//解答の候補の列挙
void Count( int area );//2進数カウンタの計算

int main( void ){
    cin >> r >> c;
    while(r != 0 && c != 0){//r=0,c=0でプログラム終了
        for(long i = 0 ; i < r ; i++ ){
            for(long j = 0 ; j < c ; j++ ){
                cin >> field[ i ][ j ];
            }
        }//ここまで入力

        ans = 0;//解答の初期化
        memset(binary , 0 , sizeof( binary ) );//配列の初期化

        for(long i = 0 ; i < pow( 2 , r ) ; i++ ){
            if(i != 0){Count( 0 );}//カウンタを1進める
            FlagMake();//カウンタごとの解答の候補を検索
            if( ans < flag ) ans = flag;//出荷枚数が解答多ければ、解答更新
        }

        cout << ans << endl;//解答出力

        cin >> r >> c;//再入力
    }
}

long FlagMake(){
    int low ,high;
    
    flag = 0;
    
    for(long i = 0 ; i < c ; i++ ){
        
        low = 0; high = 0;//low:裏側,high:表側
        
        for(int j = 0 ; j < r ; j++ ){
            if( binary[ j ] == 1 ){//行が裏返されているとき
                if( field[ j ][ i ] == 0){high++; }
                else{low++; }
            }
            else{//行が裏返っていないとき
                if( field[ j ][ i ] == 0 ){low++; }
                else{high++; }
            }
        }
        if( low > high ){flag += low; }//列を裏返すかどうかの判定
        else{flag += high; }
    }
    
    return flag;//解答の候補を返す
}

void Count( int area ){
    if( binary[ area ] == 0 ){binary[ area ] = 1;}//繰り上げなしの時
    else{//繰り上げありの時
        binary[ area ] = 0;
        Count( area + 1 );
    }
}



Measured memory_bytes: 3356
from collections import deque
# N = int(input())
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
MOD = 10 ** 9 + 7
A_p = []
A_n = []
for a in A:
  if a >= 0:
    A_p.append(a)
  else:
    A_n.append(-a)

A_p.sort(reverse=True)
A_n.sort(reverse=True)
A_p = deque(A_p)
A_n = deque(A_n)

p_top = 0
n_top = 0
ans_p = deque([])
ans_n = deque([])
for i in range(K):
  if len(A_p) == 0:
    ans_n.append(A_n.popleft())
  elif len(A_n) == 0:
    ans_p.append(A_p.popleft())
  elif A_p[0] >= A_n[0]:
    ans_p.append(A_p.popleft())
  else:
    ans_n.append(A_n.popleft())
if len(ans_n) % 2 == 1:
  if len(ans_p) > 0 and len(ans_n) > 0 and len(A_p) > 0 and len(A_n) > 0 and ans_p[-1] * A_p[0] >= ans_n[-1] * A_n[0]:
    ans_n.pop()
    ans_p.append(A_p.popleft())
  elif len(ans_p) > 0 and len(A_n) > 0:
    ans_p.pop()
    ans_n.append(A_n.popleft())
  elif len(ans_n) > 0 and len(A_p) > 0:
    ans_n.pop()
    ans_p.append(A_p.popleft())
ans = 1
for a in ans_p:
  ans = (a * ans) % MOD
for a in ans_n:
  ans = (-a * ans) % MOD
if ans != 0 and len(ans_n) % 2 == 1:
  ans = 1
  A_abs = [abs(a) for a in A]
  A_abs.sort()
  for i in range(K):
    ans = (ans * A_abs[i]) % MOD
  ans = (-ans) % MOD
print(ans)




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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct query
{
  string name;
  int rest;
};

int n,t;
queue<query> q;

int main(){
	cin>>n>>t;
  rep(i,n){
    string a;
    int b;
    cin>>a>>b;
    q.push((query){a,b});
  }
  int nt=0;
  while(q.size()){
    query nq=q.front(); q.pop();
    if(nq.rest<=t){
      nt+=nq.rest;
      cout<<nq.name<<" "<<nt<<endl;
    }else{
      nq.rest-=t;
      nt+=t;
      q.push(nq);
    }
  }

	return 0;
}

Measured memory_bytes: 6256
#include "bits/stdc++.h"
#include <random>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    for(int i = 1; i <= 100000; ++i){
        if(i*8/100 == a && i/10 == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3652
program atcoder0328_4
  integer::N,X,Y,C(2000)=0,M
  read(5,*)N,X,Y
  do I=1,N-1
     do J=I+1,N
        M=min(J-I,abs(X-I)+abs(Y-J)+1)
        C(M)=C(M)+1
     end do
  end do
  do I=1,N-1
     write(6,*)C(I)
  end do
end program atcoder0328_4

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

####################################################
# LCS(longest common sequence)
# 部分列で最長の共通のもの
####################################################

# dp[i+1][j+1]:= s の i 文字目までと t の j 文字目まででの LCS の長さ

import numpy as np

def main():
    S = np.array(list(input()), dtype='unicode')
    T = np.array(list(input()), dtype='unicode')
    ls = len(S)
    lt = len(T)

    equal = S[:, None] == T[None,:]
#    print(eq)

    dp = np.zeros((ls + 1, lt + 1), dtype=int)

    for i in range(ls):
        dp[i + 1][1:] = np.maximum(dp[i][1:], dp[i][:-1] + equal[i])
        dp[i + 1] = np.maximum.accumulate(dp[i + 1])

#    for i in range(ls):
#        for j in range(lt):
#            dp[i+1][j+1] = max(dp[i][j+1], dp[i][j]+ eq[i][j])
#            dp[i+1][j+1] = max(dp[i+1][j+1] , dp[i+1][j])

#    print(dp)

    # 復元
    res = ''
    i, j = ls, lt
    while (i > 0 and j > 0):
        # (i-1, j) -> (i, j) と更新されていた場合
        if dp[i][j] == dp[i-1][j]:
            i-=1   # DP の遷移を遡る
        # (i, j-1) -> (i, j) と更新されていた場合
        elif dp[i][j] == dp[i][j-1]:
            j-=1   # DP の遷移を遡る
        # (i-1, j-1) -> (i, j) と更新されていた場合
        else:
            res = S[i-1] + res
            # このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            i-=1
            j-=1   # DP の遷移を遡る
    print(res)

if __name__ == '__main__':
    main()

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

int main()
{
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    int isReversed = 0;
    array<string, 2> Sadd = {"", ""};
    int Ti, Fi;
    char Ci;
    for(int i=0;i<Q;i++){
        cin >> Ti;
        if(Ti == 1) isReversed ^= 1;
        else{
            cin >> Fi >> Ci;
            auto j = isReversed;
            if(Fi == 2) j ^= 1;
            Sadd[j] += Ci;
        }
    }
    if(isReversed){
        reverse(S.begin(), S.end());
        swap(Sadd[0], Sadd[1]);
    }
    string res;
    reverse(Sadd[0].begin(), Sadd[0].end());
    res += Sadd[0];
    res += S;
    res += Sadd[1];
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1348
n = STDIN.gets.chomp.to_i
posts = []
n.times do
  pts = STDIN.gets.chomp.split(/ +/).map(&:to_i)
  posts << pts
end

posts.sort!{|a,b| b[2]<=>a[2]}

xy = []
(0..100).each do |x|
  (0..100).each do |y|
    xy << [x,y]
  end
end

result = []

xy.each do |pt|
  height = 0
  posts.each do |post|
    h = (pt[0] - post[0]).abs + (pt[1] - post[1]).abs + post[2]
    
    #puts "pt:%s post:%s height:%s h:%d" % [pt, post, height, h ]
    
    if height == 0 
      height = h
    else
      if post[2] == 0
        if h < height
        		height = 0
        		break
      	end
      else
      	if h != height
      	  height = 0
      	  break
      	end
      end
    end
  end
  
  if height != 0
	 	result = pt + [ height ]
  end
end

puts result.join(" ")


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    string S; cin >> S;
    string ans = "Yes";
    if (N%2==1) ans = "No";    
    if (S.substr(0,N/2)!=S.substr(N/2)) ans = "No";
    cout << ans << endl;
    return 0;
}

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

bool check( string chkString) {
    

    string strFront;
    string strBack;
    string backReverse;

    int strSize = chkString.size();
    if ( strSize % 2 == 0  ) {
        strFront = chkString.substr( 0, strSize / 2);
        strBack = chkString.substr( strSize / 2  , strSize);
        std::reverse(strBack.begin() , strBack.end() );

        if (strFront == strBack) {
            return true;
        }
        else {
            return false;
        }

    } else {
        strFront = chkString.substr(0, (strSize - 1 )/ 2);
        strBack = chkString.substr( (strSize + 1) / 2, strSize);
        std::reverse(strBack.begin(), strBack.end());

        if (strFront == strBack) {
            return true;
        }
        else {
            return false;
        }
    }
    

}

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

    int strSize;
    strSize = s.size();

    string strFront;
    string strBack;
    strFront = s.substr(0, (strSize - 1) / 2);
    strBack = s.substr((strSize + 2) / 2 , strSize );

    bool fgS, fgF , fgB;
    fgS = check(s);
    fgF = check(strFront);
    fgB = check(strBack);
    
    if ( fgS == true  && fgB == true && fgF == true) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    

}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	double r;
	double s,len;
	double pi = 3.14159265358979;
	scanf("%lf", &r);
	s=r*r*pi;
	len=r*2*pi;
	printf("%f %f\n", s, len);
	
	return 0;
}

Measured memory_bytes: 648
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<cassert>
#include<stack>
#include<deque>
#include<list>
#include<sstream>
#include<unordered_map>
#include<time.h>
#include<functional>
#pragma comment(linker, "/STACK:8809999999")

using namespace std;
typedef short ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<ld, ld> pld;
typedef pair<ll, pll> pllp;
typedef pair<pll, ll> ppll;
typedef pair<pll, pll> ppp;
typedef vector<vector<vector<ll>>> vvv;
const ll mod = 3000;  //1e9 + 7;
const ll atcmod = 998244353;
const ld eps = 1e-9;
const ll settled = 400007;

ll h, w;
priority_queue<pllp, vector<pllp>, greater<pllp>> go;

void add(ll x, ll y, ll v, vector<vl> &table)
{
	v++;
	if (x > 0)
		go.push({ v, {x - 1, y} });

	if (x < h - 1)
		go.push({ v, {x + 1, y} });

	if (y > 0)
		go.push({ v,{ x, y - 1 } });

	if (y < w - 1)
		go.push({ v,{ x, y + 1} });

}

int main()
{
	ios_base::sync_with_stdio(false); cout.tie(NULL);
#ifndef overlord
	/*freopen("capitals.in", "r", stdin);
	freopen("capitals.out", "w", stdout);*/
#else
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin >> h >> w;
	vector<vl> table(h, vl(w, mod));

	forn(i, 0, h)
		forn(j, 0, w)
	{
		char c;
		cin >> c;
		if (c == '#')
		{
			table[i][j] = 0;
			add(i, j, 0, table);
		}
	}

	ll ans = 0;
	while (go.size())
	{
		pllp first_go = go.top();
		pll coord = first_go.second;
		ll val = first_go.first;
		go.pop();
		if (table[coord.first][coord.second] < mod)
		{
			continue;
		}

		table[coord.first][coord.second] = val;
		add(coord.first, coord.second, val, table);
		ans = max(ans, val);
	}

	cout << ans;
	return 0;
}

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

char maze[1010][1010];
int d[1010][1010];
int n, m;

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) scanf("%s", maze[i]);
    memset(d, -1, sizeof(d));
    vector< pair<int, int> > temp;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (maze[i][j] == '#') {
                temp.emplace_back(i, j);
                d[i][j] = 0;
            }
        }  
    }    
    for (int i = 0; i < temp.size(); i++) {
        for (int x = -1; x <= 1; x++) {
            for (int y = -1; y <= 1; y++) {
                if (x * x + y * y != 1) continue;
                int dx = temp[i].first + x, dy = temp[i].second + y;
                if (dx >= 0 && dy >= 0 && dx < n && dy < m && d[dx][dy] == -1) {
                    temp.emplace_back(dx, dy);
                    d[dx][dy] = d[temp[i].first][temp[i].second] + 1;
                }
            }
        }
    }
    printf("%d\n", d[temp[temp.size()-1].first][temp[temp.size()-1].second]);
    return 0;
}

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

using namespace std;

#define ll long long
#define sz(x) (int) ((x).size())

int main() {
	set<int> st;
	for (int i = 0; i <3 ; i++) {
		int x;
		cin>>x;
		st.insert(x);
	}
	puts(st.size() == 2 ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
STR = [s for s in input()] 
k = 0
for i in range((len(STR)+1)//2  ):
    if STR[i*2] == "L":
        k = 1
    else:
        pass 
for i in range((len(STR))//2  ):
    if STR[i*2+1] == "R":
        k = 1
    else:
        pass 

if k == 0:
    print("Yes") 
else:
    print("No")
    

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    if (s == "SUN") ans = 7;
    else if (s == "MON") ans = 6;
    else if (s == "TUE") ans = 5;
    else if (s == "WED") ans = 4;
    else if (s == "THU") ans = 3;
    else if (s == "FRI") ans = 2;
    else if (s == "SAT") ans = 1;
    else assert(false);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#!/mnt/c/Users/moiki/bash/env/bin/python
N,M = map(int, input().split())

cost = [0,2,5,5,4,5,6,3,7,6]
A =list(map(int, input().split()))
dp = [-1]*(N+1)
dp[0] = 0

for i in range(N):
    if dp[i] == -1:
        continue
    for c,a in zip( [cost[a] for a in A], A):
        if i + c <= N:
            dp[i+c] = dp[i]+1

# print(dp)
i = N
ans = ""
A = sorted(A, reverse=True)
while i > 0:
    for c,a in zip([cost[a] for a in A], A):
        if i-c >= 0 and dp[i-c] == dp[i]-1:
            ans += str(a)
            i -= c
            break # difficult !! 

print(ans)
        


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

#define debug(x) cerr << #x << ": " << x << endl

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  string s = to_string(n);
  bool ok = true;
  for (int i = 0; i < s.length() / 2; i++) 
    if (s[i] != s[s.length() - i - 1])
      ok = false;
  cout << (ok ? "Yes\n" : "No\n"); 
  return 0;
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7
n = 2000010
fact = [1] * (n + 1)
ifact = [1] * (n + 1)

r1, c1, r2, c2 = map(int, input().split())

for i in range(n):
    fact[i + 1] = fact[i] * (i + 1) % mod
    if i + 1 in [r1, c1, r2 + 1, c2 + 1]:
        ifact[i + 1] = pow(fact[i + 1], mod - 2, mod)

def comb(x, y):
    return (fact[x + y] * ifact[x] * ifact[y]) % mod


ans = comb(r2 + 1, c2 + 1) - comb(r2 + 1, c1) - comb(r1, c2 + 1) + comb(r1, c1)
ans %= mod
print(ans)


Measured memory_bytes: 98860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  
	public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int n = sc.nextInt();
	  long[] dp = new long[5]; // For counting 'm', 'a', 'r', 'c', 'h'.
	  
	  // Choose three from five, there is total ten patterns.
	  int[] p = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
	  int[] q = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
	  int[] r = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
	  
	  long res = 0;
	  
	  for (int i = 0; i < n; i++) {
		  String s = sc.next();
		  
		  if (s.charAt(0) == 'M') {
			  dp[0]++;
		  } else if (s.charAt(0) == 'A') {
			  dp[1]++;
		  } else if (s.charAt(0) == 'R') {
			  dp[2]++;
		  } else if (s.charAt(0) == 'C') {
			  dp[3]++;
		  } else if (s.charAt(0) == 'H') {
			  dp[4]++;
		  }
	  }
	  
	  for (int i = 0; i < 10; i++) {
		  res += (dp[p[i]] * dp[q[i]] * dp[r[i]]);
	  }
	  
	  System.out.println(res);
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

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

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


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

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		VVI time( n, VI( n + 1 ) );

		REP( i, 0, n )
		{
			REP( j, 0, n + 1 )
			{
				cin >> time[i][j];
			}
		}

		VI dp( 1 << n, INT_MAX );
		dp[0] = 0;

		REP( mask, 0, 1 << n )
		{
			REP( i, 0, n )
			{
				if ( ( mask >> i ) & 1 )
				{
					continue;
				}

				REP( j, 0, n + 1 )
				{
					if ( j && !( ( mask >> ( j - 1 ) ) & 1 ) )
					{
						continue;
					}

					dp[ mask | ( 1 << i ) ] = min( dp[ mask | ( 1 << i ) ], dp[mask] + time[i][j] );
				}
			}
		}

		cout << dp.back() << endl;
	}

	return 0;
}

Measured memory_bytes: 1488
N = int(input())
A = [1000000001]
for i in range(N):
    A.append(int(input()))

count = 0
score = 0
A.sort()

for i in range(0, N):
    count += 1
    if A[i] != A[i+1]:
        score += count % 2
        count = 0

print(score)

Measured memory_bytes: 7484
n,m,l=map(int,input().split())
A = [[0 for j in range(m)] for i in range(n)]
B = [[0 for k in range(l)] for j in range(m)]
C = [[0 for k in range(l)] for i in range(n)]
for i in range(n):
    A[i]=list(map(int,input().split()))
for j in range(m):
    B[j]=list(map(int,input().split()))
for i in range(n):
    for k in range(l):
        for j in range(m):
            C[i][k]+=A[i][j]*B[j][k]
for i in range(n):
    for k in range(l):
        if k<l-1:
            print("{} ".format(C[i][k]),end="")
        else:
            print("{}".format(C[i][k]))


Measured memory_bytes: 7088
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, k = LI()
    h = IR(n)
    h.sort()
    ans = inf
    for i in range(n - k + 1):
        ans = min(ans, h[i + k - 1] - h[i])
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 45404
import heapq as hq
n,q = map(int,input().split())
a = [[] for i in range(n)]

for i in range(q):
	k = list(map(int,input().split()))
	if k[0] == 0:
		hq.heappush(a[k[1]],-k[2])
	elif k[0] == 1:
		a[k[1]] and print(-a[k[1]][0])
	else:
		a[k[1]] and hq.heappop(a[k[1]])





Measured memory_bytes: 13180
#!/usr/bin/python
import datetime

def main():
    S = str(input())
    tdatetime = datetime.datetime.strptime(S, '%Y/%m/%d')

    if tdatetime.month <= 4:
        print('Heisei')
    else:
        print('TBD')

if __name__ == "__main__":
    main()

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

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

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
struct Unionfind {
    vector<int> par;
    vector<int> sizes;

    Unionfind(int n) : par(n), sizes(n, 1) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return sizes[root(x)];
    }

};

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

    string s;
    cin >> s;

    string ans = s;

    if(s.back() == 's') {
        ans += "es";
        cout << ans << endl;
        return 0;
    }
    else {
        ans += "s";
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 3656
public class Main {


  private static void solve() {
    char[] s = ns();
    int n = s.length;
    int mod = 1000000000 + 7;
    
    long[][] dp = new long[n + 1][3];
    long cnt = 1;
    for (int i = 1; i <= n; i ++) {
      char c = s[i - 1];
      for (int j = 0; j < 3; j ++) {
        dp[i][j] = dp[i - 1][j];
        if (c == '?') {
          dp[i][j] *= 3;
        }
      }
      
      if (c == 'A' || c == '?') {
        dp[i][0] += cnt;
      }
      
      if (c == 'B' || c == '?') {
        dp[i][1] += dp[i - 1][0];
      }
      
      if (c == 'C' || c == '?') {
        dp[i][2] += dp[i - 1][1];
      }
      
      if (c == '?') {
        cnt *= 3;
      }
      dp[i][0] %= mod;
      dp[i][1] %= mod;
      dp[i][2] %= mod;
      cnt %= mod;
    }
    System.out.println(dp[n][2]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

#define rep(i, n) for(long long i=0;i<n;i++)
using ll = long long;
const ll INF = (1LL<<60);

ll k(ll n){
    return n==0 ? 1 : (n*k(n-1));
}

ll f(ll* v, ll len){
    ll tmp[len];
    rep(i, len){
        tmp[i] = v[i];
    }
    sort(tmp, tmp+len);

    rep(i, len){
        if(tmp[i]==v[0]) return i;
    }
}

int main(){

    ll n; cin >> n;
    ll p[n], q[n];
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];

    ll psum = 0, qsum = 0;
    rep(i, n){
        psum += f(p+i, n-i)*k(n-1-i);
        qsum += f(q+i, n-i)*k(n-1-i);
    }
    cout << abs((psum+1)-(qsum+1)) << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 * Lang  : C++ 17
 * Author: little_angel
 * Date  : 23-07-2020 03:45 23
 */

#include<bits/stdc++.h>

using namespace std;
#define int long long
#define sort(a) sort(a.begin(), a.end())
#define ub(a, x) upper_bound(a.begin(), a.end(), x)
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define dbg(x) cerr<<"["<<#x<<"="<<x<<"]"
#define endl '\n'

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

void sol() {
    int n;
    cin >> n;
    if (n >= 30)cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
//    cin >> t;
    while (t--) sol();
}

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

using namespace std;

typedef long long llint;

int main() {
  llint n;
  cin >> n;
  llint a = 0, b = 1;
  int d = 1;
  string ans = "";
  while (n - b * 26 > 0) {
    b *= 26;
    n -= b;
    d++;
  }
  n--;
  for (int i = 0; i < d; i++) {
    ans += (char)('a' + (n % 26));
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596
n, m = map(int, input().split())
l = [0] * m
r = [0] * m
for i in range(m):
    l[i], r[i] = map(int, input().split())

if min(r) < max(l):
    print(0)
else:
    print(min(r) - max(l) + 1)


Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=e; i>=s; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<int>())
#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

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


int main(){
    ll h,w;
    in2(h,w);
    char a[h+1][w+1];
    ll b[h+1][w+1];
    char in;
    ll m=1000000007;
    for(ll i=1;i<=h;i++){
        for(ll j=1;j<=w;j++){
            in1(in);
            a[i][j]=in;
            b[i][j]=0;
        }
    }
    for(ll i=1;i<=h;i++){
        for(ll j=1;j<=w;j++){
            if (a[i][j]=='#') b[i][j]=0;
            else if (i==1){
                if (j==1) b[i][j]=1;
                else{
                    if (b[i][j-1]!=0) b[i][j]+=b[i][j-1];
                }
            }else if (j==1){
                if (b[i-1][j]!=0) b[i][j]+=b[i-1][j];
            }else{
                if (b[i-1][j]!=0) b[i][j]+=b[i-1][j];
                if (b[i][j-1]!=0) b[i][j]+=b[i][j-1];
            }
            b[i][j]=b[i][j]%m;
        }
    }
    out1(b[h][w]%m);

    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
 
  string result = "consonant";
  char val = S.at(0);
  if(val == 'a'||val == 'e'||
     val == 'i'||val == 'o'||val == 'u'
    ) result = "vowel";
  
  cout << result << endl;
}

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

using namespace std;

void solve(){
	int n,x,t,current=0,min=0;
	cin >> n >> x >> t;
	while(current < n){
		current+=x;
		min+=t;
	}
	cout<<min<<"\n";
}
int main(){
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
char _[9][9];
char cmap[9][9];

void rect_search(int x,int y){
  map<char,int> used;
  for(int i=y;i<y+3;i++){
    for(int j=x;j<x+3;j++){
      used[cmap[i][j]]++;
    }
  }

  map<char,int>::iterator it = used.begin();
  while(it != used.end() ){
    if((*it).second > 1){
      for(int i=y;i<y+3;i++){
	for(int j=x;j<x+3;j++){
	  if(cmap[i][j] == (*it).first){
	    _[i][j] = '*';
	  } 
	}
      }    
    }
    it++;
  }
}

void corss_search(int x,int y){
  map<char,int> used;
  for(int i=0;i<9;i++){
    used[cmap[i][x]]++;
  }
  map<char,int>::iterator it = used.begin();
  while(it != used.end()){
    if((*it).second > 1){
      for(int i=0;i<9;i++){
	if(cmap[i][x] == (*it).first)_[i][x] = '*';
      }
    }
    it++;
  }
  used.clear();
  for(int i=0;i<9;i++){
    used[cmap[y][i]]++;
  }
  it = used.begin();
  while(it != used.end()){
    if((*it).second > 1){
      for(int i=0;i<9;i++){
	if(cmap[y][i] == (*it).first)_[y][i] = '*';
      }
    }
    it++;
  }

}


int main(){
  int n;

  scanf("%d",&n);
  while(n-- > 0){
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	_[i][j] = ' ';
      }
    }
    for(int i=0;i<9;i++){
      cin >> cmap[i][0] >> cmap[i][1] >> cmap[i][2] >> cmap[i][3] >> cmap[i][4] >> cmap[i][5] >> cmap[i][6] >> cmap[i][7] >> cmap[i][8];
    }
   
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	corss_search(j,i);
      }
    }

    for(int i=0;i<9;i+=3){
      for(int j=0;j<9;j+=3)rect_search(j,i);
    }


    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	printf("%c%c",_[i][j],cmap[i][j]);
      }
      printf("\n");
    }
    if(n-1 >= 0)printf("\n");


  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll h;
    cin >> h;
    ll cnt = 0, ene=1;
    while(h>0){
        h/=2;
        cnt += ene;
        ene *= 2;
    }
    cout << cnt << endl;
    return 0;
}

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

//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std

Willy Indrayana Komara;

using ll = long long int;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a, b, h, m;
    double const phi = 2*acos(0.0);
    cin >> a >> b >> h >> m;
    h += m/60;
    m /= 5;
    //cout << min(abs(h - m), abs(12-h) + m) << endl;
    double rad = min(abs(h - m), abs(12-h) + m)/12 * 2 * phi;
    //cout << rad / (2 * phi) * 360 << endl;
    cout << setprecision(18) << sqrt(a*a + b*b - 2*a*b*cos(rad)) << endl;

}

Measured memory_bytes: 4244
#include <iostream>
using namespace std;
int main()
{
int A,B;
cin>>A>>B;
if(A==1)
A=A+13;
if(B==1)
B=B+13;
if(A>B)
cout<<"Alice";
if(A<B)
cout<<"Bob";
if(A==B)
cout<<"Draw";
system("pause");
return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String alf = "abcdefghijklmnopqrstuvwxyz";
		String salf[] = alf.split("");
		int array_t[] = new int[1000];
		int array_h[] = new int[1000];
		int score_t = 0;
		int score_h = 0;
		int i,m,t,h,k;
		int len;
		int time = scan.nextInt();
		for(i = 0; i < time; i++){
			int d = 0;
			int a = 0;
			int b = 0;
			String t_word = scan.next();
			String h_word = scan.next();
			String st_word[] = t_word.split("");
			String sh_word[] = h_word.split("");
			if(t_word.length() > h_word.length())
				len = h_word.length();
			else
				len = t_word.length();
			for(m = 0; m < len; m++){
				for(t = 0; t < alf.length(); t++){
					if(st_word[m].equals(salf[t])){
						array_t[a++] = t;
					}
				}
				for(h = 0; h < alf.length(); h++){
					if(sh_word[m].equals(salf[h])){
						array_h[b++] = h;
					}
				}
			}
				for(k = 0; k < len; k++){
					if(array_t[k] == array_h[k])
						++d;
					else if(array_t[k] > array_h[k]){
						score_t += 3;
						break;
					}
					else{
						score_h += 3;
						break;
					}
				}
				if(d == len){
					if(t_word.length() == h_word.length()){
						score_t++;
						score_h++;
					}
					else if(t_word.length() > h_word.length())
						score_t += 3;
					else
						score_h += 3;
			}
		}
		System.out.println(score_t+" "+score_h);
	}
}



		

	

Measured memory_bytes: 39392
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int all=1;
  for(int n=0;n<N;n++){
    int A;
    cin >> A;
    if( A%2==0 && A%3!=0 && A%5!=0 ) { 
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 105;
char a[N][N];

const int dx[4] = {-1,0,1,0},dy[4] = {0,1,0,-1};
int H,W;
void dfs(int x,int y,char z)
{
	for(int i = 0;i < 4;++i)
	{
		int nx = x + dx[i],ny = y + dy[i];
		if(nx >= 0 && nx < H && ny >= 0 && ny < W && a[nx][ny] == z)
		{
			a[nx][ny] = '0';
			dfs(nx,ny,z);
		}
	}
}

int main()
{
	cin >> H >> W;
	while(H && W)
	{
		for( int i = 0;i < H;++i)	cin >> a[i];
		int res = 0;
		for(int i = 0;i < H;++i)
			for(int j = 0;j < W;++j)
				if(a[i][j] != '0')
					dfs(i,j,a[i][j]),++res,a[i][j] = '0';
		cout << res << endl;
		cin >> H >> W;		
	}
	
	return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

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

	int N;
	cin >> N;

	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a.begin(), a.end());

	cout << a.back() << " ";

	int tmp = (a.back() + 1) / 2;
	auto bnd = upper_bound(a.begin(), a.end(), tmp);
	if (*bnd - tmp >= tmp - *(bnd - 1)) cout << *(bnd - 1) << "\n";
	else cout << *bnd << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
const int N=100+5;
void delR(char a[N][N],int h,int w,int dr); 
void delC(char a[N][N],int h,int w,int dc);

int main()
{
	int h,w;
	cin>>h>>w;
	char a[N][N];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin>>a[i][j];
	//删行操作 
	int i,j;
	for(i=0;i<h;){
		bool br=true; 
		for(j=0;j<w;j++){
			if(a[i][j]=='#'){
				br=false;	break;
			}
		}
		//删除第i行 
		if(br){
			h--;
			delR(a,h,w,i); 
		}
		else
			i++;
	}
	//删列操作
	for(i=0;i<w;){
		bool bc=true; 
		for(j=0;j<h;j++){
			if(a[j][i]=='#'){
				bc=false;	break;
			}
		}
		//删除第i列 
		if(bc){
			w--;
			delC(a,h,w,i); 
		}
		else
			i++;
	}
	cout<<endl;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++) 
			cout<<a[i][j];
		cout<<endl;
	}
	return 0;
}
void delR(char a[N][N],int h,int w,int dr)
{
	for(int i=dr;i<h;i++)
		for(int j=0;j<w;j++)
			a[i][j]=a[i+1][j];
}

void delC(char a[N][N],int h,int w,int dc)
{
	for(int i=dc;i<w;i++)
		for(int j=0;j<h;j++)
			a[j][i]=a[j][i+1];	
}






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

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> A(N);
	rep(i, N) {
		cin >> A.at(i).second >> A.at(i).first;
	}
	sort(A.begin(), A.end());
	int time = 0;
	rep(i, N) {
		time += A.at(i).second;
		if (time > A.at(i).first) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1792
from sys import stdin, setrecursionlimit
from itertools import accumulate

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [True] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            for j in range(2 * i * (i + 1), m, 2 * i + 1):
                p[j] = False

    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


N = 10 ** 5
P = set(prime_numbers(N))
P = [n for n in P if (n + 1) // 2 in P]
a = [0] * (N + 1)
for n in P:
    a[n] = 1
a = list(accumulate(a))

Q, *LR = map(int, open(0).read().split())
for l, r in zip(*[iter(LR)] * 2):
    print(a[r] - a[l - 1])


Measured memory_bytes: 28248
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){

double L;
double hen,volume;
cin>>L;
hen=L/3;
volume=pow(hen,3);
cout<<setprecision(10)<<volume<<endl;



  return 0;
}



Measured memory_bytes: 256