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

using namespace std;

int n, a, b, c, d;
string s;

int main() {
    cin >> n >> a >> b >> c >> d;
    a--; b--; c--; d--;
    cin >> s;

    if (d > c) {
        for (int i = b; i <= d - 1; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                cout << "No";
                return 0;
            }
        }
        for (int i = a; i <= c - 1; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
    } else {
        int found = 0;
        for (int i = b - 1; i <= min(d - 1, n - 3); i++) {
            if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
                found = 1;
                break;
            }
        }
        if (!found) {
            cout << "No";
            return 0;
        }
        for (int i = a; i <= c - 1; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
    }

    return 0;
}


Measured memory_bytes: 640
def slove():
    import sys
    input = sys.stdin.readline
    ls = list("CODEFESTIVAL2016")
    s = str(input().rstrip('\n'))
    cnt = 0
    for i in range(len(s)):
        if ls[i] != s[i]:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int main() {
    int ans[51] = {0};
    for (int a=0; a<=9; ++a)
        for (int b=0; b<=9; ++b)
            for (int c=0; c<=9; ++c)
                for (int d=0; d<=9; ++d)
                    ans[a + b + c + d] ++;

    int n;
    while (cin >> n) {
        cout << ans[n] << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n,m;
    cin >> n >> m;
    int k;
    cin >> k;
    vector<int> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    ll sum=0;
    int ab=0,bb=0;

    rep(i,n){
        if(sum+a[i]>k) break;
        sum+=a[i];
        ab++;
    }
    rep(i,m){
        if(sum+b[i]>k) break;
        sum+=b[i];
        bb++;
    }   
    int ans=ab+bb;
    // cout << sum << endl;

    while(true){
        if(sum+b[bb]>k){
            if(ab==0) break;
            sum-=a[ab-1];
            ab--;
        }else{
            if(bb==m) break;
            sum+=b[bb];
            bb++;
        }
        ans=max(ans,ab+bb);
        // cout << sum << ' ' << ab+bb << endl;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4788
#include <iostream>
#include <cstdio>

using namespace std;

int r, d, a;

int main()
{
    scanf("%d%d%d", &r, &d, &a);
    for(int i = 0; i < 10; i++)
    {
        a = a * r - d;
        printf("%d\n", a);
    }
    return 0;
}


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

int main() {
  long long X,K,D;
  cin >> X >> K >> D;
  
  if (X < 0){
    X *=-1;
  }
  
  if(X / D > K){
    cout << (X - K * D) << endl;  
  }else{
    K -= (X / D);
    X = X % D;
    if(K % 2 == 0){
      cout << X << endl;  
    }else{
      cout << (D - X) << endl;  
    }
  }
  
  
}


Measured memory_bytes: 3544
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n, a, b;
    cin >> n;
    if(n == 1)
    cout << "Hello World" << endl;
    else {
        cin >> a;
        cin >> b;
        cout << a + b << endl;
    }
    return 0; 
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
#n = ip()                                     #入力整数1つ
#h,w= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
s = set()
for i in range(len(a)):
    s.add(a[i])
s = list(s)
for i in range(len(s)):
    b = a.count(s[i])
    if b%2:j(0)
j(1)

Measured memory_bytes: 22624
#include <cstdio>

#define MAXN 309

int comb[MAXN][MAXN], dp[MAXN][MAXN], s[MAXN][MAXN];

int main() {
    int n, k, mod;
    scanf("%d%d%d", &n, &k, &mod);

    for (int i = 0; i <= n; i++) {
        comb[i][0] = 1;
        for (int j = 1; j <= i; j++)
            comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % mod;
    }

    for (int i = 0; i <= k; i++)
        dp[0][i] = 1;
    for (int i = k; i >= 0; i--)
        s[0][i] = (s[0][i + 1] + dp[0][i]) % mod;

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= k; j++)
            for (int p = 1; p <= i; p++)
                dp[i][j] = (dp[i][j] + 1LL * s[p - 1][j + 1] * comb[i - 1][p - 1] % mod * dp[i - p][j]) % mod;
        for (int j = k; j >= 0; j--)
            s[i][j] = (dp[i][j] + s[i][j + 1]) % mod;
    }

    printf("%d\n", dp[n][0]);

    return 0;
}


Measured memory_bytes: 1280
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

constexpr int INF = 1e8;
typedef pair<int, int> PII;

int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

int main() {

    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S[i];

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == 'B') {
                for (int k = 0; k < H; k++) {
                    for (int l = 0; l < W; l++) {
                        if (S[k][l] == 'B') {
                            ans = max(ans, abs(i - k) + abs(j - l));
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;

}


































Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    string n; cin >> n;
    int nlen = n.length();
    int now = 0;
    for(int i = 0; i < nlen; ++i) {
        now += (n[i]-'0');
        now %= 9;
    }
    if(now == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int bignumber(int a, int b){
    if(a>b){
        return(a);
    } else {
        return(b);
    }
}

int smallnumnber(int a, int b){
    if(a<b){
        return(a);
    } else {
        return(b);
    }
}

int greatestcommondivisor(int a,int b){
    int m,n,gcdans;
    m=bignumber(a,b);
    n=smallnumnber(a,b);
    if(n==0){
        gcdans=m;
    } else {
        gcdans=greatestcommondivisor(n,m%n);
    }
    return (gcdans) ;
}

int main(void){
    int n,k,max=0,gcd;
    scanf("%d%d",&n,&k);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if(max<a[i]){
            max=a[i];
        }
        if (i==0){
            gcd=a[i];
        } else {
            gcd=greatestcommondivisor(gcd,a[i]);
        }
    }
    if (k<=max && k%gcd==0){
        printf("POSSIBLE\n");
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<queue>
#define f first
#define s second
using namespace std;
//        N E S W
int X[4]={0,1,0,-1};
int Y[4]={-1,0,1,0};
int H,W,dis[100][100],si,sj,smuki;
char map[100][100];
long long L,memo[100][100][4];
  
int M(char c){
  if(c=='N')return 0;
  if(c=='E')return 1;
  if(c=='S')return 2;
  if(c=='W')return 3;
}

char N(int a){
  if(a==0)return 'N';
  if(a==1)return 'E';
  if(a==2)return 'S';
  if(a==3)return 'W';
}
bool in(int y,int x){
  if(y<0 || x<0 || y>=H || x>=W)return false;
  return true;
}

int main()
{
  while(1){
    cin>>H>>W>>L;
    if(H==0 &&W==0 &&L==0)break;
    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
	dis[i][j]=0;
	for(int k=0;k<4;k++)memo[i][j][k]=0;
      }
    }
    queue<pair<int,pair<int,int> > > Q;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>map[i][j];
	if(map[i][j]!='.' && map[i][j]!='#'){
	  si=i;
	  sj=j;
	  smuki=M(map[i][j]);
	  map[i][j]='.';
	}
      }
    }
    pair<int,pair<int,int> > u;
    Q.push(make_pair(smuki,make_pair(si,sj)));
    while(L>=0){
      u=Q.front();
      Q.pop();
      //cout<<u.s.f<<" "<<u.s.s<<" "<<u.f<<endl;
      for(int k=0;k<4;k++){
        int mk=(u.f+k)%4;
	int a=u.s.f+Y[mk],b=u.s.s+X[mk];
	if(!in(a,b))continue;
	if(map[a][b]=='.'){
	  L--;
	  if(memo[a][b][mk]==0)memo[a][b][mk]=L;
	  else L=L%(memo[a][b][mk]-L);
	  Q.push(make_pair(mk,make_pair(a,b)));
	  break;
	}
      }
    }
    cout<<u.s.f+1<<" "<<u.s.s+1<<" "<<N(u.f)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1588
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, X;
	cin >> N >> X;
	vector<int> m(N);
	REP(i, N) cin >> m[i];
	
	sort(ALL(m));
	int sum = accumulate(ALL(m), 0);
	X -= sum;
	cout << N + X / m[0] << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
string s0;
int ans;
queue<string>que;
stack<string>sta;
int d(string s,int al) {
    if (al == 25) { 
		que.push(s);
		ans++;
        //cout<<"push"<<endl;
		return 0; }
	for (unsigned int i = 0; i <s.size() ;i++) {
        //cout<<s[i]<<"   "<<char('z' - al-1)<<endl;
		if (s[i] == 'z' - al-1) {
			s[i] = 'z' - al ; 
            //cout<<a[k-1]<<endl;
			d(s, al + 1);
            s[i]='z' - al-1;
		}
		if (s[i] == 'z' - al ) return 0;	
	}
	d(s, al + 1);
    return 0;
}
int main() {
	while (1) {
		cin >> s0;
		if (s0 == "#")return 0;
		ans = 0;
        //cout<<s0<<endl;
		d(s0, 0);

		if (ans < 11) {
			string w[10];
			for (int i = 0; i < ans; i++) {
				w[i] = que.front();
				que.pop();
			}
			sort(w, w + ans);
			cout << ans << endl;
			for (int i = 0; i < ans; i++)
				cout << w[i] << endl;
		}
		else {
			string f[5], e[5];
			for (int i = 0; i < 5; i++) {
				f[i] = que.front();
				que.pop();
				e[i] = que.front();
				que.pop();
			}
			while (1) {
				if (que.empty())break;
				for (int i = 0; i < 5; i++) {
					if (f[i] > que.front()) {
						que.push(f[i]);
						f[i] = que.front();
						break;
					}
					if (e[i] < que.front()) {
						que.push(e[i]);
						e[i] = que.front();
						break;
					}
				}
				que.pop();
			}
			sort(f, f + 5);
			sort(e, e + 5);
			cout << ans << endl;
			for (int i = 0; i < 5; i++)
				cout << f[i] << endl;
			for (int i = 0; i < 5; i++)
				cout << e[i]<<endl;
		}
	}
}


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

int main() {
	int s, k; cin >> k >> s;
	long long ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - (x + y);
			if (z >= 0 && z <= k) ans++;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3604
#include<iostream>
#include<stdio.h>
using namespace std;

static const int MAX = 15;

int n;
int M[MAX][MAX];

void magic(int y,int x, int tmp){
	if (tmp > (n * n)) {
		return;
	}
	if (x < 0) {
		magic(y, n-1 , tmp);
	}
	else if (x >= n) {
		magic(y, 0, tmp);
	}
	else if (y >= n) {
		magic(0, x, tmp);
	}
	else if (M[y][x] != -1) {
		magic(y+1, x-1, tmp);
	}
	else {
		M[y][x] = tmp;
		magic(y + 1, x + 1, tmp + 1);
	}

}

int main() {
	while (true) {
		cin >> n;
		if (n == 0) {
			break;
		}
		for (int i = 0; i < MAX; i++) {
			for (int j = 0; j < MAX; j++) {
				M[i][j] = -1;
			}
		}
		M[(n - 1) / 2+1][(n - 1) / 2]=1;
		magic((n - 1) / 2+2 , (n - 1) / 2 + 1, 2);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				printf("%4d", M[i][j]);
			}
			printf("\n");
		}
	}
}


Measured memory_bytes: 3160
S = input()
N = len(S)
S_1 = S[0:int((N - 1)/2)]
S_2 = S[int((N + 3)/2) - 1:N + 1]

ans = "No"
if S == S[::-1] and S_1 == S_1[::-1] and S_2 == S_2[::-1]:
    ans = "Yes"

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

int dp[200010][2];
string S;

int Solve(){
    int Len=S.size();
    S=" "+S;
    dp[1][0]=1;
    for(register int i=2;i<=Len;++i){
        dp[i][0]=dp[i-1][1]+1;
        if(S[i-1]!=S[i]) dp[i][0]=max(dp[i][0],dp[i-1][0]+1);
        dp[i][1]=dp[i-2][0]+1;
        if(!(S[i-3]==S[i-1] && S[i-2]==S[i])) dp[i][1]=max(dp[i-2][0]+1,dp[i-2][1]+1);
    }
    return max(dp[Len][0],dp[Len][1]);
}

int main(){
    cin>>S;
    cout<<Solve()<<endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;
int n;
int B[M],A[M],sum;//A[i] ==> (B[i]+B[i+1])/2

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d",&A[i]);
		sum+=A[i];
		if(i>1) B[i]=A[i]+B[i-2];
		else B[i]=A[i];
	}
	for(int i=1; i<=n; i++){
		int res=sum;
		if(i&1){
			res-=(B[i-2]+B[n-1]-B[i-1])*2;
//			for(int j=1; j<=i-2; j+=2){
//				if(j==i) continue;
//				res-=A[j]*2;
//			}
//			for(int j=i+1; j<=n; j+=2){
//				if(j==i) continue;
//				res-=A[j]*2;
//			}
//			if(i==1) res+=A[n]*2;
		}else{
			res-=(B[i-2]+B[n]-B[i-1])*2;
//			for(int j=2; j<=i-1; j+=2){
//				if(j==i) continue;
//				res-=A[j]*2;
//			}
//			for(int j=i+1; j<=n; j+=2){
//				if(j==i) continue;
//				res-=A[j]*2;
//			}
//			if(i==1) res+=A[n]*2;
		}
		printf("%d ",res);
	}
//	for(int i=1; i<=n; i++) printf("%d ",B[i]);
	return 0;
}

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

#define BR "\n"
#define SP " "

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) {
    cout << "a > b" << BR;
  } else if (a < b) {
    cout << "a < b" << BR;
  } else {
    cout << "a == b" << BR;
  }

  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,A,B;
  cin>>n>>A>>B;
  string s;
  cin>>s;
  int as=0,bs=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='a'&&as+bs<A+B){
      cout<<"Yes"<<endl;
      as++;
    }
    else if(s.at(i)=='b'&&as+bs<A+B&&bs<B){
      cout<<"Yes"<<endl;
      bs++;
    }
    else{
      cout<<"No"<<endl;
    }
  }

}

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


