akhauriyash/Code-Regression huggingface dataset:
main = do
    s <- getLine
    print $ solve s 0 0

solve :: String -> Int -> Int -> Int
solve [] mx ac = mx
solve (x:xs) mx ac
    | isATGC x && mx<=ac = solve xs (mx+1) (ac+1)
    | isATGC x  = solve xs mx (ac+1)
    | otherwise = solve xs mx 0

isATGC :: Char -> Bool
isATGC c = c=='A' || c=='T' || c=='G' || c=='C'

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

using namespace std;

typedef long long int ll;


int main() {
    int n;
    cin >> n;
    double p[n];
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    vector<vector<double> > dp(n, vector<double >(n + 1, 0));
    dp[0][0] = (1 - p[0]);
    dp[0][1] = (p[0]);
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= n; ++j) {
            dp[i][j] = (1 - p[i]) * dp[i - 1][j];
            if (j - 1 >= 0) {
                dp[i][j] += (p[i] * dp[i - 1][j - 1]);
            }
        }
    }
    double ans = 0;
    for (int i = (n / 2) + 1; i <= n; ++i) {
        ans += dp[n - 1][i];
    }
    cout << fixed << setprecision(9);
    cout << ans;
}



Measured memory_bytes: 70656
import math
def plot(x,y):
    print(f"{x:.8f} {y:.8f}")
def koch(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    koch(n-1,x1,y1,sx,sy)
    koch(n-1,sx,sy,ux,uy)
    koch(n-1,ux,uy,tx,ty)
    koch(n-1,tx,ty,x2,y2)
n=int(input())
koch(n,0,0,100,0)
plot(100,0)


Measured memory_bytes: 5748
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll a,b;cin>>a>>b;
	if(a==b) cout<<"Yes\n"; else cout<<"No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void AC(){cout<<"AC\n";exit(0);}
void WA(){cout<<"WA\n";exit(0);}
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	string s;
	cin>>s;
	if(s[0]!='A'||s[1]=='C'||s[s.size()-1]=='C')WA();
	int C=0;
	for(int i=1;i<s.size();i++)
	{
	if(isupper(s[i])&&s[i]!='C')WA();
	if(i!=1&&s[i]=='C')C++;
	if(C>1)WA();
	}
	if(!C)WA();
	AC();
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int tmp;
  cin >> n;
  vector<int> cnt(n+1, 0);
  for (int i = 1; i <= 100;i++){
    for (int j = 1; j <= 100;j++){
      for (int k = 1; k <= 100;k++){
        tmp = i * i + j * j + k * k + i * j + j * k + k * i;
        if (tmp <= n) {
          cnt[tmp]++;
        }
      }
    }
  }
  for (int i = 1; i <= n;i++){
    cout << cnt[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
using Kujikatsu003.Questions;
using Kujikatsu003.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Kujikatsu003.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/abc083/tasks/abc083_b
    /// </summary>
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nab = inputStream.ReadIntArray();
            var n = nab[0];
            var a = nab[1];
            var b = nab[2];

            yield return Enumerable.Range(1, n).Where(i =>
            {
                var digitSum = GetDigitSum(i);
                return a <= digitSum && digitSum <= b;
            }).Sum();
        }

        int GetDigitSum(int n)
        {
            var sum = 0;
            while (n > 0)
            {
                sum += n % 10;
                n /= 10;
            }
            return sum;
        }
    }
}


