akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
using namespace std;

constexpr int kN = int(1E4 + 10), kInf = int(1E9 + 10);

#define F first
#define S second
struct Edge {
  int to, rev, cost, flow;
};
vector<Edge> graph[kN];
pair<int, int> dis[kN];
int from[kN];
void AddEdge(int u, int v, int f, int c) {
  graph[u].push_back(
    {v, int(graph[v].size()), c, f});
  graph[v].push_back(
    {u, int(graph[u].size()) - 1, -c, 0});
  return;
}
pair<int, int> MCMF(int s, int t) {
  priority_queue<pair<int, int>,
    vector<pair<int, int>>,
    greater<pair<int, int>>>
    pq;
  pair<int, int> nxt;
  int now, flow;
  for (int i = 0; i < kN; i++)
    dis[i] = {
      kInf, 0};  // don't necessarily need kN
  dis[s] = {0, kInf};

  pq.push({dis[s].F, s});
  while (!pq.empty()) {
    nxt = pq.top();
    pq.pop();
    if (nxt.F > dis[nxt.S].F) continue;
    for (Edge i : graph[nxt.S])
      if (i.flow > 0 &&
        i.cost + nxt.F < dis[i.to].F) {
        dis[i.to] = {nxt.F + i.cost,
          min(dis[nxt.S].S, i.flow)};
        from[i.to] = i.rev;
        pq.push({dis[i.to].F, i.to});
      }
  }
  if (dis[t].F >= kInf) return dis[t];
  flow = dis[t].S;
  now = t;
  while (now != s) {
    graph[now][from[now]].flow += flow;
    graph[graph[now][from[now]].to]
         [graph[now][from[now]].rev]
           .flow -= flow;
    now = graph[now][from[now]].to;
  }
  return dis[t];
}


string s[60];
int idx[60][60];

int main() {
	int n, m, S, T, t = 0, ans = 0;
	pair<int, int> tmp;
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> s[i];
	for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) idx[i][j] = t++;
	for (int i = 0; i < n; i++) for (int j = 1; j < m; j++) if (s[i][j] != '#' && s[i][j - 1] != '#') {
		AddEdge(idx[i][j - 1], idx[i][j], kInf, 0);
	}
	for (int i = 1; i < n; i++) for (int j = 0; j < m; j++) if (s[i][j] != '#' && s[i - 1][j] != '#') {
		AddEdge(idx[i - 1][j], idx[i][j], kInf, 0);
	}
	S = t++;
	T = t++;
	for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (s[i][j] != '#') {
		AddEdge(idx[i][j], T, 1, n + m - i - j - 2);
	}
	for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (s[i][j] == 'o') {
		ans += n + m - i - j - 2;
		AddEdge(S, idx[i][j], 1, 0);
	}
	while (true) {
		tmp = MCMF(S, T);
		if (tmp.S == 0) break;
		ans -= tmp.F * tmp.S;
	}
	cout << ans << "\n";
}



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

const int Mod = 1e9 + 7;

int n, x, c, ans = 1;

int main() {
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &x);
		if (x >= ((c << 1) | 1)) {
			c++;
		} else {
			ans = 1ll * ans * (c + 1) % Mod;
		}
	}
	while (ans = 1ll * ans * c % Mod, --c);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
cost = [0]*n

for i in a:
  cost[i] = 1

cost_zero = cost[1:x]
cost_n = cost[x+1:]

ans = min(sum(cost_zero),sum(cost_n))

print(ans)

Measured memory_bytes: 3064
N= int(input())
F = []
for i in range(N):
    F.append(list(map(int,input().split())))
    
P = []

for i in range(N):
    P.append(list(map(int,input().split())))
    
    
def calc_profit(open_list):
    if not (True in open_list):
        return -10**27
    count = [0 for i in range(N)]
    for i in range(10):
        if open_list[i]:
            for j in range(N):
                if F[j][i]==1:
                    count[j]+=1
    profit=0
    for i in range(N):
        profit+=P[i][count[i]]
    return profit

def get_max(l):
    if len(l)==10:
        return calc_profit(l)
    else:
        return max(get_max(l+[True]),get_max(l+[False]))

