akhauriyash/Code-Regression huggingface dataset:
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    break;
    $a = explode(" ",$l);
    $key->A[] = $a[0];
  }
}
printf("%d\n",count(array_unique($key->A)));


Measured memory_bytes: 3704
/*
   وَعَلَى اللَّهِ فَلْيَتَوَكَّلِ الْمُؤْمِنُونَ
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int mod = 1e9 + 7 ;

ll binpow(ll a, ll b){
   ll res = 1 ;
   while(b > 0){
       if(b & 1) res = (res % mod) * (a % mod), res %= mod ;
       a = (a % mod) * (a % mod) ;
       a %= mod ;
       b >>= 1 ;
   }
   return res ;
}

ll divide(ll a, int b){
    return ((a % mod) * binpow(b, mod - 2) % mod) % mod;
}

ll nCr(ll n, ll k)
{
    ll res = 1;

    // Since C(n, k) = C(n, n-k)
    if ( k > n - k )
        k = n - k;

    // Calculate value of
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (int i = 0; i < k; ++i)
    {
        res = ((res % mod) * ((n - i) % mod)) % mod;
        res = divide(res, i + 1);
    }

    return res;
}

int main()
{
   //  freopen("in.txt", "r", stdin) ;
   ios :: sync_with_stdio(0) ;
   cin.tie(0) ;
   cout.tie(0) ;

   ll n, a, b ;
   cin >> n >> a >> b ;
   ll tot = binpow(2, n) ;
   ll f = nCr(n, a) ;
   ll s = nCr(n, b) ;
   ll ans = ((f % mod)  + (s % mod)) % mod ;
   ans = ((ans % mod) + 1) % mod ;
   ll fin = ((tot - ans) % mod + mod) % mod ;
   cout << fin;
}
//
//994457068
//34076506


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(void)
{
	int i,j,k,l,n,d,m=0,ans=0;
	cin>>n>>d;
	int x[n][d];
	for(i=0;i<n;i++) for(j=0;j<d;j++) cin>>x[i][j];
	for(i=0;i<n;i++){
		for(j=i;j<n;j++){
			m=0;
			for(k=0;k<d;k++) m=m+(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			for(l=1;l<=160;l++){
				if(l*l==m) ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int N,A,B; cin>>N>>A>>B;
  int P=A*(N-1)+B,Q=B*(N-1)+A;
  int ans=max(0ll,Q-P+1);
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
n = int(input())
a_l =[int(i) for i in input().split()]

minus = sum(x < 0 for x in a_l)

if minus%2==0:
    print(sum(abs(x) for x in a_l))
else:
    print(sum(abs(x) for x in a_l)-2*min(abs(x) for x in a_l))


Measured memory_bytes: 14252
#include<stdio.h>
 
struct dice
{
    int n[6] ;
};
struct dice dice1 ;
 
 
int east()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[3] ;
    dice1.n[3] = dice1.n[5] ;
    dice1.n[5] = dice1.n[2] ;
    dice1.n[2] = mem ;
}
 
int west()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[2] ;
    dice1.n[2] = dice1.n[5] ;
    dice1.n[5] = dice1.n[3] ;
    dice1.n[3] = mem ;
}
 
int south()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[4] ;
    dice1.n[4] = dice1.n[5] ;
    dice1.n[5] = dice1.n[1] ;
    dice1.n[1] = mem ;
}
 
int north()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[1] ;
    dice1.n[1] = dice1.n[5] ;
    dice1.n[5] = dice1.n[4] ;
    dice1.n[4] = mem ;
}
 
int main()
{
    int i=0 ;
    int cmp=0 ;
 
    char a[101] = {0} ;
 
    for (i=0 ;i < 6 ;i++)
    {
        scanf("%d" ,&cmp) ;
 
        dice1.n[i] = cmp ;
 
    }
    scanf("%s" ,a) ;
 
    for (i=0 ;i < 101 ;i++)
    {
        if (a[i] == '\0') break ;
 
        if (a[i] == 'E') east() ;
        if (a[i] == 'W') west() ;
        if (a[i] == 'S') south() ;
        if (a[i] == 'N') north() ;
 
    }
 
    printf ("%d\n" ,dice1.n[0]) ;
    return 0 ;
}


Measured memory_bytes: 2092
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

bool colors[8] = { false };
int strong = 0;

int main()
{
	int N, a;
	int cmin = 0, cmax;

	cin >> N;

	rep(i, N) {
		cin >> a;

		if (a <= 399) colors[0] = true;
		else if (a <= 799) colors[1] = true;
		else if (a <= 1199) colors[2] = true;
		else if (a <= 1599) colors[3] = true;
		else if (a <= 1999) colors[4] = true;
		else if (a <= 2399) colors[5] = true;
		else if (a <= 2799) colors[6] = true;
		else if (a <= 3199) colors[7] = true;
		else strong++;
	}

	rep(i, 8) {
		if (colors[i]) cmin++;
	}

	cmax = cmin + strong;

	cout << max(1, cmin) << ' ' << cmax << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    ll ac = 0;
    ll pe = 0;

    vector<ll> wa(n,0), isac(n,0);
    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        --p;
        if(s == "AC"){
            if(!isac[p]){
                ++ac;
                pe += wa[p];
                isac[p] = true;
            }
        }
        else wa[p]++;
    }

    cout << ac << " " << pe << endl;


    return 0;
    
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+N)

int main(void)
{
	string test;
	cin >> test;
	int a, b,i = 0;
	for (i; i < test.size(); i++) {
		if (test[i] == 'A') {
			a = i;
			break;
		}
	}
	for (i = test.size(); i != 0; i--){
		if (test[i] == 'Z') {
			b = i;
			break;
		}
	}
	cout << b - a + 1 << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
n, m, x = map(int, input().split())
c = [0] * n
a = [[0] * m for _ in range(n)]
for i in range(n):
    c[i], *t = list(map(int, input().split()))
    a[i] = t
ans = 10 ** 9
for b in range(1 << n):
    s = 0
    li = [0] * m
    for i in range(n):
        if ~b >> i & 1:
            continue
        s += c[i]
        for j in range(m):
            li[j] += a[i][j]
    if any(y < x for y in li):
        continue
    ans = min(ans, s)
print(ans if ans < 10 ** 9 else -1)


Measured memory_bytes: 9220
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int a, b;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		while(read()){
			slove();
		}
	}
	static boolean read(){
		if(!sc.hasNext())
			return false;
		a = sc.nextInt(); b = sc.nextInt();
		
		return true;
	}
	static void slove(){
		int ans = Integer.toString(a+b).length();
		System.out.println(ans);
	}
}

Measured memory_bytes: 12000
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  string S, T;
  sc.scan(S, T);

  foreach (i; 0 .. S.length) {
    if (S == T) {
      writeln("Yes");
      return;
    }
    S ~= S.front;
    S.popFront;
  }

  writeln("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	vector<vector<int>> c(10,vector<int>(10));
	vector<vector<int>> a(h,vector<int>(w));
	rep(i,10)rep(j,10) cin>>c[i][j];
	rep(i,h)rep(j,w) cin>>a[i][j];
	vector<int> mi(10,INF);
	rep(i,10){
		vector<int> per;
		rep(j,10){
			if(j==1) continue;
			per.push_back(j);
		}
		do{
			vector<int> now(per);
			now.push_back(1);
			int pre=i;
			int cnt=0;
			rep(j,now.size()-1){
				if(now[j]==pre){
					cnt+=c[pre][now[j+1]];
					pre=now[j+1];
				}
			}
			chmin(mi[i],cnt);
		}while(next_permutation(begin(per),end(per)));
	}
	int ans=0;
	rep(i,h)rep(j,w){
		if(a[i][j]==-1||a[i][j]==1) continue;
		ans+=mi[a[i][j]];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 472
n, k = (int(i) for i in input().split())
h = [int(input()) for i in range(n)]

h.sort()
a = []
for i in range(n-k+1):
    mmax = h[i+k-1]
    mmin = h[i]
    a.append(mmax - mmin)
print(min(a))

Measured memory_bytes: 11288
var
  s:string;
  ch:char;
  i:longint;
  a:array['a'..'z'] of longint;
begin
  readln(s);
  for i:=1 to length(s) do inc(a[s[i]]);
  for ch:='a' to 'z' do if a[ch]>1 then begin writeln('no');exit;end;
  writeln('yes');
end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int N,i;
	cin >> N >> i;
	cout << N-i+1 << endl;
}

Measured memory_bytes: 256
def main():
    _, T = map(int, input().split())
    t = [int(s) for s in input().split()]

    print(solve(t, T))

def solve(t, T):
    s = 0
    for ti, tj in zip(t, t[1:]):
        s += min(T, tj - ti)
    
    s += T
    return s

main()


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

int main(){
  int a,b;
  cin>>a>>b;
  vector<string>s(a);
  for(int i=0;i<a;i++){
      cin>>s.at(i);
  }
  vector<vector<int>>count(a+2,vector<int>(b+2));
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      if(s.at(i).at(j)=='#'){
        for(int n=0;n<3;n++){
          for(int m=0;m<3;m++){
            count.at(i+n).at(j+m)+=1;
            count.at(i+1).at(j+1)+=9;
          }
        }
      }
    }
  }
  for(int i=1;i<a+1;i++){
    for(int j=1;j<b+1;j++){
      if(j==b){
        if(count.at(i).at(j)>8)
          cout<<'#'<<endl;
        else
          cout<<count.at(i).at(j)<<endl;
      }
      else{
        if(count.at(i).at(j)>8)
          cout<<'#';
        else
          cout<<count.at(i).at(j);
      }
    }
  }
}

Measured memory_bytes: 256
H, W = [int(i) for i in input().split()]
S = [[s for s in input()] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            cnt = 0
            for _i in range(max(0, i - 1), min(H, i + 2)):
                for _j in range(max(0, j - 1), min(W, j + 2)):
                    if S[_i][_j] == '#':
                        cnt += 1
            S[i][j] = str(cnt)
print('\n'.join([''.join(s) for s in S]))


Measured memory_bytes: 9168
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	string a = "YAKI", b;
	cin >> b;
	REP(i, 4) {
		if (a[i] != b[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

int main() {
  int64_t N;
  cin >> N;
  vector<char> ans;
  while(N>0){
    int a=N%26;
    if(a==0){
      ans.push_back('z');
      N=(N-26)/26;
    }
    else{
      ans.push_back(char(N%26+96));
      N=N/26;
    }
  }
  reverse(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++){
    cout << ans.at(i);
  }
}

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

int main(){
  int l,r,d;cin>>l>>r>>d;
  int sum=0;
  for(int i=l;i<=r;i++){
    if(i%d==0)sum++;
  }
  cout<<sum;
}

Measured memory_bytes: 3668
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{

    int n;

    cin >> n;
    if (n <= 9) {
        cout << n << endl;
    }
    else if (n <= 99) {
        cout << 9 << endl;
    }
    else if (n <= 999) {
        cout << 9 + (n - 99) << endl;
    }
    else if (n <= 9999) {
        cout << 909 << endl;
    }
    else if (n <= 99999) {
        cout << 909 + (n - 9999) << endl;
    }
    else {
        cout << 90909 << endl;
    }
    return 0;
}



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

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

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

int main() {
  ll X;
  std::cin >> X;

  ll ans = X / 500 * 1000;
  X %= 500;
  ans += X / 5 * 5;
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
from math import factorial,sqrt,ceil#,gcd
import numpy as np

N = int(input())
lisA = list(map(int,input().split()))
arrA = np.array(lisA)

mean = np.mean(arrA)

targetnum = round(mean)

arrans = (arrA - targetnum)**2
ans = sum(arrans)

print(int(ans))

Measured memory_bytes: 12504
#include <iostream>

using int64 = long long;

int main()
{
    int64 N;
    std::cin >> N;

    if (N % 2 == 1) {
        std::cout << 0 << std::endl;
    }
    else {
        int64 res = 0, x = 5;
        while (N >= x) {
            res += N / x / 2;
            x *= 5;
        }
        std::cout << res << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())

ans = [['.']*100 for _ in range(50)] + [['#']*100 for _ in range(50)]

if b != 1:
    B = 0
    for i in range(49):
        for j in range(100):
            flag = True
            for di, dj in (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1):
                ni, nj = i+di, j+dj
                if 0 <= ni < 50 and 0 <= nj < 100:
                    if ans[ni][nj] == '#':
                        flag = False
                        break
            if flag:
                ans[i][j] = '#'
                B += 1
            if B == b-1:
                break
        else:
            continue
        break

if a != 1:
    A = 0
    for i in range(51, 100):
        for j in range(100):
            flag = True
            for di, dj in (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1):
                ni, nj = i+di, j+dj
                if 50 <= ni < 100 and 0 <= nj < 100:
                    if ans[ni][nj] == '.':
                        flag = False
                        break
            if flag:
                ans[i][j] = '.'
                A += 1
            if A == a-1:
                break
        else:
            continue
        break

print(100, 100)
for i in range(100):
    print(''.join(ans[i]))


Measured memory_bytes: 73252
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
using namespace std;
const int N=2e5+5;
char a[N];
ll pow1[N];
int pre[N];
int bla[N];
int ans[N];
int n;
int get(int x)
{
    int ans=0;
    while(x)
    {
        x=x%__builtin_popcount(x);
        ans++;
    }
    return ans;
}
void slove(int x,int sum)
{
    if(sum<=0)
    return ;
    pow1[0]=1;
    for(int i=1;i<N;i++)
        pow1[i]=pow1[i-1]*2%sum;
    for(int i=1;i<=n;i++)
    {
        if(a[i]=='1')
        {
            pre[i]=(pre[i-1]+pow1[i-1])%sum;
        }
        else
        {
            pre[i]=pre[i-1]%sum;
        }
    }
    for(int i=n;i>=1;i--)
    {
        if(a[i]=='1')
        {
            bla[i]=(bla[i+1]+pow1[i-1])%sum;
        }
        else
        {
            bla[i]=bla[i+1]%sum;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(x==1&&a[i]=='1')
        {
            int res=(pre[i-1]+bla[i+1])%sum;
            ans[i]=1+get(res);
        }
        else if(x==0&&a[i]=='0')
        {
            int res=(pre[i-1]+bla[i+1]+pow1[i-1])%sum;
            ans[i]=1+get(res);
        }
    }
}
int main()
{
    
    cin>>n;
    scanf("%s",a+1);
    reverse(a+1,a+1+n);
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]=='1')
        {
            sum++;
        }
    }
    slove(1,sum-1);
    slove(0,sum+1);
    reverse(ans+1,ans+1+n);
    for(int i=1;i<=n;i++)
    {
        printf("%d\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 7872
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	String s = sc.next();
	boolean f1 = false;
	boolean f2 = false;
	boolean fx = false;
	for(int i = 0; i < a; i++) {
		for(int j = 0; j <= 9; j++) {
			if(Character.getNumericValue(s.charAt(i)) == j) {
				f1 = true;
				break;
			} 
		}
	}
	if(s.charAt(a) == '-') {
		fx = true;
	}
	for(int i = a + 1; i < a + b + 1; i++) {
		for(int j = 0; j <= 9; j++) {
			if(Character.getNumericValue(s.charAt(i)) == j) {
				f2 = true;
				break;
			} 
		}
	}
	if(f1 == true && f2 == true && fx == true) {
		System.out.println("Yes");
	} else {
		System.out.println("No");
	}
}
}

Measured memory_bytes: 21844
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 2e5 + 1;
ll parent[N], sizer[N];
ll findset(ll a) {
    if (a == parent[a]) {
        return a;
    }
    parent[a] = findset(parent[a]);
    return parent[a];
}

void unionset(ll a, ll b) {
    a = findset(a);
    b = findset(b);
    if(a == b){
        return;
    }
    if (sizer[a] < sizer[b]) {
        swap(a, b);
    }
    sizer[a] += sizer[b];
    parent[b] = a;
} 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n, m;
        cin >> n >> m;
        for(i = 1; i <= n; i++){
            parent[i] = i;
            sizer[i] = 1;
        }
        for(i = 0; i < m; i++){
            ll a, b;
            cin >> a >> b;
            unionset(a, b);
        }
        ll ans = -INF;
        for(i = 1; i <= n;i++){
            ans = max(ans , sizer[i]);
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 6780
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int n,m;
    cin>>n>>m;

    vii v(n);
    fo(i,n){
        cin>>v[i].ff>>v[i].ss;
    }
    sort(all(v));
    int cost = 0;
    for(int i = 0;i<n;i++){
        if(m==0) break;
        else if(m>v[i].ss){
            cost += v[i].ff*v[i].ss;
            m -= v[i].ss;
        }
        else{
            cost += v[i].ff*m;
            m = 0;
        }
    }
    cout<<cost;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 4808
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans=s.length();
		int an=0;
		for(int i = 0; i<s.length()-1; i++){
			if(s.charAt(i)!=s.charAt(i+1)){
				an=Math.max(i+1,s.length()-i-1);
				ans=Math.min(ans,an);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 24484
#include<iostream>
#include<string>
using namespace std;
int X, Y, H, W, N, DIR; string S;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int main() {
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) { break; }
		X = 1; Y = 1; DIR = 0;
		while (true) {
			cin >> S;
			if (S == "STOP") {
				cout << Y << ' ' << X << endl;
				break;
			}
			if (S == "LEFT") { DIR = (DIR + 3) % 4; }
			if (S == "RIGHT") { DIR = (DIR + 1) % 4; }
			if (S == "FORWARD") {
				cin >> N; X += dx[DIR] * N; Y += dy[DIR] * N;
				if (X > W) { X = W; }
				if (X < 1) { X = 1; }
				if (Y > H) { Y = H; }
				if (Y < 1) { Y = 1; }
			}
			if (S == "BACKWARD") {
				cin >> N; X -= dx[DIR] * N; Y -= dy[DIR] * N;
				if (X < 1) { X = 1; }
				if (X > W) { X = W; }
				if (Y < 1) { Y = 1; }
				if (Y > H) { Y = H; }
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include<functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/

//bool checkTousa(int arr[], int len)
bool checkTousa(vector<int> arr)
{
	bool ret = true;
	
	for (int i=0; i<arr.size()-2; i++)
	{
		if (arr[i+2] - arr[i+1] != arr[i+1] - arr[i])
		{
			ret = false;
		}
	}
	
	return ret;
}

int main()
{
	int n;
	
	while (cin >> n, n)
	{
		int h[n + 1];
		REP(n + 1) cin >> h[i];
		rep(i, n + 1)
		{
			vector<int> tempArr;
			rep(j, n + 1)
			{
				if (i != j)
				{
					tempArr.push_back(h[j]);
				}
			}
			if (checkTousa(tempArr))
			{
				cout << h[i] << endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=200010;
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int n,m,a[Maxn],b[Maxn];
char s[Maxn],s1[3],s2[3];
int g(int x)
{
	int p=x;
	for(int i=1;i<=m;i++)
	{
		if(a[i]==s[p]-'A')p+=b[i];
		if(p==0||p==n+1)return p;
	}
	return p;
}
int main()
{
	n=read(),m=read();
	scanf("%s",s+1);
	for(int i=1;i<=m;i++)
	{
		scanf("%s%s",s1,s2);
		a[i]=s1[0]-'A';b[i]=((s2[0]=='L')?-1:1);
	}
	int ans=n;
	int l=1,r=n;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(g(mid)==0)l=mid+1;
		else r=mid-1;
	}
	ans-=(l-1);//printf("%d\n",l-1);
	l=1,r=n;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(g(mid)==n+1)r=mid-1;
		else l=mid+1;
	}
	ans-=(n-r);//printf("%d",r+1);
	printf("%d",ans);
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define rep(i,l,p) for(int i = l; i<=p; i++)
#define drep(i,p,l) for(int i = p; i>=l; i++)
using namespace std;

int n;
struct node
{
	int val;
	node *front,*after;
	node(){
		front = NULL;
		after = NULL;
		val = -1;
	}

	node(node* inifront, int inival,node* iniafter){
		val = inival;
		after = iniafter;
		front = inifront;
	}
};

node* first = new node();
node* last = new node();


void lastPlus(int val){
	node *tmp = last->front;
	last->front = new node(last->front,val,last);
	if(tmp != NULL) tmp->after = last->front;
}

void firstPlus(int val){
	node *tmp = first->after;
	first->after = new node(first,val,first->after);

	if(tmp != NULL)tmp->front = first->after;
}
void conbine(){
	node* tmp1 = first;
	while(tmp1->after != NULL){
		tmp1 = tmp1->after;
	//	printf("%d ", tmp1->val);
	}
	//printf("\n");
	
	node* tmp2 = last;
	while(tmp2->front != NULL){
		tmp2 = tmp2->front;
	//	printf("%d ",tmp2->val);
	}
	//printf("\n");

	tmp1->after = tmp2;
	tmp2->front = tmp1;
	//printf("conbine:\n");

//	tmp1 = first;
	// rep(i,1,n){ 
	// 	printf("%d ",tmp1->val);
	// 	tmp1 = tmp1->after;
		
//	}
}
void outputfirst(){
	node* tmp;

	tmp = first->after;
	rep(i,1,n){
		printf("%d ",tmp->val);
		tmp = tmp->after;
	}
}
void outputlast(){
	node *tmp = last->front;
	rep(i,1,n){
		printf("%d ",tmp->val);
		tmp = tmp->front;
	}
}
int main(){
	scanf("%d",&n);
	int t;
	rep(i,1,n){
		scanf("%d",&t);
		if( i % 2 == 1){
			lastPlus(t);
		}else firstPlus(t);
	}
	conbine();
	t = (n+1) % 2 ;
	if ( t == 1){
		outputfirst();
	}else {
		outputlast();
	}

	 return 0;

}

Measured memory_bytes: 8448
import java.util.Scanner;

/**
 * スタック
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=ja">ALDS1_3_A</a>
 */