namespace Kujikatsu003
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Kujikatsu003.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Kujikatsu003.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for(auto& d : D){
    cin >> d;
  }
  int ans = 0;
  for(int ii=0; ii<N; ii++){
    for(int jj=ii+1; jj<N; jj++){
      ans += D[ii] * D[jj];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main(void)
{
	char r[1001] = {};
	std::cin >> r;
	int l = std::strlen(r), n=0, e=0, w=0, s=0;
	for(int i = 0; i != l; i++){
		if(r[i] == 'N') n++;
		if(r[i] == 'W') w++;
		if(r[i] == 'S') s++;
		if(r[i] == 'E') e++;
	}
	if(((n>0&&s>0)||(n+s==0))&&((w>0&&e>0)||(w+e==0)))
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
	return 0;
}

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

int x;

int main(void){
	cin >> x;
	int r = x%100;
	int t = 0;
	for(int i = 5; i >= 1; i--){
		t += r/i;
		r%=i;
	}
	if(100*t > x) cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h> 
char S[200];
 int main(){
		int K;
		scanf("%d",&K);
		getchar();
		
		gets(S);
		
		int i=0;
		while(S[i]&&i<K){
			printf("%c",S[i]);
			i++;
			
		}
		if(S[K])
		printf("...\n");
		
		      
 }

Measured memory_bytes: 1704
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
string S;
int N;
int main() {
  cin >> S;
  N = S.size();
  int head = 0;
  int tail = N - 1;
  int result = 0;
  while (head < tail){
    char h = S[head];
    char t = S[tail];
    if (h == t){
      head++;
      tail--;
      continue;
    }
    if (h == 'x'){
      head++;
      result++;
      continue;
    }
    if (t == 'x'){
      tail--;
      result++;
      continue;
    }
    cout << -1 << endl;
    return 0;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 888
#include <cstring>
#include <iostream>

using namespace std;
int main()
{
long long k,a,b;
cin>>k>>a>>b;

if(a+1>=b||k-a+1<=0)
cout<<k+1;
else
{
 k=k-a+1;
 
if(k==1)
cout<<a+1;
else if(k%2!=0)
cout<<(k/2)*b-(k/2-1)*a+1;
else
cout<<(k/2)*b-(k/2-1)*a;
}
 
 

return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll n;
    cin>>n;
    cout<<n/2+(n%2==1)<<endl;


}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
        int abss(int a){
            int x = a ;
            if(x<0)x*=-1 ;
            return x;
        }
int main()
{
    int n , k ;cin>>n>>k;int ar[n+1];
    for(int i = 1 ; i<=n ; i++)
        cin>>ar[i];
    int arr[n+1];
    arr[1]=0;
    
    for(int i = 2 ;i <=n ; i++){
        arr[i] =arr[i-1]+abss(ar[i-1]-ar[i]) 
        ;for(int j = 2 ; j<=k ; j++){
            if(i-j>0){
                arr[i]=min(arr[i] , arr[i-j] + abss(ar[i-j]-ar[i]));
            }
        }
    }
    cout<<arr[n];
   
    return 0;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b){
        if(b < c){
        cout << "Yes" << endl;
        }
        else{
        cout << "No" << endl;
    } 
    } 
    else{
    cout << "No" << endl;
    } 

    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
 
const int N=2e4+10;
const ll MOD2=998244353;
const ll MOD=1e9+7;

int main(){
    fastio;
    srng;
    #ifdef ALEXPC
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    cout.precision(13);
    int n;
    cin>>n;
    ld ans=0;
    FOR(i,n){
        ld k;
        cin>>k;
        ans+=(ld)1/k;
    }
    ans=1/ans;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  long count=0;
  int N;
  cin>>N;
  vector<int>HP(N);
  rep(i,N){
    cin>>HP[i];
  }
  while(1){
    sort(HP.begin(),HP.end(),greater<int>());
    if(HP.size()==1){
      cout<<HP[0];
      return 0;
    }
    while(HP.back()==0){
      HP.pop_back();
    }
    int tmp=*min_element(HP.begin(),HP.end());
    rep(i,HP.size()-1){
      HP[i]=HP[i]%tmp;
    }
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int a[3][3];
    vector< vector< bool > > hole(3, vector<bool>(3, false));
    rep (i, 3) rep(j, 3) cin >> a[i][j];

    int n;
    cin >> n;

    int b;
    rep (i, n)
    {
        cin >> b;
        rep (j, 3) rep (k, 3)
        {
            if (a[j][k] == b)
            {
                hole[j][k] = true;
            }
        }
    }

    bool ans = false;
    rep (i, 3)
    {
        if (hole[i][0] && hole[i][1] && hole[i][2]) ans = true;
    }
    rep (i, 3)
    {
        if (hole[0][i] && hole[1][i] && hole[2][i]) ans = true;
    }
    if (hole[0][0] && hole[1][1] && hole[2][2]) ans = true;
    if (hole[0][2] && hole[1][1] && hole[2][0]) ans = true;

    cout << (ans ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    //087
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int a=in.nextInt();
        int b=in.nextInt();
        int c=in.nextInt();
        int x=in.nextInt();
        int cnt=0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if((i*500)+(j*100)+(k*50)==x){cnt++;}
                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 22996
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())

count = [0] * (10**5 + 1)
S = [0] * (q + 1)
for i in range(n):
	count[a[i]] += 1
	S[0] += a[i]

for i in range(1, q + 1):
	b, c = [int(x) for x in input().split()]
	S[i] = S[i - 1]
	S[i] += (c - b) * count[b]
	count[c] += count[b]
	count[b] = 0
	
for i in range(1, q + 1):
	print(S[i])

Measured memory_bytes: 20496
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

struct Edge {
	int from, to, dis;
	Edge(int f, int t, int d) {
		from = f; to = t; dis = d;
	}
};

struct Node {
	int num, state;
	double cost;
	Node(int n, double c, int st) {
		num = n; cost = c; state = st;
	}
};

int main() {
	int n, m, p, a, b;
	while (cin >> n >> m >> p >> a >> b, n) {
		vector<int>t(n);
		vector<vector<Edge>>G(m + 1);
		for (int i = 0; i < n; ++i)cin >> t[i];
		for (int i = 0; i < p; ++i) {
			int x, y, z; cin >> x >> y >> z;
			G[x].emplace_back(x, y, z); G[y].emplace_back(y, x, z);
		}
		//dijkstra
		auto compare = [](const Node n1, const Node n2) {return n1.cost > n2.cost; };
		priority_queue < Node, vector<Node>, decltype(compare)> que(compare);
		que.push(Node(a, 0.0, (1 << n) - 1));
		double ans = -1;
		vector<vector<int>>visited(m + 1, vector<int>(1 << n, 0));
		while (!que.empty()) {
			Node now = que.top(); que.pop();
			int num = now.num, state = now.state;
			if (now.num == b) {
				ans = now.cost;
				break;
			}
			if (visited[num][state])continue;
			visited[num][state] = 1;
			for (int i = 0; i < state; ++i) {
				if ((i&state) == state)visited[num][i] = 1;
			}
			int sup = G[now.num].size();
			for (int i = 0; i < sup; ++i) {
				Edge e = G[num][i];
				for (int j = 0; j < n; ++j) {
					if (!((state >> j) % 2))continue;
					if (visited[e.to][state - (1 << j)])continue;
					que.push(Node(e.to, now.cost + (double)e.dis / (double)t[j], state - (1 << j)));
				}
			}
		}
		if (ans == -1)cout << "Impossible" << endl;
		else cout << ans << endl;
	}
}

Measured memory_bytes: 18088
def main():
    N, x = map(int, input().split())
    A = list(map(int, input().split()))
    ans = sum(A)
    for i in range(1, N):
        prev = list(A)
        for j in range(N):
            A[j] = min(A[j], prev[(j-1) % N])
        ans = min(ans, sum(A) + i * x)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42092
#include<stdio.h>
int main(){
  
  int sum=0;
  int N=0,X=0,T=0;
  scanf("%d %d %d", &N,&X,&T);

  sum = (N + (X - 1)) / X;
    
    
  printf("%d",sum*T);
  
 return 0; 
}

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

int main() {
  long D, N, count;
  count = 0;
  cin >> N >> D;
  
  vector<long> X(N), Y(N);
   for(int i = 0; i < N; i++){
     cin >> X[i] >>Y[i];
   }
  for(int i = 0; i < N; i++){
    if(X[i]*X[i] + Y[i]*Y[i] <= D*D){
      count++;
    }
  }
  cout << count <<endl;
 
}


Measured memory_bytes: 6384
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int R, G, B, N, ans;

int main() {    
    cin >> R >> G >> B >> N;
    rep(r, N+1) {
        rep(g, N+1) {
            int rem = N - R * r - G * g;
            if (rem < 0) break;
            if (rem % B != 0) continue;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc115

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;

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

    int c = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '2') c++;
    }

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
	int n, a[100000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	sort(a, a + n);
	long long total = 0;

	int c = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1]) {
			c++;
		} else {
			if (c < a[i - 1])
				total += c;
			else
				total += c - a[i - 1];
			c = 1;
		}
	}
	if (c < a[n - 1])
		total += c;
	else
		total += c - a[n - 1];
	printf("%lld\n", total);
}

Measured memory_bytes: 512
#include<iostream>
#include<string.h>

using namespace std;

int main() {
	string s;
	int ans = 0;
	cin >> s;
	for(int i = 0; i < s.size()/2; i++) {
		if (s[i] != s[s.size()-i-1])
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      vector<pair<int,int> > list;
      for(int i=0;i<n;i++)
	{
	  int c,m[4],s[4];
	  cin>>c>>m[0]>>s[0]>>m[1]>>s[1]>>m[2]>>s[2]>>m[3]>>s[3];
	  list.push_back(pair<int,int>(m[0]*60+m[1]*60+m[2]*60+m[3]*60+s[0]+s[1]+s[2]+s[3],c));
	}
      sort(list.begin(),list.end());
      cout<<list[0].second<<endl;
      cout<<list[1].second<<endl;
      cout<<list[list.size()-2].second<<endl;
    }
}

Measured memory_bytes: 1304
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * TITLE : Bingo
 * URL : https://atcoder.jp/contests/abc157/tasks/abc157_b
 */
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] A = new int[9];
        for (int i = 0; i < 9; i++) {
            A[i] = sc.nextInt();
        }
        BingoCard bingoCard = new BingoCard(A);

        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            bingoCard.setHitNumber(sc.nextInt());
        }
        System.out.println(bingoCard.isBingo());
        sc.close();
    }

    static class BingoCard {
        List<Target> target = new ArrayList<Target>();
        BingoCard (int[] numbers) {
            target.add((new Target(numbers[0])));
            target.add((new Target(numbers[1])));
            target.add((new Target(numbers[2])));
            target.add((new Target(numbers[3])));
            target.add((new Target(numbers[4])));
            target.add((new Target(numbers[5])));
            target.add((new Target(numbers[6])));
            target.add((new Target(numbers[7])));
            target.add((new Target(numbers[8])));
        }
        static class Target {
            int number;
            boolean isHit;
            Target (int number) {
                this.number = number;
            }
        }
        public void setHitNumber(int number) {
            target.stream().filter(n -> n.number == number).forEach(h -> h.isHit = true);
        }

        public String isBingo() {
            if ( (target.get(0).isHit && target.get(1).isHit && target.get(2).isHit) ||
                    (target.get(3).isHit && target.get(4).isHit && target.get(5).isHit) ||
                    (target.get(6).isHit && target.get(7).isHit && target.get(8).isHit) ||
                    (target.get(0).isHit && target.get(3).isHit && target.get(6).isHit) ||
                    (target.get(1).isHit && target.get(4).isHit && target.get(7).isHit) ||
                    (target.get(2).isHit && target.get(5).isHit && target.get(8).isHit) ||
                    (target.get(0).isHit && target.get(4).isHit && target.get(8).isHit) ||
                    (target.get(2).isHit && target.get(4).isHit && target.get(6).isHit) ) {
                return "Yes";
            }
            return "No";
        }
    }
}

Measured memory_bytes: 28620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 int f[366],m[366],sum;
ll checkbit(ll n , ll k)
{
    return (n&(1LL<<k));
}
bool comp(string a, string b)
{
  if(a.size()>=b.size())return false;
  else return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
      int x;
      cin>>x;
      if(x>=1800 && x<=1999){cout<<1;}
      else if(x>=1600 && x<=1799){cout<<2;}
       else if(x>=1400 && x<=1599){cout<<3;}
        else if(x>=1200 && x<=1399){cout<<4;}
         else if(x>=1000 && x<=1199){cout<<5;}
          else if(x>=800 && x<=999){cout<<6;}
           else if(x>=600 && x<=799){cout<<7;}
            else if(x>=400 && x<=599){cout<<8;}

}


Measured memory_bytes: 3648
-- day-of-takahashi.hs --- Day of Takahashi

-- author: Seong Yong-ju <sei40kr@gmail.com>

solve :: Int -> Int -> Int
solve a b =
  a +
  (if a <= b
     then 0
     else -1)

main :: IO ()
main = do
  [a, b] <- map (read :: String -> Int) . words <$> getLine
  print $ solve a b


Measured memory_bytes: 508
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	ll a[100000];
	ll xsum = 0;
	rep(i, n) {
		cin >> a[i];
		xsum ^= a[i];
	}
	int cnt = 0; int used[100000] = {};
	bool can = true;
	per(i, 31) {
		if (xsum&((ll)1 << i)) {
			ll d = 1 << i; ll d2 = (ll)1 << (i + 1);
			bool f = false;
			rep(j, n) {
				if (used[j])continue;
				if (a[j] % d == 0&&a[j]%d2!=0) {
					used[j] = 1; cnt++;
					xsum ^= d - 1; f = true; break;
				}
			}
			if (!f) {
				cout << -1 << endl; can = false; break;
			}
		}
	}
	if (can)cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <cstdio>
#include <cmath>

using namespace std;

typedef pair<int, int> P;

const int INF = 100000000;
const double EPS = 1e-8;

class State{
public:
  int pos, v, pre;
  double time;
  State(){}
  State(int pos, int v, int pre, double time) : pos(pos), v(v), pre(pre), time(time) {}
  bool operator < (const State& s) const { return time > s.time; }
};

int n, m, s, g;
P edge[30][30];
double cost[30][30][31];
bool vis[30][30][31];

bool equals(double a, double b){
  return fabs(a-b) < EPS;
}

void solve(){
  State u, v;
  u = State(s, 0, 0, 0.0);
  priority_queue<State> que;
  fill(vis[0][0], vis[30][0], (double)INF);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<31;k++){
        cost[i][j][k] = INF;
        vis[i][j][k] = false;
      }
    }
  }
  //cost[0][0][1] = 0.0;
  for(int i=0;i<n;i++){
    if(edge[s][i].first != INF){
      cost[s][i][1] = edge[s][i].first;
      que.push(State(i, 1, s, (double)edge[s][i].first));
    }
  }
  while(!que.empty()){
    u = que.top(); que.pop();
    //cout << u.pos << ' ' << u.v << ' ' << u.pre << ' ' << u.time << endl;
    if(vis[u.pre][u.pos][u.v]) continue;
    vis[u.pre][u.pos][u.v] = true;
    if(u.pos == g && u.v == 1){
      printf("%.5f\n", u.time);
      return;
    }
    for(int i=0;i<n;i++){
      if(edge[u.pos][i].first == INF) continue;
      if(u.pre == i) continue;
      for(int k=-1;k<=1;k++){
        if(u.v + k > edge[u.pos][i].second) continue;
        if(u.v + k <= 0) continue;
        v = State(i, u.v + k, u.pos, u.time + edge[u.pos][i].first / (double)(u.v + k));
        //cout << '\t' << v.pos << ' ' << v.v << ' ' << v.pre << ' ' << v.time << ' ' << vis[v.pre][v.pos][v.v] << endl;
        if(cost[v.pre][v.pos][v.v] > v.time){
          cost[v.pre][v.pos][v.v] = v.time;
          que.push(v);
        }
      }
    }
  }
  printf("unreachable\n");
}

