akhauriyash/Code-Regression huggingface dataset:
def main():
  N = int(input())
  a = list(map(int, input().split()))

  ans = 0

  for i in range(N):
    if (i + 1) % 2 == 1 and a[i] % 2 == 1:
      ans += 1

  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 61684
import sys
input = sys.stdin.readline
#from itertools import groupby
import numpy as np
def print_ans(N, input_line):
    """Test Case
    >>> print_ans(4, "0 1 1 2")
    2
    >>> print_ans(4, "1 1 1 1")
    0
    >>> print_ans(7, "0 3 2 1 2 2 1")
    24
    """
    ar = list(map(int,input_line.split()))
    ngflg = False
    if ar[0] != 0:
        ngflg = True
    k = max(ar)
    tmp_ar = [0] * (k + 1)
    for i in range(1,N):
        tmp_ar[ar[i]] += 1
    if tmp_ar[0] > 0:
        ngflg = True
    if ngflg:
        print("0")
    else:
        ans = 1
        for j in range(2, k + 1):
            ans *=  tmp_ar[j - 1] ** tmp_ar[j]

        print(ans % 998244353)
        # print(np.prod(ans_ar) % 998244353)

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = input().rstrip()
    print_ans(N, ar)


Measured memory_bytes: 32596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 998244353

ll extended_gcd(ll a, ll b, ll &x, ll &y)
{
    if(a==0)
    {
        x = 0;
        y = 1;
        return b;
    }
    
    ll x1,y1;
    ll g = extended_gcd(b%a, a, x1, y1);
    
    x = y1-(b/a)*x1;
    y = x1;
    return g;
}

ll powe(ll x,ll n) {
  if(x==0) return 0;
  if(n==0) return 1;
  ll val = powe(x,n/2);
  if(n%2) return (((val*val)%N)*x)%N;
  return (val*val)%N;
}

// ll comb(ll n, ll k) { 
//     if(k==0) return 1;
//     if(k==n) return 1;
//     return (((mods[n]*invmods[n-k])%N)*invmods[k])%N;
// }

ll cofac(vector<vector<ll> > &adj) {
  ll tot = 1, idx;
  ll res = 1;

  for(ll i=1;i<adj.size();i++) {
    idx = i;

    while(idx<adj.size() && !adj[idx][i])
      idx++;

    if(idx==adj.size())
      return 0;

    if(idx!=i) {
      swap(adj[i],adj[idx]);
      if((idx-i)%2)
        res = -res;
    }

    vector<ll> temp(adj[i].begin(),adj[i].end());

    ll val = temp[i];
    for(ll j=i+1;j<adj.size();j++) {
      ll curr = adj[j][i];

      for(ll k=i+1;k<adj.size();k++) {
        adj[j][k] = ((val*adj[j][k])%N - (curr*temp[k])%N + 2*N)%N;
      }

      tot = (tot*val)%N;
    } 
  }

  for(ll i=1;i<adj.size();i++)
    res = (res * adj[i][i])%N;
  
  ll x,y;
  extended_gcd(tot,N,x,y);
  // cout<<(res*x)%N<<endl;
  return (2*N+(res*x)%N)%N;
}

int main() {

  ll n;
  cin>>n;

  std::cout << std::fixed;
  std::cout << std::setprecision(6);

  vector<double> A(n,0);
  for(int i=0;i<n;i++)
    cin>>A[i];

  sort(A.begin(), A.end());

  double sum=0;
  sum = (A[0]+A[1])/2.0;

  for(int i=2;i<n;i++){
    sum = (A[i]+sum)/2;
  }

  cout<<sum<<endl;


  return 0;
} 


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int h , t;
   cin >>h;
   cin >>t;
    int arr[t];
   for (int i=0;i<t;i++){
        cin>>arr[i];
        h-=arr[i];
   } if (h <= 0){
        cout<<"Yes";
    }else{
        cout<<"No";
        }

    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.text.DecimalFormat;
 

class Main {
 
    public static void main(String[] args) {

        int intNum1 = 0;
        int intNum2 = 0;
        int intAnswer = 0;
        int intDivision = 0;
        int intSurplus = 0;
        double dbDivision = 0.0;
 
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String strLine = br.readLine();
            String[] strLineAry = strLine.split(" ");

            intNum1 = Integer.parseInt(strLineAry[0]);

            intNum2 = Integer.parseInt(strLineAry[1]);

            intDivision = intNum1 / intNum2;

            intSurplus = intNum1 % intNum2;

            dbDivision = (double)intNum1 / (double)intNum2;

            DecimalFormat insdf = new DecimalFormat("0.00000");

            System.out.println(intDivision + " " + intSurplus +  " " + insdf.format(dbDivision));

            }
        catch(IOException e) {

            System.out.println(e);
 
        }
        catch(NumberFormatException e) {

            System.out.println("??°?????§??\??????????????????");

        }
    }
}

