akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(){
    char str[150];
    scanf("%s", str);
    int n = strlen(str);
    for(int i = 0; i < n; i++){
        if((i & 1) && str[i] == 'R'){
        	printf("No\n");
        	return 0;
        }
        if(!(i & 1) && str[i] == 'L'){
        	printf("No\n");
        	return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
def get_prime_factorized(N):
    R = []
    b, e = 2, 0
    while b ** 2 <= N:
        while N % b == 0:
            N  = N // b
            e += 1
        if e > 0:
            R.append([b, e])
        b, e = b + 1, 0
    if N > 1:
        R.append([N, 1])
    return R


N = int(input())
H = {}
R = 1

for n in range(1, N+1):
    for l in get_prime_factorized(n):
        k, c = l
        if k in H.keys():
            H[k] += c
        else:
            H[k]  = c

for k in H.keys():
    R *= (H[k]+1)
    R %= 10**9+7

print(R)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define BUFF 256
int main(){
  int Stack[100],last=0;
  char moji[BUFF],operator[3][5]={{"+"},{"-"},{"*"}};

  while(1){
    if(scanf("%s",moji) == EOF)break;
    
    if(strstr(moji,operator[0])!=NULL){
      Stack[last - 2]=Stack[last - 2] + Stack[last - 1];
      last-=1;
    }
    else if(strstr(moji,operator[1])!=NULL){
    
      Stack[last - 2]=Stack[last - 2] - Stack[last - 1];
      last-=1;
    }
    else if(strstr(moji,operator[2])!=NULL){
      Stack[last - 2]=Stack[last - 2] * Stack[last - 1];
      last-=1;
    }
    else{
      Stack[last]=atoi(moji);
      last++;
    }
  }
  printf("%d\n",Stack[0]);
  return 0;
}


Measured memory_bytes: 2084
#include<stdio.h>

long long juk(long long a,long long b){
	if(a%b==0)return b;
	return juk(b,a%b);
}

int main(){
	int n,i;
	long long t[100],ans=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%lld",&t[i]);
	for(i=0;i<n;i++){
		ans=t[i]/juk(t[i],ans)*ans;
		//printf("%lld\n",ans);
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
  int n,x;
  cin >> n;
  x =0;
  if(n%111 == 0){
    cout << n << endl;
  }
  else {
    for(int i =0 ; i <10 ; i++){
      if(111*i < n){
        x++;
      }
    }
    cout << 111*x << endl;
  }
}


Measured memory_bytes: 256
N,D=map(int,input().split())
L=[]
hei=[i**2 for i in range(200)]

for i in range(N):
  l=list(map(int,input().split()))
  L.append(l)
ans=0
for i in range(N):
  for j in range(i+1,N):
    if sum((L[i][k]-L[j][k])**2 for k in range(D)) in hei:
      ans+=1
print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e9

int main()
{
	ll n, k;
	cin >> n >> k;
	ll ans = 0;

	REP(i, k + 1, n + 1) {
		ans += (n / i) * (i - k);
		ans += max((ll)0, (n % i) - k + 1);
	}
	cout << (k == 0 ? (n * n):ans) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e10)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T 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);
			}
		}
	}
	return ret;
}

int N,M;


int main()
{
  cin>>N>>M;

  int ans=0;
  int nu[N];
  bool red[N];
  REP(i,0,N){
    nu[i]=1;
    red[i]=false;
  }
  red[0]=true;
  REP(i,0,M){
    int x,y;
    cin>>x>>y;
    x--;y--;
    if(red[x]){
      red[y]=true;
    }


    nu[x]-=1;
    nu[y]+=1;
    if(nu[x]==0){
      red[x]=false;
    }
  }

  REP(i,0,N){
    if(red[i]){
      ans++;
    }
  }
  

  cout<<ans<<endl;



  return 0;
}

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

using namespace std;

