akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define boostIO                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, b, a) for (int i = b; i >= a; i--)
#define sz(v) (v.empty() ? 0 : v.size())
#define all(v) v.begin(), v.end()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define trav(a, x) for (auto &a : x)
#define fi first
#define se second
#define pb push_back
#define int long long
#define mod 1000000007
#define rem 998244353
#define maxn 500005
const int INF = 1e18;
typedef pair<int, int> pii;


signed main() {
    boostIO;
    string s;
    cin >> s;
    int sum = 0;
    for(int i = 0; i < s.length(); i++){
        sum += (s[i] - '0');
    }
    if(sum % 9 == 0){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}
// XD

Measured memory_bytes: 3768
import numpy as np

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

x = np.array(x)

y = np.sort(x)

left = y[n//2 - 1]
right = y[n//2 ]

for i in range(n):
    if x[i] <= left:
        print(right)
    else:
        print(left)

Measured memory_bytes: 34184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		boolean can = true;
		while (s.length() != 0) {
			String x = String.valueOf(s.charAt(0));
			int tmp = s.length();
			s = s.replace(x, "");
			if ((tmp - s.length()) % 2 != 0) {
				can = false;
				break;
			}
		}

		if (can) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}

}


Measured memory_bytes: 35600
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <limits>
#include <numeric>

#define el '\n'
typedef long long ll;

using namespace std;



class DSU{
	public:
	 vector<int> siz, par;


	 DSU(int n){
	 	this -> siz.resize(n, 1);
	 	this -> par.resize(n);
	 	for (int i = 0; i < n; i++){
	 		this -> par[i] = i;
	 	}
	 }


	 void _union(int a, int b){
	 	int pa = this -> _get(a),
	 		pb = this -> _get(b);
 		if (pa == pb) return ;
 		if (this -> siz[pa] > this -> siz[pb]){
 			this ->  siz[pa] += this ->  siz[pb];
 			par[pb] = pa;
 		} else {
 			this ->  siz[pb] += this -> siz[pa];
 			par[pa] = pb;
 		}

	 }

	 int _get(int ell){
	 
	 	return this -> par[ell] = (this -> par[ell] == ell ? ell : this -> _get(this -> par[ell])); 
	 }


	 bool _chech(int a, int b){
	 	return this -> _get(a) == this -> _get(b);
	 }
};


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin >>n>>m;
	bool a;
	int u,v;
	DSU *ds = new DSU(n);
	for(int i = 0; i < m; i++){
		cin >>a>>u>>v;
		if (!a){
			ds -> _union(u,v);
		} else {
			if (ds -> _chech(u,v)) {
				cout << 1 << el;
			} else {
				cout << 0 << el;
			}
		}
	}
}

Measured memory_bytes: 4576
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;



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

  ll ans = 0;

  ll pow2[61] = {1};
  for(int i = 1;i <= 60;i++)pow2[i] = 2LL * pow2[i-1];

  vector<vector<ll>> now_01sum(60,vector<ll>(2,0));
  for(ll i = 0;i < N;i++){
    ll A;
    cin >> A;
    for(ll j = 0;j < 60;j++){
      if(A % 2 == 1){
	ans += (pow2[j] % MOD) * (now_01sum[j][0] % MOD);
	ans %= MOD;
	now_01sum[j][1]++;
      }	
      else{
	ans += (pow2[j] % MOD) * (now_01sum[j][1] % MOD);
	ans %= MOD;
	now_01sum[j][0]++;
      }
      A/=2;
    }
  }

  cout << ans << endl;
}

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

int fa[100001];

struct edge
{
	int a,b;
}e[100001];

long long ans[100001],sz[100001];

int findfa(int x)
{
	if(x==fa[x]) return x;
	return fa[x]=findfa(fa[x]);
}



int main()
{
	int n,m,i;
	cin>>n>>m;
	int a[m],b[m];
	for(i=1;i<=m;i++)
		cin>>e[i].a>>e[i].b;
	
	for(i=1;i<=n;i++)
	{
		fa[i]=i;
		sz[i]=1;
	}
	
	ans[m]=(long long)n*(n-1)/2;
	
	int u,v;
	for(i=m;i>=1;i--)
	{
		u=findfa(e[i].a);
		v=findfa(e[i].b);
		if(u==v)
			ans[i-1]=ans[i];
		else
		{
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u];
			fa[u]=v;
		}
	}
	
	for(i=1;i<=m;i++)
		cout<<ans[i]<<endl;
	return 0;
}

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


int main(){
  cout<<fixed<<setprecision(10);
  
  int N;cin>>N;
  vector<pair<int,int>>p(N);
  vector<int>v(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i).first>>p.at(i).second;
    v.at(i)=i;
    //cout<<p.at(i).first<<" "<<p.at(i).second;
  }
  double s=0;
  int count=0;
  do{
    for(int i=0;i<N-1;i++){
      double d1=p.at(v.at(i+1)).first-p.at(v.at(i)).first;
      double d2=p.at(v.at(i+1)).second-p.at(v.at(i)).second;
      s+=sqrt(d1*d1+d2*d2);
    }
    //cout<<v.at(0)<<endl;
    count++;
  }while (next_permutation(v.begin(), v.end()));
  cout<<s/count<<endl;
  //cout<<s;
}