public class Main {

	private static int top = 0;
	private static int s[] = new int[1000];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input[] = new String[1000];
		input = sc.nextLine().split(" ");

		for (int i = 0; i < input.length; i++) {
			int a, b;
			if ("+".equals(input[i])) {
				a = pop();
				b = pop();
				push(a + b);
			} else if ("-".equals(input[i])) {
				a = pop();
				b = pop();
				push(b - a);
			} else if ("*".equals(input[i])) {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.valueOf(input[i]));
			}
		}

		System.out.println(pop());

		sc.close();
	}

	private static void push(int x) {
		s[++top] = x;
	}

	private static int pop() {
		top--;
		return s[top+1];
	}

}



Measured memory_bytes: 26136
import bisect


def searchPrimeNum(N):
    max = int(N**(1/2))
    seachList = [i for i in range(2, N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


list1 = searchPrimeNum(100000)
list2 = list(map(lambda x: 2 * x - 1, list1))
li = list(set(list1) & set(list2))
li.sort()
for i in range(int(input())):
    l, r = map(int, input().split())
    print(bisect.bisect_right(li, r) - bisect.bisect_left(li, l))

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N;
  cin >> N;

  int A[N]={};
  rep(i,N){
    int aa;
    cin >> aa;
    A[aa]++;
  }

  if(N%2==0){
    rep(i,N){
      if(i%2==1){
        A[i]-=2;
      }
    }
  }
  else{
    rep(i,N){
      if(i%2==0){
        A[i]-=2;
      }
    }
    A[0]+=1;
  }

  rep(i,N){
    if(A[i]!=0){
      cout << 0 <<"\n";
      return;
    }
  }

  ll ans=1;

  rep(i,N/2){
    ans=ans*2%MOD;
  }
  cout << ans <<"\n";
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#define rep(i,k,n)for(ll i=k;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int gcd(ll a, ll b) {

	if (b == 0) {

		return a;
	}
	else {
		a = a%b;
		gcd(b, a);
	}
}
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
vector<double> tmp(5);
//void func(vector<double>a, int b) {
//	tmp = a;
//	if()
//}
int main() {
	double N;
	vector<double>A(5);
	ll save=0;
	int save2=0;
	ll ans = 4;
	cin >> N >> A[0] >> A[1]>> A[2] >> A[3] >> A[4];
	
	tmp = A;
	sort(A.begin(), A.end());
	ans += ceil(N / A[0]);
	cout << ans;

}

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

int main(){
int N, T, s=0, S=0; cin >> N >> T;
int t[N]; cin >> t[0];
for(int i=1; i<N; i++){
  cin >> t[i]; s=t[i]-(t[i-1]+T);
  if(s>0){ S+=s; }
}
cout << t[N-1]+T-S << "\n";
}

Measured memory_bytes: 1024
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,w = get_nums_l()
ppp = list(map(lambda s: tuple(map(int,s.strip().split())), sys.stdin.readlines()))

# dp[i] = 重さiで得られる最大の価値
dp = [0] * (w+1)

for p in ppp:
    we = p[0]
    va = p[1]
    for i in reversed(range(len(dp))):
        if i+we > w:
            continue
        ne = i+we
        dp[ne] = max(dp[ne], dp[i]+va)

# log(dp)

print(max(dp))

Measured memory_bytes: 42476
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

//宣言忘れない！！
int main() {
  ll k; cin >> k;
  ll a, b; cin >> a >> b;

  bool f = false;
  Rep(i, a, b){
    if(i%k == 0) f = true;
  }

  if(f) cout << "OK" << endl;
  else cout << "NG" << endl;

  return 0;
}


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

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

typedef long long ll;
typedef pair<int,int> P;
const ll mod=1e9+7;

ll N;
ll A[100005],B[100005];
ll a[100005],b[100005];
ll ans1,ans2;

int main(){

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

cin>>N;

rep(i,N+1){
	cin>>A[i];
	a[i]=A[i];
}
rep(i,N){
	cin>>B[i];
	b[i]=B[i];
}
reverse(a,a+N+1);
reverse(b,b+N);

rep(i,N){
	if(B[i]>=A[i]){
		ans1+=A[i];
		B[i]-=A[i];
	}
	else{
		ans1+=B[i];
		B[i]=0;
	}
	if(B[i]>=A[i+1]){
		ans1+=A[i+1];
		A[i+1]=0;
		B[i]-=A[i+1];
	}
	else{
		ans1+=B[i];
		A[i+1]-=B[i];
		B[i]=0;
	}
	//reverse
	if(b[i]>=a[i]){
		ans2+=a[i];
		b[i]-=a[i];
	}
	else{
		ans2+=b[i];
		b[i]=0;
	}
	if(b[i]>=a[i+1]){
		ans2+=a[i+1];
		a[i+1]=0;
		b[i]-=a[i+1];
	}
	else{
		ans2+=b[i];
		a[i+1]-=b[i];
		b[i]=0;
	}

}

cout<<max(ans1,ans2)<<endl;


}
	


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template<typename t1, class t2>
void input(t1 count,t2 array) {
	for(t1 i = 0;i < count;i++) {
		cin >> array[i];
	}
}

template<typename t1, class t2>
void output(t1 count,t2 array) {
	for(t1 i = 0;i < count;i++) {
		cout << array[i];
		if(i != count - 1) cout << " ";
	}
	cout << endl;
}

int main(void) {
	int n,a[20],q,m[200],t;
	cin >> n;
	input(n,a);
	cin >> q;
	input(q,m);
	set<int> u;
	unsigned int end = pow(2,n);
	for(unsigned int j = 0;j < end;j++) {
		t = 0;
		for(int k = 0;k < n;k++) if(j & 1 << k)t += a[k];
		u.insert(t);
	}
	for(int i = 0;i < q;i++) {
		if(u.find(m[i]) != u.end()) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}



Measured memory_bytes: 3280
N=int(input())
L=list(map(int,input().split()))
L.sort()
#print(L)

answer=0
for i in range(N-2):
  index_c=i+2
  for j in range(i+1,N-1):
    for k in range(index_c,N):
      if L[i]+L[j]<=L[k]:
        #print(i,j,k-1,k-j-1)
        answer+=k-j-1
        index_c=k-1
        break
    else:
      #print(i,j,N-1,N-j-1)
      answer+=N-j-1
      index_c=N-1
        
print(answer)

Measured memory_bytes: 44268
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
#define LOCAL  1
#define UPLOAD 2
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';

#define ll long long

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  string S = input<string>();

  map<char, int> m;
  for(int i=0;i<S.length();i++){
    m[S[i]]++;
  }
  
  if(m.size() != 2){
    output("No");
  }
  else{
    for(auto iter:m){
      if(iter.second != 2){
        output("No");
        return 0;
      }
    }
    output("Yes");
  }
  

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*-----------------------*/
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define endl        "\n"
#define ff          first
#define ss          second
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define ee          cout<<"\n";
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int,int>
#define mp          make_pair
#define all(x)      x.begin(),x.end()
#define ps(x)       push(x)
#define psb(x)      push_back(x)
#define psf(x)      push_front(x)
#define pp          pop
#define ppb         pop_back
#define ppf         pop_front
#define OK          cout<<"Ok"<<"\n";
#define TESTS       int test;cin>>test;for(int   tcase=1;tcase<=test;tcase++)
/*------------------------*/
#define MAX int(2e5)
int L[109],H[109],T[109];

int main()
{
    FAST
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0,j=s.size()-1;i<s.size() and i<=j;i++,j--)
    {
        if(s[i]!=s[j]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_S_LEN=1e5;

string S;

string key[4]={"dreamer","dream","erase","eraser"};
bool dp[MAX_S_LEN+1];

void solve(){
	if (S.length()<5){
		cout<<"NO"<<endl;
		return;
	}
	dp[0]=true;
	FOR(i,5,(int)S.length()+1){
		REP(j,4){
			if (i>=(int)key[j].length() && S.substr(i-key[j].length(),key[j].length())==key[j]){
				dp[i]|=dp[i-key[j].length()];
			}
		}
	}
	if (dp[S.length()]){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}

int main(){
	cin>>S;
	solve();
	return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    map <pair <int, int>, int> c;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        c[{s[0] - '0', s.back() - '0'}]++;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        ans += c[{s.back() - '0', s[0] - '0'}];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){


			int n = Integer.parseInt(br.readLine());

			if(n == 0){
				break;
			}

			int input[] = new int[n];
			String[] tmpArray = br.readLine().split(" ");

			int sum = 0;
			for(int i = 0; i < n; i++){
				input[i] = Integer.parseInt(tmpArray[i]);
				sum += input[i];
			}

			double ave = (double)sum/n;

			int count = 0;

			for(int i = 0; i < n; i++){
				if(input[i] <= ave){
					count++;
				}
			}

			System.out.println(count);
		}
	}

}



Measured memory_bytes: 33124
/*  Name: Abu Hurayra
    Handle: HurayraIIT
    Institute: IIT_JU   */
    
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef string S;
typedef double D;
typedef vector<int> vi;
typedef stack<int> si;
typedef queue<int> qi;
typedef priority_queue<int> pqi;
typedef pair<int,int> pi;

#define pi acos(-1.0)
#define PSB push_back
#define PPB pop_back
#define REP(i,a,b) for(i=a;i<=b;i++)

int main()
{
    
    int d,n;
    cin >> d >> n;
    
    int cnt=0;
    int i=1;
    if(d==0)
    {
        if(n==100) cout << 101 << endl;
        else cout << n << endl;
    }
    else if(d==1)
    {
        
        if(n==100) cout << 10100 << endl;
        else cout << n << "00\n";
        
    }
    else if(d==2)
    {
        if(n==100) cout << 1010000 << endl;
        else cout << n << "0000\n";
    }
	
	
	
	return 0;
}
/*
10000
20000
...
100000
1100000
1100
10000
*/



Measured memory_bytes: 256
import numpy as np
n, k = map(int, input().split())
dice = np.arange(1, n+1)

m = np.ceil(np.log2(k) - np.log2(dice))
for i in range(n):
    if m[i] <= 0:
        m[i:] = 0
        break
p = (0.5**m)
print(sum(p)/n)


Measured memory_bytes: 14776
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

  for(int i=1;i<=9;i++){
    if(N%i==0&&N/i<=9&&N/i>=1){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import collections

def main():
    bosses=[]
    count={}
    n = int(input())
    bosses=list(map(int,input().split()))
    ans=[0]*n
    for i in bosses:
        ans[i-1]+=1

    for a in ans:
        print(a)

if __name__=="__main__":
    main()

Measured memory_bytes: 33592
# ABC132 C - Divide the Problems
n = int(input())
d = list(map(int,input().split()))
d.sort()

if n%2 == 0:
    if d[int(n/2)] == d[int((n/2)-1)]:
        print(0)
    else:
        print(d[int(n/2)]-d[int((n/2)-1)])
else:
    print(0)


Measured memory_bytes: 14428
N = int(input())
A = list(input().split())

ans = []

l1 = A[0::2]
l2 = A[1::2]
if N % 2 == 0:
    l2 = l2[::-1]
    ans = l2+l1
else:
    l1 = l1[::-1]
    ans = l1+l2

print(" ".join(ans))


Measured memory_bytes: 27204
#include<stdio.h>

int main(void){
    int n,i,ans=0,count=0;
    scanf("%d",&n);
    long int h[n];
    for(i=0;i<n;i++){
        scanf("%ld",&h[i]);
    }
    for(i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
            count++;
        }else{
            if(ans<count){
                ans=count;
            }
            count=0;
        }
    }
    if(ans<=count){
        ans=count;
    }
    printf("%d",ans);
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	for(int loop = 0; loop < n; loop++){
		int len[3];
		for(int i = 0; i < 3; i++) cin >> len[i];
		sort(len, len + 3);
		if(pow(len[0], 2) + pow(len[1], 2) == pow(len[2], 2)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1)cout<<1<<endl;
	if(n>=2&&n<4)cout<<2<<endl;
	if(n>=4&&n<8)cout<<4<<endl;
	if(n>=8&&n<16)cout<<8<<endl;
	if(n>=16&&n<32)cout<<16<<endl;
	if(n>=32&&n<64)cout<<32<<endl;
	if(n>=64&&n<128)cout<<64<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		long max = sc.nextLong();
		long val[] = new long[num];
		for(int i = 0; i < num; i ++) {
			val[i] = sc.nextLong();
		}
		int digit = 0;
		double tmp = max;
		while(true) {
			if(tmp / 2.0 >= 1) {
				digit ++;
				tmp /= 2.0;
			}else {
				break;
			}
		}
		long ans = 0;
		for(int i = digit; i >= 0; i --) {
			if(ans + (long) Math.pow(2, i) <= max) {
				int count = 0;
				for(int j = 0; j < num; j ++) {
					if(Math.floor((val[j] % Math.pow(2, i + 1)) / Math.pow(2, i)) == 1) {
						count ++;
					}else {
						count --;
					}
				}
				if(count < 0) {
					ans += (long) Math.pow(2, i);
				}
			}
		}
		long sum = 0;
		for(int i = 0; i < num; i ++) {
			sum += ans ^ val[i];
		}
		System.out.println(sum);
	}
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define long long int
#define endl "\n"
using namespace std;
int32_t main()
{	
	IOS;
	string str;
	cin>>str;
	int flag=0;
	int n= str.length();
	for(int i=1;i<=n;i++){
		if((i%2)!=0		&&		(str[i-1]=='L')){
			flag=1;
			break;
		}
		else if((i%2==0)	&&		(str[i-1]=='R')){
			flag=1;
			break;
		}
	}
	if(flag==0)	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


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

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

   ll ans=0;

   for(int i=1;i<n;i++){
      int x=n-i;

      for(int j=1;j*j<=x;j++){
         if(x%j==0){
            ans++;
            if(x/j!=j) ans++;
         }
      }
   }

   cout<<ans;

   return 0;
}


Measured memory_bytes: 3636