akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
 
using namespace std;
 
const long long int MOD = 1000000007;
 
long long int N, M, K, H, W, L, R;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> H >> W;
	vector<string>r(H);
	vector<string>c(W);
	for (int i = 0; i < H; i++) {
		cin >> r[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			c[j].push_back(r[i][j]);
		}
	}
	for (int i = 0; i < H; i++) {
		sort(r[i].begin(), r[i].end());
	}
	for (int i = 0; i < W; i++) {
		sort(c[i].begin(), c[i].end());
	}
 
	int rood = 0;
	vector<int>ro(13);
	for (int i = 0; i < H; i++) {
		int cnt = 0;
		for (int j = 0; j < H; j++) {
			if (r[i] == r[j]) {
				cnt++;
			}
		}
		ro[cnt]++;
	}
	int cood = 0;
	vector<int>co(13);
	for (int i = 0; i < W; i++) {
		int cnt = 0;
		for (int j = 0; j < W; j++) {
			if (c[i] == c[j]) {
				cnt++;
			}
		}
		co[cnt]++;
	}
	for (int i = 1; i <= 11; i += 2) {
		rood += ro[i] / i;
	}
	for (int i = 1; i <= 11; i += 2) {
		cood += co[i] / i;
	}
	if ((H & 1) < rood || (W & 1) < cood) {
		cout << "NO\n";
		return 0;
	}
	if ((!(H & 1) && rood) || (!(W & 1) && cood)) {
		cout << "NO\n";
		return 0;
	}
	if (H >= 7 && H < 9 && W >= 7 && W < 9 && ro[H] && co[W]) {
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int main() {
	int n;
	string str;
	string root;
	scanf( "%d", &n );
	while ( n-- ) {
		cin >> root;
		cin >> str;
		string copy_root = root;
		sort( copy_root.begin(), copy_root.end() );
		int move = ( upper_bound( copy_root.begin(), copy_root.end(), 'M' ) - lower_bound( copy_root.begin(), copy_root.end(), 'M' ) ) - ( upper_bound( copy_root.begin(), copy_root.end(), 'P' ) - lower_bound( copy_root.begin(), copy_root.end(), 'P' ) ) - 6;
		move %= 10;
		reverse( root.begin(), root.end() );
		for ( int i = 0; i < root.size(); i++ ) {
			if ( root[ i ] == 'A' ) {
				reverse( str.begin(), str.end() );
			}
			if ( root[ i ] == 'J' ) {
				str = str[ str.size() - 1 ] + str.substr( 0, str.size() - 1 );
			}
			if ( root[ i ] == 'C' ) {
				str = str.substr( 1, str.size() - 1 ) + str[ 0 ];
			}
			if ( root[ i ] == 'E' ) {
				if ( str.size() % 2 == 0 ) {
					str = str.substr( str.size() / 2, str.size() / 2 ) + str.substr( 0, str.size() / 2 );
				}
				else {
					str = str.substr( str.size() / 2 + 1, str.size() / 2 ) + str[ str.size() / 2 ] + str.substr( 0, str.size() / 2 );
				}
			}
		}
		for ( int i = 0; i < str.size(); i++ ) {
			if ( str[ i ] >= '0' && str[ i ] <= '9' ) {
				str[ i ] -= '0';
				str[ i ] += 10000;
				str[ i ] += move;
				str[ i ] %= 10;
				str[ i ] += '0';
			}
		}
		printf( "%s\n", str.c_str() );
	}
	return 0;
}

Measured memory_bytes: 1232
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
    
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
    map<string,int>M;
    string a,b,s;
    int A,B;cin>>a>>b>>A>>B;M[a]=A;M[b]=B;
    cin>>s;
    M[s]--;
    cout<<M[a]<<" "<<M[b]<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

int main(){
  int n;
  while(cin>>n,n){
    int ans=-1;
    M.clear();
    for(int i=0,a;i<n;i++){
      cin>> a;
      M[a]++;
      if(M[a]>n/2)ans=a;
    }
    if(ans==-1)cout <<"NO COLOR"<<endl;
    else cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	string S;
	cin >> S;

	REP(i, 1 << 4)
	{
		string a[4] = { "" };
		REP(j, 4)
		{
			if (i >> j & 1 == 1)
			{
				a[j] = 'A';
			}
		}
		string akb = a[0] + "KIH" + a[1] + 'B' + a[2] + 'R' + a[3];
		if (akb == S)
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m>>k;

	((n*100+m*10+k)%4==0) ?cout<<"YES"<<endl:cout<<"NO"<<endl;



}


Measured memory_bytes: 256
n,m,x,y = map(int, input().split())
x_lst = list(map(int, input().split()))
y_lst = list(map(int, input().split()))

flag = False
for i in range(-99, 101):
    if x < i and i <= y:
        for j in x_lst:
            if j < i:
                continue
            else:
                break
        else:
            for k in y_lst:
                if i <= k:
                    continue
                else:
                    break
            else:
                flag = True
                
print('No War') if flag else print('War')

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, w[101000];
long long S1[101000], S2[101000];
void Do(int b, int e) {
	if (b == e)return;
	if (b < e) {
		S1[1] += e - b;
		S1[b + 1] += b + 1;
		S2[b + 1]--;
		S2[e + 1]++;
		S1[e + 1] -= b + 1;
	}
	else {
		S1[1] += e - b + m;
		S2[b + 1]--;

		S1[b + 1] += b + 1;

		S2[1]--;
		S2[e + 1]++;
		S1[1] += b + 1 - m;
		S1[e + 1] -= b + 1 - m;
	}
}
int main() {
	int i;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++)scanf("%d", &w[i]);
	for (i = 1; i < n; i++)Do(w[i], w[i + 1]);
	long long s1 = 0, s2 = 0;
	long long res = 1e18;
	for (i = 1; i <= m; i++) {
		s1 += S1[i];
		s2 += S2[i];
		res = min(res, s2*i + s1);
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 2176
Module Module1

sub Main(ByVal args() as String)
    dim arr() as string = Split(Console.ReadLine())
    dim N as integer = arr(0)
    dim A as integer = arr(1)
    dim B as integer = arr(2)

    dim cnt as integer = 0
    for i as integer = 1 to N
        dim c as integer = i
        dim sum as integer = 0
        do until c = 0
            sum += c mod 10
            c = int(c/10)
        loop
        if A <= sum andalso sum <= B then
            cnt += i
        end if
    next i

    Console.WriteLine(cnt)
end sub

end Module

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
    ll X;
    std::cin >> X;
    
    auto five = [](ll x) {
        ll ret = x;
        ret *= ret;
        ret *= ret;
        return ret * x;
    };

    ll A = 0;
    ll A5 = 0;
    std::map<ll, ll> memo;
    memo[A5] = A;
    while(true) {
        ll B5 = std::abs(A5 - X);
        if(memo.count(B5) > 0) {
            ll B;
            if(A5 > X) {
                B = memo[B5];
            } else {
                B = -memo[B5];
            }
            std::cout << A << " " << B << std::endl;
            return 0;
        }
        ++A;
        A5 = five(A);
        memo[A5] = A;
    }
}


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

int main() {
    int N;
    cin >> N;
    int h = 0;
    int res = 0;
    for(int i=0; i<N; ++i) {
        int H;
        cin >> H;
        if(h <= H) ++ res;
        h = max(h, H);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

A, B, C, K = map(int, input().split())

if abs(A - B) > 10 ** 18:
    print("Unfair")
elif K % 2 == 0:
    print(A-B)
else:
    print(B-A)


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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;}

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

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

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

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

string code(const string& s, int64 k) {
  string res = s.substr(0, 1);
  REP(i, s.size()-1) {
    if (res.size() >= k) break;
    if (string("aiueo").find(s[i]) != string::npos) {
      res += s[i+1];
    }
  }
  return res;
}

int main(void) {
  int64 n;
  while (cin >> n && n) {
    vector<string> s(n);
    REP(i, n) {
      cin >> s[i];
    }
    int64 res = -1;
    FOR(i, 1, 51) {
      set<string> st;
      REP(j, n) {
        st.insert(code(s[j], i));
      }
      if (st.size() == n) {
        res = i;
        break;
      }
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 3172
Q = int(input())

def solve(x,ans):
    #X = str(x)
#    print(x,ans)
    if len(x) == 1:
        print(ans)
        return
    ret= 0
    for i in range(1,len(x)):
        n = int(x[i:]) * int(x[:i])
        ret = max(ret , n)
        
    #print(ret)
    return solve(str(ret),ans + 1)

for i in range(Q):
    solve(input(),0)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}


vector<vii> perm;

double dis(pii a,pii b)
{
  return sqrt( (a.fi-b.fi)*(a.fi-b.fi) + (a.se-b.se)*(a.se-b.se));
}
void clc(int i,int r,vii cur)
{
  if(i>=r)
  {
    perm.pb(cur);
    return;
  }
  
  forf(j,i,r)
  {
    swap(cur[j],cur[i]);
    clc(i+1,r,cur);
    swap(cur[j],cur[i]);
  }


}
void solve()
{
  
  int n;
  cin >> n;
  
  pii cord[n+1];


  forf(i,1,n+1)
  {
    cin >> cord[i].fi >> cord[i].se;
  }
  vii cur;

  forf(i,1,n+1) cur.pb(i);

  clc(0,n,cur);
  
  double an = 0;
  
  for(auto x:perm)
  {
    for(int j=1;j<sz(x);j++)
    {
      an += dis(cord[x[j]],cord[x[j-1]]);
    }
  }

  printf("%0.8f\n",(double)an/(double)sz(perm));

}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 7460
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define tzcnt __builtin_ctzl
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))

using namespace std;
typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename T>string join(V<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
mt19937 rnd; void set_rnd(){random_device r;rnd=mt19937(r());}
V<ll> fact, rfact; void set_fact(int n, ll m){fact.pb(1);rfact.pb(1);FOR(i,1,n+1)fact.pb(fact[i-1]*i%m),rfact.pb(modPow(fact[i],m,m-2));}
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 2e5+1;
int n;
ll r[N], l[N], L;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> L >> n;
  FOR(i, 1, n+1) cin >> r[i];
  ll ans = max(L-r[1], r[n]);
  FOR(i, 1, n+1) l[i] = l[i-1] + L - r[n+1-i];
  FOR(i, 1, n+1) r[i] += r[i-1];
  FOR(j, 1, n+1){
    int i;
    i = j;
    maxs(ans, l[n-i]*2+r[i]+r[i-1] - (n>=i*2 ? l[n-i*2] : r[i*2-n-1]) * 2);
    i = n-j+1;
    maxs(ans, r[n-i]*2+l[i]+l[i-1] - (n>=i*2 ? r[n-i*2] : l[i*2-n-1]) * 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    static int n = 0;
    static long[] ai = null;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        ai = new long[n];
        for(int i=0; i<n; i++) {
            ai[i] = in.nextLong();
        }
        Arrays.sort(ai);
        PriorityQueue<ABC173DTuple> queue = new PriorityQueue<>(n);
        long ans = 0;
        ABC173DTuple firstTuple = new ABC173DTuple();
        firstTuple.a = ai[n-1];
        firstTuple.b = ai[n-1];
        queue.add(firstTuple);
        for(int i=n-2; i>=0; i--) {
            long nextVal = ai[i];
            ABC173DTuple toBeDecoupled = queue.poll();
            ans += toBeDecoupled.score();
            ABC173DTuple nextT1 = new ABC173DTuple();
            nextT1.a = toBeDecoupled.a;
            nextT1.b = nextVal;
            queue.add(nextT1);
            ABC173DTuple nextT2 = new ABC173DTuple();
            nextT2.a = toBeDecoupled.b;
            nextT2.b = nextVal;
            queue.add(nextT2);
        }
        System.out.println(ans);
    }
}
class ABC173DTuple implements Comparable<ABC173DTuple> {
    long a;
    long b;
    public long score() {
        return Math.min(this.a, this.b);
    }
    
    @Override
    public int compareTo(ABC173DTuple o) {
        long diff = this.score() - o.score();
        diff *= -1;
        return (diff>0 ? 1 : (diff<0 ? -1 : 0));
    }
}

Measured memory_bytes: 63948
#include<bits/stdc++.h>
using namespace std;
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
typedef long long ll;
#define vi vector<int>

int main(){
	int a,b,c;cin>>a>>b>>c;
	map<int,int> mp;
	mp[a]++;mp[b]++;mp[c]++;
	if(mp[5]==2 && mp[7]==1)cout<<"YES";
	else cout<<"NO";
}


Measured memory_bytes: 256
# include "cstdio"
# include "iostream" 
# include "cmath" 

using namespace std;

int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0; 
} 

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

int main(){
  int N;
  cin >> N;
  int min = 40;
  for (int i = 0; i < N; i++){
    int A;
    cin >> A;
    int count = 0;
    while (A % 2 == 0){
      A /= 2;
      count ++;
    }
    if (min > count)
      min = count;
  }
  cout << min << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
    int n, m, xx, yy;
    cin >> n >> m >> xx >> yy;

    vector<int> x(n), y(m);

    for(int i=0;i<n;i++) {
        cin >> x.at(i);
    }

    for(int i=0;i<m;i++) {
        cin >> y.at(i);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    bool check = false;

    if(x.end()<y.begin()) {
        for(int i=x.at(n-1)+1;i<=y.at(0);i++) {
            if(xx<i && i<=yy) check = true;
        }
    }

    if(check == true) cout << "No War" << endl;
    else cout << "War" << endl;
}


Measured memory_bytes: 256
#! /usr/bin/python
# -*- coding: utf-8 -*-

"""Chinese Postman Problem."""

import sys

f_i = sys.stdin

V, E = map(int, f_i.readline().split())

# adjacency matrix
no_edge = 14001

adj = [[no_edge] * V for i in range(V)]

for i in range(V):
    adj[i][i] = 0

odd_b = 0 # bit DP to record odd vertex

ans = 0

# acceptance of input
for l_i in f_i:
    s, t, d = map(int, l_i.split())
    t_d = min(d, adj[s][t])
    adj[s][t] = t_d
    adj[t][s] = t_d
    odd_b ^= 1 << s
    odd_b ^= 1 << t
    ans += d

# A function to check if the number of 1 is odd in binary notation
def odd_one(n):
    ans = 0
    while n:
        ans ^= (n & 1)
        n >>= 1
    return ans

import math

if odd_b:
    # Warshall???Floyd Algorithm
    for k in range(V):
        for i in range(V):
            for j in range(V):
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j])
                
    # Minimum weighted matching
    mw = [no_edge] * (odd_b + 1)
    mw[0] = 0
    digits = int(math.log2(odd_b)) + 1

    for b in range(odd_b):
        if odd_one(b):
            continue
        for i in range(0, digits):
            if not (b & (1 << i)):
                for j in range(i + 1, digits):
                    if not (b & (1 << j)):
                        t_b = b + (1 << i) + (1 << j)
                        if t_b == t_b & odd_b:
                            t_w = mw[t_b]
                            mw[t_b] = min(t_w, mw[b] + adj[i][j])

    # Output
    ans += mw[odd_b]
    print(ans)
else:
    print(ans)

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

using namespace std;

int main()
{
   int n, k;
   string s;

   cin >> n;
   cin >> s;
   cin >> k;

   char moji = s[k-1];

   for(int i=0;i<n;i++){
      if(s[i] != moji) s[i] = '*';
   }

   cout << s << endl;

   return 0;
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        switch (Console.ReadLine())
        {
            case "25":
                Console.WriteLine("Christmas");
                break;
            case "24":
                Console.WriteLine("Christmas Eve");
                break;
            case "23":
                Console.WriteLine("Christmas Eve Eve");
                break;
            case "22":
                Console.WriteLine("Christmas Eve Eve Eve");
                break;
        }
    }
}

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

using namespace std;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;


int main()
{
    int n;
    cin >>n;
    bool fl = false;
    while(n){
        if(n%10 == 7) fl = true;
        n /= 10;
    }
    cout << (fl? "Yes\n": "No\n");

    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x, y;
  cin >> x >> y;
  
  bool can = false;
  for (int i = 0; i <= x; i++) {
    if (2 * i + 4 * (x - i) == y) can = true;
  }
  
  if (can) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3005;
const ll mod = 998244353;
int n, s;
ll a[N], dp[N];
ll fast_pw(ll x, ll y) {
    ll ret = 1;
    for(;y;y>>=1) {
        if(y&1) ret = (ret * x) % mod;
        x = (x * x) % mod;
    }
    return ret;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> s;
    for(int i = 0; i < n; i++) cin >> a[i];
    dp[0] = fast_pw(2, n);
    ll inv = fast_pw(2, mod - 2);
    for(int i = 0; i < n; i++) {
        for(int j = s; j >= a[i]; j--) {
            dp[j]+=(dp[j-a[i]]*inv)%mod;
            dp[j]%=mod;
        }
    }
    cout << dp[s];
    return 0;
}

Measured memory_bytes: 3708
#include<stdio.h>
int main()
{
    int a;
    scanf("%d",&a);
    int b[a],d,e=1,f;
    for(d=0;d<a;d++)
        scanf("%d",&b[d]);
        f=a;
    for(d=1;d<a;d++)
        if(b[d]>b[d-e])
        {
            f--;
            e++;
        }
        else e=1;
        printf("%d\n",f);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <string>

int main()
{
  int n;
  std::cin >> n;

  std::unordered_map<int,int> map;

  std::vector<int> v;
  for (int i = 0; i < n; i++) {
    int val;
    std::cin >> val;
    v.push_back(val);
    auto search = map.find(val);
    if (search != map.end()) search->second += 1;
    else map[val] = 1;
  }

  std::unordered_map<int,long> answers;

  long total = 0;
  for (auto it : map) {
    total += (long)(it.second-1) * it.second / 2;
  }

  for (auto it : map) {
    int v = it.first;
    answers[v] = total - (it.second - 1);
  }

  for (int i = 0; i < n; i++) {
    printf("%ld\n", answers[v[i]]);
  }

  return 0;
}


Measured memory_bytes: 15292
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;


int calc(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}


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

	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		int digitSum = calc(i);
		if (A <= digitSum && digitSum <= B) {
			ans += i;
		}
	}
	cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < n;i++)

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

    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    ll N;
    cin >>N;
    vector<P> arms(N);
    rep(i,N){
        ll x,l;
        cin >>x>>l;
        arms[i] = make_pair(x+l,x-l);
    }
    sort(all(arms));
    ll ans = 1;
    ll end = arms[0].first;
    rep2(i,1,N){
        if(arms[i].second >= end){
            end = arms[i].first;
            ans++;
        }
    }
    cout << ans<<endl;

}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int main() {
    char str[21];
    int i, len;
    cin>>str;
    len = strlen(str);
    for (i = len-1; i >= 0; i--)
    	cout<<str[i];
    cout<<endl;
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<ll> A(n+1),B(n);
	for(int i =  0;i<n+1;i++)cin >> A[i];
	for(int i = 0;i<n;i++)cin >> B[i];
	ll ans = 0;
	for(int i = 0;i<n;i++)
	{
		if(B[i]-A[i]>=0)
		{
			ans += A[i];
			B[i]-=A[i];
			if(B[i]-A[i+1]>=0)
			{
				ans+=A[i+1];
				A[i+1]=0;
			}
			else
			{
				ans+=B[i];
				A[i+1]-=B[i];
			}
		}
		else
		{
			ans+=B[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {

    int r, D, x2000;

    cin >> r >> D >> x2000;

    vector<int> xs(1);
    xs[0] = (x2000 * r) - D;

    for (int i = 0; i < 9; i++) {
      int x;
        x = (xs[i] * r) - D;
        xs.push_back(x);
    }

    for (int i = 0; i < xs.size(); i++) {
        cout << xs[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int n=1e5+10;
bitset<n> isprime;
vector<int>answer;
void sieve()
{
    isprime[0]=isprime[1]=0;
    for(int p=2; p<=n; ++p)
        if(isprime[p])
            for(int m=2*p; m<n; m+=p)
                isprime[m]=0;

}


int the2017ers[n];
void is2017()
{
    int sum=0;
    for (int p=1; p<=n; p++)
    {
        if(isprime[p]&&isprime[(p+1)/2]){
            sum++;
        }
        //sum+=(isprime[p]&&isprime[(p+1)/2]);
        the2017ers[p]=sum;

    }

}

int main()
{

    isprime.set();
    sieve();
    is2017();
    int tc,l,r;
    cin>>tc;
    while(tc--)
    {
        cin>>l>>r;
        cout<<the2017ers[r]-the2017ers[l-1]<<endl;
    }


    return 0;
}


Measured memory_bytes: 1024
h, w = map(int, input().split())
a_array = [input() for x in range(h)]
black = [[False for x in range(w)] for y in range(h)]
next = set()
for row in range(h):
    for column in range(w):
        if a_array[row][column] == "#":
            black[row][column] = True
            next.add((row, column))

move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
cnt = 0
while next:
    tmp = set()
    # print(next)
    cnt += 1
    for row, column in next:
        for i, j in move:
            if not (0 <= row + i < h and 0 <= column + j < w) or black[row+i][column+j]:
                continue
            black[row+i][column+j] = True
            tmp.add((row + i, column + j))
    next = tmp
print(cnt-1)


Measured memory_bytes: 123608
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}

int v[101],w[101];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,W;
	cin>>N>>W;
	rep(i,N)cin>>v[i]>>w[i];
	vvi dp(N+1,vi(W+1,0));
	rep(i,N){
		rep(j,W+1){
			if(j-w[i]>=0)
				dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
			else
				dp[i+1][j]=dp[i][j];
		}
	}
	/*rep(i,N){
		rep(j,W+1)p(dp[i][j]);
		cout<<endl;
	}*/
	P(dp[N][W])
	return 0;
}

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

int main()
{
    int H,W;
    while(1)
    {
         scanf("%d %d",&H,&W);
         if(H == 0 && W == 0)
              exit(0);
         for(int i=0;i<H;i++)
         {
              for(int j=0;j<W;j++)
              {
                   if(j==0||j==W-1||i==0||i==H-1){
                   printf("#");
                   }else {
                   printf(".");
                   }
              }
              printf("\n");
         }
         printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<ll> a;
    ll tp;
    for(int i=0;i<n;i++) {
        cin >> tp;
        a.push(tp);
    }
    vector<pair<ll, ll> > v(m);
    for(int i=0;i<m;i++) cin >> v[i].second >> v[i].first;
    sort(v.begin(), v.end(), greater<pair<ll,ll> >());
    ll cnt = 0;
    ll pt = 0;
    ll ans = 0;
    while(cnt != n){
        if(v[pt].first < a.top()){
            cnt++;
            ans += a.top();
            a.pop();
        }else{
            ans += min(v[pt].second, n-cnt) * v[pt].first;
            cnt +=  min(v[pt].second, n-cnt);
            pt++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
#define FAST ios_base::sync_with_stdio(false);
#define INPT cin.tie(NULL);
#define OUTPT cout.tie(NULL);
#define fori(i,a,b) for(i=a;i<b;i++)
#define forireverse(i,a,b) for(i=a;i>=b;i--)
#define full(x) x.begin(),x.end()
#define sortV(x) sort(full(x))
#define sortVgr(x) sort(full(x),greater<LL>()) // x -> vector
#define reverse(x) reverse(full(x)) // x -> string
#define go(t) while(t--)
#define endl cout<<"\n"
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define M 1e9+7

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

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("inputAtC.txt","r",stdin);
	freopen("outputAtC.txt","w",stdout);
	#endif
	FAST INPT OUTPT
	LL t=1;
	//cin>>t;
	go(t)
	{
		LL d,s,tt;
		cin>>d>>tt>>s;
		LL k=s*tt;
		if(k >= d) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3652
n, x = map(int, input().split())
l = list(map(int, input().split()))
x_0 = 0
for i in range(n):
    x_0 += l[i]
    if x_0 > x:
        print(i + 1)
        break
    elif n == i + 1:
        print(i + 2)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,q;
  cin >> n >> q;
  vector<vector<int>> G(n);
  vector<ll> value(n, 0);
  REP(i,n-1){
    int a,b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  REP(i,q){
    int p,x;
    cin >> p >> x;
    value[p-1] += (ll)x;
  }
  vector<int> seen(n, 0);
  queue<int> que;
  que.push(0);
  while(!que.empty()){
    int v = que.front();
    seen[v] = 1;
    que.pop();
    for(auto nv: G[v]){
      if(seen[nv]==0){
      	value[nv] += value[v];
      	que.push(nv);
      }
    }
  }
  REP(i,n) cout << value[i] << " ";
  return 0;
}


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

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    int p=1;
    for (int i=0; i<m; i++){
        p*=2;
    }
    printf ("%d\n",(1900*m+100*(n-m))*p);
	return 0 ;
}

Measured memory_bytes: 128
from collections import defaultdict as dd
N = int(input())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
res = 1
MOD = 10**9+7
dic = dd(int)
for i in range(1,N+1):
    f = factorize(i)
    for val in f:
        dic[val] += 1
for val in dic.values():
    res = res*(val+1)%MOD
print(res)


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 200013
#define INF 1000000000000000000LL
#define MOD 1000000007LL
#define IINF 1000000000
#define mp make_pair
#define pb push_back
#define remove pop
#define all(x) x.begin(), x.end()

int main() {
	if (fopen("FILENAME.in", "r")) {
		freopen("FILENAME.in", "r", stdin);
		freopen("FILENAME.out", "w", stdout);
	}
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);

	int n;
	string s;
	cin >> n >> s;

	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}

	bool bad = false;
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[i + n / 2]) {
			bad = true;
		}
	}

	if (!bad) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

//GCD GCD GCD USE GCD IN MATH

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

int A, B;

void _main() {
  cin >> A >> B;
  if (B%A == 0) cout << (A + B) << "\n";
  else cout << (B - A) << "\n";
}

Measured memory_bytes: 256
import collections

N = int(input())
S = input()

m = 0
index = 0
for i in range(N):
    a = set(S[:i])
    b = set(S[i:])
    
    common_char = a & b
    if len(common_char) > m:
        m = len(common_char)
        index = i
print(m)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int main()
{
	long long h, w;

	std::cin >> h >> w;

	std::vector<std::string> v(h);

	for (size_t i = 0; i < h; i++)
	{
		std::cin >> v[i];
	}

	int x[] = { -1, 0 , 1, -1, 0 , 1, -1, 0 , 1 };
	int y[] = { -1, -1, -1, 0 , 0, 0, 1, 1, 1 };

	for (size_t i = 0; i < h; i++)
	{
		for (size_t j = 0; j < w; j++)
		{
			if (v[i][j] == '#') continue;
			int count = 0;
			for (size_t k = 0; k < 9; k++)
			{
				int xpos = j + x[k];
				int ypos = i + y[k];

				if (xpos < 0 || xpos >= w || ypos < 0 || ypos >= h) continue;

				if (v[ypos][xpos] == '#') {
					count++;
				}
			}
			v[i][j] = (char)('0' + count);
		}
	}

	for (size_t i = 0; i < h; i++)
	{
		std::cout << v[i] << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,x[100],m,a,i;
	scanf("%d", &n);
	for(i=1; i<=n; i++)
	scanf("%d", &x[i]);
	scanf("%d", &m);
	for(i=0; i<m; i++)
	{
		scanf("%d", &a);
		if(x[a]+1!=x[a+1]&&x[a]<2019)
		x[a]++;
	}
	for(i=1; i<=n; i++)
	printf("%d\n", x[i]);
	
	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
  int main(){
    long long int N;
    cin >> N;
   long long int sum = 0;
   for(long long int i = 1; i <= N; i++) {
      if(i % 3 != 0 && i % 5 != 0) {
      sum += i;
   }
   }

   cout << sum;
 return 0;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; ; i++) {
        int j = S.size() - 1 - i;
        cerr << i << " " << j << endl;
        if(j <= i) break;
        if(S[i] != S[j]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )
 
#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
 
 
void solve()
{
	int k=0,a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0 && c>0){
		if(k%2==0)
			c=c-b;
		else
			a=a-d;
		k++;
	}
	if(a<=0)
		cout<<"No\n";
	else
		cout<<"Yes\n";
}
int  main() 
{
	auto start=clock();
	fast_io;
    int t=1;
    //cin>>t;
    while(t--)
    	solve();
    auto stop =clock();
    cerr<<"time taken:"<<double(stop-start)/double(CLOCKS_PER_SEC)<<" s"<<endl;
	return 0; 
}

Measured memory_bytes: 3704
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long ans = Long.MAX_VALUE;
		
		for (long a = 1; a*a <= n; a++) {
			if (n%a==0) {
				long b = n / a;
				long calc = f(a,b);
				ans = Math.min(ans,calc);
			} else {
				continue;
			}
		}
		System.out.println(ans);
		
		sc.close();
	}
	
	static int f (long a, long b) {
		long max = Math.max(a,b);
		String str = String.valueOf(max);
		return str.length();
	}
	
}


Measured memory_bytes: 21844
#include<stdio.h>

int main(){
  int w = 0;
  int c = 0;
  int hoge = 0;
  scanf("%d %d",&w,&c);
  if(w-2*c > 0 ){
    printf("%d",w-2*c);
  }else{
    printf("0");
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N, L; cin >> N >> L;
  ll a[N]; rep(i,N) cin >> a[i];
  rep(i,N-1) {
    if (a[i]+a[i+1]>=L) {
      cout << "Possible" << endl;
      rep(j,i) cout << j+1 << endl;
      rep(j,N-i-2) cout << N-1-j << endl;
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 1536
H, W, D = map(int, input().split())
px = [0] * (H*W+1)
py = [0] * (H*W+1)
d = [0] * (H*W+1)

for i in range(H):
    A = list(map(int, input().split()))
    for j, a in enumerate(A):
        px[a] = i
        py[a] = j

for i in range(D+1, H*W+1):
    d[i] = d[i-D] + abs(px[i]-px[i-D]) + abs(py[i]-py[i-D])

for i in range(int(input())):
    L, R = map(int, input().split())
    print(d[R]-d[L])

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

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

int gcd(int a, int b, int c) {
    return gcd(a, gcd(b,c));
}

int main() {
    int K;
    cin >> K;
    long long res = 0LL;
    for(int a = 1; a <= K; ++a) {
        for(int b = 1; b <= K; ++b) {
            for(int c = 1; c <= K; ++c) {
                res += gcd(a,b,c);
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

typedef long long ll;

const double PI = acos(-1);
int main() {
    long double a, b, x;
    cin >> a >> b >> x;
    long double ans;
    if(a*a*b/2 < x) {
        auto y = 2 * (a*a*b - x) / (a*a);
        ans = (long double)atan2(y, a)/PI*180;
    } else {
        auto y = 2*x / (b*a);
        ans = (long double)atan2(b, y)/PI*180;
    }

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, l, a[100005] = {};
    cin >> n >> l;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i < n; i++) if (a[i] + a[i + 1] >= l) {
        cout << "Possible\n";
        for (int j = 1; j < i; j++) cout << j << '\n';
        for (int j = n - 1; j >= i; j--) cout << j << '\n';
        return 0;
    }
    cout << "Impossible\n";
}


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

int main() {
    int n, a;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        mp[a]++;
    }
    if (n == mp.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 9600