akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int sum = 0, t = n;
    while(t){
        sum += t % 10;
        t = t / 10;
    }
    if(n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
	int a, b;
	while (cin >> a >> b, a | b) {
		double MIN = 1 << 29;
		for (int c = 0; c <= a; c++) {
			MIN = min(MIN, abs(sqrt((c*c + (a - c)*(a - c)))-b));
		}
		printf("%.10lf\n", MIN);
	}
}

Measured memory_bytes: 3028
# import sys
from math import factorial
from functools import reduce


def mmul(a, b, mod):
    return (a % mod) * (b % mod) % mod


def mfact(a, mod):
    fact = 1
    for m in range(2, a + 1):
        fact *= m % mod
        fact %= mod
    return fact


def mpow(a, b, mod):
    if b == 0:
        return 1
    if b == 1:
        return a % mod
    if b % 2 == 0:
        return mpow(a, b / 2, mod) ** 2 % mod
    return mpow(a, b // 2, mod) ** 2 * a % mod


def mdiv(a, b, mod):
    return mmul(a, mpow(b, mod - 2, mod), mod)


# (n+a)Ca = (n+a)! / n!a! mod mod for n >> a
def mnpaca(n, a, mod):
    res = 1
    for num in range(n + 1, n + a + 1):
        res *= num % mod
        res %= mod
    return mdiv(res, factorial(a), mod)

mod = 1000000007
N, M = [int(s) for s in input().split()]

prime_counts = []
i = 2
while i * i <= M:
    count = 0
    while M % i == 0:
        M /= i
        count += 1
    if count:
        prime_counts.append(count)
    i += 1
if M > 1:
    prime_counts.append(1)

res = reduce(lambda x, y: x * y, [mnpaca(N - 1, c, mod) for c in prime_counts],
             1)

print(res % mod)


Measured memory_bytes: 3572
def main():
    A,B = map(int,input().split())
    import fractions
    C = fractions.gcd(A,B)
    cnt = 0
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        return divisors
    def is_prime(n):
        if n == 1:
            return True
        for i in range(2,int(n**0.5)+1):
            if n % i == 0:
                return False
        return True
    
    C_2 = make_divisors(C)
    
    for i in C_2:
        if is_prime(i):
            cnt += 1
    print(cnt)
    
    


    
if __name__ == '__main__':
    main()

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n + 1);
    for(int i = 1; i < n + 1; i++){
        cin >> a.at(i);
        b.at(i) = 0;
    }
    int count = 0;
    for(int i = n; i > 0; i--){
        for(int j = i; j < n + 1; j += i){
            count += b.at(j);
        }
        if(count % 2 == a.at(i)) b.at(i) = 0;
        else b.at(i) = 1;
        count = 0;
    }
    for(int i = 1; i < n + 1; i++){
        count += b.at(i);
    }
    cout << count << endl;
    for(int i = 1; i < n + 1; i++){
        if(b.at(i) == 1) cout << i << endl;
    }
}

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

int CountMulti(const int& r1,const int& c1,const int& r2,const int& c2){
	return c1*c2*r1;
}

int main(void){
	int N;
	cin >> N;
	vector<long long> rows(N),cols(N);
	for(int i=0;i<N;i++)
		cin >> rows[i] >> cols[i];

	const long long INF = 1e18;
	long long dp[101][101];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i == j)dp[i][j] = 0;
			else dp[i][j] = INF;
		}
	}
	for(int i=0;i<N-1;i++){
		dp[i][i+1] = rows[i]*rows[i+1]*cols[i+1];
	}

	for(int d=2;d<N;d++){
		for(int l=0;l<N-d;l++){
			for(int r=l;r<l+d;r++){
				dp[l][l+d] = min(dp[l][l+d], dp[l][r] + dp[r+1][l+d] + rows[l]*rows[r+1]*cols[l+d]);
			}
		}
	}
	cout << dp[0][N-1] << endl;
	return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