int main() {
    
    int a;
    cin >> a;
    
    int b = a/3;

    if(a < 3){
      cout << 0 << endl;
    }else{
      
       cout << b << endl;
      
    }
    
 
     return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int n;

unsigned long long func(vector<long long int>& s, vector<int>& hugo, long long int k){
  unsigned long long int ret = 0;
  for(int i = 1; i < n; i++){
    if(s[i] == k){
      if(hugo[i - 1] == 0){
        hugo[i] = 1;
        ret++;
        k++;
      }
      else{
        hugo[i] = 0;
        ret++;
        k--;
      }
    }
    else if(s[i] > k){
      if(hugo[i - 1] == 0){
        hugo[i] = 1;
        ret += s[i] - k + 1;
        k += s[i] - k + 1;
      }
      else{
        hugo[i] = 0;
      }
    }
    else{
      if(hugo[i - 1] == 0){
        hugo[i] = 1;
      }
      else{
        hugo[i] = 0;
        ret += k - s[i] + 1;
        k -= k - s[i] + 1;
      }
    }
  }
  return ret;
}

void solve(){
  cin >> n;
  vector<long long int> v(n), sum(n), sum2(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
    if(i == 0) sum[i] = v[i];
    else sum[i] = sum[i - 1] + v[i];
  }
  vector<int> hugo(n), hugo2(n);
  sum2 = sum;
  unsigned long long int ans;
  long long int k = 0;

  if(sum[0] == 0){
    hugo[0] = 0;
    hugo2[0] = 1;
    ans = min(func(sum, hugo, -1), func(sum2, hugo2, 1)) + 1;
  }
  else if(sum[0] > 0){
    hugo[0] = 0;
    hugo2[0] = 1;
    ans = min(func(sum, hugo, 0), func(sum2, hugo2, sum2[0] + 1) + sum2[0] + 1);
  }
  else{
    hugo[0] = 1;
    hugo2[0] = 0;
    ans = min(func(sum, hugo, 0), func(sum2, hugo2, sum2[0] - 1) - sum2[0] + 1);
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())
W = []
for _ in range(N) :
  W.append(str(input()))
#print (W)

wl = []
for i in range(N) :
  if W[i] not in wl :
    wl.append(W[i])
  else :
    print ("No")
    exit()
  if i > 0 :
    if W[i-1][-1] != W[i][0] :
      print ("No")
      exit()
print ("Yes")
  


Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cassert>
#include<vector>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const long long inf = 1145141919810000;
typedef pair<int, int> P;

int x[114514];

signed main() {
	int n, k; cin >> n >> k;
	rep(i, n)cin >> x[i];
	int ans = inf;
	sort(x, x + n);
	for (int i = 0; i < n-k+1; i++) {
		int l = x[i], r = x[i + k - 1];
		if (l >= 0 && r >= 0)ans = min(ans, r);
		else if (l <= 0 && r <= 0)ans = min(ans, abs(l));
		else ans = min(ans, 2 * abs(min(abs(l), abs(r))) + abs(max(abs(l), abs(r))));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
char x[100001];int a,b;
int main(void)
{
    gets(x);
    for(int i=0;i<strlen(x);i++)
    {
    	if(x[i]=='C')a=1;
    	if(x[i]=='F'&&a==1)b=1;
    }
    if(a==1&&b==1)printf("Yes");
    else printf("No");
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n;
	cin >> n;

	vector<ll> a(n);
	for (auto &v : a) {
		cin >> v;
	}

	ll rainSum = accumulate(begin(a), end(a), 0LL);

	ll tmp = 0;
	for (int i = 1; i < n; i += 2) {
		tmp += a[i];
	}

	vector<ll> dp(n);
	dp[0] = rainSum - 2LL * tmp;
	for (int i = 1; i < n; i++) {
		dp[i] = 2LL * a[i - 1] - dp[i - 1];
	}

	for (int i = 0; i < (int)dp.size(); i++) {
		if (i) cout << " ";
		cout << dp[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    for(int i=1; i<=100; ++i){
        if(A*i%B==C){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

using namespace std;

int main()
{
	int n; 
  	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++)
	cin >> arr[i];

	int count=0;

	for(int i = 0; i < n;) {
		int j = i;
		while(arr[j] == arr[i] && j < n) {
			j++;
		}
		count += (j - i) / 2;
		i = j;
	}
	cout<<count;
  return 0;
}


Measured memory_bytes: 3596
N, M = map(int, input().split())

A = sorted(list(map(int, input().split())), reverse=True)

B = []
for i in range(M):
    b, c = map(int, input().split())
    B.append([b, c])

B.sort(key=lambda x:(-x[1]))

cnt = 0
ans = 0
a = 0
b = 0
while True:
    if b <= M-1 and A[a] <= B[b][1]:
        n = min(B[b][0], N-cnt)
        ans += B[b][1]*n
        cnt += n
        if cnt == N:
            print(ans)
            break
        b += 1
    elif a <= N-1:
        cnt += 1
        ans += A[a]
        if cnt == N:
            print(ans)
            break
        a += 1

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

int main(){
    int A, B, X;
    cin >> A >> B >> X;

    if(X-A<0){
        cout << "NO" << endl;
    }
    else if(X-A <= B){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std; 
#define MAXA 100000000
#define MAXB 100000000
#define MAXC 100000000
#define MAXD 100000000
#define MAXN 50
#define MAXM 50
int main(int argc,char const* argv[])
{
  string s,t;
  int sizes,sizet;
  string S,T;
  cin >> s >> t;
  sizes=s.size();
  sizet=t.size();
  vector<char> sbox(sizes,'?');
  vector<char> tbox(sizet,'?');
  for(int i=0;i<sizes;i++)
    {
      sbox[i]=s[i];
    }
   for(int i=0;i<sizet;i++)
    {
      tbox[i]=t[i];
    }
   sort(sbox.begin(),sbox.end());
   sort(tbox.begin(),tbox.end());
   reverse(tbox.begin(),tbox.end());
   string ss(sizes,'a');
   string tt(sizet,'a');
   for(int i=0;i<sizes;i++)
     {
       ss[i]=sbox[i];
     }
   for(int i=0;i<sizet;i++)
     {
       tt[i]=tbox[i];
     }
   if(tt > ss) 
     {
       cout << "Yes" << endl;
       return 0;
     }
   else
     {
       cout << "No" << endl;
       return 0;
     }

}


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

using namespace std;
using ll = long long;

const ll INF = 1e15;

int main() {
  ll m = INF;
  int k, n;
  cin >> k >> n;
  vector<int> as(n);
  rep(i, n) cin >> as[i];

  ll r, l;
  int n0 = k - as[n - 1] + as[0];
  m = l = r = as[n - 1] - as[0];
  for (int i = 1; i < n; i++) {
    r = (as[n - 1] - as[i]) + (as[i - 1] - as[0]) + n0;
    l = (as[n - i - 1] - as[0]) + as[n - 1] - as[n - i] + n0;
    m = min({m, r, l});
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 4044
#include <stdio.h>

int point[100001][3];
int dp[100001][3];

int max(int a, int b)
{
    return (a >= b) ? a : b;
}

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d %d", &point[i][0], &point[i][1], &point[i][2]);
        dp[i][0] = dp[i][1] = dp[i][2] = 0;
    }

    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = max(dp[i - 1][1] + point[i - 1][0], dp[i - 1][2] + point[i - 1][0]);
        dp[i][1] = max(dp[i - 1][0] + point[i - 1][1], dp[i - 1][2] + point[i - 1][1]);
        dp[i][2] = max(dp[i - 1][0] + point[i - 1][2], dp[i - 1][1] + point[i - 1][2]);
    }
    printf("%d\n", max(dp[n][0], max(dp[n][1], dp[n][2])));
    return 0;
}

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

long long GetNewSat(int d, int newT, const vector<int>& ts, const vector<int>& cs, const vector<vector<int>>& ss, long long sat, int D)
{
	int prevT = ts[d];
	int prevTdaysBefore = distance(ts.rbegin() + (D - d), find(ts.rbegin() + (D - d), ts.rend(), prevT));
	int prevTdaysAfter = distance(ts.begin() + d, find(ts.begin() + d + 1, ts.end(), prevT));
	int newTdaysBefore = distance(ts.rbegin() + (D - d), find(ts.rbegin() + (D - d), ts.rend(), newT));
	int newTdaysAfter = distance(ts.begin() + d, find(ts.begin() + d + 1, ts.end(), newT));
	sat -= cs[prevT] * (prevTdaysBefore + 1) * prevTdaysAfter;
	sat += cs[newT] * (newTdaysBefore + 1) * newTdaysAfter;
	sat -= ss[d][prevT];
	sat += ss[d][newT];
	return sat;
}

int main()
{
	auto& in = cin;

	const int numA = 26;
	int D;
	in >> D;
	vector<int> cs;
	vector<vector<int>> ss;
	for (int i = 0; i < numA; ++i) {
		int c;
		in >> c;
		cs.push_back(c);
	}
	for (int i = 0; i < D; ++i) {
		vector<int> s;
		for (int j = 0; j < numA; ++j) {
			int is;
			in >> is;
			s.push_back(is);
		}
		ss.emplace_back(move(s));
	}

	long long sat = 0;
	vector<int> ds(numA);
	vector<int> ts;
	for (int i = 0; i < D; ++i) {
		int t = distance(ss[i].begin(), max_element(ss[i].begin(), ss[i].end()));
		ts.push_back(t);
		sat += ss[i][t];
		for (int j = 0; j < numA; ++j)
			++ds[j];
		ds[t] = 0;
		for (int j = 0; j < numA; ++j)
			sat -= cs[j] * ds[j];
	}

	int M = 10000;
	int dif = 1;
	for (int i = 0; i < M; ++i) {
		for (int d = 0; d < D; ++d) {
			int newT = ts[d] + dif;
			dif = (dif + 1) % numA;
			newT %= numA;
			long long newSat = GetNewSat(d, newT, ts, cs, ss, sat, D);
			if (newSat > sat) {
				sat = newSat;
				ts[d] = newT;
			}
		}
	}

	for (int i = 0; i < D; ++i) {
		cout << ts[i] + 1 << "\n";
	}

	return 0;
}


Measured memory_bytes: 3708
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int N, K;
int ub, lb;
int ans[1008];
vector<vector<int>> v(1001);

bool check()
{

    for (int i = 0; i < K; ++i)
    {
        int cnt = 0;
        for (int j = 0; j < N / 2; ++j)
        {
            cnt += ans[v[i][j]];
        }
        if (cnt < lb || cnt > ub)
            return false;
    }
    return true;
}

void solve()
{
    for (int i = 0; i < N / 2; ++i)
        ans[i] = 1;
    while (1)
    {
        std::random_device seed_gen;
        std::mt19937 engine(seed_gen());
        shuffle(ans, ans + N, engine);
        if (check())
            break;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    cin >> N >> K;
    lb = N / 8;
    ub = 3 * lb;

    for (int i = 0; i < K; ++i)
    {
        for (int j = 0; j < N / 2; ++j)
        {
            int a;
            cin >> a;
            a--;
            v[i].push_back(a);
        }
    }
    solve();

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



Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector <double> A(N);
	double res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<vector<double> > dp(N + 1, vector<double>(N + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= N; j++) {
			if (j < N)dp[i + 1][j + 1] += dp[i][j] * A[i];
			dp[i + 1][j] += dp[i][j] * (1 - A[i]);
		}
	}
	for (int i = (N + 1) / 2; i <= N; i++) {
		res += dp.back()[i];
	}
	cout << fixed << setprecision(15) << res << endl;
}

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

#define debug(val) "[ " << #val " : " << (val)
#define space " "
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define vii vector<vector<int>>
#define PI (double)(atan(1)*4)
#define pb push_back
#define pi pair<int , int >
#define ff first
#define ss second
#define INF 2000000000
vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};
const int Mod = 1000 * 1000 * 1000 + 7 ;
vll mul_mat(vll a , vll b) {
    vll res(2 , vl(2,0)) ;
    int n = 2 ;
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                res[i][j] += a[i][k] * b[k][j] ;
                res[i][j] %= Mod ;
            }
        }
    }

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


int main() {
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0); // FAST IO
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        solve();
    }
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int a, b;
int p[15] = { 0,13,1,2,3,4,5,6,7,8,9,10,11,12 };

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

	if (p[a] > p[b])cout << "Alice" << endl;
	else if (p[b] > p[a])cout << "Bob" << endl;
	else cout << "Draw" << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N), F(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++)cin >> F[i];
	sort(A.begin(), A.end(), greater<>());
	sort(F.begin(), F.end());

	ll low = -1, high = 1e18;
	while (high - low > 1LL) {
		ll mid = (low + high) / 2LL;
		ll tmp = K;
		for (int i = 0; i < N; i++) {
			if (A[i] * F[i] <= mid)continue;
			ll tmp2 = ceil((double)(A[i] * F[i] - mid) / (double)F[i]);
			tmp -= tmp2;
		}
		if (tmp < 0)low = mid;
		else high = mid;
	}
	cout << high << endl;
}

Measured memory_bytes: 3328
// 左から順番にみていくとして、i=1からスタートすると
// i-1よりもiを優先的に犠牲にしたほうがいい
// （i+1にも影響を与えてくれるので）
// 1. A[i] + A[i-1] <= x -> そのまま
// 2. 1以外:
//			2.1. A[i] >=x -> A[i]だけ必要なぶん犠牲にして減らす
//			2.2 2.1以外 -> A[i-1]も犠牲にする
package main

import "fmt"

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		A[i] = V
	}
	ans := 0
	for i := 1; i < N; i++ {
		if A[i-1]+A[i] <= X {
			continue
		} else {
			hikubun := (A[i] + A[i-1]) - X
			ans += hikubun
			if A[i] >= hikubun {
				A[i] -= hikubun
			} else {
				// A[i-1]も減るけどどうせ今後登場しないので無視
				A[i] = 0
			}
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 1e5;
const double PI = acos(-1.);
const double EPS = 1e-8;

int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	int cur = - 1;
	FOR(i, 1, 1e4)
	{
		if (i * (i + 1) / 2 == n)
		{
			cur = i;
			break;
		}
	}

	if (cur == - 1)
	{
		return cout << "No", 0;
	}

	cout << "Yes\n";
	int ans[cur+1][cur];

	set<int> s;
	FOR(i ,0 ,n)
	{
		s.insert(i+1);
	}
	FOR(i, 0, cur+1)
	{
		FOR(j, 0, i)
		{
			ans[i][j] = ans[i-j-1][i-1];
		}
		FOR(j, i, cur)
		{
			ans[i][j] = *s.begin();
			s.erase(s.begin());
		}
	}

	cout << cur+1 << endl;
	FOR(i,0,cur+1)
	{
		cout << cur << " ";
		FOR(j, 0, cur)
		{
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}













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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
const int N_max=51;
const int M_max=N_max*(N_max-1);
vector<int> v[51];
bool isVisited[N_max];
void initialize(){
    REP(i,N_max){
        isVisited[i]=false;
    }
}
void dfs(int v_now){
    isVisited[v_now]=true;
    for(int i:v[v_now]){
        if(!isVisited[i]){
            dfs(i);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A=in();
    int B=in();
    int ans;
    if(abs(B-A)%2==1){
        print("IMPOSSIBLE");
    }else{
        ans=(B+A)/2;
        print(ans);
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>

double EPS = 1e-10;
const double PI = acos(-1);

using namespace std;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
  
  bool operator == ( const point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

struct circle{
  point p;
  double r;
};

circle circumscribed_circle(point p, point q, point r){
  double a[2],b[2],c[2];
  circle res;
    
    a[0]=2*(q.x-p.x);
    b[0]=2*(q.y-p.y);
    c[0]=p.x*p.x-q.x*q.x+p.y*p.y-q.y*q.y;
    
    a[1]=2*(r.x-p.x);
    b[1]=2*(r.y-p.y);
    c[1]=p.x*p.x-r.x*r.x+p.y*p.y-r.y*r.y;
    
    res.p.x=(b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0]);
    res.p.y=(c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0]);
 
    res.r=sqrt(pow(fabs(p.x-res.p.x),2)+pow(fabs(p.y-res.p.y),2));
    
    return res;
}

int main(void) {
  
  int n;
  point in[3];
  circle ans;
 
  cin >> n;
  
  while(n--){
    for(int i=0;i<3;i++)
      cin >> in[i].x >> in[i].y;

    ans=circumscribed_circle(in[0], in[1], in[2]);

    printf("%.3f %.3f %.3f\n",ans.p.x,ans.p.y,ans.r);
  }
  
  return 0;
}

Measured memory_bytes: 1244
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A + 1):
  for j in range(B + 1):
    for k in range(C + 1):
      if X == 500 * i + 100 * j + 50 * k:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
ll h, w;

int main(){
	IOS
	cin >> h >> w;
	if(h==1 or w==1){
		cout << 1 << '\n'; return 0;
	}
	cout << (h*w+1)/2 << '\n';
}

Measured memory_bytes: 256
N = gets.to_i
f = N.times.map{ gets.split.map(&:to_i) }
pr = N.times.map{ gets.split.map(&:to_i) }

mx = nil
1.upto(2**10-1) do |m|
  sum = 0
  N.times do |i|
    c = 0
    10.times do |t|
      c += 1 if f[i][t] == 1 && m[t] == 1
    end
    sum += pr[i][c]
  end
  #puts "%010b %d"%[m, sum]
  mx ||= sum
  mx = [sum, mx].max
end
p mx


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int gcd(int x,int y){
  if(x<y) swap(x,y);
  int b;
  while(x%y!=0){
    b=x;
    x=y;
    y=b%y;
  }
  return y;
}
int main(){
  int x,y;
  cin >> x >> y;
  cout << gcd(x,y) <<endl;
  return 0;
}



Measured memory_bytes: 3108
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> src = new ArrayList<>();
		for(int i=0;i<n;i++) {
				src.add(sc.nextInt());
		}
		ArrayList<Integer> array = new ArrayList<Integer>(src);
		
		Collections.sort(array);
		int max=array.get(n-1);
		int second=array.get(n-2);

		for(int i=0;i<n;i++) {
			if(max!=src.get(i))
			System.out.println(max);
			else 
				System.out.println(second);
		}

	}
}


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

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

    vector <int> nums(3);
    for(int i = 0; i < 3; i++) cin >> nums[i];
    sort(nums.begin(), nums.end());
    if(nums[0] == nums[1] && nums[1] != nums[2] || nums[2] == nums[1] && nums[1] != nums[0]){
        cout << "Yes";
    }
    else cout << "No";
    cout << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<vector<int> >  vec2int;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int main()
{
  int h, n; cin >> h >> n;
  vecint a(n,0), b(n,0);
  REP(i,n){cin >> a[i] >> b[i];}
  int inf = 1e9;
  vec2int dp(n + 1,vecint(h + 1, inf));
  REP(i,n + 1){
    dp[i][0] = 0;
  }
  REP(i,n){
    REP(j,h + 1){
      if(j - a[i] >= 0){
	dp[i + 1][j] = min(dp[i + 1][j - a[i]] + b[i], dp[i][j]);
      }else{
	dp[i + 1][j] = min(b[i], dp[i][j]);
      }
    }
  }
  // cout << endl;
  // REP(i,n + 1){
  //   REP(j, 10){
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
   cout << dp[n][h] << endl;
}

Measured memory_bytes: 39424
using System;
using System.IO;

class ApplePie
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int P = int.Parse(input[1]);

        P = P + (A * 3);

        Console.WriteLine(P / 2);
    }
}
        

Measured memory_bytes: 13140
import java.util.*;


public class Main {
	public static void main (String[] args){
		Scanner sc =  new Scanner(System.in);
		int N = sc.nextInt();
		int H[] = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		for(int i = 0; i < N-1; i++) {
			int memo = 0;
			for(int j = i+1; j < N; j++) {
				if(H[i] >= H[j]) {
					i = j;
					memo++;
				}
				else {
					break;
				}
			}
			if(memo > sum) {
				sum = memo;
			}
		}
		System.out.println(sum);
	}	
}

Measured memory_bytes: 50792
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e3+9, M = (1<<31), OO = 0x3f3f3f3f;
char str[N][N];
int l[N][N],r[N][N],u[N][N],d[N][N];
int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;++i) scanf("%s",str[i]);
  // Left
  for(int i=0;i<n;++i)
  {
    int cnt=0;
    for(int j=0;j<m;++j)
    {
      if(str[i][j]=='#') cnt=0;
      else cnt++;
      l[i][j]=cnt;
    }
  }
  // Right
  for(int i=0;i<n;++i)
  {
    int cnt=0;
    for(int j=m-1;~j;--j)
    {
      if(str[i][j]=='#') cnt=0;
      else cnt++;
      r[i][j]=cnt;
    }
  }
  //Down 
  for(int i=0;i<m;++i)
  {
    int cnt=0;
    for(int j=0;j<n;++j)
    {
      if(str[j][i]=='#') cnt=0;
      else cnt++;
      u[j][i]=cnt;
    }
  }
  //UP 
  for(int i=0;i<m;++i)
  {
    int cnt=0;
    for(int j=n-1;~j;--j)
    {
      if(str[j][i]=='#') cnt=0;
      else cnt++;
      d[j][i]=cnt;
    }
  }
  int cnt=0;
  for(int i=0;i<n;++i) for(int j=0;j<m;++j) cnt=max(cnt,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
  printf("%d\n",cnt);

  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 67200
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<climits>
#include<cmath>
#include<fstream>
#include<numeric>

int main(){
	unsigned long long int n, a;
	std::vector<unsigned long long int>dp(6);
	std::cin >> n;
	std::cin >> a;
	dp[0] = std::ceil((double)n/a);

	for(int i=1;i<5;i++){
		unsigned long long int x;
		std::cin >> x;
		dp[i] = std::max(dp[i-1],(unsigned long long int)std::ceil((double)n/x));
	}

	std::cout << dp[4] + 4 << std::endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var T, X int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &T, &X)

	fmt.Println(float64(T) / float64(X))
}


Measured memory_bytes: 640
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()
    val statement = (1..n).map {
        val m = readLine()!!.toInt()
        (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
    }

    var max = 0
    for (pattern in 0 until 1.shl(n)) {
        val num = Integer.bitCount(pattern)
        if (num <= max || (0 until n).any { i -> pattern shr i and 1 == 1 && statement[i].any { pattern shr (it[0] - 1) and 1 != it[1] } }) continue
        max = num
    }
    max
})

Measured memory_bytes: 41644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    int d;
    cin >> d;

    cout << "Christmas ";
    for(int i = 24; i >= d; i--)cout << "Eve ";
    cout << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

vector<string> S;
void rec (int k, int n, string now, char max_char) {
    if (k == n) S.push_back(now);
    else {
        for (char c = 'a'; c <= max_char + 1; c++) {
            rec(k + 1, n, now + c, max(c, max_char));
        }
    }
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s = "a";
    rec(1, n, s, 'a');
    for (string t : S) cout << t << "\n";
    // rep (i, S.size()) {
    //     rep (j, i + 1, S.size()) {
    //         bool ok = true;
    //         rep (k, n) {
    //             rep (l, k + 1, n) {
    //                 if ((S[i][k] == S[i][l]) ^ (S[j][k] == S[j][l])) ok = false;
    //             }
    //         }
    //         if (ok) cout << S[i] << " " << S[j] << "\n";
    //     }
    // }
    // cout << S.size() << "\n";
    return 0;
}

Measured memory_bytes: 7796
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Thu Jan 24 16:20:46 2019
//
package main

import (
	"fmt"
	"sort"
	"strconv"
)

func digitSum(n int) int {
	s := strconv.Itoa(n)

	sum := 0
	for i := range s {
		sum += int(s[i] - '0')
	}
	return sum
}

func unique(slice []int) []int {
	ret := []int{}
	for _, s := range slice {
		hasSame := false
		for _, r := range ret {
			if r == s {
				hasSame = true
			}
		}
		if !hasSame {
			ret = append(ret, s)
		}
	}

	return ret
}

func pow10(n int) int {
	if n == 0 {
		return 1
	}
	return 10 * pow10(n-1)
}

func main() {
	var K int
	fmt.Scan(&K)
	candidates := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}

	for i := 1; i <= 15; i++ {
		for j := 1; j <= 150; j++ {
			n := pow10(i)
			if j*(n-1) <= 1e15 {
				candidates = append(candidates, j*n+n-1)
			}
		}
	}

	candidates = unique(candidates)
	sort.Ints(candidates)

	anss := make([]int, 0)
	for i, n := range candidates {
		valid := true
		for j := i + 1; j < len(candidates); j++ {
			m := candidates[j]
			if valid && digitSum(m)*n > digitSum(n)*m {
				valid = false
			}
		}
		if valid {
			anss = append(anss, n)
		}
	}

	for i := 0; i < K; i++ {
		fmt.Println(anss[i])
	}
}


Measured memory_bytes: 5504
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
ans = 1001
for i in range(1<<d): # 0から2^D -1までの全難易度についてそれを解くか解かないかの組み合わせ
    count, score, left = 0, 0, 0
    for j in range(d): # 100からD*100の難易度まで
        if (i >> j) & 1: # j*100の難易度の問題を解く場合(最後の桁が1かで判定)
            score += (j+1)*100*pc[j][0] + pc[j][1] # 全部の問題をといてボーナスポイントも得る
            count += pc[j][0] # 全部の問題解いた分をカウント
        else: left = j # 解かない場合は全て残りに回される
    for j in range(pc[left][0]): # 残っている時
        if score >= g: break
          
        score += (left+1)*100 # gを超えない範囲で1つずつ足され、カウントされる
        count += 1
    if score >= g: ans = min(ans, count) # gを越えるカウントの中でもっとも小さいものが答え
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H + 2,
   vector<char>(W + 2, ' '));

  for (int i = 1 ; i <= H ; i++) {
    for (int j  = 1; j <= W; j++) {
      char c;
      cin >> c;
      S[i][j] = c;
    }
  }

  for (int i = 1 ; i <= H ; i++) {
    for (int j  = 1; j <= W; j++) {
      if (S[i][j] == '.') {
        int num = 0;
        for (int a = -1; a <= 1 ; a++) {
          for (int b = -1; b <= 1 ; b++) {
            if (S[i + a][j + b] == '#') {
              num++;
            }
          }
        }
        S[i][j] = '0' + num;
      }
    }
  }

  for (int i = 1 ; i <= H ; i++) {
    for (int j  = 1; j <= W; j++) {
      cout << S[i][j];
    }
    cout << endl;
  }



}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int c = 0;
  for(int rc=0;rc<=n;rc++)
  {
      for(int gc=0;gc<=n;gc++)
      {
          if((n-rc*r-gc*g)%b==0&&(n-rc*r-gc*g>=0))
          {
              //cout<<rc<<" "<<gc<<" "<<(n-rc*r-gc*g)/b<<"\n";
              c++;
          }
      }
  }
  cout<<c;
  return 0;
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    double l;
	cin >> l;
    cout<<fixed<<setprecision(7)<<(l/3)*(l/3)*(l/3);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

