akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    string s;
    cin >> s;
    ll c = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'o')
            c++;
    }
    if (c + (15 - s.size()) >= 8)
        cout << "YES"
             << "\n";
    else
        cout << "NO"
             << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L,R;
    cin >> L >> R;
    ll v1 = L % 2019;
    ll v2 = R % 2019;
    ll v[2020] = {};
    ll pos = 0;
    ll val = L;
    while(pos < 2020){
        if(val > R) break;
        v[val % 2019]++;
        val++;
        pos++;
    }
    vector<ll> tt;
    rep(i,0,2019){
        if(v[i] != 0) tt.push_back(i);
    }
    sort(tt.begin(), tt.end());
    ll ans = INF;
    ll n = tt.size();
    rep(i,0,n){
        rep(j,0,n){
            if(i >= j) continue;
            ans = min(ans, (tt[i] * tt[j]) % 2019);
        }
    }
    print(ans);


    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int d;
  cin >> d;
  d=25-d;
  cout << "Christmas ";
  if(d){
    for(int i=0;i<d;i++){
      cout << "Eve ";
    }
  }
  cout << "\n" << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<assert.h>

typedef long long ll;

int main() {
    int n, m, p[100001] = {0};
    char s, tmp;
    scanf("%d%d", &n, &m);
    for (size_t i = 0; i < m; i++)
    {
        int w;
        scanf("%d %c%c", &w, &s, &tmp);
        if (p[w] >= 0) {
            if (s == 'A')
            {
                p[w] = ~p[w];
            }
            else
            {
                p[w]++;
            }
        }
    }

    int sum = 0;
    int cnt = 0;
    for (size_t i = 0; i < 100001; i++)
    {
        if (p[i] < 0)
        {
            sum += ~p[i];
            cnt++;
        }
    }
    
    printf("%d %d", cnt, sum);
}


Measured memory_bytes: 512
N=int(input())

ans=100000000
now=0

for i in range(1,int(N**0.5) +2):
    if N%i !=0:
        continue
    else:
        A=i
        B=int(N/A)
        now =max(len(str(A)),len(str(B)))
        ans =min(ans,now)
    
print(ans)

Measured memory_bytes: 9376
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[100000+1];
 
ll f(ll n,ll a[],ll k)
{
	if(dp[n]!=-1)
	return dp[n];
	
	ll t=INT_MAX;
	
	for(ll i=1;i<=k;i++)
	{
	    if((n-i)>0)
	    {
	        ll c=abs(a[n]-a[n-i])+f(n-i,a,k);
	        if(c<t)
	        t=c;
	    }
	    
	    else
	    break;
	}
	
	dp[n]=t;
	
	return dp[n];
}
 
int main()
{
	ll n,k;
	cin>>n>>k;
	
	ll a[n+1];
	
	for(ll i=0;i<=100000;i++)
	dp[i]=-1;
	
	
	a[0]=0;
	for(ll i=1;i<=n;i++)
	cin>>a[i];
	
	dp[0]=0;
	dp[1]=0;
	
    cout<<f(n,a,k)<<endl;
    
}

Measured memory_bytes: 9600
N=int(input())
cntAB=0
llA=0
flB=0
flag=True
for i in range(N):
  s=input()
  cntAB+=s.count('AB')
  if s[-1]=='A': llA+=1
  if s[0]=='B': flB+=1
  if (s[-1]=='A') ^ (s[0]=='B'): flag=False

if flag: cntAB+=max(llA-1,0)
else: cntAB+=min(llA,flB)

print(cntAB)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a%b) : a;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 500010;
//const int MAXM = 100010;
const int MAXK = 30;
//const i64 INF = 1000000000000000000LL;
const int INF = 1000000000;
//const int MOD = 998244353;
const int B = 31;
const int MOD = 998244353;
//const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

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

#define rep(i,a,b) for (int i = (a), I = (b); i <= I; ++ i)

int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool leap(int y)
{
	return y%4 == 0 && y%100 != 0 || y%400 == 0;
}

int n, m;
int a[MAXN];
vector<int> v[MAXN];

void solve()
{
	cin >> n;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
	}
	int ret = 0;
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j < i; ++ j)
			ret += a[i]*a[j];
	cout << ret << endl;
}

int main()
{
	
	int T;
	T = 1;
	//scanf("%d", &T);
	while (T --)
	solve();
	
	return 0;
}