int main(){
	int N;
	cin >> N;
	LL ans = 1;
	for(int i = 1; i <= N; ++i){
	   ans = (ans * i) % 1000000007;
    }
	cout << ans << endl;	

}	













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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n;
  	ci(n)
  vll A(n);
  ll ans=0;
  FOR(i,0,n){
	ci(A[i])
      FOR(j,0,30){
      	if(A[i]%2==0){
          A[i]/=2;
          ans+=1;
        }
        else{
          A[i]=ans;
          ans=0;
          break;          
        }
    }
  }
  SORT(A);
  co(A[0])
    
  }

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
      String[] t=sc.nextLine().split("");
//    String nyuA=sc.nextLine();
//   String nyu=sc.nextLine();

//int n=Integer.parseInt(nyu);

//int A=Integer.parseInt(t[0]);
//int B=Integer.parseInt(t[1]);
String tem="";
for(int i=0;i<t.length;i++){
switch(t[i]){
case "0":
tem+="0";
break;
case "1":
tem+="1";
break;
case "B":
String[] te=tem.split("");
tem="";
for(int j=0;j<te.length-1;j++){
tem+=te[j];
}
break;
default:
break;

}//sw

}//for

System.out.println(tem);


	}
}

Measured memory_bytes: 21460
#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 H,W;
string s[50];
int dx[8]={0,1,1,1,0,-1,-1,-1};
int dy[8]={1,1,0,-1,-1,0,-1,1};
int main(){
	cin>>H>>W;
	rep(i,H) cin>>s[i];
	rep(i,H) rep(j,W) if(s[i][j]=='.'){
		int c = 0;
		rep(d,8){
			int ni = i+dx[d], nj = j+dy[d];
			if(0<=ni&&ni<H&&0<=nj&&nj<W&&s[ni][nj]=='#') c++;
		}
		s[i][j] = '0'+c;
	}
	rep(i,H) cout<<s[i]<<endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn num_to_array(mut n: u64) -> Vec<u64> {
    let mut v = Vec::new();
    let d = 10;
    while n != 0 {
        v.push(n % d);
        n /= d;
    }
    v.reverse();
    v
}

fn main() {
    input! {
        a: u64,
        b: u64,
    }
    let n = (a..b+1).fold(0, |acc,x| {
        let a1 = num_to_array(x);
        let mut a2 = a1.clone();
        a2.reverse();
        if a1 == a2 { acc+1 } else { acc }
    });
    println!("{}", n);
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int f(int n) {
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cnt += (n % i == 0);
  }
  return cnt;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      cnt += (f(i) == 8) && i % 2 == 1;
    }
    cout << cnt << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
s =[input() for i in range(H)]
t = ["."*(W+2)]
for i in range(H):
    t.append("."+s[i]+".")
t.append("."*(W+2))
flag = 0
for i in range(1,H+1):
    for j in range(1,W+1):
        if t[i][j] == "#" and t[i][j+1] == "." and t[i][j-1] == "." and t[i-1][j] == "." and t[i+1][j] == ".":
            flag = 1
            break
    else:
        continue
    break
if flag == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include "stdio.h"
int main ()
{
	int r,g,b,n;
	scanf ("%d %d %d %d",&r,&g,&b,&n);
	int i=0;
	for (int j=0;j<=n/r;j++)
	  for (int x=0;x<=n/g;x++)
	    { 
	      if (n-j*r-x*g>=0&&(n-j*r-x*g)%b==0)
	        i++;
		}
		
	printf ("%d",i);
	
	return 0;
}

Measured memory_bytes: 128
S = input()
flag = False
if (len(S) < 4):
  flag = False
else:
  if (S[0] == 'Y' and S[1] == 'A' and S[2] == 'K' and S[3] == 'I'):
    flag = True
  
if flag:
  print('Yes')
else:
  print('No')

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

int main() {
  int n;
  cin >> n;
  int t = 3 * n;
  vector<int> a(t);
  for (int i = 0; i < t; i++) {
    cin >> a.at(i);
  }
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a.at(2 * i + 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
import Control.Monad
import Data.Array.Unboxed

main :: IO ()
main = do
  [n,q] <- map read . words <$> getLine
  s <- getLine
  lrs <- replicateM q $ (\[x,y] -> (x,y)) . map read . words <$> getLine :: IO [(Int,Int)]
  let acs = listArray (0,n-1) $ 0 : neighbour s 0 :: UArray Int Int
  forM_ lrs $ \(l,r) -> print $ acs!(r-1) - acs!(l-1)

neighbour :: String -> Int -> [Int]
neighbour [] _ = []
neighbour [_] _ = []
neighbour (x:y:xs) acc
  | [x,y] == "AC" = (acc + 1) : neighbour (y:xs) (acc + 1)
  | otherwise     = acc       : neighbour (y:xs) acc


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

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int c[4] = { 0 };
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s == "AC")
        {
            c[0]++;
        }
        else if (s == "WA")
        {
            c[1]++;
        }
        else if (s == "TLE")
        {
            c[2]++;
        }
        else if (s == "RE")
        {
            c[3]++;
        }
    }
    cout << "AC x " << c[0] << '\n';
    cout << "WA x " << c[1] << '\n';
    cout << "TLE x " << c[2] << '\n';
    cout << "RE x " << c[3] << '\n';
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int house[5][4][11]={{{0}}};
int main(void){
    int n,b,f,r,v;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        house[b][f][r]=house[b][f][r]+v;
    }
    
    for(int i=1;i<=4;i++){
        
        for(int j=1;j<=3;j++){
            for(int k=1;k<=10;k++){
                cout << ' ' << house[i][j][k];
            }
            cout << endl;
        }
        
        if(i == 4){
            
        }
        else{
            for(int j=0;j<20;j++){
             cout << "#";   
            }
            cout << endl;
        }
        
    }
}


