akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;
const int INF = numeric_limits<int>::max() / 2;

int sx,sy,n,t;
int field[200][200];//0:can't 1:can
int d[200][200];
int dx[6]={1,0,1,-1,0,-1},dy[6]={1,1,0,-1,-1,0};

void solve(){
  queue<pii> que;
  for(int i=0;i<200;i++) for(int j=0;j<200;j++) d[i][j]=INF;
  que.push(pii(sx+100,sy+100));
  d[sx+100][sy+100]=0;

  while(que.size()){
    pii p=que.front();que.pop();
    for(int i=0;i<6;i++){
      int nx=p.first+dx[i],ny=p.second+dy[i];

      if(0<=nx&&nx<200&&0<=ny&&ny<200&&field[nx][ny]&&d[nx][ny]==INF){
        que.push(pii(nx,ny));
        d[nx][ny]=d[p.first][p.second]+1;
      }
    }
  }
}

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

  while(true){
    cin >>t >> n;
    if(n==0&&t==0)break;
    for(int i=0;i<200;i++) for(int j=0;j<200;j++) field[i][j]=1;
    for(int i=0;i<n;i++){
      int x,y;cin >> x>> y;
      field[x+100][y+100]=0;
    }
    cin >> sx>>sy;
    solve();
    int res=0;
    for(int i=0;i<200;i++) for(int j=0;j<200;j++) if(d[i][j]<=t) res++;
    cout <<res << endl;
  }
}

Measured memory_bytes: 3452
import sys

S = input()

if len(S)>=10:
    print("NO")
    sys.exit()

for i in range(2**(len(S)+1)):
    op_list = [""]*(len(S)+1)

    for j in range(len(op_list)):
        if (i>>j) & 1:
            op_list[j] = "A"

    s = ""

    for k in range(len(op_list)-1):
        s = s + op_list[k] + S[k]

    s = s + op_list[len(op_list)-1]

    if s=="AKIHABARA":
        print("YES")
        sys.exit()

print("NO")

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        // 主処理
        String result = "123".replace(a, "").replace(b, "");

        // 出力
        System.out.println(result);
        sc.close();
    }
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  stack<char> t;
  rep(i,s.size()){
    if(s[i]=='B'){
      if(!t.empty()) t.pop();
    }
    else if(s[i]=='0') t.push('0');
    else if(s[i]=='1') t.push('1');
  }
  string ans="";
  while(!t.empty()){
    ans+=t.top();
    t.pop();
  }
  reverse(all(ans));
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#define Max 3002
#define MAX_INT (int)1e15+2
#define MOD ((int)1e9+7)
using namespace std;

double dp[Max][Max];
bool vis[Max][Max];
double a[Max];

void init(){
	int i,j;
	for(i=0;i<Max;i++)
		for(j=0;j<Max;j++){
			vis[i][j] = false;
			dp[i][j] = 0.0;
		}
}

double solve(int pos,int minHead,int n){
	if(pos >= n){
		if(minHead > n/2)
			return 1.0;
		return 0.0;
	}

	if(vis[pos][minHead])
		return dp[pos][minHead];

	vis[pos][minHead] = true;
	double x = (double)solve(pos+1,minHead,n)*(1-a[pos]);//tail
	double y = (double)solve(pos+1,minHead+1,n)*a[pos];//head
	dp[pos][minHead] = x+y;
	return dp[pos][minHead];
}


int main(){
	int n,i;
	init();
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%lf",&a[i]);

	int minHead = (n/2)+1;
	double ans = solve(0,0,n);
	cout << setprecision(10) << ans << endl;
}










/*
Atcoder Dp G-Longest Path iterative solution

vector<int>vec[Max];
queue<int>q;

int dp[Max];
int vis[Max];

void init(){
	int i;
	for(i=0;i<Max;i++){
		dp[i] = 0;
		vis[i] = 0;
	}
}

int getMax(int a,int b){
	return (a<b)?b:a;
}

void solve(int x){
	int i,u;
	q.push(x);

	while(!q.empty()){
		u = q.front();
		q.pop();

		if(vis[u])
			continue;
		vis[u] = 1;
		
		for(i=0;i<vec[u].size();i++){
			dp[vec[u][i]] = getMax(dp[vec[u][i]],dp[u]+1);
			q.push(vec[u][i]);
		}
	}

}

int main(){
	int n,m,incoming[Max],x,y,i;
	for(i=0;i<Max;i++)
		incoming[i] = 0;
	
	init();

	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		vec[y].push_back(x);
		incoming[x]++;
	}
	
	for(i=1;i<=n;i++)
		solve(i);
	
	int max = 0;
	for(i=0;i<Max;i++)
		max = getMax(max,dp[i]);
	
	printf("%d\n",max);
	return 0;
}
*/