main(){
  while(scanf("%d%d", &n, &m) && (n|m)){
    scanf("%d%d", &s, &g);
    s--; g--;
    fill(edge[0], edge[30], P(INF, 0));
    for(int i=0;i<m;i++){
      int a, b, c, d;
      scanf("%d%d%d%d", &a, &b, &c, &d);
      a--; b--;
      edge[a][b] = edge[b][a] = P(c, d);
    }
    solve();
  }
}

Measured memory_bytes: 2388
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))

    if N==1 and M==0:
        print(0)
        return

    ans = [None for _ in range(N)]

    for i in range(M):
        s, c = list(map(int, input().split()))

        if N!=1 and s==1 and c==0:
            print("-1")
            return

        if (ans[s-1] is not None) and (ans[s-1] != c):
            print("-1")
            return

        ans[s-1] = c

    s = ""
    for i, x in enumerate(ans):
        if (i==0) and (x is None):
            s += "1"
        elif x is None:
            s += "0"
        else:
            s += str(x)
    print(s)



if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
import math

N, M = map(int, input().split())

def comb(n):
    if n == 2:
        return 1
    elif n == 1:
        return 0
    elif n > 0:
        return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
    else:
        return 0

print(comb(N)+comb(M))


Measured memory_bytes: 2940
N=int(input())
if N<10:
    print(N)
    exit()
