akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void){
    int n,flag=0;
    while (cin>>n) {
        if (n==3) {
            cout<<2<<" "<<5<<endl;
        } else if (n%2==0) {
            for (int i=n-1;i>0;i-=2) {
                double sqrtNum=sqrt(i);
                for (int j=3;j<sqrtNum;j+=2) {
                    if (i%j==0) {
                        flag=1;
                        break;
                    }
                }
                if (flag==0) {
                    cout<<i<<" ";
                    break;
                } else {
                    flag=0;
                }
            }
            for (int k=n+1;k>0;k+=2) {
                double sqrtNum=sqrt(k);
                for (int l=3;l<sqrtNum;l+=2) {
                    if (k%l==0) {
                        flag=1;
                        break;
                    }
                }
                if (flag==0) {
                    cout<<k<<endl;
                    break;
                } else {
                    flag=0;
                }
            }
        } else {
            for (int m=n-2;m>0;m-=2) {
                double sqrtNum=sqrt(m);
                for (int o=3;o<sqrtNum;o+=2) {
                    if (m%o==0) {
                        flag=1;
                        break;
                    }
                }
                if (flag==0) {
                    cout<<m<<" ";
                    break;
                } else {
                    flag=0;
                }
            }
            for (int p=n+2;p>0;p+=2) {
                double sqrtNum=sqrt(p);
                for (int q=3;q<sqrtNum;q+=2) {
                    if (p%q==0) {
                        flag=1;
                        break;
                    }
                }
                if (flag==0) {
                    cout<<p<<endl;
                    break;
                } else {
                    flag=0;
                }
            }
        }
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll n,k;
    cin>>n>>k;
    ll ar[n];
    for(ll i=0;i<n;i++)
        cin>>ar[i];
    ll maxsum=0;
    for(ll i=0;i<k;i++)
        maxsum+=ar[i];
    ll tempsum=maxsum;
    ll maxindex=k-1;
    for(ll i=k;i<n;i++)
    {
        tempsum=tempsum+ar[i]-ar[i-k];
        if(tempsum>maxsum)
        {
            maxsum=tempsum;
            maxindex=i;
        }
    }
    double ans=0;
    for(ll i=maxindex;i>maxindex-k;i--)
    {
        ans+=ar[i]+1;
    }
    printf("%0.12lf",ans/2);
}

Measured memory_bytes: 1920
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	//int Test; scanf("%d", &Test); while (Test--){
		int n; scanf("%d", &n);
		int ans = 0;
		for(int i = 3; i <= n; i += 2) {
			int cnt = 0;
			for(int j = 1; j * j <= i; j++) {
				if(i % j == 0) {
					cnt += (j * j == i) ? 1 : 2;
				}
			}
			if(cnt == 8) {
				ans += 1;
			}
		}
		printf("%d\n", ans);
	//}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>

void func_B(int N, int D) {
	int** X = new int* [N];
	for (int i = 0; i < N; i++)
		X[i] = new int[D];

	for (int i = 0; i < N; i++)
		for (int j = 0; j < D; j++)
			std::cin >> X[i][j];

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			double dist = 0;
			for (int k = 0; k < D; k++) {
				dist += abs(pow(X[j][k] - X[i][k], 2));
			}
			dist = sqrt(dist);
			if (ceil(dist) == floor(dist))
				cnt++;
		}
	}
	std::cout<<cnt;

	for (int i = 0; i < N; i++)
		free(X[i]);
	free(X);
}


int main() {
	int N, D;
	std::cin >> N >> D;
	func_B(N, D);
	return 0;
}

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

int main() {
  int64_t P,x,y,Q=1000000007,Z=0;
  cin>>P>>x>>y;
  int64_t N=P; //ここから
       int64_t a=1,b=0,c=1;
       while(N>0){
         a*=2;
         if(N%a!=0){
           N-=a/2;
           int64_t d=2;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           c=c*d;
          c=c%Q;
         }
        b++;
      } //ここまで
  Z+=c;
  
    int64_t A=P,B=x,C=1;
  for(int64_t i=1;i<=B;i++){
    C=(C*i)%Q;
  }
  N=Q-2;
   a=1,b=0,c=1;
  while(N>0){
    a*=2;
    if(N%a!=0){
      N-=a/2;
      int64_t d=C;
      for(int j=0;j<b;j++){
        d=(d*d)%Q;
      }
      c=(c*d)%Q;
    }
    b++;
  }
  C=c;
  for(int i=0;i<B;i++){
    C=(C*(A-i))%Q;
  }
  Z=(Z+Q-C)%Q;
  
A=P,B=y,C=1;
  for(int64_t i=1;i<=B;i++){
    C=(C*i)%Q;
  }
N=Q-2,a=1,b=0,c=1;
  while(N>0){
    a*=2;
    if(N%a!=0){
      N-=a/2;
      int64_t d=C;
      for(int j=0;j<b;j++){
        d=(d*d)%Q;
      }
      c=(c*d)%Q;
    }
    b++;
  }
  C=c;
  for(int i=0;i<B;i++){
    C=(C*(A-i))%Q;
  }
  Z=(Z+Q-C-1)%Q;
  cout<<Z<<endl;
}




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

