akhauriyash/Code-Regression huggingface dataset:
import numpy as np
N_MAX = 10**5

def make_prime_table(n):
    table = np.ones(n+1, dtype=np.int)
    table[0] = 0
    table[1] = 0
    for i in range(2,int(n**0.5)+1):
        if (1 == table[i]):
            j = i*2
            while j<=n:
                table[j] = 0
                j += i
    return table
  
prime_table = make_prime_table(N_MAX)
like2017_table = np.zeros(N_MAX+1, dtype=np.int)

c = 0
for i in range(3,N_MAX,2):
  if (prime_table[i] == 1):
    if (prime_table[(i+1)//2] == 1):
      c += 1
  like2017_table[i] = c
  like2017_table[i+1] = c

Q = int(input())
for q in range(Q):
  l,r = map(int, input().split())
  print(like2017_table[r] - like2017_table[l-1])


Measured memory_bytes: 16176
N = int(input())
lista = sorted(list(map(int, input().split())))
length = 2
while length>1:
    #print(length)
    #print(lista)
    for n in range(1, length):
        lista[n] = lista[n]%lista[0]
    #print(lista)
    lista = list(set(lista))
    lista.sort()
    if lista[0] == 0:
        lista.remove(0)
    #print(lista)
    length = len(lista)
print(lista[0])    


Measured memory_bytes: 14864
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;


int main()
{
    int a,b,t;
    cin>>a>>b>>t;
    int ans=t/a*b;
    cout<<ans<<endl;
    
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    vector<int> vec(1,0);
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        vec.push_back(t);
    }
    int x=0,y=0;
    int ans[100][100]={};
    bool f=false;
    ans[x][y]=1;
    vec[1]--;
    for(int i=1;i<=n;i++){
        for(int j=0;j<vec[i];j++){
            if(f==false){
                if(x+1<w){
                    x++;
                    ans[y][x]=i;
                }else{
                    y++;
                    ans[y][x]=i;
                    f=true;
                }
            }else{
                if(x-1>=0){
                    x--;
                    ans[y][x]=i;
                }else{
                    y++;
                    ans[y][x]=i;
                    f=false;
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<ans[i][j]<<(j==w-1?"\n":" ");
        }
    }
    return 0;
}

Measured memory_bytes: 384
if __name__ == "__main__":
    s = set()
    h,w,m = map(int,input().split())
    a = [0]*h
    b = [0]*w
    for i in range(m):
        x,y = map(int,input().split())
        x -= 1
        y -= 1
        a[x] += 1
        b[y] += 1
        s.add((x,y))
    amax = max(a)
    bmax = max(b)
    c = []
    d = []
    for i in range(len(a)):
      if amax == a[i]:
        c.append(i)
    for i in range(len(b)):
      if bmax == b[i]:
        d.append(i)
    minus = True
    end = False
    for x in c:
      for y in d:
        if not (x,y) in s:
          minus = False
          end = True
        if end:
            break
      if end:
        break
    ans = amax+bmax
    if minus:
        ans -= 1
    print(ans)

Measured memory_bytes: 83352
#include<iostream>
using namespace std;
typedef long long ll;
ll a[123456];
const int mod=998244353;
ll fun(ll x,ll y){
	ll res=1;
	while(y)
	{
		if(y&1)	res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res%mod;
}
int main()
{
	ll n;
	cin>>n;
	ll x,sum=1,s=0;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(i==1&&x!=0)	sum=0;
		a[x]++;
		s=max(s,x);
	}
	for(int i=s;i>=0;i--)
	{
		if(a[i]==0)	sum=0;
		if(i>1)
			sum=sum*fun(a[i-1],a[i])%mod;
	}
	if(a[0]>1)	sum=0;
	cout<<sum%mod<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define NI   -1
struct Node {
  int p = NI;
  int l = NI;
  int r = NI;
};

Node tree[30];

void preorder(int id) {
  if (id == NI) return;
  cout << " " << id;
  preorder(tree[id].l);
  preorder(tree[id].r);
}

void inorder(int id) {
  if (id == NI) return;
  inorder(tree[id].l);
  cout << " " << id;
  inorder(tree[id].r);
}

void postorder(int id) {
  if (id == NI) return;
  postorder(tree[id].l);
  postorder(tree[id].r);
  cout << " " << id;
}

int main() {
  int N; cin >> N;
 
  for (int i = 0; i < N; i++) {
    int id; cin >> id;
    cin >> tree[id].l >> tree[id].r;
    if (tree[id].l != NI) {
      tree[tree[id].l].p = id;
    }
    if (tree[id].r != NI) {
      tree[tree[id].r].p = id;
    }
  }

  // get root
  int root = 0;
  while (tree[root].p != NI) {
    root = tree[root].p;
  }

  cout << "Preorder" << endl;
  preorder(root);
  cout << endl;

  cout << "Inorder" << endl;
  inorder(root);
  cout << endl;

  cout << "Postorder" << endl;
  postorder(root);
  cout << endl;
}





Measured memory_bytes: 3092
def resolve():
    h = int(input())
    count=0
    while True:
        if h ==1:
            break
        h = int(h/2)
        count +=1
    #print(count)
    ans = 0
    for i in range(count+1):
        ans+=2**i
    print(ans)

if __name__ == "__main__":
    resolve()

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

int main()
{
    long long N,T,A;
    

    cin >> N >> T >> A;
    vector<long long> H(N);
    for(int i = 0; i < N; i++)
    {
        cin >> H.at(i);
    }

    int ans;
    long long num = pow(10,9)+1;

    
    for(int i = 0; i < N; i++)
    {
        if(abs(A*1000 - (T*1000 - H.at(i) * 6)) <= num)
        {
            num = abs(A*1000 - (T*1000 - H.at(i) * 6));
            ans = i+1;
        }
    }

    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0)
ll f(ll b,ll n)
{
    return n < b ? n : f(b,n / b) + (n % b);
}
ll n,s;
void upd(ll x,ll &ans)
{
    if (!(2 <= x && x <= n)) return ;
    if (f(x,n) == s)
        ans = min(ans,x);
}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    fi>>n>>s;
    ll ans = 1e18;
    for (int i = 1;i <= 2e6;++i)
        upd(i,ans);
    for (int i = 1;i <= 2e6;++i)
        upd((n - s) / i,ans),upd((n - s) / i + 1,ans),upd((n - s) / i - 1,ans);
    if (f(n+1,n) == s) ans = min(ans,n+1);
    if (ans == 1e18) return puts("-1") * 0;
    fo << ans << '\n';
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
string a,b="CF"; 
int al,bl;
int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){ 
            bl++;
            if(bl==2)   
                break;
        }
    if(bl==2) cout<<"Yes"; 
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

int main(){
    string S; cin >> S;
    int s1=0, s2=0;
    rep(i, S.size()){
        if(i%2==1){
            if(S[i]!='1') s1++;
            else s2++;
        }
        else{
            if(S[i]!='1') s2++;
            else s1++;
        }
    }
    cout << min(s1, s2) << endl;
    return 0;
}


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

int main() {
    int N, K, res=0, l[50];
    cin >> N >> K;
    for (int i=0; i < N; i++) cin >> l[i];
    sort(l, l+N, greater<int>());
    for (int i=0; i < K; i++) {
        res += l[i];
    }
    cout << res << endl;
}

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

/*ll fact(ll n)
{
  ll f=1,i;
  for(i=1;i<=n;i++)
  {
    f=f*i;
  }
  return f;
}*/
//#define FOR(i,0,n) for(int i=0;i<n;i++)
int main() {
  // your code goes here
 /* int t;
  cin>>t;
  while (t--)
  {*/
    
 ios_base::sync_with_stdio(false); 
    cin.tie(NULL);cout.tie(NULL);
    ll n,z,t;cin>>n;
    z=n/3;
    t=z*z*z;
    cout<<std::fixed<<std::setprecision(12)<<(1.0*n/3*n/3*n/3);
    }

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

const int mod = 924844033;
int dp[2001][2001];
long long int dp2[4001],tmp[4001],fac[2001];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for(int i=0;i<=2000;i++)
		dp[i][0]=1,dp[i][1]=i;
	for(int i=0;i<=2000;i++)
		for(int j=2;j<=2000;j++){
			if(i>0)
				dp[i][j]+=dp[i-1][j];
			if(i>1)
				dp[i][j]+=dp[i-2][j-1];
			dp[i][j]%=mod;
		}
	int n,k;
	cin>>n>>k;
	int cur=0;
	dp2[0]=1;
	for(int i=1;i<=k;i++){
		int sz=(n-i)/k;
		for(int j=0;j<=cur+((sz+1)>>1);j++)
			tmp[j]=0;
		for(int j=0;j<=cur;j++)
			for(int k=0;k<=((sz+1)>>1);k++)
				tmp[j+k]=(tmp[j+k]+dp2[j]*dp[sz][k])%mod;
		cur+=(sz+1)>>1;
		for(int j=0;j<=cur;j++)
			dp2[j]=tmp[j];
	}
	for(int i=1;i<=k;i++){
		int sz=(n-i)/k;
		for(int j=0;j<=cur+((sz+1)>>1);j++)
			tmp[j]=0;
		for(int j=0;j<=cur;j++)
			for(int k=0;k<=((sz+1)>>1);k++)
				tmp[j+k]=(tmp[j+k]+dp2[j]*dp[sz][k])%mod;
		cur+=(sz+1)>>1;
		for(int j=0;j<=cur;j++)
			dp2[j]=tmp[j];
	}
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%mod;
	for(int i=0;i<=cur;i++)
		dp2[i]=dp2[i]*fac[n-i]%mod;
	long long int ans=0;
	for(int i=0;i<=cur;i++)
		if(i&1)
			ans-=dp2[i];
		else
			ans+=dp2[i];
	ans=(ans%mod+mod)%mod;
	cout<<ans<<endl;
}



Measured memory_bytes: 16000
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <utility>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);

    for(char i='a';i<='z';i++)
    {
        cin>>i;
cout<<char(i+1);return 0;
    }
        return 0;
}