Measured memory_bytes: 256
x = int(input())
a = 34
b = 10

# 冪乗数一覧
list_val = []
for i in range(1,a):
    for j in range(2,b):
        if i ** j <= 1000:
            list_val.append(i ** j)
        else:
            break

list_val = list(set(list_val))
list_val.sort()

# 一番近い数字をprint
import bisect

insert_index = bisect.bisect_left(list_val,x)

if list_val[insert_index] == x:
    print(x)
else:
    print(list_val[insert_index-1])

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int Ma = in.nextInt();
		int Mb = in.nextInt();
		int[] a = new int[N], b = new int[N], c = new int[N];
		for(int i=0;i<N;i++){
			a[i] = in.nextInt();
			b[i] = in.nextInt();
			c[i] = in.nextInt();
		}
		int[][][] dp = new int[41][401][401];
		for(int i=0;i<dp.length;i++)
			for(int j=0;j<dp[i].length;j++)
				for(int k=0;k<dp[i][j].length;k++)
					dp[i][j][k] = 5000;
		dp[0][0][0] = 0;
		for(int i=0;i<N;i++){
			for(int j=0;j<dp[i].length;j++){
				for(int k=0;k<dp[i][j].length;k++){
					if(dp[i][j][k] >= 5000) continue;
					dp[i+1][j][k] = Math.min(dp[i+1][j][k], dp[i][j][k]);
					dp[i+1][j+a[i]][k+b[i]] = Math.min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
				}
			}
		}
		int min = 5000;
		for(int j=0;j<dp[0].length;j++){
			for(int k=0;k<dp[0][j].length;k++){
				if(Ma*1.0/Mb == j*1.0/k)
					min = Math.min(min, dp[N][j][k]);
			}
		}
		System.out.println(min == 5000 ? -1 : min);
	}
}


Measured memory_bytes: 41532
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	string s;
	cin >> s;

	int N = s.size();

	rep(i,N-1){
		if(s[i] == s[i+1]){
			cout << (i+1) << " " << (i+2) << endl;
			return 0;
		} 
	}

	rep(i,N-2){
		if(s[i] == s[i+2]){
			cout << (i+1) << " " << (i+3) << endl;
			return 0;
		} 
	}

	cout << "-1 -1" << endl;
}

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

const long long int mod=1e9+7;


long long int dfs(const vector<vector<int>> &graph, int K, int now, int from) {
    int usable_color_num;

    if (from == -1) {
        // Child of the root node (only one color is already used).
        usable_color_num = K - 1;
    } else {
        usable_color_num = K - 2;
    }

    if (K < graph[now].size()) {
        // Impossible case.
        return 0;
    } else {
        long long int case_num = 1;
        for (auto e : graph[now]) {
            // Computation on each depth.
            if (e == from) continue;
            case_num *= usable_color_num;
            usable_color_num--;
            case_num %= mod;
        }
        for (auto e : graph[now]) {
            // Go down into one deeper depth.
            if (e == from) continue;
            case_num *= dfs(graph, K, e, now);
            case_num %= mod;
        }
        return case_num;
    }
}