def sieve(n):
    res = [True for _ in range(n + 1)]
    res[0] = False
    res[1] = False
    i = 2
    while i * i <= n:
        if res[i]:
            for j in range(i * 2, n + 1, i):
                res[j] = False
        i += 1
    return res

S = sieve(55555)
A = []
cnt = 0

for i in range(55555):
    if S[i] and i % 5 == 1:
        A.append(i)
        cnt += 1
    if cnt == N:
        break

print(*A)

Measured memory_bytes: 3608
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	string s;
	cin >> s;
	if(s == "ABC"){
		cout << "ARC" << endl;
	}else{
		cout << "ABC" << endl;
	}
	return 0;
}


Measured memory_bytes: 3620
import sys

a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

d1 = (v - w)*t
d2 = abs(a-b) 
if v < w:
    print("NO")
elif d1 >= d2 :
    print("YES")
else:
    print('NO')

Measured memory_bytes: 9208
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [x, y] <- getIntList

  let solve i | i > x     = "No"
              | otherwise = let j = x - i
                                n = i * 2 + j * 4
                            in if n == y
                               then "Yes"
                               else solve (i+1)

  putStrLn $ solve 0


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

def digitSum(s):
    x1 = s//10**4
    x2 = (s-x1*10**4)//10**3
    x3 = (s-x2*10**3-x1*10**4)//10**2
    x4 = (s-x3*10**2-x2*10**3-x1*10**4)//10
    x5 = (s-x4*10-x3*10**2-x2*10**3-x1*10**4)
    # print(x1,x2,x3,x4,x5)
    return x2,x3,x4,x5

a,b,c,d=digitSum(N)

suzi=[b,c,d]

puramai=[0,0,0]
i=0
answer=[0,0,0]
def tansaku(i,puramai,sum,answer):
    if i==3:
        if sum+a==7:
            answer[0]=puramai[0]
            answer[1]=puramai[1]
            answer[2]=puramai[2]
            return 
        else:
            return            
    sum+=suzi[i]
    puramai[i]='+'
    tansaku(i+1,puramai,sum,answer)

    sum=sum-2*suzi[i]
    puramai[i]='-'
    tansaku(i+1,puramai,sum,answer)
    

tansaku(0,puramai,0,answer)  

    
m=str(a)+answer[0]+str(b)+answer[1]+str(c)+answer[2]+str(d)+'=7'
print(m)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include <map>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <limits.h>
#include <string>
#include<functional>
#include <set>
#include <utility>
#include <iomanip>
#include <string>
#define INF 1<<30
#define MO 1000000007
#define MI 998244353
#define ll long long
#define woo 140737488355327
using namespace std;
int a[2100010];ll dp[2100001][3];
int main()
{
    int n;scanf("%d",&n);
    for(int i=0;i<n;i++)
      scanf("%d",&a[i]);
    ll ans;
    if(n%2==0)
    {
    dp[0][0]=a[0];dp[0][1]=a[1];
    for(int i=2;i<n;i+=2)
    {
        dp[i/2][0]=dp[i/2-1][0]+a[i];
        dp[i/2][1]=max(dp[i/2-1][0]+a[i+1],dp[i/2-1][1]+a[i+1]);
    }
    ans=max(dp[n/2-1][0],dp[n/2-1][1]);
    }
    else
    {
    dp[0][0]=a[0];dp[0][1]=a[1];dp[0][2]=a[2];
    for(int i=1;i<n/2;i++)
    {
        dp[i][0]=dp[i-1][0]+a[i*2];
        dp[i][1]=max(dp[i-1][0]+a[i*2+1],dp[i-1][1]+a[i*2+1]);
        dp[i][2]=max(max(dp[i-1][0]+a[i*2+2],dp[i-1][1]+a[i*2+2]),dp[i-1][2]+a[i*2+2]);
    }
    ans=max(dp[n/2-1][0],max(dp[n/2-1][1],dp[n/2-1][2]));
    }
    printf("%lld\n",ans);
}