Measured memory_bytes: 17108
#include <iostream>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, s, n) for (int i = s; i <= n; i++)
typedef long long ll;

string s[100001];

int main()
{
	int N;
	ll seq = 0, ans = 0;

	cin >> N;
	rep(i, N) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}

	sort(s, s + N);
	s[N] = "0000000000";

	rep(i, N) {
		if (s[i] == s[i + 1]) seq++;
		else {
			ans += (seq + 1) * seq / 2;
			seq = 0;
		}
	}

	cout << ans << endl;

	return 0;
}


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


int main(void) {
  vector<ll> num(3);
  ll K;
  cin >> num[0] >> num[1] >> num[2] >> K;

  sort(num.rbegin(), num.rend());

  rep(i, K) {
    num[0] = num[0] * 2;
  }

  cout << num[0] + num[1] + num[2] << endl;
  
  return 0;
}

Measured memory_bytes: 3608
int main(void){
  int l,m,n;
  int i;
  
  scanf("%d %d",&l,&m);
  for(i = 0; i < m; i++){
    scanf("%d",&n);
    l -= n;
  }
  
  printf("%d",l >= 0 ? l : -1);
}
  
  

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 1e5 + 7;

string a , b; ll dp[3009][3009];
ll lcs( int i = 0 , int j = 0 ){

    if ( i == (int)a.L && j == (int)b.L ) return 0;

    ll& ret = dp[i][j];
    if ( ~ret ) return ret;

    ll ans = -1*OO;
    if ( a[i] == b[j] ){
        ans = max( ans , lcs(i+1 , j+1) + 1 );
    }

    if ( i < (int)a.L ) ans = max( ans , lcs(i+1 , j) );
    if ( j < (int)b.L ) ans = max( ans , lcs(i , j+1) );
    return ret = ans;
}

void build( int i = 0 , int j = 0 ){

    if ( i == (int)a.L && j == (int)b.L ) return;

    ll ans = -1*OO;
    if ( a[i] == b[j] ){
        cout << a[i]; build(i+1 , j+1); return;
    }
    if ( i < (int)a.L ) ans = max( ans , lcs(i+1 , j) );
    if ( j < (int)b.L ) ans = max( ans , lcs(i , j+1) );

    if      ( lcs( i , j ) == lcs( i+1 , j ) ) build( i+1 , j );
    else if ( lcs( i , j ) == lcs( i , j+1 ) ) build( i , j+1 );
}


int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> a >> b;
    mem( dp , -1 ); ll ret = lcs();
    if ( ret > 0 ) build();
    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 71424
#include <bits/stdc++.h>
#define what_is(x) cerr<<#x<<" is "<<x<<"\n";
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bi back_inserter
using ll=long long;
using namespace std;
const long MOD=998244353;
const long mod1=1000000007;
/*__gcd(a,b),__builtin_ffs(ll)(x),__builtin_clz(x),__builtin_popcount(x)*/
/*ll comb(int n,int r){
	ll p=1,q=1,m;
	if(n-r<r)
		r=n-r;
	while(r){
		p*=n;
		q*=r;
		m=__gcd(p,q);
		p/=m;
		q/=m;
		n--;r--;
	}
	return p;
}*/

void solve()
{
		int n,m,i,flag=0;
		cin>>n>>m;
		vector<int> final(n,0);
		for(i=1;i<=m;i++)
		{
				int s,c;
				cin>>s>>c;
				if(s-1==0 && c==0 && n!=1)
						flag=1;
				else
						{
						if(final[s-1]==0 || final[s-1]==c)
								final[s-1]=c;
						else
								flag=1;
						
						}
		}
		if(flag==1)
				cout<<"-1";
		else
		{
				if(final[0]==0 && n!=1)
						final[0]=1;
				if(final[0]==0 && n==1)
						final[0]=0;
				for(i=0;i<n;i++)
						cout<<final[i];
		}
}
int main() {
	ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
	long t=1;
	//cin>>t;
		while(t--) solve();
		return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<cstdlib>//rand()
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i)
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("in.in", "r", stdin);
    int n;
    cin >> n;
    cout << n + n * n + n * n * n << "\n"; 
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll int,ll int>
#define pdd pair<double,double>
#define MOD 1000000007
using namespace std;

//--------------------SEGMENT TREE IMPLEMENTATION WITH LAZY UPDATE FOR RANGE SUM----------------

ll int segtree[200005];
ll int arr[100005];
ll int seglazy[200005];

void build(int node,int st,int en)
{
	if(st==en)
	{
		segtree[node]=arr[st];
		return;
	}

	int mid=(st+en)/2;

	build(2*node,st,mid);
	build(2*node+1,mid+1,en);

	segtree[node]=segtree[2*node]+segtree[2*node+1];
}