Measured memory_bytes: 79744
from collections import defaultdict
mod=10**9+7
n=int(input())
A=tuple(map(int,input().split()))

def solve(n,A):
    D=defaultdict(int)
    for a in A:
        D[a]+=1
    if n%2:
        if D[0]!=1:
            return 0
        for i in range(2,n,2):
            if D[i]!=2:
                return 0
    else:
        for i in range(1,n,2):
            if D[i]!=2:
                return 0
    return pow(2,n//2,mod)

print(solve(n,A))

Measured memory_bytes: 58476
#include <bits/stdc++.h>
using namespace std;
int n, nn;
set<string> res;
void f(string s) {
	if(s.length() > 0 && stoi(s) <= nn){
		set<char> st;
		for(int i=0; i<s.length(); ++i) {
			st.insert(s[i]);
		}
		if(st.size() == 3)
		  res.insert(s);
	} 
	if(s.length() == n) {
		return;
	}
	f(s + '3');
	f(s + '5');
	f(s + '7');
}

int main() {
	cin >> nn;
	n = to_string(nn).length();
	f("");
	cout << res.size() << "\n";
	return 0;
}

Measured memory_bytes: 2688
#include<stdio.h>
#include<string.h>

int main(){
	int ok[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
	int i, n, k, a, m;
	scanf("%d", &n);
	scanf("%d", &k);
	int D[k+1];
	for(i = 0; i < k; i++){
		scanf("%d", &(D[i]));
		ok[D[i]] = -1;
	}
	for(m = n; ; m++){
		char in[6] = {'\0'};
		sprintf(in, "%d", m);
		int allok = 0;
		for(i = 0; i < strlen(in); i++){
			/*各桁の判定パート*/
			int j = in[i] - '0';
			if(ok[ j ] == j){
				allok += 1;
			}else{
				break;
			}
		}
		
		if(allok == strlen(in)){
			printf("%d\n", m);
			break;
		}
	}
	return 0;
}

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

int main(){
	int N;
	int count = 0;
	cin >> N;
	for(int num = 1; num <= N; num += 2){
		int div_count = 0;
		for(int i=1; i <= num; i++){
			if(num%i == 0){
				div_count++;
			}
		}
		if(div_count == 8)	count++;
	}
	cout << count;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

var S string

func main() {
	fmt.Scanf("%s", &S)

	runes := []rune(S)

	m := make(map[rune]interface{})
	for i := 0; i < len(S); i++ {
		m[runes[i]] = runes[i]
	}

	if len(m) == 3 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool g[777][777];
vector<int>G[777];
int n,m;
int color[777];
bool dfs(int u,int c)
{
	color[u]=c;
	int ans=1;
	for(int i=0;i<G[u].size();i++)
	{
		ans&=color[G[u][i]]<0?dfs(G[u][i],c^1):color[G[u][i]]^c;
	}
	return ans;
}
bool check()
{
	bool ans=true;
	int c=-2;
	for(int i=0;i<n;i++)if(color[i]<0)ans&=dfs(i,c+=2);
	return ans;
}
pair<int,int>cnt[777];
int dp[777][777];
int f(int a)
{
	return a*(a-1)/2+(n-a)*(n-a-1)/2;
}
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)color[i]=-1;
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		g[a][b]=g[b][a]=1;
	}
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)
	{
		if(!g[i][j])
		{
			G[i].push_back(j);
			G[j].push_back(i);
		}
	}
	if(!check())
	{
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		if(color[i]%2)cnt[color[i]>>1].second++;
		else cnt[color[i]>>1].first++;
	}
	dp[0][0]=1;int i;
	for(i=0;cnt[i].first>0;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i+1][j+cnt[i].first]|=dp[i][j];
			dp[i+1][j+cnt[i].second]|=dp[i][j];
		}
	}
	int ans=1e9;
	for(int j=0;j<=n;j++)if(dp[i][j])ans=min(ans,f(j));
	cout<<ans<<endl;
}


Measured memory_bytes: 3200
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define pli pair<long long , int>
#define pil pair<int ,long long>
#define pi acos(-1)
#define pb push_back
#define mkp make_pair
#define all(a) a.begin(), a.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    string s,t;
    cin>>s>>t;

    string o = t+s;
    cout<<o<<"\n";
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	count := 0

	count += n / 25
	n = n % 25
	count += n/10
	n = n % 10
	count += n / 5
	n = n % 5
	count += n

	fmt.Println(count)
}


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

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

using namespace std;

