akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
int main(){
    string s,t;
    cin>>s>>t;
    if(s.substr(0,s.size())==t.substr(0,s.size()) && t.size()==s.size()+1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;   
       
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>
#include <iomanip>

typedef long long ll;
using namespace std;
ll my_gcd(ll a, ll b){
    if(a<b) return my_gcd(b,a);
    if(b==0) return a;
    return my_gcd(b, a%b);
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ac = a/c;
    ll ad = a/d;
    ll cd = c*d / my_gcd(c,d);
    ll acd = a/cd;
    ll bc = b/c;
    ll bd = b/d;
    ll bcd = b/cd;
    ll ret = 0;
    ret += bc - ac;
    ret += bd - ad;
    ret += acd - bcd;
    ret += (a%c==0) + (a%d==0) - (a%cd == 0);
    ret = b- a - ret + 1;
    cout << ret << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

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

    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

ll com(ll n,ll r){
    ll ret=1;
//    if(r<=0){
//        return 1;
//    }
    for (int i = 0; i < r; ++i) {
        ret*=n-i;
    }
    ll d=1;
    for (int i = 0; i < r; ++i) {
        d*=i+1;
    }
    return ret/d;
}

ll g(string n,ll i,ll k,ll ans){
    ll d=n.size()-i;
    ll f=n[i]-'0';
    if(k<=0){
        return ans;
    }
    if(f==0){
        if(i+1<n.size()) {
            return g(n, i + 1, k, ans);
        }
        else {
            return ans-1;
        }
    }
    ll tmp=com(d-1,k);
    for (int j = 0; j < k; ++j) {
        tmp*=9;
    }
    ans+=tmp;
//    cout <<ans <<endl;
    tmp=com(d-1,k-1);
//    cout <<tmp<<endl;
    for (int j = 0; j < k - 1; ++j) {
        tmp*=9;
    }
//    cout <<f<<endl;
    ans+=tmp*(f-1);
//    cout <<ans <<endl;
    if(i+1<n.size()) {
        return g(n, i + 1, k - 1, ans);
    }
    else {
        return ans;
    }
}

int main(){
    string n;cin >>n;
    ll k;cin >>k;
    if(n.size()<k){
        cout <<0<<endl;
    }
    else {
        cout << g(n, 0, k, 0) + 1 << endl;
    }
    return 0;
}



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

namespace AOJ
{
  class Program
  {
    static void Main()
    {
      int[] data = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
      int r = data[0];
      int c = data[1];
      int[,] sheet = new int[r + 1, c + 1];
      int i, j;

      for (i = 0; i <= r; i++)
        for (j = 0; j <= c; j++)
          sheet[i, j] = 0;

      for (i = 0; i < r; i++)
      {
        data = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        for (j = 0; j < c; j++)
        {
          sheet[i, j] = data[j];
          sheet[i, c] += data[j];
          sheet[r, j] += data[j];
        }
        sheet[r, c] += sheet[i, c];
      }

      for (i = 0; i <= r; i++)
      {
        for (j = 0; j < c; j++)
        {
          Console.Write("{0} ", sheet[i, j]);
        }
        Console.WriteLine(sheet[i, j]);
      }
    }
  }
}

Measured memory_bytes: 9872
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...)
#endif
using namespace std;
 
const int maxN = 1 << 19;

int T[maxN];
 
int main()
{
	long long n, m, k;
	scanf ("%lld%lld%lld", &n, &m, &k);
	
	long long res;
	
	if ((k-m)%2 == 0)
		res = (k-m)/2;
		
	else
	{
		res = (k-m)/2 + 1ll + min(m-1, n-k);
	}
	
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 101

static const int INFTY = (1<<21);

main(){
  int n,M[N][N];
  int i,j,e,sum;
  int u,minv;
  int d[N],p[N],color[N];
  
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  }
  
  for(i=0;i<n;i++){
    d[i]=INFTY;
    if(i==0){
      d[i]=0;
    }
    p[i]=-1;
    color[i]=0;
  }
    
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]==0){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1){
      break;
    }   else {
      color[u]=1;
      for(j=0;j<n;j++){
	if(d[j]>M[u][j] && color[j]==0){
	  p[j]=u;
	  d[j]=M[u][j];
	}
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
      if(p[i]!=-1) sum += M[i][p[i]];
    }

printf("%d\n",sum);
return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    FOR(i, 1, N){
        cin >> A[i];
        --A[i];
    }

    vector<int> num_sub(N, 0);
    FOR(i, 1, N) ++num_sub[A[i]];
    REP(i, N) cout << num_sub[i] << endl;

    return 0;
}

Measured memory_bytes: 4408
'''
                        *             * * * * * * * *
                        *             *
                        *             *
                        *             *
                        *             *
                        *             *
                        *             *
                        * * * * * * * * * * * * * * *
                                      *             *
                                      *             *
                                      *             *
                                      *             *
                                      *             *
                                      *             *
                        * * * * * * * *             *

'''
import sys
sys.setrecursionlimit(10**7)
dp=[-1]*(10**5+2)
def frog(arr,N):
    if N==0:
        dp[0]=0
        return dp[0]
    elif N==1:
        dp[1]=abs(arr[1]-arr[0])
        return dp[1]
    elif N==2:
        dp[2]=min(frog(arr,N-1)+abs(arr[N]-arr[N-1]),abs(arr[N]-arr[N-2]))
        return dp[2]
    else:
        if dp[N]!=-1:
            return dp[N]
        dp[N]=min(frog(arr,N-2)+abs(arr[N]-arr[N-2]),frog(arr,N-1)+abs(arr[N]-arr[N-1]))
        return dp[N]
if __name__ == "__main__":
    N=int(input())
    h=[int(i) for i in input().split()][:N]
    frog(h,N-1)
    print(dp[N-1])

Measured memory_bytes: 127092
#include<iostream>
#include<string>
#include<cctype>
#define rep(i,start,n) for(int i=start ; i<n ; i++)

using namespace std;

int main(){

int count=0,count2=0,x=0;
string  taro,hanako;                                  //????????????????????????????´??????????????????¨?????°

cin >> x;                                             //card????????°??\???

rep(i,0,x){

  cin >> taro >> hanako;                                  //?????????????????????

  rep(i , 0 , taro.length()){                                  // ???????????????
    if(isupper(taro[i])){
      taro[i] = tolower(taro[i]);                        //??????????°????????????????
    }
  }

  rep(i , 0 , hanako.length()){                                  // ???????????????
    if(isupper(hanako[i])){
      hanako[i] = tolower(hanako[i]);                        //??????????°????????????????
    }
  }


if(taro == hanako){
  count = count +1;                             //?????????????????´???
  count2 = count2 + 1;
}
else if(hanako < taro){                         //????????????????????´???
  count2 = count2 + 3;
}
else if(taro < hanako){                       //??±?????????????????´???
  count = count + 3;
}

}

cout << count2 << " " << count << endl;

return 0;

}

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

int main() {
    string s;
    cin >> s;
    int maxlength = 0;
    int length = 0;
    for(int i = 0; i < (int)s.size(); i++)
    {
        if (s.at(i) == 'A' || s.at(i) == 'T' || s.at(i) == 'G' || s.at(i) == 'C') {
            length++;
        }
        else {
            maxlength = max(maxlength,length);
            length = 0;
        }
    }
    maxlength = max(maxlength, length);
    cout << maxlength << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,D,x,y,count=0;
	double d;
	cin>>N>>D;
	for (int i = 0; i < N; ++i)
	{
		cin>>x>>y;
		d=sqrt(pow(x,2)+pow(y,2));
		if(d<=D)
			count++;
	}
	cout<<count;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;
    ll power(ll a, ll b)    //a is base, b is exponent
    {
        if(b==0)
            return 1;
        if(b==1)
            return a;
        if(b%2 == 1)
            return (power(a,b-1)*a)%mod;
        ll q = power(a,b/2);
        return (q*q)%mod;
    }

void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n;
  if(n<10)
  {
    c(n);
    return;
  }
  mii mp;
  for (ll i = 1; i <= n; ++i)
  {
    k = log10(i);

    x = i/power(10,k);
    y = i%10;
        mp[{x,y}]++;
 
  }
  for(auto it=mp.begin();it!=mp.end();it++)
  {
    x = (it->F).F;
    y = (it->F).S;
    k = it->S;
   // cout<<x<<" "<<y<<" "<<k<<" " ;
    if(x==y)
    {
    ans += k*k;  
    it->S=0;  
    }
    else
    {
        ans+= 2*mp[{y,x}]*k;
        it->S=0;  
        mp[{y,x}]=0;
    //    cout<<mp[{y,x}]<<" ";
    }
    //c(ans);
  }
  c(ans);
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  ll T=1;
  //cin>>T;
  while(T--){
  solve();
  }
  return 0;
}


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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 410, Mod = 1e9 + 7;
int fpow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1ll * a * a % Mod)
		if (b & 1) res = 1ll * res * a % Mod;
	return res;
}
int S[N][N], f[N][N], n, c, A[N], B[N];
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	read(n), read(c);
	for (int i = 1; i <= n; i++) read(A[i]);
	for (int i = 1; i <= n; i++) read(B[i]);
	for (int k = 0; k <= 400; k++)
		for (int i = 1; i <= 400; i++)
			S[k][i] = (S[k][i - 1] + fpow(i, k)) % Mod;
	f[0][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= c; j++)
			for (int k = 0; k <= j; k++)
				f[i][j] = (f[i][j] + 1ll * f[i - 1][j - k] * ((S[k][B[i]] - S[k][A[i] - 1] + Mod) % Mod) % Mod) % Mod;
	printf("%d\n", f[n][c]);
	return 0;
}


