akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<numeric>
#include<cstdlib>
#define ll long long int
#define all(x) x.begin(),x.end()
 
 #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
#define v vector<long long int> 
#define vv vector< int> 
#define gcd(m,n) __gcd(m,n)
#define vp vector<pair<long long int ,long long int>>
#define pb push_back
#define mp make_pair
#define pp pop_back
#define iter vector<int>::iterator
#define pa pair<long long int ,long long int> 
#define f(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,n) for (ll i=a ; i<n ;i+=1)
#define fe(d,e) for(auto d:e)
#define mod 1000000007
#define F first
#define S second
#define sett set<long long int>
#define um unordered_map<ll,ll>
# define N 100005LL
using namespace std;

#define T (sizeof(arr)/sizeof(arr[0]))
int arr[]={1,2,3,4,5
};
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
}

ll modInverse(ll n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
ll nCr(ll n,  ll r, ll p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
    ll fac[n + 1]; 
    fac[0] = 1; 
    for (ll i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}



vector<vector<ll>> graph(200005);
ll visited[200005]; 

void dfs(ll node){
    visited[node]=1;
    cout<<node<<" ";
    for (ll u:graph[node]){
        if(!visited[u])dfs(u);
    }
}


int main(){
    ll n;
        cin>>n;
       
        ll ans=0;
        for(ll i=1;i<=n/3;i++)
        {
            ans+=nCr(n-2*i-1,i-1,mod);
            ans%=mod;
            
        }
        cout<<ans%mod<<"\n";
    
}




            




        

   

    

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

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  vector<int> dist(n + 1, 0);
  x--;
  y--;

  rep(l, n) {
    for (int r = l + 1; r < n; r++) {
      int d = r - l;
      if (l <= x && r >= y) d -= y - x - 1;
      int w = abs(x - l) + abs(y - r) + 1;
      // printf("%d %d %d\n", l, r, d);
      dist[min(d, w)]++;
    }
  }

  rep(i, n - 1) { cout << dist[i + 1] << endl; }

  return 0;
}


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

int main(){
	int n,m,time[20010],ma,tmp;
	while(cin>>n>>m,n+m){
		ma=0;
		tmp=0;
	for(int i=0;i<n;i++)cin>>time[i];
		for(int i=n;i<n+m;i++)cin>>time[i];
		sort(time,time+(n+m-1));
		for(int i=0;i<n+m;i++){
			ma=max(ma,(time[i]-tmp));
			tmp=time[i];
		}
		cout<<ma<<endl;
	}
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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 N, C, D[30][30], c[500][500];
int t[3][30];

int main() {
    cin >> N >> C;
    rep(i, C) rep(j, C) cin >> D[i][j];
    rep(i, N) rep(j, N) cin >> c[i][j];
    rep(i, N) rep(j, N) c[i][j]--;

    rep(i, N) rep(j, N) t[(i+j)%3][c[i][j]]++;
    int ans = INF;
    rep(i, C) rep(j, C) rep(k, C) {
        if (i == j || j == k || k == i) continue;
        int sum = 0;
        rep(l, C) {
            sum += D[l][i] * t[0][l];
            sum += D[l][j] * t[1][l];
            sum += D[l][k] * t[2][l];
        }
        chmin(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
    
  if(A+B == C+D)
    cout << "Balanced" << endl;
  if(A+B < C+D)
    cout << "Right" << endl;
  if(A+B > C+D)
    cout << "Left" << endl;
}

Measured memory_bytes: 3564
#include<stdio.h>
int main(void)
{
    char s[4];
    int i=0,a=0;
    scanf("%s",s);
    for(i=1;i<3;i++){
        if(s[i-1]!=s[i])
            a++;
    }
    if(a>0)
        printf("Yes\n");
    else 
        printf("No\n");
    return 0;
}

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

int main()
{
  int N, T;
  cin >> N >> T;
  int ans = 10000;
  bool flg = false;
  for (int i = 0; i < N; i++)
  {
    int c, t;
    cin >> c >> t;
    if (t <= T)
    {
      ans = min(ans, c);
      flg = true;
    }
  }
  if (flg)
  {
    cout << ans << endl;
  }
  else
  {
    cout << "TLE" << endl;
  }
}


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

int main(){
   int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;

   int en[f*f+1];
   int miz[f*f+1];
   int cnt=0;
   for(int i=0;i<=f;i++){
       for(int j=0;j<=f;j++){
           int y=i*c+j*d;
           if(y<=f){
               en[cnt++]=y;
           }
       }
   }
   int cnt2=0;
   for(int i=0;i<=f;i++){
       for(int j=0;j<=f;j++){
           int x=100*a*i+100*b*j;
           if(x<=f){
               miz[cnt2++]=x;
           }
       }
   }
   double dense;
   double densemax=100*e/(double)(100+e);
   double max=-1;
   int water;
   int salt;
   for(int i=0;i<=cnt2;i++){
       for(int j=0;j<=cnt;j++){
           if(miz[i]+en[j]==0)continue;
           if(miz[i]+en[j]<=f){
               //if(en[j]==0) dense=0;
               dense=100*en[j]/(double)(miz[i]+en[j]);
               if(dense<=densemax){
                   if(max<dense){
                       max=dense;
                       salt=en[j];
                       water=miz[i];
                       //cout << dense << endl;
                   }
               }
           }
       }
   }

    cout << water+salt << " " << salt << endl;
   
}


Measured memory_bytes: 1280
#include <stdio.h>
int main(){
    long int N, K;
    scanf("%ld %ld", &N, &K);
    long int  b;
    long int ans = 0;
    if(K == 0){
        printf("%ld\n", N * N);
    }else{
    for(b = K + 1; b <= N; b++){
    long int lMax = N/b;
    long int rLast = N % b - K + 1;
    if(rLast < 0 ){
        rLast = 0;
    }
    ans += (b - K) * lMax + rLast;
    }
    printf("%ld\n", ans);
    }
    return 0;
}

//rはKからb - 1まで. l*b+ r<=N

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

vll ans;
vector<bool> seen;
void dfs(const vector<vll> &G, ll v){
    seen[v] = true;
    for(auto g:G[v]){
        if(seen[g])continue;
        ans[g] += ans[v];
        dfs(G,g);
    }
}

int main()
{
    int N,Q;
    cin >> N >> Q;
    vector<vll> G(N);
    ans.assign(N,0);
    seen.assign(N,false);
    REP(i,N-1){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    REP(i,Q){
        ll a,b;
        cin >> a >> b;
        a--;
        ans[a]+=b;
    }
    REP(i,N){
        if(seen[i])continue;
        dfs(G,i);
    }
    REP(i,N){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 25180
x, n = map(int, input().split())
plist = list(map(int, input().split()))

a = x
while True:
    if not a in plist:
        big = a
        break
    a += 1

b = x-1
while True:
    if not b in plist:
        small = b
        break
    b -= 1

if abs(big-x) < abs(small-x):
    ans = big
else:
    ans = small

print(ans)


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  int arr[n], i;
  for (i=1; i<=n; i++)
    {
      cin >> arr[i];
    }
  int ans=0;
  for (i=1; i<=n; i+=2)
    {
      if (arr[i]%2!=0)
	ans++;
    }
  cout << ans << endl;
  return 0;
}
      


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10 ** 5)

n = int(input())
uvw = [tuple(int(x) for x in input().split()) for _ in range(n-1)]

c = [-1] * n

r = [[] for _ in range(n)]

for u, v, w in uvw:
    r[u-1].append([v-1, w])
    r[v-1].append([u-1, w])


def f(p):
    count = 0
    for x, w in r[p]:
        if c[x] == -1:
            if w % 2 == 0:
                c[x] = c[p]
                f(x)
            else:
                c[x] = (c[p] + 1) % 2
                f(x)
            count += 1


c[0] = 0
f(0)

for x in c:
    print(x)


Measured memory_bytes: 98388
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 45
#define INF 1e9
 
int N,p[MAX],t[MAX];
int dp[MAX][4];
bool used[MAX];
 
void init(){
    p[0] = t[0] = 0;
    fill(dp[0],dp[0]+MAX*4,INF);
    memset(used,false,sizeof(used));
}
 
int d(int idx,bool v){
    if(v){
	return p[idx]+p[idx+1];
    }else{
	return abs(p[idx]-p[idx+1]);
    }
}
 
int solve(int idx,int cap){
    used[idx] = true;
    if(idx == N){
	return dp[idx][cap] = p[idx];
    }
    int &res = dp[idx][cap],dt = t[idx+1]-t[idx];
    if(res != INF) return res;
    if(p[idx]*(cap+1)+p[idx+1] <= dt){
	res = min(res,solve(idx+1,1) + d(idx,1));
    }
    if(cap < 3 && d(idx,0)*(cap+1) <= dt){
	res = min(res,solve(idx+1,cap+1) + d(idx,0));
    }
    return res;
}
 
int main(){
    while(cin >> N, N){
	init();
	for(int i = 1 ; i <= N ; i++){
	    cin >> p[i] >> t[i];
	}
	int ans = solve(0,0);
	if(ans != INF){
	    cout << "OK " << ans << endl;
	}else{
	    cout << "NG " << find(used+1,used+N,false)-used << endl;
	}
    }
    return 0;
}

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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	V b(N), ans(N);  VECCIN(b);

	for(int i = N - 1 ; 0 <= i ; i--){

	 int erase_ite = -1;
	 for(int j = i ; 0 <= j ; j--){
		if(b[j] == j + 1){
	 	 b.erase(b.begin() + j);
         ans[i] = j + 1;
          break;
	 	}
     }
      if(!ans[i]){
        cout << -1 << endl;
        return 0;
      }
	}

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


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a < b && b < c) cout << "Yes" << endl;
    else cout <<"No" << endl;
}



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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template< int mod >
struct Combination
{
  vector< int64_t > mfact, rfact;

  Combination(int sz) : mfact(sz + 1), rfact(sz + 1)
  {
    mfact[0] = 1;
    for(int i = 1; i < (int)mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const
  {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const
  {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const
  {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const
  {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const
  {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const
  {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  map<int, int> mp;
  int pl = 0, pr = 0;
  for(int i=0;i<n+1;++i) {
    int tmp; cin >> tmp;
    if(mp[tmp] == 0) mp[tmp] = i+1;
    else {
      pl = mp[tmp] - 1;
      pr = i;
    }
  }
  // cout << pl << ":" << pr << endl;

  int l = pl;
  int r = n - pr;
  // cout << l << ":" << r << endl;
  Combination<MOD> comb(100010);
  vector<ll> sl(n+10), sr(n+10);
  sl[0] = 1, sr[0] = 1;
  for(int i=1;i<=n+1;++i) {
    sl[i] = sl[i-1] + comb.C(l, i);
    sr[i] = sr[i-1] + comb.C(r, i);
    sl[i] %= MOD;
    sr[i] %= MOD;
  }


  cout << n << endl;
  for(int k=2;k<=n+1;++k) {
    ll res = comb.C(n+1, k);
    res -= comb.C(l+r, k-1);
    res = (res + MOD) % MOD;
    cout << res << endl;
  }

}


Measured memory_bytes: 9088
#!usr/bin/env python3

def string_three_numbers_spliter():
    a, b, c = [int(i) for i in input().split()]
    return a, b, c


def main():
    a, b, c = string_three_numbers_spliter()

    if a < b and a < c:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 7740
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  f              first
#define  s              second
#define  pb             push_back
#define  INPa(a,n)      foo(i,1,n) cin>>a[i];
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
string s;


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    cin>>s;
    foo(i,0,s.size()-1){
        if(s[i] == '7'){
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\n";
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 8340
#include<iostream>

using namespace std;

int main(void)

{
    int x, y, a, r;
    cin>>x>>y;
    if(y > x*4 || y < x*2){
        cout<<"No\n";
    }
    else if(y == x*2 || y == x*4){
        cout<<"Yes\n";
    }
    else{
        a = x*2;
        r = y-a;
        if(r%2 == 0){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3132
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

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

    vector<i64> arr(n);

    for (int i = 0; i < n; i++)
        scanf("%lld", &arr[i]);

    if (arr[0] != 0)
    {
        printf("-1\n");
        return 0;
    }

    i64 ans = 0;

    for (int i = 0; i < n - 1; i++)
    {
        if (arr[i + 1] > arr[i] + 1)
        {
            printf("-1\n");
            return 0;
        }

        if (arr[i + 1] <= arr[i])
            ans += arr[i];
    }

    ans += arr[n - 1];

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define p1(n) printf("showing %d\n",n)
#define p2(m,n) printf("showing %d %d\n",m,n)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))
#define all(n) n.begin(),n.end()
//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
    int i,j,k,n,m,val,t=0,test;
    //freopen("000input.txt","r",stdin);
    cin>>m>>n;
  cout<<m*n<<endl;
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 3676
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

#include <random>

using namespace std;
#define int long long


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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &i:a)cin >> i;
    sort(a.begin(), a.end());
    cout << accumulate(a.begin(), a.begin() + k, 0ll) << endl;
}

Measured memory_bytes: 3664
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    int n = s.Length;
		long answer = 0;
    long mod = 1000000007;
    long oneMultiple = 1;

    for(int i = 0; i < n; i++)
    {
      if(i == n-1)
      {
        if(s[n-1] == '0') answer += oneMultiple;
        else answer += oneMultiple*3;

        answer %= mod;
      }else
      {
        if(s[i] == '1')
        {
          answer += DivideMod(3,n-1-i,mod)*oneMultiple;
          answer %= mod;

          oneMultiple *= 2;
          oneMultiple %= mod;
        }
      }
    }

		Console.WriteLine(answer);
	}

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

}

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

int main(void){
    int N;
    cin >> N;
    double x;
    double sum{0.0};
    string u;
    for(int i{0}; i<N; ++i){
        cin >> x;
        cin >> u;
        if(u=="JPY")
            sum += double(x);
        else
            sum += x*380000.0;
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 	int n;
  	cin >> n;
  	if(n==25)
      	cout<<"Christmas\n";
  	if(n==24)
      	cout<<"Christmas Eve\n";
  	if(n==23)
        cout<<"Christmas Eve Eve\n";
  	if(n==22)
		cout<<"Christmas Eve Eve Eve\n";

}

Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

let N = readInt()!
var answer = 0
for C in stride(from: 1, to: N+1, by: 2) {
    var num_of_divisors = 0
    for X in 1...C {
        if C % X == 0 {
            num_of_divisors += 1
        }
    }
    if num_of_divisors == 8 {
        answer += 1
    }
}
print(answer)

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <limits.h>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    int N;
    vector<long long> A;
    vector<long long> A_sum;
    long long sum = 0;
    
    cin >> N;
    
    int ans = 1;
    
    for ( int i = 0; i < N; i++ ) {
        long long t;
        cin >> t;
        A.push_back(t);
    }
    
    sort( A.begin(), A.end() );
    
    for ( int i = 0; i < N; i++ ) {
        sum += A[i];
        A_sum.push_back(sum);
    }
    
    for ( int i = N-2; i >= 0; i-- ) {
        if ( A[i+1] <= A_sum[i]*2 ) {
            ans++;
        }
        else {
            break;
        }
    }
    
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2548
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//(*'ω'*)ACcept me...
int main(){
    int n;cin>>n;
    vector<pair<int,int>> vec(n,pair<int,int>(0,0));
    for(int i=0;i<n;i++){
        cin>>vec[i].first;
        vec[i].second=i+1;
    }
    vector<int> ans(n);
    for(int rep=0;rep<n;rep++){
        bool found=false;
        for(int i=n-1;i>=0;i--){
            if(vec[i].first!=vec[i].second)continue;
            found=true;
            ans[rep]=vec[i].first;
            vec[i].second=-1;
            for(int j=i+1;j<n;j++)vec[j].second--;
            break;
        }
        if(!found){
            cout<<-1<<endl;return 0;
        }
    }
    for(int i=n-1;i>=0;i--){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 3600
import time
st_time=time.time()

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
show_flg=True


a,b,x=LI()
if x<a*a*b/2:
    t=a*b*b/2/x
    ans=math.atan(t)/math.pi*180
else:
    t=2*b/a-2*x/(a**3)
    ans=math.atan(t)/math.pi*180

print(ans)

Measured memory_bytes: 38892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    vector<ll> ABC(3);
    cin >> ABC[0] >> ABC[1] >> ABC[2];
    sort(all(ABC));
    ll cnt = 0, M = ABC.at(2), ans = 0;
    repi(i, 3, 0)
    {
        ABC.at(i) -= M;
        ABC.at(i) = abs(ABC.at(i));
        if (ABC.at(i) % 2 != 0)
        {
            cnt++;
        }
        ans += int(ABC.at(i) / 2);
    }
    ans = cnt == 1 ? ans += 2 : cnt == 2 ? ans += 1 : ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n,p = map(int,input().split())
    ls = [int(x) for x in input().split()]
    flg = False

    for i in range(n):
        if ls[i]%2==1:
            flg = True
            break
    if flg :
        print(2**(n-1))

    else:
        if p == 0:
            print(2**n)
        else:
            print(0)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	vector<vector<ll>> s(26),t(26);

	string sstr, tstr;
	cin >> sstr >> tstr;

	rep(i, sstr.size()) {
		s[sstr[i] - 'a'].emplace_back(i);
	}
	rep(i, tstr.size()) {
		t[tstr[i] - 'a'].emplace_back(i);
	}

	rep(i, 26) {
		if (t[i].size() != 0 && s[i].size() == 0) {
			cout << -1;
			return;
		}
	}

	ll count = 0;
	ll pos = 0;

	rep(i, tstr.size()) {

		char tgt = tstr[i];

		auto itr = lower_bound(s[tgt - 'a'].begin(), s[tgt - 'a'].end(), pos);

		if (itr == s[tgt - 'a'].end()) {
			//もう一度
			count++;
			pos = 0;

			itr = lower_bound(s[tgt - 'a'].begin(), s[tgt - 'a'].end(), pos);

		}

		pos = *itr;
		pos++;

	}

	cout << count * sstr.size() + pos;


}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int MAX = 1e5 + 10;
const int mod = 1e9;
int N, M, Q, K;
vector<int> vec;
int dp[16100][8010], dest[2];
bool dflag[2];
 
int rec(int pos, int vi, int init){
    if(vi >= vec.size()){
        if(pos == dest[vi%2]) dflag[vi%2] = true;
        return 1;
    }
    int &ret = dp[pos][vi];
    if(ret != -1) return 1;
    dp[pos][vi] = 1;
    rec(pos + vec[vi], vi + 2, 0);
    if(!init) rec(pos - vec[vi], vi + 2, 0);
    return 1;
}
 
int main()
{
    int i, j, k;
    string s;
    cin >> s >> dest[0] >> dest[1];
 
    int pos = -1;
    int n= s.size();
    while(pos < n){
        int cnt = 0;
        while(pos < n && s[++pos] == 'F') cnt++;
        vec.push_back(cnt);
    }
 
    dest[0] += 8000; dest[1]+= 8000;
    memset(dp, -1, sizeof(dp));
    rec(8000, 0, 1);
    if(!dflag[0]){
        printf("No\n");
        return 0;
    }
    memset(dp, -1, sizeof(dp));
    rec(8000, 1, 0);
    if(!dflag[1]){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
}

Measured memory_bytes: 504192
object Main extends App {
    val lines = io.Source.fromInputStream(System.in).getLines()
    val s = lines.next()

    if (isStrongPalindrome(s)) {
        println("Yes")
    } else {
        println("No")
    }

    def isStrongPalindrome(s: String): Boolean = {
        def isPalindrome(s: String): Boolean = s.reverse == s
        val isPalindromeEntirely = isPalindrome(s)

        val n = s.length()
        val isPalindromeFirstHalf = isPalindrome(s.substring(0, (n - 1) / 2))
        val isPalindromeLatterHalf = isPalindrome(s.substring((n + 3) / 2 - 1))
        isPalindromeEntirely && isPalindromeFirstHalf && isPalindromeLatterHalf
    }
}


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

int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n,x,c=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x%2!=0&&i%2!=0)
        c++;
    }
    cout<<c<<endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int sx, sy, gx, gy;
    sx = 0; sy = 0;
    int st, gt;
    st = 0;
    rep(i, N) {
        cin >> gt >> gx >> gy;
        int x = abs(gx - sx);
        int y = abs(gy - sy);
        int t = gt - st;
        if ((t -x -y) %2 != 0 || (t - x - y) < 0){
            cout << "No" << endl;
            exit(0);
        }
        sx = gx; sy = gy; st = gt;
    }
    cout << "Yes" << endl;
}


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

namespace ProblemA
{
    class Program
    {
        static void Main()
        {
            var x = GetIntArray();

            for(int i = 0; i < x.Length; i++)
            {
                if(x[i] == 0)
                {
                    Console.WriteLine(i + 1);
                }
            }
        }

        //入力関係のメソッド
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();
        //出力関係のメソッド
        public static void OutIntArray(int[] values)
        {
            foreach (var value in values)
            {
                Console.WriteLine(value);
            }
        }
        public static void OutLongArray(long[] values)
        {
            foreach (var value in values)
            {
                Console.WriteLine(value);
            }
        }
        public static void OutList(List<object> list)
        {
            foreach (var value in list)
            {
                Console.WriteLine(value);
            }
        }

    }
}


Measured memory_bytes: 28296
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = list(rs())
if 'Y' in li:
  print('Four')
else:
  print('Three')




Measured memory_bytes: 27220
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int ans = 1;
    char pre = S.charAt(0);
    for (int i = 1; i < N; i++) {
      char cur = S.charAt(i);
      if (pre == cur) continue;
      pre = cur;
      ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 24332
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

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

  int ss = s.size(), cnt = 0;
  rep(i,ss){
    if(s[i] != t[i])  ++cnt;
  }

  cout << cnt << endl;
  return 0;
}


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

class UnionFind {
public:
    vector<int> rank, parent, size;

    UnionFind();
    UnionFind(int n) {
        rank.resize(n, 0);
        parent.resize(n, 0);
        size.resize(n, 0);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }

    bool same(int a, int b) {
        return root(a) == root(b);
    }

    void unite(int a, int b) {
        int x = root(a), y = root(b);
        if (rank[x] < rank[y]) swap(x, y);
        parent[y] = x;
        if (rank[x] == rank[y]) ++rank[x];
        size[x] += size[y];
    }

    int root(int x) {
        if (parent[x] != x) {
            parent[x] = root(parent[x]);
        }
        return parent[x];
    }

    long long island_num(int x) {
        return size[parent[x]];
    }
};

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

    int N, M; cin >> N >> M;
    UnionFind uf(N);

    vector< vector<int> > q(M, vector<int>(2, 0));
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; a--; b--;
        q[i][0] = a; q[i][1] = b;
    }

    vector<long long> convenience(M, 0);
    for (int i = M - 1; i >= 0; --i) {
        int a = q[i][0], b = q[i][1];
        if (uf.same(a, b)) {
            convenience[i] = 0;
        } else {
            convenience[i] = uf.island_num(a) * uf.island_num(b);
            uf.unite(a, b);
        }
    }

    long long inconvenience = 0;
    for (long long c : convenience) {
        inconvenience += c;
        cout << inconvenience << '\n';
    }

    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
map<int, int> divide(int n){//素因数分解
    map<int, int> res;
    for(int i = 2; i * i <= n; i++){
        while(n % i == 0){
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}
long long repow(long long x, long long y){
    if(y == 0) return 1;
    if(y % 2 == 0){
        long long t = repow(x, y /2);
        return t*t%MOD;
    }
    else return x*repow(x, y -1) %MOD;
}
int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    map<int, int> m;
    vector<map<int, int>> ve(N);
    for(int i = 0; i < N; i++){
        map<int, int> m2 = divide(A[i]);
        ve[i] = m2;
        for(auto v:m2){
            m[v.first] = max(m[v.first], v.second);
        }
    }
    long long lcm = 1;
    for(auto x: m){
        lcm *= repow(x.first, x.second);
        lcm %= MOD;
    }
    long long ans = 0;
    for(int i = 0; i < N; i++){
        ans += lcm *repow(A[i], MOD - 2);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3200
import java.util.Scanner;

class Main {
    static final long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 1;
        long[] cnt = new long[n + 1];
        for (int i = 2; i < n + 1; i++) {
            int tmp = i;
            int j = 2;
            while (tmp != 1) {
                while (tmp % j == 0) {
                    tmp = tmp / j;
                    cnt[j]++;
                }
                j++;
            }
        }
        for (int i = 1; i < n + 1; i++) {
            ans = ans * (cnt[i] + 1) % mod;
        }
        System.out.println(ans);
        sc.close();
    }
}

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

int main(){
  int n; cin >> n;
  vector<int> b(n);
  for(int i=0; i<n; ++i) cin >> b[i];
  
  stack<int> buf;
  int index = n-1;
  while(b.size() > 0){    
    if(index < 0){
      cout << -1 << endl;
      return 0;
    }
    if(b[index] == index+1){
      buf.push(b[index]);
      b.erase(b.begin() + index);
      index = b.size() - 1;
      continue;
    }
    --index;
  }
  
  for(int i=0; i<n; ++i){
    cout << buf.top() << endl;
    buf.pop();
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
vector< mp > dp;
vector< ll > a;
mp calc( ll i ){
    if( i == -1 ){
	return mp(0,-1);
    }
    return mp( a[i] , i );
}
mp calc( mp a , mp b ){
    set< mp > st;
    st.insert( calc( a.first ) );
    st.insert( calc( a.second ) );
    st.insert( calc( b.first ) );
    st.insert( calc( b.second ) );
    auto it = st.end();
    ll i,j;
    it--;
    i = it->second;
    it--;
    j = it->second;
    return mp(i,j);
}


int main(){
    ll n;
    cin>>n;
    a = vector<ll>( 1<<n , 0 );
    for(ll i=0;i<(1<<n);i++) cin>> a[i];
    dp = vector< mp >( 1<<n );// or で上から2つ
    for(ll i=0;i<(1<<n);i++) dp[ i ] = mp( i , -1 );
    for(ll i=1;i<(1<<n);i++){
	for(ll j=0;j<n;j++){
	    dp[i] = calc( dp[i] , dp[ i & ~(1<<j) ] ); 
	}
    }
    ll res = 0;
    for(ll i=1;i<(1<<n);i++){
	res = max(res, a[ dp[i].first ] + a[ dp[i].second ] );
	cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 9216
import java.util.Scanner;


public class Main {

    public static final String Y = "Yes";
    public static final String N = "No";
    public static final String I = "IMPOSSIBLE";
    public static final String B = "Bad";
    public static final String G = "Good";
    public static final long MOD = 1_000_000_007l;
    public static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        // n+1個の数値がある
        long n = nl();

        // k個以上を選択
        long k = nl();

        long sum = 0l;

        // 和としてあり得るものの個数をmod(10^9 + 7)で出力

        for (long i = k; i <= n + 1; i++) {
            sum += n * i - i * i + i + 1;
            sum %= MOD;
        }

        out(sum);

    }

    /*
     * 以下メソッド集
     */
    static int ni() {

        return sc.nextInt();
    }

    static long nl() {

        return sc.nextLong();
    }

    static String n() {

        return sc.next();
    }

    static char[] nc() {

        return sc.next().toCharArray();
    }

    static int kaijo(int n) {

        if (n == 0 || n == 1) {
            return 1;
        } else {
            return n * kaijo(n - 1);
        }
    }

    static int fib(int n) {

        return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
    }

    static long lcm(long m, long n) {

        return m * n / gcd(m, n);
    }

    static int lcm(int m, int n) {

        return m * n / gcd(m, n);
    }

    static long gcd(long a, long b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static int gcd(int a, int b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static void out(String info) {

        System.out.println(info);
    }

    static void out(int info) {

        System.out.println(info);
    }

    static void out(double info) {

        System.out.println(info);
    }

    static void out(long info) {

        System.out.println(info);
    }

    static void out(char info) {

        System.out.println(info);
    }

    static void outn(String info) {

        System.out.print(info);
    }

    static void outn(int info) {

        System.out.print(info);
    }

    static void outn(double info) {

        System.out.print(info);
    }

    static void outn(long info) {

        System.out.print(info);
    }

    static void outn(char info) {

        System.out.print(info);
    }

    static int max(int a, int b) {

        return Math.max(a, b);
    }

    static long max(long a, long b) {

        return Math.max(a, b);
    }

    static int min(int a, int b) {

        return Math.min(a, b);
    }

    static long min(long a, long b) {

        return Math.min(a, b);
    }
}

Measured memory_bytes: 35776
h, w = list(map(int, input().split()))
grid = [[0]*w for _ in range(h)]
for i in range(h):
  s = input()
  for j in range(len(s)):
    if s[j]=="#":
      grid[i][j]="#"
      for dx in range(-1, 2):
        for dy in range(-1, 2):
          if dx==0 and dy==0:
            continue
          nx, ny = j+dx, i+dy
          if 0<=nx<w and 0<=ny<h and grid[ny][nx]!="#":
            grid[ny][nx]+=1
for i in range(h):
  print("".join(map(str, grid[i])))

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

const int MNUM = 12;
const int ANUM = 0;
const int RNUM = 17;
const int CNUM = 2;
const int HNUM = 7;

int main(){
    int n;
    scanf("%d", &n);
    char name[15];
    vector<long long> abc(26);
    long long ans;

    for (int i = 0; i < n; i++)
    {
        scanf("%s", name);
        abc.at((name[0] - 'A'))++;
    }

    ans = (abc.at(MNUM) * abc.at(ANUM) * abc.at(RNUM)) +
          (abc.at(MNUM) * abc.at(ANUM) * abc.at(CNUM)) +
          (abc.at(MNUM) * abc.at(ANUM) * abc.at(HNUM)) +
          (abc.at(MNUM) * abc.at(RNUM) * abc.at(CNUM)) +
          (abc.at(MNUM) * abc.at(RNUM) * abc.at(HNUM)) +
          (abc.at(MNUM) * abc.at(CNUM) * abc.at(HNUM)) +
          (abc.at(ANUM) * abc.at(RNUM) * abc.at(CNUM)) +
          (abc.at(ANUM) * abc.at(RNUM) * abc.at(HNUM)) +
          (abc.at(ANUM) * abc.at(CNUM) * abc.at(HNUM)) +
          (abc.at(RNUM) * abc.at(CNUM) * abc.at(HNUM));

    cout << ans << endl;

    return 0;
}

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

using namespace std;

const int MAX_N = 20;
const int MAX_M = 2000;
const int MAX_Q = 200;
int n, A[MAX_N + 1], q, m[MAX_Q + 1];
bool dp[MAX_N + 1][MAX_M + 1], checked[MAX_N + 1][MAX_M + 1];

bool solve(int i, int m) {
    if (checked[i][m]) return dp[i][m];
    checked[i][m] = true;
    if (m == 0) return dp[i][m] = true;
    if (i >= n) return dp[i][m] = false;
    return dp[i][m] = solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main() {
    // memset(dp, -1, sizeof(dp));

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &m[i]);
    }

    for (int i = 0; i < q; i++) {
        if (solve(0, m[i])) puts("yes");
        else puts("no");
    }
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <algorithm>
#include <set>
using namespace std;
int main() {
	int N; cin >> N; 
	int A[100010] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	multiset<int> S;
	S.insert(-1145141919); S.insert(1145141919); 
	S.insert(A[0]); 
	for(int i = 1; i < N; i++){
		auto it = S.lower_bound(A[i]); 
		it--; 
		if(*it == -1145141919) S.insert(A[i]); 
		else{
			S.insert(A[i]); S.erase(it); 
		}
	}
	cout << (int) S.size() - 2 << endl; 
}

Measured memory_bytes: 5376
#include <iostream>

using namespace std;


int main()
{
int n,ac=0,wa=0,re=0,tle=0;
string stats;
cin>>n;
for(int i=0;i<n;i++){
    cin>>stats;
    if(stats=="AC"){ac++;}
    else if(stats=="WA"){wa++;}
    else if(stats=="RE"){re++;}
    else if(stats=="TLE"){tle++;}

}
cout<<"AC"<<" x "<<ac<<endl;
cout<<"WA"<<" x "<<wa<<endl;
cout<<"TLE"<<" x "<<tle<<endl;
cout<<"RE"<<" x "<<re<<endl;
    return 0;
}


Measured memory_bytes: 3208
//cara pikir 
//pake recursive tapi gak 3 x
// C++ program for implementation of Ford Fulkerson algorithm 
#include <iostream> 
#include <limits.h> 
#include <string.h> 
#include <queue> 
#include <iostream> 
#include <set> 
#include <iterator> 
#include <algorithm>
#include <map>
using namespace std;

int main() {
   
  string s;
  cin>>s;
  cout<<s[0]<<s.length()-2<<s[s.length()-1]<<endl;
   return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  if(a % 2 != b % 2 || b % 2 != c % 2 || c % 2 != a % 2) {
    if(a % 2 == b % 2) {
      a++;
      b++;
      ans++;
    } else if(b % 2 == c % 2) {
      b++;
      c++;
      ans++;
    } else {
      c++;
      a++;
      ans++;
    }
  }
  vector<int> s = {a, b, c};
  sort(s.begin(), s.end());
  ans += (s[2] - s[0]) / 2;
  ans += (s[2] - s[1]) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256