int s(int n){
	int res=0;
	while(n)res+=n%10,n/=10;
	return res;
}

int main(){
	int n;
	cin>>n;
	cout<<(n%s(n)?"No":"Yes");
}

Measured memory_bytes: 3612
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pb push_back
using namespace std;
void solve(){
   string s;
   cin>>s;
   if(s[0]==s[1] && s[1]==s[2] && s[0]=='R'){
       cout<<"3";
   }else if((s[0]==s[1] || s[1]==s[2]) && s[1]=='R')
   cout<<"2";
   else if(s[0]=='R' || s[1]=='R' ||s[2]=='R')cout<<"1";
   else
   cout<<"0";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 3672
import bisect

N,M = map(int,input().split())
PY = [list(map(int,input().split())) for _ in range(M)]
L = [[] for _ in range(N)]

for P,Y in PY:
    bisect.insort_left(L[P-1],Y)

for P,Y in PY:
    P_ans = str(P).zfill(6)
    Y_ans = str(bisect.bisect_right(L[P-1],Y)).zfill(6)
    print(P_ans,Y_ans,sep="")

Measured memory_bytes: 37468
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ull=unsigned long long;
const int mod=1e9+7;
const ll N = 4e5+5;


vector<ll>ans,veca,vecb;
vector<int>adj[N];
vector<double>aka;
vector<pair<int,double>>dp[N];
vector<bool>vis;


void init(int n){
    ans.clear();veca.clear();aka.clear();vis.clear();
    vecb.clear(),vecb.resize(n);veca.resize(n);vis.resize(n);
    for (int i = 0; i <n; i++) {
        vis[i]=0;
    }
    for (int i = 0; i<=n; i++) {
        adj[i].clear();
    }
    for (int i = 0; i <=n; i++) {
        dp[i].clear();
    }
    
}
int power(int a,int n){
    int res=1;
    for (int i = 0; i < n; i++) {
        res=(1LL*res*a)%mod;
    }
    return res%mod;
}
int add(int a){
    if(a<0) a+=mod;
    return a;
}
void solve(){
    int n;
    cin>>n;
    int akash=(power(10,n)%mod)-((2LL*(power(9,n)))%mod)+(power(8,n)%mod);
    akash=add(akash);
    cout<<akash<<"\n";
    
}

int main(){
   
   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
        
        
    return 0;
}

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

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n,x,t;
    cin>>n>>x>>t;
    n=n+x-1;
    long long int ans=n/x;
    ans=ans*t;
	cout<<ans;

return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;



int main() {
	string S;
   	cin>>S;
  	ll ans=0;
  
  	for(int bit=0;bit<(1<<(S.size()-1));bit++){
      	string val={S[0]};
      	for(int i=0;i<S.size()-1;i++){
         	if(bit&(1<<i)){
               ans+=stoll(val);
               val={S[i+1]};
            }else{
               val.push_back(S[i+1]); 
            }
        }
      	ans+=stoll(val);
    }
  	
    cout<<ans<<endl;
  	
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int) (n); i++)
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  if(a > b) for (int i = 0; i < a; i++) {
    cout << b;
  }
  else for (int i = 0; i < b; i++) {
    cout << a;
  }
}



Measured memory_bytes: 256
S = input()
acgt = ["A","C","G","T"]
S_tf = [any([sss == aaa for aaa in acgt]) for sss in S]
maxlen = 0
curlen = 0
for i in S_tf:
    if i:
        curlen += 1
        if maxlen < curlen:
            maxlen = curlen
    else:
        curlen = 0
print(maxlen)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

int main(void){
	int N,l,r;
	ll sum;
	cin>>N;
	rep(i,N){
		cin>>l>>r;
		sum+=r-l+1;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    int ac[n],wa[n];
    for(int i=0;i<n;i++){ac[i]=-1;wa[i]=0;}
    for(int i=0;i<m;i++){
        int p;
        string s;
        cin >> p >> s;p--;
        if(ac[p]!=-1)continue;
        if(s=="AC"){
            ac[p]=1;
        }
        else{
            wa[p]++;
        }
    }
    int ans[2];
    for(int i=0;i<n;i++){
        if(ac[i]>0){
            ans[0]++;
            ans[1]+=wa[i];
        }
    }
    cout << ans[0] << " " << ans[1] << endl;
    return 0;
}

Measured memory_bytes: 1024
n,x = map(int, input().split())
l = list(map(int, input().split()))


d=[0]*(n+1)
for i in range(1,n+1):
  d[i] = d[i-1]+l[i-1]

tmp = [1 if di<=x else 0 for di in d]
ret=sum(tmp)

print(ret)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	      Scanner sc = new Scanner(System.in);
	      int n = sc.nextInt();
	      int d = sc.nextInt();
	      int x = sc.nextInt();
	      int bis;
	      int ums = 0;
	      int counter = 0;
	      for(int i=0; i<n; i++) {
	    	  bis = sc.nextInt();
	    	  for(int j=1; j<=d; j++) {
	    		  if(j==1+bis*counter) {
	    		  ums++;
	    		  counter++;
	    		  }
	    	  }
	    	  counter=0;
	      }
	      System.out.println(ums + x);
	}

}

