akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] x = new int[n][d];
		int ans = 0, sum = 0;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < d; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (i == j) {
					continue;
				}
				sum = 0;
				for (int k = 0; k < d; k++) {
					sum += Math.pow(x[i][k] - x[j][k], 2);
				}
				// System.out.println("i:"+i+" j:"+j+" sum:"+Math.sqrt(sum));
				if (Math.sqrt(sum) == (int)Math.sqrt(sum)) {
					ans++;
				}
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
/*ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}*/

/*void decToBinary(ll n)
{
    string s;
int binaryNum[32];
int i = 0;
while (n > 0) {
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
for (int j = i - 1; j >= 0; j--) {
 char c = binaryNum[j] +'0';
 s=s+c;
}
 
 //cout<<s<<endl;
 
 
 
 // for (int j = i - 1; j >= 0; j--)
 // cout<<s[j];
 
sort(s.begin(), s.end());
do {
cout << s << endl;
} while (next_permutation(s.begin(), s.end())); */
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll mindig(ll n){
ll x;
ll ans=mod;
 while(n>0)
        {
            x=n%10;
            ans=min(ans,x);
            n=n/10;
        }
        return ans;
}
ll maxdig(ll n)
{
    ll x;
    ll ans1=-1;
         while(n>0)
        {
            x=n%10;
            ans1=max(ans1,x);
            n=n/10;
        }
        return ans1;
}
 ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int main()
{
    char c;
    cin>>c;
    if(c<96)
    cout<<"A"<<endl;
    else 
    cout<<"a"<<endl;
}