const int MX=1500*1000+1;
int n,m,H[1500],W[1500];
int h[MX],w[MX];

void comb(int *A,int *a,int k)
{
	fill_n(a,MX,0);
	rep(i,k)
	{
		int len=0;
		for(int j=i;j<k;j++)len+=A[j],a[len]++;
	}
}

int main()
{
	while(scanf("%d%d",&n,&m),n)
	{
		rep(i,n)scanf("%d",H+i); comb(H,h,n);
		rep(i,m)scanf("%d",W+i); comb(W,w,m);
		int ans=0;
		rep(i,MX)ans+=h[i]*w[i];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(){
  int n,k,i,x,ans=0;
  scanf("%d",&n);
  scanf("%d",&k);
  for(i=0; i<n; i++){
    scanf("%d",&x);
    if(k-x>x-0){
      ans+=2*x;
    }
    else{
      ans+=2*(k-x);
    }
  }
  printf("%d\n",ans);
  return 0;


}

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

using namespace std;
int a[110000];
int main()
{
    int x;int i;
    for(i=2;i<1100;i++)
        a[i]=0;
    a[1]=1;
    for(i=2;i<=35;i++)
       {
           int s=i;
           while(s<1000)
           {
               s=s*i;
               a[s]=1;
           // printf("i=%d , s=%d\n",i,s);
           }
       }
   // printf("dsdf\n");
   /* for(i=0;i<100;i++)
        printf("i=%d , %d\n",i,a[i]);*/
    scanf("%d",&x);

        for(i=x;i>=1;i--)
    {
        if(a[i]==1)
          {
              printf("%d\n",i);return 0;
          }

    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

struct hms {		// ツ篠楪甘板、ツ閉ェツ、ツ秒ツつェツ与ツつヲツづァツづェツつスツづつォツづ個計ツ算ツ陛「ツ渉閉。ツ秒ツづ可環キツ算ツ。ツ青ョツ青板氾。
  int t;
  int h, m, s;
  hms(int _h, int _m, int _s) {h=_h;m=_m;s=_s;t=h*3600+m*60+s;}
  hms(int _t) {t = _t; h = t/3600; m = t%3600/60; s=t%60;}
};

int main() {
  int s = 0;
  REP(i,4) {
    int a;
    cin >> a;
    s+= a;
  }
  cout << hms(s).m << endl;
  cout << hms(s).s << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m;
   cin>>n>>m;
   int ans=0;
   for(int i=n-1;i>=1;i--)
   ans+=i;
   for(int i=m-1;i>=1;i--)
   ans+=i;
   cout<<ans;
 	
} 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
int main(void){
    ll a,b,c;
    cin >> a >> b >> c;
    ll d = c - a - b;
    if(d > 0 && d * d > 4 * a * b){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;


int main(){

    int N, M;
    cin >> N >> M;
    vector <pair<int, int> > AB(M);
    map <int, int> F;
    int max = 1;

    for (int i = 0; i < M; i++){
        cin >> AB[i].first >> AB[i].second;
        F[AB[i].first] ++;
        if (AB[i].first > max){
            max = AB[i].first;
        }
    }

    if (max > 1){
        int sum = F[1];
        for (int i = 2; i <= max; i++){
            sum += F[i];
            F[i] = sum; 
        }
    }
    

    sort(AB.begin(), AB.end());

    bool flag = false;
    if (F[1] != 0){
        for (int i = 0; i < F[1]; i++){
            int a = AB[i].second;
            if (F[a] != F[a - 1]){
                for (int j = F[a - 1]; j < F[a]; j++){
                    if (AB[j].second == N){
                        flag = true;
                        break;    
                    }
                }
            }
            if (flag == true){
                break;
            }
        }
    }
    
    
    
    if (flag == true){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    

    return 0;
}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     ll n,a,b;
     cin >> n >> a >> b;
     vector<ll> v(n);
     for(int i=0;i<n;i++)cin >>v[i];
     ll ans=0;
     for(int i=0;i<n-1;i++){
        ans+= min((v[i+1]-v[i])*a,b);
     }
     cout << ans;
  }


  int main(){
    IOS
       solve();
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 1024
#include <iostream>                                  
#include <cstring>                                   
#include <cstdio>                                  
                                                     
using namespace std;                                 
                                                     
int main (void) {                                    
  char ch[1000];                                     
                                                     
  while (true) {                                     
    scanf("%s", ch);                                 
    if (strcmp(ch,"0")==0) {                         
      break;                                         
    }                                                
    int ans = 0;                                     
    for (int i=0; i<1000; i++) {                     
      if (ch[i]=='\0') {                             
        break;                                       
      }                                              
      ans += ch[i]-'0';                              
    }                                                
    cout << ans << endl;                             
  }                                                  
}                                                    
                             

Measured memory_bytes: 3140
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
const int MOD=1e9+7;
int fact[500001]={0},inv[500001]={0};
static inline int ModPow(int a,int b){int c=1;while(b>0){if(b&1){c=1l*c*a%MOD;}a=1l*a*a%MOD;b>>=1;}return c;}
static inline void init(int sz)
{
  sz++;fact[0]=1;rep(i,sz-1)fact[i+1]=1l*fact[i]*(i+1)%MOD;
  inv[sz-1]=ModPow(fact[sz-1],MOD-2);
  rep(i,sz-1)inv[sz-2-i]=1l*inv[sz-1-i]*(sz-1-i)%MOD;
}
static inline int comb(const int n,const int k){if(k<0||n<k){return 0;}return 1l*fact[n]*inv[n-k]%MOD*inv[k]%MOD;}
static inline int P(const int n,const int k){if(k<0||n<k){return 0;}return 1l*fact[n]*inv[n-k]%MOD;}
int main()
{
  int N=IN(),M=IN(),sum=0,nega=1;init(M);
  rep(k,N+1){sum=(1l*sum+MOD+nega*1l*comb(N,k)*P(M,k)%MOD*ModPow(P(M-k,N-k),2)%MOD)%MOD;nega*=-1;}
  return printf("%d\n",sum),0;
}

Measured memory_bytes: 5388
import collections
import itertools
import sys
input = sys.stdin.readline


def check_tri(a, b, c):
    if a + b > c and b + c > a and c + a > b:
        return True
    else:
        return False


def print_ans(lr):
    """Test Case
    >>> print_ans([4, 4, 9, 7, 5])
    5
    >>> print_ans([4, 5, 4, 3, 3, 5])
    8
    >>> print_ans([9, 4, 6, 1, 9, 6, 10, 6, 6, 8])
    39
    >>> print_ans([1,1])
    0
    """
    ans = 0
    c = collections.Counter(lr)
    target = itertools.combinations(list(c.keys()), 3)
    for t in target:
        if check_tri(t[0], t[1], t[2]):
            tmp = (c[t[0]] * c[t[1]] * c[t[2]])
            ans += tmp
    print(ans)


if __name__ == '__main__':
    N = int(input().rstrip())
    lr = list(map(int, input().rstrip().split()))
    print_ans(lr)


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

int main() {
    ll K,N;
    cin >> K >> N;
    vector<ll> A(N,0);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    ll res=0;
    for(int i=0;i<N;i++){
        if(i==N-1)res=max(K-A[i]+A[0],res);
        else res=max(A[i+1]-A[i],res);
    }
    cout << K-res;
    return 0;
}


Measured memory_bytes: 4852