akhauriyash/Code-Regression huggingface dataset:
public class Main {


  private static void solve() {
    long n = nl();
    //N = p(m + 1), m > p

    long sum = 0;
    for (long p = 1; p * p <= n; p ++) {
      if (n % p == 0) {
        long m = n / p - 1;
        
        if (m > p) {
          sum += m;
        }
      }
    }
    System.out.println(sum);
  }

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

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

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

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

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

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

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

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

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

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

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

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


Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll dp[5][100007];

int main(){
  ll N;
  cin >> N;
  dp[0][0]=0;
  dp[1][0]=0;
  dp[2][0]=0;
  Rep(i,1,N+1){
    ll A,B,C;
    cin >> A >> B >> C;
    dp[0][i]=max(dp[1][i-1],dp[2][i-1])+A;
    dp[1][i]=max(dp[0][i-1],dp[2][i-1])+B;
    dp[2][i]=max(dp[1][i-1],dp[0][i-1])+C;
  }
  cout << max(max(dp[0][N],dp[1][N]),dp[2][N]) << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long int
#define db long double
#define ull unsigned long long int
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
#define MAXN 1000005
 
using namespace std;

ll dp[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tests=1;
    // cin>>tests;
    while(tests--)
    {
    	ll x,i,j,n,k;
    	cin>>n>>k;
    // 	vector<ll>pre;
    	dp[0]=1;
    	rep(i,1,n)
    	{
    		cin>>x;
    // 		vector<ll>pre(k+1,0);
            // pre.resize(k+1,0LL);
            ll pre[k+50LL];
            memset(pre,0,sizeof(pre));
    		for(j=0;j<=k;j++)
    		{
    			ll left=j+1;
    			ll right=j+x;
    			if(right>=left)
    			{
    				pre[left]+=dp[j];
    				pre[left]%=MOD;
    				if(right+1<=k)
    					{
    						pre[right+1]-=dp[j];
    						pre[right+1]=(pre[right+1]+MOD)%MOD;
    					}
    			}
    		}
    		rep(j,1,k)
    		{
    			pre[j]+=pre[j-1];
    			pre[j]=(pre[j]+MOD)%MOD;
    			dp[j]+=pre[j];
    			dp[j]=(dp[j]+MOD)%MOD;
    		}

    	}
    	cout<<dp[k];


    }
    	return 0;
    
}

Measured memory_bytes: 5140
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int b,a,sum,p,i,x;
	char ss[16];
	while(scanf("%s %d %d",ss,&a,&b)!=EOF){
		sum=a*200+b*300;
		p=a+b;
		printf("%s %d %d\n",ss,p,sum);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define MOD 1000000007
 
using namespace std;
 
using ll = long long;
 
ll solve() {
 
    int H, W;
    cin >> H >> W;
    set<int> As, Bs;
    REP(i, H) {
        int A;
        cin >> A;
        --A;
        As.insert(A);
    }
    REP(i, W) {
        int B;
        cin >> B;
        --B;
        Bs.insert(B);
    }
 
    int n_used_rows = 0;
    int n_used_cols = 0;
    ll result = 1;
    RREP(x, H * W) {
        int n_filled = H * W - 1 - x;
        bool inA = As.count(x) > 0;
        bool inB = Bs.count(x) > 0;
        int n_ways;
        if (inA && inB) {
            n_ways = 1;
            ++n_used_rows;
            ++n_used_cols;
        } else if (inA && !inB) {
            n_ways = n_used_cols;
            ++n_used_rows;
        } else if (!inA && inB) {
            n_ways = n_used_rows;
            ++n_used_cols;
        } else {
            n_ways = n_used_rows * n_used_cols - n_filled;
            if (n_ways <= 0) return 0;
        }
        result = (result * n_ways) % MOD;
    }
    return result;
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    cout << solve() << endl;
 
    return 0;
}

Measured memory_bytes: 3672
// --------------
// Tejas Pandey  |
// 16 - 11 - 19  |
// ABC #145      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int r;
		cin >> r;
		cout << r*r << "\n";
	}
	return 0;
}

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

int main() {
	int N,M,C,count=0,ans=0;
	cin >> N >> M >> C;
	vector<int> B(M);
	vector<vector<int>> A(N,vector<int>(M));
	for(int i=0;i<M;i++) cin >> B[i];
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			cin >> A.at(i).at(j);
			ans+=B[j]*A[i][j];
		}
		ans+=C;
		if(ans>0) count++;
		ans=0;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
s = input()
q = int(input())
for i in range(q):
    command = input().split()
    a, b = int(command[1]), int(command[2]) + 1
    if command[0] == "print":
        print(s[a:b])
    elif command[0] == "reverse":
        s = s[:a] + s[a:b][::-1] + s[b:]
    elif command[0] == "replace":
        s = s[:a] + command[3] + s[b:]

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M,L=MI()
    inf=10**15
    d=[[inf]*N for _ in range(N)]
    for i in range(M):
        a,b,c=MI()
        a-=1
        b-=1
        if c<=L:
            d[a][b]=c
            d[b][a]=c
        