Measured memory_bytes: 1536
def checkb():
	for i in range(n-1):
		if nl1[i] == nl1[i+1]:
			#print("Same number")
			for j in range(n):
				if nlo[j] == nl1[i]:
					for k in range(j+1,n):
						if nlo[k] == nl1[i]:
							if sl[j] == bsl[i+1] and sl[k]==bsl[i]:
								return False
	return True

def checks():
	for i in range(n-1):
		if nl2[i] == nl2[i+1]:
			for j in range(n):
				if nlo[j] == nl2[i]:
					for k in range(j+1,n):
						if nlo[k] == nl2[i]:
							if sl[j] == ssl[i+1] and sl[k]==ssl[i]:
								return False
	return True

n = int(input())

nlo = [[] for i in range(n)]#Origin number
nl1 = [[] for i in range(n)]#number Bubble
sl = [[] for i in range(n)]

nl2 = [[] for i in range(n)]#number Selection
bsl = [[] for i in range(n)]
ssl = [[] for i in range(n)]

a = input().split()
for i in range(n):
	sl[i] = ssl[i] = bsl[i] = a[i][0]
	nlo[i] = nl1[i] = nl2[i] = int(a[i][1])

#Bubble Sort
for i in range(n):
	for j in range(n-1,i,-1):
		if nl1[j] < nl1[j-1]:
			nl1[j], nl1[j-1] = nl1[j-1], nl1[j]
			bsl[j], bsl[j-1] = bsl[j-1], bsl[j]

