akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

vector<pair<int,LL>> adjlist[101010];
vector<LL> dist(101010);
bool used[101010];
bool flag = 0;

void bfs(int i)
{
    dump(i)
    queue<int> que;
    //LL dist[101010];
    //REP(j,101010) dist[j] = -LINF;
    dist[i] = 0;
    used[i] = true;
    que.push(i);

    //for(auto p : adjlist[i])
    //{
    //    que.push(p.first);
    //    dump(p.first)
    //}
    while(!que.empty())
    {
        int p = que.front(); que.pop();
        dump(p)
        used[p] = true;
        for(auto r : adjlist[p]){
            if(dist[r.first] == -LINF)
            {
                dist[r.first] = dist[p] + r.second;
                //que.push(make_pair(make_pair()))
                que.push(r.first);
            }
            else
            {
                if(dist[r.first] != dist[p]+ r.second)
                {
                    flag = 1;
                    return ;
                }
            }
        }


    }
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    REP(j,101010) dist[j] = -LINF;

    REP(i,101010) used[i] = false;
    REP(i,M)
    {
        int L,R; LL D;
        cin>>L>>R>>D;
        L--; R--;
        adjlist[L].emplace_back(R,D);
        adjlist[R].emplace_back(L,-D);
    }
    REP(i,N)
    {
        if(used[i] == true) continue;

        bfs(i);
        if(flag == 1)
        {
            cout << "No" << endl;
            return 0;
        }

    }
    cout << "Yes" << endl;




}

Measured memory_bytes: 14024
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
#define pi acos(-1)
#define eps 0.000001
using namespace std;

long long x;

int main()
{
    long long ans = 0;
    scanf("%lld", &x);
    ans += x / 11 * 2;
    x %= 11;
    if(x > 6)
        ans += 2;
    else if(x)
        ans += 1;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
		for(int i=0;i<n;i++) 	pq.add(sc.nextInt());

		for(int i=0;i<m;i++) {
			int waribiki = pq.poll();
			waribiki /= 2;
			pq.add(waribiki);
		}

		long ans =0;
		for(int i=0; i<n; i++) ans +=pq.poll();
		System.out.println(ans);
	}
}


Measured memory_bytes: 58428
#include<stdio.h>
#define M 1000000007
#define N_MAX 200000
long long fact[N_MAX+1];

void compute(int N, int H){
  int word[N_MAX], invalid[N_MAX];
  int deleted[100], inserted[100];
  int d_p = 0, i_p = 0;
  int i, j, s, t;
  long long ans = 0, unable;
  for ( i = 0; i < N; i++ ) {
    invalid[i] = 0;
    word[i] = i;
  }

  for ( int i = 0; i < H; i++ ){
    scanf("%d %d", &s, &t);
    s--; t--; // to 0 origin
    int tmp = word[s];
    word[s] = word[t];
    word[t] = tmp;
  }

  for ( i = 0; i < N; i++ ) if ( word[i] != i ) invalid[i] = 1;

  for ( i = 0; i < N; i++ ){
    unable = (word[i] < i) ? word[i] : i;
    for ( j = 0; j < d_p; j++ )
      if ( deleted[j] < word[i] ) unable--;
    for ( j = 0; j < i_p; j++ )
      if ( inserted[j] < word[i] ) unable++;

    ans += ((word[i] - unable) * fact[N-i-1])%M;
    ans %= M;

    if ( invalid[i] ){
      deleted[d_p++] = i;
      inserted[i_p++] = word[i];
    }
  }

  printf("%lld\n", ans);
}

int main(){
  int i;
  fact[0] = 1;
  for (i = 1; i <= N_MAX; i++ ) fact[i] = (fact[i-1]*i)%M;

  int N, H;
  while(1){
    scanf("%d", &N);
    if ( N == 0 ) break;
    scanf("%d", &H);
    compute(N, H);
  }

  return 0;
}




Measured memory_bytes: 4968
lst=[]
tmp=0
ans=0
x=int(input())
for j in range(1,32):
    for i in range(2,11):
        if j**i <= 1000:
            lst.append(j**i)
lst=sorted(lst)
for i in lst:
    tmp=i
    if i>x:
        print(ans)
        exit()
    ans=tmp
    if i==1000:
        print(1000)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n;
	string a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	cin>>m;
	string b[m];
	for(int i=0;i<m;i++)
		cin>>b[i];
	int maxv=0;
	for(int i=0;i<n;i++)
	{
		int sum=0;
		for(int j=0;j<n;j++)
			if(a[j]==a[i])
				sum++;
		for(int j=0;j<m;j++)
			if(b[j]==a[i])
				sum--;
		if(sum>maxv)
			maxv=sum;
	}
	cout<<maxv;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,ll>