int main() {
    int N, K; cin >> N >> K;
    vector<vector<int>> graph(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b; cin >> a >> b; a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    long long int answer = K * dfs(graph, K, 0, -1);  // K: color choice of the root node.
    answer %= mod;

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 11520
import bisect
from collections import OrderedDict
def resolve():
    N, C = list(map(int, input().split()))
    P = []
    cal = [0]
    for i in range(N):
        x, v = list(map(int, input().split()))
        P.append(x)
        cal.append(cal[i]+v)
    
    to_right = [0]
    for i in range(N):
        to_right.append(max(to_right[i], cal[i+1]-P[i]))
    to_left = [0]
    for i in range(N):
        to_left.append(max(to_left[i], cal[N]-cal[N-i-1]-(C-P[-i-1])))
    right_left = 0
    for i in range(N-1):
        right_left = max(right_left, cal[i+1]+to_left[N-i-1]-2*P[i])
    left_right = 0
    for i in range(N-1):
        left_right = max(left_right, cal[N]-cal[N-i-1]+to_right[N-i-1]-2*(C-P[-i-1]))
    print(max(to_right+to_left+[right_left, left_right]))

    
if '__main__' == __name__:
    resolve()


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

using namespace std;

typedef long long ll;

const int MAXN = 505;

ll v[MAXN][MAXN];
bool not_prime[2000005];
vector<int> p;

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
  return x / gcd(x, y) * y;
}

int main() {
  int n;
  cin >> n;
  if(n == 2) {
    puts("4 7");
    puts("23 10");
    return 0;
  }
  not_prime[1] = 1;
  for(int i = 2; i <= 2000000; i++) {
    if(!not_prime[i]) {
      p.push_back(i);
      for(int j = i + i; j <= 2000000; j += i) {
        not_prime[j] = 1;
      }
    }
  }
  for(int i = 0; i <= n + 1; i++) {
    for(int j = 0; j <= n + 1; j++) {
      v[i][j] = 1;
    }
  }
  vector<int> id1, id2;
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      if((i + j) % 2 == 1) {
        id1.push_back(i - j);
        id2.push_back(i + j);
      }
    }
  }
  sort(id1.begin(), id1.end());
  sort(id2.begin(), id2.end());
  id1.erase(unique(id1.begin(), id1.end()), id1.end());
  id2.erase(unique(id2.begin(), id2.end()), id2.end());
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      if((i + j) % 2 == 1) {
        v[i][j] *= p[lower_bound(id1.begin(), id1.end(), i - j) - id1.begin()];
        v[i][j] *= p[id1.size() + lower_bound(id2.begin(), id2.end(), i + j) - id2.begin()];
      }
    }
  }
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      if((i + j) % 2 == 0) {
        v[i][j] = lcm(lcm(v[i - 1][j], v[i][j - 1]), lcm(v[i + 1][j], v[i][j + 1])) + 1;
      }
    }
  }
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      printf("%lld ", v[i][j]);
    }
    puts("");
  }
  return 0;
}


Measured memory_bytes: 8948
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args)throws IOException{
    	int a, b;
    	InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
        String buf = br.readLine();
        StringTokenizer st = new StringTokenizer(buf," ");
    	a = Integer.parseInt(st.nextToken());
        b = Integer.parseInt(st.nextToken());

        if (a > b) System.out.println("a > b");
        else if (a == b) System.out.println("a == b");
        else System.out.println("a < b");
    }
}

Measured memory_bytes: 24032
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int n = cin.next!int;
  int h = cin.next!int;
  int[] a = new int[n], b = new int[n];
  foreach (i; 0 .. n) {
    a[i] = cin.next!int;
    b[i] = cin.next!int;
  }
  sort!"a > b"(b);
  int res;
  int maxi = 0;
  foreach (t; a) {
    maxi = max(t, maxi);
  }
  foreach (i; 0 .. n) {
    if (maxi <= b[i]) {
      h -= b[i];
      ++res;
    }
    if (h <= 0) {
      writeln(res);
      return;
    }
  }

  writeln((h % maxi == 0 ? h / maxi : h / maxi + 1) + res);
}


Measured memory_bytes: 4092
/* Contests */

#include <iostream>
#include <algorithm>

using namespace std;

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

  int ca = 0, cb = 0, cc = 0;
  
  int* p = new int[n];
  for(int i = 0; i < n; i++){
  	cin >> p[i];
    if(p[i]<=a){
    	ca++;
    }else if(p[i]>a && p[i]<=b){
    	cb++;
    }else{
    	cc++;
    }
  }

  cout << min(ca, min(cb, cc)) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