Measured memory_bytes: 3616
N, M = map(int, input().split())
s = [[] for i in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    s[a].append(b)

for i in s[1]:
    if N in s[i]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Measured memory_bytes: 66508
//
//AtCoder Grand Contest 011
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n,c,k;
    cin >> n >> c >> k;

    vector<int> t(n);
    REP(i, n) cin >> t[i];
    sort(ALL(t));


    int ans = 0;
    int idx = 0;
    while(idx<n){
        int st = -1;
        REP(i, c){
            if (st==-1){
                st = t[idx]+k;
                idx++;
            }else{
                if (st>=t[idx]) idx++;
                else break;
            }
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3680
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"
#define cauto const auto

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
template<class A,class B> pair<A,B> operator+(const pair<A,B> &p,const pair<A,B> &q){ return {p.X+q.X,p.Y+q.Y};}
template<class A,class B,class C,class D> pair<A,B>& operator+=(const pair<A,B> &p,const pair<C,D> &q){ p.X+=p.X; q.Y+=q.Y; return p;}
template<class A,class B> pair<A,B> operator-(const pair<A,B> &p,const pair<A,B> &q){ return {p.X-q.X,p.Y-q.Y};}
template<class A,class B,class C,class D> pair<A,B>& operator-=(const pair<A,B> &p,const pair<C,D> &q){ p.X-=p.X; q.Y-=q.Y; return p;}
template<class A,class B> istream& operator>>(istream &is, pair<A,B> &p){ is>>p.X>>p.Y; return is;}
template<class T> T read(){ T re; cin>>re; return move(re);}
template<class T> T read(const T &dec){ T re; cin>>re; return re-dec;}
template<class T> vector<T> readV(const int sz){ vector<T> re(sz); for(auto &x:re) x=read<T>(); return move(re);}
template<class T> vector<T> readV(const int sz, const T &dec){ vector<T> re(sz); for(auto &x:re) x=read<T>(dec); return move(re);}
vv<int> readG(const int &n,const int &m){ vv<int> g(n); rep(_,m){ cauto a=read<int>(1),b=read<int>(1); g[a].pb(b); g[b].pb(a);} return move(g);}
vv<int> readG(const int &n){ return readG(n,n-1);}

const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	cauto n=read<int>();
	cauto g=readG(n);
	ll re=0;
	reps(i,1,n+1) re+=i*(n+1ll-i);
  rep(a,n)for(auto b:g[a])if(a<b) re-=(a+1ll)*(n-b);
	cout<<re NL;
  return 0;
}
 

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


int main()
{
  ll MOD = 1000000007;
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n)
    cin >> a[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(k + 1, 1));
  rep(i, n)
    for (int j = 1; j <= k; j++)
      dp[i+1][j] = (dp[i+1][j-1] + dp[i][j] - (j - a[i] > 0 ? dp[i][j-a[i]-1] : 0)) % MOD;
  ll ans;
  if (k > 0)
    ans = dp[n][k] - dp[n][k-1];
  else
    ans = dp[n][k];
  if (ans < 0)
    ans += MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	ll k,n;
	cin>>k>>n;
	ll a[n],b[n+1],i;
	for(i=0;i<n;i++)
	{
	    cin>>a[i];
	}
	b[0]=a[0]+k-a[n-1];
	for(i=1;i<n;i++)
	{
	    b[i]=a[i]-a[i-1];
	}
	sort(b,b+n);
	cout<<k-b[n-1];

	return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int N;
int sum = 0;

int main() {
	cin >> N;
	vector<int> d(N);
	rep(i, 0, N) {
		cin >> d[i];
	}

	rep(i, 0, N)rep(j, i + 1, N)sum += (d[i] * d[j]);

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
 int main(){

  int val;
  int i,j,N;
  int count = 0;

  scanf("%d",&val);

	for(i = 0 ;i < val;i++){
	scanf("%d",&N);
	 for(j = 2;j * j <= N;j++){
		 if(N % j == 0)break;
	  }
      if(j * j > N)
		  count++;
	 }
	 printf("%d\n",count);
	 return 0;
 }

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

int main(){
    int N;
    ll vol;
    cin >> N;
    vector<int> box(3*N);
    for(int i = 0; i < N*3; i++){
        cin >> box.at(i);
    }

    sort(box.begin(), box.end(), greater<int>());
    vol = 0;

    for(int i = 1; i < 2*N; i += 2){
        vol += box.at(i);
    }

    cout << vol << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end() 
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define forn(i, n) for(int i=0;i<(n);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

using _Tp = long long;
static _Tp const mod = 1e9+7;
class modular {
	public:
	_Tp value;
	modular() {}
	modular(_Tp b) {value = b%mod;}
	_Tp operator=(_Tp b) {value = b%mod; return b;}
	auto operator+(modular b) {return modular{(value+b.value)%mod};}
	auto operator+(_Tp b) {return modular{(value+b)%mod};}
	auto operator-(modular b) {return modular{(value-b.value+mod)%mod};}
	auto operator-(_Tp b) {return modular{(value-b+mod)%mod};}
	auto operator*(modular b) {return modular{value*b.value%mod};}
	auto operator*(_Tp b) {return modular{value*b%mod};}
	auto operator/(modular b) {return modular{value*pow(b.value, mod-2)%mod};}
	auto operator/(_Tp b) {return modular{value*pow(b, mod-2)%mod};}
	operator _Tp() {return value;}
	static _Tp pow(_Tp v, _Tp k) {
		if(k == 0) return 1;
		if(k == 1) return v%mod;
		if(k % 2 == 0) {
			auto ret = pow(v, k/2);
			return ret*ret%mod;
		}
		return v*pow(v,k-1)%mod;
	}
};
modular C(ll p, ll q) {
	modular one = 1, two = 1;
	for(ll i=p;i>p-q;i--) one = one*i;
	for(ll i=1;i<=q;i++) two = two*i;
	return one/two;
}
int main() {
	fastio;
	ll n, a , b;
	cin >> n >> a >> b;
	modular ans = modular(modular::pow(2, n)) - 1;
	// ans - nCa - nCb
	ans = ans - C(n, a) - C(n, b);
	cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll H, W, h, w;
  cin >> H >> W >> h >> w;
  ll ans = (H - h) * (W - w);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <bitset>

using namespace std;

int popcount(int n)
{
	return bitset<32>(n).count();
}

int f(int n)
{
	if (n == 0) {
		return 0;
	}
	return 1 + f(n % popcount(n));
}


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

	int pc = count(X.begin(), X.end(), '1');
	int pc_minus = pc - 1;
	int pc_plus = pc + 1;

	reverse(X.begin(), X.end());

	vector<int> pow2mod_minus(N);
	vector<int> pow2mod_plus(N);

	if (pc > 1) {
		pow2mod_minus[0] = 1 % (pc - 1);
	}
	pow2mod_plus[0] = 1 % (pc + 1);
	
	for (int i = 1; i < N; ++i) {
		if (pc_minus != 0) {
			pow2mod_minus[i] = (pow2mod_minus[i - 1] * 2) % pc_minus;
		}
		pow2mod_plus[i] = (pow2mod_plus[i - 1] * 2) % pc_plus;
	}

	int Xmod_minus = 0;
	int Xmod_plus = 0;
	for (int i = 0; i < N; ++i) {
		if (X[i] == '1') {
			if (pc_minus != 0) {
				Xmod_minus = (Xmod_minus + pow2mod_minus[i]) % pc_minus;
			}
			Xmod_plus = (Xmod_plus + pow2mod_plus[i]) % pc_plus;
		}
	}

	for (int i = N - 1; i >= 0; --i) {
		if (X[i] == '1') {
			if (pc_minus == 0) {
				cout << 0 << endl;
			}
			else {
				int tmp = (pc_minus - pow2mod_minus[i]) % pc_minus;
				int Y = (Xmod_minus + tmp) % pc_minus;
				cout << 1 + f(Y) << endl;
			}
		}
		else {
			int Y = (Xmod_plus + pow2mod_plus[i]) % pc_plus;
			cout << 1 + f(Y) << endl;
		}
	}
}


Measured memory_bytes: 5184
#include <stdio.h>
#include <string.h>
#define swap(a,b) (a += b,b = a - b,a -= b)
#define MAX 2000000
#define INFTY (1 << 30)

void maxHeapify(int i);
int extract();
void increaseKey(int i, int key);
void insert(int key) ;


int size, A[MAX+1];

int main(){
  int key;
  char com[20];
  
  while(1){
    scanf("%s", com);
    if ( com[0] == 'e' && com[1] == 'n' ) break;
    if ( com[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(com, "extract") == 0  ){
      printf("%d\n", extract());
    } 
  }
  
  return 0;
}


void increaseKey(int i, int key) {
  int tmp;
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i / 2] < A[i] ){
    swap(A[i], A[i/2]);
    i = i/2;
  }
}

void insert(int key) {
  size++;
  A[size] = -INFTY;
  increaseKey(size, key);
}

int extract(){
  int maxv;
  if ( size < 1 ) return - INFTY;
  maxv = A[1];
  A[1] = A[size--];
  maxHeapify(1);
  return maxv;
}

void maxHeapify(int i){
  int l, r, largest, t;
  l = 2*i;
  r = 2*i+1;
  if ( l <= size && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= size && A[r] > A[largest] ) largest = r;
  if ( largest != i ){
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(largest);
  }
}



Measured memory_bytes: 5604
a, b, c, d = map(int, input().split())

def gcd(n, m):
	while m:
		n, m = m, n % m
	return n

def lcm(n, m):
	return n * m // gcd (n, m)

if c == 1 or d == 1:
    print(0)
    exit()

if a == 1:
    div_a = 0
else:
    div_a = (a-1) // c + (a-1) // d - (a-1) // lcm(c, d)
div_b = b // c + b // d - b // lcm(c, d)

print(b - a + 1 - div_b + div_a)

Measured memory_bytes: 3064
package main

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

const (
	bufsiz = 1024 * 1024
)

func main() {
	writer := newWriter(os.Stdout)
	defer writer.Flush()

	sc := newScanner(os.Stdin)
	t := sc.scanFloat()
	x := sc.scanFloat()

	writer.println(t / x)
}

func mapContains(m map[int]int, sum int) map[int]int {
	for key, value := range m {
		if value == sum {
			delete(m, key)
		}
	}

	return m
}

// contains returns:
// if s contains e, true. / if s not contains e, false.
func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

type scanner struct {
	*bufio.Scanner
}

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &scanner{s}
}

func (s *scanner) scanStr() string {
	s.Buffer(make([]byte, bufsiz), bufsiz)
	if !s.Scan() {
		panic("scan failed")
	}
	return s.Text()
}

func (s *scanner) scanInt() int {
	if !s.Scan() {
		panic("scan failed")
	}
	i, err := strconv.Atoi(s.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func (s *scanner) scanFloat() float64 {
	if !s.Scan() {
		panic("scan failed")
	}
	i, err := strconv.ParseFloat(s.Text(), 5)
	if err != nil {
		panic(err)
	}
	return i
}

type writer struct {
	*bufio.Writer
}

func newWriter(wr io.Writer) *writer {
	w := bufio.NewWriter(wr)
	return &writer{w}
}

func (w *writer) printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(w, f, args...)
}

func (w *writer) println(args ...interface{}) (int, error) {
	return fmt.Fprintln(w, args...)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int ans = 0;
	string s;
	cin >> s;
	for(int i = 0;i < 3;i++){
		if(s[i] == '1') ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# 解説を見て                                                     
def input_to_int_list(input_str):
    return list(map(lambda x: int(x), input_str.split(' ')))


h, w, d = input_to_int_list(input())
x_ix = [0 for _ in range(h * w + 1)] 
y_ix = [0 for _ in range(h * w + 1)] 

for i in range(h):
    input_list = input_to_int_list(input())
    for j in range(w):
        v = input_list[j]
        x_ix[v] = i 
        y_ix[v] = j 

cost_list = [0 for _ in range(h * w + 1)] 
for i in range(d + 1, h * w + 1): 
    cost_list[i] = cost_list[i - d] \
                    + abs(x_ix[i] - x_ix[i - d]) \
                    + abs(y_ix[i] - y_ix[i - d]) 

q = int(input())
for i in range(q):
    input_list = input_to_int_list(input())
    l = input_list[0]
    r = input_list[1]
    print(cost_list[r] - cost_list[l])

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

using namespace std;

typedef long long ll;

ll N,A,B;
ll X[100001];
ll aida[100001];
ll ans;

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

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

  for(int i = 1; i < N; i++) aida[i] = X[i] - X[i-1];

  for(int i = 1; i < N; i++) {
    if(aida[i] * A > B) ans += B;
    else ans += aida[i] * A;
  }

  cout << ans << endl;
}
  
  
  


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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define FORR(el,vecc) for(auto& el:vecc)
#define ll long long int
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.6lf\n",a);
#define SIZE

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define N (int)(1e5+10)


using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;

/*ios_base::sync_with_stdio(false);cin.tie(0);*/
int main(){
    ll n;
    cin >>n;
    cout << (n-1) /2;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

N = X // 500
min1 = min(A, N)
i = k = 0

while(i <= min1):
    M = X - (500 * i)
    L = M // 100
    min2 = min(B, L)
    j = 0
    while(j <= min2):
        P = M - (100 * j)
        Q = P / 50
        if Q <= C:
            k += 1
        j += 1
    i += 1

print(k)


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

using namespace std;

int main() {
    int N, K, H;
    cin >> N >> K;

    char S[N];

    for (int i = 0; i < N; i++)
    {
        char t;
        cin >> t;
        S[i] = t;
    }
    
    H = 0;
    for (int i = 0; i < N; i++)
    {
        if ((i == 0 && S[i] == 'L') || (i == N - 1 && S[i] == 'R'))
        {
            continue;
        } else if (S[i] == 'L' && S[i - 1] == 'L') {
            H++;
        } else if (S[i] == 'R' && S[i + 1] == 'R') {
            H++;
        }
    }

    cout << min(N - 1, H + 2 * K);

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
const int mod = 1000000007;
const int N = 2e5+5, M = N;
//=========================================


int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    // dp[i] = TRUE if the first player wins if there are i stones remaining
    int n, k;
    cin >> n >> k;

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


    vector<bool> dp(k + 1);
    for(int stones = 0; stones <= k; ++stones){
        for(int x : a){
            if(stones >= x && !dp[stones - x])
                dp[stones] = true;
        }
    }

    puts(dp[k] ? "First" : "Second");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;
  vector <int> p(N);
  rep(i,N) cin >> p[i];

  int mx = *max_element(all(p));
  int ans = mx / 2 + (accumulate(all(p), 0) - mx) ;
  cout << ans << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

/*

*/

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

        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long K= sc.nextLong();
        long D = sc.nextLong();

        long ans = 0;
        long kaisu = Math.abs(X / D);
        if (kaisu > K) {
            ans = Math.abs(Math.abs(X) - (D * K));
        } else {
            if ((K-kaisu) %2 == 0) {
                ans = Math.abs(Math.abs(X) - (D * kaisu));
            } else {
                ans = Math.abs(Math.abs(X) - (D * (kaisu+1)));
                // ans = Math.min(Math.abs(X - (D * (kaisu+1))), Math.abs(X - (D * (kaisu+2))));
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 35600
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main(int argc, char *argv[]){
    unsigned int N;
    std::cin >> N;
    std::vector<unsigned int> B(N-1);
    for(auto &b : B){
        std::cin >> b;
    }
    unsigned int sum = B[0];
    unsigned int lastB = B[0], newB;
    for(int i=1; i<N-1; ++i){
        newB = B[i];
        sum += std::min(lastB,newB);
        lastB = newB;
    }
    sum += B[N-2];
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ans = ['']*m
mat = [list(map(int, input().split())) for _ in range(m)]
d = {}
for idx in range(m):
    p, y = mat[idx]
    y = (y, idx)
    ans[idx] += str(p).zfill(6)
    if p in d:
        d[p].append(y)
    else:
        d[p] = [y]

for v in d.values():
    v.sort(key=lambda x: x[0])
    for i, (_, idx) in enumerate(v):
        i += 1
        ans[idx] += str(i).zfill(6)

for a in ans:
    print(a)

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

  int N,M;
  cin >> N >> M;
  int K[M];
  V<int> S[M];
  REP(i,M) {
    cin >> K[i];
    REP(j,K[i]) {
      int s;
      cin >> s;
      S[i].push_back(s);
    }
  }
  int P[M];
  REP(i,M) cin >> P[i];

  int max = 1;
  REP(i,N) max *= 2;
  int ans = 0;

  REP(n,max) {
    int s[N];
    int x = n;
    REP(i,N) {
      s[i] = x & 1;
      x >>= 1;
    }
    auto isOK = [&](int* s) {
      REP(i,M) {
        int sum = 0;
        REP(j,K[i]) sum += s[S[i][j]-1];
        if (sum % 2 != P[i]) return false;
      }
      return true;
    };
    if (isOK(s)) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	vector<long long>dp;
	vector<vector<long long> >a;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	a.resize(n,vector<long long>(n));
	dp.resize(1<<n);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	for(int i=1;i<1<<n;i++)
		for(int j=0;j<n-1;j++)
			if(1<<j&i)
				for(int k=j+1;k<n;k++)
					if(1<<k&i)
						dp[i]+=a[j][k];
	for(int i=1;i<1<<n;i++)
		for(int j=(i-1)&i;j;j=(j-1)&i)
			dp[i]=max(dp[i],dp[j]+dp[i^j]);
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
    int n;
    cin >> n;
    vector<int>a(n);
    int i, j,k;
    int cnt = 0;
    for (i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    for (i = 0; i < n - 2; i++)
    {
        for (j = i+1; j < n-1; j++)
        {
            for (k = j + 1; k < n; k++)
            {
                if (a.at(i) != a.at(j) && a.at(j) != a.at(k) && a.at(k) != a.at(i))
                {
                    if (a.at(i) + a.at(j) > a.at(k))
                    {
                        //cout << i+1 << " " << j+1 << " " << k+1 << endl;
                        cnt++;
                    }
                }
            }
        }
    }
    cout << cnt << endl;
    
}

Measured memory_bytes: 3632
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<stdio.h>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	
	bool flag = true;

	int time = 0, cnt = 0;
	rep(i,100){
		if(time <= c && c <= time + a){
			cout << 60*cnt + c << endl;
			flag = false;
			break;
		}
		time += a + b;
		if(time > 60){
			cnt++, time -= 60;
		}
	}
	if(flag)cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 1160
//Author : Vipul Sharma
 
// LIBRARIES

#include<iostream>
#include<set>
#include<algorithm>
#include<map>
#include <bits/stdc++.h>
 
// MACROS
#define ll long long int
#define ld long double
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i,b,a) for(ll i=b-1;i>=a;i--)
#define eqrep(i,b) for(ll i=1;i<=b;i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ld long double
#define pb push_back
#define eb emplace_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
using namespace std;
long long cost = 1e18;
 
 
 
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	booster;
	char c;
	cin>>c;
	if(c>='a' and c<='z') cout<<"a"<<endl;
	else if(c>='A' and c<='Z') cout<<"A"<<endl;
	return 0;
}

Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int ans=0;
		int a=scan.nextInt();
		List<Integer> foo = new ArrayList<Integer>();
		foo.add(a);
		for(int i=1;i!=1000000;i++) {
			if(a%2==0) {
				if(foo.indexOf(a/2)!=-1) {
				ans=i;
				break;
		        }
				a=a/2;
			}
				else {
					if(foo.indexOf(a*3+1)!=-1) {
						ans=i;
						break;
			        }
					a=a*3+1;
				}
			foo.add(a);
			}
		System.out.println(ans+1);
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
    int n=in,p[n];
    forin(p,n);
    int ans=0,l=n;
    for (int i=0;l!=0;i++){
        if (p[i]<=l) {
            ans++;
            l=p[i]-1;
        }
    }
    out(ans);
}

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

int main(){
  int N,b,c;
  c=0;
  cin>>N;
  b=N;
  for (int i=0;i<8;i++){
    c +=b%10;
    b =int(b/10);
  }
  if(N%c==0){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    int adda, addb, sum;
    int minp = INT_MAX;
    for (int i = 0; i <= 100000; i++){
        minp = min(i * 2 * c + max(0,x-i) * a + max(0,y-i) * b, minp);
    }

    cout << minp << endl;



}


Measured memory_bytes: 256
//2019.7.27 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define eps 1e-10
#define RG register
#define db double
#define lb long db
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
#define Pi 2.0*acos(-1.0)
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline int read() {
//    res s=0,ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
inline int read() {
    res s=0,ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG __int128 x){
//    if(x>10)write(x/10);
//    putchar(x%10+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=1e7+10;
namespace MAIN{
    char S[N],T[N];
    int n,m;
    int F[N],G[N];
    inline void MAIN(){
        scanf("%s",S+1),scanf("%s",T+1),n=int(strlen(S+1)),m=int(strlen(T+1));
        while(n<(m<<1)){
            for(res i=1;i<=n;i++)S[i+n]=S[i];
            n<<=1;
        }
        for(res i=1;i<=n;i++)S[i+n]=S[i];
        n<<=1,F[0]=-1;
        for(res i=1;i<=m;i++){
            res j=i-1;
            while(j&&T[F[j]+1]!=T[i])j=F[j];
            F[i]=F[j]+1;
        }
        res j=0,ans=0;
        for(res i=1;i<=n;i++){
            while(j>=0&&S[i]!=T[j+1])j=F[j];
            if(++j==m)G[i]=G[i-m]+1,ans=max(ans,G[i]);
        }
        printf("%d\n",ans>=n/m-1?-1:ans);
    }
}
int main(){
//    freopen("compound1.in","r",stdin);
//    freopen("compound.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 27008
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)
typedef long long ll;

int main(){
	ll A, B, V, W, T;
	cin >> A >> V >> B >> W >> T;

	if (B < A){
		if (A - T * V <= B - T * W) cout << "YES" << endl;
		else cout << "NO" << endl;
	} 
	else{
		if (V * T + A >= W * T + B) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n+1);
  rep(i,n+1) cin >> a.at(i);
  
  vector<int> b(n);
  rep(i,n) cin >> b.at(i);
  
  long ans = 0;
  
  rep(i,n){
    int v;
    v = min(a.at(i),b.at(i));
    ans += v;
    a.at(i) -= v;
    b.at(i) -= v;
    
    v = min(a.at(i+1),b.at(i));
    ans += v;
    a.at(i+1) -= v;
    b.at(i) -= v;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define endl "\n"
#define count_ones __builtin_popcountl
#define piii pair<int,pair<int,int>>
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
/* -------------------------------------- */
int main() {
	boost();
	ll t;cin>>t;
	map<string,ll> m;
	while(t--){
		string a;cin>>a;
		sort(a.begin(), a.end());
		m[a]++;
	}
	ll sum=0;
	for(auto it=m.begin();it!=m.end();it++){
		ll fr= it->second;
		if(fr > 1){
			sum += (fr*(fr-1))/2;
		}
	}
	cout<<sum;
}

Measured memory_bytes: 11264
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include <utility>      // std::swap
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 200000000000;


    ll W,H,N,M;
    ll sum;
    ll ans=0;
    ll sm,lr;
    ll A;
    deque<ll> s;
    bool f=false;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A;
        //DEB(N)END
        if (i==0||(N-i)%2==1)s.push_front(A);
        else s.push_back(A);

    }



    REP(i,s.size()){
        cout<<s[i];
        if(i!=(signed)s.size()-1)cout<<" ";
    }
    //cout<<ans;
    return 0;
}


Measured memory_bytes: 3840
import scala.util.control.Breaks

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.nextLine
  val b = Breaks

  val sRev = s.reverse
  val targets = List("dream".reverse, "dreamer".reverse, "erase".reverse, "eraser".reverse)

  var i = 0
  var flg = true
  b.breakable{
    while(i < sRev.length){
      var isMatch = false
      for(target <- targets) {
        if(i + target.length <= sRev.length && sRev.substring(i, i + target.length) == target){
          isMatch = true
          i += target.length
        }
      }
      if(!isMatch) {
        flg = false
        b.break
      }
    }
  }

  if(flg) {
    println("YES")
  }else{
    println("NO")
  }
}


Measured memory_bytes: 33472
h,w = map(int, input().split())
grid = []
ddxy = [[0,1],[1,0],[0,-1],[-1,0],[1,1],[1,-1],[-1,1],[-1,-1]]
ans=[[0]*w for _ in range(h)]

def ok(x, y):
    if x>-1 and y>-1 and x<w and y<h and ans[y][x]!=-1:
        return 1
    else:
        return 0
for i in range(h):
    s = list(input().strip())
    grid.append(s)
for i in range(h):
    for j in range(w):
        if grid[i][j]=="#":
            ans[i][j]=-1
            for dxdy in ddxy:
                if ok(j+dxdy[1],i+dxdy[0]):
                    ans[i+dxdy[0]][j+dxdy[1]]+=1
for i in range(h):
    for j in range(w):
        if(ans[i][j])==-1:
            print("#", end="")
        else:
            print(ans[i][j], end="")
    print()


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

int main(){
  int s,k,ans=0;
  cin >> k >> s;
  
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
  		int z = s - (x + y);
        if((z <= k) && (z >= 0))
          ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#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<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
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 pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve(){
	int a, b; cin >> a >> b;
	if (b%a == 0)cout << a + b << endl;
	else cout << b - a << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
/* Author haleyk10198 */
/* 作者:  haleyk10198 */
/* CF handle: haleyk100198*/
/* FOR ACM-ICPC WF*/
#include <bits/stdc++.h>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define vi vector<int>
#define vvi vector<vi>
#define EPS 1e-9

using namespace std;

ll x, l, r;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	
	l = 0, r = 31700;
	cin >> x;
	while(l+1 < r){
		ll mid = (l+r)/2;
		if(mid*mid > x)
			r = mid;
		else
			l = mid;
	}
	cout << l*l << endl;
	return 0;
}


Measured memory_bytes: 764
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int n = sc.nextInt();
        int m = sc.nextInt();

        // 処理
        String out = n == m ? "Yes" : "No";

        // 出力
        System.out.println(out);
    }
}

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

using ULL = unsigned long long;

void solve(){
  string s; cin >> s;
  int n = s.size(); s.push_back('R');
  int L = 0;
  int rL = 0;
  int R = 0;
  int ans[100000]={};
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'L'){
      if(R!=0 && L == 0){
        rL= i;
      }
      L++;
    }
    else{
      if(L!=0){
        ans[rL] = R/2+ (L - L/2);
        ans[rL-1] = L/2+ (R - R/2);
        L = R = rL = 0;
      }
      R++;
    }
  }
  for(int i = 0; i < n; i++){
    if(i != 0) cout << " ";
    cout << ans[i];
  }cout << endl;
}
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int main(void){
  int n,i,j;
  char s[100][11];
  scanf("%d",&n);
  scanf("%s",s[0]);
  for(i=1;i<n;i++){
    scanf("%s",s[i]);
    int l=strlen(s[i-1]);
    for(j=0;j<i;j++){
      if(strcmp(s[i],s[j])==0) {printf("No");return 0;}
    }
    if(s[i-1][l-1]!=s[i][0]) {printf("No");return 0;}
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

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

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}


int A[N];

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	int n;
	scanf("%d",&n);
	REP(i,n) scanf("%d",&A[i+1]);
	ll ans = 1,cnt = 1;
	int pos = 1;
	REPP(i,2,n+1){
		if(A[i]==pos+1){
			ans  = ans*(cnt+1)%mod;
			// cnt++;
		}else{
			pos+=2; cnt++;
		}
	}
	while(cnt){
		ans = ans*cnt%mod;
		cnt--;
	}
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vector<pll> a;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        ll aa;
        cin >> aa;
        sum += aa;
        a.emplace_back(aa, i);
    }
    sort(a.begin(), a.end());
    vector<ll> ret(n, 0);
    ll minidx = a[n - 1].second;
    ll cnt    = 1;
    ll lasta  = a[n - 1].first;
    for (int i = n - 2; i >= 0; --i) {
        assert(a[i].first <= a[i + 1].first);
        if (a[i].first < a[i + 1].first) {
            ret[minidx] += cnt * (a[i + 1].first - a[i].first);
        }
        cnt++;
        chmin(minidx, a[i].second);

    }
    ret[minidx] += cnt * a[0].first;
    ll tot = 0;
    for (auto &r : ret) {
        cout << r << "\n";
        tot += r;
    }
    assert(tot == sum);
    return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> l(n);
    int sum = 0;
    int mx = 0;
    rep(i, n){
        cin >> l[i];
        sum += l[i];
        mx = max(mx, l[i]);
    }

    Judge(mx < sum-mx);



    return 0;
}


Measured memory_bytes: 256