print(get_max([]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll n,m; cin >> n >>m;
  vector<ll> h(n);
  rep(i,n){
    cin >> h[i];
  }
  map<ll,ll> ng; 
  rep(i,m){
    ll a,b; cin >> a >> b;
    if(h[a-1]<h[b-1]){
      ng[a-1]++;
    }else if(h[a-1]>h[b-1]){
      ng[b-1]++;
    }else if(h[a-1]==h[b-1]){
      ng[a-1]++;
      ng[b-1]++;
    }
  }
  ll ans=0;
  rep(i,n){
    if(ng[i]==0) ans++;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 10384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    int N=1000000;
    init();
    int n;
    cin >> n;
    vector<int> data(N,0);
    vector<int>d(n);
    rep(i,n){
        cin>>d[i];
        if(data[d[i]]!=0){
            data[d[i]]=2;
            continue;
        }
        for(int j=d[i];j<=N;j+=d[i]){
            data[j]++;
        }
    }
    int ans=0;
    rep(i,n){
        if(data[d[i]]==1)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7932
#include<stdio.h>

int main(void)
{
  int a,b,i,d;

  scanf("%d",&a);
  scanf("%d",&b);

    if(b>a){
      for(i=0;i<b;i++){
        printf("%d",a);
      }
      printf("\n");
    }
    else{
      for(i=0;i<a;i++){
        printf("%d",b);
      }
      printf("\n");
    }

  return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int> p(N);
    for (int &t: p)
        cin>>t;
    for (int A=100; A>=0; A--)
    {
        int c = 0;
        for (int t: p)
            if (t>=A)
                c++;
        if (c>=A)
        {
            cout<<A<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3100
var  s:ansistring; a,b:longint; ch:char;
begin
   readln(a,b);
    readln(s);
         if s[a+1]<>'-' then writeln('No')
           else  
                 begin
                     delete(s,a+1,1);
                  for ch:='0' to '9' do
                    while(pos(ch,s)<>0) do delete(s,pos(ch,s),1);
                      if length(s)>=1 then writeln('No')
                          else writeln('Yes');
                 end;
end.

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

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

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

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 998244353;

vector<int64> fact(11234), inv(11234);
int64 K, N;

int64 mpow(int64 a, int64 b){
	if(b == 0) return 1;
	if(b%2) return a*mpow(a, b-1)%mod;
	int64 ret = mpow(a, b/2);
	return ret*ret%mod;
}

void init(int64 N, int64 K){
	fact[0] = 1;
	inv[0] = 1;
	FOR(i, 1, 11234){
		fact[i] = fact[i-1]*i%mod;
		inv[i] = mpow(fact[i], mod-2);
	}
}

int64 comb(int64 a, int64 b){
	if(a < b || a < 0 || b < 0){
		return 0;
	}
	return fact[a]*inv[b]%mod*inv[a-b]%mod;
}

int64 calc2(int64 N, int64 k, int64 x){ 
	int64 res = 0;
	REP(i,  x+1){
		res = (res+mpow(2, i)*comb(x, i)%mod*comb(N-i+k+i-1, N-i)%mod)%mod;
	}
	return res;
}

int64 calc(int64 N, int64 k){ 
	int64 res = 0;
	int32 p = K-abs(K+1-k);
	if(p%2){
		res += calc2(N, K-p, p/2);
		res %= mod;
		res = (res+calc2(N-1, K-p, p/2)%mod)%mod;
	}else{
		res += calc2(N, K-p, p/2);
		res %= mod;
	}
	return res;
}


int main(void){
	cin >> K >> N;
	init(N, K);
	FOR(i, 2, 2*K+1){
		cout << calc(N, i) << endl;
	}
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
long long d,t,s;
int main(){
    cin>>d>>t>>s;
    if(d>s*t)
        cout<<"No";
    else
        cout<<"Yes";
}

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

int main() {
	// your code goes here

int N;

cin >> N;

int i=0;



while(N>0){

N/=2;

i++;

}

int k=1;

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

k*=2;
}



cout << k << endl;



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int r,g,b;
  cin >> r >> g >> b;

  cout << ((r*100+g*10+b)%4 == 0 ? "YES" : "NO") << endl; 
  return 0;
} 

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  string n;
  cin>>n;

  string n_org=n;
  reverse(n.begin(),n.end());

  if(n==n_org)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3632
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

H,W,M = MI()
hw = [tuple(MI()) for _ in range(M)]
A = [0]*(H+1)
B = [0]*(W+1)

from collections import defaultdict
d = defaultdict(int)
for h,w in hw:
    A[h] += 1
    B[w] += 1
    d[(h,w)] = 1


ma = max(A)
mb = max(B)
ans = ma+mb
C,D = [],[]
for i in range(1,H+1):
    if A[i] == ma:
        C.append(i)
for i in range(1,W+1):
    if B[i] == mb:
        D.append(i)

if len(C)*len(D) > M:
    print(ans)
else:
    for i in C:
        for j in D:
            if d[(i,j)] == 0:
                print(ans)
                exit()
    print(ans-1)


Measured memory_bytes: 213620
#include <bits/stdc++.h>
#define INF 1000000000000000000LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll gcd(ll x,ll y){
	if(y==0)return x;
	return gcd(y,x%y);
}

ll mul(ll x,ll y){
	ll res=0;
	while(y>0LL){
		if(res+x>INF)return INF+1LL;
		if(y&1LL)res+=x;
		x+=x;
		y>>=1LL;
	}
	return res;
}

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


int n;
ll m;
ll a[21];
double p[21];
double pos[1<<20];
ll val[1<<20];
vector<ll> vec;

int main(void){
	scanf("%d%lld",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<n;i++){
		int b;
		scanf("%d",&b);
		p[i]=(double)b/100.0;
	}
	for(int i=0;i<(1<<n);i++){
		ll v=0;
		double po=1.0;
		for(int j=0;j<n;j++){
			if(i>>j & 1){
				if(v==0)v=a[j];
				else v=lcm(v,a[j]);
				po*=p[j];
			}else{
			}
		}
		vec.push_back(v);
		val[i]=v;
		pos[i]=po;
	}
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	double ans=0.0;
	for(int i=1;i<(1<<n);i++){
		int vi=lower_bound(vec.begin(),vec.end(),val[i])-vec.begin();
		ll cnt=m/val[i];
		if(__builtin_popcount(i)%2==1)ans+=cnt*pos[i];
		else{
			ans-=cnt*pos[i];
		}
	}
	printf("%.9f\n",ans);
	return 0;
} 


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

using namespace std;
using Long = __int128_t;

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

    int n, q;
    long long l, r;
    cin >> n >> q >> l >> r;
    vector<int> as(n);
    for (int i = 0; i < n; i++) cin >> as[i];

    vector<long long> qs(q), xs(q), ss(q), ts(q);
    for (int i = 0; i < q; i++) {
        cin >> qs[i] >> xs[i] >> ss[i] >> ts[i];
    }

    Long lmima = -((Long) 1 << 64), lijou = (Long) 1 << 64;
    while (lmima < lijou - 1) {
        Long m = (lmima + lijou) / 2;
        Long v = m;
        for (int i = 0; i < q; i++) {
            if (qs[i] == 1) {
                if (v >= xs[i]) {
                    v = ts[i] * (v + ss[i]);
                }
            } else {
                if (v <= xs[i]) {
                    v = (v - ss[i]) / ts[i];
                }
            }
        }
        if (v >= l) {
            lijou = m;
        } else {
            lmima = m;
        }
    }

    Long rika = -((Long) 1 << 64), rue = (Long) 1 << 64;
    while (rika < rue - 1) {
        Long m = (rika + rue) / 2;
        Long v = m;
        for (int i = 0; i < q; i++) {
            if (qs[i] == 1) {
                if (v >= xs[i]) {
                    v = ts[i] * (v + ss[i]);
                }
            } else {
                if (v <= xs[i]) {
                    v = (v - ss[i]) / ts[i];
                }
            }
        }
        if (v <= r) {
            rika = m;
        } else {
            rue = m;
        }
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (as[i] >= lijou && as[i] <= rika) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 9600
ch = input()
ch = ch[::-1]
flag = 1

while flag>0 and len(ch)>0:
    if ch.find('maerd')==0 or ch.find('esare')==0:#chの0番目にあった
        ch = ch[5:]
    elif ch.find('remaerd')==0:
        ch = ch[7:]
    elif ch.find('resare')==0:
        ch = ch[6:]
    else:
        flag = -1
if flag<0:
    print("NO")
else:
    print("YES")
    

Measured memory_bytes: 3316
a,b,c,d,e,f=gets.split(" ").map(&:to_i)
w=[]
s=[]
i=0
while 100*a*i<=f do
	j=0
	while 100*(a*i+b*j)<=f do
		w << 100*(a*i+b*j)
		j+=1
	end
	i+=1
end
i=0
while c*i<=f do
	j=0
	while c*i+d*j<=f do
		s << c*i+d*j
		j+=1
	end
	i+=1
end
w.sort!.uniq!
s.sort!.uniq!
water=w[-1]
sugar=0
w.each{|ww|
	s.each{|ss|
		if ww+ss>f || ww*e<ss*100 then
			break
		end
		if water*ss>(ww+ss)*sugar then
			water=ww+ss
			sugar=ss
		end
	}
}
print(water," ",sugar,"\n")

Measured memory_bytes: 6136
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var l = int.Parse(input.ReadLine());

        double z = (double)l / 3.0;

        return z * z * z;
    }
}

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

using namespace std;

const int maxn = 55;

double a[maxn];

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)cin >> a[i];
	sort(a,a+n);
	double ans = a[0];
	for(int i = 1; i < n; i++) {
		ans = (ans + a[i]) / 2;
	}
	cout << ans <<"\n";
	return 0;
}

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

using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<long> ps(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ps[i];
    }
    int ans = 0;
    for (int s = 1; s < (1 << n); s++)
    {
        bool ok = 1;
        long lcm = 1;
        for (int i = 0; i < n && ok; i++)
        {
            if (s >> i & 1)
            {
                lcm = lcm * ps[i] / __gcd(ps[i], lcm);
            }
        }
        for (int i = 0; i < n; i++)
        {
            if (s >> i & 1)
            {
                continue;
            }
            ok &= lcm % ps[i] != 0;
        }
        if (ok)
        {
            ans++;
            //cout << bitset<20>(s) << endl;
        }
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 3104
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

ll result[200005] = {0};
void fact(ll n) {
   if (n >= 0) {
      result[0] = 1;
      for (ll i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
   }
}

void dfs(ll n, ll m, ll i, vector<ll> &v){
  if(i == n){
  }else{
    for(int k = 1; k <= m; k++){
      v.push_back(k);
      dfs(n, m, i+1, v);
      v.pop_back();
    }
  
  }
}

void solution(){
  string s;
  cin >> s;
  if(s == "ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}     



Measured memory_bytes: 3136
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_map>
#include <iomanip>

using namespace std;

using ll = long long;

const int N = 11;
char s[N];

bool valid(char c) {
    return c == 'A' || c == 'T' || c == 'G' || c == 'C';
}
int main() {
    scanf("%s", s);
    int len = strlen(s);
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < len; i++) {
        if (valid(s[i])) cnt++;
        else cnt = 0;
            ans = max(ans, cnt);
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())

SS='.'*(W+2)
S=['.'+input()+'.' for _ in range(H)]

SS=['.'*(W+2)]

SS.extend(S)

SE=['.'*(W+2)]

SS.extend(SE)

for i in range(1,H+1):
    for j in range(1, W+1):
        if SS[i][j]=='#':
            print('#',end='')
        else:   
            print(str((SS[i-1][j-1]+SS[i][j-1]+SS[i+1][j-1]+SS[i-1][j]+SS[i+1][j]+SS[i-1][j+1]+SS[i][j+1]+SS[i+1][j+1]).count('#')),end='')
        if j==W:
            print('')

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5))
		cout << "YES\n";
	else cout << "NO\n";
}

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

    //int t; cin >> t; while (t--)
        solve();
}


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

int main() {
  int a,b,c[1000010];
  cin >> a >> b;
  
  for(int i=0;i<b;i++)
    cin >> c[i];
  
  long long int ans = 0;
  for(int i=0;i<b;i++){
    ans += c[i];
  }
  
  if(a-ans >= 0){
    cout << a - ans << endl;
  }
  
  else{
    cout << " -1 " << endl;
  }
  
}
  

  

 

Measured memory_bytes: 3656
package main

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

func main() {
	defer stdout.Flush()
	s := readString()
	toggle := 1
	for _, r := range s {
		if toggle == 1 {
			printf("%c", r)
		}
		toggle = 1 - toggle
	}
	println()
}

var (
	stdin  *bufio.Reader
	stdout *bufio.Writer
)

func init() {
	stdin = bufio.NewReader(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func scanf(f string, args ...interface{}) (int, error) {
	n, err := fmt.Fscanf(stdin, f, args...)
	for {
		r, _, err := stdin.ReadRune()
		if err != nil || !unicode.IsSpace(r) {
			stdin.UnreadRune()
			break
		}
	}
	return n, err
}

func readInt() int {
	var n int
	scanf("%d", &n)
	return n
}

func readIntSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	return a
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func readString() string {
	var s string
	scanf("%s", &s)
	return s
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}


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

#define mp make_pair
#define ll long long
#define f first
#define s second

using namespace std;

int n;
vector<int> dx = {-1, 1, 0, 0};
vector<int> dy = {0, 0, -1, 1};
vector<int> ord;
vector<vector<int>> b, dist;
bool chk(pair<int, int> pos){
    return pos.f >= 0 && pos.s < n && pos.s >= 0 && pos.f < n;
}
void fix(int pos){
    b[pos/n][pos%n] = -1;
    queue<pair<int, int>> q;
    q.push({pos/n, pos%n});
    while(!q.empty()){
        pair<int, int> cur = q.front();
        q.pop();
        for(int i = 0; i < 4; ++i){
            pair<int, int> t = mp(cur.f + dx[i], cur.s + dy[i]);
            if(chk(t) && dist[t.f][t.s] > dist[cur.f][cur.s] + (b[cur.f][cur.s] != -1)){
                dist[t.f][t.s] = dist[cur.f][cur.s] + (b[cur.f][cur.s] != -1);
                q.push({t.f, t.s});
            }
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    ord.assign(n * n, 0);
    b.assign(n, vector<int>(n, 0));
    dist.assign(n, vector<int>(n, 0));
    for(int i = 0; i < n * n; ++i){
        cin >> ord[i]; ord[i]--;
        b[ord[i]/n][ord[i]%n] = i;
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            dist[i][j] = min(i, j);
            dist[i][j] = min(dist[i][j], n - i - 1);
            dist[i][j] = min(dist[i][j], n - j - 1);
        }
    }
    ll res = 0;
    for(int i = 0; i < n * n; ++i){
        res += dist[ord[i]/n][ord[i]%n];
        fix(ord[i]);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 6076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(x+y>16){cout<<":(";}
    else if(x>8||y>8){ cout<<":(";}
    else
    {cout<<"Yay!";}
  
  
  
  
  
  
  
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int ans=1,n,k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		if(ans<=k)  ans+=ans;
		else ans+=k;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> P, Q;
    P = Q = vector<int>(N);
    for (int i = 0; i < N; i++)cin >> P[i];
    for (int i = 0; i < N; i++)cin >> Q[i];
    vector<int> tmp(N);
    for (int i = 0; i < N; i++)tmp[i] = i + 1;
    int cnt = 1;
    int a, b;
    do {
        if (tmp == P)a = cnt;
        if (tmp == Q)b = cnt;
        cnt++;
    } while (next_permutation(tmp.begin(), tmp.end()));
    cout << abs(a - b) << endl;

}

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

int main () {
  int n,k;
  cin >>n>>k;
  vector<int>h(n);
  for (int i=0;i<n;i++){
    cin >>h[i];
  }
  int cnt =0;

  for(int i=0;i<n;i++){
    if (h[i] >=k)cnt ++;
  }

  cout <<cnt <<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
  int i, k, n, q, b, e, t, u;
  fscanf(stdin, "%d", &n);
  int a[n];
  for (i=0; i<n; i++)
    fscanf(stdin, "%d", &a[i]);

  fscanf(stdin, "%d", &q);
  for (i=0; i<q; i++) {
    fscanf(stdin, "%d %d %d", &b, &e, &t);

    for (k=0; k<e-b; k++) {
      u = a[b+k];
      a[b+k] = a[t+k];
      a[t+k] = u;
    }
  }
  for (i=0; i<n-1; i++)
    printf("%d ", a[i]);
  printf("%d\n", a[i]);

  return 0;
}



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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i]; A[i]--;
	}

	vector<int> cnt(N);
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		ans += cnt[A[i]]++;
	}
	for (int i = 0; i < N; i++) {
		cout << ans - (cnt[A[i]]-1) << '\n';
	}

	return 0;
}


Measured memory_bytes: 4224
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new aoj2151().doIt();
    }
    class aoj2151{
    	Point2D[] p = new Point2D[301];
    	int ans(int n){
    		int result = 1;
    		for(int i = 0;i < n;i++){
    			for(int j = i+1;j < n;j++){
    				double dot = p[i].distance(p[j]);
//    				System.out.println(dot);
    				if(dot > 2.0)continue;
    				double e = Math.sqrt(1.0 - dot*dot/4.0);
    				for (int pm = 0; pm < 2; ++pm) {
    					Point2D c = new Point2D.Double((p[i].getX()+p[j].getX())/2.0 + (p[j].getY()-p[i].getY())*e/dot,
    							(p[i].getY()+p[j].getY())/2.0 - (p[j].getX()-p[i].getX())*e/dot);
    					int cnt = 2;
    					for (int k = 0; k < n; ++k) {
    						if (k == i || k == j)continue;
    				        if ((c.getX()-p[k].getX())*(c.getX()-p[k].getX())+(c.getY()-p[k].getY())*(c.getY()-p[k].getY()) <= 1.0 + 0.000001)cnt++;
    				      }
    				      result = Math.max(result, cnt);
    				      e *= -1.0;
    				    }
    				}
    			}
    		return result;
    	}
    	void doIt(){
    		while(true){
    			int n = sc.nextInt();
    			if(n == 0)break;
    			for(int i = 0;i < n;i++){
    				p[i] = new Point2D.Double(sc.nextDouble(),sc.nextDouble());
    			}
    			System.out.println(ans(n));
    		}
    	}
    }
}

Measured memory_bytes: 68312
package main

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

func main() {
	n := readInt()
	m := readInt()
	h := make([]int, n)
	good := make([]bool, n)
	for i := 0; i < n; i++ {
		h[i] = readInt()
		good[i] = true
	}
	for i := 0; i < m; i++ {
		a_i := readInt() - 1
		b_i := readInt() - 1
		if h[a_i] > h[b_i] {
			good[b_i] = false
		} else if h[b_i] > h[a_i] {
			good[a_i] = false
		} else {
			good[a_i] = false
			good[b_i] = false
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		if good[i] {
			ans++
		}
	}

	fmt.Println(ans)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 6020
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return (a//gcd(a,b)*b)
n,m = map(int,readline().split())
s = readline().rstrip().decode('utf-8')
t = readline().rstrip().decode('utf-8')
l = lcm(n,m)
g = gcd(n,m)
flag = 1

for i in range((n-1)//(n//g)+1):
    if not s[i*(n//g)] == t[i*(m//g)]:
        flag = 0
        break


if flag:
    print(l)
else:
    print(-1)

Measured memory_bytes: 39536
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner (System.in);
		String S=in.next();
		int condition =0;
		for (int i = 1; i < S.length(); i++) {
			if(S.charAt(i-1)!=S.charAt(i))
				condition++;
		}
        System.out.println(condition);
	}
}

Measured memory_bytes: 30276
S = list(input())
mod = 10**9+7
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
  s = S[-(i+1)]
  if s == "?":
    for k in range(10):
      for j in range(13):
        dp[i+1][(mul * k + j)%13] += dp[i][j]
        dp[i+1][(mul * k + j)%13] %= mod

  else:
    k = int(s)
    for j in range(13):
      dp[i+1][(mul * k + j)%13] += dp[i][j]
      dp[i+1][(mul * k + j)%13] %= mod
  
  mul = (mul * 10) % 13

print(dp[len(S)][5])
  



Measured memory_bytes: 65272
S = input().strip()

start = False
i = 0
count = 0
max = 0
while i < len(S) and (len(S) - max > i or start):
    if start:
        if S[i] not in ["A", "C", "G", "T"]:
            start = False
            count = 0
    else:
        if S[i] in ["A", "C", "G", "T"]:
            start = True

    if start:
        count += 1
        if count > max:
            max = count
    i += 1
print(max)


Measured memory_bytes: 3064
N, K = list(map(int, input().split(' ')))
l = list(map(int, input().split(' ')))
minuss = [0] + [-i for i in l if i < 0][::-1]
pluss = [0] + [i for i in l if i >= 0]
# minuss から k本、plussからK-k本取る(短い方を折り返すので2倍)
ans = 1e16  # ?
if pluss == [0]:  # 4 2 [-4, -3 , -2, -1]
    pluss = minuss
    minuss = [0]
for k in range(K):
    if k >= len(minuss) or K - k >= len(pluss):
        continue
    ans = min(ans, min(minuss[k] * 2 + pluss[K-k], minuss[k] + pluss[K-k] * 2))
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

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

    if (S.size() <= K) {
        cout << S << endl;
    } else {
        string t = S.substr(0, K);
        cout << t << "..." << endl;
    }

    return 0;
}

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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;
  int Q; cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    //int Q; cin >> Q;
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;


int main() {
    ll n; cin >> n;
    vpl group;
    if(n%2==0){
        rep(i,n/2){
            group.emplace_back(i+1,n-i);
        }
    }else{
        group.emplace_back(0,n);
        rep(i,n/2){
            group.emplace_back(i+1,n-i-1);
        }
    }
    vpl ans;
    rep(i,group.size()){
        REP(j,i+1,group.size()){
            if(group[i].first != 0){
                ans.emplace_back(group[i].first, group[j].second);
            }
            if(group[j].first != 0){
                ans.emplace_back(group[i].second, group[j].first);
            }
            if(group[i].first != 0 && group[j].first != 0){
                ans.emplace_back(group[i].first, group[j].first);
            }
            ans.emplace_back(group[i].second, group[j].second);
        }
    }
    ll m = ans.size();
    cout << m << endl;
    for(auto i : ans) cout << i.first << " " << i.second << endl;
    //cout << group.size() << endl;
}

Measured memory_bytes: 512
/*
 * FileName:     C
 * CreatedDate:  2020-04-05 14:08:04 +0900
 * LastModified: 2020-04-05 14:35:31 +0900
 */

#include <stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    int A[2][N],dp[2][N];
    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++){
            scanf("%d",&A[i][j]);
        }
    }
    dp[0][0]=A[0][0];
    dp[1][0]=dp[0][0]+A[1][0];
    for(int i=1;i<N;i++){
        dp[0][i]=dp[0][i-1]+A[0][i];
//        printf("%d ",dp[0][i]);
    }
//    printf("\n%d \n",dp[1][0]);
    for(int i=1;i<N;i++){
        if(dp[0][i]<dp[1][i-1]){
            dp[1][i]=dp[1][i-1]+A[1][i];
        }
        else{
            dp[1][i]=dp[0][i]+A[1][i];
        }
    }
    printf("%d\n",dp[1][N-1]);
    return 0;
}


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

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

int main() {
    int n;
    cin >> n;
    int a[2][n];
    rep(i,n){
        cin >> a[0][i];
    }
    rep(i,n){
        cin >> a[1][i];
    }
    int res=0;
    int sum=0;
    rep(i,n){
        int k =0;
        rep(j,n){
            if(i == j){
                sum+= a[k][j];
                k++;
                sum+= a[k][j];
            }else{
                sum+= a[k][j];
            }
        }
        res = max(res,sum);
        sum = 0;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int num;
int main(){
	scanf("%d",&num);
	int n=num%10;
	if(n==2||n==4||n==5||n==7||n==9){
		printf("hon");
	}else if(n==0||n==1||n==6||n==8){
		printf("pon");
	}else{
		printf("bon");
	}
	return 0;
} 

Measured memory_bytes: 3724
#include<stdio.h>
int a[1000000]={0};

int main(void){
int i,j,b,c;
while(scanf("%d",&b)!=EOF){
c=0;
for(i=2;i<=b;i++){
    if(a[i]==1)continue;
            if(a[i]==0){
            c++;
            }
    for(j=2;i*j<=b;j++){
        a[i*j]=1;
    }
     //if(a[i]==0){
    //printf("%d\n",i);
    //}
}
    printf("%d\n",c);
}
return 0;
}

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

int main(){
	int n, i;
    cin>>n;
  	int a[n];
  	for(i=0;i<n;i++){
    	cin>>a[i];
    }
  	for(i=0;i<n;i++){
    	if(a[i]%2==0){
        	if(a[i]%3!=0 && a[i]%5!=0){
            	break;
            }
        }
    }
  	if(i==n){
    	cout<<"APPROVED"<<endl;
    }else{
    	cout<<"DENIED"<<endl;
    }
  	
  return 0;
  
}

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

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll left=a-b;
    if(c-left>0){
        cout<<c-left<<endl;
    }else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    if x > pre_x:
        a = x - pre_x
        b = 0
    else:
        b = pre_x - x
        a = 0
    if y > pre_y:
        c = y - pre_y
        d = 0
    else:
        d = pre_y - y
        c = 0
    total = a+b+c+d
    if t - pre_t >= total and (t - pre_t - total) % 2 == 0:
        count += 1
    else:
      print("No")
      break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")

Measured memory_bytes: 3064
<?php
while(true){
    list($H,$W) = explode(" ",trim(fgets(STDIN)));
    if($H == 0 && $W == 0) break;
    for($i = 0; $i < $H; $i++){
        for($j = 0; $j < $W; $j++){
            if(($i % 2 == 0 && $j % 2 == 0) || ($i % 2 != 0 && $j % 2 != 0)){
                echo "#";
            } else {
                echo ".";
            }
        }
        echo "\n";
    }
    echo "\n";
}

Measured memory_bytes: 15232
import sys
from operator import itemgetter

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    C = [[int(i) for i in input().split()] for _ in range(M)]
    C.sort(key=itemgetter(1), reverse = True)
    counter = 0
    for b, c in C:
        end = False
        for j in range(b):
            if counter > N - 1: 
                end = True
                break
            if A[counter] < c:
                A[counter] = c
                counter += 1
            else:
                end = True
                break
        if end: break
    print(sum(A))
        
    return 0

if __name__ == "__main__":
    solve()

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

bool f(string s) {
  string t = s;
  reverse(all(t));
  return s == t;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  cout << (f(s) & f(s.substr(0, n / 2)) & f(s.substr(n / 2 + 1)) ? "Yes" : "No")
       << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  a[0] = 0; b[0] = 0;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < m; i++) cin >> b[i];
  
  int ans = 0, j = m;
  ll tot = 0;
  for(int i = 0; i < m; i++) tot += b[i];
  
  for(int i = 0; i < n+1; i++){
    while(tot > k && j > 0){
      j--;
      tot -= b[j];
    }
    if(tot > k) break;
    ans = max(ans, i+j);
    if(i == n) break;
    tot += a[i];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4852
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int n, d, x;
	cin >> n >> d >> x;
	d--;
	x += n;
	REP(i, n) {
		int a;
		cin >> a;
		x += d / a;
	}
	cout << x << endl;
	return 0;
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	ll n;
	cin>>n;
	ll a[n],sum=0;
	map<ll,ll> mp;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
		sum+=a[i];
	}
	ll q,aa,b; 
	cin>>q;
	while(q--){
		cin>>aa>>b;
		sum=sum-mp[aa]*aa+mp[aa]*b;
		mp[b]+=mp[aa];
		mp[aa]=0;
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 10212
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int temp[n]={0};
    for(int i=0;i<k;i++){
        int t;
        cin>>t;
        int a[t];
        for(int j=0;j<t;j++){
            cin>>a[j];
            temp[a[j]-1]++;
        }
    }
    int c=0;
    for(int i=0;i<n;i++){
        if(temp[i]==0){
            c++;
        }
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<int,int>

using namespace std;

int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
pair <int, int> vu[4] = { {0,1}, {0,-1} , {1,0},{-1,0} }; // EWSN

const int max_v = 2e5 + 7;
const int INF = 1e7 + 7;

LL arr[max_v];
LL num[max_v];
int n;

inline LL fun(LL idx)
{
	return (((idx * (idx - 1)) / 2) - (((idx - 1) * (idx - 2)) / 2));
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ci(n);
	fa(i, 0, n)
	{
		ci(arr[i]);
		++num[arr[i]];
	}

	LL sum = 0;
	fa(i, 1, n+1)
	{
		if (num[i] >= 2)
		{
			sum += (num[i] * (num[i] - 1)) / 2;
		}
	}

	fa(i, 0, n)
	{
		co(sum - fun(num[arr[i]]) << "\n");
	}

	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int n,m; cin >> n >> m;
    vector<pair<ll,ll>> p(n);
    rep(i,n){
        int x,y; cin >> x >> y;
        p[i] = make_pair(x,y);
    }
    sort(p.begin(), p.end());
    ll ans = 0;
    for(pair<ll,ll> pa: p){
        if(m > pa.second){
            ans += pa.first*pa.second;
            m -= pa.second;
        } else {
            ans += pa.first*m;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
public class Main
{
	int n,m,A[],B[];
	char s[];
	ArrayList<Integer> list[];
	private void solve()throws IOException
	{
		n=nextInt();
		m=nextInt();
		s=(" "+nextLine()).toCharArray();
		//A[i] is the number of adjacent A to i and similarly B[i]
		A=new int[n+1];
		B=new int[n+1];
		list=new ArrayList[n+1];
		for(int i=1;i<=n;i++)
			list[i]=new ArrayList<>();
		for(int i=1;i<=m;i++)
		{
			int a=nextInt();
			int b=nextInt();
			list[a].add(b);
			if(s[b]=='A')
				A[a]++;
			else
				B[a]++;
			list[b].add(a);
			if(s[a]=='A')
				A[b]++;
			else
				B[b]++;
		}
		boolean bad[]=new boolean[n+1];
		Queue<Integer> queue=new LinkedList<>();
		for(int i=1;i<=n;i++)
			if(A[i]==0 || B[i]==0)
			{
				bad[i]=true;
				queue.add(i);
			}
		while(!queue.isEmpty())
		{
			int v=queue.remove();
			for(int vv:list[v])
			{
				if(bad[vv])
					continue;
				if(s[v]=='A')
					A[vv]--;
				else
					B[vv]--;
				if(A[vv]==0 || B[vv]==0)
				{
					bad[vv]=true;
					queue.add(vv);
				}
			}
		}
		for(int i=1;i<=n;i++)
			if(!bad[i])
			{
				out.println("Yes");
				return;
			}
		out.println("No");
	}

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

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 79120
#include<stdio.h>

int main(void)
{
	int i,n,an[101];

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &an[i]);
	}
	if (n >= 1) printf("%d", an[n - 1]);
	for (i = n-2; i >= 0; i--)
	{
		printf(" %d", an[i]);
	}

	printf("\n");

	return 0;
}


Measured memory_bytes: 2052