    for i in range(N):
        d[i][i]=0
        
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j]=min(d[i][j],d[i][k]+d[k][j])
                
    d2=[[inf]*N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if d[i][j]<=L:
                d2[i][j]=1
                
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d2[i][j]=min(d2[i][j],d2[i][k]+d2[k][j])
                
    Q=I()
    for i in range(Q):
        s,t=MI()
        s-=1
        t-=1
        ans=d2[s][t]
        if ans>=inf:
            print(-1)
        else:
            print(ans-1)
                
    

main()


Measured memory_bytes: 56284
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i< (n);i++)
#define rep1(i,n) for(int i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const static ll MOD = (1e+9)+7;

int main(){
    ll N;cin>>N;
    vector<ll> A(N);rep(i,N)cin>>A[i];
    sort(A.begin(),A.end(),greater<ll>());
    ll ans = 0, sum = 0;
    rep(i,N)sum+=A[i];
    rep(i,N){
        sum -= A[i];
        ans++;
        if(sum*2 < A[i])break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  int N; //宝石個数
  scanf("%d",&N);
  
  int V[N]; //価値
  for(int i=0;i<N;i++){
    scanf("%d",&V[i]);
  }
  
  int C[N]; //コスト
  for(int i=0;i<N;i++){
    scanf("%d",&C[i]);
  }
  
  int buy;
  for(int i=0;i<N;i++){
    if((V[i] - C[i]) > 0) buy += (V[i] - C[i]);
  }
  printf("%d",buy);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>

int main(void){
    int i,n,min=0;
    char stn[200000];
    int w[100000];
    int b[100000];
    scanf("%d",&n);
    scanf("%s",stn);
    char *tmp1 = stn;
    char *tmp2;
    int cnt=0;
    while(*tmp1!='\0'){
        tmp2 = tmp1;
        tmp1 += strspn(tmp1,".");
        w[cnt] = tmp1-tmp2;
        min += w[cnt];

        tmp2 = tmp1;
        tmp1 += strspn(tmp1,"#");
        b[cnt] = tmp1-tmp2;

        cnt++;
    }

    min -= w[0];
    int tmp = min;
    for(i=1;i<cnt;i++){
        tmp = tmp + b[i-1] - w[i];
        if(tmp<min)min = tmp;
    }
    printf("%d\n",min);
    return 0;
}


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

const int INF = 1001001001;
int dist[100005][3];

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> to(N);
    rep(i, M){
        int ut, vt;
        cin >> ut >> vt;
        --ut; --vt;
        to[ut].emplace_back(vt);
    }
    int S, T;
    cin >> S >> T;
    S--;
    T--;
    
    rep(i, N){
        rep(j, 3){
            dist[i][j] = INF;
        }
    }

    queue<P> q;
    q.push(P(S, 0));
    dist[S][0] = 0;
    while(!q.empty()){
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for(int u:to[v]){
            int nl = (l+1)%3;
            if (dist[u][nl] != INF) continue;
            dist[u][nl] = dist[v][l]+1;
            q.push(P(u, nl));
        }
    }
    int ans = dist[T][0];
    if (ans == INF) ans = -1;
    else ans /= 3;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

long double N,K;
int p[21] = {1};
int main(){
    cin >> N >> K;
    for(int i=1;i<=20;i++) p[i] = 2*p[i-1];
    long double ans = (N>=K? 1.0*(N-K+1)/N:0);
    cerr << fixed << endl;
    cerr << setprecision(12);
    for(int i=1;i<=min((int)N,(int) K-1);i++){
        for(int j=1;j<=20;j++){
            if(p[j]*i>=K){
                ans += (long double) pow((long double)0.5,(long double) j)/(1.0*N);
                //cerr << pow(0.5,j) << endl;
                break;
            }
        }
    }
    cout << fixed;
    cout << setprecision(12) << ans << endl;
}

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



int main(){
    ll N, M; cin >> N;
    map<string, ll> MS, MT;
    for(int i = 0; i < N; i++){
        string S; cin >> S;
        MS[S]++;
    }
    cin >> M;
    for(int i = 0; i < M; i++){
        string T; cin >> T;
        MT[T]++;
    }
    ll Max = 0;
    for(auto m : MS){
        Max = max(Max, m.second - MT[m.first]); 
    }
    cout << Max << endl;
}


Measured memory_bytes: 256
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val L = readLine()!!.split(" ").map { it.toInt() }
    val sortedL = L.sorted()
    val others = (0 until N - 1).map { sortedL[it] }.sum()

    println(if (others > sortedL.max()!!) "Yes" else "No")
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 8007;

int n;
char a[MAXN], b[MAXN];
bool vis[MAXN];
int nxt[MAXN], pre[MAXN];
int vp[MAXN];

void init ();
void input ();
void work ();

int calc ( int np, bool flag );



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%s%s", a+1, b+1 );
}

void work ()
{
	// main work
	
	n = strlen ( a+1 );
	
	bool a0 = true, b0 = true;
	lpi ( i, 1, n ){
		a0 &= a[i] == '0';
		b0 &= b[i] == '0';
	}
	if ( b0 ){
		if ( a0 ) printf ( "0\n" );
		else printf ( "-1\n" );
		return;
	}
	
	lpi ( i, 1, n ) b[i+n+n+n] = b[i+n+n] = b[i+n] = b[i];
	
	lpi ( i, n+1, n*3 ){
		lpi ( j, i, n*4 ){
			if ( b[j] == '1' ){
				nxt[i] = j;
				break;
			}
		}
		lpd ( j, i, 0 ){
			if ( b[j] == '1' ){
				pre[i] = j;
				break;
			}
		}
	}
	
//	lpi ( i, 1, n*4 ) cerr << nxt[i] << " "; cerr << endl;
//	lpi ( i, 1, n*4 ) cerr << pre[i] << " "; cerr << endl;
	
	int ans = INF;
	
	lp ( i, 0, n ) ans = min ( ans, calc ( i, true ) + i );
	INIT ( vis, false );
	lpd ( i, n, 0 ) ans = min ( ans, calc ( i, false ) + n - i );
	
	cout << ans << endl;
}



int calc ( int np, bool flag )
{
	INIT ( vp, 0 );
	int cur = 0, mini = INF;
	lpi ( i, 1, n ){
		if ( b[i+np] == '1' ) vis[i] = true;
		if ( a[i] != b[i+np] ){
			if ( vis[i] ) ++cur;
			else{
				if ( flag ) vp[i+n-pre[i+n]-1] = max ( vp[i+n-pre[i+n]-1], nxt[i+np+n] - ( i+np+n ) );
				else vp[i+np+n-pre[i+np+n]-1] = max ( vp[i+np+n-pre[i+np+n]-1], nxt[i+n+n] - ( i+n+n ) );
				++cur;
			}
		}
	}
	lpdi ( i, n-1, 0 ) vp[i] = qmax ( vp[i], vp[i+1] ), mini = qmin ( mini, i + vp[i] );
//	cerr << np << " " << flag << " " << cur << " " << mini << endl;
	return cur + mini * 2;
}

Measured memory_bytes: 384
# ABC 070: B – Two Switches
a, b, c, d = map(int, input().split())

if b <= c or d <= a:
    print(0)
elif a <= c and d <= b:
    print(d - c)
elif c <= a and b <= d:
    print(b - a)
elif a <= c and b <= d:
    print(b - c)
elif c <= a and d <= b:
    print(d - a)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;


/*void printvec(vector<int> v) {
	int a = v.size();
	for (int i = 0; i < a; i++) {
		printf("%d ", v[i]);
	}
	printf("\n");
}*/


int main(){
	int N, M;
	cin >> N >> M;
	if (N == M)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

string s;

int main(){
  cin >> s;
  ll cnt=0;
  for(int i=0;i<s.size();++i){
   cnt+=(s[i]=='o');
  }
  if(cnt+(15-s.size())>=8){
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, p;
    cin >> n >> p;
    vi a(n);
    int cntodd = 0;
    rep(i, n) {
        cin >> a[i];
        if (a[i] % 2 == 1) cntodd++;
    }
    int cnteven = n - cntodd;
    if (p == 1 && cntodd == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = (cntodd >= 1 ? (ll)pow(2, cntodd-1) : 1);
    ans *= (ll)pow(2, cnteven);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<functional>
#include<math.h>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
  string o,e;
  cin >> o;
  cin >> e;
  bool loop = o.size() > e.size();
  string miria = "";
  for(int i=0;i<e.size();i++){
    cout << o[i] << e[i];
  }
  if(loop){
    cout << o[e.size()] << endl;
  }else{
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();

    let mut ans = 0;
    let mut i = 1;
    while i * i < n {
        if n % i == 0 {
            let j = n / i;
            if j - 1 > i {
                ans += j - 1;
            }
        }
        i += 1;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
// https://atcoder.jp/contests/abc134/tasks/abc134_c

package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)

	max, max2 := -1, -1
	maxi := -1

	for i := 0; i < N; i++ {
		var a int
		fmt.Scanf("%d", &a)
		if max2 <= a {
			if max <= a {
				max2, max = max, a
				maxi = i
			} else {
				max2 = a
			}
		}
	}

	for i := 0; i < N; i++ {
		if i == maxi {
			fmt.Println(max2)
		} else {
			fmt.Println(max)
		}
	}
}


Measured memory_bytes: 6912
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
int cut[10005];
int dp[2][5005][2];
int main()
{
	srand((unsigned int)time(NULL));
	int n; scanf("%d",&n);
	for(int i=1;i<n;i++) scanf("%d",&cut[i]);
	for(int i=0;i<2;i++)for(int j=0;j<5005;j++)for(int k=0;k<2;k++)dp[i][j][k]=1e8;
	dp[0][1][0]=0; int cur=0,nxt=1;
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<5005;j++)for(int k=0;k<2;k++) dp[nxt][j][k]=1e8;
		for(int j=0;j<=n/2;j++)
		{
			dp[nxt][j+1][0]=min(dp[nxt][j+1][0],dp[cur][j][0]);
			dp[nxt][j][1]=min(dp[nxt][j][1],dp[cur][j][0]+cut[i]);
			dp[nxt][j][1]=min(dp[nxt][j][1],dp[cur][j][1]);
			dp[nxt][j+1][0]=min(dp[nxt][j+1][0],dp[cur][j][1]+cut[i]);
		}
		swap(cur,nxt);
	}
	printf("%d\n",min(dp[cur][n/2][0],dp[cur][n/2][1]));
}

Measured memory_bytes: 1304
import numpy as p
n,M=map(int,input().split())
l=n*3+1
d=p.zeros((l,n*5),p.int64)
d[0][0]=d[1][1]=d[2][2]=d[2][-1]=1
for i in range(3,l):d[i]=(d[i-3]*(i-2)*(i-1)+p.roll(d[i-2],-1)*(i-1)+p.roll(d[i-1],1))%M
print(d[-1][:l].sum()%M)


Measured memory_bytes: 481372
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int H, W;
    cin >> H >> W;
    REP(i, H){
        string S;
        cin >> S;
        cout << S << el << S << el;
    }
}



Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> &P){
os << P.first;
os << " ";
os << P.second;
os << "\n";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans=0;
    stack<int> s;
    string a;
    while(cin >> a){
        if (a=="+"||a=="-"||a=="*"){
            int v1 = s.top();
            s.pop();
            int v2 = s.top();
            s.pop();
            if(a=="+") s.push(v1+v2);
            else if (a=="-") s.push(v2-v1);
            else s.push(v2*v1);
        }else{
            s.push(stoi(a));
        }
    }
    ans = s.top();




    cout << ans << endl;
}


Measured memory_bytes: 3204
import java.util.Collections;
import java.util.Scanner;
import java.util.stream.Collectors;

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

        String s = sc.next();
        String t = sc.next();

        System.out.println(solve(s, t) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(String s, String t) {
        return s.chars().sorted().mapToObj(ch -> String.valueOf((char) ch)).collect(Collectors.joining())
                .compareTo(t.chars().boxed().sorted(Collections.reverseOrder())
                        .map(x -> String.valueOf((char) x.intValue())).collect(Collectors.joining())) < 0;
    }
}

Measured memory_bytes: 28756
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
typedef vector<vp> vvp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 998244353;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modpow(ll x, ll n){
	ll r=1;
	while(n){
		if(n&1) r=r*x%MOD;
		x=x*x%MOD;
		n>>=1;
	}
	return r;
}
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
int main(){
  ll n,m,k,ans=0;cin>>n>>m>>k;
  COMinit();
  rep(i,0,k+1){
    ans+=mod(mod(m*modpow(m-1,n-i-1),MOD)*COM(n-1,i),MOD);
    ans%=MOD;
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 15584
#import <stdio.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
void swap(int *x, int *y){
    int tmp = *x;
    *x=*y;
    *y=tmp;
}

int main(){
    int A,B,C,X,Y;
    scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
    if(A>B){
        swap(&A,&B);
        swap(&X,&Y);
    }
    int p,q,r;
    if(2*C<A){
        p=0;
        q=0;
        r=2*MAX(X,Y);
    } else if (A+B<2*C){
        p=X;
        q=Y;
        r=0;
    } else if (2*C<B){
        q=0;
        r=2*Y;
        if(X<=Y) {
            p=0;
        } else {
            p=X-Y;
        }
    } else {
        if(X<=Y){
            r=2*X;
            q=Y-X;
            p=0;
        } else {
            r=2*Y;
            p=X-Y;
            q=0;
        }
    }
    printf("%d", p*A+q*B+r*C);
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int n, k;
int arr[60];
int ans[60];

void print() {
    int i, pa = -1;
    printf("%d\n",n+k*(n-1));
    ans[k] = -1;
    for (int j=0;j<=k;j++) {
        for (i=0;i<n;i++) {
            if (i==ans[j]||i==pa) continue;
            printf("%d ",i+1);
        }
        if (j<k) printf("%d ",ans[j]+1);
        pa = ans[j];
    }
    printf("\n");
}

int main() {
    int i, f = 1, s = 0;

    scanf("%d%d",&n,&k);
    for (i=0;i<n;i++) {
        scanf("%d",&arr[i]);
        arr[i] = max(k+1-arr[i],0);
        if (arr[i]>(k+1)/2) f = 0;
        s += arr[i];
    }
    if (s>k) f = 0;
    if (!f) {
        printf("-1\n");
        return 0;
    }
    while(s<k) {
        (*min_element(arr,arr+n))++;
        s++;
    }
    vector<int> ord;
    for (i=0;i<k;i+=2) ord.push_back(i);
    for (i=1;i<k;i+=2) ord.push_back(i);
    int p = 0;
    while(*max_element(arr,arr+n)) {
        int t = max_element(arr,arr+n)-arr;
        while(arr[t]--) {
            ans[ord[p++]] = t;
        }
        arr[t]++;
    }
    print();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>

const int eps = 'z' - 'a' + 1;
const int ms = 200200;
const int INF = 1e9;

std::string str;
int nxt[ms][eps];
int height[ms];
int to[ms];

int main()
{
	std::cin >> str;
	str = "#" + str;
	int n = str.size();
	for(int i = 0; i < ms; i++)
	{
		for(int j = 0; j < eps; j++)
		{
			nxt[i][j] = n;
		}
	}
	memset(height, 0x3f, sizeof height);
	for(int i = n - 2; i >= 0; i--)
	{
		for(int j = 0; j < eps; j++)
			nxt[i][j] = nxt[i + 1][j];
		nxt[i][str[i + 1] - 'a'] = i + 1;
	}
	height[n] = 0;
	for(int i = n - 1; i >= 0; i--)
	{
		for(int j = 0; j < eps; j++)
		{
			if(1 + height[nxt[i][j]] < height[i])
			{
				to[i] = j;
				height[i] = 1 + height[nxt[i][j]];
			}
		}
	}
	std::string ans;
	int on = 0;
	while(on != n)
	{
		ans += 'a' + to[on];
		on = nxt[on][to[on]];
	}
	std::cout << ans << "\n";
}

Measured memory_bytes: 22464
n, w = map(int, input().split())
l1 = [list(map(int, input().split())) for i in range(n)]
v = 0
for i in range(n):
  v += l1[i][1]
d = [10 ** 9 + 1] * (v + 1)
d[0] = 0
for i in range(n):
    for j in range(v, -1, -1):
        d[j] = min(d[j], d[j - l1[i][1]] + l1[i][0])
answer = 0
for j in range(v + 1):
    if  w >= d[j]:
        answer = max(answer, j)
print(answer)

Measured memory_bytes: 41948
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int c1 = scanner.nextInt();
        int c5 = scanner.nextInt();
        int c10 = scanner.nextInt();
        int c50 = scanner.nextInt();
        int c100 = scanner.nextInt();
        int c500 = scanner.nextInt();
        int a = 0;
        a=c1*1+c5*5+c10*10+c50*50+c100*100+c500*500;
        if(a>=1000)
            System.out.println(1);
        else
            System.out.println(0);

    }
}


Measured memory_bytes: 26348
#include <iostream>
#include <cstring>
#include <cstdio>
#include<algorithm>
#include <queue>
#include <cmath>
#include <limits>
#include <map>
using namespace std;
int main(){
  long n, m;
  long ans = 1;
  cin >> m >> n;
  long calc_m = m;
  long calc_n = n;
  for (long i = 2; i < max(m,n) / 2; i++){
      while(calc_m%i==0 && calc_n%i==0){
        calc_m = calc_m / i;
        calc_n = calc_n / i;
        ans = ans * i;
      }
  }
  ans = ans * calc_m * calc_n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

int main()
{
    int k;
    cin >> k;
    for (int i = 0; i < k; i++)
    {
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3520
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N;
	static char[][] operand;
	static char[] ans;
	static int[] c2i = new int[26];
	static boolean[] used = new boolean[10];

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			operand = new char[N - 1][];
			for (int i = 0; i < N - 1; ++i) {
				operand[i] = rev(sc.next());
			}
			ans = rev(sc.next());
			System.out.println(solve());
		}
	}

	static int solve() {
		for (int i = 0; i < N - 1; ++i) {
			if (operand[i].length > ans.length) return 0;
		}
		Arrays.fill(c2i, -1);
		Arrays.fill(used, false);
		return rec(0, 0, 0);
	}

	static int rec(int digits, int pos, int sum) {
		if (pos == operand.length) {
			int cur = c2i[ans[digits] - 'A'];
			if (cur != -1) {
				if (sum % 10 != cur) return 0;
			} else {
				if (used[sum % 10]) return 0;
			}
			if (digits == ans.length - 1) {
				return (digits == 0 || 0 < sum) && sum < 10 ? 1 : 0;
			}
			if (cur == -1) {
				c2i[ans[digits] - 'A'] = sum % 10;
				used[sum % 10] = true;
			}
			int ret = rec(digits + 1, 0, sum / 10);
			if (cur == -1) {
				c2i[ans[digits] - 'A'] = -1;
				used[sum % 10] = false;
			}
			return ret;
		}
		if (digits >= operand[pos].length) return rec(digits, pos + 1, sum);
		int cur = c2i[operand[pos][digits] - 'A'];
		if (cur == -1) {
			int ret = 0;
			for (int i = 0; i < 10; ++i) {
				if (used[i]) continue;
				if (digits > 0 && i == 0 && digits == operand[pos].length - 1) continue;
				used[i] = true;
				c2i[operand[pos][digits] - 'A'] = i;
				ret += rec(digits, pos + 1, sum + i);
				used[i] = false;
				c2i[operand[pos][digits] - 'A'] = -1;
			}
			return ret;
		} else {
			if (digits > 0 && cur == 0 && digits == operand[pos].length - 1) return 0;
			return rec(digits, pos + 1, sum + cur);
		}
	}

	static char[] rev(String s) {
		char[] ret = new char[s.length()];
		for (int i = 0; i < s.length(); ++i) {
			ret[i] = s.charAt(s.length() - 1 - i);
		}
		return ret;
	}

}

Measured memory_bytes: 20752
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": ";
#include <bits/stdc++.h>
using namespace std;

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

	 ll t=1,r,n,a,d,c,b,x,y,sum,cnt,i,j,k,m,l,q,maxx,minn,temp,ans,flag,g,ts;
	
	 char ch;
	 double dans;
	 string str,ttr;
	 
	// cin >> t;

	
	for(ts=1;ts<=t;ts++)
	{
	     flag=0;sum=0;cnt=0;ans=0;k=0;maxx=0;minn=0;a=0;b=0;temp=0;
	    
	     cin >> n>>m;
	    // ll arr[n];
	    
	     vector<ll> vt;
	     vector<pair<ll,ll>> vtt;
	     
	     
	     if(m>=n)
	     cout<<"unsafe";
	     else
	     cout<<"safe";
	    
	     ln
	 }
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	string s; cin >> s;
	if(s=="ARC") cout << "ABC";
	else cout << "ARC";
}

Measured memory_bytes: 3548
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<stdio.h>
#include<cmath>
#include<map>
#include<bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long


int main(){
    int n; cin>>n;
    int now = 0;
    rep(i, n){
        int a; cin>>a;
        if(a == now+1){
            now++;
        }
    }
    int ans;
    if(now == 0) ans = -1;
    else ans = n - now;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
  	cin >> N;
  	string S;
  	cin >> S;
  	int x =0;
  	int y =0;
    for(int i=0;i<N;i++){
    	if(S[i] == 'I'){
          x++;
          y = max(x, y);
        }
      	else x -= 1;
    }
  	cout << y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n,m);
  COUT((1900*m+100*(n-m))*pow(2,m));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,res = 0;
    string str1,str2;
    cin>>str1>>str2;
    map<char,int>mp;
    n = str1.size();
    res = str2.size();
    if(n<res)
        cout<<"LESS\n";
    else if(n>res)
        cout<<"GREATER\n";
    else
    {
        int blb = 0;
        for(int i = 0;i < str1.size() ;i++)
        {
            int l = str1[i] - '0',m = str2[i] - '0';
             if(l>m)
             {
                blb = 1;
                 break;
             }
             else if(l<m)
             {
                 blb = 2;
                 break;
             }

        }
        if(blb == 1)
            cout<<"GREATER\n";
        else if(blb == 2)
            cout<<"LESS\n";
        else
            cout<<"EQUAL\n";
    }
    return 0;
}


Measured memory_bytes: 256
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let n = line.trim().parse::<i32>().unwrap();
    if n < 1200 {
        println!("ABC");
    } else {
        println!("ARC");
    }
}


