akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;

int seiyaku_check(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a,b,c;
	
	cin >> a >> b >> c;
	
	seiyaku_check(a,1,100);
	seiyaku_check(b,1,100);
	seiyaku_check(c,1,100);
	
	if(a*c <= b){
		cout << c << endl;
	}else{
		cout << b/a << endl;
	}
	
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *
 
N, L = MAP()
S = [input() for _ in range(N)]
S.sort()
print("".join(S))

Measured memory_bytes: 5200
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
  cin>>N>>K>>S;
  ll kind = 0; 
  char last = 'z'; 
  rep(i,N){ 
    kind += last != S[i]; 
    last = S[i]; 
  } 
  kind = max(1LL, kind - K*2); 
  cout<<N-kind<<endl;
}


Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 

using namespace std;

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

	cout << (X - A) % B;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

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

    int N;
    cin >> N;

    list<int> a;
    for (int i=0; i<N; i++) {
      int64_t c;
      cin >> c;
      if (i % 2 == 0) {
        a.push_back(c);
      } else {
        a.push_front(c);
      }
    }

    if (N % 2 == 1) {
      reverse(a.begin(), a.end());
    }

    for(auto itr = a.begin(); itr != a.end(); ++itr) {
      cout << *itr << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 8448
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=1;
  cin>>N;
  
  Graph G(N);
  char C[N][N];
  REP(i,N){
    REP(j,N){
      cin>>C[i][j];
      if(C[i][j]=='1') G[i].PB(j);
    }
  }
  
  // 2部グラフ判定 //
  
  bool CAN=true;
  int COLOR[N];
  REP(i,N) COLOR[i]=-1;
  queue<int> Q;
  Q.push(0);
  COLOR[0]=0;
  
  while(!Q.empty()){
    int v=Q.front();
    Q.pop();
    FORE(nv,G[v]){
      if(COLOR[nv]==-1){
        COLOR[nv]=1-COLOR[v];
        Q.push(nv);
      }
      else if(COLOR[nv]!=1-COLOR[v]){
        CAN=false;
        break;
      }
    }
  }
  
  //////////////////
  
  if(CAN){
    REP(i,N){
      ll DIM[N];
      REP(j,N) DIM[j]=-1;
      queue<int> QQ;
      QQ.push(i);
      DIM[i]=1;
      
      while(!QQ.empty()){
        int v=QQ.front();
        QQ.pop();
        FORE(nv,G[v]){
          if(DIM[nv]!=-1) continue;
          DIM[nv]=DIM[v]+1;
          QQ.push(nv);
        }
      }
      
      REP(j,N) chmax(ans,DIM[j]);
    }
    co(ans);
  }
  else co(-1);
  return 0;
}

Measured memory_bytes: 512
H,W = map(int,input().split())
while H != 0 or W != 0:
    for i in range(H):
        for j in range(W):
            if j == 0 or j == W-1 or i == 0 or i == H - 1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()
    H,W = map(int,input().split())