ll int query(int node,int st,int en,int l,int r)
{
	if(l > en || r < st)
	{
		return 0;
	}

	if(l<=st && r>=en) return segtree[node];

	int mid=(st+en)/2;

	ll int p1=query(2*node,st,mid,l,r);
	ll int p2=query(2*node+1,mid+1,en,l,r);

	return p1+p2;
}

void updateRangeLazy(int node,int st,int en,int l,int r,int val)	// Value changed to 'val'
{
	if(st > en || l > en || r < st) return;

	if(seglazy[node]!=0)
	{
		segtree[node]+=(en-st+1)*seglazy[node];

		if(st!=en)
		{
			seglazy[2*node]+=seglazy[node];
			seglazy[2*node+1]+=seglazy[node];
		}
		seglazy[node]=0;
	}

	if(l<=st && en<=r)
	{
		segtree[node]=(en-st+1)*val;

		if(st!=en)
		{
			seglazy[2*node]+=val;
			seglazy[2*node+1]+=val;
		}
		return;
	}

	int mid=(st+en)/2;

	updateRangeLazy(2*node,st,mid,l,r,val);
	updateRangeLazy(2*node+1,mid+1,en,l,r,val);

	segtree[node]=segtree[2*node]+segtree[2*node+1];
}

//------------------POWER, GCD, LCM and INVERSE MODULO FUNCTIONS-----------------------------

ll int pow(ll int base,ll int p,ll int mod = MOD)
{
	ll int powAns = 1;

	while(p)
	{
		if(p%2)
		{
			powAns=(powAns*base)%mod;
		}

		base=(base*base)%mod;
		p=p/2;
	}

	return powAns;
}

ll int gcd(ll int a, ll int b)
{
	if(b==0) return a;
	else return gcd(b,a%b);
}

ll int lcm(ll int a,ll int b)
{
	return (a*b)/gcd(a,b);
}

ll int invMod(ll int val)
{
	return pow(val,MOD-2,MOD);
}

//---------------------------------MAIN STARTS HERE------------------------------------------

int cnt[26];

int main()
{
	// freopen("input.txt","r",stdin);		freopen("output.txt","w",stdout);

	int n;

	string str;
	cin>>n;
	cin>>str;

	for(int i=0;i<26;i++) cnt[i] = 1;

	for(int i=0;i<str.length();i++)
	{
		cnt[str[i]-'a']++;
	}

	long long int ans = 1;

	for(int i=0;i<26;i++)
	{
		ans = (ans*cnt[i])%1000000007;
	}

	ans = (ans-1)%1000000007;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1020
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using pii = pair<int, int>; using vi = vector<int>;
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

vector<int> a;
vector<int> ans;
void f(int x) {
	if (x == 0)return;
	int p = lower_bound(all(a), x) - a.begin();
	ans.emplace_back(p);
	f(x - p);
}

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

	rep(i, 0, sqrt(N) * 2) {
		a.emplace_back(i*(i + 1) / 2);
	}
	f(N);
	dumpc(a);
	reverse(all(ans));
	dumpc(ans);
	rep(i, 0, ans.size()) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

 using namespace std;

 int main() {
   int N, K, i, distance;

   cin >> N >> K;

   vector<int> x(N + 1);

   for (i = 1; i <= N; i++) cin >> x.at(i);

   distance = 0;
   for (i = 1; i <= N; i++) {
     distance += 2 * min(x.at(i), K - x.at(i));
   }

   cout << distance << endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int get_unique_long(std::vector<int> &Vec) {
  std::sort(Vec.begin(), Vec.end());
  Vec.erase(std::unique(Vec.begin(), Vec.end()), Vec.end());
  return Vec.size();
}

int main() {
  int N = 0;

  int X = 0;
  std::cin >> N >> X;
  std::vector<int> M(N, 0);
  int answer = 0;

  for (int i = 0; i < M.size(); i++) {
    int a = 0;
    std::cin >> a;
    M[i] = a;
    //std::cout << M[i] << " ";
  }
  std::sort(M.begin(), M.end());
  int sum = std::accumulate(M.begin(), M.end(), 0);
  int tmp_X = X;
  int sum_counter = 0;
  
    if (tmp_X - sum >= 0) {
      tmp_X -= sum;
      sum_counter=1;
    } 
     
    
  

  int counter = 0;

  while (tmp_X > 0) {
    if (tmp_X - M[0] >= 0) {
      tmp_X -= M[0];
      counter++;
    } else {
      break;
    }
  }

  std::cout << counter + sum_counter * M.size() << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%d%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%lld%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}

string sa;

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    cin>>n;
    cin>>sa;
    a=1;
    for(i=1;i<n;i++){
        if(sa[i]!=sa[i-1])a++;
    }
    cout<<a<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

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

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

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  int a, b, c;
  cin >> a >> b >> c;

  if(a==b&&b==c) {
    no();
  }else if(a==b||b==c||c==a) {
    yes();
  }else {
    no();
  }

  return 0;
}



Measured memory_bytes: 256
use std::io::stdin;fn main() {let mut st = String::new();stdin().read_line(&mut st).unwrap();let a:Vec<_> = st.trim().split(' ').map(|x| x.parse().unwrap()).collect();let r = (1..1001).find(|x| x*8/100==a[0] && x/10==a[1]).unwrap_or(-1);println!("{}", r)}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

using namespace std;


int main(){
   double a,b,h,m;
   cin>>a>>b>>h>>m;
   double c=90-30*h-0.5*m;
   double d=90-6*m;
   c*=acos(-1)/180;
   d*=acos(-1)/180;

   double ax=a*cos(c),ay=a*sin(c);
   double bx=b*cos(d),by=b*sin(d);

   double ans=sqrt(pow((bx-ax),2)+pow((by-ay),2));

  
   cout<<std::setprecision(10)<<ans<<endl;


   
return 0;
}



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

template<class T>
ostream& operator<<(ostream& os,vector<T> const& v){for(auto itr=v.begin();itr!=v.end();++itr){if(itr!=v.begin())os<<' ';os<<*itr;}return os;}

signed main(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  int q;
  cin>>q;
  while(q--){
    int k;
    cin>>k;
    cout<< lower_bound(a.begin(),a.end(),k)-a.begin() <<" ";
    cout<< upper_bound(a.begin(),a.end(),k)-a.begin() <<endl;
  }

}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef int64_t ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  string s;
  cin >> s;
  s.push_back('X');
  s.push_back('Y');

  rep(j, s.size()) {
    if (s[j] == s[j+1]) {
      printf("%d %d\n", j+1, j+2);
      return 0;
    }
    if (s[j] == s[j+2]) {
      printf("%d %d\n", j+1, j+3);
      return 0;
    }
  }

  puts("-1 -1");
  
  return 0;
}


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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll a,b,n;
        cin>>a>>b>>n;
        if(n<b) cout<<(a*n)/b;
        else cout<<(a*(b-1))/b;

    }
    return 0;
}