Measured memory_bytes: 4352
H, W = map(int,input().split())
S = [list(input()) for i in range(H)]

for h in range(H):
    for w in range(W):
        if S[h][w] in ['.', 'B']: continue
        
        ary = [[0,1], [0,-1], [1,0], [-1,0]]
        flag = False
        for x, y in ary:
            xd = h+x
            yd = w+y
            if xd < 0 or xd >= H or yd < 0 or yd >=W: continue
            if S[xd][yd] in ['B', '#']:
                S[h][w] = 'B'
                S[xd][yd] = 'B'
                flag = True
        
        if not flag:
            print('No') 
            exit()

print('Yes')

Measured memory_bytes: 9128
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

// 二次元累積和
struct cumulative_sum_2d {
    using lint = long long;
    int x, y;
    vector<vector<lint>> data;
    vector<vector<lint>> sum;
    cumulative_sum_2d(const int _x, const int _y) : x(_x), y(_y) {
        data.assign(x, vector<lint>(y, 0));
        sum.assign(x + 1, vector<lint>(y + 1, 0));
    }
    vector<lint> &operator[](const int k) {
        return data[k];
    }
    void build() {
        for (int i = 0; i < x; i++)
            for (int j = 0; j < y; j++)
                sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + data[i][j];
    }
    //[a,b)×[c,d)の和を計算
    lint query(const int a, const int b, const int c, const int d) const {
        return sum[b][d] - sum[b][c] - sum[a][d] + sum[a][c];
    }
};