lli solve(){
    lli h, w;
    cin>>h>>w;
    vector<string> S(h);
    loop(i, 0, h)
        cin>>S[i];
    vector<vll> dp(h+1, vll(w+1, 0));
    dp[1][1] = 1;
     loop(i, 1, h+1){
        loop(j, 1, w+1){
            if(i == 1 && j == 1)
                continue;
            if(S[i-1][j-1] == '#')
                continue;
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            dp[i][j] %= M;
        }
    }
    cout<<dp[h][w]<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 12160
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n,m = map(int, input().split())
    x,y = [], []
    for _ in range(m):
        a,b = map(int, input().split())
        if a==1:
            x.append(b)
        if b==n:
            y.append(a)
    if not len(x)+len(y)==len(set(x+y)):
            print('POSSIBLE')
            exit()
    print('IMPOSSIBLE')


if __name__ == '__main__':
    main()

Measured memory_bytes: 25184
main(){
  int c,i;
  while(scanf("%d",&c)!=-1){
  int a[10]={512,256,128,64,32,16,8,4,2,1};
    for(i=0;i<10;i++)
      if(a[i]<=c)
    c-=a[i];
      else
    a[i]=0;
    for(i=9;i>=0;i--)
      if(a[i]){
    printf("%d",a[i]);
    break;
      }
    for(i--;i>=0;i--)
      if(a[i])
    printf(" %d",a[i]);
    puts("");
  }
  return 0;
}


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

using namespace std;

int main()
{
	cerr << "Compilation Done." << '\n';
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int k,n;
	cin >> k >> n;
	vector<int> arr(n);
	for(auto& i:arr) cin >> i;
	int ans = 1e9;
	for(int i = 1; i < n; i++) {
		ans = min(ans, k-(arr[i] - arr[i-1]));
	} 
	ans = min(ans, k - (k - arr[n-1] + arr[0]));
	cout << ans;
	return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  /*freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);*/
  int n;cin>>n;
  if(n>=30){
  	cout<<"Yes"<<endl;
  }
  else{
  	cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;

#ifndef errOut
#define errOut(s)
#endif

std::string calc(const std::string& s, int k) {
    std::multimap<char, int> startIdxes;
    std::set<std::string> ss;
    for (int idx = 0; idx < s.length(); ++idx) {
        char const ch = s[idx];
        startIdxes.insert(std::make_pair(ch, idx));
    }
    for (char ch = 'a'; ch <= 'z'; ++ch) {
        auto chItr = startIdxes.find(ch);
        if (chItr == startIdxes.end()) {
            continue;
        }
        for (auto itr = chItr; itr != startIdxes.end() && itr->first == ch; ++itr) {
            int const startIdx = itr->second;
            for (int len = 1; startIdx + len <= s.size(); ++len) {
                std::string const substr = s.substr(itr->second, len);
                if (ss.find(substr) != ss.end()) {
                    continue;
                }
                if (ss.size() >= k) {
                    auto itr = ss.end();
                    --itr;
                    if (substr >= *itr) {
                        break;
                    } else {
                        ss.erase(itr);
                    }
                }
                ss.insert(substr);
            }
        }
        if (ss.size() >= k) {
            break;
        }
    }
    auto itr = ss.begin();
    for (int idx = 1; idx < k; ++idx, ++itr) {
    }
    return *itr;
}

int main() {
    std::string s;
    int k;
    std::cin >> s;
    std::cin >> k;
    std::cout << calc(s, k)  << std::endl;
    return 0;
}


Measured memory_bytes: 512
import heapq
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
q = []
printed = set()
heapq.heappush(q, (-A[0] - B[0] - C[0], 0, 0, 0))
i = 0
while i < K:
    m = heapq.heappop(q)
    if m in printed:
        continue
    print(-m[0])
    printed.add(m)
    x, y, z = m[1], m[2], m[3]
    if x + 1 < X:
        heapq.heappush(q, (-A[x + 1] - B[y] - C[z], x + 1, y, z))
    if y + 1 < Y:
        heapq.heappush(q, (-A[x] - B[y + 1] - C[z], x, y + 1, z))
    if z + 1 < Z:
        heapq.heappush(q, (-A[x] - B[y] - C[z + 1], x, y, z + 1))
    i += 1


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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 510
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
#define fi first
#define pi pair<int, int>
#define se second
#define mp make_pair
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
int k;
int r[maxn][maxn];
int main() {
	cin >> k;
	if (k == 1) {
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}
	int n = 0;
	while (2 * n < k) n += 2;
	int cnt = 0;
	int num = k - n;
	printf("%d\n", n);
	for (int i = 0; i < n; i++) {
		int nm[2] = {cnt, cnt};
		if (i < num)
			nm[0]++, nm[1] += 2, cnt += 2;
		else 
			nm[1]++, nm[0]++, cnt++;
		for (int j = 0; j < n; j++) {
			int npl = (j + n - i) % n;
			r[j][npl] = nm[j % 2];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) 
			printf("%d ", r[i][j]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2176
package main
import(
  "fmt"
)

func conv(orig string) string {
  var tmp string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  d := make(map[byte]byte)
  idx := 0
  s := make([]byte, len(orig))
  for i, v := range []byte(orig) {
    if b, ok := d[v]; ok {
      s[i] = b
    } else {
      d[v] = tmp[idx]
      s[i] = tmp[idx]
      idx++
    }
  }
  return string(s)
}
  
func main() {
  var S, T string
  fmt.Scanln(&S)
  fmt.Scanln(&T)
  
  s := conv(S)
  t := conv(T)
  if s == t {
    fmt.Print("Yes")
  } else {
    fmt.Print("No")
  }
}


Measured memory_bytes: 4480
def main(s):
    e = ["dreamer","eraser","dream","erase"]
    #キューの初期化
    t = [""]
    #キューが空でない間繰り返し
    while len(t) > 0:
        val = t.pop(0)
        for i in e:
            tar = val + i
            #一致したら終了判定→キューに追加
            if s[:len(tar)] == tar:
                if s == tar:
                    return True
                else:
                    t.append(tar)
    return False

s = input()
print("YES" if main(s) else "NO")

Measured memory_bytes: 3992
N, K = map(int, input().split())
A = list(map(int, input().split()))

i = 1
while i <= K:
  i *= 2

x = 0
while i != 0:
  if sum([1 for a in A if a&i==0]) > N/2:
    if x+i <= K:
      x += i
  i //= 2;

print(sum([a^x for a in A]))


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

const int mod = 1000000007;
struct mint {
    ll x;

    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator-=(const mint a) {
      if ((x += mod - a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }

    mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
    }

    mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
    }

    mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
    }

    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
    }

    mint inv() const {
      return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
      return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
    }
};


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

  vector<int> a(2 * n);
  rep(i,n) {
    cin >> a[i];
    a[i + n] = a[i];
  }

  mint answer = 0;
  // self inverse
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if(a[i] > a[j]) answer += 1;
    }
  }
  answer = answer * k;

  mint cnt = 0;
  // two
  for (int i = 0; i < n; i++) {
    for (int j = n; j < 2 * n; j++) {
      if(a[i] > a[j]) cnt += 1;
    }
  }

  cnt = cnt * (1LL + (k - 1LL)) * (k - 1LL) / 2;
  answer += cnt;

  cout << answer.x << '\n';
  return 0;
}


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

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

  int q;
  cin >> q;

  bool rev = false;
  vector<char> head, tail;
  int t, f;
  char c;
  auto add = [&]() {
    if (f == 1) {
      if (rev)
        tail.push_back(c);
      else
        head.push_back(c);
    }
    if (f == 2) {
      if (rev)
        head.push_back(c);
      else
        tail.push_back(c);
    }
  };

  for (int i = 0; i < q; ++i) {
    cin >> t;

    if (t == 1) {
      rev = !rev;
    }
    if (t == 2) {
      cin >> f >> c;
      add();
    }
  }

  string sh = "", st = "";
  if (rev) {
    for (int i = 0; i < head.size(); ++i)
      st += head[i];
    for (int i = tail.size() - 1; i >= 0; --i)
      sh += tail[i];
    reverse(s.begin(), s.end());
  } else {
    for (int i = head.size() - 1; i >= 0; --i)
      sh += head[i];
    for (int i = 0; i < tail.size(); ++i)
      st += tail[i];
  }

  cout << sh << s << st << endl;
}