Measured memory_bytes: 3604
def conv(s):
    if s.find('.') == -1:
        s += '.'
    s = s.rstrip('0')
    t = len(s) - s.find('.') - 1
    a = int(s.replace('.', ''))
    if a == 0:
        return (0, 0)
    x, y = -t, -t
    while a % 5 == 0:
        x += 1
        a //= 5
    while a % 2 == 0:
        y += 1
        a //= 2
    return (x, y)


N, *A = open(0).read().split()
N = int(N)

d = {}
for a in A:
    t = conv(a)
    d.setdefault(t, 0)
    d[t] += 1

result = 0
xs = list(d.keys())
for i in range(len(xs)):
    x, y = xs[i]
    t = d[xs[i]]
    if x >= 0 and y >= 0:
        result += t * (t - 1) // 2
    for j in range(i + 1, len(xs)):
        m, n = xs[j]
        if x + m >= 0 and y + n >= 0:
            result += t * d[xs[j]]
print(result)

Measured memory_bytes: 25480
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
for i in range(n):
  ans += b[a[i] - 1]
  if i < n-1 and a[i] + 1 == a[i+1]:
    ans += c[a[i]- 1]
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	int n, m;
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
  int N;
  cin >>N;
  int K[2][N];
  int B[N];
   
	for(int i=0;i<2;i++){
     	for(int j=0;j<N;j++){
          cin >> K[i][j];
          B[j]=0;
        }
    }
  
     	for(int j=0;j<N;j++){
          for(int k=0;k<=j;k++){
          B[j]+=K[0][k];
           
            }
          
       	  for(int t=j;t<N;t++){
          B[j]+=K[1][t];
            }
        }
    sort(B, B + N, greater<int>());
   cout << B[0] <<endl;
  
 
     
    }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int a[26] = {0};
    
    for(int i = 0; i < n;i++){
        a[s[i]-'a']++;
    }
    ll ans = 1;
    for(int i = 0; i < 26; i++){
        if (a[i] > 0){
            ans *= (a[i]+1);
        }
        ans %= mod;
    }
    ans--;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

int n;
double total = 0;
vector<int> x(10), y(10);

int kaijo(int n){
    int ret = 1;
    for(int i = 1; i <= n; i++){
        ret *= i;
    }
    return ret;
}