Measured memory_bytes: 7008
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
ll gc(ll a, ll b){
    if(b == 0) return a;
    return gc(b, a % b);
}
ll lcm(ll a, ll b){
    return (a * b) / gc(a, b);
}
string s, t;
bool check(ll len){
    ll n = s.size();
    ll m = t.size();
    map<ll, char> mp;
    for(ll i = 0; i < n; i++){
        ll idx = i * (len / n) + 1;
        mp[idx] = s.at(i);
    }
    for(ll i = 0; i < m; i++){
        ll idx = i * (len / m) + 1;
        if(!mp.count(idx)){
            mp[idx] = t.at(i);
        }else{
            if(mp[idx] != t[i]){
                return false;
            }
        }
    }
    return true;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n, m;
    cin >> n >> m;
    cin >> s >> t;
    ll d = lcm(n, m);
    if(!check(d)){
        cout << -1;
    }else{
        cout << d;
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 14076
using System;
using System.Linq;

namespace AOJ.ITP
{
    public class Finding_a_Word
    {
        public static void Main()
        {
            string find = Console.ReadLine().ToLower();
            int counter = 0;
            while (true)
            {
                string line = Console.ReadLine();
                if (line == "END_OF_TEXT") { break; }
                // 単語に分割
                var words = line.ToLower().Split(' ');

                counter += words.Count(x => x == find);
            }

            Console.WriteLine(counter);
        }
    }
}

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


void solve(std::vector<long long> x){
    for (int i = 0; i < 5; i++) {
        if (x[i] == 0) {

            cout << i + 1 << endl;
            return;
        }
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
//#define ll long long;
double a[3000][3000]={0};

int main() {
    int n,i,j,l;
    double k;
    cin>>n;
    double pro[n];
    for(i=0;i<n;i++)
    {
        cin>>pro[i];
        if(i==0)
        a[0][i]=pro[i];
        else
        {
            a[0][i]=pro[i]*a[0][i-1];
        }
    }
    a[1][0]=1-pro[0];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<n;j++)
        {
            a[i][j]=(a[i-1][j-1]*((double)1-pro[j]))+(a[i][j-1]*pro[j]);
            //cout<<a[i-1][j-1]<<" "<<1-pro[j]<<" | "<<a[i][j-1]<<" "<<pro[j]<<" |||||| ";
        }
        //cout<<endl;
    }
    k=0;
    for(i=0;(n-i)>i;i++)
    {
        //cout<<a[i][n-1]<<" ";
        k+=a[i][n-1];
    }
    cout<<setprecision(15)<<k;
    
}

Measured memory_bytes: 74100
def main():
    h,w,d = map(int,input().split())
    a = []
    for i in range(h):
        a.append(list(map(int,input().split())))
    M = [[] for i in range(h*w)]
    for i in range(h):
        for j in range(w):
            M[a[i][j]-1] = [i,j]
    dist = [0 for i in range(h*w)]
    for i in range(h*w):
        if i-d>=0:
            dist[i] += dist[i-d] + abs(M[i][0]-M[i-d][0]) + abs(M[i][1]-M[i-d][1])

    q = int(input())
    for i in range(q):
        l,r = map(int,input().split())
        print(dist[r-1]-dist[l-1])

if __name__ == "__main__":
    main()

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

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

    vector<int> num(N);
    for(int i=0;i<N;i++){
        cin >> num[i];
    }
    sort(num.rbegin(),num.rend());

    long long sum=0;
    for(int i=0;i<N/2;i++){
        if(i==0){
            sum+=num.at(i)-num.at(N-1)+num.at(i)-num.at(N-2);
        }
        else{
            sum+=num.at(i)-num.at(N-i)+num.at(i)-num.at(N-i-2);
        }
        //if(N%2==0){
          //  sum+=num.at(N/2-1)-num.at(N/2+1);
        //}
    }


    sort(num.begin(),num.end());
    //cout << num[0] << num[1] << num[2] << endl;
    long long sumb=0;
    for(int i=0;i<N/2;i++){
        if(i==0){
            sumb+=-num.at(i)+num.at(N-1)-num.at(i)+num.at(N-2);
        }
        else{
            sumb+=-num.at(i)+num.at(N-i)-num.at(i)+num.at(N-i-2);
        }
        //if(N%2==0){
         //  sum+=num.at(N/2-1)-num.at(N/2+1);
        //}
    }
    //cout << sum << sumb << endl;
    cout << max(sumb,sum) << endl;
    //cout << sum << sumb << endl;

}

Measured memory_bytes: 768
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = 0
for i in range(N):
  if abs(T - 0.006 * H[i] - A) < abs(T - 0.006 * H[ans] - A):
    ans = i
print (ans + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define maxN	100001
#define nl		"\n"
using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << nl;
	else cout << "No" << nl;	
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Get some numbers from stdio and convert it
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums := make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}

	a := nums[0]
	b := nums[1]
	c := nums[2]

	r := c - (a - b)
	if r < 0 {
		r = 0
	}

	fmt.Println(r)
}

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

const int MAXN = 100010;
vector<int> adj[MAXN];
int dist[MAXN];

int dfs(int s) {
    if(dist[s] != -1)
        return dist[s];

    int max_dist = 0;
    for(int & x : adj[s]) 
        max_dist = max(max_dist, 1+dfs(x));
    return dist[s] = max_dist;
}

int main() {
    int N, M;
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
    }

    memset(dist, -1, sizeof dist);
    int res = 0;
    for(int i=1; i<=N; i++)
        res = max(res, dfs(i));
    cout << res << "\n";
}

Measured memory_bytes: 8192
n = int(input())
t = 0
h = 0
for i in range(n):
    s1, s2 = input().split()
    if s1 < s2:
        h += 3
    elif s1 > s2:
        t += 3
    else:
        t += 1
        h += 1
print(t, h)


Measured memory_bytes: 5596
//shan61916
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;