Measured memory_bytes: 12544
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<ll>> matA(n, vector<ll>(m));
    vector<vector<ll>> matB(m, vector<ll>(l));
    vector<vector<ll>> matC(n, vector<ll>(l));
    rep(i, n) {
        for (auto &e : matA[i]) {
            cin >> e;
        }
    }
    rep(i, m) {
        for (auto &e : matB[i]) {
            cin >> e;
        }
    }
    rep(i, n) {
        rep(k, l) {
            rep(j, m) { matC.at(i).at(k) += matA.at(i).at(j) * matB.at(j).at(k); }
        }
    }
    rep(i, n) {
        rep(k, l) {
            if (k) cout << " ";
            cout << matC[i][k];
        }
        cout << "\n";
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

namespace program
{
    class Program
    {
        static void Main()
        {
          string s = Input.ScanStr();
          string t = Input.ScanStr();
          if(s[0]==t[2] && s[1]==t[1] && s[2]==t[0])
          Console.WriteLine("YES");
          else
            Console.WriteLine("NO");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
def cumsum(s):
    n = len(s)
    cs = [0] * (n+1)
    for i in range(n):
        cs[i+1] = cs[i] + s[i]
    return cs

n = int(input())
a = list(map(int, input().split()))

cs = cumsum(a)
ans = float("inf")
for i in range(n+1):
    ans = min(ans, abs(cs[i] - (cs[n] - cs[i])))
print(ans)

Measured memory_bytes: 26220
#include<stdio.h>
#include<stdlib.h>
#define N 2000000
#define NIL 2000000000
 
int A[N];
int hs = 0;
 
void maxHeap(int i){
  int l, r, lar;
  int temp;
  l = 2*i;
  r = 2*i+1;
  if(l <= hs && A[l] > A[i]) lar = l;
  else lar = i;
  if(r <= hs && A[r] > A[lar]) lar = r;
  if(lar != i){
    temp = A[i];
    A[i] = A[lar];
    A[lar] = temp;
    maxHeap(lar);
  }
}
void change(int i, int key){
  int temp;
  A[i] = key;
  while(i > 1 && A[i/2] < A[i]){
    temp = A[i];
    A[i] = A[i/2];
    A[i/2] = temp;
    i /= 2;
  }
}
 
void insert(int key){
  hs++;
  A[hs] = NIL;
  change(hs, key);
}
 
int extract(void){
  int max;
  max = A[1];
  A[1] = A[hs];
  hs--;
  maxHeap(1);
  return max;
}
 
int main(){
  int k;
  char word[10];
  while(1){
    scanf("%s", word);
    if(word[0] == 'i'){
      scanf("%d", &k);
      insert(k);
    }
    if(word[0] == 'e' && word[1] == 'x') printf("%d\n", extract());
    if(word[0] == 'e' && word[1] == 'n') break;
  }
return 0;
}

Measured memory_bytes: 4692
#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"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

void Search(const vector<vector<int>>&edge, const vector<int>&depth, vector<int>&sum, vector<int>&num, vector<int>&mini, const string&s, int node) {
	if (s[node] == '1')num[node] = 1;
	for (auto i : edge[node]) {
		if (depth[i] < depth[node])continue;
		Search(edge, depth, sum, num, mini, s, i);
		num[node] += num[i];
		sum[node] += num[i] + sum[i];
	}
	for (auto i : edge[node]) {
		if (depth[i] < depth[node])continue;
		if (sum[node] < (num[i] + sum[i]) * 2) {
			mini[node] = max(0, (mini[i] + num[i]) * 2 - (sum[node]-(sum[i]-mini[i])));
		}
	}
	return;
}

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

	cin >> N;
	string s;
	cin >> s;
	vector<vector<int>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> L >> R;
		L--;
		R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	int ans = MOD;
	for (int i = 0; i < N; i++) {
		vector<int>depth(N, MOD);
		Calculate_Depth(edge, depth, i);
		vector<int>sum(N);
		vector<int>num(N);
		vector<int>mini(N);
		Search(edge, depth, sum, num, mini, s,i);
		if (mini[i]||(sum[i]&1))continue;
		ans = min(ans, sum[i] / 2);
	//	cout << "node " << i << endl;
	//	for (int j = 0; j < N; j++) {
	//		cout << j << " " << sum[j] << " " << num[j] << " " << mini[j] << endl;
	//	}
	//	cout << i << " " << ans << endl;
	}
	if (ans == MOD)ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    var (X, N) = readLine()!!.split(" ").map{ it.toInt() }
    val pList = readLine()!!.split(" ")

    var count = 0
    while(true){
        if(!pList.contains((X-count).toString())) {
            X = X-count
            break
        }
        if(!pList.contains((X+count).toString())) {
            X = X+count
            break
        }
        count++
    }
    
    println(X)
}


Measured memory_bytes: 36472
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		string str2 = Console.ReadLine();
		string ans = "No";
		for(var i=0;i<str.Length;i++){
			int t = 0;
			for(var j=0;j<str.Length;j++){
				if(str.Substring(j,1) != str2.Substring((i+j)%str.Length,1)){
					t = 1;
					break;
				}
			}
			if(t == 0){
				ans = "Yes";
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <stdio.h>

int main (void){


	char strS[101];
	char strZ[201];
	char strP[101];
	int ans = 0 ;		//??????????????° P?????????????????¨???????????????1??????????????????
	int fans = 0 ;

	int i = 0;		//???????????°
	int j = 0;		//?????????s?????????
	int k = 0;

	scanf("%s", strS);				//?????????S???????????????

	/*?????????strS?????????????????????*/
	for(i = 0 ; i < 102 ; i++){
		if(strS[i] == '\0'){
			j = i;
			break;
		}
	}

	/*?????????S?????¨?????¶?????????*/
	k = 0;
	for(i = 0 ; i < 200 ; i++){
		if(strS[k] == '\0'){		//\0?????????????????????????????????
			k -= j;
		}
		strZ[i] = strS[k];
		k++;
	}

		strZ[200] = '\0';			//\0??????????????§?£????

//		printf("%s\n",strZ);			//strZ??????????????????????????????


	scanf("%s", strP);				//?????????P???????????????

	/*?????????????????????????????????????????????????????°??????*/
	for( k =  0 ; k < 100 ; k++){
		ans = 0 ;											//k????????????????????????????????????ans???????????????
		for( i = 0 ; strP[i] != '\0' && ans == 0 ; i++){
			if( strZ[ i + k ] != strP[i] ){
				ans = 1 ;
				}
		}
		if(!ans){		//????????§??????????????????????????????Yes??????????????????
			fans = 1 ;
		}
	}

	/*????????¨???*/
	if(fans){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;

}

Measured memory_bytes: 524
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<17, mod = 1e9 + 7, i2 = (mod+1)/2;
ll n, k, f[maxn];
vector<int> divs;
ll bp(ll a, ll p) {
	ll r = 1;
	while(p) {
		if(p&1) r = r*a%mod;
		a = a*a%mod, p>>=1;
	}
	return r;
}

int p[maxn], b[maxn];
int cycl(string s) {
	int i = 0, j = -1; b[0] = -1;
	while(i < s.size()) {
		while(j != -1 && s[i] != s[j]) j = b[j];
		i++, j++;
		b[i] = j;
	}
	int t = s.size() - b[s.size()];
	return s.size()%t ? s.size() : t;
}
void brute(int n, int k) {
	map<int, int> cnt;
	set<string> vis;
	int tn = n;
	n = (n+1)/2;
	
	while(true) {
		string s, t;
		for(int i = 0; i < n; i++) s.pb(p[i]+'a');
		t = s;
		if(tn&1) t.pop_back();
		reverse(all(t));
		s += t;
		
		int ok = 1;
		string u = s + s;
		for(int i = 0; i < tn; i++)  ok &= !vis.count(u.substr(i, tn));
		vis.insert(s);
		
		if(ok) {
			cnt[cycl(s)]++;
			if(cycl(s) == 2) cout << s << '\n';
		}
		int add = 1;
		for(int i = 0; add && i < n; i++)
			((++p[i] == k) ? p[i] : add) = 0;
		if(add) break;
	}
	for(auto i : cnt) cout << i.first << " " << i.second << '\n';
	//return ans.size();
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k;
	//cout << brute(n, k) << '\n';
	//return 0;
	for(int i = 1; i*i <= n; i++) {
		if(n%i) continue;
		divs.pb(i);
		if(n/i != i) divs.pb(n/i);
	}
	sort(all(divs));
	for(int i = 0; i < divs.size(); i++) {
		f[i] = bp(k, (divs[i]+1)/2);
		if(divs[i]%2 == 3) {
			int t = divs[i]/2;
			t = (t+1)/2;
			f[i] = (f[i] + bp(k, t))*i2%mod;
		}
		//cout << divs[i] << " " << f[i] << '\n';
	}
	for(int i = 0; i < divs.size(); i++) {
		
		for(int j = i+1; j < divs.size(); j++) {
			if(divs[j]%divs[i]) continue;
			f[j] = (mod + f[j] - f[i])%mod;
			//if(divs[i] > 1 && (divs[j]/divs[i])%2 == 0)
			//f[j] = (mod + f[j] - f[i]))%mod;
		}
	}
	ll ans = 0;
	for(int i = 0; i < divs.size(); i++) {
		if(divs[i]%2 == 0) f[i] = f[i]*i2%mod;
		ans = (ans + divs[i] * f[i])%mod;
	}
	cout << ans << '\n';
	//brute(n, k);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

long long median(vector<long long> &a){
    // sort(a.begin(), a.end());
    long long size = a.size();
    long long ret;
    if(size % 2 == 0){
        ret = a[size / 2 - 1] + a[size / 2];
    }
    else{
        ret = a[(size + 1) / 2 - 1] * 2;
    }
    // cout << ret << endl;
    return ret;
}

int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> ab(n);
    vector<ll> minmed(n), maxmed(n);
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
        minmed[i] = a;
        maxmed[i] = b;
    }

    sort(minmed.begin(), minmed.end());
    sort(maxmed.begin(), maxmed.end());
    ll mimed, mamed;
    mimed = median(minmed);
    mamed = median(maxmed);

    // cout << mimed << endl;
    // cout << mamed << endl;

    long long ans = 0;
    if(n % 2 == 0){
        ans = mamed - mimed + 1;
    }
    else{
        ans = (mamed - mimed) / 2 + 1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (int)(s); i < (int)(e); ++i)
#define per(i,s,e) for(int i = (int)(s)-1; i >= (int)(e); --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  int x; cin >> x;
  if(x == 1 || x == 2*n-1){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    vector<int> v;
    rep(i,1,2*n){
      v.push_back(i);
    }
    swap(v[n-1],v[x-1]);
    swap(v[n-2],v[0]);
    swap(v[n],v[2*n-2]);
    for(auto&e:v)cout << e << endl;
  }  
  return 0;
}


Measured memory_bytes: 2420
n=int(input())
a=list(map(int,input().split()))
a.sort()
ctr=1
ln=[]
for i in range(n-1):
    if a[i]==a[i+1]:
        ctr+=1
    elif a[i]!=a[i+1]:
        ln.append([a[i],ctr])
        ctr=1
ln.append([a[n-1],ctr])
ans=0
for k in range(len(ln)):
    if ln[k][0]>ln[k][1]:
        ans+=ln[k][1]
    else:
        ans+=ln[k][1]-ln[k][0]
print(ans)


Measured memory_bytes: 16760
#include <bits/stdc++.h>
const int mod=998244353;
using namespace std;
int n;
char a[300010];
int main(){
	int RG=0,GB=0,RB=0,R=0,G=0,B=0,phi,ans=1;
	scanf("%d",&n),phi=n,n*=3;
	scanf("%s",a+1);
	for(int i=1;i<=n;i++){
		if(a[i]=='R'){
			if(GB) ans=1ll*ans*GB%mod,GB--;
			else if(G) ans=1ll*ans*G%mod,G--,RG++;
			else if(B) ans=1ll*ans*B%mod,B--,RB++;
			else ans=1ll*ans*phi%mod,phi--,R++;
		}
		if(a[i]=='G'){
			if(RB) ans=1ll*ans*RB%mod,RB--;
			else if(R) ans=1ll*ans*R%mod,R--,RG++;
			else if(B) ans=1ll*ans*B%mod,B--,GB++;
			else ans=1ll*ans*phi%mod,phi--,G++;
		}
		if(a[i]=='B'){
			if(RG) ans=1ll*ans*RG%mod,RG--;
			else if(R) ans=1ll*ans*R%mod,R--,RB++;
			else if(G) ans=1ll*ans*G%mod,G--,GB++;
			else ans=1ll*ans*phi%mod,phi--,B++;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512
import java.util.*;
import java.util.HashSet;
import java.util.Set;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int y=sc.nextInt();
        if(((x==1)||(x==3)||(x==5)||(x==7)||(x==8)||(x==10)||(x==12))&&((y==1)||(y==3)||(y==5)||(y==7)||(y==8)||(y==10)||(y==12))){
            System.out.println("Yes");
        }
        else if(((x==4)||(x==6)||(x==9)||(x==11))&&((y==4)||(y==6)||(y==9)||(y==11))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        

        }
       
        
    }

Measured memory_bytes: 20688
// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0)
    cout<<(a+b)/2;
    else
    cout<<(a+b)/2+1;
    cout<<endl;
}

Measured memory_bytes: 384
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=5;
int cnt[maxn];

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	rep(i,3){
		int a,b;
		cin>>a>>b;
		cnt[a]++;cnt[b]++;
	}
	int mx=0;
	REP(i,4)mx=max(mx,cnt[i]);
	cout<<((mx==3)?"NO":"YES")<<endl;
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,c;
    cin>>n>>m>>c;
    int ara[m],cnt=0,i,x;
    for(i=0;i<m;i++)
        cin>>ara[i];
    while(n--)
    {
        int sum=c;
        for(i=0;i<m;i++)
        {
            cin>>x;
            sum+=(x*ara[i]);
        }
        if(sum>0)cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  s = new Array();
  var mas =0;
  for(i=0;i<n;i++){
    s[i]=parseInt(input[i+1]);
    mas+=s[i];
  }
  if(mas%10==0){
    s.sort(function(a,b){
            if( a > b ) return -1;
            if( a < b ) return 1;
            return 0;
    });
    for(i=n-1;i>=0;i--){
      if(s[i]%10!=0){
        mas-=s[i];
        break;
      }
    }
  }
  if(mas%10==0){
    mas=0;
  }
  var ans =mas;
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import heapq
t=int(input())
for _ in range(t):
    n,a,b,c,d=map(int,input().split())
    dp=dict()
    dp[n]=0
    que=[[0,n]] # [cost, present_number]

    def dp_revise(x,v):
        if x not in dp.keys():
            dp[x]=v
            return True
        elif dp[x]>v:
            dp[x]=v
            return True
        else: 
            return False

    while que:
        p=heapq.heappop(que)
        if p[1]==0: 
            break
        x=p[1]
        r2=x%2
        v=min(a+r2*d, d*(x//2+r2))+dp[x] # compare doA or doD to reach x//2
        if dp_revise(x//2,v):
            heapq.heappush(que,[v,x//2])
        if r2!=0:
            v=min(a+d, d+d*(x//2+1))+dp[x] # compare doA or doD to reach x//2
            if dp_revise(x//2+1,v):
                heapq.heappush(que,[v,x//2+1])
        r3=x%3
        v=min(b+r3*d, d*(x//3)*2+r3*d)+dp[x] # compare doB or doD to reach x//3
        if dp_revise(x//3,v):
            heapq.heappush(que,[v,x//3])
        if r3!=0:
            v=min(b+(3-r3)*d, d*(x//3+1)*2+(3-r3)*d)+dp[x] # compare doB or doD to reach x//3
            if dp_revise(x//3+1,v):
                heapq.heappush(que,[v,x//3+1])
        r5=x%5
        v=min(c+r5*d, d*(x//5)*4+r5*d)+dp[x] # compare doC or doD to reach x//5
        if dp_revise(x//5,v):
            heapq.heappush(que,[v,x//5])
        if r5!=0:
            v=min(c+(5-r5)*d, d*(x//5+1)*4+(5-r5)*d)+dp[x] # compare doC or doD to reach x//5
            if dp_revise(x//5+1,v):
                heapq.heappush(que,[v,x//5+1])
            
    print(dp[0])

Measured memory_bytes: 91820
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val A = IntArray(N) { sc.next().toInt() }
        val Asorted = A.sorted()
        val R = Array(2) { mutableSetOf<Int>() }
        for (i in 0 until N) R[i % 2].add(Asorted[i])
        var ans = 0
        for (i in 0 until N) {
            if (!R[i % 2].contains(A[i])) ans++
        }
        pw.println(ans / 2)
    }
}


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

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>>grid(h,vector<char>(w));
    rep(i,h)rep(j,w)cin>>grid[i][j];
    const int dx[4]={1, 0, -1, 0};
    const int dy[4]={0, 1, 0, -1};
    bool ans=true;
    rep(i,h)rep(j,w){
        if(grid[i][j]=='#'){
            bool found=false;
            for (int dir = 0; dir < 4; ++dir) {
                int nh = i + dx[dir];
                int nw = j + dy[dir];

                if (nh >= 0 && nh < h && nw >= 0 && nw < w && grid[nh][nw]=='#'){
                    found=true;
                }
            }
            if(!found)ans=false;
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,x;
	cin >> n >> x;
	int m[n];
    int sum=0;

	for (int i=0; i<n; i++) {
		cin>>m[i];
        sum+=m[i];
	}
    sort(m,m+n);

    int count=n;
    while(true){
        sum+=m[0];
        count++;
        if(x<sum){
            count--;
            break;
        }
    }


	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
d=[]
for i in range(10):
  l=list(map(int,input().split()))
  d.append(l)
for k in range(10):
  for i in range(10):
    for j in range(10):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ans=0
for i in range(H):
  l=list(map(int,input().split()))
  for j in l:
    if j==-1:
      continue
    ans+=d[j][1]
print(ans)


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  string s;
  vector<pair<int, int>> ans;
  Solver(string n) : n(n.size()), s(n){};

  void solve() {
    DBG(s)
    if (s.back() != '0' || s[0] == '0') {
      cout << -1 << endl;
      return;
    }
    DBG(s)
    s.pop_back();
    string r = s;
    reverse(r.begin(), r.end());
    DBG(s, r)
    if (r != s) {
      cout << -1 << endl;
      return;
    } else {
      int now = 2;
      int j = n / 2;
      for (; j >= 1; --j) {
        if (s[j - 1] == '1') break;
      }
      DBG(j)
      if (j == 1) {
        for (int i = 2; i <= n; ++i) {
          cout << "1 " << i << endl;
        }
        return;
      }
      addEdge(1, 2);
      for (int i = 2; i < j; ++i) {
        addEdge(now, i + 1);
        if (s[i - 1] == '1') {
          now = i + 1;
        }
      }
      DBG(now, ans)
      if (n == 2) {
      } else if (n % 2 == 0) {
        ans.emplace_back(now, n + 1 - now);
        for (int i = j + 1; i <= n + 1 - (j + 1); ++i) {
          ans.emplace_back(now, i);
        }
      } else {
        ans.emplace_back(now, j + 1);
        ans.emplace_back(n + 1 - now, j + 1);
        for (int i = j + 2; i <= n + 1 - (j + 1); ++i) {
          ans.emplace_back(j + 1, i);
        }
      }
    }
    for (int i = 0; i < ans.size(); ++i) {
      cout << ans[i].first << ' ' << ans[i].second << endl;
    }
  }
  void addEdge(int x, int y) {
    ans.emplace_back(x, y);
    ans.emplace_back(n + 1 - x, n + 1 - y);
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  std::string n;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 2628
/**
 * shell sort
 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

void insertionSort(int a[], int n, int g, int & cnt)
{
  for(int i = g; i < n; ++i){
    //show
    //for(int i = 0; i<n ; ++i){ cout << a[i] <<" "; }
    // cout << endl;
    // cout << "cnt: " << cnt << endl;
    // cout << "g:   " << g << endl;
    // cout << "---" <<endl;
    
    int v = a[i];
    int j = i - g;

    while(j >= 0 && a[j] > v){
      a[j+g] = a[j];
      j = j - g;
      ++cnt;
    }
    a[j+g] = v;
  }
}


int main()
{
  const int N_max = 1000000;
  int N;
  int cnt = 0;
  int a[N_max];
  cin >> N;
  for(int i = 0; i<N ; ++i){
    cin >> a[i];
  }

  
  int k=1;
  int pow_2_k = 2;
  vector<int> G;
  while(pow_2_k - 1 <= N){
    G.push_back(pow_2_k - 1);
    ++k;
    pow_2_k *= 2;
  }

  reverse(G.begin(), G.end());
  int m = G.size();

  for(int i = 0; i < m; ++i){
    insertionSort(a, N, G[i], cnt);
  }


  //output
  //L1
  cout << m <<endl;
  //L2
  for(int i = 0; i<m ; ++i){
    cout << (i==0? "" : " ")  << G[i];
  }
  cout << endl;
  //L3
  cout << cnt << endl;
  //L4 - 
  for(int i = 0; i<N ; ++i){ cout << a[i] <<endl; }

  return 0;
}

Measured memory_bytes: 5128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

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

  bool flag=false;
  for(int i=1;i<10;i++){
    if(n%i==0 && n/i<10) flag=true;
  }

  if(flag) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	int n,ans = 0,a[20],b[20],c[20];
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> a[i]; }
	for (int i = 0; i < n; i++) { cin >> b[i]; }
	for (int i = 0; i < n - 1; i++) { cin >> c[i]; }

	ans += b[a[0] - 1];
	for (int i = 1; i < n; i++)
	{
		ans += b[a[i] - 1];
		if (a[i - 1] + 1 == a[i]) { ans += c[a[i - 1] - 1]; }
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    int a[5];

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    int n,cnt=1,i=0;
    cin >>n;
    while (n) {
        i++;
        int x = n % 10;
        a[i] = x;
        n /= 10;
        if (i == 1)
            continue;
        if (x == a[i-1])
            cnt++;
        else
            cnt = 1;
        if (cnt >= 3) {
            cout <<"Yes";
            return 0;
        }
    }
    cout <<"No";



    return 0;
}


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

int main() {

char C[3][3];

for(int i=0;i<3;i++){
   for(int j=0;j<3;j++)
   cin>>C[i][j];
}
cout<<C[0][0]<<C[1][1]<<C[2][2]<<endl;
}

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

int s[100][100][100] = {};

int main() {
	int n;
	cin >> n;
	int b[100];
	for(int y = 0; y < n; y++) {
		for(int x = 0; x < n; x++) cin >> b[x];
		for(int x1 = 0; x1 < n; x1++) {
			s[y][x1][x1] = b[x1];
			for(int x2 = x1+1; x2 <= n; x2++) {
				s[y][x1][x2] = s[y][x1][x2-1] + b[x2];
			}
		}
	}
	int ans = -10000*10000-1;
	for(int y1 = 0; y1 < n; y1++) {
		for(int x1 = 0; x1 < n; x1++) {
			for(int x2 = x1; x2 < n; x2++) b[x2] = 0;
			for(int y2 = y1; y2 < n; y2++) {
				for(int x2 = x1; x2 < n; x2++){
					b[x2] += s[y2][x1][x2];
					ans = max(ans, b[x2]);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
set<pa> S;
bool u[500010];
int n,a[500010],ans;
int UP(int x){
	int t=1;
	while (t<=x) t<<=1;
	return t;
}
int main(){
	cin>>n;
	FOR(i,1,n) getint(a[i]);
	sort(a+1,a+n+1);
	FOR(i,1,n) S.insert(mp(a[i],i));
	FORD(i,n,1){
		if (u[i]) continue;
		S.erase(S.find(mp(a[i],i)));
		int t=UP(a[i])-a[i];
		if (S.lower_bound(mp(t,0))==S.end()) continue;
		pa tmp=*S.lower_bound(mp(t,0));
		if (tmp.fi!=t) continue;
		u[tmp.se]=1;
		++ans;
		S.erase(S.find(tmp));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	int w;
	cin >> s;
	cin >> w;
	vector<string> a((s.size() + w - 1) / w);
	int tmp = 0;
	int counter = 0;
	for (int i = 0; i < s.size(); i++) {
		if (i - counter == w) {
			tmp++;
			counter += w;
		}
		a[tmp] += s[i];
	}
	for (int i = 0; i < (s.size() + w - 1) / w; i++) {
		cout << a[i].at(0);
	}
	cout << endl;
 	return 0;
}

Measured memory_bytes: 256
from sys import stdin
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
max_cnt = 0
cnt = 0
for i in range(len(s) - len(t) + 1):
    cnt = 0
    for j in range(len(t)):
        if s[i + j] in t[j]:
            cnt += 1
    if max_cnt < cnt:
        max_cnt = cnt
print(len(t) - max_cnt)

Measured memory_bytes: 73152
#include <stdio.h>
int i;

int main(void)
{
    int a[10000],N,cnt=0;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<N;i++)
    {
        while(a[i]%2==0)
        {
            a[i]/=2;
            cnt++;
        }
    }
    
    printf("%d",cnt);
    
    
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, i, j, k, x;
	cin >> n >> k;
	vector<bool> valid(10, true);
	for (i = 0; i < k; i++) {
		cin >> x;
		valid[x] = false;
	}

	for (i = n;; i++) {
		string s = to_string(i);
		bool ok = true;
		for (auto ch : s) {
			if (!valid[ch - '0']) {
				ok = false;
				break;
			}
		}
		if (ok) {
			cout << i << "\n";
			break;
		}
	}	

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
char ch[100][100],v;
int n ,m,s;
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>ch[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(ch[i][j]=='.')
            {
                if(ch[i][j+1]=='#')s++;
                if(ch[i][j-1]=='#')s++;
                if(ch[i+1][j]=='#')s++;
                if(ch[i+1][j+1]=='#')s++;
                if(ch[i+1][j-1]=='#')s++;
                if(ch[i-1][j]=='#')s++;
                if(ch[i-1][j+1]=='#')s++;
                if(ch[i-1][j-1]=='#')s++;
                v=s+'0';
                ch[i][j]=v;
            }
            s=0;
        }
    }
for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cout<<ch[i][j];
        }
        cout<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
int A[100100];
int ans[100100];
int key[100100];
int main() {
	int N, K, Q; cin >> N >> K >> Q;
	REP(i, N) {
		ans[i] = K - Q;
		key[i] = 0;
	}
	REP(i, Q) {
		cin >> A[i];
		A[i]--;
		key[A[i]]++;
	}
	REP(i, N) {
		ans[i] += key[i];
	}
	REP(i, N) {
		if (ans[i] <= 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	return 0;
}

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

const int INF = 1000000000;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;		// ????????°

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(T[i][j]>T[i][k]+T[k][j]){
						T[i][j]=T[i][k]+T[k][j];
					}
				}
			}
		}

		int min=0;
		int total,num;

		for(int i=0;i<m;i++){
			min+=T[0][i];
		}

		for(int i=1;i<m;i++){
			total=0;
			for(int j=0;j<m;j++){
				total+=T[i][j];
			}
			if(min>total){	
				min=total;
				num=i;
			}
		}
		
		cout<<num<<' '<<min<<endl;

	}

	return 0;
}

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

using namespace std;

int main(){
int N, X; cin >> N >> X;
  vector<int> D(N); int min_weight = 1e6; int sum = 0; int cnt = 0;
  for(int i = 0; i < N; i++){
    int c ; cin >> c; D[i] = c; min_weight = min(min_weight,c); sum += c;}
  
 int  rem = X - sum; cnt += N;
  
 cnt += rem / min_weight; 
  
  cout << cnt << 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++)
#define all(v) v.begin(), v.end()
int main(){
  long long a, b, c; cin >> a >> b >> c;
  long long d = c-a-b;
  if (d>0 && d*d>4*a*b){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<string.h>

#define MAX 1000

using namespace std;

typedef unsigned long long ull;

int H,W,R,C;
char field[MAX][MAX]; 
char pattern[MAX][MAX]; 

ull hashh[MAX][MAX],temp[MAX][MAX];
ull target;


void compute_hash(char a[MAX][MAX], int n, int m){
	const ull B1=9973;
	const ull B2=100000007;
	
	ull t1=1;
	for(int i=0;i<C;i++) t1*=B1;
	
	for(int i=0;i<n;i++){
		ull e=0;
		for(int j=0;j<C;j++) e=e*B1+a[i][j];
		for(int j=0;C+j<=m;j++){
			temp[i][j]=e;
			e=e*B1-t1*a[i][j]+a[i][j+C];
		}
	}
	ull t2=1;
	for(int i=0;i<R;i++) t2*=B2;
	for(int j=0;j+C<=m;j++){
		ull e=0;
		for(int i=0;i<R;i++) e=e*B2+temp[i][j];
		for(int i=0;i+R<=n;i++){
			hashh[i][j]=e;
			e=e*B2-t2*temp[i][j]+temp[i+R][j];
		}
	}
}

void solve(){
	compute_hash(pattern,R,C);
	target=hashh[0][0];
	compute_hash(field,H,W);
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(target==hashh[i][j])
			printf("%d %d\n",i,j);
		}
	}
}

int main(){
	scanf("%d %d",&H,&W);
	cin.ignore();
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			scanf("%c",&field[i][j]);
		}
		cin.ignore();
	}
	scanf("%d %d",&R,&C);
	cin.ignore();
	for(int i=0;i<R;i++){
		for(int j=0;j<C;j++){
			scanf("%c",&pattern[i][j]);
		}
		cin.ignore();
	}
	if(H>=R&&W>=C)
	solve();
}



Measured memory_bytes: 19760
#include<bits/stdc++.h>
#include<climits>
 
using namespace std;
 
#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
typedef long long int lld; 
 
lld n,a[100001],dp[100001];
 
//TOP-DOWN
lld frogOne(lld n){
    lld c=INT_MAX;
    if(n==2) return dp[n]=min(abs(a[n]-a[0]),abs(a[n]-a[1])+abs(a[1]-a[0]));
    if(n==1) return dp[n]=abs(a[n]-a[0]);
    if(n==0) return dp[n]=0;
    if(dp[n]!=-1) return dp[n];  
    c=min(frogOne(n-1)+abs(a[n-1]-a[n]),frogOne(n-2)+abs(a[n-2]-a[n]));
    return dp[n]=c;
}
 
 
int main(){
    fast;
    cin.tie(0);
    lld i,j;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<frogOne(n-1)<<endl;
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            //ここから
            int[] str = IO.ReadLineToIntArray();
            int N = str[0];
            int K = str[1];

            long ans = 0;
            if (2*N < K)
            {
                Console.WriteLine(0);
                return;
            }
            if (K % 2 == 0)
            {
                ans += (long)Math.Pow((N - K/2) / K + 1, 3);
            }
            ans += (long)Math.Pow(N / K, 3);
            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
    
    class Func
    {
        long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }
        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    class IO
    {
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }   
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
void insertion_sort(int n,int a[])
{
    int i,j,h;
    for(i=1;i<=n-1;i++)
    {
        for(h=0;h<n;h++)
        {
            if(h>0)
                printf(" ");
            printf("%d",a[h]);
        }
        printf("\n");
        int v=a[i];
        j=i-1;
        while(j>=0&&a[j]>v)
        {
            a[j+1]=a[j];
            j--;
            a[j+1]=v;
        }
    }
     for(h=0;h<n;h++)
        {
            if(h>0)
                printf(" ");
            printf("%d",a[h]);
        }
        printf("\n");
}
int main()
{
    int i,n,a[101];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
        insertion_sort(n,a);
        return 0;
}



Measured memory_bytes: 2132