void dfs(int depth, int now, double dist, vector<int> seen){
    // すでに探索済の場合
    if(seen[now]){
        return;
    }
    //全頂点を探索した場合
    if(depth == n){
        total += dist;
        return;
    }
    seen[now] = 1;

    for(int i = 0; i < n; i++){
        double now_dist = sqrt(pow(x[now] - x[i], 2) + pow(y[now] - y[i], 2));
        dfs(depth + 1, i, dist + now_dist, seen);
    }
}

int main(){
    cin >> n;
    rep(i, n) cin >> x[i] >> y[i];

    for(int i = 0; i < n; i++){
        vector<int> seen(n, 0);
        dfs(1, i, 0, seen);
    }
    cout << fixed << setprecision(10) << total / kaijo(n) << endl;

    return 0;

}


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

public class Main {
	
	public static final int MAX = 13;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){
			final long n = sc.nextLong();
			
			if(n == 0L){
				break;
			}
			
			StringBuilder sb = new StringBuilder();
			long rest = n;
			boolean m_flag = false;
			while(rest != 0){
				long a = rest / (10);
				long b = rest - a * (10);
				
				if(b < 0 & !m_flag){
					b += (10);
					a -= 1;
				}else if(b > 0 && m_flag){
					b -= (10);
					a += 1;
				}
				
				if(b < 0){
					b = -b;
				}
				
				sb.insert(0, b);
				rest = a;
				m_flag = !m_flag;
			} 
			
			System.out.println(sb.toString());
		}
	}
}

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

int N;
vector<ll> l(87);

int main(){
  cin >> N;
  vector<tuple<string,int,int>> v(N);
  rep(i, N){
    cin >> get<0>(v.at(i)) >> get<1>(v.at(i));
    get<2>(v.at(i)) = i+1;
  }
  sort(v.begin(), v.end());
  string pre = get<0>(v.at(0));
  int tmp = 0;
  rep(i, N){
    if(pre != get<0>(v.at(i))) {
      reverse(v.begin()+tmp, v.begin()+i);
      tmp = i;
      pre = get<0>(v.at(i));
    }
  }
  reverse(v.begin()+tmp, v.end());
  rep(i, N){
    // cout << get<0>(v.at(i)) << " " << get<1>(v.at(i)) << " ";
    cout << get<2>(v.at(i)) << endl;
  }
}