int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, l, s =0;
  cin >> n >> l;
  vector<ll> a(n);
  for(ll i = 0; i < n; i++) {
    a[i] = i + l;
    s+= a[i];
  }
  ll t = INT_MAX;
  ll p;
  for(ll i = 0; i < n; i++) {
    if(abs(s - (s - a[i])) < t){
     t = abs(s - (s- a[i])) ;
     p = a[i];
   }
  }
  cout << s - p;
  return 0;
} //good night.

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
  // とりあえず数字列を
  let Nums = arg.split("\n")[0].split(" ");
  let aPrice = Nums[0]*1;
  let bPrice = Nums[1]*1;
  let abPrice = Nums[2]*1;
  let aNum = Nums[3]*1;
  let bNum = Nums[4]*1;
  let ans = 0;
  let ave = (aPrice + bPrice)/2;
  let is_half_better = (ave > abPrice);
  let smallerNum = aNum > bNum ? bNum : aNum;
  // 
  let oddNum = aNum > bNum ? aNum - bNum : bNum - aNum;
  let biggerNumPrice = aNum > bNum ? aPrice : bPrice;
  // 残った方を半分の方で補うかの処理
  let remPrice = (biggerNumPrice/2) > abPrice ? abPrice*oddNum*2:oddNum * biggerNumPrice;
  
  // どっちを取るべきかのif文
  if(is_half_better){
  	ans = abPrice * smallerNum *2 + remPrice;
  }else{
  	ans = aPrice * aNum + bPrice * bNum;
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
package main

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

//var sc = bufio.NewScanner(os.Stdin)
var nrs = bufio.NewReaderSize(os.Stdin, 1000000)

func readLineToInt() []int {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := nrs.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    line := strings.Split(string(buf), " ")
    var intLine []int
    for _, str := range line {
        n, _ := strconv.Atoi(str)
        intLine = append(intLine, n)
    }
    return intLine
}

/*
func readLineToInt() []int {
    sc.Scan()
    line := strings.Split(sc.Text(), " ")
    var intLine []int
    for _, str := range line {
        n, _ := strconv.Atoi(str)
        intLine = append(intLine, n)
    }
    return intLine
}
*/

func main() {
    ns := readLineToInt()
    n, s := ns[0], ns[1]
    aList := readLineToInt()
    ans := n + 1
    left , right := 0, 0
    acc := aList[0]
    for left < n{
        for acc < s && right < n - 1{
            right++
            acc += aList[right]
        }
        if acc < s {
            break
        }
        if right - left + 1 < ans {
            ans = right - left + 1
        }
        acc -= aList[left]
        left++
    }
    if ans == n + 1 {
        fmt.Println(0)
    } else {
        fmt.Println(ans)
    }
}


Measured memory_bytes: 9220
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

int board[222][222];
int dp[222][222][222][2];
int H, W;

int dfs(int row, int col1, int col2, int flag) {
	int& ret = dp[row][col1][col2][flag];
	if (ret >= 0) return ret;
	ret = 0;
	if (row == H+1) return ret;
	if (flag == 0) {
		// 左の人が右に移動
		if (col1+1 < col2) {
			ret = max(ret, board[row][col1+1] + dfs(row, col1+1, col2, 0));
		}
		ret = max(ret, dfs(row, col1, col2, 1));
	} else {
		// 右の人が右に移動
		if (col2 < W+1) {
			ret = max(ret, board[row][col2+1] + dfs(row, col1, col2+1, 1));
		}
	}
	// 一段下に移動
	ret = max(ret, board[row+1][col1] + board[row+1][col2] + dfs(row+1, col1, col2, 0));
	return ret;
}

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++)
		cin >> board[i][j];
	memset(dp, -1, sizeof(dp));
	cout << dfs(0, 0, 1, 0) << endl;
	return 0;
}


Measured memory_bytes: 85888
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M; cin >> M;
    int sum = 0;
    int digit = 0;
    int ans = 0;
    rep(i, M) {
        int d, c; cin >> d >> c;
        digit += c;
        sum += d * c;
        if (sum >= 100) {
            int dec = (sum - 1) / 9;
            ans += dec;
            sum -= dec * 9;
        }
    }
    ans += (sum - 1) / 9;
    cout << ans + (digit - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B)
    {
        cout << C << endl;
    }
    else if (B == C)
    {
        cout << A << endl;
    }
    else
    {
        cout << B << endl;
    }

    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;


int main()
{
    int n,y;
    int a = -1;
    int b = -1;
    int c = -1;
    int i,j;
    cin >> n >> y;
    
    for (i = 0;i <= n;i++){
        for (j = 0;j <= n-i;j++){
            if (10000*i + 5000*j + (n-i-j)*1000 == y){
                a = i;
                b = j;
                c = n-i-j;
                break;
            }
        }
    }
    
    cout << a << " " << b << " " << c << "\n";
}


Measured memory_bytes: 256
n = gets.to_i
s = gets
cnt = 0
if !(s.include?('R')&&s.include?('W'))
  puts '0'
  return
end