#Selection Sort
for i in range(n):
	minj = int(i)
	for j in range(i,n):
		if nl2[j] < nl2[minj]:
			minj = j
	nl2[i], nl2[minj] = nl2[minj], nl2[i]
	ssl[i], ssl[minj] = ssl[minj], ssl[i]
"""
print(sl)
print(bsl)
print(ssl)
print(nlo)
print(nl1)
"""
for i in range(n):
	print(str(bsl[i]) + str(nl1[i]),end="")
	if i == n-1:
		break
	print(" ",end="")
print()
if checkb():
	print("Stable")
else:
	print("Not stable")
for i in range(n):
	print(str(ssl[i]) + str(nl2[i]),end="")
	if i == n-1:
		break
	print(" ",end="")
print()
if checks():
	print("Stable")
else:
	print("Not stable")


Measured memory_bytes: 5644
N, A, B = map(int, input().split())
S = input()
student_pass = A + B
abroad_student_pass = B
passed_students = 0
passed_students_abroad = 0


for status in S:
  if status == 'c':
    print('No')
  elif status == 'a':
    if passed_students < student_pass:
      print('Yes')
      passed_students += 1
    else:
      print('No')
  elif status == 'b':
    if passed_students < student_pass and passed_students_abroad < abroad_student_pass:
      print('Yes')
      passed_students += 1
      passed_students_abroad += 1
    else:
      print('No')

Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;

ll f(ll a) {
	ll n = (a + 1) / 2;
	ll x = 0;
	if (n % 2 == 0) {
		x = 0;
	}
	else {
		x = 1;
	}

	if (a % 2 == 0) {
		x ^= a;
	}
	else {
	}

	return x;
}

int main() {
	ll a, b; cin >> a >> b;
	cout << (f(a - 1) ^ f(b)) << endl;
	return 0;
}

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

typedef long long ll;

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