int main(){

	int R, G, B, N;
	cin >> R >> G >> B >> N;

	int ans = 0;

	for(int i=0; i<=N; i++){
      for(int j=0; j<=N-i; j++){
		int k = N - R*i - G*j;
		if(k < 0) break;
        if(k % B == 0) {
          ans++;
        }
      }
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  map<int,int> m;
  m[1] = 0;
  m[2] = W;
  m[3] = 0;
  m[4] = H;
  int x = 0, y = 0, a = 0;
  for(int i = 0; i < N; i++){ 
    cin >> x >> y >> a;
    //cout << x << " " << y << " " << a << endl;
    if(a == 1){
      if(m[1] < x) m[1] = x;
    }else if(a == 2){
      if(m[2] > x) m[2] = x;
    }else if(a == 3){
      if(m[3] < y) m[3] = y;
    }else if(a == 4){
      if(m[4] > y) m[4] = y;
    }
    //cout << m[1] << " " << m[2] << " " << m[3] << " " <<  m[4] << endl;
  }
  //cout << m[1] << m[2] << m[3] << m[4];
  int ans = max(0,max((m[2] - m[1]),0) * max((m[4] - m[3]),0));
  cout << ans;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         200009
#define inf         1e9+8
#define mp          make_pair
#define rep(i,n)    for(int i=0;i<n;i++)
#define repo(i,m,n) for(int i=m;i<=n;i++)
#define ll          long long
#define pii         pair<ll,ll >
#define sc(n)       scanf("%d",&n)
#define sc2(m,n)    scanf("%d%d",&m,&n);
#define MOD         4294967296
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          x
#define ss          y
using namespace std;



int main()
{
        char a,b,c,d;
        cin>>a>>b>>c>>d;
        int yy=(a-'0')*10+(b-'0');
        int mm=(c-'0')*10+(d-'0');
        if((yy>12 || yy<1) && mm<=12 && mm>0) cout<<"YYMM\n";
        else if(yy<=12 && yy>0 && (mm>12 || mm<1)) cout<<"MMYY\n";
        else if(yy<=12 && yy>0 && mm<=12 && mm>0) cout<<"AMBIGUOUS\n";
        else cout<<"NA\n";
}


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

int a;
int cnt=0;
ll num(int k,ll n,int n3,int n5,int n7,bool f){
    if(k<=0){
        if(n>0 && n<=a && n3>=1 && n5>=1 && n7>=1) cnt++;
        return 0;
    }
    if(f==false) num(k-1,0,n3,n5,n7,false);
    num(k-1,n*10+3,n3+1,n5,n7,true);
    num(k-1,n*10+5,n3,n5+1,n7,true);
    num(k-1,n*10+7,n3,n5,n7+1,true);
}

int main(){
    string s;
    cin>>s;
    a =stoi(s);
    int d=s.size();
    num(d,0,0,0,0,false);
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;

vector<vector<int>> g;
int maxx = 0,idx = 0;
void dfs(int a, int p, int d) {
	if (maxx < d) {
		maxx = d;
		idx = a;
	}
	for (int i : g[a]) {
		if (p != i) {
			dfs(i, a, d + 1);
		}
	}
}
int solve(int a) {
	maxx = 0;
	idx = 0;
	dfs(a, -1, 0);
	return idx;
}
void dist() {
	int sub = solve(0);
	solve(sub);
}

int main() {
	int n; cin >> n;
	g.resize(n);
	rep(i, 0, n - 1) {
		int p1, p2; cin >> p1 >> p2;
		p1--; p2--; 
		g[p1].push_back(p2);
		g[p2].push_back(p1);
	}
	dist();
	if (maxx % 3 == 1) printf("Second");
	else printf("First");
	return 0;
}


Measured memory_bytes: 20608
import math
tate,yoko = map(int,input().split())
if tate == 1 or yoko == 1:
    print(1)
else:
    if yoko%2 == 0:
        print(int((tate*yoko/2)))
    else:
        print(int((tate*(yoko-1)/2 + math.ceil(tate/2))))


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

int main() {
    int x, n, temp;
	//input init condition
    cin >> x >> n;
    int p[102] = {};

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

    int i = 0;

    for (; x - i >= 0 || x + i <= 101; i++) {
        if (x - i >= 0 && p[x - i] == 0) {
			//remove the end
            cout << x - i;
            return 0;
        } else if (x + i <= 101 && p[x + i] == 0) {
            cout << x + i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		long max=1000000000000000000l;
		
		int n=s.nextInt();
		
		long[] arr=new long[n];
		
		int z=0;
		
		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextLong();
			
			if(arr[i]==0)
				z++;
		}
		
		long ans=1;
		
		int f=0;
		
		for(int i=0;i<n;i++)
		{
			long p=max/ans;
			
			if(arr[i]<=p)
			{
				ans=ans*arr[i];
			}
			else
			{
				f=1;
				break;
			}
		}
		
		if(f==0)
		{
			System.out.println(ans);
		}
		else if(z>0)
		{
			System.out.println(0);
		}
		else
		{
			System.out.println(-1);
		}
		
	}
	
}

Measured memory_bytes: 61512
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
using ll = long long;
using namespace std;
int main(){
    string s;
    cin >> s;
    ll count=0;
    ll reg=-1;
    ll c=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W'){
            c++;
            reg=i+1;
            count += reg-c;
          //  cout<<reg-c<<endl;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    float ans;
    if((Integer.parseInt(N) % 2) == 0){
      ans = (float)(Integer.parseInt(N) / 2) / Integer.parseInt(N);
    } else {
      ans = (float)((Integer.parseInt(N) / 2) + 1) / Integer.parseInt(N);
    }
    
    System.out.println(String.format("%.10f", ans));
  }
}


Measured memory_bytes: 23508
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
ans=0
lst=[0]*(k+1)
for i in range(k):
    tori=k//(k-i)
    lst[k-i]=pow(tori,n,mod)
    for j in range(1,tori):
        lst[k-i]-=lst[(k-i)*(j+1)]
# print(lst)
for i in range(k):
    ans+=lst[i+1]*(i+1)
    ans%=mod
print(ans)

Measured memory_bytes: 75716
import CoreFoundation
let n=Int(readLine()!)!

if n < 100  {
  print("0")
  exit(0)
}

var min =  ( n / 100 ) * 100 
var max =  min + ( ( n / 100 ) * 5 )

if( n <= max ) {
  print("1")
} else {
  print("0")
}


Measured memory_bytes: 3568
#pragma GCC optimize("O2")
#pragma GCC optimize("O1")
#pragma GCC optimize("O3")
#pragma GCC optimize("Os")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	cout<<"";
        }
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				boolean[] v=new boolean[8000000];
				int m=sc.nextInt();
				int n=sc.nextInt();
				int pos=m;
				if(m+n==0) {
					break;
				}
				for(int i=0; i<n; i++) {
					while(v[pos]) {
						pos++;
					}
					for(int j=pos;j<=7368791; j=j+pos) {
						v[j]=true;
					}
				}
				while(v[pos]) {
					pos++;
				}
				System.out.println(pos);
			}
			
		}
	}
}



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