for i in 0...n do
  if s[n-1-i]=='R'
    rr = n-1-i
    break
  end
end

i = 0
while i < rr
  if s[i]=='W'
    cnt += 1
    s[i] = 'R'
    s[rr] = 'W'
    for j in 0..rr
      if s[rr-j]=='R'
        rr = rr-j
        break
      end
    end
  end
  i += 1
end
puts cnt

Measured memory_bytes: 14592
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
#include<iomanip>
using namespace std;
int main() {
	int a[2],b[2];
	scanf("%d%d%d%d",&a[0],&a[1],&b[0],&b[1]);
	int i,j;
	for(i=0;i<b[1]-a[1];i++){
		printf("U");
	}
	for(i=0;i<b[0]-a[0];i++){
		printf("R");
	}
	for(i=0;i<b[1]-a[1];i++){
		printf("D");
	}
	for(i=0;i<b[0]-a[0];i++){
		printf("L");
	}
	
	printf("L");
	for(i=0;i<b[1]-a[1]+1;i++){
		printf("U");
	}
	for(i=0;i<b[0]-a[0]+1;i++){
		printf("R");
	}
	printf("DR");
	for(i=0;i<b[1]-a[1]+1;i++){
		printf("D");
	}
	for(i=0;i<b[0]-a[0]+1;i++){
		printf("L");
	}
	printf("U\n");
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  // priority_queue<int, vi, greater<int>> a;
  priority_queue<int> a;
  for (int i = 0; i < n; i++) {
    int a_tmp;
    cin >> a_tmp;
    a.push(a_tmp);
  }
  // vi b(m);
  // vi c(m);
  // for (int i = 0; i < m; i++) {
  //   cin >> b[i] >> c[i];
  // }
  vector<pii> bc(m);
  for (int i = 0; i < m; i++) {
    int b, c;
    cin >> b >> c;
    bc[i] = pii(b, c);
  }

  // for (int i = 0; i < m; i++) {
  //   for (int j = 0; j < b[i]; j++) {
  //     int val = a.top();
  //     if (val < c[i]) {
  //       a.pop();
  //       a.push(c[i]);
  //     } else {
  //       break;
  //     }
  //   }
  // }
  // ll ans = 0;
  // while (!a.empty()) {
  //   ans += a.top();
  //   a.pop();
  // }

  sort(bc.begin(), bc.end(), [](pii a, pii b) { return a.second > b.second; });

  ll ans = 0;
  int cnt = 0;
  int pidx = 0;
  while (cnt < n) {
    int val = a.top();
    if (pidx < m && val < bc[pidx].second) {
      ans += min(bc[pidx].first, n - cnt) * (ll)bc[pidx].second;
      cnt += min(bc[pidx].first, n - cnt);
      pidx++;
    } else {
      ans += val;
      a.pop();
      cnt++;
    }
    // cout << cnt << ":" << ans << endl;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1528
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  ll d, a;
  cin >> n >> d >> a;
  vector<vector<ll>> x(n, vector<ll>(2));
  for(int i = 0; i < n; i++){
    cin >> x[i][0] >> x[i][1];
  }
  sort(x.begin(), x.end());
  
  ll cnt = 0;
  queue<pair<ll, ll>> que;
  ll sum = 0;
  for(int i = 0; i < n; i++) {
    while(true){
      pair<ll, ll> tmp = que.front();
      if(tmp.first < x[i][0] && !que.empty()){
        sum -= tmp.second;
        que.pop();
      }else{
        break;
      }
    }
    if(x[i][1] <= sum * a) {
      continue;
    }

    ll r = min(x[i][0] + 2 * d, x[n - 1][0]);
    ll bomb = (x[i][1] - sum * a + a - 1) / a;
    //que.push(make_pair(r, bomb));
    que.emplace(r, bomb);
    sum += bomb;
    cnt += bomb;
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 12800
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import heapq
import collections
import itertools
import bisect
mod = 10 ** 9 + 7
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = list(np.array(A)*-1)
heap_tree = heapq.heapify(A)
for i in range(M):
    max_value = heapq.heappop(A)*-1
    max_value = (max_value//2)*-1
    heapq.heappush(A, max_value)
ans = 0
for a in A:
    ans -= a
print(ans)


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

int main()
{
	int a, b;
	cin >> a >> b;
	
	if (a >= 1 && a <= 9)
	{
		if (b >= 1 && b <= 9)
		{
			cout << a * b << endl;
		}
		else
		{
			cout << -1 << endl;
		}
	}
	else
	{
		cout << -1 << endl;
	}
	
	return 0;
}


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

using namespace std;

bool is_prime(long long int n)
{
    if (n < 2)
        return false;

    if (n < 4)
        return true;

    if (n % 2 == 0)
        return false;

    if (n < 9)
        return true;

    if (n % 3 == 0)
        return false;

    long long int i = 5;

    while (i*i <= n)
    {
        if (n % i == 0)
            return false;
        
        if (n % (i+2) == 0)
            return false;

        i = i + 6;
    }

    return true;
}

int main()
{
    long long int x;

    cin >> x;

    while (!is_prime(x))
        x++;

    cout << x << "\n";

    return 0;
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a: print("No War")
    else :print("War")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#x = ip()                              #入力整数1つ
#x,y = (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ma = max(a)
mb = min(b)
z = set([i+1 for i in range(ma,mb)])
xy  =  set([i+1 for i in range(x,y)])
a = xy.intersection(z)
j(len(a))



Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;cin>>a>>b;
    if (a<=5)
    {
        /* code */
        cout<<'0'<<endl;
    }
    else if (a>=6&&a<=12)
    {
        /* code */
        cout<<b/2<<endl;
    }
    else
    {
        cout<<b<<endl;
    }
    
    
    
}

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

vector<int> list[100000];
int num[100000];
int n,m;

void bfs(int s,int sign){

  queue<int> Q;
  Q.push(s);

  while(!Q.empty()){
    int k=Q.front(); Q.pop();
    for(int i=0;i<list[k].size();i++){
      int temp=list[k][i];
      if(num[temp]==-1){ //未訪問なら
        Q.push(temp); num[temp]=sign;
      }
    }
  }
}
int main(){

  cin>>n>>m;

  for(int i=0;i<m;i++){
    int u,v; cin>>u>>v;
    list[u].push_back(v);
    list[v].push_back(u);
  }
  fill(num,num+100000,-1);
  int q; cin>>q;

  int sign=0;
  for(int i=0;i<n;i++){
    if(num[i]==-1){
      bfs(i,sign++);
    }
  }
  for(int i=0;i<q;i++){
    int s,t; cin>>s>>t;
    if(num[s]==num[t] && (num[s]!=-1 || num[t]!=-1)){
      cout<<"yes\n";
    }else{
      cout<<"no\n";
    }
  }

}



Measured memory_bytes: 8932
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int n, p;
bool valid(int x, int y)
{
	if (x < 0 || x >= n) return false;
	if (y < 0 || y > x) return false;
	return true;
}

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

int solve(vector<vi>& v)
{
	int res = 0;
	vector<vi> vis(n);
	REP(i, n)REP(j, i + 1) vis[i].push_back(0);
	REP(i, n)REP(j, i + 1)
	{
		if (v[i][j] == 0 || vis[i][j]) continue;				
		vis[i][j] = 1;
		set<pii> st, emp;
		st.emplace(i, j);
		queue<pii> que; que.emplace(i, j);
		while (!que.empty())
		{
			int x = que.front().first, y = que.front().second;
			que.pop();
			REP(k, 6)
			{
				int nx = x + dx[k], ny = y + dy[k];
				if (!valid(nx, ny)) continue;
				if (v[nx][ny] == 0 && !emp.count(pii(nx, ny)))
				{
					vis[nx][ny] = 1;
					emp.emplace(nx, ny);
					continue;
				}
				if (v[nx][ny] == v[x][y] && !st.count(pii(nx, ny)))
				{
					vis[nx][ny] = 1;
					st.emplace(nx, ny);
					que.emplace(nx, ny);
				}
			}
		}
		if (emp.size()) continue;
		if (v[i][j] == p) res -= st.size();
		else res += st.size();
	}
	return res;
}

int main()
{
	while (cin >> n >> p, n)
	{
		vector<vi> v(n);
		REP(i, n)REP(j, i + 1)
		{
			int a; cin >> a;
			v[i].push_back(a);
		}
		int ans = -INF;
		REP(i, n)REP(j, i + 1) 
		{
			if (v[i][j] == 0)
			{
				auto w = v;
				w[i][j] = p;
				chmax(ans, solve(w));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
import collections
n,m=map(int,input().split())
par=[i for i in range(n+1)]
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
for _ in range(m):
    a,b=map(int,input().split())
    A=find(a)
    B=find(b)
    par[max(A,B)]=par[min(A,B)]
l=[]
for i in range(1,n+1):
    l.append(find(i))
l=collections.Counter(l)
print(max(l.values()))
    

Measured memory_bytes: 126548
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#define mid ((l + r) / 2)
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1.0);

int main() {
    ios_base :: sync_with_stdio(false);
    char s[5];
    bool ans;
    cin >> s;
    for(int i = 0; i < 3; i ++) {
        if(s[i] == s[i + 1]) {
            ans = false;
            break;
        }
        if(i == 2) ans = true;
    }
    if(ans) cout << "Good" << endl;
    else cout << "Bad" << endl;
    return 0;
}

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

int main(){
    string S; long long K; cin >> S >> K; int N = S.length();
    for (int i = 0; i < N - 1; i++) {
        long long n = ('z' - S[i] + 1) % 26;;
        if (n > K) continue;
        S[i] = 'a'; K -= n;
    }
    K %= 26;
    for (int i = 0; i < K; i++) {
        if (S[N-1] == 'z') {
            S[N-1] = 'a';
        } else {
            S[N-1]++;
        }
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
bool f[8][8];
int dx[12]={0,0,0,0,0,0,1,-1,2,-2,3,-3};
int dy[12]={1,-1,2,-2,3,-3,0,0,0,0,0,0};
bool check(int x,int y)
{
	if(x>=0&&x<8&&y>=0&&y<8)
	{
		if(f[x][y])
		{
			return true;
		}
	}
	return false;
}
void dfs(int x,int y)
{
	f[x][y]=false;
	for(int i=0;i<12;i++)
	{
		if(check(x+dx[i],y+dy[i]))
		{
			dfs(x+dx[i],y+dy[i]);
		}
	}
	return ;
}
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<8;j++)
		{
			char s[9];
			cin >> s;
			for(int k=0;k<8;k++)
			{
				if(s[k]=='1')
				{
					f[j][k]=true;
				}
				else
				{
					f[j][k]=false;
				}
			}
		}
		int p,q;
		cin >> p >> q;
		dfs(q-1,p-1);
		cout << "Data " << i+1 << ':' << endl;
		for(int j=0;j<8;j++)
		{
			for(int k=0;k<8;k++)
			{
				if(f[j][k])
				{
					cout << 1;
				}
				else
				{
					cout << 0;
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int F(char*s,int b)
{
	int x[128],c=0;
	x['D']=x['U']=0;
	x['L']=-1;
	x['R']=1;
	int l=-2,r=2;
	for(;*s;++s,b=!b)
	{
		if(c==*s)return 0;
		c=*s;
		if(b)
		{
			if(x[*s]>r)return 0;
			else l=x[*s];
		}
		else
		{
			if(x[*s]<l)return 0;
			else r=x[*s];
		}
	}
	return 1;
}
int main()
{
	int n;
	char s[100008];
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s",s);
		puts((F(s,0)||F(s,1))?"Yes":"No");
	}
	return 0;
}

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

namespace ConsoleApp33 {
    class Program {
        static void Main(string[] args) {
            int D = int.Parse(Console.ReadLine());

            switch (D) {
                case 25:
                    Console.WriteLine("Christmas");
                    break;
                case 24:
                    Console.WriteLine("Christmas Eve");
                    break;
                case 23:
                    Console.WriteLine("Christmas Eve Eve");
                    break;
                case 22:
                    Console.WriteLine("Christmas Eve Eve Eve");
                    break;
            }

        }
    }
}


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

/*
union_find class:
  int n;
  int *par, *rank;

  method: 
    union_find(int n);
    int find(int x);
    void unite(int x, int y);
    bool same(int x, int y);
    void print();
*/


class union_find{
public:
  int n;
  int *par, *rank;

  union_find(int n){
    this-> n = n;
    par = new int[n];
    rank = new int[n];
    init();
  }
  
  int find(int x){
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);

    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }

  int solve(){
    for(int i=0; i<n; i++){

    }
  }

  void print(){
    cout << "---------------" << endl;
    for(int i=0; i<n; i++){
      cout << "par " << i << " : " << par[i] << endl;
    }
    cout << "---------------" << endl;
  }

private:
  void init(){
    for(int i=0; i<n; i++){
      par[i] = i;
      rank[i] = 1;
    }
  }
};

int main(){
  int n, m; cin >> n >> m;
  union_find uf(n);
  int v[n];
  for(int i=0; i<n; i++) cin >> v[i];

  for(int i=0; i<m; i++){
    int x, y;
    cin >> x >> y;
    uf.unite(x-1, y-1);
  }  

  int cnt = 0;
  for(int i=0; i<n; i++){
    if(uf.same(i, v[i]-1)) cnt++;
  }

  cout << cnt << endl;
  /* uf.print(); */
  
  return 0; 
}


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

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

    int n;
    cin>>n;

    set<int> st;
    for (int i=1; i<=n; i++) {
        int x;
        cin>>x;
        st.insert(x);
    }

    if (st.size() == n) cout<<"YES"<<endl;
    else                cout<<"NO"<<endl;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
    int n;cin >> n;
    string s;cin >> s;
    vector<pair<int,int>> left(s.size());//w,eの順
    vector<pair<int,int>> right(s.size());
    if(s[0]=='E') left[0].second = 1;
    else left[0].first = 1;

    if(s[n-1]=='E') right[n-1].second = 1;
    else right[n-1].first = 1;

    for(int i=1;i<n;i++){
        if(s[i]=='E'){
            left[i].second = left[i-1].second+1;
            left[i].first = left[i-1].first;
        }else if(s[i]=='W'){
            left[i].first = left[i-1].first+1;
            left[i].second = left[i-1].second;
        }

        if(s[n-i-1]=='E'){
            right[n-1-i].second = right[n-1-i+1].second+1;
            right[n-1-i].first = right[n-1-i+1].first;
        }else{
            right[n-1-i].first = right[n-1-i+1].first+1;
            right[n-1-i].second = right[n-1-i+1].second;
        }
    }
    /*cout << "left" << endl;
    for(auto &i:left){
        cout << i.first << " ";//w
    }
    cout << endl;
    for(auto &i:left){
        cout << i.second << " ";//e
    }
    cout << endl;
    cout << "right" << endl;
    for(auto &i:right){
        cout << i.first << " ";//w
    }
    cout << endl;
    for(auto &i:right){
        cout << i.second << " ";//e
    }
    cout << endl;*/
    Int ans = INF;
    for(int i=0;i<n;i++){
        Int tmp=0;
        if(i-1>=0){
            tmp+=left[i-1].first;
        }
        if(i+1<n){
            tmp+=right[i+1].second;
        }
        //debug(tmp);
        ans = min(ans,tmp);
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int state = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'A') {
      state = 1;
    } else if (s[i] == 'B' && state == 1) {
      state = 2;
    } else if (s[i] == 'C' && state == 2) {
      ans++;
      state = 0;
    } else {
      state = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main () {
	cin.tie(0);
	cin.sync_with_stdio(0);

	ll x;
	cin >> x;
	ll ans = x / 11 * 2;
	x %= 11;
	if(x && x <= 6) ans++;
	else if(x) ans += 2;
	cout << ans;
}

Measured memory_bytes: 384
def subset_sum(s, a):
	n = len(a)
	dp = [[False for x in range(s+1)] for x in range(n+1)]
	for i in range(n):
		v = a[i]
		for j in range(s+1):
			if v == j:
				dp[i+1][j] = True
			elif v > j:
				dp[i+1][j] = dp[i][j]
			else:
				dp[i+1][j] = dp[i][j] or dp[i][j-v]
	return dp[n][s]

n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for i in range(q):
	if subset_sum(m[i], a) == True:
		print('yes')
	else:
		print('no')



Measured memory_bytes: 5948
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vpi vector<pi>
#define vpl vector<pl>
#define umi unordered_map<int,int>
#define uml unordered_map<ll,ll>
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define inf 1000000000000000
#define md 998244353
#define endl "\n"

ll prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    for (ll i = 2; i <= floor(sqrt(n)); i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
}

ll gcd(ll a, ll b)
{ 
	return !b ? a : gcd(b, a % b); 
}
ll lcm(ll a, ll b)
{ 
	return (a / gcd(a, b)) * b; 
}
ll fastExponentiation(ll n, ll x, ll modulo) 
{
	ll res = 1;
	while(x > 0) 
       {
          if(x & 1)
          res = (res*n) % modulo; 
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res; 
}


ll power(ll n , ll p ){
	if(p==0)
	   return 1;
 
	 ll res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;
 
	   	 return res;
}

int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 

int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 


void solve()
{
    // cout<<fixed<<setprecision(20)<<endl;
	
	string s;
	cin>>s;
	
	int n=s.size();
	
	int l=0,r=n-1;
// 	cout<<l+1<<" "<<r+1<<endl;
	while(l<=r)
	{
	    if(s[l]!=s[r])
	    {
	        cout<<"No\n";
	        return ;
	    }
	    l++; r--;
	}

	l=0,r=(n-1)/2-1;
// 	cout<<l+1<<" "<<r+1<<endl;
	while(l<=r)
	{
	    if(s[l]!=s[r])
	    {
	        cout<<"No\n";
	        return ;
	    }
	    l++; r--;
	}
	
	l=(n+1)/2,r=n-1;
// 	cout<<l+1<<" "<<r+1<<endl;
	while(l<=r)
	{
	    if(s[l]!=s[r])
	    {
	        cout<<"No\n";
	        return ;
	    }
	    l++; r--;
	}
	
	cout<<"Yes\n";
	
	
}


int main()
{
	fastio
	
	// int t; cin>>t; while(t--)
	solve();
	
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++)
    cin>>vec.at(i);
  int count=1;
  int a=0;
  bool finished=false;
  for(int i=1;i<N;i++){
  	for (int j=0;j<i;j++){
      if(vec.at(i)>vec.at(a)){
        finished=true;
        break;
      }
    }
    if(finished==true)
      finished=false;
    else{
      count++;
      a=i;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  ll n, k; cin >> n >> k;

  ll res = 0;
  if(k == 0) res = n*n;
  else {
    for(ll b = k+1; b <= n; ++b) {
      res += (n+1)/b * (b - k);
      res += max(0LL, (n+1)%b - k);
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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=1e9+1;

int main()
{
    rep(i,3){
        rep(j,3){
            char c;
            cin >> c;
            if(i==j) cout << c;
        }
    }
    cout << endl;
    return 0;
} 

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

long long h, w;
vector<string> s;

long long solve();

int main() {
  cin >> h >> w;
  s.resize(h);
  for (auto& p : s) cin >> p;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  auto calc = [](bool ch) {
    long long res = 0;
    vector<vector<int>> sum(h, vector<int>(w, 0));
    using P = pair<int, int>;
    vector<vector<P>> points(h + w);
    for (int i = 0; i < h; ++i)
      for (int j = 0; j < w; ++j) {
        if (i && j) sum[i][j] += sum[i - 1][j - 1];
        if (s[i][j] == '#') {
          ++sum[i][j];
          points[i - j + w].emplace_back(i, j);
        }
      }
    for (auto v : points) {
      int len = v.size();
      for (int i = 0; i < len; ++i)
        for (int j = i + 1; j < len; ++j) {
          P a = v[i], b = v[j];
          int dif = b.first - a.first;
          assert(dif == b.second - a.second);
          auto calcsec = [&](P c, P d) {
            long long res = 0;
            int now = max({0LL, d.first - (h - 1), d.second - (w - 1)});
            d.first -= now, d.second -= now;
            if (d.first < 0 || d.second < 0 || c.first >= h || c.second >= w)
              return 0LL;
            res += sum[d.first][d.second];
            if (c.first >= 0 && c.second >= 0) res -= sum[c.first][c.second];
            return res;
          };
          // down
          P d(a.first + 2 * dif - ch, a.second - ch),
              c(b.first - 1 + ch, b.second - 2 * dif - 1 + ch);
          res += calcsec(c, d);
          // up
          d = P(a.first - ch, a.second + 2 * dif - ch);
          c = P(b.first - 2 * dif - 1 + ch, b.second - 1 + ch);
          res += calcsec(c, d);
        }
    }
    return res;
  };
  res += calc(0);
  for (int i = 0; i < h; ++i) reverse(s[i].begin(), s[i].end());
  res += calc(1);
  return res;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (ll i=0;i<n;i++)
using namespace std;
 
ll n;
ll a[330000];
 
int main() {
  cin>>n;
  rep(i,3*n) cin>>a[i];
  sort(a,a+3*n);
  reverse(a,a+3*n);
  ll ans=0;
  rep(i,n) ans+=a[i*2+1];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

#define MAX (20000)

char prime[MAX + 1];

int main(void)
{
	int i, j;
	int N, num;
	
	prime[0] = prime[1] = 0;
	for (i = 2; i <= MAX; i++){
		prime[i] = 1;
	}
	
	for (i = 2; i * i <= MAX; i++){
		for (j = i * i; j <= MAX; j += i){
			prime[j] = 0;
		}
	}
	
	while (scanf("%d", &N) != EOF){
		num = 0;
		
		for (i = 1, j = N; i <= N; i++, j--){
			if (prime[i] && prime[j]){
				num++;
			}
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}

Measured memory_bytes: 616
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)



signed main(){
	int N,K;
	cin>>N>>K;
	cout<<N-K+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
int n,m;
int a[110];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>m;
	int flag=0;
	int cnt=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		cnt+=a[i];
	}
	for(int i=1;i<=n;i++){
		if(a[i]*4*m>=cnt) flag++;
	}
	if(flag<m) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
   ll x,y;
   cin >> x >> y;
  vector<ll> a = {1,3,5,7,8,10,12};
  vector<ll> b = {4,6,9,11};
  ll gx = 0;
  ll gy = 0;
  for(int i = 0;i < 7;i++){
    if(a[i] == x)gx = 1;
    if(a[i] == y)gy = 1;
  }
  for(int i = 0;i < 4;i++){
    if(b[i] == x)gx = 2;
    if(b[i] == y)gy = 2;
  }
  if(gx == gy)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624