int main(){
    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    ll g = gcd(n, m);
    ll l = n / g * m;
    ll sstep = n / g;
    ll tstep = m / g;
    for(int i=0; i<g; i++) {
        if(s[sstep*i] != t[tstep*i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << l << endl;
    
    return 0;
} 

Measured memory_bytes: 512
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int w, n;
int ans[30];
int main()
{
    cin >> w >> n;
    REP(i, w) {
        ans[i] =i + 1;
    }
    REP(i, n) {
        char c;
        int a, b;
        cin >> a >> c >> b;
        a--;b--;
        int tmp = ans[a];
        ans[a] = ans[b];
        ans[b] = tmp;
    }
    REP(i, w) {
        cout << ans[i] << endl;
    }
}



Measured memory_bytes: 3004
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
int n;
pair<double,int>p[1000];
main()
{
    while(cin>>n,n)
    {
        for(int i=0;i<n;i++)
        {
            double h,w;
            cin>>p[i].second>>h>>w;
            h/=100;
            p[i].first=abs(22-w/h/h);
        }
        sort(p,p+n);
        cout<<p[0].second<<endl;
    }
}


Measured memory_bytes: 3056
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    total = sum(A)
    if N - total >= 0:
        print(N - total)
    else:
        print(-1)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68564
import itertools
L,R = map(int,input().split())
if 2019 <= (R - L) + 1:
  print(0)
  exit()
  
lst = list(range(L,R+1))
md = [x * y % 2019 for x,y in itertools.combinations(lst,2)]
md.sort()
print(md[0])


Measured memory_bytes: 81556
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  string s, t;
  cin >> s >> t;
  vector<int> tq(26, 0), sq(26, 0);
  rep(i,t.size())
  {
    tq[t[i] - 'a']++;
    sq[s[i] - 'a']++;
  }
  sort(tq.begin(), tq.end());
  sort(sq.begin(), sq.end());
  rep(i,26)
    if (tq[i] != sq[i]) {
      cout << "No";
      return 0;
    }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 776
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int A, B;

int main(void) {
    scanf("%d %d", &A, &B);
    
    if ((A*B) % 2 == 0) puts("No");
    else puts("Yes");

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
const double inf=1e10;
struct D {
  //各速度ごとの左端と右端
  vector<double> l,r;
  D():l(3,inf),r(3,-inf) {}
  //点追加のメソッド
  void add(double x, int v){
    //vが-1から始まることを考慮
    v++;
    //各速度の右端と左端を更新
    mins(l[v],x);
    maxs(r[v],x);
  }
  // 時間を与えた時の幅を返す関数
  double get(double t){
    double nl = inf,nr = -inf;
    rep(i,3){
      mins(nl, l[i]+i*t);
      maxs(nr, r[i]+i*t);
    }
    return nr-nl;
  }
  // 点同士がすれ違うタイミングを返す関数
  vector<double> events(){
    vector<double> ts;
    rep(i,3)rep(j,i){//j<iつまり速度が違う時の列挙
      //左端同士がすれ違うタイミング
      {
      double t=(l[j]-l[i])/(i-j);
      if(t>0) ts.push_back(t);
      }
      // 右端同士がすれ違うタイミング
      {
      double t=(r[j]-r[i])/(i-j);
      if(t > 0) ts.push_back(t);
      }
    }
    // 変化しうる点を全て返す
      return ts;
  }
};
int main(){
 int N;cin>>N;
 D xd,yd;
 rep(i,N){
   int x,y;
   char d;
   cin>>x>>y>>d;
   if(d=='L') xd.add(x,-1),yd.add(y,0);
   if(d=='R') xd.add(x,1),yd.add(y,0);
   if(d=='U') xd.add(x,0),yd.add(y,1);
   if(d=='D') xd.add(x,0),yd.add(y,-1);
 }
 // 点同士がすれ違うタイミングを列挙する
 vector<double> ts;
 ts.push_back(0);
 ts.push_back(inf);
 {
   auto nts = xd.events();
   ts.insert(ts.end(),nts.begin(),nts.end());
 }
 {
   auto nts = yd.events();
   ts.insert(ts.end(),nts.begin(),nts.end());
 }
 // rep(i,ts.size())cout<<ts.at(i)<<endl;
 sort(ts.begin(),ts.end());
 double ans= 1e18;
 for(double t:ts){
   double now = xd.get(t)*yd.get(t);
   // cout<<now<<endl;
   mins(ans,now);
 }
 printf("%.10f\n",ans);
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pii pair<int,int>
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n,m,ans=0; cin>>n>>m;
  vector<vector<bool>> v(n,vector<bool>(n));
  rep(i,0,m){
    int a,b; cin>>a>>b;
    v[a-1][b-1]=true; v[b-1][a-1]=true;
  }
  vector<int> tem={};
  rep(i,0,n) pb(tem,i);
  do{
    bool f=true;
    rep(i,0,tem.size()-1){
      if(!v[tem[i]][tem[i+1]]){
      	f=false;
      	break;
      }
    }
    if(f) ans++;
  }while(next_permutation(tem.begin()+1,tem.end()));
  co(ans);
  
  return 0;
}

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

using namespace std;

int main() {

	long n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;

	long bottleNeck = min(a, min(b,min(c,min(d,e))));

	long time = (n + bottleNeck - 1) / bottleNeck + 4;

	cout << time;

	return 0;
}

Measured memory_bytes: 256
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

map<int,int> cnt;

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int x,n;
   cin >> x >>  n;
   f(i,0,n){
      int y;
      cin >> y;
      cnt[y] = 1;
   }
   int r = x;
   while(cnt[r]) r++;
   int l = x;
   while(cnt[l]) l--;
   if(abs(l-x) <= abs(r-x)){
      cout << l << '\n';
   }else{
      cout << r << '\n';
   }
   return 0;
} 

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long LL;
#define REP(i,N) for (int i=0; i<N; i++)

int main() {
  int N, ans = 0;
  int a[100000], reg[1000000] = {0};
  cin >> N;
  REP(i, N) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    if (a[i] - 1 >= 0) {
      reg[a[i]-1]++;
    }
    reg[a[i]]++;
    reg[a[i]+1]++;
  }
  for (int i = 0; i < 100001; i++) {
    if (ans < reg[i]) ans = reg[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    if(N%2==0)
    {
        double M=double(N);
        cout <<setprecision(10)<<fixed<< 0.500000000000 <<endl;
    }
    else
    {
        double M=double(N);

        cout <<setprecision(10)<<fixed<<(((M+1)/2)/M) <<endl;
    }
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a), greater<ll>());
    ll ans = a[0];
    ll cnt = n - 2;
    for(int i = 1; i < n; i++) {
        if(cnt == 0) {
            break;
        }
        if(cnt >= 2) {
            ans += a[i] * 2;
            cnt -= 2;
            continue;
        }
        if(cnt == 1) {
            ;
            ans += a[i];
            cnt = 0;
            continue;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

string s, t;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        String T = scanner.next();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        String U = scanner.next();
        
        if(U.equals(S)){
            System.out.print(A-1);
            System.out.print(" ");
            System.out.println(B);
        }else{
            System.out.print(A);
            System.out.print(" ");
            System.out.println(B-1);
        }
        
    }
}


Measured memory_bytes: 23124
from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
q = deque([0])
d = [-1] * n
d[0] = 0
ans = [0] * n
print('Yes')
while q:
    p = q.popleft()
    for node in g[p]:
        if d[node] == -1:
            d[node] = d[p] + 1
            q.append(node)
        else:
            if d[node] + 1 == d[p]:
                ans[p] = node + 1
for i in range(1, n):
    print(ans[i])


Measured memory_bytes: 37916
#pragma GCC optimze("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// inbuilt function in c++
// abs(-2)=2 , __gcd(2,3)=1 , swap(a,b) , 
//string/array s = "aba"; sort(s.begin(), s.end());  do {  cout << s << '\n';  } while(next_permutation(s.begin(), s.end()));  
//for all permutation of s.
#include <bits/stdc++.h>
#define int                 long long int
#define double              long double
#define get(a,n)            for(int i=0;i<n;i++){cin>>a[i];}
#define out(a,n)            for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define maxm(a)             int maxi=LLONG_MIN;int index;for(int i=0;i<n;i++){if(maxi<a[i]){maxi=a[i];index=i;}}
#define minm(a)             int mini=LLONG_MAX;int index;for(int i=0;i<n;i++){if(mini>a[i]){mini=a[i];index=i;}}
#define db(x)               cout<<x<<" "<<endl;
#define endl                "\n"
#define PI                  acos(-1)
#define half(a)             a%2?cout<<(a/2+1)<<endl:cout<<a/2<<endl;
#define array               int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define pb(a)                push_back(a)
#define all(a)              a.begin(),a.end()
using namespace std;
void show(int *a)
{
    int size = (*(&a + 1) - a)-1;
    for(int i=0;i<size;i++)
    {
            cout<<a[i]<<" ";
    }   
    cout<<endl;
}
int binary_search(int *a,int n,int e)
{
    int f,l,m;f=0;l=n-1;
    while(f<=l)
    {//returns index of that value.
        m=(f+l)/2;
        if(e==a[m])
            return(m);
        else if(e>a[m])
                f=m+1;
            else
                l=m-1;
    }
    return -1;
}
vector<int> pf;
void primefactors(int n)  
{  
    while (n % 2 == 0)  
    pf.push_back(2),n = n/2;  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            pf.push_back(i); 
            n = n/i;  
        }  
    }  
    if (n > 2)  
        pf.push_back(n);
        //dont forgot to clear pf vector. 
}  
vector<int> fac;
//vector<int,greater<int>>fac;
void factors(int n) 
{ 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
            fac.push_back(i);
            else
            fac.push_back(i),fac.push_back(n/i); 
        } 
    } 
    //dont forgot to clear fac vector.
} 
// priority_queue stores the values in descending order q.front() returns maximum element. ".size() works for priority_queue."
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);
    int t=1;