Measured memory_bytes: 23636
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

const int MAX = 1e5 + 5;

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

    int N;
    cin >> N;

    vector<bool> seen(MAX, false);
    int duplicates = 0;

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        duplicates += seen[a];
        seen[a] = true;
    }

    if (duplicates % 2 != 0)
        duplicates++;

    cout << N - duplicates << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  ll a,b,c; cin >> a >> b >> c;
  if(a+b>=c) cout << c + b << endl;
  else cout << (a+b) + b + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
def f(n):
    if n%2 == 0:
        return n/2
    else:
        return 3*n + 1

s = int(input())
a = []
i = 1

while s not in a:
    a.append(s)
    s = f(s)
    i += 1
else:
    ans = i

print(ans)
    

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(Console.ReadLine());
        }

        var sorted = A.OrderByDescending(v => v).ToArray();
        var result = A.Select(v => sorted[0] == v ? sorted[1] : sorted[0]).ToList();

        Console.WriteLine(string.Join(Environment.NewLine, result));
    }
}

Measured memory_bytes: 32724
import java.util.*;

public class Main {
    public static void main(String[] args) {
      
        int S = 4;       // 入力数
        int tScore = 0;  // 高橋くんの整数
      
        // 標準入力から値を取得してinputに入れる
        Scanner sc = new Scanner(System.in);
        char[] input = sc.nextLine().toCharArray();
        
        for (int i = 0; i < S; i++) {
            String tmp = String.valueOf(input[i]);
          
            if (tmp.equals("+")) {
                tScore = tScore + 1;
            } else {
                tScore = tScore - 1;
            }
        }
      
        System.out.println(tScore);
    }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main(){

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

    while(k > 0 && a >= b){
        b *= 2;
        --k;
    }
    while(k > 0 && b >= c){
        c *= 2;
        --k;
    }

    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,m,uu,vv,d[100100],c[200100],co[100100];
vector<int> ga[100100];
vector<pair<int,int> > cand[100100];
pair<int,int> nxt[100100];
void search(int u){
	int v=nxt[u].first;
	if(!co[v]) search(v);
	co[u]=3-co[v];
	c[nxt[u].second]=d[u];
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>d[i];
	for(int i=1;i<=m;i++){
		cin>>uu>>vv;
		ga[uu].push_back(vv);
		ga[vv].push_back(uu);
		if(d[uu]>=d[vv]) cand[uu].push_back(make_pair(vv,i));
		if(d[vv]>=d[uu]) cand[vv].push_back(make_pair(uu,i));
	} 
	for(int i=1;i<=n;i++){
		if(cand[i].size()==0){cout<<-1<<endl;return 0;}
		nxt[i]=cand[i][0];
	}
	for(int i=1;i<=n;i++){
		int j=nxt[i].first;
		if(nxt[j].first==i){
			c[nxt[i].second]=d[i];
			co[i]=1;
			co[j]=2;
		}
	}
	for(int i=1;i<=n;i++){
		if(!co[i]){
			search(i);
		}
	}
	for(int i=1;i<=n;i++){
		if(co[i]==1) cout<<"W";
		else cout<<"B";
	}
	cout<<endl;
	for(int i=1;i<=m;i++){
		if(!c[i]) c[i]=1e9;
		cout<<c[i]<<endl;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 17536
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

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

void resolve() {
    LL n,y;
    cin >> n >> y;
    REP(i,0,y/10000+1) {
        LL b = y - 1000 * n - 9000 * i;
        if (b % 4000 == 0 && b >= 0) {
            b /= 4000;
            int c = n - i - b;
            if (c >= 0) {
                cout << i << " " << b << " " << c << endl;
                return;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a[10000005];
int main()
{
	for (ll i = 1; i <=10000000; i++)
	{
		for (ll j = i; j <=10000000 ; j+=i)
		{
			a[j]++;
		}
	}
	ll ans=0;
	ll n;cin>>n;
	for (ll i =1; i <=n; i++)
	{
		ans+=a[i]*i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 81700
#include <iostream>

using namespace std;

int main() {
  int c;
  cin >> c;
  if (c == 22)
    cout << "Christmas Eve Eve Eve" << endl;
  else if (c == 23)
    cout << "Christmas Eve Eve" << endl;
  else if (c == 24)
    cout << "Christmas Eve" << endl;
  else if (c == 25)
    cout << "Christmas" << endl;
}

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

N, K = map(int, input().split())
A = list(map(int, input().split()))
l = [0]
s = {0}

for i in range(K):
    nex = A[l[-1]]-1
    
    if nex in s:
        for i in range(len(l)):
            if l[i]==nex:
                mark = i
                break
        
        t = len(l)-mark
        print(l[mark+(K-mark)%t]+1)
        exit()
    
    l.append(nex)
    s.add(nex)

print(nex+1)

Measured memory_bytes: 113708
import sys

x, n = map(int, sys.stdin.readline().split())
if not n:
    print(x)
    exit()

p = list(map(int, sys.stdin.readline().split()))

p.sort(key = lambda item: (abs(x-item), item))

if p[0] != x:
    print(x)
    exit()

# print(p)

j = 1
for i in range(1, 2 + n // 2):
    if j == n or p[j] != x - i:
        print(x - i)
        exit()
    j += 1

    if j == n or p[j] != x + i:
        print(x + i)
        exit()
    j += 1

print(x)


Measured memory_bytes: 61984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Graph vector<vector<ll>>
#define INF (1ll<<40-1)
#define mod 1000000007
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; }

vector<ll> sum;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(ll i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}

vector<ll> xorsum;
void pre_process_xor(vector<ll> &a,vector<ll> &s){//累積xorのvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(ll i=0;i<n;i++){
        s[i+1]=s[i]^a[i];
    }
}

int main(){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    pre_process(a,sum);
    pre_process_xor(a,xorsum);

    ll ans=0;
    ll left=0;
    for(ll right=1;right<=n;right++){
        while((xorsum[right]^xorsum[left])!=(sum[right]-sum[left])){
            left++;
        }

        ans+=right-left;
    }

    cout<<ans<<endl;

    return 0;
}

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

int N, M;
int A[10010];
int sum = 0;

int main(){
  cin >> N >> M;

  for(int i = 0; i < M; i++){ cin >> A[i]; sum += A[i]; }

  if(sum > N) cout << -1 << endl;
  else cout << N - sum << endl;
  return 0;

  
}
    

Measured memory_bytes: 3656
local h, w, k = io.read("*n", "*n", "*n", "*l")
local t = {}
for i = 1, h do
  t[i] = {}
  local s = io.read()
  for j = 1, w do
    t[i][j] = s:sub(j, j) == "#"
  end
end
local tot = 1 << (h + w)
local hflag, wflag = {}, {}
local ans = 0
for i = 0, tot - 1 do
  local ti = i
  for j = 1, h do
    hflag[j] = ti % 2 == 0
    ti = ti // 2
  end
  for j = 1, w do
    wflag[j] = ti % 2 == 0
    ti = ti // 2
  end
  local c = 0
  for j = 1, h do
    for k = 1, w do
      if t[j][k] and hflag[j] and wflag[k] then
        c = c + 1
      end
    end
  end
  if c == k then ans = ans + 1 end
end
print(ans)


Measured memory_bytes: 2764
x,y,a,b,c = map(int ,input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p = p[:x]
q = q[:y]

pq = p+q
pq.sort(reverse=True)

pqr = pq + r
pqr.sort(reverse=True)

yamm = 0
for i in range(x+y):
    yamm += pqr[i]

print(yamm)

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    int k;
    cin >> k;
    vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a.at(k-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define digits 61
typedef long long ll;
const long long MOD = 1e9+7;

int main(){
  int n;cin>>n;
  vector<ll> one(digits,0);
  
  REP(i,n){
    ll a;cin>>a;
    REP(j,digits){
      if(a%2) one.at(j)++;
      a/=2;
    }
  }

  ll ans=0;
  REP(i,digits){
    ll tmp=(ll)pow(2,i)%MOD;
    tmp=(tmp*(n-one.at(i)))%MOD;
    tmp=(tmp*one.at(i))%MOD;
    ans=(ans+tmp)%MOD;
  }
  cout<<ans;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

ll n;
vector<ll> a;

int main(void) {

    cin >> n;
    rep(i, n) {
        ll aa;
        cin >> aa;
        a.push_back(aa);
    }

    sort(ALLOF(a));

    double min = 1000000000;
    double mid = a[n - 1] / 2.0;
    int min_i = 0;
    int i = 0;

    while(true) {
        double dst = abs(a[i] - mid);

        if (dst < min) {
            min = dst;
            min_i = i;
        }
        else break;
        i++;
    }

    cout << a[n - 1] << ' ' << a[min_i] << endl;

    return 0;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    public class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().Split(' ');
            double x = 0;
            for (int i = 0; i < a; i++)
            {
                x += (double)1 / int.Parse(s[i]);
            }

            Console.WriteLine((1 / x));
        }



    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int n;
  cin>>n;
  vector<int>a(n);
  int max1=0,max2=0;
  rep(i,n){
    cin>>a[i];
    if(max1<=a[i]){
      max2=max1;
      max1=a[i];
    }
    else if(max1>=a[i]&&max2<a[i]){
      max2=a[i];
    }
  }
  rep(i,n){
    if(a[i]==max1){cout<<max2<<endl;}
    else cout<<max1<<endl;
  }

}


Measured memory_bytes: 4744
#include <iostream>

using namespace std;
int sosu_sum[100005];
int sosu[100005];

int main(){
    //sosu_sum[1] =1;
    sosu[2] =1;
    for(int i = 3; i < 100001; i +=2){
        bool issosu = true;
        for(int j =3; j < i ;j +=2){
            if(i %j ==0){
                issosu =false;
                break;
            }
        }
        if(issosu){
            sosu[i] =1;
            if(sosu[(i +1)/2]==1){
                sosu_sum[i] = sosu_sum[i-2] + 1;
                continue;
            }
        }
        sosu_sum[i] = sosu_sum[i-2];
    }
    int Q, l, r;
    cin >>Q;
    
    for(int i =0 ; i < Q; i++){
        cin >> r >> l;
        if(r == 1) cout << sosu_sum[l] << endl;
        else cout << sosu_sum[l] - sosu_sum[r -2]<< endl;
    }

    return 0;
}
    

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;


int main(){
    string s;
    cin >> s;
    int w;
    cin >>w;
    
    for(int i=0; i<s.length(); i+=w){
        cout<<s[i];
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import math
MOD=1000000007
N=int(input())
f=[0]*1000

def factors(n):
  for i in range(2,n+1):
    if n==1: return
    if n%i==0:
      while n%i==0:
        f[i]+=1
        n//=i

for i in range(2,N+1):
  factors(i)

ans=1
for i in range(1000):
  if f[i]>0:
    ans*=(f[i]+1)
    ans%=MOD

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#define ll long long
using namespace std;

ll N;
ll arr[3] = {3, 5, 7};
string st = "357";

int dfs(ll n) {
  ll ret = 1;
  if (n > N)
    return 0;

  for (int i = 0; i < 3; i++) {
    if (to_string(n).find(st[i]) == string::npos) {
      ret = 0;
    }
  }
  for (int i = 0; i < 3; i++) {
    ret += dfs(n * 10 + arr[i]);
  }

  return ret;
}

int main() {
  cin >> N;

  cout << dfs(0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, count = 0;
	int i;

	scanf("%d %d %d", &a, &b, &c);
	if(b < a)
		return -1;
	for(i = a;i <= b;i++)
	{
		if (c % i == 0)
			count++;
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#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++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  string s,t;
  cin>>s>>t;
  s+=t;
  ll a=stoll(s);
  bool j=false;
  for(int i=1;i<=317;i++){
    if(i*i==a){
      j=true;
    }
  }
  if(j) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	string S;
	cin >> S;
	string a[] = { "dream","dreamer","erase","eraser" };
	reverse(&S);
	for (int i = 0; i < 4; i++) {
		reverse(&a[i]);
	}
	while (S.length()) {
		bool f = 0;
		for (int i = 0; i < 4; i++) {
			if (a[i] == S.substr(0, a[i].length())) {
				S = S.substr(a[i].length());
				f = 1;
				break;
			}
		}
		if (!f) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

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


const int P_MAX = 1000005;
vi pmn(P_MAX);     //smallest prime number that can divide i(pmn[i] == i -> i is prime number)
vi cnt(P_MAX,0);

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) scanf("%d", &a[i]);

    int ggg = a[0];
    rep(i,n-1) ggg = __gcd(ggg, a[i+1]);
    if(ggg != 1){
        puts("not coprime");
        return 0;
    }

    //エラトステネスの篩
    for(int i = 1; i < P_MAX; i++)
        if(i%2 == 0) pmn[i] = 2;
        else pmn[i] = i;
    for(int i = 3; i*i < P_MAX; i += 2){
        if(pmn[i] == i){
            for(int j = 3*i; j < P_MAX; j += 2*i)
                if(pmn[j] == j) pmn[j] = i; 
        }
    }

    rep(i,n){
        while(a[i] != 1){
            int apmn = pmn[a[i]];
            if(cnt[apmn]){
                puts("setwise coprime");
                return 0;
            }
            cnt[apmn]++;
            while(a[i]%apmn == 0) a[i] /= apmn;
        }
    }
    puts("pairwise coprime");
}


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

#define int long long

int n, k;
int dp[1010][1010];

int poyo(int i=0, int uyu=1001)
{
  int& ret = dp[i][uyu];
  if (ret != -1) return ret;
  if (i == n) return 1;

  ret = 0;

  for (int j = 0; j < k; j++){
    if (j == uyu) continue;
    ret += poyo(i + 1, j);
  }

  return ret;
}

signed main()
{
  cin >> n >> k;

  memset(dp, -1, sizeof(dp));
  cout << poyo() << endl;
}


Measured memory_bytes: 8192
import sys


def dfs(v):
    global visited
    visited[v] = True
    for nv in graph[v]:
        if nv in graph[v]:
            if not visited[nv]:
                dfs(nv)


if __name__ == "__main__":
    sys.setrecursionlimit(10**6)
    N, M = map(int, input().split())
    graph = [[] for _ in range(N)]
    visited = [False]*N
    for _ in range(M):
        A, B = map(lambda x: int(x)-1, input().split())
        graph[A].append(B)
        graph[B].append(A)
    ans = -1
    for v in range(N):
        if not visited[v]:
            dfs(v)
            ans += 1
    print(ans)


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  int a, b, c;
  cin >> a >> b >> c;
  if (a * c <= b)
    pr(c);
  else
    pr(b / a);
  return 0;
}


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

const ll INF = 1LL << 60;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> v(50,vector<char>(50));
    rep(i,h){
        rep(j,w){
            cin >> v[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            if(i==0){
                if(j==0){
                    if(v[i][j]=='#'&&v[i][j+1]=='.'&&v[i+1][j]=='.'){
                        cout << "No" << endl;
                        return 0;
                    }
                }
                else{
                    if(v[i][j]=='#'&&v[i][j+1]=='.'&&v[i+1][j]=='.'&&v[i][j-1]=='.'){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
            else if(j==0){
                if(v[i][j]=='#'&&v[i][j+1]=='.'&&v[i+1][j]=='.'&&v[i-1][j]=='.'){
                        cout << "No" << endl;
                        return 0;
                }
            }
            else if(i==h-1){
                if(j==w-1){
                    if(v[i][j]=='#'&&v[i][j-1]=='.'&&v[i-1][j]=='.'){
                        cout << "No" << endl;
                        return 0;
                    }
                }
                else{
                    if(v[i][j]=='#'&&v[i][j+1]=='.'&&v[i-1][j]=='.'&&v[i][j-1]=='.'){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
            else if(j==w-1){
                if(v[i][j]=='#'&&v[i][j-1]=='.'&&v[i+1][j]=='.'&&v[i-1][j]=='.'){
                        cout << "No" << endl;
                        return 0;
                }
            }
            else if(v[i][j]=='#'&&v[i][j+1]=='.'&&v[i][j-1]=='.'&&v[i+1][j]=='.'&&v[i-1][j]=='.'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

// template ends here

void solve(){
	// code starts from here
	string s,t;
	cin >> s >> t;
	
	int ans = 0;
	for(int i = 0; i < (int)s.size(); i++) if(s[i] != t[i])ans++;
	cout << ans << endl;	
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3872
# dp array
import sys
input = sys.stdin.readline
def chmax(dp, i, k, b):
    if dp[i][k] < b:
        dp[i][k] = b
        return True
    return False
def main():
    N = int(input())
    activities = []
    for _ in range(N):
        activities.append(list(map(int, input().split())))
    dp = [[0 for _ in range(3)] for _ in range(N)]
    dp[0] = activities[0]
    for i in range(1, N):
        for j in range(3):
            for k in range(3):
                if j != k:chmax(dp, i, k, dp[i-1][j]+activities[i][k])
    print(max(dp[-1][0], dp[-1][1], dp[-1][2]))
if __name__ == "__main__":
    main()

Measured memory_bytes: 70492
#include<iostream>
using namespace std;
#define MAX 100
void BubbleSort(int x[],int n);

int main(){
	int i,N;
	int x[MAX] = {0} ;
	
	cin >> N ;

	for(i=0;i<N;i++){
		cin >> x[i] ;
	}

	BubbleSort(x,N);
	return 0;

}

void BubbleSort(int x[],int n){
	int i,j,tmp,count=0;

	for(i=1;i<n;i++){
		for(j=(n-1);j>(i-1);j--){
			if(x[j] < x[j-1]){
				tmp = x[j] ;
				x[j] = x[j-1] ;
				x[j-1] = tmp ;
				count++;
			}
		}
	}

	for(i=0;i<n;i++){

	if(i<(n-1))cout << x[i] << ' ' ;
	if(i == (n-1))cout << x[i] << endl ;

	}
	
	cout << count << endl ;
}

Measured memory_bytes: 1164
import numpy as np

N,W = map(int,input().split())
item = []
V_MAX = 0
for _ in range(N):
    w, v = map(int,input().split())
    V_MAX += v
    item.append([w,v])
dp = np.array([float('inf')]*(V_MAX+1))
dp[0] = 0
pos = np.zeros(V_MAX+1, dtype = "int32")
pos[0] = 1
for w,v in item:
    dp = np.minimum(dp, np.concatenate([np.array([np.inf]*v),np.roll(dp,v)[v:]]) + np.dot(np.concatenate([np.zeros(v),np.roll(pos,v)[v:]]),w))
    pos = (pos + np.concatenate([np.zeros(v),np.roll(pos,v)[v:]]))
    pos[pos > 0] = 1
res = 0
for i in range(V_MAX + 1):
    if dp[i]<=W and res < i : res = i
print(res)

Measured memory_bytes: 17144
#include<bits/stdc++.h>
using namespace std;
const int Maxn= +50,INF=0xfffffff;
int AC , WA , TLE , RE;
string str;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> str;
		if (str == "AC") AC++;
		else if (str == "WA") WA++;
		else if (str == "TLE") TLE++;
		else RE++;
	}
	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;	
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int N, h[100005];
int dp[100005];

int main() {
    const int inf = 1e9;

    cin >> N;

    fill(dp, dp+N, inf);

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

    dp[0] = 0;
	// 差し上げるDP
    for (int i = 0; i < N-1; i++) {
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i]-h[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i]-h[i+2]));
    }
    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	if (a[a.size()-1]=='2'||a[a.size()-1]=='4'||a[a.size()-1]=='5'||a[a.size()-1]=='7'||a[a.size()-1]=='9')
		cout<<"hon";
	else if (a[a.size()-1]=='0'||a[a.size()-1]=='1'||a[a.size()-1]=='6'||a[a.size()-1]=='8')
		cout<<"pon";
	else
		cout<<"bon";
	return 0;
}


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    int k;
    cin>>k;

    bool res=false;
    if(a<b && b<c)
    {
        res=true;
    }
    else
    {
        while(b<=a && k>0)
        {
            b=b*2;
            k--;
        }

        while(c<=b && k>0)
        {
            c=c*2;
            k--;
        }

        if(a<b && b<c)
            res=true;
    }
    // cout<<a<<" "<<b<<" "<<c<<endl;

    if(res)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}



 

Measured memory_bytes: 3620
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

struct Edge {
    from: usize,
    to: usize,
    coin: i64,
}

fn dfs(i: usize, to: &Vec<Vec<usize>>, mut reachable: Vec<bool>) -> Vec<bool> {
    if reachable[i] {
        return reachable;
    }

    reachable[i] = true;

    for v in &to[i] {
        reachable = dfs(*v, to, reachable);
    }

    return reachable;
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, m, p) = input!(usize, usize, i64);

    let mut to = vec![vec![]; n];
    let mut ot = vec![vec![]; n];

    let mut reachable_n = vec![false; n];
    let mut reachable_1 = vec![false; n];

    let mut edges = Vec::with_capacity(m);
    for _ in 0..m {
        let (a, b, c) = input!(usize, usize, i64);
        edges.push(Edge { from: a - 1, to: b - 1, coin: c - p });
        to[a - 1].push(b - 1);
        ot[b - 1].push(a - 1);
    }

    reachable_n = dfs(0, &to, reachable_n);
    reachable_1 = dfs(n - 1, &ot, reachable_1);

    let mut coins = vec![std::i64::MIN; n];
    coins[0] = 0;

    for i in 0..(n + 1) {
        let mut updated = false;
        for e in &edges {
            if reachable_1[e.from] && reachable_1[e.to] &&
               reachable_n[e.from] && reachable_n[e.to] {
                if coins[e.from] != std::i64::MIN {
                    let coin_value = coins[e.from] + e.coin;
                    if coins[e.to] < coin_value {
                        coins[e.to] = coin_value;
                        updated = true;
                        if i == n {
                            println!("-1");
                            return;
                        }
                    }
                }
            }
        }

        if !updated {
            break;
        }
    }

    if coins[n - 1] < 0 {
        println!("0");
    } else {
        println!("{}", coins[n - 1]);
    }

}

fn main() {
    solve();
}


Measured memory_bytes: 4732