Measured memory_bytes: 256
module.exports=function(t){var r={};function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(r){return t[r]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=0)}([function(t,r,e){"use strict";var n=e(1);e(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,r){t.exports=require("fs")},function(t,r,e){"use strict";var n=e(3),i=e(5);t.exports=function(t){var r=new n(t);i(r)}},function(t,r,e){"use strict";var n=e(4);t.exports=class{constructor(t){var r=t.trim().split(/\s+/g);this.inp=new n(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,r,e){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,r,e){"use strict";var n=e(6);t.exports=function(t){for(var r=99999999999,e=t.in(),i=t.in(),o=t.in(),s=new Array(e),u=0;u<e;u++)s[u]=new Array(e).fill(r);for(var c=0;c<i;c++){var f=t.in(),a=t.in(),l=t.in();s[f-1][a-1]=l,s[a-1][f-1]=l}for(var p=n(s),v=0;v<e;v++)for(var d=0;d<e;d++)p[v][d]<=o?s[v][d]=1:s[v][d]=r;for(var h=n(s),y=t.in(),b=0;b<y;b++){var g=t.in(),m=t.in(),x=h[g-1][m-1];x==r?console.log(-1):console.log(x-1)}}},function(t,r,e){"use strict";t.exports=function(t){for(var r=t.length,e=[],n=0;n<r;n++)e.push(t[n].concat());for(var i=0;i<r;i++)for(var o=0;o<r;o++)for(var s=0;s<r;s++)e[o][s]>e[o][i]+e[i][s]&&(e[o][s]=e[o][i]+e[i][s]);return e}}]);

Measured memory_bytes: 62540
import sys
readline = sys.stdin.readline
class Node:
    __slots__ = ['value', 'left', 'right']
    def __init__(self, value = None, left = None, right = None):
        self.value = value
        self.left = left
        self.right = right
class BinTree:
    __slots__ = ['_tree', 'result']
    def __init__(self):
        self._tree = None
    def insert(self, value):
        p = None
        c = self._tree
        while c is not None:
            p = c
            if value < c.value:
                c = c.left
            else:
                c = c.right
        if p is None:
            self._tree = Node(value)
        elif value < p.value:
            p.left = Node(value)
        else:
            p.right = Node(value)
    def find(self, value):
        c = self._tree
        while c is not None:
            if value == c.value:
                return True
            elif value < c.value:
                c = c.left
            else:
                c = c.right
        return False
    def delete(self, value):
        def node_move(p, c, a):
            if p.left == c:
                p.left = a
            else:
                p.right = a
        c = self._tree
        p = Node(None, c)
        while c.value != value:
            p = c
            if c is None:
                return
            if value < c.value:
                c = c.left
            else:
                c = c.right
        if c.left is None:
            node_move(p, c, c.right)
        elif c.right is None:
            node_move(p, c, c.left)
        elif c.right.left is None:
            c.right.left = c.left
            node_move(p, c, c.right)
        else:
            q = c.right
            while q.left.left is not None:
                q = q.left
            c.value = q.left.value
            q.left = q.left.right
    def preoder_walk(self):
        self.result = []
        def preoder(node):
            if node is not None:
                self.result.append(node.value)
                preoder(node.left)
                preoder(node.right)
        preoder(self._tree)
        print(" " + " ".join(map(str, self.result)))
    def inorder_walk(self):
        self.result = []
        def inorder(node):
            if node is not None:
                inorder(node.left)
                self.result.append(node.value)
                inorder(node.right)
        inorder(self._tree)
        print(" " + " ".join(map(str, self.result)))
n = int(input())
tree = BinTree()
for _ in range(n):
    com = readline().split()
    if com[0] == "insert":
        tree.insert(int(com[1]))
    elif com[0] == "find":
        print("yes" if tree.find(int(com[1])) else "no")
    elif com[0] == "delete":
        tree.delete(int(com[1]))
    else:
        tree.inorder_walk()
        tree.preoder_walk()



Measured memory_bytes: 77244
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int lx,ly;
    cin >> lx >> ly;
    do{
        int x=1,y=1,n,d=0;
        char a[7];
        cin >> a;
        while(a[0]!='S'){
            n=0;
            switch(a[0]){
                case'F':
                    cin >> n;
                    break;
                case'B':
                    cin >> n;
                    n*=-1;
                    break;
                case'L':
                    d-=1;
                    break;
                case'R':
                    d+=1;
                    break;
            }
            if (d==-1)
                d=3;
            if (d==4)
                d=0;
            if (n!=0)
                switch(d){
                    case 0:
                        y+=n;
                        break;
                    case 1:
                        x+=n;
                        break;
                    case 2:
                        y-=n;
                        break;
                    case 3:
                        x-=n;
                        break;
                }
            if (x>lx)
                x=lx;
            if (x<1)
                x=1;
            if (y>ly)
                y=ly;
            if (y<1)
                y=1;
            cin >> a;
        }
        cout << x <<' '<< y << endl;
        cin >> lx >> ly;
    }while (!(lx==0&&ly==0));
    return 0;
}


Measured memory_bytes: 2996
N = int(input())
A = list(map(int, input().split()))
ans = []
L = []
R = []

def gcd(x, y):
    if y > x:
        x, y = y, x
    while y:
        x, y = y, x % y
    return x

for i in range(N):
    if i == 0:
        L.append(A[0])
    else:
        L.append(gcd(L[i - 1], A[i]))

for i in range(N):
    if i == 0:
        R.append(A[-1])
    else:
        R.append(gcd(R[i - 1], A[N - i - 1]))

for i in range(N):
    if i == 0:
        ans.append(R[N - 2])
    elif i == N - 1:
        ans.append(L[N - 2])
    else:
        ans.append(gcd(L[i - 1], R[N - i - 2]))

print(max(ans))

Measured memory_bytes: 14488
S = input()

def func(S):
    for x in S:
        if x in ('A', 'C', 'a', 'c'):
            continue
        if not x.islower():
            return False
    return True

def func2(S):
    cnt = 0
    for x in S[2:-1]:
        if x=='C':
            cnt += 1
    if cnt == 1:
        return True
    return False

if S[0] == 'A' and func2(S) and func(S):
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3060
D, G = map(int,input().split())
Alist = [input().split() for i in range(D)]
for i in range(D):
    for j in range(2):
        Alist[i][j] = int(Alist[i][j])
m = 0
s = 0
c = 0
for i in range(D):
    m = m + Alist[i][0]
p = []
q = []
h = []
t = 0
v = 100
for i in range(D):
    p.append(100*(i+1)*Alist[i][0]+Alist[i][1])
while len(p) < 10:
        p.append(0)
for i in range(2**D):
    c = 0
    s = 0
    r = 0
    x = list(format(i,'b'))
    for i in range(len(x)):
        x[i] = int(x[i])
    x.reverse()
    while len(x) < 10:
        x.append(0)
    for f in range(10):
        r = r + p[f]*x[f]
    for i in range(D):
        c = c + Alist[i][0]*x[i]
    x.reverse()
    while t < 10:
        if x[t] == 0:
            if (10-t) <= D: 
                v = t
                break
            else:
                t = t + 1
        else:
            t = t + 1
    if v == 100:
        h.append(m)
    else:
        while r < G:
            if s == Alist[(10-v)-1][0]:
                break
            r = r + 100*(10-v)
            s = s + 1
        if r >= G:
            h.append(s+c)
print(min(h))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll ans = 0, hmin=100;
  rep(i,5){
    ll x = 0;
    cin >> x;
    if(x % 10 == 0){
      ans += x;
    }
    else{
      hmin = min(hmin,x % 10);
      x = x/10 + 1;
      x *= 10;
      ans += x;
    }
  }
  if(hmin == 100){
    cout << ans;
  }
  else{
    cout << ans - (10 - hmin);
  }
}

Measured memory_bytes: 3576
package main

import (
	"fmt"
	"math"
)

func main() {
	var s []byte
	fmt.Scan(&s)


	stmp := make([]byte, len(s))
	_ = copy(stmp,s)
	cnt := 0
	for i := 0; i < len(s); i++ {
		if i % 2 == 0 && s[i] == '0' {
			cnt++
		}
		if i % 2 == 1 && s[i] == '1' {
			cnt++
		}
	}
	cnt2 := 0

	for i := 0; i < len(s); i++ {
		if i % 2 == 0 && s[i] == '1' {
			cnt2++
		}
		if i % 2 == 1 && s[i] == '0' {
			cnt2++
		}
	}
	fmt.Println(min(cnt, cnt2))
}
func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 2724
N, K = map(int, input().split())
p_list = list(map(int, input().split()))

c_s_list = [0] #Cumulative sum_list
c_sum = 0 #Cumulative sum
for dice in p_list:
    average = (dice + 1) / 2 #ダイスの期待値
    c_sum += average
    c_s_list.append(c_sum)

ans = 0
for i in range(N-K+1):
    tmp = c_s_list[i+K] - c_s_list[i]
    if tmp >= ans:
        ans = tmp
print(ans)





Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,ans=1;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x%2==0 && x%3!=0 && x%5!=0){
            ans=0;
            break;
        }

    }
    if(ans)
        cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <algorithm>