//    cin>>t;
    while(t--)
    {
        int a,v,b,w,t;
        cin>>a>>v>>b>>w>>t;
        if(v>=w)
        {
            if((abs(b-a)>abs(v-w)*t))
            {
                cout<<"NO"<<endl;
            }
            else
            {
                cout<<"YES"<<endl;
            }
        }
        else
        {
            cout<<"NO"<<endl;
        }
        
        
    }
   

  
}

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

using namespace std;

const int mod = 1e9 + 7;

int dp[22][(1<<21) + 2];
int a[23][23];

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

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


	// dp[i][msk|(1<<i)] += dp[i-1][msk]

	memset(dp, 0, sizeof dp);
	dp[0][0] = 1;

	for(int i = 1; i <= n; i++){
		for(int j = 0; j < (1<<n); j++) {
			if(__builtin_popcount(j) != (i-1)) continue;
			for(int k = 0; k < n; k++){
				if(j&(1<<k)) continue;
				if(a[i-1][k] == 0) continue;
				dp[i][j|(1<<k)] += dp[i-1][j];
				dp[i][j|(1<<k)] %= mod;
			}
		}
	}

	cout << dp[n][(1<<n) - 1] << endl;
}


Measured memory_bytes: 180608
h, w, k = map(int, input().split())
C = [input() for i in range(h)]
ans = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for ii in range(h):
            for jj in range(w):
                if (i >> ii) & 1 == 0 and (
                        j >> jj) & 1 == 0 and C[ii][jj] == '#':
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)