Measured memory_bytes: 1276
#テストファイルで実行する時
import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

n,t = map(int,input().split())

c = [list(map(int,input().split())) for i in range(n) ]

min = 100000

for i in range(n):
	if c[i][1] <= t:
		if c[i][0] < min:
			min = c[i][0]

print(min if min!=100000 else 'TLE')
	


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void)
{
	int res = 1e9;
	
	int n; cin >> n;
	
	for (int i = 0; i < n; i++){
		int a; cin >> a;
		
		int count = 0;
		
		while(a % 2 == 0){
			a /= 2;
			count++;
		}
		
		if(res > count) res = count;
	}
	
	cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define int double
using namespace std;

signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<int>e(a);
	for (int f = 0; f < a; f++)cin >> e[f];
	int n = d;
	int m = b;
	int s = d / b;
	sort(e.begin(), e.end());
	for (int g =a-1; g!=-1; g--) {
		if (s < e[g] / c) { n += e[g]; m += c; s = n / m;}
	}
	cout << (signed)s << endl;
}

Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            b[i] = sc.nextInt();
        }

        int sum = b[0] + b[n - 2];
        for (int i = 0; i < n - 2; i++) {
            sum += Math.min(b[i], b[i + 1]);
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 21972
#include<stdio.h>
int main()
{
    int n, a;
    scanf("%d %d", &n, &a);
    int i, j, k;
    int x[55];
    for (i = 0; i < n; i++)
        scanf("%d", &x[i]);
    unsigned long long int dp[52][52][2505] = {};
    dp[0][0][0] = 1;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
        {
            for (k = 0; k < 2505; k++)
            {
                if (dp[i][j][k] > 0)
                {
                    dp[i + 1][j][k] += dp[i][j][k];
                    if (k + x[i] < 2505)
                        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
                }
            }
        }
    }
    unsigned long long int ans = 0;
    for (i = 1; i <= n; i++)
        ans += dp[n][i][i*a];
    printf("%lld\n", ans);
    return 0;
}

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

typedef long long ll;

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

    int k, n;
    cin >> k >> n;
    vector<int> houses(n);

    for (int i = 0; i < n; ++i) {
        cin >> houses[i];
    }

    int max_diff = 0;
    for (int i = 0; i < n; ++i) {
        int diff = abs(houses[(i + 1) % n] - houses[i]);
        if (i + 1 == n)
            diff = k - diff;
        max_diff = max(diff, max_diff);
    }

    cout << k - max_diff << "\n";
}


Measured memory_bytes: 1024
from itertools import permutations

S=input()
a,b,c="a","b","c"
D={a:0,b:0,c:0}

for s in S:
    D[s]+=1

X=min(D.values())
Y=max(D.values())

if Y-X<=1:
    print("YES")
else:
    print("NO")


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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> koma(n);
    for(int i=0;i<n;i++) cin>>koma.at(i);
    
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int hoge;
        cin>>hoge;
        koma.at(hoge-1)++;
        
        if(koma.at(hoge-1)>2019) koma.at(hoge-1)--;
        
        for(int i=0;i<n;i++){
            if(hoge-1!=i && koma.at(hoge-1)==koma.at(i)){
                koma.at(hoge-1)--;
                break;
            }
        }
    }
    
    for(auto a:koma) cout<<a<<endl;
    
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <iostream>
#include <algorithm>