const int maxn=1e5+10;
int n,id[maxn],omove,orev,emove,erev,bit[maxn],rnk[maxn];
bool rev[maxn],vis[maxn];

inline void wrong(){
	puts("No");
	exit(0);
}
inline void add(int x,int val){
	while(x<maxn){
		bit[x]+=val;
		x+=x&-x;
	}
}
inline int sum(int x){
	int res=0;
	while(x){
		res+=bit[x];
		x-=x&-x;
	}
	return res;
}

int main(){
	cin>>n;
	for(int i=1,a;i<=n;++i){
		cin>>a;
		id[i]=(a+2)/3;
		rnk[id[i]]=i;
		if(vis[id[i]]||a==3*id[i]-1)
			wrong();
		vis[id[i]]=true;
		if(a==3*id[i])
			rev[i]=true;
	}
	for(int i=1,a;i<=n;++i){
		cin>>a;
		if(a!=3*id[i]-1)
			wrong();
	}
	for(int i=1,a;i<=n;++i){
		cin>>a;
		if(rev[i]&&a!=3*id[i]-2||!rev[i]&&a!=3*id[i])
			wrong();
	}
	for(int i=1;i<=n;++i)
		if((i&1)!=(id[i]&1))
			wrong();
	for(int i=1;i<=n;i+=2)
		add(i,1);
	for(int i=1;i<=n;i+=2){
		add(rnk[i],-1);
		omove+=sum(rnk[i]);
		orev+=rev[i];
	}
	memset(bit,0,sizeof(bit));
	for(int i=2;i<=n;i+=2)
		add(i,1);
	for(int i=2;i<=n;i+=2){
		add(rnk[i],-1);
		emove+=sum(rnk[i]);
		erev+=rev[i];
	}
	if((omove&1)!=(erev&1)||(emove&1)!=(orev&1))
		wrong();
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define llrep(i, a, b) for(ll i = (a); i < (b); ++i )
#define llrrep(i, a, b) for(ll i = (a); i > (b); --i )
#define llREP(i, a, b) for(ll i = (a); i <= (b); ++i )
#define llRREP(i, a, b) for(ll i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )



int D, N;
int A[200010];
ull DP[200010];
ull PQRS[20010][4];

ull USUBABS(ull A, ull B) {
    return A > B? (A-B): (B-A);
}

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 15) {
        cout << "+" << endl;
    }else if(a * b == 15) {
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }
}

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

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

   int price = 700;

   rep (i, 3) {
       if (s[i] == 'o') {
           price += 100;
       }
   }

   cout << price << endl;
}

Measured memory_bytes: 256
s = gets.chomp.chars.map(&:to_i)
n = s.size
a = Array.new(2019,0)
dd = 0
a[0] = 1
pp = 1
(0..(n-1)).each do |i|
  dd = ((pp * s[n-1-i])+dd)%2019
  pp = (10*pp)%2019
  a[dd] += 1