Measured memory_bytes: 256
n=gets.to_i
p=gets.split.map(&:to_i)
q=gets.split.map(&:to_i)

a=0
b=0
[*1..n].permutation.to_a.each_with_index do |perm, i|
  a=i if perm==p
  b=i if perm==q
end

puts (a-b).abs


Measured memory_bytes: 20356
#include <iostream>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int k;
	ll a[12], b[12], c[12];
	ll x, y, z, w, aa;
	while(cin >> k)
	{
		if(k==0) break;
		cin >> x >> y;
		z=y;
		reps(i, k)
		{
			a[i]=z%10;
			z/=10;
		}
		queue<pal> q;
		q.push(pal(100*x+0, 0));
		ll ans=k;
		int i;
		while(!q.empty())
		{
			x=q.front().first;
			aa=q.front().second;
			i=(int)(x%100)+1;
			x/=100;
			if(x==y)
			{
				ans=min(ans, aa);
			}
			q.pop();
			reps(j, k)
			{
				b[j]=x%10;
				x/=10;
			}
			int tmp=a[i]-b[i]+10;
			if(tmp%10!=0) aa++;
			if(i<=k)
			{
				for(int l=i; l<=k; l++)
				{
					b[l]=(b[l]+tmp)%10;
					w=0;
					reps(j, k)
					{
						w*=10;
						w+=b[k+1-j];
					}
					q.push(pal(w*100+i, aa));
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  string A,B,memo;
  int red,blue;
  cin >> A >> B;
  cin >> red >> blue;
  cin >> memo;
  if(A==memo){
    cout << red-1 << " " << blue;
  }
  else{
    cout << red << " " << blue-1;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
    int n;
    scanf("%d",&n);
    int open[105][11];
    for(int i=0; i<n; i++){
        for(int j=0; j<10; j++){
            scanf("%d",&open[i][j]);
        }
    }
    int profit[105][11];
    for(int i=0; i<n; i++){
        for(int j=0; j<=10; j++){
            scanf("%d",&profit[i][j]);
        }
    }

    int ans=0,sum,max=-1000000000,count;
    for(int i=1; i<1<<10; i++){
        ans=0;
        for(int j=0; j<n; j++){
            count=0;
            for(int k=0; k<10; k++){
                if( (1&i>>k) && open[j][k] ){
                    count++;
                }
            }
            ans+=profit[j][count];
        }
        if(ans>max)max=ans;
    }
    printf("%d",max);
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

struct pg {
	time_t in_time;
	bool is_in;
	int bless;
	pg(): in_time(0), is_in(false), bless(0) {};
};

time_t to_time(int h, int m)
{
	return h * 60 + m;
}

int main()
{
	int N;
	while(cin >> N, N) {
		pg goddess;
		vector<pg> pgs(1000);
		vi visiting_pgs;

		REP(_, N) {
			int M, D, h, m, id;
			char e;
			scanf("%d/%d %d:%d %c %d", &M, &D, &h, &m, &e, &id);
			time_t now = to_time(h, m);
			switch(id) {
				case 0: // Goddess
					if (e == 'I') {
						goddess.is_in = true;
						goddess.in_time = now;
					} else {
						goddess.is_in = false;
						for(vi::iterator it = visiting_pgs.begin(); it != visiting_pgs.end(); it++) {
							pgs[*it].bless += now - max(goddess.in_time, pgs[*it].in_time);
							pgs[*it].in_time = now;
						}
					}
					break;
				default:
					if (e == 'I') {
						pgs[id].is_in = true;
						pgs[id].in_time = now;
						visiting_pgs.push_back(id);
					} else {
						if (goddess.is_in) {
							pgs[id].bless += now - max(goddess.in_time, pgs[id].in_time);
						}
						visiting_pgs.erase(find(ALL(visiting_pgs),id));
					}
					break;
			}
		}

		int ans = 0;
		REP(i, pgs.size()) {
			ans = max(ans, pgs[i].bless);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1284
#include <iostream>
#include <queue>
#include <list>
#include <vector>
#include <string>

using namespace std;

#define MIN(x, y) x<y?x:y

int main()
{
	int x, ans=0;

	for (int i = 0; i < 5; i++)
	{
		cin>>x;
		if(x==0) ans=i;
	}

	cout<<ans+1<<endl;

	return 0;
}


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

int main() {

  int N, A, B;
  cin >> N >> A >> B;
  
  if (N * A < B) {
    cout << N * A <<endl;
  }
  else if (N * A == B) {
    cout << B <<endl;
  }
  else {
    cout << B <<endl;
  }
  
}


Measured memory_bytes: 3640
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, M, C;
  std::cin >> N >> M >> C;
  std::vector<i64> B;
  tools::read(B, M);

  i64 answer = 0;
  for (i64 i = 0; i < N; ++i) {
    std::vector<i64> A_i;
    tools::read(A_i, M);
    i64 feature = C;
    for (i64 j = 0; j < M; ++j) {
      feature += A_i[j] * B[j];
    }
    if (feature > 0) ++answer;
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
    Scanner cin = new Scanner();
	  int[] w = new int[10];
    int[] k = new int[10];
	  for (int i = 0; i < 10; i++)
	  {
	    w[i] = cin.nextInt();
	  }
	  for (int i = 0; i < 10; i++)
	  {
	    k[i] = cin.nextInt();
	  }
    Array.Sort(w);
    Array.Reverse(w);
    Array.Sort(k);
    Array.Reverse(k);
    int[] W = new int[3];
    int[] K = new int[3];
    Array.Copy(w, W, 3);
    Array.Copy(k, K, 3);
    Console.WriteLine("{0} {1}", W.Sum(x => x), K.Sum(x => x));
	  return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll a;
	string s;
	cin >> a >> s;
	s.erase(s.end() - 3);
	cout << a * stoi(s) / 100 << endl;
}

Measured memory_bytes: 3672
n=int(input())
d=[]
ans=False
for i in range(n):
    d1,d2=map(int,input().split())
    d.append((d1,d2))

for i in range(n-2):
    d1,d2=d[i]
    e1,e2=d[i+1]
    f1,f2=d[i+2]
    if d1==d2 and e1==e2 and f1==f2:
        ans=True
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

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

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    ll a=2, b=1;
    if (n==0)
    {
        cout<<a;
        return 0;
    }
    if (n==1)
    {
        cout<<b;
        return 0;
    }
    ll c;
    for (int i=2;i<=n;i++)
    {
        c=a+b;
        a=b;
        b=c;
    }
    cout<<c;

    return 0;
}

Measured memory_bytes: 3620
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        _: usize,
        k: usize,
        mut s: Chars,
    }

    s[k - 1] = s[k - 1].to_lowercase().nth(0).unwrap();

    println!("{}", s.iter().collect::<String>());
}


Measured memory_bytes: 2100
#include<stdio.h>

int main(){

   int H, W;
   int i, j;

   scanf("%d %d", &H, &W);

   while(H!=0 || W!=0){
      for(i=0;i<H;i++){
         for(j=0;j<W;j++){
            printf("#");
         }
         printf("\n");
      }
      printf("\n");
      scanf("%d %d", &H, &W);
   }
   
   return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#define Ll long long
using namespace std;
const int N=5e5+5;
struct cs{
    Ll v;int id;
    bool operator <(const cs &a)const {return v<a.v;}
}t;
priority_queue<cs>Q;
Ll a[N],ans;
int l[N],r[N];
bool ok[N];
int n,m;
int main()
{
    scanf("%d",&n);m=n/2;
    for(int i=1;i<=n;i++){
        scanf("%lld",&t.v);
        a[i]=t.v;
        t.id=i;
        l[i]=i-1;
        r[i]=i+1;
        Q.push(t);
    }
    r[0]=1;l[n+1]=n;
    a[n+1]=a[0]=-1e14;
    while(m--){
        while(ok[Q.top().id])Q.pop();
        t=Q.top();Q.pop();
        ans+=t.v;
        int x=t.id;
        a[x]=a[l[x]]+a[r[x]]-a[x];
        t.v=a[x];
        ok[l[x]]=ok[r[x]]=1;
        l[x]=l[l[x]];r[l[x]]=x;
        r[x]=r[r[x]];l[r[x]]=x;
        Q.push(t);
    }
    printf("%lld",ans);
}


Measured memory_bytes: 9988
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

#define MAXN 16
int Q[MAXN][MAXN];//i番目の人がいうj番目がどういう状態か
int N;
int A[MAXN];//i番目の人の証言の数
int tmp[MAXN];
bool flag = 0;
void set_data(){
    cin >> N;
    rep(i,MAXN)rep(j,MAXN)Q[i][j] = 2;
    rep(i,N){
        cin >> A[i];
        rep(j,A[i]){
            int a;
            cin >> a;
            a--;
            cin >> Q[i][a];
        }
    }
    return ;
}

int main(){
    set_data();
    if(N==1&&A[0]==0)flag = 1;
    int ans = 0;
    int count = 0;
    int j;
    for(int i=0;i<(1<<N);i++){
        rep(l,MAXN)tmp[l] = 2;
        for(j=0;j<N;j++){
            if(i&(1<<j)){
                count++;
                if(tmp[j]==0)j = N*2;
                tmp[j] = 1;

                //j番目の人が正直だと仮定
                for(int k=0;k<N;k++){
                    if(Q[j][k]==2){
                    }else if(tmp[k]==2){
                        tmp[k] = Q[j][k];
                    }else if(tmp[k]!=Q[j][k])j = N*2;
                    
                }
            }else{
                if(tmp[j]==2)tmp[j] = 0;
                if(tmp[j]==1){
                    j = N*2;
                }
                //j番目の人は嘘つきと仮定している
            }
        }
        if(j<N+1){
            ans = max(ans,count);
        }
        count = 0;
    }
    if(flag)cout << 1 << endl;
    else cout << ans << endl;
    return 0;
}

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


int main() {
    int N;
    cin >> N;
    int flag = 0;
    while(N >= 0) {
        if (N%7 == 0) {
            cout << "Yes" << endl;
            flag++;
            break;
        }
        N -= 4;    
    }
    if (flag == 0) {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	while(1){
		ll N,M; cin >> N >> M;
		if(!N && !M) break;
		ll r; cin >> r;
		vvl v(N,vl(725,-1));
		ll now = 0;
		set<P> se;
		while(r--){
			ll t,n,m,s; cin >> t >> n >> m >> s; n--; t -= 540;
			REP(i,now,t){
				for(auto j : se) v[j.first][i] = j.second;
			}
			now = t;
			if(s == 1) se.emplace(n,m);
			else se.erase(P(n,m));
		}
		ll q; cin >> q;
		while(q--){
			ll ts,te,m; cin >> ts >> te >> m;
			ts -= 540; te -= 540;
			ll ans = 0;
			REP(j,ts,te){
				rep(i,N){
					if(v[i][j] == m){
						ans++;
						break;
					}
				}
			}
			cout << ans << "\n";
		}
	}
}


Measured memory_bytes: 8288
#include<stdio.h>

int main(void){
	
	int array[101][101]={};
	int i,t,r,c,a;
	
	
	scanf("%d %d",&r,&c);
	
	for(i=0;i<r;i++){
		for(t=0;t<c;t++){
			scanf("%d",&a);
			array[i][t] = a;
			array[i][c] += a;
			array[r][t] += a;
			array[r][c] += a;
		}
	}
	for(t=0;t<=r;t++){
		for(i=0;i<=c;i++){
			printf("%d",array[t][i]);
			if(i != c){
				printf(" ");
			}
		}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 652
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n, k = NextInts()
da = NextIntList()

for i in range(k, n):
    if da[i] > da[i-k]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 32348
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n int

    fmt.Scan(&n)
    player := make([]int, n)

    for i := 0; i < n; i++ {
        fmt.Scan(&player[i])
    }

    //フレンドリーを逆順にソートする
    sort.Sort(sort.Reverse(sort.IntSlice(player)))
    /*
    4
    3 2 2 1
    3 (2)        -> 3 1/2 = 0
    3 (2) 2      -> 2 2/2 = 1
    3 2 (1) 2    -> 2 3/2 = 1
    =>7
    
    7
    7 6 5 4 3 2 1
    7 (6)            -> 7 1/2 = 0
    7 (5) 6          -> 6 2/2 = 1
    7 5 6 (4)        -> 6 3/2 = 1
    7 (3) 5 6 4      -> 5 4/2 = 2
    7 3 5 (2) 6 4    -> 5 5/2 = 2
    7 3 5 2 6 (1) 4  -> 4 6/2 = 3
    =>33
    */


    comfort := 0
    for i := 1; i < n; i++ {
        comfort += player[i/2]
    }
    fmt.Println(comfort)
}



Measured memory_bytes: 6500
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

signed main() {

	int n, a, b;
	cin >> n >> a >> b;
	int ans = n * a < b ? n * a : b;
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
def Alchemist(n , vl):

    vl.sort()
    ans = vl[0]

    for i in range(1 , n):
        ans = (ans + vl[i]) / 2

    return ans

def main():
    n = int(input())
    vl = list(map(int , input().split()))
    print(Alchemist(n , vl))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(int i=0; i<n; i++)
#define rep(i,start,n) for(int i=start; i<n; i++)

void solve(){
	string s;cin>>s;

	int n = s.length();

	int st=0,ed=n-1;

	while(s[st]!='B' && st<n)st++;
	while(s[ed]!='W' && ed>=0)ed--;

	int ans = 0;
	int cnt = 0;

	if(st>=ed  || st>=n || ed<0){
		cout<<ans<<endl;
		return;
	}

	for(int i=ed;i>=st;i--){
		if(s[i]=='W')cnt++;
		else ans+=cnt;
	}
	cout<<ans<<endl;
	
}
	
signed main(){
    fast;    
    // int t;cin>>t;while(t--)
    solve();    
    return 0;
}


Measured memory_bytes: 3792
#include <vector>
#include <iostream>
#include <stdio.h>
#include <functional>
#include <cassert>

using namespace std;

int main() {
	int n, q, x, y, com, tmp;
	cin >> n >> q;
	vector<int> a(n, 2147483647);
	for (int i = 0; i < q; ++i) {
		cin >> com >> x >> y;
		if (com == 0) {
			tmp = a[x];
			a[x] = y;
		}
		else {
			int kai = a[x];
			for (int i = x+1; i <= y; ++i) {
				if (kai > a[i]) {
					kai = a[i];
				}
			}
			cout << kai << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3132
def main():
        
    h,w,k = map(int,input().split())
    s=[]
    for i in range(h):
        s.append(list(input()) )
    empty=[ss==["."]*w for ss in s]
    last_false=-1
    to_see=[]
    for i in range( len(empty) ):
        if empty[i]==False:
            last_false=i
            to_see.append(i)
        else:
            to_see.append(last_false)
    
    to_see2 = [t for t in to_see if t!=-1][0]
    to_see = [t if t!=-1 else to_see2 for t in to_see]
    c=0
    colors=[]
    for ss in s:
        c=0
        color=[]
        for si in ss:
            if si=="#":
                c+=1
            color.append(c)
        color=[1 if col==0 else col for col in color]
    #    c=color[-1]+1
        colors.append(color)
        
    c=0
    for i in range(h):
        if empty[i]:
            colors[i] = colors[to_see[i]]
        else:
            c+=1        
            if i>0 and c>1:
                colors[i] = [colors[i][j]+ colors[i-1][-1] for j in range(w)]
    for i in range(h):
        print(*colors[i])
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 50140
#include<stdio.h>
#include<string.h>
#define R 100000
int dp[55][3005];
int main(){
	int h,i,j,k,n,m,s,ans;
	while(1){
		scanf("%d%d%d",&n,&m,&s);
		if(n+m+s==0)break;
		memset(dp,0,sizeof(dp));
		ans=0;
		dp[0][0]=1;
		for(i=1;i<=m;i++){
			for(j=n*n;j>0;j--){
				for(k=i;k<=s;k++){
					dp[j][k]+=dp[j-1][k-i];
					dp[j][k]%=R;
				}
			}
		}
		printf("%d\n",dp[n*n][s]);
	}
	
	return 0;
}
//n×n-i+1

Measured memory_bytes: 1052
#include <stdio.h>

int main(void) {
	
	int t,n,i,x;
	
	for(i=0; i < 4;i++){
		scanf("%d %d",&t,&n);
		
		if(t==1){
			x=6000*n;
		}else if(t==2){
			x=4000*n;
		}else if(t==3){
			x=3000*n;
		}else if(t==4){
			x=2000*n;
		}
		
		printf("%d\n",x);
	}
	
		return 0;
}

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

int main() {
  int n;
  cin >> n;
  set<string> s;
  rep(i, n) {
    string v;
    cin >> v;
    s.insert(v);
  }
  if (s.size() == 3)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
ps = map(float, input().split())

dp = [0] * (N+1)
dp[0] = 1
for p in ps:
    pp = 1 - p
    for j in reversed(range(N+1)):
        dp[j] = dp[j]*pp + dp[j-1]*p

print(sum(dp[(N+1)//2:]))


Measured memory_bytes: 43612
#include <cstdio> 
#include<iostream>
using namespace std;
typedef long long ll;
ll sum (ll n) {
    return n*(n+1)/2;
}

int main() {
     ll n, res;
    scanf("%lld", &n);
    res=sum(n)-3*sum(n/3)-5*sum(n/5)+15*sum(n/15);
    printf("%lld\n", res);
    return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  char a,b;
  cin >> a >> b;
  
  if(a=='H'&&b=='H' || a=='D'&&b=='D') cout << 'H' << endl;
  else cout << 'D' << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;

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

            string x = "";

            for (int i = 0; i < str.Length; i++)
            {
                x += "x";
            }

            Console.WriteLine(x);
        }
    }
}


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

int main() {
    string str;
    cin >> str;
    int n = str.size();
    for (int i = 0; i < n; ++i) {
        cout << str[n - i - 1];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+10;
const ll MOD=1e9+7;


int main(){
	ll p2[MAX];
	ll p3[MAX];
	p2[0]=1;
	p3[0]=1;
	rep1(i,100005){
		p2[i]=(2*p2[i-1])%MOD;
		p3[i]=(3*p3[i-1])%MOD;
	}
	
	string L;
	cin>>L;
	int n=sz(L);
	int bit[MAX];
	rep(i,n){
		if(L[n-i-1]=='0')bit[i]=0;
		else bit[i]=1;
	}
	ll ans=0;
	ll ti=1;
	ll ds=0;
	for(int i=n-1; i>=0; i--){
		if(bit[i]==1){
			ll tmp=(ti*p3[i])%MOD;
			ans=(ans+tmp)%MOD;
			ds++;
          	ti=(2*ti)%MOD;
		}
	}
	ans=(ans+p2[ds])%MOD;
	cout<<ans<<endl;
}


Measured memory_bytes: 2432
using System;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            var combinatorialDiscriminant = new CombinatorialDiscriminant(S);
        }
    }

    class CombinatorialDiscriminant
    {
        public CombinatorialDiscriminant(string target)
        {
            bool result = Exists(target);
            if (result) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }

        private bool Exists(string target)
        {
            bool result1 = Regex.IsMatch(target, "[A]{3}");
            bool result2 = Regex.IsMatch(target, "[B]{3}");

            if (result1 == false && result2 == false) return true;
            return false;
        }
    }
}


Measured memory_bytes: 15948
import scala.io.StdIn._
import scala.annotation.tailrec
import scala.collection._

object Main {

  def sieve(top: Int): Iterator[Int] = {
    val topNdx = (top - 3) / 2 + 1
    val (cmpsts, sqrtLmtNdx) = (new Array[Int]((topNdx >>> 5) + 1), (Math.sqrt(top).toInt - 3) / 2)

    @inline def isCmpst(ci: Int): Boolean =
      (cmpsts(ci >>> 5) & (1 << (ci & 31))) != 0

    @inline def setCmpst(ci: Int): Unit =
      cmpsts(ci >>> 5) |= 1 << (ci & 31)

    @tailrec def forCndNdxsFrom(cndNdx: Int): Unit = {
      if(cndNdx <= sqrtLmtNdx){
        if(!isCmpst(cndNdx)){
          val p = 2 * cndNdx + 3

          @tailrec def cullPrmCmpstsFrom(cmpstNdx: Int): Unit =
            if(cmpstNdx <= topNdx){
              setCmpst(cmpstNdx)
              cullPrmCmpstsFrom(cmpstNdx + p)
            }

          cullPrmCmpstsFrom((p * p - 3) >>> 1)
        }
        forCndNdxsFrom(cndNdx + 1)
      }
    }

    forCndNdxsFrom(0)

    @tailrec def getNxtPrmFrom(cndNdx: Int): Int =
      if ((cndNdx > topNdx) || !isCmpst(cndNdx)) 2 * cndNdx + 3
      else getNxtPrmFrom(cndNdx + 1)

    Iterator.single(2) ++ Iterator.iterate(3)(p => getNxtPrmFrom((p - 1) >>> 1)).takeWhile(_ <= top)
  }

  @tailrec
  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(sieve(n).size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit ={
    loop(readLine)
  }
}

Measured memory_bytes: 65872
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

const MOD: i64 = 1_000_000_007;

fn main() {
    let n = scan!(usize);
    let vs = scan!(usize;;);

    let mut nums = vec![0; n];
    for v in vs {
        nums[v] += 1
    }

    if nums[0] == 0 {
        let mut ans = 1;
        for i in 1..n {
            if i % 2 == 1 {
                if nums[i] == 2 {
                    ans *= 2;
                    ans %= MOD;
                } else {
                    println!("{}", 0);
                    return;
                }
            }
        }
        println!("{}", ans)
    } else if nums[0] == 1 {
        let mut ans = 1;
        for i in 1..n {
            if i % 2 == 0 {
                if nums[i] == 2 {
                    ans *= 2;
                    ans %= MOD;
                } else {
                    println!("{}", 0);
                    return;
                }
            }
        }
        println!("{}", ans)
    } else {
        println!("{}", 0);
    }
}


Measured memory_bytes: 6396
def count(i,j):
  count = 0
  if list[i][j-1]=='#':
    count +=1
  if list[i][j+1]=='#':
    count +=1
  if list[i-1][j]=='#':
    count +=1
  if list[i+1][j]=='#':
    count +=1
  if count >= 1:
    return True
  else:
    return False

h,w = map(int, input().split())
s_init='0'*(w+2)
flag=True
list=[]
list.append(s_init)
for i in range(h):
  s=str(input())
  list.append('0'+s+'0')
list.append(s_init)
for i in range(1,h+1):
  for j in range(1,w+1):
    if list[i][j]=='#':
      if not(count(i,j)):
        flag=False
if flag:
  print('Yes')
else:
  print('No')

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

using namespace std;
typedef long long ll;
 



void solve(){
	ll m,n,k;
	cin >> n >> m >> k;
	vector<ll> a(n);
	vector<ll> b(m);
	for(int i = 0; i<n; i++){
		cin >> a[i];
	}
	for(int i = 0; i<m; i++){
		cin >> b[i];
	}
	vector<ll> sumA(n+1);
	vector<ll> sumB(m+1);
	for(int i = 0; i<n; i++){
		sumA[i+1] = sumA[i] + a[i];
	}
	for(int i = 0; i<m; i++){
		sumB[i+1] = sumB[i] + b[i];
	}
	int total = 0;
	for(int i = 0; i<= n;i++){
		ll other = k-sumA[i];
		if(other < 0){
			continue;
		}
		int l = lower_bound(sumB.begin(), sumB.end(), other)-sumB.begin();
		if(l>m||sumB[l]>other){
			--l;
		}
		total = max(total, i+l);
	}
	cout << total;
}

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

Measured memory_bytes: 9600
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
using namespace std;

int main() {
  int N,r=0,b=0;
  string s;
  cin >> N >> s;
  for (int i = 0; i < N; i++) {
    if(s[i] == 'R') {
      r++;
    } else {
      b++;
    }
  }
  if(r>b)s="Yes";
  else s="No";
  cout <<  s << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int[][] wav = new int[n][2];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 2; j++){
                wav[i][j] = sc.nextInt();
            }
        }
        int m = n * 1000 + 1;
        long[] dp = new long[m];
        for (int i = 1; i < m; i++) {
            dp[i] = n * 1000000000l + 1;
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = m - 1; j >= 0; j--) {
                if (j >= wav[i][1]) {
                    dp[j] = Math.min(dp[j], dp[j - wav[i][1]] + wav[i][0]);
                }
                if (dp[j] <= w) {
                    ans = Math.max(ans, j);
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24404
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	double x,h;
	while(cin >> x >> h && x && h)
	{
		double sum = 0;
		sum += x*x;
		double half = x /2;
		sum += 2*x*sqrt(half*half+h*h);

		cout << fixed;
		cout.precision(6);
		cout << sum << endl;
	}
	return 0;
}

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

#define EPS 1e-10

int main(){
  int n;cin>>n;
  for(int i=0;i<n;++i){
    double a,b,c,d,e,f,g,h;cin>>a>>b>>c>>d>>e>>f>>g>>h;
    double dx1,dy1,dx2,dy2;
    dx1 = a - c;
    dy1 = b - d;
    dx2 = e - g;
    dy2 = f - h;
    //cout << dx1 << " " << dy1 << " " << dx2 << " "<<dy2<<endl;
    double det = fabs(dx1*dy2 - dx2*dy1);
    (fabs(det)<EPS) ? cout<<"YES"<<endl : cout<<"NO"<<endl;
  }
  return EXIT_SUCCESS;
}

Measured memory_bytes: 1232
from sys import stdin
from math import factorial

#長さNのビット列を列挙する
def make_bit_line(N):
    output=[]
    for i in range(0, 2**N):
        temp_list = []
        bin_num = bin(i)[2:]
        for k in range(N-len(bin_num)):
            temp_list.append(0)
        for i in range(len(bin_num)):
            temp_list.append(int(bin_num[i]))

        output.append(temp_list)
    return output

def calc_val(S,bianry):
    total_num = 0
    last_pos = 0
    for i in range(len(binary)):
        if(binary[i]==1):
            total_num += int(S[last_pos:i+1])
            last_pos = i+1
    total_num+=int(S[last_pos:])
    return total_num




S = str(stdin.readline().rstrip())

N = len(S)

total_sum = 0
bit_line = make_bit_line(N-1)

for binary in bit_line:
    total_sum += calc_val(S, binary)

print(total_sum)

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	ll n ;
	cin >> n ;
	vector<ll> a(5);
	rep(i,5) cin >> a[i];
	SORT(a);
	ll group = ( n +a[0] - 1 ) / a[0];
	cout << group + 4 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
long long gcd(long long p, long long q){
	long long r;
	if (p > q){
		r = p;
		p = q;
		q = r;
	}
	if (q%p == 0) return p;
	else return gcd(q - (p*(q / p)), p);
}
int main(void){
	long long a, b, g;
	for (; scanf("%lld %lld", &a, &b) != EOF;){
		g = gcd(a, b);
		printf("%lld %lld\n", g, a*b / g);
	}
		return 0;
	}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    set<int> St = {a, b, c};
    cout << St.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  int x[n];
  int y[n];
  for(int i = 0; i < n; i++){
    cin>>x[i];
    y[i]=x[i];
  }
  //中央値を調べる
  sort(y,y+n);
  int tmp1=y[n/2-1];
  int tmp2=y[n/2];
 

  for(int i = 0; i<n; i++){
    if(x[i]<=tmp1) cout<<tmp2<<endl;
    else cout<<tmp1<<endl;
  }
  return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> input(h);
  vector<vector<int>> a(h, vector<int>(w));
  queue<pair<int, int>> q;
  for (int i=0; i<h; i++) {
    cin >> input[i];
    for (int j=0; j<w; j++) {
      if (input[i][j] == '#') {
        a[i][j] = 1;
        q.push({i, j});
      } else {
        a[i][j] = 0;
      }
    }
  }

  int cnt = 1;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();

    //      y1
    // x1 [x, y] x2
    //      y2
    int y = p.first, x = p.second;
    // cout << y << " " << x << endl;
    int y1 = y - 1, y2 = y + 1;
    int x1 = x - 1, x2 = x + 1;

    // cout << "a[x][y]: " << a[x][y] << endl;

    if (y1 >= 0 && y1 < h && a[y1][x] == 0) {
      a[y1][x] = a[y][x] + 1;
      q.push({y1, x});
      cnt = max(cnt, a[y1][x]);
    }
    if (y2 >= 0 && y2 < h && a[y2][x] == 0) {
      a[y2][x] = a[y][x] + 1;
      q.push({y2, x});
      cnt = max(cnt, a[y2][x]);
    }
    if (x1 >= 0 && x1 < w && a[y][x1] == 0) {
      a[y][x1] = a[y][x] + 1;
      q.push({y, x1});
      cnt = max(cnt, a[y][x1]);
    }
    if (x2 >= 0 && x2 < w && a[y][x2] == 0) {
      a[y][x2] = a[y][x] + 1;
      q.push({y, x2});
      cnt = max(cnt, a[y][x2]);
    }
  }

  cout << cnt - 1 << endl;

  return 0;
}


Measured memory_bytes: 13456
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
        int b =sc.nextInt();
        System.out.println(a*b+" "+(2*a+2*b));
    }
 
}


Measured memory_bytes: 25936