#define MAX_N 100
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, s, t) for(int i=s; i<=s; ++i)

using namespace std;

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

    int abc, len_abc[3];
    rep(i, 3)
    {
        cin >> abc;
        len_abc[i] = abc;
    }
    sort(len_abc, len_abc+3);
    
    if(len_abc[0] == 5 && len_abc[1] == 5 && len_abc[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

int main() {
    string S;
    cin >> S;
    if (S.at(0) == S.at(1)) {
        cout << "Bad" << endl;
    } else if (S.at(1) == S.at(2)) {
        cout << "Bad" << endl;
    } else if (S.at(2) == S.at(3)) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,x;
    cin >> n >> x;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(), a.end());
    int64_t res = 0;
    int64_t sum = 0;
    rep(i,n){
        x -= a.at(i);
        if(x<0) break;
        if(x>=0) res++;
    }
    if(x>0) res--;
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
ll N;
ll A[100010],B[100010];
int main(){
  bool f=true;
  cin>>N;
  ll sum=0;
  rep(i,N){
    cin>>A[i];
    sum+=A[i];
  }
  ll z=N*(N+1)/2,n;
  if(sum%z==0){
    n=sum/z;
  }
  else{
    f=false;
  }
  rep(i,N-1){
    B[i]=A[i+1]-A[i];
  }
  B[N-1]=A[0]-A[N-1];
  ll x=0;
  rep(i,N){
    if(n-B[i]>=0&&(n-B[i])%N==0){
      x+=(n-B[i])/N;
    }
    else{
      f=false;
      break;
    }
  }
  if(n==x&&f) prin("YES");
  else prin("NO");
  return 0;
}


Measured memory_bytes: 1792
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]

h_sum=sum(h)

ok=10**9
ng=0
while abs(ok-ng)>1:
 mid=(ok+ng)//2

 l=[max(i-(mid*b),0) for i in h]
 cnt=0
 for j in l:

#  if j<=0:
#   continue

  if j%(a-b)==0:
   cnt+=j//(a-b)
  else:
   cnt+=j//(a-b)+1

 if cnt<=mid:
  ok=mid
 else:
  ng=mid

print(ok)

Measured memory_bytes: 15004
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			var a = cin.ArrayInt(n);
			long ans = 0;
			long current = 0;
			for (int i = n - 1; i >= 0; i--) {
				if (a[i] == current) {
				}else if (a[i] > current) {
					if (i < a[i]) {
						Console.WriteLine(-1);
						return;
					}

					ans += a[i];
					current = a[i];
				} else {
					Console.WriteLine(-1);
					return;
				}

				current = Math.Max(0, current - 1);
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 17864
import heapq

N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(A)

for _ in range(M):
  v = heapq.heappop(A) * (-1)
  heapq.heappush(A, -(v >> 1))

print(-sum(A))

Measured memory_bytes: 86392
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int p = sc.nextInt();

        p += 3 * a;

        System.out.println(p / 2);

        sc.close();
        ;
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    string s; cin >> s;
    if(s[k-1] >= 'A' && s[k-1] <= 'Z') s[k-1] += ('a' - 'A');
    cout << s;
    cout << endl;
    return 0;
}





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

int main(){
	int n;
	cin>>n;
	
	if(n%1000==0)
	   cout<<0;
	else{
		int x;
		x=n/1000+1;
		
		cout<<x*1000-n;
	}
	return 0;
}

Measured memory_bytes: 3532
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] s = new int[100];
		int n, i, sum, max, min;
		
		while (true) {
			for (i = 0; i < 100; i++)
				s[i] = 0;
			n = stdIn.nextInt();
			if (n == 0) break;
			
			for (i = 0; i < n; i++)
				s[i] = stdIn.nextInt();
			
			sum = 0;
			for (i = 0; i < n; i++)
				sum += s[i];
			
			max = s[0];
			min = s[0];
			for (i = 1; i < n; i++) {
				if (max < s[i]) max = s[i];
				if (min > s[i]) min = s[i];
			}
			
			sum = sum - max - min;
			
			System.out.println(sum / (n - 2));
		}
	}
}

Measured memory_bytes: 28776
#include <iostream>

using namespace std;

class Illumination{
public:
	enum Structure{HOLE, BUILDING, ROAD};

	Illumination();
	~Illumination();

	int solve();

private:
	int W;
	int H;
	Structure* map;

	void input();
	void newArrays(int n);
	void initArrays();
	inline int idx(int x, int y){ return x + y * (W + 2);}
	void searchNeighbors(int x, int y, Structure before, Structure after);
	int countNeighbors(int x, int y, Structure s);
};

Illumination::Illumination() : W(0), H(0){
	map = NULL;
}

Illumination::~Illumination(){
	delete[] map;
}