#include <array>

using namespace std;

int main()
{
    long long H, W;
    int N;
    scanf("%lld %lld %d", &H, &W, &N);
    map<pair<long long, long long>, int> nine;
    for (int i = 0; i < N; ++i){
        long long a, b;
        scanf("%lld %lld\n", &a, &b); --a; --b;

        for (int y = max<long long>(1, a - 1); y < min(H - 1, a + 2); ++y){
            for (int x = max<long long>(1, b - 1); x < min(W - 1, b + 2); ++x){
                auto xy = make_pair(x, y);
                if (nine.count(xy)){
                    ++nine[xy];
                }else{
                    nine.emplace(xy, 1);
                }
            }
        }
    }

    array<long long, 9> result; result.fill(0);
    long long result_sum = 0;
    for (auto& elem : nine){
        ++result[elem.second - 1];
        ++result_sum;
    }
    printf("%lld\n", (H - 2) * (W - 2) - result_sum);
    for (auto& elem : result){
        printf("%lld\n", elem);
    }
}


Measured memory_bytes: 56448
n = int(input())
wi = list(map(int, input().split()))

#print(wi)

s2=sum(wi)
s1=0
diff=10**5
for i in range(n):
    tmp=wi[i]
    s1 += tmp
    s2 -= tmp
    if abs(s1-s2)<abs(diff):
        diff=abs(s1-s2)
    else:
        break

print(diff)

Measured memory_bytes: 3064
#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);
  }
  for (int k = 0; k>=0 ; k++){
    int p=0;
    
  	for (int j = 0;j<N;j++){
    
    	if (vec.at(j)%2 == 0){
    	  vec.at(j) /= 2;
     	 p++;
    	}
    	else
      	break;
  }
    if(p == N){
      continue;
    }
    else
      cout << k << endl;
      break;
  }
      
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> x(n);
    int s = 0;
    rep(i, n)
    {
        cin >> a[i];
        s += a[i];
    }
    s = s / 2;
    int x0 = s;
    for (int i = 1; i < n - 1; i += 2) {
        x0 -= a[i];
    }
    x[0] = x0;
    for (int i = 1; i < n; i++) {
        x[i] = a[i - 1] - x[i - 1];
    }
    rep(i, n)
    {
        cout << x[i] * 2 << " ";
    }

    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