Measured memory_bytes: 73600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
int main(void){
    int n,m;
    while(cin>>n>>m,n){
        vvi riku(n,vi(n,99999999));
        vvi kai(n,vi(n,99999999));
        rep(i,n){
            riku[i][i]=0;
            kai[i][i]=0;
        }
        int x,y,t;
        char sl;
        rep(i,m){
            cin>>x>>y>>t>>sl;
            if(sl=='L'){
                riku[x-1][y-1]=t;
                riku[y-1][x-1]=t;
            }else{
                kai[x-1][y-1]=t;
                kai[y-1][x-1]=t;
            }
        }
        int r;
        cin>>r;
        vvi dp(r+1,vi(n,99999999));
        vi jun(r,0);
        rep(i,r){
            cin>>jun[i];
            jun[i]--;
        }
        rep(k,n)rep(i,n)rep(j,n){
            riku[i][j]=min(riku[i][j],riku[i][k]+riku[k][j]);
            kai[i][j]=min(kai[i][j],kai[i][k]+kai[k][j]);
        }
        dp[1][jun[0]]=0;
        for(int i=1;i<r;i++)rep(j,n)rep(k,n){
            if(j!=k) dp[i+1][k]=min(dp[i+1][k],dp[i][j]+riku[jun[i-1]][j]+kai[j][k]+riku[k][jun[i]]);
            else dp[i+1][k]=min(dp[i+1][k],dp[i][j]+riku[jun[i-1]][jun[i]]);
        }
        cout<<*min_element(dp[r].begin(),dp[r].end())<<endl;
    }
}







Measured memory_bytes: 3872
import java.util.Scanner;

public class Main {
    static int MAX_FAC = 400001;
    static long FAC[] = new long[MAX_FAC];
    static long INV_FAC[] = new long[MAX_FAC];
    private static long MOD = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long ans=0;
        initFAC();
        if(k==1){
            ans = (n*(n-1)) % MOD;
        }else{
            for(long i=1;i<=Math.min(k, n-1);i++){
                //System.out.println(bara((int)n, (int)(n-i)) + ":" + comb((int)n, (int)i));
                ans += ((bara((int)n, (int)(n-i)) * comb((int)n, (int)i)) % MOD);
                ans %= MOD;
            }
            ans ++;
            ans %= MOD;
        }
        System.out.println(ans);
    }
    static long comb(int n, int k){
        return (((FAC[n] * INV_FAC[n-k]) % MOD) * INV_FAC[k]) % MOD;
    }

    static void initFAC(){
        FAC[0]=1;
        INV_FAC[0] = modinv(FAC[0]);
        for(int i=1;i<MAX_FAC;i++){
            FAC[i]=(i*FAC[i-1]) % MOD;
            INV_FAC[i] = modinv(FAC[i]);
        }
    }
    static long modpow(long a, long b){
        if(b == 1){return a % MOD;}
        if(b == 0){return 1;}
        long res = b/2;
        long rem = b%2;
        long p = modpow(a, res) % MOD;
        if(rem == 1){
            return (((p*p) % MOD) * a) % MOD;
        }else{
            return (p*p) % MOD;
        }
    }

    static long modinv(long a){
        return modpow(a, MOD-2);
    }

    private static long bara(int n, int k){
        return comb(n-1, k-1);
    }

}


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

ll n, ac, wa, tle, re;