Measured memory_bytes: 6952
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        root = x
        while self.par[root] != root:
            root = self.par[root]
        while self.par[x] != root:
            par = self.par[x]
            self.par[x] = root
            x = par
        return root

    def unite(self, x, y):
        xr = self.find(x)
        yr = self.find(y)
        if xr == yr: return
        if self.size[xr] <= self.size[yr]:
            self.par[xr] = yr
            self.size[yr] += self.size[xr]
        else:
            self.par[yr] = xr
            self.size[xr] += self.size[yr]

import sys
input = sys.stdin.buffer.readline

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

uf = UnionFind(N)
res = list()

for _ in range(Q):
    t, u, v = map(int, input().split())
    if t == 0:
        uf.unite(u, v)
    else:
        res.append(int(uf.find(u) == uf.find(v)))

print('\n'.join(map(str, res)))

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

using ll = long long;

int main(){
    int N;cin >> N;
    string s;cin >> s;
    int R = count(s.begin(), s.end(), 'R');
    int ans = 0;
    for(int i = 0;i < N;i++){
        if(i <= R-1 && s[i] == 'W'){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3752
#encoding:utf-8
weights = []
while gets
 weights.push $_.to_f
end

i = 0
while i < weights.length
 if weights[i] <= 48.00
  puts "light fly"
 elsif weights[i] > 48.00 && weights[i] <= 51.00
  puts "fly"
 elsif weights[i] > 51.00 && weights[i] <= 54.00
  puts "bantam"
 elsif weights[i] > 54.00 && weights[i] <= 57.00
  puts "feather"
 elsif weights[i] > 57.00 && weights[i] <= 60.00
  puts "light"
 elsif weights[i] > 60.00 && weights[i] <= 64.00
  puts "light welter"
 elsif weights[i] > 64.00 && weights[i] <= 69.00
  puts "welter"
 elsif weights[i] > 69.00 && weights[i] <= 75.00
  puts "light middle"
 elsif weights[i] > 75.00 && weights[i] <= 81.00
  puts "middle"
 elsif weights[i] > 81.00 && weights[i] <= 91.00
  puts "light heavy"
 else
  puts "heavy"
 end 
 i += 1
end

Measured memory_bytes: 6116
<?php
$cost = explode(" ",fgets(STDIN));
sort($cost);
$answer[] = $cost[1]+$cost[2]-$cost[0]*2;
$answer[] = $cost[2]-$cost[0];
$answer[] = $cost[2]*2-$cost[1]-$cost[0];
sort($answer);
if($answer[0]<0){
$answer[0] = -$answer[0];
}
echo $answer[0];


Measured memory_bytes: 3700
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=1000;

int n;
int a[MAXN];



ll ans;
int ret[MAXN],nret;

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);

	int mxi=0; FOR(i,1,n) if(a[i]>a[mxi]) mxi=i;
	if(a[mxi]<0) {
		ans=a[mxi];
		nret=0; REP(i,n-mxi-1) ret[nret++]=n-i-1; REP(i,mxi) ret[nret++]=0;
	} else {
		ans=LLONG_MIN; int bs=-1;
		REP(s,2) {
			ll cur=0; bool any=false; for(int i=s;i<n;i+=2) if(a[i]>=0) cur+=a[i],any=true;
			if(any&&cur>ans) ans=cur,bs=s;
		}
		int cnt=0; nret=0;
		if(n%2==bs) ret[nret++]=n-1;
		for(int i=n-1-(n%2==bs?1:0);i>=bs;i-=2) {
			if(a[i]>=0) { ++cnt; continue; }
			ret[nret++]=i; if(cnt==0) ret[nret++]=i-1; if(i==0) ret[nret++]=0;
		}
		if(bs==1) ret[nret++]=0;
		REP(i,cnt-1) ret[nret++]=1;
	}
	printf("%lld\n",ans); printf("%d\n",nret); REP(i,nret) printf("%d\n",ret[i]+1); puts("");
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dl double
using namespace std;

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
	string s;
	cin >>s;
	if(s[2]==s[3] && s[4]==s[5])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

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

int main() {
  string s;
  int x, y, sx = 0;
  int N = 8010;
  int slen = 16010;
  int len = 0;
  int lens[N];
  int lens_idx = 0;
  bool dp_x[N][slen];
  bool dp_y[N][slen];
  int offset = slen / 2;
  cin >> s >> x >> y; x += offset; y += offset;

  for (int i=0; s[i]=='F' && i<s.length(); i++) sx++;
  
  for (int i=0; i<N; i++) {
    for (int j=0; j<slen; j++) {
      dp_x[i][j] = false;
      dp_y[i][j] = false;
    }
    lens[i] = 0;
  }
  dp_x[0][offset + sx] = true;
  dp_y[0][offset] = true;
  for (int i=sx + 1; i<s.length(); i++) {
    if (s[i] == 'T') {
      lens[lens_idx++] = len;
      len = 0;
    } else {
      len++;
      if (i == s.length() - 1) lens[lens_idx++] = len;
    }
  }

  for (int li=0; li<lens_idx; li++) {
    for (int i=0; i<slen; i++) {
      if ((li & 1) == 0) {
        if (slen - lens[li] < i) dp_y[li / 2 + 1][i] = dp_y[li / 2][i - lens[li]];
        else if(i < lens[li]) {
          dp_y[li / 2 + 1][i] = dp_y[li / 2][i + lens[li]];
        } else dp_y[li / 2 + 1][i] = dp_y[li / 2][i - lens[li]] | dp_y[li / 2][i + lens[li]];
      } else {
        if (slen - lens[li] < i) dp_x[li / 2 + 1][i] = dp_x[li / 2][i - lens[li]];
        else if(i < lens[li]) {
          dp_x[li / 2 + 1][i] = dp_x[li / 2][i + lens[li]];
        } else dp_x[li / 2 + 1][i] = dp_x[li / 2][i - lens[li]] | dp_x[li / 2][i + lens[li]];
      }
    } 
  }
  cout << ((dp_x[lens_idx / 2][x] & dp_y[(lens_idx + 1) / 2][y]) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 250880
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int ans = 0;
	for (int i = 0; i < a+1; ++i)
	{
		for (int j = 0; j < b+1; ++j)
		{
			for (int k = 0; k < c+1; ++k)
			{
				ans += (i * 500 + j * 100 + k * 50 == x);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <typename T>
class SegmentTree
{
public:
    SegmentTree(const int n, const T &unit) : _unit(unit)
    {
        _n = 1 << __lg(2 * n - 1);
        _data.resize(2 * _n, unit);
    }

    SegmentTree(const vector<T> &v, const T &unit) : _unit(unit)
    {
        int n = v.size();
        _n = 1 << __lg(2 * n - 1);
        _data.resize(2 * _n, unit);

        // 最下段に要素をセット
        for (int i = 0; i < n; i++) this->set(i, v[i]);
        // セグメント木を構築
        this->build();
    }

    // k 番目の要素を最下段にセット
    void set(int k, const T &x) { _data[k + _n] = x; }

    // セグメント木を構築
    void build(void)
    {
        for (int i = _n - 1; i > 0; i--) _data[i] = f(_data[2 * i], _data[2 * i + 1]);
    }

    // k番目の値をxに更新する
    void update(int k, const T &x)
    {
        k += _n; // 葉の節点に変換
        _data[k] = x;
        while (k >>= 1) _data[k] = f(_data[2 * k], _data[2 * k + 1]);
    }

    // 区間[a, b)に対してクエリ処理した結果を返す
    T query(int a, int b)
    {
        T left = _unit, right = _unit;
        a += _n, b += _n; // 葉の節点に変換
        for (; a < b; a >>= 1, b >>= 1) {
            if (a & 1) left  = f(left, _data[a++]);
            if (b & 1) right = f(_data[--b], right);
        }
        return f(left, right);
    }

    const T &operator[](size_t k) const { return _data[k + _n]; }
    T &operator[](size_t k) { return _data[k + _n]; }

private:
    int _n;          // 要素数
    vector<T> _data; // データを格納する配列
    T _unit;        // 単位元

    // クエリ処理用の関数
    T f(const T &a, const T &b) { return max(a, b); }
};

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

    int n; ll c; cin >> n >> c;
    vector<ll> x(n + 2), v(n + 2);
    for (int i = 1; i <= n; i++) cin >> x[i] >> v[i];
    x[n + 1] = c;

    SegmentTree<ll> l(n + 2, 0), r(n + 2, 0);
    for (int i = 0; i < n; i++) {
        l[i + 1] = l[i] + v[i + 1] - (x[i + 1] - x[i]);
    }
    for (int i = n; i > 0; i--) {
        r[i] = r[i + 1] + v[i] - (x[i + 1] - x[i]);
    }
    l.build(); r.build();

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ll res1 = l[i] + max<ll>(0, r.query(i + 1, n + 2) - x[i]);
        ll res2 = r[i] + max<ll>(0, l.query(0, i) - (c - x[i]));
        ans = max({ans, res1, res2});
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}

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

  int n,h,w; cin >> n >> h >> w;

  int ans = 0;

  REP(i,n){
    int a,b; cin >> a >> b;
    if(h<=a && w<=b) ++ans;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
A, B, C, K = map(int, input().split())

score = 0
if A < K:
    K -=A
    score += A
else:
    score = K
    print(score)
    exit()

if B < K:
    K -=B
else:
    print(score)
    exit()

if C < K:
    K -=C
    score -= C
else:
    score -= K
    print(score)
    exit()
print(score)

Measured memory_bytes: 8952
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 100000;

int main() {
    int n, m;
    cin >> n >> m;

    int c[m];
    rep(i, m) {
        cin >> c[i];
    }

    int dp[n+1];  // dp[j] : j円支払うときのコインの枚数の最小値(jは0-index)

    rep(j, n+1) {
        dp[j] = INF;
    }

    dp[0] = 0;
    rep(i, m) {
        for(int j = c[i]; j <= n; j++) {
            dp[j] = min(dp[j], dp[j-c[i]] + 1);
        }
    }

    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3276
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int maxn=0;
	long long ans=0;
	for (int i=1,a;i<=n;i++)
	{
		scanf("%d",&a);
		if (a<maxn) ans+=(long long)(maxn-a);
		maxn=max(maxn,a);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3232
//# pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#define out(i,a,now) for(int i=a.be[now],to=a.v[i];~i;i=a.ne[i],to=a.v[i])
#define fo(i,a,b) for(i=(a);i<=(b);i++)
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)<(b)?(a):(b))
#define mp(a,b) make_pair(a,b)
#define qk(x) memset(x,0,sizeof(x))
#define RG register
#define gs(x) (tr[tr[x].f].son[1]==x)
#define lb(x) (x&(-x))
#define mid ((l+r)>>1)
#define SF scanf
#define PF printf
#ifdef Mogician
#endif
using namespace std;
typedef long long LL;
typedef double DB;
template <class T> void cmax(T &a,T b)
{
    a=max(a,b);
}
template <class T> void cmin(T &a,T b)
{
    a=min(a,b);
}
template <class T> void swp(T &a,T &b)
{
	T temp=a; a=b; b=temp;
}
const LL maxn=210000;
LL a[maxn],n,ADD[maxn],XOR[maxn];
int main()
{
	SF("%lld",&n);
	LL i;
	fo(i,1,n) SF("%lld",&a[i]);
	LL cnt=0,ans=0;
	fo(i,1,n) XOR[i]=XOR[i-1]^a[i];
	fo(i,1,n) ADD[i]=ADD[i-1]+a[i];
	LL j=0;
	fo(i,1,n)
	{
		while ((XOR[i]^XOR[j])!=(ADD[i]-ADD[j]))
		{
			j++;
		}
		ans+=i-j;
	}
	PF("%lld",ans);
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int n, sum = 0,x,a[234567];
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n-1; i++) {
		if (a[i]+a[i+1]>x) {
			
			sum += min( a[i] + a[i + 1] - x, a[i+1]);
			a[i+1] -= min( a[i] + a[i + 1] - x, a[i+1]);
		}
	}
	if (a[0] > x)sum += a[0] - x;
	cout << sum;
}



Measured memory_bytes: 1024
#include<stdio.h>


int A[100000];

int partition(int A[],int p,int r){
  int x,i,j,exs;

  x = A[r];
  i = p-1;

  for(j = p ; j < r; j++){
    if(A[j] <= x){
      i++;
      exs = A[j];
      A[j] = A[i];
      A[i] = exs;
    }
  }
    exs = A[i+1];
    A[i+1] = A[r];
    A[r] = exs;

  return i+1;

}


int main(void){

  int i,j;
  int num;
  int q;

  scanf("%d",&num);
  for(i = 0 ; i < num ; i++)
    scanf("%d",&A[i]);
  q = partition(A,0,num-1);
  for( i = 0 ; i < num-1 ; i++){
    if(i == q){
      printf("[%d] ",A[q]);
       continue;
    }
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  return 0;
}

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

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

  bool dup = false;
  set<int> appeared;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if(appeared.count(a)){
      dup = true;
    }
    appeared.insert(a);
  }
  if(dup){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 9600
#include <stdio.h>

long double w, h, x, y;

int main() {
    scanf("%Lf %Lf %Lf %Lf", &w, &h, &x, &y);

    printf("%.6Lf ", (w*h)/2.0);

    if (w/2.0 == x && h/2.0 == y) {puts("1");}
    else {puts("0");}

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const LL LINF = 1LL << 60;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ LL to, cost; edge(int t, LL c) :to(t), cost(c){} };

int main()
{
	int n;
	while (cin >> n && n)
	{
		int m; cin >> m;
		vector<LL> dists(n);
		rep(i, n - 1)
		{
			int d; cin >> d;
			dists[i + 1] += dists[i] + d;
		}

		LL ans = 0;
		int now = 0;
		rep(i, m)
		{
			int step; cin >> step;
			ans = (ans + abs(dists[now + step] - dists[now])) % MOD;
			now += step;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1788
package main

import (
    "fmt"
)

var n, q int
var s []byte
var qs [][]byte

func main() {
    fmt.Scan(&n, &q)
    fmt.Scan(&s)

    qs = make([][]byte, q)
    for i := 0; i < q; i++ {
        var ts, ds []byte
        fmt.Scan(&ts, &ds)
        qs[i] = []byte{ts[0], ds[0]}
    }
    lp := bl(-1, n)
    rp := br(-1, n)
    fmt.Println(rp - lp - 1)
}

func bl(l, r int) int {
    if r-l <= 1 {
        return l
    }
    p := int((l + r) / 2)
    if left(p) {
        return bl(p, r)
    } else {
        return bl(l, p)
    }
}

func br(l, r int) int {
    if r-l <= 1 {
        return r
    }
    p := int((l + r) / 2)
    if right(p) {
        return br(l, p)
    } else {
        return br(p, r)
    }
}

func left(pos int) bool {
    if pos == -1 {
        return true
    }
    if pos == n {
        return false
    }
    for i := 0; i < q; i++ {
        t := qs[i][0]
        d := qs[i][1]
        if s[pos] == t {
            switch d {
            case 'L':
                pos--
                if pos == -1 {
                    return true
                }
            case 'R':
                pos++
                if pos == n {
                    return false
                }
            }
        }
    }
    return false
}

func right(pos int) bool {
    if pos == -1 {
        return false
    }
    if pos == n {
        return true
    }
    for i := 0; i < q; i++ {
        t := qs[i][0]
        d := qs[i][1]
        if s[pos] == t {
            switch d {
            case 'L':
                pos--
                if pos == -1 {
                    return false
                }
            case 'R':
                pos++
                if pos == n {
                    return true
                }
            }
        }
    }
    return false
}                                                                                                                                                                                                                                           

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int N;
  cin >> N;

  vector<int> A(N + 2, 0);
  for (int i = 1; i <= N; i++) {
    cin >> A.at(i);
  }

  int S = 0;
  for (int i = 0; i <= N; i++) S += abs(A.at(i) - A.at(i + 1));

  for (int i = 1; i <= N; i++) {
    int diff = abs(A.at(i - 1) - A.at(i)) + abs(A.at(i) - A.at(i + 1)) -
               abs(A.at(i - 1) - A.at(i + 1));
    cout << S - diff << "\n";
  }
  return 0;
}


Measured memory_bytes: 1664
n = int(raw_input())
Card = [[] for _ in [0]*n]
Cost = {}
for i in range(n):
  Card[i] = map(int, raw_input().split())
  Cost[(i, i)] = 0
for i in range(1, n):
  for j in range(0, n-i):
    a = j+i
    Cost[(j, a)] = min([reduce(lambda a,b: a*b, [Card[j][0],Card[k][1],Card[k+1][0],Card[a][1]]) + Cost[(j, k)] + Cost[(k+1, a)] for k in range(j, j+i)])
print Cost[0, n-1]

Measured memory_bytes: 4520
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <sstream>

using namespace std;

int main()
{
    int N;
    int K;
    int R;
    cin >> N >> K >> R;
    
    if(N + K >= R)
    {
        cout << " Yes" << endl;
    }
    
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N - 1);
    REP(i, N - 1) {
        cin >> b[i];
    }
    a[0] = b[0];
    a[N - 1] = b[N - 2];
    FOR(i, 1, N - 1) {
        a[i] = min(b[i - 1], b[i]);
    }
    int res = 0;
    REP(i, N) {
        res += a[i];
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

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

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


int main() {
    int n; cin >> n;
    set<int> s;
    for(int i = 0;i < n;i++){
        int x; cin >> x;s.insert(x);
    }
    if(s.size() == n){
        cout << "YES";
    }else{
        cout << "NO";
    }
}




Measured memory_bytes: 13000
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}


int main(){
    int n;
    cin >> n;
    int nn = n;
    int sum = 0;

    while(n){
        sum += (n % 10);
        n /= 10;
    }

    cout << ( ( nn % sum == 0) ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main() {
    char a, b;
    cin >> a >> b;
    if(a==b) cout << "=" << endl;
    else if(a>b) cout << ">" << endl;
    else cout << "<" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	llint n;
	cin >> n;
	llint ans = 1;
	rep(i, n) {
		ans *= i + 1;
		ans %= 1000000007;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

int main(){
    ll n,k;
    cin >> n >> k;
    int ans=0;
    vector<int> way(n+1,-1);
    vector<int> trail;
    vector<ll> a(n);
    way[1]=0;

    rep(i,n){
        cin >> a[i];
    }
    
    ll loop_num;
    int from=1;
    int to=1;
    int counter=0;
    int before_loop=0;
    trail.push_back(1);

    while(true){
        counter++;
        to=a[from-1];
        trail.push_back(to);
        if(way[to]!=-1){
            loop_num=counter-way[to];
            break;
        }
        way[to]=counter;
        from = to;
    }
    if(k<=counter){
        cout << trail[k] << endl;
    }else{
        k = (k-counter) % loop_num;
        before_loop=counter-loop_num;
        cout << trail[before_loop+k] << endl;
    }


}

Measured memory_bytes: 6628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const ll INF=1e18;


int main() {
	int	n,rsum = 0,ans =0;
	string s;
	cin >> n >> s;
	rep(i,n){
		if(s[i] == 'R') rsum++;
	}
	rep(i,rsum){
		if(s[i] == 'W') ans++;
	}
	cout << ans <<endl;
}

Measured memory_bytes: 3684
#include "stdio.h"
#include "iostream"
using namespace std;


int main()
{
	char c[3][3];
	int i, j;
	char s[4];
	for (i = 0;i <= 2;i++)for (j = 0;j <= 2;j++) {
		cin >> c[i][j];
	}
	for (i = 0;i < 3;i++) {
		s[i] = c[i][i];
	}
	s[3] = '\0';
	printf("%s\n", s);

    return 0;
}



Measured memory_bytes: 256
N,A,B=map(int,input().split())

MOD=10**9+7
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

print((pow(2,N,MOD) - comb(N , A) - comb(N , B) - 1 ) % MOD )

Measured memory_bytes: 42972
fun main(args : Array<String>) {
    val (n, a, b) = readLine()!!.split(" ").map { it.toLong() }

    if ((b-a) % 2L == 0L) {
        println((b-a) / 2L)
    } else {
        val diffA = a - 1L
        val diffB = n - b

        if (diffA <= diffB) {
            val posB = b - diffA - 1L
            println((posB - 1L) / 2L + diffA + 1L)
        } else {
            val posA = a + diffB + 1L
            println((n-posA) / 2L + diffB + 1L)
        }
    }
}

Measured memory_bytes: 37800
import scala.io.{StdIn => in}
import annotation.tailrec

object Main extends App {
  val n = in.readInt
  val ms = in.readLine.split(" ").map(_.toInt)

  @tailrec
  def gcd(a:Int, b:Int):Int = {
    if(b== 0) a
    else gcd(b, a%b)
  }

  val ans = ms reduce gcd
  println(ans)
}

Measured memory_bytes: 42352
X=int(input())

def ok(B):
    i=1
    B=abs(B)
    while i**5<B:
        i+=1
    return i**5==B

def get(B):
    f = B/abs(B)
    i=1
    B=abs(B)
    while i**5<B:
        i+=1
    return int(i*f)



A_cand=[]
i=0
while i**5<=10**10:
    A_cand.append(i)
    i+=1

#print(A_cand)
for a in range(300):
    B_5=a**5-X
    if ok(B_5):
        r=get(B_5)
        print(a,r)
        exit()
        break
for a in A_cand:
    a*=-1
    B_5=a**5-X
    if ok(B_5):
        r=get(B_5)
        print(a,r)
        exit()
print(0/0)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

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


int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, avg, curr, total = 0, cost = 0;
  set<int> freqs;
  vi nums;
  
  cin >> n;
  
  while(n--){
    cin >> curr;
    nums.PB(curr);
    total += curr;
  }
  
  sort(nums.begin(), nums.end());
  
  if (nums[0] == nums[nums.size() - 1]) { cout << 0 << "\n"; return 0; }
  
  avg = round((total + 0.0) / (nums.size() + 0.0));
  
  for(auto pp : nums) cost += pow((pp - avg) , 2);
  
  cout << cost << "\n"; return 0;
}


Measured memory_bytes: 256
# 159 B
S = input()
N = len(S)
Sf = S[0:(N-1)//2]
NSf = len(Sf)
Sb = S[(N+3)//2 -1:N+1]
NSb = len(Sb)
ans = 0

for i in range(N//2):
    if S[i:i+1] != S[N-1-i:N-i]:
        ans = 1

for i in range(NSf//2):
    if Sf[i:i+1] != Sf[NSf-1-i:NSf-i]:
        ans = 1
        
for i in range(NSb//2):
    if Sb[i:i+1] != Sb[NSb-1-i:NSb-i]:
        ans = 1
        
print('Yes') if ans == 0 else print('No')

Measured memory_bytes: 9152
n, k = map(int, input().split())
s = input()
n = len(s)

if n == 1:
    print(1)
    exit(0)

l = []
if s[0] == "0":
    l.append(0)

temp = 1
for i in range(1, n):
    if s[i] == s[i - 1]:
        temp += 1
        if i == n - 1:
            l.append(temp)
    else:
        l.append(temp)
        temp = 1
        if i == n - 1:
            l.append(temp)

if s[-1] == "0":
    l.append(0)

ans = 0

b = []
b.append(l[0])
for i in range(1, len(l)):
    b.append(b[-1] + l[i])


if 2 * k + 1 > len(l) - 1:
    print(b[len(l) - 1])
    exit(0)
else:
    ans = b[2 * k]


for i in range(1, len(l)):
    if i * 2 + 2 * k > len(l) - 1:
        break
    ans = max(ans, b[min(i * 2 + 2 * k, len(l) - 1)] - b[i * 2 - 1])
print(ans)


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


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

    vector<int> B(N-1);
    for(int i = 0; i < N-1; i++){
        cin >> B.at(i);
    }

    vector<int> A(N);

    for(int i = 0; i < N; i++){
        if(i == 0) A.at(i) = B.at(i);
        if(0 < i && i < N-1){
            A.at(i) = min(B.at(i),B.at(i-1));
            }
        if(i == N - 1)A.at(N - 1) = B.at(N-2);
    }

    long long Ans = 0;

    for (int i=0; i < N; i++){
        Ans += A.at(i);
    }


    cout << Ans << endl;
}


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

int main(){
	int n,m,l;
	int i,j,k;
	int A[100][100],B[100][100];
	long C[100][100]={0};
	
	cin>>n>>m>>l;
	for (i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>A[i][j];
		}
	}
	
	for (i=0;i<m;i++){
		for(j=0;j<l;j++){
			cin>>B[i][j];
		}
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				C[i][j]+=A[i][k]*B[k][j];
			}
		}
	}
	
	for (i=0;i<n;i++){
		for(j=0;j<l;j++){
			cout<<C[i][j];
			if(j!=l-1){
				cout<<" ";
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int k;
  int a, b;
  cin >> k >> a >> b;
  srep(i,a,b+1) {
    if (i%k == 0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 2e5+5


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

       int h,n;
       cin >> h >>n;
    int i,a[n+1];
    for(i=1; i<=n; i++) cin >> a[i];
    for(i=1; i<=n; i++){
        h=h-a[i];
        if(h<=0){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No" << '\n';
        
        

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 1e5 + 1;
vt<ll> dp(mxN), pfx(mxN, 1);
ll n, k;
 
 
int main()
{
FIO
 
    cin >> n >> k;
    ll num;
    For(n)
    {
        cin >> num;
        Rev(s,k,0)
        {
            ll l = max(s - num, 0ll);
            ll r = s;
            dp[s] = mod + pfx[r] - (l == 0 ? 0 : pfx[l-1]);
            dp[s] %= mod;
        }
        Rep(s,0,k)
        {
            pfx[s] = dp[s] + (s == 0 ? 0 : pfx[s-1]); 
            pfx[s] %= mod;
        }
    }
    cout << dp[k] << endl;
}

Measured memory_bytes: 4624
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
# template


def solve():
    ofs = 1000
    h, w = map(int, readline().split())
    A = [list(map(int, readline().split())) for i in range(h)]
    B = [list(map(int, readline().split())) for i in range(h)]
    dp = [0 for _ in range(w+1)]
    x = abs(A[0][0]-B[0][0])
    dp[0] = 1 << ofs

    for i in range(h):
        for j in range(w):
            x = abs(A[i][j]-B[i][j])
            t = (dp[j] | dp[j-1])
            dp[j] = ((t << x) | (t >> x))

    b = list(map(lambda s: s == '1', list(bin(dp[w-1])[-ofs-1:-ofs+100])))
    for i, s in enumerate(b):
        if(s):
            print(i)
            return


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3316