// int dx[]={0,1,0,-1,1,-1,-1,1};
// int dy[]={1,0,-1,0,1,1,-1,-1};
int dx[]={1,0};
int dy[]={0,1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
char a[8][8];
bool re[8][8];
int h,w;

void dfs(int x,int y){
  re[x][y]=true;
  rep(i,2){
    if(x+dx[i]<0||h-1<x+dx[i]||y+dy[i]<0||w-1<y+dy[i]) continue;
    if(a[x+dx[i]][y+dy[i]]=='#'){
      dfs(x+dx[i],y+dy[i]);
      break;
    }
  }
}

signed main(){
  cin>>h>>w;
  string ans="Possible";
  rep(i,h){
    rep(j,w) cin>>a[i][j];
  }
  dfs(0,0);
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#'&&!re[i][j]) ans="Impossible";
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
 
int main() {
  
  string str;
  int n,l;
  bool ans = true;
  
  cin>>str;
  n=str.length();
  l=(n-1)/2; //2つの回文の長さ
  
  for(int i=0;i<l;i++)
  {
   ans &= str[i] == str[n-1-i]; //全体が回文か
  }
  for(int i=0;i<l/2;i++) //切り捨てでうまくいく
  {
    ans &= str[i] == str[l-1-i];
    ans &= str[n-l+i] == str[n-1-i];
  }
  
  if(ans) cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
import itertools
n=int(input())
l=[i+1 for i in range(n)]
p=[int(x) for x in input().rstrip().split()]
q=[int(x) for x in input().rstrip().split()]

cnt=0
ans_l=[]
for pq in itertools.permutations(l):
  ans_l.append(list(pq))

print(abs(ans_l.index(p)-ans_l.index(q)))

Measured memory_bytes: 10228
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int ans = 0;
		if (N < 105) {
			System.out.println(ans);
			return;
		}
		for (int i = 105; i <= N; i+=2) {
			int count = 0;
			for (int j = 1; j <= i; j++) {
				if (i%j == 0) {
					count++;
				}
			}
			if (count == 8) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='+'){
      ans++;
    }else{
      ans--;
    }
  }

  cout<<ans<<endl;
}
  

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

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

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

ll power(ll a,ll b)
{
    if(b==0)return 1;
    ll x=power(a,b/2);
    x=x*x;
    if(b%2)x=x*a;
    return x;
}
/**
double cosine_rule(double a,double b,double c)
{
    double res=(a*a+b*b-c*c)/(2*a*b);
    res=acos(res);
    return res;
}
*/
ll dp[105][mx],n,w;
ll cost[105],weight[105];
ll solve(ll pos,ll v)
{
    if(pos==(n+1))return 0;
    ll &ret=dp[pos][v];
    if(ret!=-1)return ret;
    ll niye=0,naniye=0;
    if(v+weight[pos]<=w)niye=cost[pos]+solve(pos+1,v+weight[pos]);
    naniye=solve(pos+1,v);
    return ret=max(niye,naniye);
}
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    ll tst,a,b,c,k,m,res=0,ans=0,t=0;
    memset(dp,-1,sizeof(dp));
    sl(n),sl(w);
    for(ll i=1;i<=n;i++)
    {
        sl(weight[i]),sl(cost[i]);
    }
    res=solve(1,0);
    printf("%lld\n",res);


    return 0;
}


Measured memory_bytes: 82432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    double N, M; cin >> N >> M;
    double T = 100*(N-M) + 1900*M;
    double p = pow(0.5, M);

    cout << (int)T/p << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;



int main(int argc, const char * argv[]) {
	int N;
	ll buf;
	cin >> N;
	int val[N];
	map<ll,int> xgr;
	int one=1;
	REP(i,N){
		cin >> buf;
		val[i] = buf;
		if(xgr.find(buf)!=xgr.end()){
			xgr.find(buf)->second++;
		}else{
			xgr.insert(mp(buf,one));
		}
	}

	ll a1=-1, a2=-1;
	int sum=0,prev_sum=0;
	for(std::map<ll,int>::iterator itr = xgr.begin();
			itr != xgr.end();itr++){
//		printf("%d %d\n",itr->first,itr->second);
		sum += itr-> second;
		if(sum==N/2){
			a1 = itr->first;
			cerr << "a1 : " << a1 << endl;
		}else if(sum > N/2){
			if(a1==-1){
				a1 =a2 = itr->first;
				cerr << "a1 & a2 : " << a1 << endl;
			}else{
				a2 = itr->first;
				cerr << "a2 : " << a2 << endl;
			}
			break;
		}
	}

	REP(i,N){
		if(val[i]<=a1){
			println(a2);
		}else{
			println(a1);
		}
	}


	return 0;

}


Measured memory_bytes: 15232
n=int(input())
a=list(map(int,input().split()))
q=int(input())
for i in range(q):
    tmp=list(map(int,input().split()))
    if tmp[0]==0:
        ans=float('inf')
        for j in range(tmp[1],tmp[2]):
            ans=min(ans,a[j])
        print(ans)
    else:
        ans=float('inf')*(-1)
        for j in range(tmp[1],tmp[2]):
            ans=max(ans,a[j])
        print(ans)


Measured memory_bytes: 5636