end
ans = 0
a.each do |j|
  if not j == 0
    ans += j*(j-1)/2
  end
end
puts ans

Measured memory_bytes: 26468
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using lint = long long;
using ldouble = long double;

void solve() {
    lint h;
    std::cin >> h;
    lint ans = 0, cnt = 1;
    while (h > 0) {
        h = h / 2;
        ans += cnt;
        cnt *= 2;
    }
    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

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

    for(int i=0; i<(int)s.size() && K>0; i++){
        int diff='z'-s[i]+1;
        if(s[i]=='a'){
            continue;
        }else if(diff<=K){
            s[i]='a';
            K-=diff;
        }else if(i==(int)s.size()){
            s[i]+=K;
            K=0;
        }
    }
    if(K>0){
        s[(int)s.size()-1]+=(K%26);
        K=0;
    }
    cout << s << '\n';
}

Measured memory_bytes: 3740
import java.util.*;
import java.math.BigInteger;
 class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      String s = scan.next() ;
      char[] c = s.toCharArray() ;
      for(int i= 0 ; i<c.length ; i++){
          if(i%2==0){
              System.out.print(c[i]+"");
          }
      }
    }
}

Measured memory_bytes: 38584
def main():
    N = int(input())
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()
    if N % 2 == 1:
        minMed = A[N//2]
        maxMed = B[N//2]
        print(int(maxMed-minMed)+1)
    else:
        minMed = A[N//2-1] + A[N//2]
        maxMed = B[N//2-1] + B[N//2]
        print(int(maxMed-minMed)+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 101080
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int h, w;
  cin >> h >> w;
  bool s[h + 2][w + 2];
  memset(s, false, sizeof(s));
  FOR(i, 1, h + 1) {
    FOR(j, 1, w + 1) {
      char c;
      cin >> c;
      if (c == '#') s[i][j] = true;
    }
  }

  FOR(i, 1, h + 1) {
    FOR(j, 1, w + 1) {
      if (s[i][j]) {
        if (!s[i - 1][j] && !s[i + 1][j] && !s[i][j - 1] && !s[i][j + 1]) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;


  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            int a = int.Parse(Console.ReadLine());

            int result = a + a*a + a*a*a ;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27520
def solve(n, k, r, s, p, t) -> int:
    convert = {opp: me for opp, me in zip('rsp', 'prs')}
    score = {'r': r, 's': s, 'p': p}
    my_hands = tuple(convert[_t] for _t in t)

    ret = 0
    for i in range(k):
        w = my_hands[i::k]
        flg = False
        for j, (_w1, _w2) in enumerate(zip(w[:-1], w[1:])):
            if flg:
                flg = False
                continue

            ret += score[_w1]
            if _w1 == _w2:
                flg = True

        if not flg:
            ret += score[w[-1]]

    return ret


def main():
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()
    print(solve(n, k, r, s, p, t))


if __name__ == '__main__':
    main()


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  bool is = false;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j == n) is = true;
      if(is) break;
    }
    if(is) break;
  }
  if(is) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    mp ms;
    int sum = 0;
    rep(i, n){
        string s;
        int x;
        cin >> s >> x;
        sum += x;
        ms[s] = sum;
    }

    string s; 
    cin >> s;

    int ans = sum - ms[s];
    cout << ans << endl;

    return 0;
}



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

using ll = long long int;
using P = std::pair<int, int>;

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

constexpr ll mod = 1e9 + 7;

ll pow(ll x, ll m)
{

    ll re = 1, y = 1;

    for (int i = 0; i < 40; ++i)
    {
        if (m & y)
            re = re * x % mod;
        x = x * x % mod;
        y *= 2;
    }

    return re;
}

ll inv(ll x)
{

    return pow(x, mod - 2);
}

class mint
{
    ll num = 0;

public:
    mint(ll x = 0) : num(x) {}

    mint operator+(const mint &rhs) const
    {
        return (num + rhs.num) % mod;
    }
    mint operator*(const mint &rhs) const
    {
        return num * rhs.num % mod;
    }
    mint operator-(const mint &rhs) const
    {
        return (num - rhs.num + mod) % mod;
    }
    mint operator/(const mint &rhs) const
    {
        return num * inv(rhs.num) % mod;
    }
    mint operator+=(const mint &rhs)
    {
        return num = (num + rhs.num) % mod;
    }
    friend std::ostream &operator<<(std::ostream &os, const mint &rhs);
};

std::ostream &operator<<(std::ostream &os, const mint &rhs)
{

    os << rhs.num;

    return os;
}

std::vector<mint> fact;

mint comb(ll x, ll y)
{
    //std::cerr << fact[x] << ' ' << fact[x - y] << ' ' << fact[y] << ' ' << (fact[x] / fact[x - y] / fact[y]) << std::endl;
    return fact[x] / fact[x - y] / fact[y];
}

int main()
{
    ll n, k;

    std::cin >> n >> k;

    int l = std::min(k, n - 1);

    fact.resize(n + 1);

    fact[0] = 1;

    for (ll i = 1; i <= n; ++i)
        fact[i] = fact[i - 1] * (mint)i;

    mint ans = 0;

    rep(i, l + 1)
    {
        ans += comb(n, i) * comb(n - 1, i);
        //std::cerr << comb(n, i) << std::endl;
    }

    std::cout << ans << std::endl;

    //std::cerr << inv(2) << std::endl;

    return 0;
}

Measured memory_bytes: 4820
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=300009;



int n;
int mxf=0;
int a[maxn];
int f[maxn];


int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	
	for(int i=1;i<=n;++i){
		f[a[i]]=f[a[i]-1]+1;
		mxf=max(mxf,f[a[i]]);
	}
	
	cout<<n-mxf<<endl;
	return 0;
}
	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int inf=1e5+9,mod=1e9+7;
ll fact[inf+inf],ans[inf];
pair<int,int> a[inf];

ll po(ll x,ll y){

    ll ans=1;
    while(y){
        if(y%2)
            ans=(ans*x)%mod;

        x=(x*x)%mod;
        y/=2;
    }
    return ans;
}

ll modinv(ll x,ll y){

    return ((x%mod)*po(y,mod-2))%mod;
}

ll ways(ll x1,ll y1,ll x2,ll y2){
    ll x=x2-x1,y=y2-y1;
    return modinv(fact[x+y],(fact[x]*fact[y])%mod)%mod;
}

int main(){

    fact[0]=1;
    for(int i=1;i<inf+inf;i++)
        fact[i]=(fact[i-1]*i)%mod;
        
        int n,m,k;
        scanf("%d%d%d",&n,&m,&k);
        for(int i=1;i<=k;i++)
            scanf("%d%d",&a[i].first,&a[i].second);

        k++;
        a[k]=make_pair(n,m);
        sort(a+1,a+1+k);

        for(int i=1;i<=k;i++)
            ans[i]=ways(1,1,a[i].first,a[i].second);

        for(int i=1;i<=k;i++){
            for(int j=i+1;j<=k;j++){
                if(a[i].first>a[j].first || a[j].second<a[i].second)
                    continue;
                ans[j]-=(ans[i]*ways(a[i].first,a[i].second,a[j].first,a[j].second))%mod;
                ans[j]+=mod;
                ans[j]%=mod;
            }
        }
        cout<<ans[k]<<endl;
    
}


Measured memory_bytes: 1920
// CONTEST SOURCE
#include <algorithm>
#include <climits>
#include <cmath>
#include <cmath>
#include <cstdio>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
using namespace std;
#define ll long long
#define x first
#define y second
#define pii pair<int, int>
#define pdd pair<double, double>
#define L(s) (int)(s).size()
#define VI vector<int>
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define inf 1000000000
#define pi 2 * acos(0.)
string s;
int main() {
  cin >> s;
  cout << s.substr(0, L(s) - 8) << endl;
}

Measured memory_bytes: 256
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))
(let* ((line0 (mapcar #'parse-integer (splitat #\space (read-line nil nil))))
       (line1 (mapcar #'parse-integer (splitat #\space (read-line nil nil)))))
      (format t "~A~%" (if (< (cadr line0) (cadr line1)) 0 1)))


Measured memory_bytes: 12516
import java.util.Scanner;

/*
 * @author Tanzim Ibn Patowary
 * Created  May 13, 2020 1:21:16 PM
 */
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		String string = in.next();
		StringBuilder mBuilder = new StringBuilder();
		if (string.length()>num) {
			mBuilder.append(string.substring(0, num)).append("...");
			System.out.println(mBuilder.toString());
		}else {
			System.out.println(string);
		}
	}
}


Measured memory_bytes: 27092
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var l1 = ReadIntArray();
        var hp = l1[0];
        var sp_damage_list = ReadIntArray();

        var damage_total = sp_damage_list.Sum();
        Console.WriteLine(hp > damage_total ? "No" : "Yes");
    }

    static string[] ReadStringArray()
    {
        return Console.ReadLine().Split(' ');
    }

    static int[] ReadIntArray()
    {
        return ReadStringArray().Select(_ => int.Parse(_)).ToArray();
    }
}
 


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

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

int n,m,k;
int d[101];
int e[101][101];
int dp[2][1<<16];
int go[101];
bool calced[1<<16];

int main(void){
	scanf("%d%d%d",&n,&m,&k);
	memset(go,-1,sizeof(go));
	for(int i=0;i<m;i++){
		scanf("%d",&d[i]);
		d[i]--;
		go[d[i]]=i;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<k;j++){
			scanf("%d",&e[i][j]);
			e[i][j]--;
		}
	}
	int prev=0,now=1;
	memset(dp,false,sizeof(dp));
	memset(calced,false,sizeof(calced));
	dp[0][(1<<m)-1]=true;
	int cnt=0;
	while(1){
		for(int i=0;i<(1<<m);i++){
			if(dp[prev][i]){
				if(calced[i])continue;
				calced[i]=true;
				for(int j=0;j<k;j++){
					int bit=0;
					for(int l=0;l<m;l++){
						if(i>>l & 1){
							if(go[e[d[l]][j]]>=0){
								bit|=(1<<go[e[d[l]][j]]);
							}
						}
					}
					dp[now][bit]=true;
				}
			}
		}
		cnt++;
		if(dp[now][0]){
			printf("%d\n",cnt);
			return 0;
		}
		swap(now,prev);
	}
	return 0;
}

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

int main () {
  int N;
  cin >> N;
  vector<int> dia(N + 1);
  for (int i = 0; i < N; i++)
    cin >> dia.at(i);
  dia.at(N) = 0;

  sort(dia.begin(), dia.end());
  reverse(dia.begin(), dia.end());
  int pile = 0;
  for (int i = 0; i < N; i++) {
    if (dia.at(i) > dia.at(i + 1))
      pile++;
  }
  
  cout << pile << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<complex>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D EPS = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n;
  if (n <= 999) cout << "ABC" << endl;
  else cout << "ABD" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll L, R, ans = infll;

int main()
{
    cin >> L >> R;
    for (ll i = L; i <= min(L + 2019 * 1LL, R); i++)
    {
        for (ll j = i + 1; j <= min(L + 2019 * 1LL, R); j++)
        {
            ans = min((i * j) % 2019 * 1LL, ans);
            ans %= 2019;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int N=S.size();
  char x;
  int sum=0;
  int count=0;
  for(int i=0;i<N;i++){
    if(count==0){x=S[i]; count++;}
    else if(S[i]!=x){sum+=2; count--;}
    else{count++;}
  }
  cout << sum << endl;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if((a+b)%2 == 0) cout << (a+b)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}

Measured memory_bytes: 764
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
    

main = do
    s <- getLine
    let remaining = 15 - length s
    if length (filter (== 'o') s) + remaining >= 8 then
        putStrLn "YES"
    else
        putStrLn "NO"


Measured memory_bytes: 380
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		int n = sc.nextInt();
		List<Long> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			long h = sc.nextLong();
			list.add(h);
		}

		int maxResult = 0;
		long prevH = list.get(0);
		int currentCount = 0;
		for (int i = 1; i < n; i++) {
			long h = list.get(i);
			
			if(h <= prevH){
				currentCount++;
			} else{
				maxResult = Math.max(currentCount, maxResult);
				currentCount = 0;
			}

			prevH = h;
		}
		maxResult = Math.max(currentCount, maxResult);


		System.out.println(maxResult);

	}
}


Measured memory_bytes: 50560
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n;
string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> s;
    n = s.size();
    bool b;
    if(s[0] != s[n - 1]){
    	b = n % 2;
    } else{
    	b = 1 - (n % 2);
    }
    if(b) cout << "First";
   	else cout << "Second";
}