#define pli std::pair<ll,int>
#define psi std::pair<string,int>
#define pli std::pair<ll,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%I64d",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,ll>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vli std::vector<li>
#define vlpli vector<list<pli>>
#define lpli list<pli>
#define li std::list<int>
#define Endl printf("\n")
#define ma 1000000
#define mod 998244353
#define Nmax 10000000000000000
using namespace std;

int main()
{
   int n;cin>>n;
   int a[n];
   for(int i=0;i<n;i++) si(a[i]);
   int dp[n];
   dp[0]=0;dp[1]=abs(a[1]-a[0]);
   for(int i=2;i<n;i++){
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
   }
   cout<<dp[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>
 
using namespace std;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

double arc(double px,double py,double nowx,double nowy,double fux,double fuy){
	px-=nowx;py-=nowy;
	fux-=nowx;fuy-=nowy;
	return acos((px*fux+py*fuy)/(hypot(px,py)*hypot(fux,fuy)));
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,idx=0;
    cin>>n;
    double x[n],y[n];
    for(int i=0;i<n;i++){
    	cin>>x[i]>>y[i];
    	if(x[i]>x[idx])idx=i;
    }

    if(n==2){
    	cout <<"0.5\n0.5\n";
    	return 0;
    }
    int p=idx,now;
    double ma=-1.0,th;
    for(int i=0;i<n;i++){
    	if(i==idx)continue;
    	th=arc(x[idx],y[idx]-0.5,x[idx],y[idx],x[i],y[i]);
    	if(th>ma)now=i,ma=th;
    }
    int memo=now;
    double ans[n];
    for(int i=0;i<n;i++){
    	ans[i]=0.0;
    }
    while(1){
    	ma=-1.0;
    	int tmp;
    	for(int i=0;i<n;i++){
    		if(i==now||i==p)continue;
    		th=arc(x[p],y[p],x[now],y[now],x[i],y[i]);
    		if(th>ma)tmp=i,ma=th;
    	}
    	ans[now]=(M_PI-ma)/(M_PI*2.0);
    	p=now;
    	now=tmp;
    	if(now==idx){
    		ans[now]=(M_PI-arc(x[p],y[p],x[now],y[now],x[memo],y[memo]))/(M_PI*2.0);
    		break;
    	}
    }
    for(int i=0;i<n;i++){
    	doublecout(ans[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 int a,b;
 int count =0;
 cin >> a>>b;
 int c[b];
 rep(i,b){
   cin >>c[i];
   count +=c[i];
 }
 if(count-a>=0){
   cout << "Yes" << endl;
 }else{
   cout << "No" <<endl;
 }
 return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
void YES(bool che){
    if(che)cout<<"YES\n";
    else cout<<"NO\n";
}
void Yes(bool che){
    if(che)cout<<"Yes\n";
    else cout<<"No\n";
}
int n;
ll x[5];
ll dp[4];
int main(void){
   cin>>n;
   for(int i=0;i<n;i++){
       char c[15];
       cin>>c;
       if(c[0]=='M')x[0]++;
       else if(c[0]=='A')x[1]++;
       else if(c[0]=='R')x[2]++;
       else if(c[0]=='C')x[3]++;
       else if(c[0]=='H')x[4]++;
   }
   for(int i=0;i<5;i++){
       if(x[i]>0){
           dp[3]+=dp[2]*x[i];
           dp[2]+=dp[1]*x[i];
           dp[1]+=x[i];
       }
   }
   cout<<dp[3]<<endl;
}


Measured memory_bytes: 256
def readinput():
    n=int(input())
    l=list(map(int,input().split()))
    return n,l

def main(n,a):
    MOD=10**9+7
    hist=[0]*61
    bs=[]
    for i in range(n):
        # s=list(reversed(bin(a[i])[2:]))
        # for j in range(len(s)):
        #     if s[j]=='1':
        #         hist[j]+=1
        # bs.append(s)

        s=bin(a[i])[2:]
        for j in range(len(s)):
            if s[j]=='1':
                hist[len(s)-j-1]+=1
        # j=0
        # ai=a[i]
        # while ai>0:
        #     if ai&1==1:
        #         hist[j]+=1
        #     ai = ai >> 1
        #     j+=1


    #print(bs)
    #print(hist)
    #print(hist)
    sum=0
    # for i in range(n-1):
    #     s=bs[i]
    #     b=1
    #     for j in range(len(s)):
    #         if s[j]=='0':
    #             sum=(sum+hist[j]*b)%MOD
    #         else:
    #             sum=(sum+( n-i-hist[j] )*b)%MOD
    #             hist[j]-=1
    #         b*=2
    #     for j in range(len(s),61):
    #         sum=(sum+hist[j]*b)%MOD
    #         b*=2
    b=1
    for j in range(61):
        sum=(sum+( hist[j]*(n-hist[j])*b )%MOD )%MOD
        b*=2

    return sum

if __name__=='__main__':
    n,l=readinput()
    ans=main(n,l)
    print(ans)


Measured memory_bytes: 50660
package main

import (
	"fmt"
)

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func main() {
	var n int
	fmt.Scan(&n)

	nums := scanNums(n)

	sum := 0
	for leftIndex, left := range nums {
		for rightIndex := leftIndex + 1; rightIndex < len(nums); rightIndex++ {
			right := nums[rightIndex]

			heal := left * right
			sum += heal
		}
	}

	fmt.Println(sum)
}

Measured memory_bytes: 512
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i32>();
    let (w, a, b) = (line[0], line[1], line[2]);

    let (a, b) = (cmp::min(a, b), cmp::max(a, b));
    println!("{}", cmp::max(b-a-w, 0));
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
#define error(args...) { vector<string> _debug = split(#args, ',');err(begin(_debug), args);}

vector<string> split(const string& s, char c){
	vector<string> v;stringstream ss(s);string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {cerr << endl;}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a,Args... args){
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << " ",err(++it, args...);
}


const int inf = 1 << 28;
int idx[2010][2];
const int limit = 2010;
int dp[limit][limit];

template <int depth> struct Binary_indexed_tree {
	using T = int;
	const static int h = depth;
	const static int n = 1 << h;
	T data[n];

	void init() {
		fill_n(data, n, 0);
	}

	void add(int i, T x) {
		for (i++; i < n; i += i & -i) {
			data[i] += x;
		}
	}

	T sum(int i) {
		T ret = 0;
		for (i++; i > 0; i -= i & -i){
			ret += data[i];
		}
		return ret;
	}
};

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

	Binary_indexed_tree<15> white,black;

	rep(i,2*n){
		char c;
		int v;
		cin >> c >> v;
		v--;

		if(c == 'W')
			idx[v][0]=i;
		else
			idx[v][1]=i;
		
	}

	rep(i,n+1)rep(j,n+1) dp[i][j] = inf;
	dp[0][0] = 0;

	white.init();
	rep(i,n+1){
		black.init();
		rep(j,n+1){
			if(i+1<=n){
				const int tmp = idx[i][0];
				const int num = max(0,tmp - white.sum(tmp) - black.sum(tmp));
				//error("white",i,j,num);
				chmin(dp[i+1][j],dp[i][j]+num);
			}

			if(j+1<=n){
				const int tmp = idx[j][1];
				const int num = max(0,tmp - white.sum(tmp) - black.sum(tmp));
				//error("black",i,j,num);
				chmin(dp[i][j+1],dp[i][j]+num);
			}

			black.add(idx[j][1],1);
		}
		white.add(idx[i][0],1);
	}

	cout << dp[n][n] << endl;

	return 0;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  int a, b; cin >> a >> b;
  if(b*2<=a) cout << a-2*b << endl;
  else cout << 0 << endl;
}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> dp(n);
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
    if (i > 1) {
      dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

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

    vector<bool> used(K, false);

    int x = 0;
    int cnt = 0;
    bool ok = true;
    while (1) {
        x = (x * 10 + 7) % K;

        if (used[x]) {
            ok = false;
            break;
        }

        used[x] = true;
        cnt++;
        if (x == 0) {
            break;
        }
    }

    if (ok) {
        cout << cnt << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3768
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;
    cin>>n;
    vll a(n);

    rep(i,n){
        cin>>a[i];
    }

    ll ans2=10000000;
    for(int i= -100;i<=100;i++){
        ll ans=0;    
        rep(j,n){ans+=(i - a[j])*(i - a[j]);}
        ans2= min(ans2,ans);
    }

    cout<<ans2<<endl;   
}

Measured memory_bytes: 3580
while True:
    h,w = map(int, input().split()) 
    if h == 0 and w == 0:
        break
    for y in range(h):
        print("#",end="")
        if y == 0 or y == h-1:
            str = '#'
        else:
            str = '.'
        for x in range(w-2):
            print(str,end="")
        print("#")
    print()


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 100111, inf = 1000111222;

string s;

void bad() {
    cout << -1 << endl;
    exit(0);
}

vector<pair<int, int> > ans;

void add(int a, int b) {
    ans.PB({a, b});
}

int build(int sz, int cur) {
    add(cur, cur + 1);
    ++cur;
    int nxt = cur + 1;
    for (int i = 1; i < sz; ++i) {
        add(cur, nxt);
        if (s[i] == '1') {
            cur = nxt;
        }
        ++nxt;
    }
    return cur;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> s;
    if (s[0] != '1' || s.back() != '0') {
        bad();
    }
    s.pop_back();

    for (int i = 0; i <= s.size() / 2; ++i) {
        if (s[i] != s[s.size() - i - 1]) {
            bad();
        }
    }
    if (s.size() == 1) {
        cout << "1 2" << endl;
        return 0;
    }
    if (s.size() == 2) {
        cout << "1 2" << endl;
        cout << "2 3" << endl;
        return 0;
    }
    if (s.size() % 2 == 1) {
        int r1 = build(s.size() / 2, 0);
        int r2 = build(s.size() / 2, s.size() / 2 + 1);
        if (s[s.size() / 2] == '1') {
            add(r1, r2);
        } else {
            for (int i = 0; i < ans.size(); ++i) {
                if (ans[i].F == r2) {
                    ans[i].F = r1;
                }
                if (ans[i].S == r2) {
                    ans[i].S = r1;
                }
            }
            add(r1, r2);
        }
    } else {
        int r1 = build(s.size() / 2 - 1, 0);
        int r2 = build(s.size() / 2 - 1, s.size() / 2);
        int left = s.size();
        if (s[s.size() / 2] == '1') {
            add(r1, left);
            add(left, r2);
        } else {
            for (int i = 0; i < ans.size(); ++i) {
                if (ans[i].F == r2) {
                    ans[i].F = r1;
                }
                if (ans[i].S == r2) {
                    ans[i].S = r1;
                }
            }
            add(r1, r2);
            add(r1, left);
        }
    }
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i].F + 1 << ' ' << ans[i].S + 1 << "\n";
    }
    return 0;
}





Measured memory_bytes: 2420
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>


using ll = long long int;

constexpr int MAX_N = 55, MAX_S = 2500;

int n, a;
int x[MAX_N];
//ll dp[MAX_N][MAX_N + 1][MAX_S + 1];

template<typename T>
::std::vector<T> make_vec(int n, T&& v) { return ::std::vector<T>(n, ::std::forward<T>(v)); }
template <class... Args>
auto make_vec(int n, Args... args) {
	auto val = make_vec(::std::forward<Args>(args)...);
	return ::std::vector<decltype(val)>(n, move(val));
}
auto dp = make_vec(MAX_N, MAX_N + 1, MAX_S + 1, 0ll);

int main() {

	std::cin >> n >> a;

	for (int i = 0; i<n; ++i)
		std::cin >> x[i];

	dp[0][0][0] = 1;
	dp[0][1][x[0]] = 1;

	for (int i = 1; i<n; ++i) {
		dp[i][0][0] = 1;
		for (int j = 1; j <= i + 1; ++j) {
			for (int k = 0; k <= MAX_S; ++k) {
				dp[i][j][k] = dp[i - 1][j][k];
				if (k >= x[i])
					dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
			}
		}
	}

	ll ans = 0;

	for (int i = 1; i <= MAX_S; ++i) {
		if (i%a == 0) {
			if (i / a > MAX_N) { break; }
			ans += dp[n - 1][i / a][i];
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

#endif


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

int main()
{
    string str,str1;
    cin>>str>>str1;
    int n=str.length();
    if(str1.substr(0,n)==str)
     {cout<<"Yes";
     }
    else
     {cout<<"No";
     }

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
using namespace std;
int main() {
	vector<int> S, T;
	int time, code;
	cin >> time;
	for (int i = 0; i < time; ++i) {
		cin >> code;
		S.push_back(code);
	}
	cin >> time;
	for (int i = 0; i < time; ++i) {
		cin >> code;
		T.push_back(code);
	}
	vector<int>::iterator heS, heT;
	int answer=0;
	for (heT = T.begin(); heT != T.end(); ++heT) {
		heS = S.begin();
		S.push_back(*heT);
		while (*heT != *heS) {
			++heS;
		}
		if (heS != S.end() - 1)++answer;
		S.pop_back();
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 1320
S=input()

def solve(s,c):
  ch=True
  for i in range(len(s)-1):
    if s[i]!=s[i+1]:
      ch=False
  if ch:
    return 0
  else:
    ans=""
    for i in range(len(s)-1):
      if s[i]==c or s[i+1]==c:
        ans+=c
      else:
        ans+=s[i]
    return solve(ans,c)+1
  
ans=100
for i in range(len(S)):
  ans=min(ans,solve(S,S[i]))

print(ans)

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


int main(){

	string s;
	long k;
	cin >> s >> k;
	for(int i = 0; i < k; i++)
	{
		if(s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.NoSuchElementException;

import java.util.Arrays;

public class Main {
	
	int N,nMin,nMax;
	public void solve() {
		while(true){
			N = nextInt();
			nMin = nextInt();
			nMax = nextInt();
			
			if(N + nMin + nMax == 0)break;
			
			int[] p = new int[N];
			
			for(int i = 0;i < N;i++){
				p[i] = nextInt();
			}
			
			int gap = 0;
			int num = 0;
			
			for(int i = nMin;i <= nMax;i++){
				if(gap <= p[i - 1] - p[i]){
					gap = p[i - 1] - p[i];
					num = i;
				}
			}
			
			out.println(num);
		}
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
 
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}
 
	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt() {
		return Integer.parseInt(next());
	}
 
	public long nextLong() {
		return Long.parseLong(next());
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 31284
#include<stdio.h>
int min(int a, int b)
{
    if (a < b)
        return a;
    else
        return b;
}
int main()
{
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    int i;
    int ans[3] = {};
    int p;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &p);
        if (p <= a)ans[0]++;
        else if (p <= b)ans[1]++;
        else ans[2]++;
    }
    printf("%d\n", min(min(ans[0], ans[1]), ans[2]));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) (((a%MOD+MOD)%MOD+(b%MOD+MOD)%MOD)%MOD)
#define MUL(a, b) ((((a%MOD+MOD)%MOD)*((b%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }
template<typename I> int ACC(I f, I l, int i){ return accumulate(f, l, i); }


int N, C;
int D[40][40];
int c[510][510];
int a[3][40];
int b[3][40];


signed main(){
    cin >> N >> C;
    rep(i, 0, C) rep(j, 0, C) cin >> D[i][j];
    rep(i, 0, N) rep(j, 0, N) cin >> c[i][j], c[i][j]--;

    rep(i, 0, N) rep(j, 0, N) a[(i+j)%3][c[i][j]]++;

    rep(i, 0, 3) rep(j, 0, C) rep(k, 0, C) b[i][j] += D[k][j]*a[i][k];

    int ans = INF;
    rep(i, 0, C){
        rep(j, 0, C){
            if(i == j) continue;
            rep(k, 0, C)
                if(j != k && i != k) chmin(ans, b[0][i]+b[1][j]+b[2][k]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2304
N, M = map(int, input().split())
votes = list(map(int, input().split()))
min_votes = sum(votes) * 1.0 / (4*M)
votes_greater_than_min = list(filter(lambda x: x >= min_votes, votes))
if len(votes_greater_than_min) >= M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define al(s) s.begin(),s.end()

typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
typedef pair<int, ppi> pipp;


int main()
{
	int m;
	while (cin >> m&&m)
	{
		vector<pi> a;
		for (int r = 0; r < m; r++)
		{
			int num; cin >> num;
			int score = 0;
			int k[21], j[21];
			memset(k, -1, sizeof(k));
			memset(j, -1, sizeof(j));
			for (int i = 0; i < 18; i += 2)
			{
				cin >> k[i];
				if (k[i] == 10)
				{
					j[i] = 2;
				}
				else
				{
					cin >> k[i + 1];
					if (k[i] + k[i + 1] == 10)
					{
						j[i + 1] = 1;
					}
				}
			}
			cin >> k[18] >> k[19];
			if (k[18] + k[19] >= 10)
			{
				cin >> k[20];
			}
			for (int i = 0; i < 21; i++)
			{
				if (j[i] == 1)
				{
					k[i] += k[i + 1];
				}
				else if (j[i] == 2)
				{
					k[i] += k[i + 2];
					if (k[i + 3] == -1)
					{
						k[i] += k[i + 4];
					}
					else
					{
						k[i] += k[i + 3];
					}
				}
			}

			for (int i = 0; i < 21; i++)
			{
				score += max(0, k[i]);
			}
			a.push_back(pi(score, num));
		}
		sort(a.begin(), a.end());
		reverse(a.begin(), a.end());
		bool che = true;
		while (che)
		{
			che = false;
			for (int i = 1; i < m; i++)
			{
				if (a[i].second < a[i - 1].second&&a[i].first == a[i - 1].first)
				{
					swap(a[i], a[i - 1]);
					che = true;
				}
			}

		}
		for (int i = 0; i < m; i++)
		{
			cout << a[i].second << " " << a[i].first << endl;
		}

	}
}

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

nodes = []
edge = []
for i in range(N):
    nodes.append([])

for i in range(N-1):
    a, b = [int(v) - 1 for v in input().split(' ')]
    if a >= len(nodes):
        exit()
    if b >= len(nodes):
        exit()
    nodes[a].append((b, i))
    nodes[b].append((a, i))
    edge.append(0)

max_l = 0
max_i = 0
if nodes is None:
    exit()

for i, links in enumerate(nodes):
    if links is None:
        exit()
    l = len(links)
    if max_l < l:
        max_l = l
        max_i = i

def fill(nodes, edge, queue):
    while len(queue) > 0:
        ni, pc = queue.pop(0)
        links = nodes[ni]

        c = 1
        if pc == c:
            c += 1

        if links is None:
            exit()

        next_links = []
        for n, i in links:
            if n < 0 or i < 0:
                exit()
            if n >= len(nodes) or i >= len(edge):
                exit()

            if edge[i] != 0:
                continue
            edge[i] = c
            queue.append((n, c))

            c += 1
            if pc == c:
                c += 1

queue = [(max_i, 0)]    
fill(nodes, edge, queue)

print(max_l)
for e in edge:
    print(e)

Measured memory_bytes: 39652
# a=input()
N=int(input())
#a,b=map(int,input().split(" "))
#a=[int(_) for _ in input().split(" ")]

ans=0

a = N // 10

N = N - 10 * a

if N==3:
    ans="bon"
elif N==0 or N==1 or N==6 or N==8:
    ans="pon"
else:
    ans="hon"
#print(a,b)
print(ans)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;

const int N = 1e6 + 69;

ll n,m,k,x,y,ans;

ll A[N];

vector< ll > v;

string s;

int main(){

    ios::sync_with_stdio(0);

    cin>>n;

    for(ll i=1;i<=60;i++)
    if(n>=(1LL<<i)){
        x = i;
    }

    cout<<(1LL<<(x+1))-1<<endl;

}


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

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = reader.nextInt();
        }
        System.out.println(solve(a));
    }

    private static int solve(int[] a) {
        int[] dp = new int[a.length];
        Arrays.fill(dp, Integer.MAX_VALUE);
//        return findMin(a.length - 1, a.length - 1, a, dp);
        return findMin2(0, 0, a, dp);
    }

    private static int findMin(int curPos, int prevPos, int[] a, int[] dp) {
        if (curPos < 0)
            return Integer.MAX_VALUE;
        if (dp[curPos] > 0)
            return dp[curPos];
        int score = Math.abs(a[curPos] - a[prevPos]);
        if (curPos == 0) {
            return score;
        }
        int min = Math.min(
                findMin(curPos - 1, curPos, a, dp),
                findMin(curPos - 2, curPos, a, dp));
        dp[curPos] = min;

        return min + score;
    }

    private static int findMin2(int curPos, int prevPos, int[] a, int[] dp) {
        if (curPos >= dp.length)
            return Integer.MAX_VALUE;
        int score = Math.abs(a[curPos] - a[prevPos]);
        if (curPos == a.length - 1)
            return score;
        int min;
        if (dp[curPos] != Integer.MAX_VALUE) {
            min = dp[curPos];
        } else {
            min = Math.min(findMin2(curPos + 1, curPos, a, dp), findMin2(curPos + 2, curPos, a, dp));
            dp[curPos] = min;
        }
        return min + score;
    }
}


Measured memory_bytes: 61624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  string str1,str2;
  cin >> str1 >> str2;
  int k1 = str1.length();
  int k2 = str2.length();
  if(k1>k2)
    cout << "GREATER" << endl;
  else if(k1<k2)
    cout << "LESS" << endl;
  else if(k1==k2)
  {
    if(str1==str2)
      cout << "EQUAL" << endl;
    else
    {
      int p=0;
      for(int i=0;i<k1;i++)
      {
        int a1 = str1[i]-'0';
        int a2 = str2[i]-'0';
        if(a1>a2)
        {
          p=1;
          break;
        }
        else if(a1<a2)
        {
          p=2;
          break;
        }
      }
      if(p==2)
        cout << "LESS" << endl;
      else if(p==1)
        cout << "GREATER" << endl;
     }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n,i,status1=1,status2=1,k;
    int a[1000];
    cin>>x>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if(n==0)
    {
        cout<<x;
    }
    else
    {
        k=-1;
        while(status1==1&&status2==1)
        {
            status1=0;
            status2=0;
            k++;
            for(i=0;i<n;i++)
            {
              if(a[i]==x+k)
              {
                  status1=1;
              }
              if(a[i]==x-k)
              {
                  status2=1;
              }
            }
        }
        if(status2==0)
        {
            status1=1;
            cout<<x-k;
        }
        if(status1==0)
        {
            cout<<x+k;
        }
    }
    return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;

// 座標 corrdinate と深さを保持するための構造体
struct Corr {
    int h;
    int w;
    int depth;
};

int H, W;  // 迷路の縦，横
int s_h, s_w, g_h, g_w;  // スタート，ゴールの座標
int h, w, depth;  // キューから取り出した座標
queue<Corr> q;
bool seen[50][50];

vector<int> h_vec = {0, 0, -1, +1};  // 進む方向の簡便化，テクニックとして覚えておく．
vector<int> w_vec = {-1, +1, 0, 0};  // ループで回すことで上下左右に移動できるようになっている
vector<string> s;

vector<vector<int>> bfs() {
    vector<vector<int>> dist(H, vector<int>(W));
    while (!q.empty()) {
        Corr now = q.front(); q.pop();  // キューの先頭を取り出す
        h = now.h, w = now.w, depth = now.depth;  // 行，列が y, x になっているので注意
        dist[h][w] = depth;
        //cout<<y<<" "<<x<<" "<<depth<<endl;
        // 停止条件：現在の座標がゴールなら深さを返す
        // if (h == g_h && w == g_w) return depth;

        // 上下左右 4 方向を探索．進むことができればキューに格納する．
        REP(i,4) {
            Corr next = {h + h_vec[i], w + w_vec[i], depth + 1};
            if (0 <= next.h && next.h <= H-1 && 0 <= next.w && next.w <= W-1 && seen[next.h][next.w] == false && s[next.h][next.w]=='.') {
                seen[next.h][next.w] = true;  // 同じ場所を探索しないようにする
                q.push(next);
            }
        }
    }
    return dist;
}

signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    // Failed to predict input format
    cin>>H>>W;
    s.resize(H);
    REP(i,H) cin>>s[i];
    int ans = 0;
    REP(i,H){
        REP(j,W){
            REP(k,H){
                REP(l,W){
                    s_h=i; s_w=j; g_h=k; g_w=l;
                    if(s[i][j]=='.'&&s[k][l]=='.'&&(i!=k||j!=l)){
                        Corr start = {s_h, s_w, 0};  // 初期位置の深さ(depth)は 0
                        q.emplace(start);// 初期位置をキューに格納
                        memset(seen, false, sizeof(seen));
                        seen[s_h][s_w] = true;
                        auto dist = bfs();
                        //REP(x, H){
                        //    REP(y, W){
                        //        cout << dist[x][y] << " ";
                        //    }
                        //    cout << endl;
                        //}
                        ans = max(dist[g_h][g_w], ans);
                        // ans = max(bfs(),ans);
                    } else continue;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b,c,x; 
    scanf("%d %d %d",&a,&b,&c);
  if(a > b)
 {
    x=b;
    b=a;
    a=x;
 }
  if( b > c)
 {
    x=b;
    b=c; 
    c=x;
 }
  if(a > b)
 {
    x=b;
    b=a;
    a=x;
 }
   printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(long long)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;
int sz=262144;complex<double> y[262160],A[262160],B[262160];

void dft(complex<double> *x,bool inv);
#define P pair<int,int>



//始点、終点の設定は適宜やる

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

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
  /*  cin >>h>>w;
    vector<vector<int>> a(h,vector<int>(w));
    rep(i,h)rep(j,w)cin >>a[i][j];*/

  string s;cin >>s;
  string t1=s.substr(0,(s.size()+1)/2-1);
  reverse(all(s));
  string t2=s.substr(0,(s.size()+1)/2-1);
  if(kaibun(t1)&&(t1==t2))cout <<"Yes"<<endl;
  else cout <<"No"<<endl;


}

void dft(complex<double> *x,bool inv){
    for(int i=sz>>1;i>=1;i>>=1){
        complex<double> zeta=polar(1.0,2.0*acos(-1)*i/sz*(inv?-1.0:1.0)),now=1;
        for(int j=0;2*j<sz;j+=i){//i飛ばし
            rep(k,i) {
                y[k+j]=x[2*j+k]+now*x[2*j+i+k];
                y[j+k+(sz/2)]=x[2*j+k]-now*x[2*j+i+k];//sz/2以上のやつ。原点対称を利用
            }
            now*=zeta;
        }
        rep(i,sz)x[i]=y[i];//探索の区間の幅を狭める前にこぴー
    }

    if(inv)rep(i,sz)x[i]/=sz;

}


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

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

int main() {
    int N, M, A;
    cin >> N >> M;
    priority_queue<int> q;
    rep(i, N) {
        cin >> A;
        q.push(A);
    }
    rep(i, M) {
        A = q.top();
        q.pop();
        q.push(A / 2);
    }
    ll ans = 0;
    while (!q.empty()) {
        A = q.top();
        ans += A;
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[100022];
//ll b[100022];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
       // b[i]=a[i]*2;
    }
    int sum=1;
    sort(a,a+n);
    ll maxx=a[0];
    for(int i=1;i<n;i++)
    {
        if(maxx*2>=a[i])
        {
            sum++;
            maxx+=a[i];
        }
        else
        {
            sum=1;
            maxx+=a[i];
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    long long int x,y;
    cin>>x>>y;
    long long int ans;
    if(x%y==0){
        ans=-1;
    }else{
        ans=x*(y-1);
    }
    cout<<ans<<endl;
    return 0;
}

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

using ll=long long;
using ld=long double;

void solve(){
	int n;
	cin>>n;
	if(n>=30){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x>y?y:x;}

int main(){
    char str[10];

    scanf("%s",str);
    for(int i=0;str[i+1]!='\0';i++){
        if(str[i]==str[i+1]){
            printf("Bad\n");
            return 0;
        }
    }
    printf("Good\n");
    return 0;
}

Measured memory_bytes: 128
import math

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort(reverse = True)
    return divisors

A.sort()
l0 = make_divisors(A[0])
l1 = make_divisors(A[1])

if n == 2:
    gcd_max = max(A[0], A[1])
else:
    for d in l1:
        count = 0
        for i in range(2, n):
            if A[i] % d != 0:
                count += 1
            if count > 0:
                break
        if count == 0:
            gcd1 = d
            break
    for d in l0:
        count = 0
        for i in range(1, n):
            if A[i] % d != 0:
                count += 1
            if count > 1:
                break
        if count <= 1:
            gcd2 = d
            break
    gcd_max = max(gcd1, gcd2)

print(gcd_max)


Measured memory_bytes: 14588
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	let
		odds = length $ filter odd [ 1 .. n ]
	printf "%.10f\n" $ ( fromIntegral odds :: Double ) / fromIntegral n

Measured memory_bytes: 508
#include<cstdio>
#include<vector>
using namespace std;
int main(void){
	int i,q,wa=0,w;
	vector<int>a;
	int N,M;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&q);
		a.push_back(q);
		wa+=q;
	}
	scanf("%d",&M);
	for(;M>0;M--){
		scanf("%d %d",&q,&w);
		q--;
		printf("%d\n",wa-a[q]+w);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstdio>   
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;


int main(){
    ofstream out("output.txt");

    int n;
    cin>>n;

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

    int res = 0;
    int x,y,z;
    for(int i = 1; i<n-1; i++){
        aux.pb(a[i-1]);
        aux.pb(a[i]);
        aux.pb(a[i+1]);
        sort(aux.begin(),aux.end());
        if(aux[1] == a[i])res++;
        aux.clear();
    }
    cout<<res<<endl;

    return 0;
}



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


int main()
{
	string strInput;
	getline(cin, strInput);
	for (size_t i = 0; i < strInput.length(); i++)
	{
		if (islower(strInput[i]))
		{
			strInput[i] = toupper(strInput[i]);
		}
		else if (isupper(strInput[i]))
		{
			strInput[i] = tolower(strInput[i]);
		}
	}
	puts(strInput.c_str());

	//system("pause");
	return 0;
}

Measured memory_bytes: 3152
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int main() {
    string s, t, u;
    cin >> s >> t >> u;
    cout << 'A' << t[0] << 'C' << endl;
    return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    char x;
    cin >> x;
    if (x >= 'a') {
        cout << "a" << endl;
    } else {
        cout << "A" << endl;
    }
    return 0;
}



Measured memory_bytes: 3600