Measured memory_bytes: 3080
VS = [(Y, Y*(2//q), q) for Y, q in zip(map(int, input().split()), (0.25, 0.5, 1, 2))]
N = int(input())
#print(VS)
tanka = 0
for Y, _, q in sorted(VS, key=lambda x:x[1], reverse=False):
  u = N // q
  N -= q * u
  #print((q, u))
  tanka += Y * int(u)
  if N <= 0:
    break
 
print(tanka)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

int main()
{
    int N, M, K;
    cin>>N>>M>>K;
    vector<int> P(N), T(N);
    for (int i=0; i<N; i++)
        P[i] = i,
        T[i] = -1;

    function<int(int)> f = [&](int x)
    {
        if (P[x]==x)
            return x;
        else
            return P[x] = f(P[x]);
    };

    for (int k=0; k<K; k++)
    {
        int type;
        cin>>type;
        if (type == 1)
        {
            int a, b;
            cin>>a>>b;
            a--, b--;
            int ra = f(a);
            int rb = f(b);
            if (T[ra]!=-1 && T[rb]!=-1 && T[ra]!=T[rb])
            {
                cout<<k+1<<endl;
                return 0;
            }
            if (ra != rb)
            {
                P[ra] = rb;
                if (T[rb] == -1)
                    T[rb] = T[ra];
            }
        }
        else
        {
            int c, x;
            cin>>c>>x;
            c--, x--;
            int rc = f(c);
            if (T[rc] != -1 && T[rc] != x)
            {
                cout<<k+1<<endl;
                return 0;
            }
            T[rc] = x;
        }

//        cout<<"P";
//        for (int p: P)
//            cout<<" "<<p;
//        cout<<endl;
//        cout<<"T";
//        for (int t: T)
//            cout<<" "<<t;
//        cout<<endl;
    }
    cout<<0<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N){
  ll ans = 0;
  for (int i = 1; i < N; i++) {
    if(i != N-i)ans++;
  }
  cout << ans/2 << endl;
}

// 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)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int mult(int x, int y) {
	return 1ll * x * y % mod;
}
int add(int x, int y) {
	x += y;
	if (x >= mod) {
		return x - mod;
	}
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) {
		return x + mod;
	}
	return x;
}
void add_self(int& x, int y) {
	x = add(x, y);
}
int bin_pow(int x, int y) {
	if (y == 0) {
		return 1;
	}
	if (y % 2 == 0) {
		return bin_pow(mult(x, x), y / 2);
	}
	return mult(x, bin_pow(x, y - 1));
}
int inv(int x) {
	return bin_pow(x, mod - 2);
}
const int maxn = 4e6 + 5;
vector<int> fact(maxn), inv_fact(maxn);
int C(int x, int y) {
	assert(x >= y);
	return mult(fact[x], mult(inv_fact[y], inv_fact[x - y]));
}
int solve_function(int k, int n) {
	return C(k + n + 1, k + 1);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	fact[0] = 1;
	for (int i = 1; i < maxn; ++i) {
		fact[i] = mult(fact[i - 1], i);
	}
	for (int i = 0; i < maxn; ++i) {
		inv_fact[i] = inv(fact[i]);
	}
	int r1, r2, c1, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	int answer = 0;
	for (int i = r1; i <= r2; ++i) {
		int x2 = solve_function(i, c2);
		int x1 = solve_function(i, c1 - 1);
		add_self(answer, sub(x2, x1));
	}
	cout << answer << '\n';
	//~ int answer2 = 0;
	//~ for (int i = r1; i <= r2; ++i) {
		//~ for (int j = c1; j <= c2; ++j) {
			//~ add_self(answer2, C(i + j, i));
		//~ }
	//~ }
	//~ cout << answer2 << '\n';
 	return 0;
}


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

const long K[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
	long k;
	cin>>k;
	cout<<K[k]<<endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.List
import Data.Char

main :: IO()
main = do
	[a,b,c] <- (map(read::String->Int) . words) <$> getLine
	let s = sort [a,b,c]
	putStrLn $ (show (s!!0)) ++ " " ++ (show (s!!1)) ++ " " ++ (show (s!!2))

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    VVI dp(n + 1, VI(m + 1, 0));
    vector<VP> prev(n + 1, VP(m + 1));
    FOR(i, 1, n)FOR(j, 1, m) {
        vector<pair<int, P>> candidate;
        if(s[i - 1] == t[j - 1])
            candidate.push_back(make_pair(dp[i - 1][j - 1] + 1, P(i - 1, j - 1)));
        else
            candidate.push_back(make_pair(dp[i - 1][j - 1], P(i - 1, j - 1)));
        candidate.push_back(make_pair(dp[i - 1][j], P(i - 1, j)));
        candidate.push_back(make_pair(dp[i][j - 1], P(i, j - 1)));
        sort(ALL(candidate));
        dp[i][j] = candidate.back().first;
        prev[i][j] = candidate.back().second;
    }
    cerr << dp[n][m] << ln;
    
    string ans;
    P next_p = P(n, m);
    int cnt = dp[next_p.first][next_p.second];
    do {
        cerr << next_p.first << " " << next_p.second << ln;
        int i = next_p.first;
        next_p = prev[next_p.first][next_p.second];
        if(cnt > dp[next_p.first][next_p.second]) ans += s[i - 1];
        cnt = dp[next_p.first][next_p.second];
    } while(dp[next_p.first][next_p.second] > 0);
    reverse(ALL(ans));
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 105984
#dp[i][j]:iまでで価値jになるようにするときの品物の重さ
#答えはdp[N]をjが大きいものから見ていってWより小さいもの

INF = 10**15

N,W = map(int,input().split())
w = []
v = []
for i in range(N):
    tmpW,tmpV = map(int,input().split())
    w.append(tmpW)
    v.append(tmpV)

dp = [[INF]*(100*1000+1) for i in range(N)]
dp[0][0]=0
dp[0][v[0]]=w[0]

for i in range(1,N,1):
    for j in range(0,100*1000+1,1):
        dp[i][j] = min(dp[i-1][j],dp[i][j])
        if j - v[i]>=0:
            dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]]+w[i])