void Illumination::newArrays(int n){
	map = new Structure[n];
}

void Illumination::initArrays(){
	for (int i = 0; i < W + 2; i++) map[idx(i, 0)] = map[idx(i, H + 1)] = ROAD;
	for (int i = 0; i < H + 2; i++) map[idx(0, i)] = map[idx(W + 1, i)] = ROAD;
}

void Illumination::searchNeighbors(int x, int y, Structure before, Structure after){
//	cout << x << ", " << y << " : " << endl;
	if (map[idx(x, y)] == before && countNeighbors(x, y, after) > 0) map[idx(x, y)] = after;
	else return;

	auto check = [&](int _x, int _y, Structure _before, Structure _after){
		if (map[idx(_x, _y)] == _before){
//			map[idx(_x, _y)] = _after;
//			cout << _x << ", " << _y << endl;
			searchNeighbors(_x, _y, _before, _after);
		}
	};

	check(x, y + 1, before, after);
	check(x, y - 1, before, after);
	check(x + 1, y, before, after);
	check(x - 1, y, before, after);

	if (y % 2 == 0){
		check(x - 1, y - 1, before, after);
		check(x - 1, y + 1, before, after);
	}
	else{
		check(x + 1, y - 1, before, after);
		check(x + 1, y + 1, before, after);
	}
	return;
}

void Illumination::input(){
	cin >> W >> H;
	newArrays((W + 2) * (H + 2));

	initArrays();

	for (int i = 1; i < H + 1; i++){
		for (int j = 1; j < W + 1; j++){
			int tmp;
			cin >> tmp;
			map[idx(j, i)] = (Structure)tmp;
		}
	}
	/*
	cout << endl;
	for (int i = 0; i < H + 2; i++){
		for (int j = 0; j < W + 2; j++){
			cout << map[idx(j, i)] << " ";
		}
		cout << endl;
	}
	*/
}

int Illumination::countNeighbors(int x, int y, Structure s){
	int ans = 0;

	if (map[idx(x, y + 1)] == s) ans += 1;
	if (map[idx(x, y - 1)] == s) ans += 1;
	if (map[idx(x + 1, y)] == s) ans += 1;
	if (map[idx(x - 1, y)] == s) ans += 1;

	if (y % 2 == 0){
		if (map[idx(x - 1, y - 1)] == s) ans += 1;
		if (map[idx(x - 1, y + 1)] == s) ans += 1;
	}
	else{
		if (map[idx(x + 1, y - 1)] == s) ans += 1;
		if (map[idx(x + 1, y + 1)] == s) ans += 1;
	}
	return ans;
}

int Illumination::solve(){
	input();
	
	for (int i = 1; i < W + 1; i++){
		searchNeighbors(i, 1, HOLE, ROAD);
		searchNeighbors(i, H, HOLE, ROAD);
	}
	for (int i = 1; i < H + 1; i++){
		searchNeighbors(1, i, HOLE, ROAD);
		searchNeighbors(W, i, HOLE, ROAD);
	}
	
	int ans = 0;

//	cout << endl;
	for (int i = 1; i < H + 1; i++){
		for (int j = 1; j < W + 1; j++){
			if (map[idx(j, i)] == BUILDING){
				ans += countNeighbors(j, i, ROAD);
			}
//			cout << map[idx(j, i)] << " ";
		}
//		cout << endl;
	}
	return ans;
}

int main(){
	Illumination* illumination = new Illumination();
	cout << illumination->solve() << endl;

	delete illumination;

	return 0;
}

Measured memory_bytes: 1692
#include<stdio.h>

void trace(int A[], int N)
{
	int i;

	for (i = 0; i < N; i++)
	{
		if (i > 0)
		{
			printf(" ");
		}

		printf("%d", A[i]);

	}

	printf("\n");
}

void insertionSort(int A[], int N)
{
	int j, i, v;

	for (i = 0; i < N; i++)
	{
		v = A[i];
		j = i - 1;

		while (j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;
		}

		A[j + 1] = v;
		trace(A, N);
	}
}

int main()
{
	int N, i, j;
	int A[100];

	scanf("%d", &N);

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

	insertionSort(A, N);

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int sz = (1 << n);
    vector<int> a(sz);
    for (int i = 0; i < sz; i++) {
        cin >> a[i];
    }

    vector< set<P> > dp(sz);
    dp[0].emplace(a[0], 0);
    vector<int> ans(sz, 0);
    ans[0] = a[0];
    for (int i = 1; i < sz; i++) {
        dp[i].emplace(a[i], i);
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                int prv = i - (1 << j);
                for (auto& p : dp[prv]) {
                    dp[i].insert(p);
                    if ((int)dp[i].size() > 2) dp[i].erase(*dp[i].begin());
                }
            }
        }
        for (auto& p : dp[i]) {
            ans[i] += p.first;
        }
        ans[i] = max(ans[i], ans[i - 1]);
    }

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

