akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
const ll MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll 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;
  }
}
long long COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<ll> factorial(ll n)
{
  vector<ll> fac;
  fac.push_back(1);
  for (ll i = 1; i < n + 10; i++)
  {
    fac.push_back((fac[i - 1] * i) % mo);
  }
  return fac;
}
int main()
{
/* 
https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5
ボール      箱	      入れ方に制限なし 箱の中身は1つ以下 箱の中身は1つ以上
区別できる   区別できる  1            2             3
区別できない  区別できる  4            5             6
区別できる   区別できない 7            8             9
区別できない  区別できない 10          11            12
*/
ll n , k ;
cin >> n >> k ;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
COMinit();
vector<ll> fac = factorial(100000);

//1
//cout << mypow(k,n) << endl;
//2
//cout << (COM(k,n)*fac[n])%mo << endl;
/* 
//3
ll t=0;
rep(i,k+1){
  t=mod(t+mypow(-1,k-i)*COM(k,i)*mypow(i,n));
}
cout << t << endl;
 */
//4
//cout << COM(n+k-1,n) << endl;
//5
//cout << COM(k,n) << endl;
//6
//cout << COM(n-1,k-1) << endl;
//8
cout << (n>k?0:1) << endl;
return 0;
}


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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1e9
using namespace std;
typedef long long ll;

ll n;
int main(){
  std::cin >> n;
  std::cout << (n%2!=0? n*2:n) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
        #include <iomanip>
        using namespace std;
        double   dp[3002][2];


      int main()
      {
         int n;
         cin>>n;
         dp[0][0]=1.0;
         dp[0][1]=1.0;
         for(int i=1 ;i<=n;i++)
         {
                 double p;
                 cin>>p;
                 for(int j=1;j<=i;j++)
                 {
                     dp[j][i%2]=dp[j][(i+1)%2]*(1-p) +dp[j-1][(i+1)%2]*p ;
                 }
              dp[0][0]*=(1-p) ;

              dp[0][1]*=(1-p) ;
      

       }
      

    double ans=0;
      for(int i=n/2+1 ;i<=n;i++)
      {
         ans+=dp[i][n%2];
      }

      cout<<fixed<<setprecision(11)<<ans<<endl;
        return 0;
      }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner src = new Scanner(System.in);
		int A=src.nextInt();
		int B=src.nextInt();
		int i=1;
		int S;
		if(A>=B) {
			if(B==1)
				
				System.out.println(0);
			else
				
				System.out.println(1);
			}
		else
		{
			for(;;i++) {
				S=A*i-i+1;;
			
				if(S>=B) {	
					System.out.println(i);
					break;
				}
			}
			
		}

	}

}


Measured memory_bytes: 23124
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        int n = sc.nextInt();
        int[] d = new int[n];

        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                sum += d[i] * d[j];
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [ for i in 1..n -> stream.ReadLine().ToCharArray() ]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let s = util.Scan1 string
let L = Seq.length s
let isACGT = String.forall (fun x -> List.contains x ['A';'C';'G';'T'])

seq {
  yield 0; // for empty
  for i in 0..L-1 do
  for j in i..L-1 do
    if isACGT s.[i..j]
      then yield j - i + 1
}
|> Seq.max
|> printfn "%d"