for j in range(100*1000,-1,-1):
    if dp[N-1][j] <= W:
        print(j)
        exit()

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int g = A[0];
    for (int i = 1; i < N; i++) {
        g = __gcd(g, A[i]);
    }
    cout << g << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int N;
  cin >> N;
  int a[N];
  FOR(i,0,N-1) cin >> a[i];
  int ans = 1;

  FOR(i,1,N-1){
    int ref = i-1;
    bool view = true;
    while(ref>=0){
      if(a[i]<a[ref]) view = false;
      ref--;
    }
    if(view==true) ++ans;
  }

  cout << ans << endl;


}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    ll count = 0;
    for(int x = min(a, b); x >= 1; --x){
        if(a % x == 0 && b % x == 0){
            count += 1;
            if(count == k){
                cout << x << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [0 for i in range(n)]
counter = 0
for i in range(n):
    s[i] = int(input())
    counter += s[i]
# 全探査だとO(2^100)となり不適
# 全問正解した場合から,
# 得点が10の倍数でない1問を取り除く
s = sorted(s)
if counter % 10 != 0:
    print(counter)
    exit()
else:
    for i in range(n):
        if (counter - s[i]) % 10 != 0:
            print(counter - s[i])
            exit()
print(0)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  bool ok=true;
  for(int i=0;i<N;i++){
    if(a[i]%2==0){
      if(a[i]%3==0){}
      else if(a[i]%5==0){}
      else ok=false;
    }
  }
  if(ok)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
  return 0;
}


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

using ll = long long;

const int mod = 1e9 + 7;

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

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<int>> can(n, vector<int>(n));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            scanf("%d", &can[i][j]);
        }
    }
    vector<int> dp(1 << n); // 2^n
    dp[0] = 1;
    //~ for(int a = 0; a < n; ++a) {
    for(int mask = 0; mask < (1 << n) - 1; ++mask) {
        int a = __builtin_popcount(mask); // the number of bits set to 1
        for(int b = 0; b < n; ++b) {
            if(can[a][b] && !(mask & (1 << b))) {
                int m2 = mask ^ (1 << b);
                //~ debug() << imie(mask) imie(m2) imie(dp[mask]);
                add_self(dp[m2], dp[mask]);
            }
        }
    }
    //~ }
    printf("%d\n", dp[(1<<n)-1]);
}