if N<100:
    print(9)
    exit()
if N<1000:
    print(9+N-100+1)
    exit()
if N<10000:
    print(909)
    exit()
if N<100000:
    print(909+N-10000+1)
    exit()
if N==100000:
    print(90909)
    exit()

Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char x; cin >> x;
    int a=x-'a';
    cout << char(a+1+'a') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int       long long
#define w(x)      int x;cin >> x;while (x--)
#define rep(d,a,n)  for(int d=a;d<=n;d++)
#define rep_(d,a,n)  for(int d=a;d>=n;d--)
#define nl        "\n" 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define oj  freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int inf=1e18;
int gcd(int a,int b,int temp){
    if(temp==1){
        return 1;
    }else if(a%temp==0 && b%temp==0){
        return temp;
    }
    temp-=max(a%temp,b%temp);
    return gcd(a,b,temp);
}

void fun(){
    int n;cin>>n;
    int sum=0;
    int val[100001];
  rep(l,0,100000){val[l]=0;}
    rep(i,0,n-1){
        int tem;cin>>tem;
        sum+=tem;
        val[tem]++;
    }
    int q;cin>>q;
    while(q--){
        int b,c;cin>>b>>c;
        sum+=(c)*val[b];
        sum-=b*val[b];
        val[c]+=val[b];
        val[b]=0;
        cout<<sum<<nl;
    }
}
int32_t main()
{
   
    fast_io;
    fun();
    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n ; i++ ){
    cin >> v.at(i);
  }
  vector<int> c(n);
  for(int i = 0; i < n; i++){
    cin >> c.at(i);
  }
  int ans = 0;
  for(int i = 0; i< n; i++){
    if(v.at(i) > c.at(i)){
      ans += v.at(i) - c.at(i);
    }
  }
  cout << ans << endl;
    
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#ifdef LOCAL
template <class T> ostream &operator<<(ostream &str, const vector<T> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
#define dbg cerr << "  line " << __LINE__ << ": "
#else
#define var(x) 0
struct dbg_cls {
  template <class T> dbg_cls &operator<<(const T &oth) { return *this; }
} dbg;
#endif
using ll = long long;
using ld = long double;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    vector<ll> table(100);
    int prev = 0;
    for (ll i = 1; i <= 12; i++) {
      for (ll j = prev; j <= prev + i; j++)
        table[j] = i - 1;
      prev += i;
    }

    ll x;
    cin >> x;
    map<ll, ll> factor;
    for (ll j = 2; j * j <= x; j++) {
      while (x % j == 0) {
        ++factor[j];
        x /= j;
      }
    }
    if (x != 1)
      ++factor[x];
    ll ans = 0;
    for (auto p : factor)
      ans += table[p.second];
    cout << ans << '\n';
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


Measured memory_bytes: 3656
n=int(input())
s=sorted([int(input()) for _ in [0]*n])
if sum(s)%10!=0:
    print(sum(s))
else:
    a=sum(s)
    for i in range(n):
        if s[i]%10!=0:a=s[i];break
    print(sum(s)-a)

Measured memory_bytes: 3060
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> 
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MaX 300005
using namespace std;

 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

int main()
{
	fast();
	char x;
	cin>>x;
	if(x>='A' and x<='Z')
		cout<<'A';
	else
		cout<<'a';
}






/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀
*/

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

int main() {
  int N, K, d = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i ++) {
    int x;
    cin >> x;
    d += x * (K/2 >= x) + (K - x) * (K/2 < x);
  }
  
  cout << d*2 << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        out.println(n>=30?"Yes":"No");
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 33000
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,t,v[5],dp[100010][5],a[100010],ans=0;
string s;

int main()
{
  cin>>n>>t>>v[0]>>v[1]>>v[2]>>s;
  rep(i,n)
  {
    if(s[i]=='r') a[i]=0;
    else if(s[i]=='s') a[i]=1;
    else a[i]=2;
  }
  rep(i,n)
  {
    rep(j,3)
    {
      int tmp=0;
      if(i-t>=0) rep(k,3) if(k!=j) tmp=max(tmp,dp[i-t][k]);
      dp[i][j]=tmp+(j==(a[i]-1+3)%3 ? v[j]:0);
    }
  }
  rep(i,n) if(i+t>=n) ans+=max(dp[i][0],max(dp[i][1],dp[i][2]));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2816
S=input()
sum="Yes"
kai=len(S)
unk=(int(kai)-1)/2
unk1=(int(kai)+3)/2
A=S[0:int(unk)]
B=S[int(unk1-1):int(kai)]
#print(B)
for i in range(kai//2):
  if S[i]!=S[-i-1]:
    sum="No"
for i in range(len(A)):
  if A[i]!=A[-i-1]:
    sum="No"
for i in range(len(B)):
  if B[i]!=B[-i-1]:
    sum="No"
print(sum)

Measured memory_bytes: 3064
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

ll f(ll b, ll n) {
	if (b > n) return n;
	return f(b, n / b) + (n % b);
}

void solv() {

	int n;
	cin >> n;
	ll a[100010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	sort(a, a + n);
	// 貪欲？
	// どのように貪欲にする？
	// -1,-1である場合 ans = 0となる
	// -1,-1,-1である場合 -1 - (-1) = 0, 0 - (-1) ,ans = 1となる
	// 正の値で引いていく
	ll pq[100010];
	ll nq[100010];
	int pc = 0;
	int nc = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (a[i] >= 0) pq[pc++] = a[i];
		else nq[nc++] = a[i];
	}
	vector<pair<ll, ll>> v;
	ll res = 0;
	if (nc == 0) {
		ll ba = pq[0];
		
		for (size_t i = 1; i < pc - 1; i++)
		{
			v.push_back(make_pair(ba, pq[i]));
			ba -= pq[i];
		}
		v.push_back(make_pair(pq[pc - 1], ba));
		res = pq[pc - 1] - ba;

	}
	else if (pc == 0) {
		ll ba = nq[nc - 1];
		for (size_t i = 0; i < nc - 1; i++)
		{
			v.push_back(make_pair(ba, nq[i]));
			ba -= nq[i];
		}
		res = ba;
	}
	else {
		for (size_t i = 0; i < pc - 1; i++)
		{
			v.push_back(make_pair(nq[0], pq[i]));
			nq[0] -= pq[i];
		}
		ll ba = pq[pc - 1];
		for (size_t i = 0; i < nc; i++)
		{
			v.push_back(make_pair(ba, nq[i]));
			ba -= nq[i];
		}
		res = ba;
	}
	cout << res << endl;
	for (size_t i = 0; i < v.size(); i++)
	{
		cout << v[i].first << " " << v[i].second << endl;
	}
}

int main() {
//	COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 5488
/** MIT License Copyright (c) 2018 Vasilyev Daniil **/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template<typename T> using v=vector<T>;
#define int long long
typedef string str;
typedef vector<int> vint;
#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define pb push_back
#define sz(a) ((int)(a).size())
const long long inf=4611686018427387903;//2^62-1
#if 0 //FileIO
ifstream fin ("input.txt" );
ofstream fout("output.txt");
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
#define eol put endl
void read(){}             template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get   (arg)     ;read(args...) ;}
void print(){}            template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put   (arg)<<" ";print(args...);}
void debug(){cerr<<endl;} template<typename Arg,typename... Args> void debug(Arg  arg,Args...  args){cerr<<(arg)<<" ";debug(args...);}
int getInt(){int a; get a; return a;}
//code goes here
void run(){int ans=0;
    int n;get n;str s;get s;
    rep(i,1,n){
        str s1=s.substr(0,i);
        str s2=s.substr(i);
        set<char>z1,z2;for(char i:s1)z1.insert(i);for(char i:s2)z2.insert(i);
        int d=0;
        for(char i:z1)if(z2.count(i))d++;
        ans=max(ans,d);
    }
    put ans;eol;
}
int32_t main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
#include <iostream>

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

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

const string YES = "Yes";
const string NO = "No";

void solve(ll N, ll M) {
  ;
  bool pred = N == M;
  cout << (pred ? YES : NO) << endl;
}

int main() {
  ll N;
  cin >> N;
  ll M;
  cin >> M;
  solve(N, M);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;


int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    rep(i, h){
        rep(j, w){
            if(j < a && i < b) cout << "0";
            else if(b <= i && a <= j) cout << "0";
            else cout << "1";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;
typedef pair<double, int> Pdi;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

double pi = 3.141592653589793238;

signed main(){

    int N; cin >> N;
    vector<double> x(N), y(N);

    REP(i, N) cin >> x[i] >> y[i];

    vector<double> ans(N, 0.0);
    
    int n = 1000000;
    REP(i, n){
        double theta = 2.0 * pi * (double)i / (double)(n);
        double maxv = -1.0 * INF, v;
        int maxi;
        REP(j, N){
            v = x[j] * cos(theta) + y[j] * sin(theta);
            if(v > maxv){
                maxv = v;
                maxi = j;
            }
        }
        ans[maxi] += 1.0 / (double)n;
    }

    REP(i, N) cout << ans[i] << endl;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){


  int a,b;
  cin>>a>>b;
  cout<<(double)a/b<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define PI 3.14159265359

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin >> n >> m;
    vector<vi> adjList(n);
    vi mark(n, -1);
    for_(i, 0, m) {
        int a, b; cin >> a >> b;
        a -= 1; b -= 1;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }

    int INF = 10*m;
    queue<int> q;
    q.push(0);
    while (q.size()) {
        int p = q.front(); q.pop();
        for (int n: adjList[p]) {
            if (mark[n] != -1) continue;
            mark[n] = p;
            q.push(n);
        }
    }

    bool valid = true;
    for_(i, 0, n) if (mark[i] == -1) {
        valid = false;
        break;
    }
    if(!valid) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        for_(i, 1, n) cout << mark[i]+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 10224