Measured memory_bytes: 14940
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    bool ans = true;
    reverse(all(s1));
    if(s1 != s2)ans = false;
    reverse(all(s1));reverse(all(s2));
    cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define s(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;

int main() {
	int a, b, c,d;
	cin >> a >> b >> c>>d;
	int ans = min(a, b);
	int abc = min(c, d);
	cout << ans + abc << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m, l, r int
	fmt.Scan(&n, &m)

	min := 1
	max := n
	for i := 0; i < m; i++ {
		fmt.Scan(&l, &r)

		if min < l {
			min = l
		}
		if max > r {
			max = r
		}
	}

	if max >= min {
		fmt.Print(max - min + 1)
	} else {
		fmt.Print(0)
	}
}


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

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

Measured memory_bytes: 3784
# coding: utf-8
n = int(input())
L=[]
for i in range(n):
    a, b = map(int,input().split())
    if a==b:
        L.append(1)
    else:
        L.append(0)
flg=False
for i in range(n-2):
    if L[i] and L[i+1] and L[i+2]:
        flg=True
        break

if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62344
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long X;
    cin >> X;
    for(long long t=1;; t++){
        long long Y = (t*(t+1)) / 2;
        if(X <= Y){
            cout << t << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1


n=int(input())
nn=n
# ===================================== 約数のリスト   
ir=int(n**(0.5))+1
ret=[]
for i in range(1,ir):
    if n%i == 0 and isPrime(i):
        ret.append(i)
#    if n%i == 0 and (i!= 1) & (i*i != n) and isPrime(n//i):
    if n%i == 0 and  (i*i != n) and isPrime(n//i):
            ret.append(n//i)

ret2=[]
for i in ret:
    while nn//i>0 and nn%i==0:
        ret2.append(i)
        nn=nn//i
        
print(str(n)+":",end="")
for i in ret2:
#    print(" ",i,end="")
    print("",i,end="")
print()





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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 5e5 + 5;
const int inf = 1e16 + 2;

int ar[N] , W[N] , ans = 1;
int get(int x){
    if(x == ar[x]) return x;
    return ar[x] = get(ar[x]);
}
void merge(int a , int b) {
    a = get(a);
    b = get(b);
    if(a == b) return;
    ar[b] = ar[a];
    W[a] += W[b];
    ans = max(W[a] , ans);
}
void solve(int Case) {
    ans = 1;
    int n , m ;
    cin >> n >> m ;
    for(int i = 0 ; i <= n ; i ++) ar[i] = i , W[i] = 1;
    while(m --) {
        int u , v ;
        cin >> u >> v ;
        merge(u , v) ;
    }
    cout << ans << '\n';
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int Case = 1;
    while(testcase --) {
        solve(Case ++);
    }
    return 0;
}


Measured memory_bytes: 6736
a = []
a = gets.chomp.split("")
b = []
b  = gets.chomp.split("")
#p a
#p b
for i in 0..a.length-1
    t = 0
    for j in 0..a.length-1
        if i + j <= a.length-1
            #p "#{a[j]} #{b[i+j]}"
            if a[j] != b[i+j]
                t = 1
            end    
        else
            #p "#{a[j]} #{b[i+j-a.length]}"
            if a[j] != b[i+j-a.length]
                #p j
                #p i+j-a.length
                #p "#{a[j]} #{b[i+j-a.length]}"
                t = 1
            end
        end
    end
    #p 1
    if t == 0
        puts "Yes"
        exit
    end
end
puts "No"
    
            

Measured memory_bytes: 3836
#include <iostream>
#include <cstring>
#include <map>
#include <string>
#include <stack>
#include <vector>
using namespace std;

#define INF 1000000007LL
#define ll long long
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) rep2(i,0,n)
#define sz size()

ll n,m[5],D,a[222],digitsum[5];
ll dp[6][222][888];
ll nPk[888][888],nPksum[888][889],nCk[888][888],fact[888]={1},p10[888]={1};

ll f(int dig, int card, int sum){
	if(card<0 || sum<0)return 0;
	ll& res=dp[dig][card][sum];
	if(res>-1)return res;
	if(dig==5)return res=(card==0)&&(sum==0);
	res=0;
	rep(i,m[dig]+1){
		res = (res + f(dig+1,card-i,sum-i*max(1,dig)) * nCk[m[dig]][i] ) % INF;
	}
	
	//cout<<dig<<","<<card<<","<<sum<<" : "<<res<<endl;
	return res;
}

int main(){
	rep2(i,1,888)p10[i]=p10[i-1]*10%INF;
	rep2(i,1,888)fact[i]=fact[i-1]*i%INF;
	rep(i,888)nCk[i][0]=nCk[i][i]=1;
	rep2(i,1,888)rep2(j,1,i)nCk[i][j]=(nCk[i-1][j-1]+nCk[i-1][j])%INF;
	rep(i,888){
		nPk[i][0]=1;
		rep2(j,1,i+1)nPk[i][j]=(nPk[i][j-1]*(i+1-j))%INF;
		nPksum[i][0]=0;
		rep2(j,1,i+2)nPksum[i][j]=(nPksum[i][j-1]+nPk[i][j-1])%INF;
	}
	//rep(i,6)cout<<nPksum[5][i]<<" ";
	rep2(i,1,6)p10[i]=p10[i-1]*10;
	cin>>n;
	rep(i,n){
		cin>>a[i];
		rep(j,6){
			if(a[i]<p10[j]){
				m[j]++;
				digitsum[j]+=a[i];
				D+=max(j,1);
				break;
			}
		}
	}
	ll ans=0;
	
	rep2(i,1,5)if(m[i]>=1){
		m[i]--;
		D-=i;
		
		memset(dp,-1,sizeof(dp));
		
		/*while(1){
			int card,dig;
			cin>>card>>dig;
			cout<<f(0,card,dig)<<endl;
		}*/
		
		//rep(j,5)cout<<m[j]<<" ";cout<<endl;
		
		memset(dp,-1,sizeof(dp));
		ll res=0;
		
		rep(j,n)rep(k,D+1){
			res= ( res + (f(0,j,k) * fact[j] % INF *nPksum[n-1-j][n-j])%INF * p10[k] ) % INF;
			//cout<<i<<" "<<j<<" "<<k<<" : "<<f(0,j,k)<<" * "<<fact[j]<<" * "<<nPksum[n-1-j][n-j]<<" * "<<p10[k]<<endl;
		}
		
		ans=(ans+res*digitsum[i])%INF;
		//cout<<i<<" : "<<digitsum[i]<<" * "<<res<<endl;
		
		m[i]++;
		D+=i;
	}
	
	if(m[0]==0){
		cout<<ans<<endl;
		return 0;
	}
	
	m[0]--;
	D-=1;
	n--;
	
	//cout<<"-----\n";
	
	ll ans2=0;
	
	rep2(i,1,5)if(m[i]>=1){
		m[i]--;
		D-=i;
		
		memset(dp,-1,sizeof(dp));
		
		/*while(1){
			int card,dig;
			cin>>card>>dig;
			cout<<f(0,card,dig)<<endl;
		}*/
		
		//rep(j,5)cout<<m[j]<<" ";cout<<endl;
		
		memset(dp,-1,sizeof(dp));
		ll res=0;
		
		rep(j,n)rep(k,D+1){
			res= ( res + (f(0,j,k) * fact[j] % INF *nPksum[n-1-j][n-j])%INF * p10[k] ) % INF;
			//cout<<i<<" "<<j<<" "<<k<<" : "<<f(0,j,k)<<" * "<<fact[j]<<" * "<<nPksum[n-1-j][n-j]<<" * "<<p10[k]<<endl;
		}
		
		ans2=(ans2+res*digitsum[i])%INF;
		//cout<<i<<" : "<<digitsum[i]<<" * "<<res<<endl;
		
		m[i]++;
		D+=i;
	}
	
	//cout<<ans<<" - "<<ans2<<" = \n";
	cout<<(ans-ans2+INF)%INF<<endl;
}

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

int main(){
  string s;
  int ans=1e9;
  cin>>s;
  for(int i=0;i<s.size();i++){
    bool f=1;
    string tmp=s;
    int cnt=0;
    while(f){
      bool ff=1;
      for(int j=0;j<tmp.size();j++)
	if(tmp[j]!=s[i])ff=0;
      if(ff)ans=min(cnt,ans),f=0;
      string ntp;
      for(int j=0;j<(int)tmp.size()-1;j++){
	if(tmp[j]==s[i]||tmp[j+1]==s[i])ntp+=s[i];
	else ntp+="?";
      }
      cnt++;
      tmp=ntp;

    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

struct Point
{
    bool isUsed;
    int x, y;

    Point(bool flag, int inputx, int inputy)
    {
        isUsed = flag;
        x = inputx;
        y = inputy;
    }
};

bool isSmall(Point& a, Point& b)
{
    return a.x < b.x && a.y < b.y ? true : false;
}

int count(vector<Point>& a)
{
    int temp = 0;
    for(auto item : a)
        if(item.isUsed)
            temp++;
    return temp;
}

int main()
{
    int N; cin >> N;
    vector<Point> redPoints(N, {false, 0, 0});
    vector<Point> bluePoints(N, {false, 0, 0});
    for(auto &item : redPoints) cin >> item.x >> item.y;
    for(auto &item : bluePoints) cin >> item.x >> item.y;

    sort(redPoints.begin(),  redPoints.end(),  [](const Point& a, const Point& b) -> bool { return a.y > b.y; });
    sort(bluePoints.begin(), bluePoints.end(), [](const Point& a, const Point& b) -> bool { return a.x < b.x; });

    for(auto &blue : bluePoints)
        for(auto &red : redPoints)
            if( isSmall(red, blue) && !red.isUsed )
            {
                red.isUsed = true;
                break;
            }

    cout << count(redPoints) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

int n;

typedef long long LL;

LL k;
const int maxn = 55;
int a[maxn][maxn];

LL dp[maxn][maxn][maxn * 2];
const LL mod = 1e9 + 7;

void add(LL &a, LL b){
    a += b;
    if(a >= mod)
        a -= mod;
}

LL val[maxn];
LL nxt[maxn];
int main(){
    cin >> n >> k;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            scanf("%d", &a[i][j]);
            if(a[i][j] == 1){
                dp[i][j][0] = 1;
            }
        }
    }
    for(int j = 1;(1LL << j) <= k;j++){
        for(int u = 1;u <= n;u++){
            for(int v = 1;v <= n;v++){
                for(int w = 1;w <= n;w++){
                    add(dp[u][w][j], 1LL * dp[u][v][j - 1] * dp[v][w][j - 1] % mod); 
                }
            }
        }
    }
    for(int i = 1;i <= n;i++){
        val[i] = 1;
    }
    for(int j = 0;(1LL << j) <= k;j++){
        if(k & (1LL << j)){
            for(int i = 1;i <= n;i++){
                nxt[i] = 0;
            }
            for(int u = 1;u <= n;u++){
                for(int v = 1;v <= n;v++){
                    add(nxt[v], 1LL * val[u] * dp[u][v][j] % mod);
                } 
            }
            for(int i = 1;i <= n;i++){
                val[i] = nxt[i];
            }
        }
    }
    LL ans = 0;
    for(int i = 1;i <= n;i++){
        add(ans, val[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2688
n,m=map(int,input().split())
ans=0
b=[0]*m
for _ in range(n):
    aa=list(map(int,input().split()))
    aa=aa[1:]
    for i in aa:
        b[i-1]+=1

for i in b:
    if i==n:
        ans+=1

print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
using ll = long long;
using namespace std;
ll X[100010];
ll W[100010];
ll tmp[100010]; //T秒後の位置, いんでっくす

ll ans[100010];

ll calc_count(ll x, ll y, ll L, ll T)
{
    if (T * 2 < abs(x - y))
        return 0;
    ll remain = T * 2 - abs(x - y);
    return 1 + remain / L;
}
int main(void)
{
    ll N, L, T;
    cin >> N >> L >> T;

    for (int i = 0; i < N; ++i)
    {
        cin >> X[i] >> W[i];
    }
    for (int i = 0; i < N; ++i)
    {
        if (W[i] == 1)
        {
            tmp[i] = (X[i] + (T % L) + L) % L;
        }
        else
        {
            tmp[i] = (X[i] - (T % L) + L) % L;
        }
        //cout << tmp[i] << endl;
    }
    sort(tmp, tmp + N);
    int count = 0;

    for (int i = 0; i < N; ++i)
    {
        if (W[i] == 1)
            count -= (T - (L - X[i]) + L) / L;
        else
            count += (T - (X[i] + 1) + L) / L;
    }
    count = (count % N + N) % N; //countは非負

    for (int i = 0; i < N; ++i)
    {
        ans[(i + count) % N] = tmp[i];
    }
    for (int i = 0; i < N; ++i)
        cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 4352
var n=Int(readLine()!)!
var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var i = 0
var d : Double = 0

arr = arr.sort() 
//print( arr )

d = ( ( Double(arr[0]) + Double(arr[1]) ) / 2 )
//print( d )
for i in 2..<n {
  d = ( ( d + Double(arr[i]) ) / 2)
}
       
print( d )

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

#define endl '\n'

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(0);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

ll f(ll b, ll n) {
  ll ans = 0;
  while(n) {
    ans += n%b;
    n /= b;
  }
  return ans;
}

int main() { BUFF
  ll n, s; 
  cin >> n >> s;

  if(s>n) {
    cout << -1 << endl;
    return 0;
  }

  if(s==n) {
    cout << n+1 << endl;
    return 0;
  }

  for(ll b=2; b*b<=n; b++) {
    if(f(b, n) == s) {
      cout << b << endl;
      return 0;
    }
  }

  ll ans = -1, rem = n-s;
  for(ll i=1; i*i<=rem; i++) {
    if(rem%i==0) {
      ll b = i + 1;
      if(f(b, n) == s) {
        if(ans== -1 || b < ans) ans = b;
      }
      // cout << i << " " << b; 
      b = rem/i+1;
      // cout << " " << b << endl; 
      if(f(b, n) == s) {
        if(ans== -1 || b < ans) ans = b;
      }
    } 
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = Integer.parseInt(sc.next());
        sc.nextLine();
        char[][] data = new char[a+2][b+2];
        for(int i = 0;i<a+2;i++){
            Arrays.fill(data[i], '.');
        }
        for(int i = 1;i<a+1;i++){
            String s = sc.nextLine();
            for(int j = 1;j<b+1;j++){
                data[i][j] = s.charAt(j-1);
            }
        }
        String ans = "Yes";
        for(int i = 1;i<a+1;i++){
            for(int j = 1;j<b+1;j++){
                if(data[i][j] == '#'){
                    if(data[i+1][j] == '.'
                    && data[i][j+1] == '.'
                    && data[i-1][j] == '.'
                    && data[i][j-1] == '.'){
                        ans = "No";
                        break;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<stack>
#include<tuple>
#include<utility>
#define rep0(i,n) for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;
/*ビットxにi番目のフラグが立っているかどうか
if(x & (1 << i))
↑ a << b == a*pow(b,2)
/*{0, 1, ..., n-1} の部分集合の全探索
for (int bit = 0; bit < (1 << n); ++bit)
*/

int main(){
  string s;  cin >> s;
  int ans = 0;
  int cnt = 0;
  rep0(i,s.size()){
    if(s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T'){
      cnt++;
    }else{
      ans = max(ans,cnt);
      cnt = 0;
    }
  }
  cout << max(ans,cnt);
  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	vector<int> A(4),B(4);
	while(cin>>A[0]){
		vector<int> AN(10,0);
		AN[A[0]]++;
		REP(i,3){
			A[i+1]=in();
			AN[A[i+1]]++;
		}
		int blow=0,hit=0;
		REP(i,4){
			B[i]=in();
			if(AN[B[i]]) blow++;
			if(A[i]==B[i]){
				blow--;
				hit++;
			}
		}
		out(hit,blow);
	}
	return 0;
}


Measured memory_bytes: 3052
#include <iostream>
#include <cstdio>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
const int sz = 1e5, ma = 1e9;
template <typename T>
T chmin(T a, T b) { a = min(a, b); }
template <typename T>
T chmax(T a, T b) { a = max(a, b); }
int n, k, a[sz], dp[41][2];
void solve()
{
    scanf("%lld%lld", &n, &k);
    rep(i, n) scanf("%lld", a + i);

    rep(m, 41)
    {
        int score[2] = {0, 0};
        rep(i, n)
        {
            score[1 - (a[i] >> m) & 1] += (1LL << m);
        }
        dp[m][0] = max(score[0], score[1]) + (m == 0 ? 0 : dp[m - 1][0]);
        if ((k >> m) & 1)
        {
            dp[m][1] = max(score[0] + (m == 0 ? 0 : dp[m - 1][0]),
                           score[1] + (m == 0 ? 0 : dp[m - 1][1]));
        }
        else
        {
            dp[m][1] = score[0] + (m == 0 ? 0 : dp[m - 1][1]);
        }
    }
    cout << dp[40][1] << endl;
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(int i = (m); i <= (n); i++)
#define zep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, k;
    string s;
    cin >> n >> s >> k;
    k--;
    
    zep(i, 0, n){
    	if(s[i] != s[k])s[i] = '*';
    }
    
    print(s)
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        readonly static long mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = s[0];
            int m = s[1];
            bool[] broken = new bool[n+1];
            for (int i = 0; i < m; i++)
            {
                broken[int.Parse(ReadLine())] = true;
            }

            long[] dp = new long[n + 2];
            dp[n] = 1;
            for (int i = n - 1; i >= 0; i--)
            {
                if (broken[i])
                {
                    dp[i] = 0;
                }
                else
                {
                    dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
                }
            }
            WriteLine(dp[0]);
        }
    }
}

Measured memory_bytes: 13920
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    int N; cin>>N;
    vector<int> A(N+1),B(N+1),C(N);
    for (int i = 1; i <= N; ++i) {
        cin>>A[i];
    }
    for (int i = 1; i <= N; ++i) {
        cin>>B[i];
    }
    for (int i = 1; i <= N-1; ++i) {
        cin>>C[i];
    }

    int ans=0;
    int past=-1;
    for (int i = 1; i <= N; ++i) {
        ans+=B[A[i]];
        if(A[i] == past+1){
            ans+=C[past];
        }
        past = A[i];
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const MAXN = 3e5;
int N, m[MAXN], d[MAXN+1];

int main() {
  std::cin >> N;
  std::fill_n(m, N, 0);
  for(int i = 0; i < N; ++i) { int A; std::cin >> A; ++m[A-1]; }
  std::fill_n(d, N+1, 0);
  for(int i = 0; i < N; ++i) ++d[m[i]];
 
  int sum_D = 0, sum_iD = N, k = 1;
  for(int ans = N; ans >= 1; --ans) {
    sum_D += d[ans];
    sum_iD -= d[ans]*ans;
    int f = sum_iD/ans + sum_D + 1;
    for(int i = k; i < f; ++i) std::cout << ans << std::endl;
    k = f;
  }
  while(k <= N) { std::cout << 0 << std::endl; ++k; }
  return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
using namespace std;
#define N 5005
int n,head[N],cnt,a[N],f[N],g[2][N],flag;//f[i]表示
struct edge{ int to,nxt; }e[N<<1];
void adde(int x,int y){
	e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt;
}
void ins(int x,int y){ adde(x,y); }
void dfs(int u){
	if (!head[u]){ f[u]=0; return; }
	//g[i]表示和u颜色相同的点权和为i的情况下，最小的和u颜色不同的点权和。
	for (int i=head[u],v; i; i=e[i].nxt){
		v=e[i].to; dfs(v);
	}
	int nk=0,k=1; memset(g[nk],0,sizeof(g[nk]));
	for (int i=head[u],v; i; i=e[i].nxt){
		//a[v] or f[v] ===> sum<=a[u]
		v=e[i].to;
		nk^=1,k^=1;
		memset(g[nk],0x3f,sizeof(g[nk]));
		per (j,a[u],0){
			if (j>=a[v]) g[nk][j]=min(g[nk][j],g[k][j-a[v]]+f[v]);
			if (j>=f[v]) g[nk][j]=min(g[nk][j],g[k][j-f[v]]+a[v]);
		}
	}
	rep (i,0,a[u]) f[u]=min(f[u],g[nk][i]);
	if (f[u]>inf) flag=0;
}
int main(){
	scanf("%d",&n);
	rep (i,2,n){
		int x; scanf("%d",&x); ins(x,i);
	}
	rep (i,1,n) scanf("%d",&a[i]);
	memset(f,0x3f,sizeof(f)); flag=1;
	dfs(1);
	//rep (i,1,n) cerr<<f[i]<<' ';cerr<<endl;
	puts(!flag?"IMPOSSIBLE":"POSSIBLE");
	return 0;
}
/*
8
1 1 1 3 4 5 5
4 1 6 2 2 1 3 3
*/

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
        int n=0,i;
        char c;
        for(i=0;i<4;i++){
                scanf("%c",&c);
                if(c=='+') n++;
                else if(c=='-') n--;
        }
        printf("%d\n",n);
        return 0;
}


Measured memory_bytes: 1656
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, M) = nextLongList()
    val n = if (N == 1L) 1L else N - 2
    val m = if (M == 1L) 1L else M - 2
    println(n * m)
}

Measured memory_bytes: 38000
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll R, C, K;
	cin >> R >> C >> K;
	map<pii, ll> v;
	rep(i, K) {
		ll r, c, vtmp;
		cin >> r >> c >> vtmp;
		v[make_pair(r - 1, c - 1)] = vtmp;
	}
	vector<vector<vl>> DP(R + 1);
	rep(r, R + 1) {
		DP[r].resize(C + 1);
		rep(c, C + 1) {
			DP[r][c].resize(4, 0);
		}
	}
	rep(r, R) {
		rep(c, C) {
			rep(k, 4) {
				DP[r + 1][c + 1][k] = max(DP[r + 1][c + 1][k], DP[r + 1][c][k]);
				DP[r + 1][c + 1][0] = max(DP[r + 1][c + 1][0], DP[r][c + 1][k]);
			}
			if (v.find(make_pair(r, c)) != v.end()) {
				rep(k, 3) {
					DP[r + 1][c + 1][k + 1] = max(DP[r + 1][c + 1][k + 1], DP[r + 1][c][k] + v[make_pair(r, c)]);
				}
				rep(k, 4) {
					DP[r + 1][c + 1][1] = max(DP[r + 1][c + 1][1], DP[r][c + 1][k] + v[make_pair(r, c)]);
				}
			}
		}
	}
	ll ans = 0;
	rep(k, 4)
		ans = max(ans, DP[R][C][k]);

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 649016
#include<bits/stdc++.h>
#define REP(i,N) for (int i=0;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main(){
    int N,j;
    cin >>N;
    vector<int> A(N),B(N),C(N-1);
    REP(i,N) cin >>A[i];
    REP(i,N) cin >>B[i];
    REP(i,N) cin >>C[i];

    int val=0;
    REP(i,N){
        int k=A[i]-1;
        val+=B[k];
        if(A[i+1]==A[i]+1){
            val+=C[k];
        }
    }
    cout <<val<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int l,r,i,j;
	cin>>l>>r;
	int t,w;
	if(r-l>=2018) 
	{
		cout<<0<<endl;
		return 0;
	}
	else
	{
		t=l%2019;
		w=r%2019;
		if(t>w) swap(t,w);
	}
	int ans=1000000000;
	for(i=t;i<=w;i++)
		for(j=i+1;j<=w;j++)
		{
			ans=min(ans,i*j%2019);	
		}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
m, d = map(int, input().split())


def is_seki(m, d1, d10):
    if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
        return 1
    else:
        return 0

total = 0
for month in range(1, m+1):
    for day in range(1, d+1):
        day = str(day)
        if len(day) == 2:
            d1 = int(day[0])
            d10 = int(day[1])
        else:
            d1 = 0
            d10 = int(day)
        total += is_seki(month, d1, d10)

print(total)

Measured memory_bytes: 40176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include <queue>
#include <deque>
#include <numeric>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long LL;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< LL > vl;
typedef vector< vl > vvl;
typedef vector< bool > vb;
typedef pair <int, int> ii;
#define tr(c,it) for(decltype(c.begin()) it = c.begin(); it != c.end(); it++)
#define rep(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define repr(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define in(a,b) ( (b).find(a) != (b).end())


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

	int n;
	cin >> n;

	vl h(n), c(n, 10000000001);
	rep(i, n) cin >> h[i];

	c[0] = 0;
	auto valid = [n](int x) -> bool {return (x < n); };

	rep(i, n - 1) {
		if (valid(i + 1)) c[i + 1] = min(c[i + 1], c[i] + abs(h[i + 1] - h[i]));
		if (valid(i + 2)) c[i + 2] = min(c[i + 2], c[i] + abs(h[i + 2] - h[i]));
	}

	cout << c[n-1];
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << "\n";

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

S = raw_input()

S = S.replace('mew', '[1]')
S = S.replace('me', 'm[1]e')
S = S.replace('ew', 'e[1]w')
S = S.replace('m', '[')
S = S.replace('e', ',')
S = S.replace('w', ']')

for i in range(500):
    S = S.replace('[[1],[1]]', '[1]')

if S == '[1]' or S == '':
    print 'Cat'
else:
    print 'Rabbit'



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

using namespace std;

const int N = 2010;
const int mod = 1e9 + 7;

int fac[N * N], inv[N * N], f[N][N];

int qpow(int a, int x) {
	int ret = 1;
	while(x) {
		if(x & 1) ret = (long long)ret * a % mod;
		x >>= 1, a = (long long)a * a % mod;
	}
	return ret;
}

int C(int n, int m) {
	if(n < m || n < 0 || m < 0) return 0;
	return (long long)fac[n] * inv[m] % mod * inv[n - m] % mod;
}

void Init(int n) {
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= n; ++ i)
		fac[i] = (long long)fac[i - 1] * i % mod;
	inv[n] = qpow(fac[n], mod - 2);
	for(int i = n; i >= 1; -- i)
		inv[i - 1] = (long long)inv[i] * i % mod;
}

int main() {
#ifdef ylsakioi
	freopen("agc002f.in", "r", stdin);
	freopen("agc002f.out", "w", stdout);
#endif
	int n, k;
	Init(N * N - 10);
	scanf("%d%d", &n, &k);
	if(k == 1) return puts("1"), 0;
	f[1][0] = 1;
	for(int i = 0; i <= n; ++ i)
		for(int j = 0; j <= i; ++ j) {
			if(i) (f[i][j] += f[i - 1][j]) %= mod;
			if(j) (f[i][j] += 1ll * C((n - j + 1) * (k - 1) + (n - i) - 1, k - 2) * f[i][j - 1] % mod) %= mod;
		}
	printf("%d\n", (long long)f[n][n] * fac[n] % mod);
	return 0;
}


Measured memory_bytes: 46720
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        int len = line.length();
        
        String result = "";
        
        for(int i = 0; i < len; i++)
        {
            result = result + "x";
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
using namespace std;
#define ll long long int

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = min( b/a , c );
  cout << ans << endl;
  return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

vector<int> a, b, c, d;
int N, M, Q;
int ans;

void dfs(vector<int> A, int size) {
  if (size == N) {
    int now = 0;
    REP(i, Q) {
      if (A.at(b.at(i)) - A.at(a.at(i)) == c.at(i)) {
        now += d.at(i);
      }
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= M) {
    dfs(A, size + 1);
    ++A.back();
  }
}

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

  cin >> N >> M >> Q;
  a = b = c = d = vector<int>(Q);
  REP(i, Q) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    --a.at(i);
    --b.at(i);
  }
  ans = 0;
  dfs(vector<int>(1, 1), 1);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=10000000000;

//main
int main() {
    
    //入力
    string S;
    long K;
    cin>>S>>K;
    
    //計算
    char x='1';
    long len=S.size();
    for(int i=0;i<S.size();i++){
        if(S.at(i)!='1'){
            x=S.at(i);
            len=i;
            break;
        }
    }
    
    //出力
    if(len<K){
        cout<<x<<endl;
    }else{
        cout<<1<<endl;
    }
}

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

int main(){
  int K, N; 
  std::cin >> K >> N;
  
  int A;
  int max_dist = 0;
  std::vector<int> As;
  
  for (int i = 0; i < N; i++){
    std::cin >> A;
    As.push_back(A);
    if (i != 0){
      if (As[i] - As[i - 1] > max_dist) max_dist = As[i] - As[i - 1];
    }
  }
  
  if (As[0] + K - As[N - 1] > max_dist) max_dist = As[0] + K - As[N - 1];
  
  std::cout << K - max_dist;
  
  return 0;
}

Measured memory_bytes: 4312
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(m)]
for a,b in s:
    k=float('inf')
    f=0
    for i,(c,d) in enumerate(p,start=1):
        t=abs(a-c)+abs(b-d)
        if k>t:
            k=t
            f=i
    print(f)


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

const int mod = 1e9 + 7;
const int MX  = 2e6;

ll power(ll x, ll y, ll p = mod) {
    ll res = 1;
    x      = x % p;
    while (y) {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

ll modInverse(ll n, ll p = mod) { return power(n, p - 2, p); }

ll fac[MX + 5];
void init(ll p = mod) {
    fac[0] = 1;
    for (int i = 1; i <= MX; i++) fac[i] = fac[i - 1] * i % p;
}

ll C(ll n, ll r, ll p = mod) {
    if (r == 0) return 1;
    if (n - r < r) return C(n, n - r, p);
    if (n <= MX)
        return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) %
                p) %
               p;
    ll num = 1, den = 1;
    for (int i = 0; i < r; ++i) {
        (den *= i + 1) %= p;
        (num *= (n - i)) %= p;
    }
    return num * modInverse(den, p) % p;
}


int main() {
    init(mod);
    int n, k;
    string s;
    cin >> k >> s;
    n = s.size() + k;
    ll r = 0;
    for (int i = s.size(); i <= n; ++i) (r += C(n, i) * power(25, n - i)) %= mod;
    cout << r;
}

Measured memory_bytes: 20972
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
using namespace std;
int town[51] = {0};

int main(){
	int N, M,A,B,C;
	cin >> N >> M;
	for (int i = 0; i < M; i++){
		int ai, bi;
		cin >> ai >> bi;
		town[ai]++;
		town[bi]++;
	}
	for (int i = 1; i < N + 1; i++){
		cout << town[i] << "\n";
	}



	return 0;
}

Measured memory_bytes: 256
module Main where

import Data.Array ((!), (//), listArray)
import Data.Maybe
import qualified Data.ByteString.Lazy.Char8 as B
import Control.Monad
    
solve :: Int    -- Max Weight
     -> [[Int]] -- [[value, weight]]
     -> Int     -- Max Value
solve w = iter $ listArray (0, w) $ replicate (w+1) 0 where
    iter mem [] = mem ! w
    iter mem ([value, weight]:xs) = iter mem' xs where
        mem' = mem // (iter2 w)
        iter2 0 = []
        iter2 w
            | w >= weight = (w, max (mem ! (w - weight) + value) (mem ! w)) : iter2 (w-1)
            | otherwise   = iter2 (w-1)

readLine:: B.ByteString -> [Int]
readLine s = map (fst . fromJust . B.readInt) (B.words s)

readLines :: [B.ByteString] -> [[Int]]
readLines [] = []
readLines (s:ss) = readLine s : readLines ss

main :: IO() 
main = do
    contents <- B.getContents
    let lines = B.lines contents
        [n,w] = readLine (head lines)
        l   = readLines (tail lines)
        ans = solve w l
    print ans



Measured memory_bytes: 149088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        int[] ps = {2, 3, 13, 23, 43, 53, 73, 83, 103, 113, 163, 173, 193, 223, 233, 263, 283, 293, 313, 353, 373, 383, 433, 443, 463, 503, 523, 563, 593, 613, 643, 653, 673, 683, 733, 743, 773, 823, 853, 863, 883, 953, 983, 1013, 1033, 1063, 1093, 1103, 1123, 1153, 1163, 1193, 1213, 1223, 1283};
        for (int i=0; i<n-1; i++){
            System.out.print(ps[i] + " ");
        }
        System.out.print(ps[n-1]);
    }
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
#define int  long long
int A[100005];
const int mod = 1e9+7;
int inv(int x)
{
    int ans = 1;
    int n=mod-2;
    while(n)
    {
        if(n&1)
        {
            ans=(ans*x)%mod;
        }
        x= (x*x)%mod;
        n>>=1;
    }
    return ans;
}
int f[100005];
void init(int n)
{
    f[0]=1;
    for(int i=1; i<=n; i++)
    {
        f[i]=(f[i-1]*i)%mod;
    }
}
int C(int n,int m)
{

    return ((f[n]*inv(f[m]))%mod*inv(f[n-m]))%mod;
}
signed main()
{

    int n,k;
    scanf("%lld%lld",&n,&k);
    init(n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&A[i]);
    }
    sort(A+1,A+n+1);
    int a=0,b=0;
    for(int i=1; i<=n; i++)
    {
        if(i>=k)b=(b+A[i])%mod;
        if(i<=n-k+1)
        {
            a=(a+A[i])%mod;
        }
    }
    int x = k, y = n-k+1,ans=0;

    for(int i=0; i<=n; i++)
    {
        ans=(ans+((b-a+mod)%mod*C(k+i-2,k-2))%mod)%mod;
        a=(a-A[y--]+mod)%mod;
        b=(b-A[x++]+mod)%mod;
        if(y==0)break;
        if(x==n+1)break;
    }
    cout<<ans<<'\n';


}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

constexpr auto MAX = 101;
constexpr auto INF = 10000000;

int cost[MAX][MAX];
auto n = 0;
auto k = 0;

auto init() -> void {
    for (int i = 0; i < MAX; i++) {
        for (int j = 0; j < MAX; j++) {
            cost[i][j] = i==j ? 0 : INF;
        }
    }
}

auto update(int c, int d, int e) -> void {
    cost[c][d] = min(cost[c][d], e);
    cost[d][c] = cost[c][d];

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cost[i][j] = min(cost[i][j], cost[i][c] + cost[c][d] + cost[d][j]);
            cost[j][i] = cost[i][j];
        }
    }
}

auto main(int argc, char const *argv[]) -> int {
    while (cin>>n>>k, n || k) {
        init();
        auto witch = 0;
        for (auto i = 0; i < k; i++) {
            cin>>witch;
            if ( witch ) {
                auto c = 0;
                auto d = 0;
                auto e = 0;
                cin>>c>>d>>e;
                update(c, d, e);
            }else {
                auto a = 0;
                auto b = 0;
                cin>>a>>b;
                if (cost[a][b] != INF) cout<<cost[a][b]<<endl;
                else cout<<"-1"<<endl;
            }
        }

    } 

    return 0;
}

Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	unordered_set<string> set;
	
	cin >> N;
	for(int i = 0; i < N; i++){
		string S;
		cin >> S;
		if(set.find(S) == set.end()){
			set.insert(S);
		}
	}
	
	cout << set.size() << endl;
	
	return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, Y;
    cin >> N >> Y;
    Y /= 1000;
    ll x = -1, y = -1, z = -1;
    for (ll i = 0; i <= N; i++) {
        for (ll j = 0; i + j <= N; j++) {
            ll k = N - i - j;
            ll t = 10 * i + 5 * j + k;
            if (t == Y) {
                x = i, y = j, z = k;
            }
        }
    }

    cout << x << " " << y << " " << z << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3652
h=[int(input()) for i in range(5)]
h=sorted(h, key=lambda x:x%10)
total=0
frag=True
for i in h:
    if i%10==0:
        total+=i
    elif frag==True and i%10!=0:
        total+=i
        frag=False
    else:
        i=i//10
        i=i*10+10
        total+=i
print(total)

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


// 指定した行が白色のみか調べる関数
bool is_white_row(vector<vector<char>> &grid, int y) {
    bool ret = true;

    for(int x=0; x<grid[y].size(); x++) {
        if (grid[y][x] == '#') {
            ret = false;
            break;
        }
    }

    return ret;
}


// 指定した列が白色のみか調べる関数
bool is_white_col(vector<vector<char>> &grid, int x) {
    bool ret = true;

    for(int y=0; y<grid.size(); y++) {
        if (grid[y][x] == '#') {
            ret = false;
            break;
        }
    }

    return ret;
}


// グリッドを詰める関数（'x'で置き換える）
// n : 詰める行番号もしくは列番号
// option : 列を詰めるか行を詰めるか（0 : 行, 1 : 列）
void compress_grid(vector<vector<char>> &grid, int n, int option) {

    // 行を詰めるとき
    if (option == 0) {
        for(int x=0; x<grid[n].size(); x++) {
            grid[n][x] = 'x';
        }
    }

    // 列を詰めるとき
    else if (option == 1) {
        for(int y=0; y<grid.size(); y++) {
            grid[y][n] = 'x';
        }
    }

}


int main() {
    int H, W;
    cin >> H >> W;
    
    // グリッド
    // 白 : '.' / 黒 : '#' / 詰めたマス : 'x'
    vector<vector<char>> grid(H, vector<char>(W));

    // グリッドの初期状態を読み込む
    for(int i=0; i<H; i++) {
        string line;
        cin >> line;
        for(int j=0; j<line.size(); j++) {
            grid[i][j] = line.at(j);
        }
    }

    // 行方向で圧縮
    for(int y=0; y<H; y++) {
        if (is_white_row(grid, y)) {
            compress_grid(grid, y, 0);
        }
    }

    // 列方向で圧縮
    for(int x=0; x<W; x++) {
        if (is_white_col(grid, x)) {
            compress_grid(grid, x, 1);
        }
    }

    // 結果を表示
    int cout_count;
    for(int y=0; y<grid.size(); y++) {
        cout_count = 0;
        for(int x=0; x<grid[y].size(); x++) {
            if (grid[y][x] != 'x') {
                cout << grid[y][x];
                cout_count++;
            }
        }
        if (cout_count != 0) {
            cout << endl;
        }
    }
}

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

int main() {
	int N;
	cin >> N;
	if (1==N) {
		cout << "Hello World" <<endl;
	}
	else{
		int A;
		int B;
		cin >> A >> B;
		cout << A + B << endl;
	}
	return 0;
}

Measured memory_bytes: 3572
// C++ 14
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int h, w; cin >> h >> w;
  vector<string> A(h);
  loop(i,0,h) cin >> A[i];
  vector<bool> deleteH(h, false);
  vector<bool> deleteW(w, false);
  loop(i,0,h) {
    bool del = true;
    loop(j,0,w) {
      del &= A[i][j] == '.';
    }
    deleteH[i] = del;
  }
  loop(j,0,w) {
    bool del = true;
    loop(i,0,h) {
      del &= A[i][j] == '.';
    }
    deleteW[j] = del;
  }

  loop(i,0,h) {
    if (deleteH[i]) continue;
    loop(j,0,w) {
      if (deleteW[j]) continue;
      cout << A[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(100000)

calculated = set([0, 1])
cal_fib = [0 for _ in range(45)]
cal_fib[0:2] = 1, 1

def fib(n):
    if cal_fib[n] == 0:
        cal_fib[n] = fib(n-1) + fib(n-2)
    return cal_fib[n]

n = int(input())
print(fib(n))

Measured memory_bytes: 7708