Measured memory_bytes: 512
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int debt = 100000;
        int weeks = stdIn.nextInt();
        
        for(int i = 1; i <= weeks; i++){
            debt *= 1.05;
            
            if(debt % 1000 != 0){
                debt = ((debt / 1000) + 1) * 1000;
            }
        }
        
        System.out.println(debt);

        stdIn.close();
    }
}


Measured memory_bytes: 26136
H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]
#print(S)

def lonely(i,j):
  if S[i][j]=="#":
    res=0
    if i-1>=0: res+=1 if S[i-1][j]=="#" else 0
    if i+1<H: res+=1 if S[i+1][j]=="#" else 0
    if j-1>=0: res+=1 if S[i][j-1]=="#" else 0
    if j+1<W: res+=1 if S[i][j+1]=="#" else 0
    #print(i,j,res)
    return res
  else:
    return 1

ans="Yes"
for i in range(H):
  for j in range(W):
    if lonely(i,j)==0:
      ans="No"
print(ans)

Measured memory_bytes: 3064
from fractions import gcd
def lcm(a,b):
    return a*b/gcd(a,b)
while True:
    tmp = map(int, raw_input().split(" "))
    if all(t==0 for t in tmp):
        break
    b = []
    for a,m in zip(tmp[::2], tmp[1::2]):
        i, c = 1, a%m
        while c!=1:
            c = (a*c)%m
            i += 1
        b.append(i)
    print reduce(lcm,b)