template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

int n, k;

int main() {
    cin >> n >> k;
    cumulative_sum_2d black(2 * k, 2 * k);
    for (int i = 0; i < n; i++) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') {
            y += k;
        }
        x %= 2 * k, y %= 2 * k;
        black[x][y]++;
    }
    black.build();
    int ans = 0;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < k; j++) {
            int b_ok = black.query(0, i, 0, j) + black.query(i + k, 2 * k, 0, j) +
                       black.query(i, i + k, j, j + k) + black.query(0, i, j + k, 2 * k) +
                       black.query(i + k, 2 * k, j + k, 2 * k);
            chmax(ans, max(b_ok, n - b_ok));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 62976
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
using namespace std;
const int N=1e6+69, base=1024*1024, mod=1e9+7,ma=1e9;
vector <pll> G[N];
LL wej[N],odw[N],odl[N],n,a,b,c,m;
queue <int> q;
int32_t main(void) {
    boost;
    cin>>n>>m;
    f1(i,m) {
        cin>>a>>b>>c;
        G[a].PB(MP(b,c));
        wej[b]++;
    }
    f1(i,n) {
        if(wej[i]==0) q.push(i);
        odl[i]=-1;
    }
    while(!q.empty()) {
        int v=q.front();
        odw[v]=1;
        LL war=-1;
        q.pop();
        f0(i,G[v].size()) {
            int w=G[v][i].f;
            wej[w]--;
            if(wej[w]==0) q.push(w);
            if(odl[w]!=-1) war=odl[w]-G[v][i].s;
        }
        if(odl[v]==-1) odl[v]=war;
        if(odl[v]==-1) odl[v]=0;
        //cout<<"v: "<<v<<" "<<odl[v]<<endl;
        f0(i,G[v].size()) {
            int w=G[v][i].f;
            if(odl[w]==-1) odl[w]=G[v][i].s+odl[v];
            if(odl[w]!=G[v][i].s+odl[v]||odl[w]>ma) {
                cout<<"No\n";
                return 0;
            }
        }
    }
    f1(i,n) if(odw[i]==0) {
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";
}


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

int main() {
  long long N, K;
  cin >> N >> K;
  vector<vector<long long>> ab(N);
  for (int i = 0; i < N; i++) {
    long long a, b; cin >> a >> b;
    ab.at(i) = { a, b };
  }
  sort(ab.begin(), ab.end());
  for (int i = 0; i < N; i++) {
    K -= ab.at(i).at(1);
    if (K <= 0) {
      cout << ab.at(i).at(0) << endl;
      break;
    }
  }
}

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

int main(void){
    char s1[101],s2[101],t[101];
    scanf("%s", s1);
    scanf("%s", t);
    int flag = 0;

    int n = strlen(s1);

    for(int j=0;j<n;j++){
        s2[0] = s1[n-1];
        for(int i=0;i<n-1;i++){
            s2[i+1] = s1[i];
        }
        for(int i=0;i<n;i++){
            s1[i] = s2[i];
        }
        if(strcmp(s1,t) == 0){
            cout << "Yes" << endl;
            flag = 1;
            break;
        }
    }
    
    if(flag == 0){
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  ykaka
 *    created: 01.08.2020 20:54:48       
**/
 
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i<(n);++i)
using namespace std;
using ll = long long;
 
int main(){
  string s;
  cin >> s;
  int ts = 0;
  if(s[1] == 'S'){
    if(s[0] == 'R' || s[2] == 'R')ts++;
  }
  if(s[1] == 'R'){
    ts++;
    if(s[0] == 'R')ts++;
    if(s[2] == 'R')ts++;
  }
  cout << ts << endl;
  return 0;
}



Measured memory_bytes: 3524
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n, ans;
  ans = 0;
  cin >> n;
  cin.ignore();
  int v[n], c[n], a[n];
  for(int i=0; i<n; i++){
  cin >> v[i];
  }
  for(int i=0; i<n; i++){
    cin >> c[i];
  }
  for(int i=0; i<n; i++){
    a[i]=v[i]-c[i];
  }
  sort(a, a+n);
  int i=n-1;
  while(a[i]>0){
    ans=ans+a[i];
    i--;
  }
  cout << ans;
  return 0;
}

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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define deb 0

vector <int> v[100001];

int dfs(int x, int p)
{
	int ans = 0;
	for (int y: v[x]) {
		if (y == p) continue;
		ans ^= dfs(y, x);
	}
	return ans+1;
}

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

	int n, i, j, k, x, y;
	cin >> n;
	for (i = 1; i < n; ++i) {
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}

	puts(dfs(1, 0) == 1 ? "Bob" : "Alice");

	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

const int inf=1e9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};	

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

	int cost=inf;
	for (int i = 1; i < 101; i++){
		int sum=0;
		for (int j = 0; j < n; j++){
			sum+=pow((x[j]-i),2);
		}
		cost=min(cost,sum);
	}

	cout<<cost<<endl;

	return 0;
}



Measured memory_bytes: 256
using System;
using System.Windows;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class Program
{
  static int n;
  static List<int>[] G;
  static int[] color;
  
    static void Main(string[] args)
    {
      //入力を受け取る
      var D = Console.ReadLine();
      var S = D.ToCharArray();
      //var d = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
      //Array.Sort(d);
      
      var count = 0L;
      
      for(int i = 1; i < S.Length ; i++){
        if(S[i-1] == '0' && S[i] == '0'){
          S[i] = '1';
          count++;
        }else if(S[i-1] == '1' && S[i] == '1'){
          S[i] = '0';
          count++;
        }
      }
      
      Console.WriteLine(count);

    }
}




Measured memory_bytes: 11488