int main() {
	cin>>n;
	string s[n];
	for (int i=0; i<n; i++) {
		cin>>s[i];
		if (s[i]=="AC") ac++;
		else if (s[i]=="WA") wa++;
		else if (s[i]=="TLE") tle++;
		else re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}



Measured memory_bytes: 6724
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 6223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

int N, M, S;
const int MAX = 1250000;
struct edge { int to, cost; };
vector<vector<edge> > G;
VI d;

void dikstra(int s) {
	priority_queue<pii, vector<pii>, greater<pii> >que;
	REP(i, MAX)d[i] = LLINF;
	d[s] = 0;
	que.push(pii(0, s));
	while (!que.empty()) {
		pii p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		REP(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(pii(d[e.to], e.to));
			}
		}
	}
}

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


	G.resize(MAX);
	d.resize(MAX);

	cin >> N >> M >> S;
	chmin(S, 2450LL);
	int k = 0;
	map<pii, int>mp;
	REP(i, N) {
		eREP(j, 2450) mp[pii(i, j)] = k++;
	}
	REP(i, M) {
		int u, v, a, b; cin >> u >> v >> a >> b;
		u--; v--;
		eFOR(j,a, 2450) {
			G[mp[pii(u, j)]].push_back((edge) { mp[pii(v, j - a)], b });
			G[mp[pii(v, j)]].push_back((edge) { mp[pii(u, j - a)], b });
		}
	}

	REP(i, N) {
		int c, d; cin >> c >> d;
		eREP(j, 2450 - c) {
			G[mp[pii(i, j)]].push_back((edge) { mp[pii(i, j + c)], d });
		}
	}

	dikstra(mp[pii(0, S)]);

	FOR(i, 1, N) {
		int ans = LLINF;
		eREP(j, 2450) chmin(ans, d[mp[pii(i, j)]]);
		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 66364
import sys
readline = sys.stdin.readline
 
INF = 10**30
def calc(k):
    if k in D:
        return D[k]
    if not k:
        return 0
    res = k*d
    if k != k//2 + 1:
        res = min(res, calc(k//2 + 1) + a + d*(2-k%2))
    if k != k//3 + 1:
        res = min(res, calc(k//3 + 1) + b + d*(3-k%3))
    if k != k//5 + 1:
        res = min(res, calc(k//5 + 1) + c + d*(5-k%5))
    
    if k >= 2:
        res = min(res, calc(k//2) + a + d*(k%2))
    if k >= 3:
        res = min(res, calc(k//3) + b + d*(k%3))
    if k >= 5:
        res = min(res, calc(k//5) + c + d*(k%5))
    D[k] = res
    return res
T = int(readline())
Ans = [None]*T
for qu in range(T):
    n, a, b, c, d = map(int, readline().split())
    D = dict()
    Ans[qu] = calc(n)
print('\n'.join(map(str, Ans)))

Measured memory_bytes: 11416
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	LL n, k;
	while(cin >> n >> k) {
		LL sum = (n - k) * n + n * (n - 1) / 2;
		DEBUG(sum);
		if(n * (n - 1) > sum) {
			cout << -1 << endl;
			continue;
		}
		vector<LL> a(n), b(n), c(n);
		REP(i, n) {
			c[i] = k + 2 * n + i;
		}

		LL u = (n * (n - 1) / 2 + n - 1) / n;
		DEBUG(u);
		REP(i, n - (n + 1) % 2) {
			DEBUG(i);
			if(i % 2 == 0) {
				a[i] = k + i / 2;
				DEBUG(k + i);
				DEBUG(u + i);
				b[i] = k + n + u + i / 2;
			} else {
				DEBUG(u + i / 2);
				DEBUG(i / 2);
				a[i] = k + u + 1 + i / 2;
				b[i] = k + n + i / 2;
			}
		}
		if(n % 2 == 0) {
			a[n - 1] = k + n / 2;
			b[n - 1] = k + n + (n - 1) / 2;
		}
		DEBUG(a[0]);
		REP(i, n) {
			cout << a[i] << ' ' << b[i] << ' ' << c[i] << endl;
		}
	}
	return 0;
}


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

int main(){
  int A,B,K;cin>>A>>B>>K;
  int count=0;
  for(int i=100;i>0;i--)
  {
    if(A%i==0&&B%i==0)
    {
      count=count+1;
    }
    if(count==K)
    {
       cout<<i<<endl;
      break;
    }
  }
}
  

Measured memory_bytes: 256
import math

N = int(input())

NList = [0 for i in range(N)]
count = 0
tmp = 0

sqrt_n = int(math.sqrt(N))

for i in range(1, sqrt_n):
    for p in range(1, sqrt_n):
        for q in range(1, sqrt_n):
            if i ** 2 + p ** 2 + q ** 2 + i * p + p * q + i * q > N:
                break
            else:
                NList[i ** 2 + p ** 2 + q ** 2 + i * p + p * q + i * q - 1] += 1
                
for n_count in NList:
    print(n_count)


Measured memory_bytes: 9404
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
vector<vector<int>> G;
const int MN = 100000;
int depth[MN];
int sz[MN];
int par[MN];

void dfs(int v,int p=-1){
	par[v] = p;
	sz[v] = 1;
	for(int u:G[v]) if(u!=p){
		depth[u] = depth[v]+1;
		dfs(u,v);
		sz[v] += sz[u];
	}
}


int main(){
	cin>>N;
	G.resize(N);
	rep(i,N-1){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	dfs(0);
	int D = depth[N-1];
	int up = (D-1)/2;
	int v = N-1;
	rep(i,up) v = par[v];
	int B = sz[v];
	int A = N-sz[v];
	if(A<=B) puts("Snuke");
	else puts("Fennec");
}


Measured memory_bytes: 13184
n=int(input())
s_list=[input() for i in range(n)]
m=int(input())
t_list=[input() for i in range(m)]
l_list=list(set(s_list))
a=max(0,max(s_list.count(l_list[i-1])-t_list.count(l_list[i-1]) for i in range(len(l_list))))
print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 1e9;

int main(){

    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for(int i = 0; i < H; i++){
        cin >> s[i];
    }
    
    vector<vector<int>> cnt(H, vector<int>(W));

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(i == 0 && j == 0){
                if(s[i][j] == '.'){
                    cnt[i][j] = 0;
                }
                else{
                    cnt[i][j] = 1;
                }
                continue;
            }

            int costU, costL;
            if(i == 0){
                costU = INF;
            }
            else{
                if(s[i - 1][j] == s[i][j]){
                    costU = cnt[i - 1][j];
                }
                else{
                    costU = cnt[i - 1][j] + 1;
                }
            }

            if(j == 0){
                costL = INF;
            }
            else{
                if(s[i][j - 1] == s[i][j]){
                    costL = cnt[i][j - 1];
                }
                else{
                    costL = cnt[i][j - 1] + 1;
                }
            }

            cnt[i][j] = min(costU, costL);
        }
    }

    cout << (cnt[H - 1][W - 1] + 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    a, b = LI()
    if a <= b:
        print(a)
    else:
        print(a-1)
    return

#B
def B():
    a, b, c = LI()
    k = II()
    print(a + b + c + max(a, b, c) * ((2 ** k) - 1))
    return

#C
def C():
    H, W = LI()
    s = SR(H)
    for h in range(H):
        for w in range(W):
            if s[h][w] == "#":
                for mh, mw in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
                    hm = mh + h
                    wm = mw + w
                    if 0 <= hm < H and 0 <= wm < W:
                        if s[hm][wm] == "#":
                            break
                else:
                    print("No")
                    return

    print("Yes")
    return

#D
def D():
    n = II()
    ans = []
    sosu = [2]
    i = 2
    while len(ans) != n:
        for k in sosu:
            if i % k == 0:
                i += 1
                break
        else:
            sosu.append(i)
            if i % 5 == 1:
                ans.append(i)
            i += 1
    for i in ans:
        print(i, end=" ")
    print()
    return


#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 40432
unittest
{
	assert( [ "1 21" ].parse.expand.solve == "Yes" );
	assert( [ "100 100" ].parse.expand.solve == "No" );
	assert( [ "12 10" ].parse.expand.solve == "No" );
}



import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split;
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( string a, string b )
{
	return ( ( a ~ b ).to!real.sqrt % 1 == 0 ) ? "Yes" : "No";
}


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

#define LL long long
#define MOD 1000000007

LL factorial(LL n){
	if(n==1) return 1;
	else{
		return (n*factorial(n-1))%MOD;
	}
}

int main(){
	LL n,m;	cin>>n>>m;
	if(abs(n-m)>1) cout<<"0"<<endl;
	else{
		LL ans;
		if(n==m)ans=2;
		else 	ans=1;

		LL a=factorial(n), b=factorial(m);

		ans=(ans*a)%MOD;
		ans=(ans*b)%MOD;

		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define fo(i,a) for(ll i=0;i<a;i++)
#define Fo(i,a,n) for(ll i=a; i<n; i++)
#define u_m unordered_map
#define u_s unordered_set
#define ff first
#define ss second
#define mp make_pair
using namespace std;
ll __pow(ll x, ll y) {ll res = 1;while(y>0){if(y&1) res*=x; y>>=1; x*=x;}return res;}
ll gcd(ll a , ll b){if(b==0) return a;a%=b;return gcd(b,a);}
bool isprime(ll n){for(ll i=2; i*i<=n; i++){if(n%i==0) return 0;}return 1;}
ll n,m,x,y,z,k;
ll dp(ll n){
    if(n<10) return max((ll)1, n);
    else return max((n%10)*dp(n/10), 9*dp(n/10-1));
}
void solve(){
    cin>>n;
    if(n>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int main(){
    ll t=1;
    //cin >> t;
    for(ll i=1; i<=t; i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3628