Measured memory_bytes: 11432
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)

res = 0
for k in range(2):
    b = [0, 24]
    tmp = 10 ** 10
    for i, j in enumerate(a):
        if i % 2 == k:
            b.append(24 - j)
        else:
            b.append(j)
    b = sorted(b)
    for i, j in zip(b, b[1:]):
        tmp = min(tmp, j - i)
    res = max(res, tmp)
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
int main(){
    ll N;
    cin>>N;
    
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    
    ll min=1000000000001;
    //<<min;
    REP(i,ret.size()/2+1){
        ll t=ret[i-1]+ret[ret.size()-i]-2;
        //sl(ret[i-1],ret[ret.size()-i],t);
        min=t<min?t:min;
    }
    cout<<min;
    
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int x;cin>>x;
  if(x >= 30)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3648
from collections import deque

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
prev = [-1] * n
visited = [False] * n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

def bfs(v):
    q = deque()
    visited[v] = True
    q.append(v)
    while q:
        v = q.popleft()
        for child in edges[v]:
            if not visited[child]:
                visited[child] = True
                prev[child] = v
                q.append(child)

bfs(0)
print("Yes")
for i in range(1, n):
    print(prev[i] + 1)


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

int main(){
  int N;
  cin >> N;
  int d[N];
  for(int i=0;i<N;i++) cin >> d[i];
  sort(d,d+N);
  cout << (d[N/2]-d[N/2-1]) << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

#define N 100000

int main() {
	static int aa[N];
	int n, i, x;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	x = abs(aa[0]);
	for (i = 1; i < n; i++)
		x += abs(aa[i] - aa[i - 1]);
	x += abs(aa[n - 1]);
	for (i = 0; i < n; i++)
		printf("%d\n", x - abs(aa[i] - aa[i - 1]) - abs(aa[i] - aa[i + 1]) + abs(aa[i + 1] - aa[i - 1]));
	return 0;
}


Measured memory_bytes: 1536
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

def lcmm(*args):
    return reduce(lcm, args)

N = int(input())
T = [0] * N
syuki = 0
for i in range(N):
    T[i] = int(input())
syuki = lcmm(*T)
print(syuki)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
int dp[301][301][301];
vector<pi> con[301];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m; cin >> n >> m;
	rep(i, m){
		int l, r, x; cin >> l >> r >> x;
		con[r].emplace_back(l, x);
	}
	dp[0][0][0] = 1;
	for(int k = 1; k <= n; k++){
		rep(i, k) rep(j, i + 1) if(dp[k - 1][i][j]) rep(l, 3){
			vi nxt = {k - 1, i, j};
			nxt[l] = k;
			sort(all(nxt), greater<int>());
			
			(dp[nxt[0]][nxt[1]][nxt[2]] += dp[k - 1][i][j]) %= mod;
			//if(0)
			for(auto q : con[k]){
				int left = q.first;
				int cnt = (nxt[0] >= left) + (nxt[1] >= left) + (nxt[2] >= left);
				if(cnt != q.second){
					dp[nxt[0]][nxt[1]][nxt[2]] = 0;
					break;
				}
			}
		}
	}
	ll ans = 0;
	rep(i, n) rep(j, n) ans += dp[n][i][j] + dp[i][n][j] + dp[i][j][n];
	cout << ans % mod << endl;
	
	return 0;
}

Measured memory_bytes: 104832
#include<bits/stdc++.h>
using namespace std;
int n,m,k,a[100005],b[100005],ans;
int main(){
	cin>>n>>m>>k;
	int aa=100001,bb=100001;
	for(int i=1;i<=n;i++)cin>>a[i],aa=min(aa,a[i]);
	for(int i=1;i<=m;i++)cin>>b[i],bb=min(bb,b[i]);
	ans=aa+bb;
	for(int i=1;i<=k;i++){
		int x,y,z;
		cin>>x>>y>>z;
		ans=min(ans,a[x]+b[y]-z);
	}
	cout<<ans;
}


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

using namespace std;
map <string ,int> mp;
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    int mx=-1;
    //string s;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
     if(it->second>mx)
     {
         mx=it->second;
        // s=it->first;
     }

    }
    set<string >st;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        if(it->second==mx)
        {
            st.insert(it->first);
        }
    }
    for(auto v:st)
        cout<<v<<endl;


}


Measured memory_bytes: 34560