Measured memory_bytes: 5900
/*it will crash due to not much memory
available in the cache1() in my lappy
but got accepted
in UVA ;)*/

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define clear(a) memset(a,0,sizeof(a))
#define N 10000
char a[10002];
void seive(void){
	int k = sqrt(N);
	clear(a);
	a[0]=1;
	a[1]=1;
	int i;
	for(i=2;i<=k;i++){
		if(a[i]==0){
			int j;
			for(j=i+i;j<=N;j+=i){
				a[j]=1;
			}
		}
	}
}

int main(){
    int n,i,j,k;
    seive();
    while(scanf("%d",&n) && n){
        for(i=n;i>=2;i--){
            if(!a[i] && !a[i-2]){
                printf("%d %d\n",i-2,i);
                break;
            }
        }
    }
    return 0;
}

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

int main() { 
    int N, K;
    cin >> N >> K;

    double p = 0;

    if (N-K+1>=0) {
        p += (double)(N-K+1)/N;
    }
    for (int i=1; i<=N; i++) {
        if (i>=K) break;
        int n = ceil(log2((double)K/i));
        // cout << n << endl;
        p += (double)1.0/N * pow(double(0.5), n);
    }

    cout << fixed << setprecision(10) << p << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void push(int *A, int x, int *min, int *max, int d) {
    if (d) {
        A[(*max)++]=x;
    } else {
        A[(*min)--]=x;
    }
}

void pop(int *A, int *min, int *max, int d) {
    if (d) {
        A[(*max)--] = '\0';
    } else {
        A[(*min)++]='\0';
    }
}

void randomAccess(int A) {
    printf("%d\n", A);
}

int main(void) {
    int *A, x;
    int i, p, q, d, query, min, max;

    scanf("%d", &q);
    A=(int *)malloc(sizeof(int)*q*2);
    memset(A, '\0', sizeof(int)*q*2);
    max=q;
    min=q-1;

    for (i=0; i<q; i++) {
        scanf("%d", &query);
        if (query==0) {
            scanf("%d %d", &d, &x);
            push(A, x, &min, &max, d);
        } else if (query==1) {
            scanf("%d", &p);
            randomAccess(A[min+p+1]);
        } else if (query==2) {
            scanf("%d", &d);
            pop(A, &min, &max, d);
        }
    }
    free(A);
    return 0;
}



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

#define FOR(a,b,c) for (int a=(b);a<(c);++a)
#define REP(i,n) FOR(i,0,n)
#define ll long long
#define pii pair<int,int>
#define x first
#define y second
#define pb push_back
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;

char c[MAX];
int n;

int main(){
	scanf ("%d",&n);
	scanf ("%s",c);
	int c1=0,c2=0;
	REP(i,n){
		if (c[i]=='R') c1++;
		else c2++;
	}
	int d1=0,d2=0;
	REP(i,c1){
		if (c[i]=='W') d1++;
	}
	FOR(i,c1,n){
		if (c[i]=='R') d2++;
	}
	printf ("%d\n",max(d1,d2));
	
	
	return 0;
}


Measured memory_bytes: 4020
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>
#include<algorithm>
#include<string>
#include<math.h>
#include<iomanip>

int main(){
	double a, b, x;
	std::cin>> a>> b>> x;

	double ans= 0;

	if(x<= a*a*b/2){
		ans= std::atan(b/((x*2)/(a*b)));
	}else{
		ans= std::atan((((a*a*b-x)*2)/(a*a))/ a);
	}


	std::cout<<std::setprecision(10)<<ans*180/3.1415926535<<std::endl;

	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////


signed main(){
  int n;cin>>n;
  int ans = 1;
  while(ans <= n)ans *= 2;
  if(ans > n)ans /= 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	string s;
	cin>>s;
	rep(i,s.size()){
		s[i]-=3;
		if(s[i]<'A')s[i]+=26;
	}
	cout<<s<<endl;	
}

Measured memory_bytes: 1180
from copy import deepcopy
n = int(input())
x = list(map(int, input().split()))
mod = 10 ** 9 + 7
c = 1
for i in range(2, n):
    c *= i
    c %= mod
c2 = deepcopy(c)
ans = 0
for i in range(n):
    ans += (x[i] - x[i - 1]) * c2
    ans %= mod
    c2 += pow(i + 1, mod - 2, mod) * c
    c2 %= mod
print(ans)

Measured memory_bytes: 20364
#include <iostream>

#define rep(i, n) for(int i = 2; i < n; i ++)

using namespace std;

int main(void){
	const int N = (int)1e6;
	bool num[N];
	rep(i, N) num[i] = true;
	for(int i = 2; i * i < N; i ++) if(num[i]) for(int j = i; i * j < N; j ++) num[i * j] = false;

	for(int n, count = 0; cin >> n; cout << count << endl, count = 0)
		rep(i, n + 1) if(num[i]) count ++;

	return 0;
}

Measured memory_bytes: 2132
import sys
import bisect
input = sys.stdin.readline

def main():
    N = int(input())
    l = sorted(list(map(int, input().split())))
    
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            a = l[i]
            b = l[j]
            right = bisect.bisect_left(l, a + b)
            ans += max(0, right - j - 1)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "Yes" << endl; else cout << "No" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

struct edge{int to, cost;};

class Graph
{
public:
    int V;
    vector<vector<edge>> G;

    Graph(int V): V(V){
        G = vector<vector<edge>>(V, vector<edge>(0));
    }

    void add_edge(int from, int to, int cost){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    //SCC decomposition
    void dfs(int v, vector<bool> &used, vec &vs){
        used[v] = true;
        REP(i, G[v].size()){
            if(!used[G[v][i].to]) dfs(G[v][i].to, used, vs);
        }
        vs.push_back(v);
    }
    void rdfs(int v, int k, vector<bool> &used, vec &cmp){
        used[v] = true;
        cmp[v] = k;
        REP(i, G[v].size()){
            if(!used[G[v][i].to]) rdfs(G[v][i].to, k, used, cmp);
        }
    }
    vec scc(int &k){
        vector<bool> used(V, false);
        vec vs(0), cmp(V);
        REP(i, V){
            if(!used[i]) dfs(i, used, vs); 
        }
        //reverse graph
        Graph rG(V);
        REP(v, V) REP(i, G[v].size()) rG.add_edge(G[v][i].to, v, G[v][i].cost);

        fill(used.begin(), used.end(), false);
        k = 0;
        IREP(i, vs.size()){
            if(!used[vs[i]]) rG.rdfs(vs[i], k++, used, cmp);
        }
        return cmp;
    }

};

signed main(){

    int N, M; cin >> N >> M;
    string s; cin >> s;
    int a, b;
    Graph G(2 * N);
    REP(i, M){
        cin >> a >> b;
        a--; b--;
        if(s[a] == s[b]){
            G.add_edge(a, b + N, 0);
            G.add_edge(b, a + N, 0);
        }else{
            G.add_edge(a + N, b, 0);
            G.add_edge(b + N, a, 0);
        }
    }
    int k;
    G.scc(k);
    ANS(k < 2 * N);
    
    return 0;
}

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

int main()
{
    int swi, bulb;
    int result = 0;
    cin >> swi >> bulb;
    vector<int> s(bulb, 0);
    vector<int> p(bulb);
    for (int i = 0; i < bulb; i++)
    {
        int k; cin >> k;
        for (int j = 0; j < k; j++)
        {
            int tmp = 0; cin >> tmp;
            --tmp;
            s[i] |= (1 << tmp);
        }
    }
    for (int i = 0; i < bulb; i++)
    {
        cin >> p[i];
    }
    for (int i = 0; i < (1 << swi); i++)
    {
        int on = 0;
        for (int j = 0; j < bulb; j++)
        {
            int A = i & s[j];
            int flags = 0;
            for (int k = 0; k < swi; k++) flags += (A >> k) & 1;
            if (flags % 2 == p[j]) on++;
        }
        if (on == bulb) result++;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 10;
int a[N], b[N];
vector<int> sub, add;
long long sum, rtr;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], rtr += a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i], rtr -= b[i];
	if (rtr < 0) {
		cout << -1;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (a[i] - b[i] > 0) 
			add.push_back(a[i] - b[i]);
		else if (a[i] - b[i] != 0)
			sub.push_back(b[i] - a[i]);
	}
	sort(add.begin(), add.end());
	reverse(add.begin(), add.end());
	for (int i = 0; i < sub.size(); i++)
		sum += sub[i];
	int i;
	for (i = 0; i < add.size(); i++) {
		if (sum <= 0)
			break;
		sum -= add[i];
	}
	cout << i + sub.size();

	return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 300000 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	3e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p, m, y;
string s, t;
ld w;
ll a, b;


// <------------- Implement Functions Here ----------> //



// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {	
	cin >> a >> b >> b >> b >> b >> k;
	if(b-a > k) cout<<":(";
	else cout<<"Yay!";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3656