Measured memory_bytes: 50176
N,X,Y = map(int, input().split())

#進む距離kの箱
Ans = [0 for _ in range(N)]


for i in range(1, N): #スタートする頂点
    for j in range(i+1, N+1): #到着する頂点
        
        #頂点iからjまでの最短経路
        #iからjまで普通に進むか、X-Yの道を使うか。そのどっちが最短か
        Ans[min(j-i, abs(X-i)+abs(Y-j)+1)] += 1

#答え:K=1から出力
for i in Ans[1:]:
    print(i)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    set<int> s[W];
    rep(i, W){
        s[i].insert(H);
    }
    rep(i, N){
        int x, y;
        cin >> x >> y;
        s[y-1].insert(x-1);
    }
    int d = 0, a[W];
    rep(i, W){
        while(s[i].count(i+d)) d++;
        a[i] = i+d;
    }
    int ans = H;
    rep(i, W){
        if(a[i] >= H) break;
        s[i].insert(a[i]);
        set<int>::iterator ite;;
        ite = s[i].find(a[i]);
        ite++;
        ans = min(ans, *ite);
    }
    cout << ans << endl;
}

Measured memory_bytes: 36608
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(i,n) rep2(i,0,n)
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int n=s.size();
    int l=n/2,r=n/2;
    while(l>=0 && s[l]==s[n/2])--l;
    while(r<n && s[r]==s[n/2])++r;
    cout << min(n-1-l,r) << endl;
    return 0;
}

Measured memory_bytes: 512
N, M, X = map(int, input().split())
c_list = [ list(map(int, input().split())) for _ in range(N) ]

# 2**N
fg = 0
cost = sum([ i[0] for i in c_list])
for i in range(2**N):
    t_cost = []
    l = [ 0 for _ in range(M)]
    for j in range(N):
        if ((i>>j) & 1 ):
            t_cost.append(c_list[j][0])
            l = [ x+y for x,y in zip(l,c_list[j][1:])]
    if len([ 0 for k in l if k < X ]) == 0:
        fg = 1
        cost = min(cost, sum(t_cost))
if fg != 0:
    print(cost)
else:
    print('-1')

Measured memory_bytes: 9248
import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val MOD = 998244353L

	val (n,m) = f.readLine().split(" ").map{it.toInt()}
	val array = f.readLine().split(" ").map{it.toInt()}

	val dp = Array(n, {LongArray(m+1)})

	dp[0][0] = 2L
	if(array[0] <= m) dp[0][array[0]] = 1L

	for(k in 0 until n-1){
		for(j in 0..m){
			if(dp[k][j] == 0L) continue
			dp[k+1][j] = (dp[k+1][j] + ((dp[k][j]*2 + MOD)%MOD) + MOD)%MOD
			if(j+array[k+1] <= m){
				dp[k+1][j+array[k+1]] = (dp[k+1][j+array[k+1]] + dp[k][j] + MOD)%MOD
			}
		}
	}

	println(dp[n-1][m])

}


Measured memory_bytes: 107784
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <set>
#include <map>
#define MAXX 55555
#define ll long long
using namespace std;


int main() {
    int n;
    cin>>n;
    int m = n/2;
    
    map<int,int> evens;
    map<int,int> odds;
    
    
    for(int i=1;i<=n;i++) {
        int x;
        cin>>x;
        
        if (i&1) {
            odds[x]++;
        } else {
            evens[x]++;
        }
    }
    
    
    if (evens.size() == 1 && odds.size() == 1) {
        
        if (evens.begin()->first == odds.begin()->first) {
            cout << n/2 << endl;
            return 0;
        } else {
            cout << 0 << endl;
            return 0;
        }
    }
    
    vector<pair<int,int>> ct_evens;
    vector<pair<int,int>> ct_odds;
    
    for(auto x : evens) {
        ct_evens.push_back({-x.second,x.first});
    }
    
    
    for(auto x : odds) {
        ct_odds.push_back({-x.second,x.first});
    }
    
    
    sort(ct_evens.begin(),ct_evens.end());
    sort(ct_odds.begin(),ct_odds.end());
    
    int ans = n+2;
    for(int i=0;i<min(3,(int)ct_evens.size());++i)
        for(int j=0;j<min(3,(int)ct_odds.size());++j) {
            int x = ct_evens[i].second;
            int y = ct_odds[j].second;
            
            if (x != y) {
                ans = min(ans, n+ct_evens[i].first+ct_odds[j].first);
            }
        }
    
    
    cout << ans << endl;
    return 0;
    
    
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int A, B, T;


signed main(void) {
    cin >> A >> B >> T;
    cout << (T/A)*B << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	for(int i=0;i<4;i++){
		cin>>a>>b;
		if(a==1)
		cout<<b*6000<<endl;
		if(a==2)
		cout<<b*4000<<endl;;
		if(a==3)
		cout<<b*3000<<endl;
		if(a==4)
		cout<<b*2000<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164