akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
import sys

N, K = map(int, input().split())
S = list(map(int, input()))

if 0 not in S:
    print(N)
    sys.exit(0)

left = defaultdict(int)
right = defaultdict(int)
index = 0
for i in range(1, N):
    if S[i-1] == 0 and S[i] == 1:
        right[index] = i
        index += 1
    elif S[i-1] == 1 and S[i] == 0:
        left[index] = i-1

    if i == N-1:
        if S[i] == 0:
            right[index] = i
            left[index+1] = i
        if S[i] == 1:
            left[index] = i

ans = 0
for ind in range(index+1):
    a = left[ind+1] - right[ind-K] + 1
    if ans < a:
        ans = a


print(ans)


Measured memory_bytes: 16264
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
map<string,int>vis;
int arr[55];
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s>>arr[i];
        vis[s]=i;
    }
    string s;cin>>s;
    int ans=0;
    for(int i=vis[s]+1;i<=n;i++)
    {
        ans+=arr[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef long long int int64;

void run(void){
  int n;
  scanf("%d",&n);
  int64 x,y;
  scanf("%lld%lld",&x,&y);
  int i;
  for(i=1;i<n;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    int64 nx=(x+a-1)/a*a;
    int64 ny=nx/a*b;
    if(nx<x || ny<y) {
      ny=(y+b-1)/b*b;
      nx=ny/b*a;
    }
    x=nx;
    y=ny;
  }
  printf("%lld\n",x+y);
}

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int L,R,D;
	cin>>L>>R>>D;
	int Ans=0;
	for (int i=L;i<=R;++i) if (i%D==0) ++Ans;
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.*;
public class Main {
 
  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);

      char c = sc.next().charAt(0);
      if(Character.isLowerCase(c))
      System.out.println("a");
    else
      System.out.println("A");
  }
}

Measured memory_bytes: 35708
main :: IO ()
main = getLine >>=
  putStrLn .
  (\ ds -> if (ds !! 0 == ds !! 1) && (ds !! 1 == ds !! 2) ||
              (ds !! 1 == ds !! 2) && (ds !! 2 == ds !! 3) then "Yes"
           else "No")

Measured memory_bytes: 380
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

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


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}
ll n,m;
bool ok(ll a,ll b){
    return a>=0&&b>=0&&a<n&&b<m;
}
ll dx[8]={1,0,-1,0,1,-1,1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};

int main(){
    IOS;
    make(string,s);
    ll n=s.length();
    vector <ll> l(n),r(n);
    ll c=-1;
    vector <ll> ans(n);
    for(ll i=0;i<n;i++){
        if(s[i]=='L'){
            if(c==-1) {l[i]=i; c=i;}
            else l[i]=c;
        }
        else c=-1;
    }
    c=-1;
    for(ll i=n-1;i>=0;i--){
        if(s[i]=='R'){
            if(c==-1) {r[i]=i; c=i; }
            else r[i]=c;
        }
        else c=-1;
    }
    for(ll i=0;i<n;i++){
        if(s[i]=='L'){
            if((i-l[i])%2==0) ans[l[i]]++;
            else ans[l[i]-1]++;
        }
        else{
            if((r[i]-i)%2==0) ans[r[i]]++;
            else ans[r[i]+1]++;
        }
    }
    fr(i,n) cout<<ans[i]<<" ";

    return 0;
}


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

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

	map<string, int> ma;
	
	int max_v = 0;

	for (int i = 0; i < n; i++) {
		string  tmp; cin >> tmp;
		ma[tmp] += 1;
		max_v = max(max_v, ma[tmp]);
	}
	
	for (auto x : ma) {
		if (x.second == max_v) {
			cout << x.first << endl;
		}
	}

    return 0;
}

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

int main() {
int A,B,C,D;
cin >> A >> B >> C >>D;
if(A*B==C*D){
    cout << A*B; return 0;
}
if(A*B > C*D){
    cout << A*B; return 0;
}
else{
    cout << C*D;
}

return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	ll x,y;
	cin >> x >> y;

	int ans = 0;
	for(ll i = x; i <= y; i *=2) ans++;
	cout << ans << endl;

	return 0;
}

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

const int INF = 1 << 30;
int ans[51];

int main() {
    fill_n(ans, 51, INF);
    for (int a = 0; a < 26; a++) {
        for (int b = 0; b < 19; b++) {
            for (int c = 0; c < 11; c++) {
                int idx = 2 * a + 3 * b + 5 * c;
                if (idx > 50) {
                    continue;
                }
                int a1 = a / 5, a2 = a % 5;
                int b1 = b / 4, b2 = b % 4;
                int c1 = c / 3, c2 = c % 3;
                ans[idx] = min(ans[idx], 1520*a1 + 380*a2 + 1870*b1 + 550*b2 + 2244*c1 + 850*c2);
            }
        }
    }
    int n;
    while (cin >> n, n) {
        cout << ans[n/100] << endl;
    }
}

Measured memory_bytes: 1160
use std::io;
use std::str;

fn main() {
    let s: String = read();
    let n = s.chars().filter(|c| *c == '1').count();
    println!("{}", n);
}

fn read<T: str::FromStr>() -> T {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;


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

    long res = 0;
    for (long a = 1; a < sqrt(N) + 10; a++) {
        if (N % a == 0) {
            long m = N / a - 1;
            if (m > 0 && N / m == N % m) res += N / a - 1;
        }
    }

    cout << res << endl;

    return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<char>> a(n,vector<char>(n));
    vector<vector<char>> b(m,vector<char>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a.at(i).at(j);
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin>>b.at(i).at(j);
        }
    }
    int x=0;
    for(int k=0;k<=n-m;k++){
        for(int l=0;l<=n-m;l++){
            x=0;
            for(int i=0;i<m;i++){
               for(int j=0;j<m;j++){
                   if(a.at(i+k).at(j+l)==b.at(i).at(j)) x++;
                }
            }
            if(x==pow(m,2)) break;
        }
        if(x==pow(m,2)) break;
    }
    if(x==pow(m,2)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vvl a(2, vl(n));
    rep(i, 2) {
        rep(j, n) {
            cin >> a[i][j];
        }
    }

    vvl dp(2, vl(n));  // dp[i][j] : (i,j)までに得られる飴の個数の最大値
    dp[0][0] = a[0][0];
    dp[1][0] = a[0][0] + a[1][0];
    rep(i, 2) {
        exrep(j, 1, n-1) {
            if(i == 0) {
                chmax(dp[i][j], dp[i][j-1] + a[i][j]);
            }
            else if(i == 1) {
                chmax(dp[i][j], max(dp[i][j-1], dp[i-1][j]) + a[i][j]);
            }
        }
    }

    out(dp[1][n-1]);
    re0;
}

Measured memory_bytes: 384
n,m = map(int, raw_input().split())

a = []
b = [0]*m
for i in xrange(n):
    x = map(int,raw_input().split(" "))
    a.append(x)

for i in xrange(m):
    b[i] = input()

result = [0]*n

for i in xrange(n):
    for j in xrange(m):
        result[i] += a[i][j]*b[j]

    print result[i]

Measured memory_bytes: 6556
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val a = readLine()!!.split(' ').map { it.toLong() }

    val q = PriorityQueue<Long>(n) { o1: Long, o2: Long -> -o1.compareTo(o2) }
    for (x in a) {
        q.add(x)
    }
    repeat(m)   {
        val x = q.poll()
        q.add(x / 2)
    }
    val ans = q.sum()
    println(ans)
}

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int toint(string s){
	int i=sz(s)-1;
	int ans=0;
	for(char c:s){
		ans+=pow(10,i--)*(int)(c-'0');
	}
	return ans;
}

bool check(int x){
	int j=sqrt(x);
	return j*j==x;
}

int main(){
	string a,b;
	cin>>a>>b;
	a+=b;
	cout<<(check(toint(a))?"Yes":"No");
}





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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    REP(i, 5)
    {
        ll x;
        cin >> x;
        if (x == 0)
        {
            cout << i + 1 << endl;
            break;
        }
    }
}


Measured memory_bytes: 3620
// https://atcoder.jp/contests/abc125/tasks/abc125_b

#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;

    int v[N];
    int c[N];

    for(auto &x: v) cin >> x;
    for(auto &x: c) cin >> x;

    int X=0, Y=0;
    for(int i = 0; i < N; i++) {
        if(v[i] > c[i]) {
            X += v[i];
            Y += c[i];
        }
    }

    cout << X-Y << endl;
}


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

using namespace std;

#define STREAM_IO ios_base::sync_with_stdio(false)
#define STREAM_IO_BUFFERED cin.tie(0); cout.tie(0)

typedef long long ll;
#define LL (ll)
typedef unsigned int uint;
#define UINT (uint)
typedef unsigned long long ull;
#define ULL (ull)

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define mp make_pair

template <class T1, class T2> inline istream &operator>>(istream &in, pair <T1, T2> &pr) { in >> pr.first >> pr.second;	return in; }
template <class T1, class T2> inline ostream &operator<<(ostream &out, const pair <T1, T2> &pr) { out << pr.first << ' ' << pr.second; return out; }

typedef vector <int> vi;
typedef vector <ll> vl;
#define pb push_back
#define ppb pop_back
#define clr clear

template <class T> inline istream &operator>>(istream &in, vector <T> &v) { for (T &x : v) in >> x; return in; }
template <class T> inline ostream &operator>>(ostream &out, const vector <T> &v) { for (T &x : v) out << x << ' '; return out; }

template <class T> inline istream &operator>>(istream &in, set <T> &v) { T x; in >> x; v.insert(x); return in; }
template <class T> inline ostream &operator>>(ostream &out, set <T> &v) { for (T &x : v) out << x << ' '; return out; }

template <class T> inline istream &operator>>(istream &in, multiset <T> &v) { T x; in >> x; v.insert(x);  return in; }
template <class T> inline ostream &operator>>(ostream &out, multiset <T> &v) { for (T &x : v) out << x << ' '; return out; }

template <class T> void Write(const vector <T> &v, char c = ' ') { for (const T &x : v) cout << x << c; }
template <class T> void Writeln(const vector <T> &v, char c = ' ') { for (const T &x : v) cout << x << c; cout << char(10); }

template <class T> void Write(set <T> &v, char c = ' ') { for (const T &x : v) cout << x << c; }
template <class T> void Writeln(set <T> &v, char c = ' ') { for (const T &x : v) cout << x << c; cout << char(10); }

template <class T> void Write(multiset <T> &v, char c = ' ') { for (const T &x : v) cout << x << c; }
template <class T> void Writeln(multiset <T> &v, char c = ' ') { for (const T &x : v) cout << x << c; cout << char(10); }

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

ll gcd(ll a, ll b) { while (b) { a %= b; swap(a, b); } return a; }
int gcd(int a, int b) { while (b) {	a %= b;	swap(a, b);	} return a; }

#define bitscnt(U) __builtin_popcountll(LL (U))

#define SZ(U) int((U).size())
#define all(U) (U).begin(), (U).end()
#define rall(U) (U).rbegin(), (U).rend()
#define imin(U) (U).begin()
#define gmin(U) (*imin(U))
#define imax(U) (--(U).end())
#define gmax(U) (*imax(U))
#define REV(U) reverse(all(U))
#define SORT(U) sort(all(U))
#define CLR(U) memset(U, 0, sizeof U)
#define ONES(U) memset(U, -1, sizeof U)
#define CPY(FROM, TO) memcpy(TO, FROM, sizeof TO)

void solve()
{
	string s;
	cin >> s;
	if (s.size() > 3 && s.substr(0, 4) == "YAKI")
		cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main()
{
	//freopen("input.txt", "r", stdin);
	STREAM_IO;
	STREAM_IO_BUFFERED;
	solve();
	return 0;
}


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

int main() {
  int sum=0,lim=644;
  vector<double> s(5),t(5);
  for(int i=0; i<5; i++) cin>>s[i];
  for(int i=0; i<5; i++){
    for(double j=0; ; j++){
      if(s[i]/10<=j) {
        t[i] = j*10;
        sum+=t[i];
        break;
      }
    }
  }
  for(int i=0; i<5; i++){
    int x = sum-t[i]+s[i];
    lim = min(x,lim);
  }
  cout<<lim;
}

Measured memory_bytes: 256
const { SSL_OP_SSLEAY_080_CLIENT_DH_BUG } = require("constants");

process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  const [n, m, l] = parseLine(lines[0]);

  const A = [],
    B = [];
  for (let i = 1; i <= n; i++) {
    A.push(parseLine(lines[i]));
  }
  for (let i = 1 + n; i <= n + m; i++) {
    B.push(parseLine(lines[i]));
  }
  for (let i = 0; i < n; i++) {
    const r = [];
    for (let j = 0; j < l; j++) {
      let sum = 0;  
      for (let k = 0; k < m; k++) {
        sum += A[i][k] * B[k][j];
      }
      r.push(sum);
    }
    console.log(r.join(" "));
  }
});

function parseLine(s) {
  return s.split(" ").map((s) => Number(s));
}



Measured memory_bytes: 20608
n,m = map(int,input().split())
lr = [list(map(int,input().split()))for i in range(m)]

low = 1
high = 10**5

for l,r in lr:
    if low <= l:
        low = l 
    if r <= high:
        high = r 

if high < low:
    print(0)
    exit()
print(high - low + 1)

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

int main(){
    int a, b, c, d, r;
    double f;
    // a = 3;
    // b = 2;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double) a / b;
    cout << d << " " << r << " " << std::setprecision(13) << std::fixed << f << endl;

    return 0;
}


Measured memory_bytes: 3292
#include <stdio.h>

int main() {
  int a, b, c ;

   scanf ("%d %d %d", &a, &b, &c ) ; 
  

   if ((a >= b) && (c >= b)) {
     printf("%d ", b) ;
     if (a <= c)
        printf("%d %d\n", a, c) ;
      else
        printf("%d %d\n", c, a) ;
}
    else if ((a <= b) && (a <= c)) {
      printf("%d ", a) ;
      if (b <= c)
        printf("%d %d\n", b, c) ;
      else
        printf("%d %d\n", c, b) ;

    }

    else if ((c <= a) && (c <= a)) {
     printf("%d ", c) ;
     if (b <= a)
        printf("%d %d\n", b, a) ;
      else
        printf("%d %d\n", a, b) ;
}
	else if ( (a == b) && ( b == c))
       printf("%d %d %d\n", a, b, c);

return 0 ;
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
  double a, b, sum = 0;
  cin >> a >> b;

  sum = (a+b)/2.0;

  if((int)(sum)+1-sum<=0.5) {
    cout << (int)sum+1 << endl;
  }
  else {
    cout << (int)sum << endl;
  }

  return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int,input().split())
Way = [''] * 4 
Way[0] = 'R' * (tx-sx) + 'U' * (ty-sy)
Way[1] = 'L' * (tx-sx) + 'D' * (ty-sy)
Way[2] = 'D' + 'R' * (tx-sx+1) + 'U' * (ty-sy+1) + 'L'
Way[3] = 'U' + 'L' * (tx-sx+1) + 'D' * (ty-sy+1) + 'R'
print(''.join(Way))

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
typedef unsigned long long int ull;
typedef long long int ll;

int a[500005];
const int M=1e4;
ll cnt[M];
int main()
{
    int n,m,b,c,x,y;
    ll sum,ans=0;
    sum=0;
    cin>>n;
    //set<int>s;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        //s.insert(a[i]);
    }
    int cnt=0;
    sort(a,a+n);
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]!=a[j] && a[j]!=a[k]  && a[i]+a[j]>a[k])
                    cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

void inserting(vector<int> &a, int n)
{
    for (int i = 1; i < n; i++)
    {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        printv(a);
    }
}

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

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



Measured memory_bytes: 3136
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	cin >> n >> m;

	int ans = ceil(double(n)/m);

	cout << ans << endl;	
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}



Measured memory_bytes: 5504
#include <stdio.h>
#include <string.h>

int main(void) {
    char s[10];
    int a,c,d,i = 1,j,sum = 0,f = 0;
    scanf("%d%d%d",&a,&c,&d);
    while(i <= a) {
        sprintf(s, "%d", i);
        for (j = 0; j < strlen(s); j++) {
            f += s[j] - '0';
        }
        if (f >= c && f <= d) {
            sum = sum + i;
        }
        i++;
        f = 0;
    }
    printf("%d\n",sum);
    return 0;
}

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

#define INF 100000000

using namespace std;

int limlessKP_SOLVER(int *W, int *V, int n, int m){ // n = number of items, m = capacity
    int dp[n+1][m+1];
    for(int i=0; i<n+1; i++){
        for(int j=0; j<m+1; j++){
            if(j== 0) dp[i][j] = 0;
            else      dp[i][j] = INF;
        }
    }
    for(int i=1; i<n+1; i++){
        for(int j=1; j<m+1; j++){
            dp[i][j] = min(dp[i-1][j], dp[i][max(0, j - W[i-1])] + V[i-1]);
        }
    }
    return dp[n][m];
}

int main(){
    int H, N;
    cin >> H >> N;
    int A[N], B[N];
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
    }
    cout << limlessKP_SOLVER(A, B, N, H) << endl;
    return 0;
}

Measured memory_bytes: 39296
#include <iostream>
#include <limits>
#include <vector>

const long long int inf = 1000000000 + 1;
int cnt = 0;

void merge(std::vector<long long int> &s, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    std::vector<long long int> L(n1+1);
    std::vector<long long int> R(n2+1);

    for (int i = 0; i < n1; i++) {
        L[i] = s[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = s[mid + i];
    }
    L[n1] = inf;
    R[n2] = inf;

    // std::cout << "==== merge ====" << std::endl;
    // for (int i = 0; i < n1; i++) {
    //     std::cout << L[i] << " ";
    // }
    // std::cout << std::endl;
    // for (int i = 0; i < n2; i++) {
    //     std::cout << R[i] << " ";
    // }
    // std::cout << std::endl;
    // std::cout << "||" << std::endl;
    // std::cout << "\\/" << std::endl;


    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            s[k] = L[i];
            i++;
        }
        else {
            s[k] = R[j];
            j++;
        }
        cnt++;
    }

    // for (int i = left; i < right; i++) {
    //     std::cout << s[i] << " ";
    // }
    // std::cout << std::endl;
}

void mergesort(std::vector<long long int> &s, int left, int right)
{
    if (left + 1 < right) {
        int mid = left + (right - left) / 2;
        mergesort(s, left, mid);
        mergesort(s, mid, right);
        merge(s, left, mid, right);
    }
}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    std::vector<long long int> s(n);
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
    }

    mergesort(s, 0, n);

    for (int i = 0; i < n - 1; i++) {
        std::cout << s[i] << " ";
    }
    std::cout << s[n - 1] << std::endl;

    std::cout << cnt << std::endl;
    return 0;
}

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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<int,int> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

ll memo[410][410];
ll v[410];
ll sum[410];

int n;

ll dp(int i, int j){
	if(i == j)
		return 0LL;
		
	if( (i+1) == j)	
		return v[i] + v[j];
	
	if(memo[i][j] != -1LL)
		return memo[i][j];
	
	ll ans = INFLL;
		
	for(int k=i; k<j; k++){
		if(k == i)
			ans = min(ans, sum[j] - sum[i-1] + dp(i,k+1) + dp(k+2, j) );		
		else if(k == j-1)
			ans = min(ans, sum[j] - sum[i-1] + dp(i,k-1) + dp(k, j) );				
		else
			ans = min(ans, sum[j] - sum[i-1] + min(dp(i,k+1) + dp(k+2, j), dp(i,k-1) + dp(k, j)) );		
	}
	
	return memo[i][j] = ans;
}

int main() {	
	memset(memo, -1, sizeof(memo));
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;

	for(int i=1; i<=n; i++){
		cin >> v[i];
		sum[i] = sum[i-1] + v[i];
	}
	
	cout << dp(1, n) << endl;

	return 0;	
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<ll,ll> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	ll n,a[100010],m,ans=0,sum=0;
	cin>>n>>m;
	REP(i,n){
		cin>>a[i];
	}
	REP(i,n-1){
		if(a[i]+a[i+1]>m){
			ans+=(a[i]+a[i+1])-m;
			if(a[i+1]-(a[i]+a[i+1]-m)<0)a[i+1]=0;
			else a[i+1]-=a[i]+a[i+1]-m;
		}
		DEB(ans)END
	}
	DEB(ans)END
	cout<<ans<<endl;
	return 0;
}
//5 1 2 4


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

typedef long long ll;

using namespace std;


const ll mod=1000000007;


bool judge(ll x,ll* A,ll N,ll K){
    ll p=0;

    for(int i=0;i<N;++i){
        
        p+=(A[i]-1)/x;
       
    }
     //cout<<"x: "<<x<<" p:"<<p<<endl;

    return p<=K;
}

ll binarysearch(ll* A,ll N,ll K){
    ll ok=1e9;
    ll ng=0;
    while(abs(ok-ng)>1){
          ll mid=(ok+ng)/2;
        if(judge(mid,A,N,K)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    return ok;

}



int  main(){
    ll N,K;
    cin>>N>>K;
    ll A[N];

    ll end;

    for(int i=0;i!=N;i++){
        cin>>A[i];

    }
    
    ll ans=binarysearch(A,N,K);
    cout<<ans<<endl;
}


Measured memory_bytes: 5132
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat May 23 22:09:04 JST 2020
 **/

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

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

template <class A, class B, class C, class D>
std::pair<A, B>& operator+=(std::pair<A, B>& x, const std::pair<C, D>& y) {
    return x = {x.first + y.first, x.second + y.second};
}
template <class A, class B, class C, class D> std::pair<A, B> operator+(std::pair<A, B> x, const std::pair<C, D>& y) {
    return x += y;
}
template <class T, class integer> T& get(std::vector<std::vector<T>>& v, const std::pair<integer, integer>& p) {
    return v[p.first][p.second];
}

const std::vector<std::pair<int, int>> DIRECTIONS = {
    {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
};

template <class S, class T> bool in_range(S x, T l, T r) { return l <= x && x < r; }
using pii = std::pair<int, int>;
signed main() {
    int n;
    std::cin >> n;
    std::vector<int> p(n * n);
    REP(i, n * n) std::cin >> p[i], p[i]--;
    auto d = make_vec<int>(n, n, 0);
    auto filled = make_vec<int>(n, n, true);
    REP(i, n) REP(j, n) d[i][j] = std::min({i, j, n - 1 - i, n - 1 - j});
    Int ans = 0;
    for (int val : p) {
        pii st = {val / n, val % n};
        ans += get(d, st);
        get(filled, st) = false;
        std::queue<pii> q({st});
        while (!q.empty()) {
            pii cur = q.front();
            q.pop();
            for (const pii& dir : DIRECTIONS) {
                pii nxt = cur + dir;
                if (!in_range(nxt.first, 0, n) || !in_range(nxt.second, 0, n)) continue;
                if (chmin(get(d, nxt), get(d, cur) + get(filled, cur))) q.push(nxt);
            }
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 6072
n=int(input())
c=0

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

for i in factorization(n):
  for j in range(1,100000):
    if (j-1)*j<=2*i[1]<j*(j+1):
      c+=j-1
if n!=1:
  print(c)
else:
  print(0)

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

template<class T,class U> inline void chmax(T&a,U b){if(a<b)a=b;}

int main(int argc, char *argv[])
{
	int n,m,q;
	cin >> n >> m >> q;
	vector<int> a(q), b(q), c(q), d(q);
	for (int i = 0; i < q; i++) {
		cin >> a[i]>> b[i] >> c[i] >> d[i];
		a[i]--;b[i]--;
	}
	vector<int> A(n,1);
	int ans = 0;
	auto dfs = [&](auto&& dfs, int v) -> void{
		while (A[v] <= m) {
			if (v == n-1) {
				int tmp = 0;
				for (int i = 0; i < q; i++) {
					tmp += A[b[i]] - A[a[i]] == c[i] ? d[i] : 0;
				}
				chmax(ans,tmp);
			}
			else {
				if (A[v+1] < A[v]) {
					A[v+1] = A[v];
				}
				dfs(dfs, v+1);
			}
			A[v]++;
		}
		A[v] = 1;
		return;
	};
	dfs(dfs, 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3164
fun main(args: Array<String>) {
	var (h, w) = readLine()!!.split(" ").map{ it.toLong() }
	if (h % 3 == 0L || w % 3 == 0L) {
		println(0)
		return
	}
	var ans = Math.min(h, w)
	for (i in 1..(w - 1)) {
		val a = (w - i) * h
		val b = ((h + 1) / 2) * i
		val c = (h / 2) * i
		val diff = Math.max(Math.abs(a - b), Math.max(Math.abs(b - c), Math.abs(c - a)))
		ans = Math.min(ans, diff)
	}
	for (i in 1..(h - 1)) {
		val a = (h - i) * w
		val b = ((w + 1) / 2) * i
		val c = (w / 2) * i
		val diff = Math.max(Math.abs(a - b), Math.max(Math.abs(b - c), Math.abs(c - a)))
		ans = Math.min(ans, diff)
	}
	println(ans)
}


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

int main(){
  int n;
  cin >> n;
  string str;
  cin >> str;
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  else{
  for(int i=0;i<n/2;i++){
    if(str.at(i)!=str.at((n/2)+i)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << 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 repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 999999999;

int main(){
   int x,y;
   cin >> x >> y;
   if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
      && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) 
      )
      cout << "Yes";
      else if((x == 4 || x == 6 || x == 9 || x == 11)
      && (y == 4 || y == 6 || y == 9 || y == 11))
      cout << "Yes";
      else if((x == 2) && (y == 2))
      cout << "Yes";
      else cout << "No";
   return 0;
}

Measured memory_bytes: 256
N = int(input())
T = list(map(int,input().split()))
M = int(input())
list = [list(map(int,input().split())) for _ in range(M)]
for _ in range(M):
    T_ = [x for x in T]
    T_[list[_][0]-1] = list[_][1]
    num = 0
    for t in T_:
        num += t
    print(num)
#go


Measured memory_bytes: 3060
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
void solve()
{
	int n;
	cin>>n;
	int ac=0;
	int wa=0;
	int tle=0;
	int re=0;
	while(n--)
	{
		string s;
		cin>>s;
		if(s[0]=='A')
			ac++;
		if(s[0]=='W')
			wa++;
		if(s[0]=='T')
			tle++;
		if(s[0]=='R')
			re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl; 
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>

void preorder(int);
void inorder(int);
void postorder(int);

typedef struct node{
  int pa;
  int le;
  int ri;
}TREE;

TREE tree[26];
int n;

int main(){
  int i,node,left,right,root;
  scanf("%d",&n);
  if(n>25) exit(2);
  for(i=0;i<n;i++) {
    tree[i].pa=tree[i].le=tree[i].ri=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&node,&left,&right);
    if(left != -1){
      tree[left].pa=node;
      tree[node].le=left;
    }
    if(right != -1){
      tree[right].pa=node;
      tree[node].ri=right;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].pa==-1) root=i;
  }

  printf("Preorder\n");
  preorder(root);
  printf("\nInorder\n");
  inorder(root);
  printf("\nPostorder\n");
  postorder(root);
  printf("\n");
  
  return 0;
}

void preorder(int u){
  if(u == -1)return;
  printf(" %d",u);
  preorder(tree[u].le);
  preorder(tree[u].ri);
}

void inorder(int u){
  if(u == -1)return;
  inorder(tree[u].le);
  printf(" %d",u);
  inorder(tree[u].ri);
}

void postorder(int u){
  if(u == -1)return;
  postorder(tree[u].le);
  postorder(tree[u].ri);
  printf(" %d",u);
}



Measured memory_bytes: 2060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) string((s).rbegin(), (s).rend())
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;

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

int w, h;

int field[21][21];

const int INF = 100;

int dfs(int sx, int sy, int cnt){
	if(cnt >= 10) return INF;

	int best = INF;
	rep(i, 4){
		int x, y;
		x = sx+dx[i];
		y = sy+dy[i];

		if(x < 0 || x >= w || y < 0 || y >= h) continue;
		if(field[y][x] == 1) continue;

		while(1){
			if(x < 0 || x >= w || y < 0 || y >= h) break;
			if(field[y][x] == 1){
				field[y][x] = 0;
				int n = dfs(x-dx[i], y-dy[i], cnt+1);
				best = min(best, n);
				field[y][x] = 1;
				break;
			}else if(field[y][x] == 3){
				return cnt+1;
			}
			x += dx[i];
			y += dy[i];
		}
	}
	return best;
}

int main(){
	int sx, sy;
	while(1){
		cin >> w >> h;
		if(!w && !h) break;
		rep(i, h){
			rep(j, w){
				cin >> field[i][j];
				if(field[i][j] == 2){
					sx = j;
					sy = i;
				}
			}
		}
		int best;
		best = INF;
		best = min(best, dfs(sx, sy, 0));
		//cout << "***";
		cout << (best==INF?-1:best) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, s;
            var word = Console.ReadLine().Split(' ');
            A = int.Parse(word[0]);
            B = int.Parse(word[1]);

            s = A * B;
			if (A >= 10 || B >= 10)
			{
				Console.WriteLine("-1");
			}
			else if (A < 10 || B < 10)
			{
				Console.WriteLine(s);
			}

			Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>

#include <iomanip>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > 12)
    {
        cout << b;
    }
    else if (a <= 12 && a >= 6)
    
    {
        cout << b / 2;
    }
    else if (a < 6 && a >= 0)
    {
        cout << 0;
    }
}

Measured memory_bytes: 256
from itertools import permutations

def check(xs):
    if xs[0] != xs[-1] ^ xs[1]:
        return False
    for i in range(1, len(xs)-1):
        if xs[i] != xs[i-1] ^ xs[i+1]:
            return False
    if xs[-1] != xs[-2] ^ xs[0]:
        return False
    return True

def solve0(A):
    for xs in permutations(A):
        if check(xs):
            return "Yes"
    return "No"

def solve(A):
    """
    N <= 10**5
    A <= 10**9
    a[i] == a[i-1] xor a[i+1]
    """
    x = 0
    for a in A:
        x ^= a

    return "Yes" if x == 0 else "No"

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    print(solve(A))

if 0==1:
    from random import randint
    N = 7
    for j in range(1, 100):
        A = [randint(0, 999999999) for i in range(N)]
        answer0 = solve0(A)
        answer = solve(A)
        if answer != answer0:
            print(answer, answer0)
            exit(1)

main()


Measured memory_bytes: 14496
#include <iostream>
#include <cstdio>
using namespace std;
int n, s, mv, to, t[105], v[105], z[40005];
int main() {
	int i, j=0;
	cin>>n;
	for(i=1; i<=n; i++) cin>>t[i], t[i]*=2;
	for(i=1; i<=n; i++) cin>>v[i], v[i]*=2;
	for(i=1; i<=n; i++) {
		to += t[i];
		z[j] = min(z[j], v[i]);
		for(++j; j<=to; j++) z[j] = min(z[j-1]+1, v[i]);
		j--;
	}
	for(i=j-1; i; i--) s += mv = min(z[i], mv+1);
	printf("%.9f", s/4.0);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }

  ll s = 0;
  for (int i = 1; i < n; ++i) {
    ll walk_cost = (x[i] - x[i-1]) * a;
    if (walk_cost < b) s += walk_cost;
    else   s += b;
  }
  cout << s << endl;
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int a, b, x;

int main(){
    cin >> a >> b;
    if(a - (2*b) < 0){
        cout << x;
    } else{
        cout << a - (2*b);
    }

}

//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
# Ref. https://atcoder.jp/contests/abc091/submissions/5903551

from collections import defaultdict
d = defaultdict(int)

n = int(input())
for i in range(n):
    d[input()] += 1

m = int(input())
for i in range(m):
    d[input()] -= 1

ans = max(d.values())
print(max(0, ans))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}



int main(){
  
  int x;
  cin>>x;
  int ans;
  for(int i = x; i<= 100005; i++){
    if(prime_(i)){
      ans = i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0; 
}


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

int main(){
    int n;
    cin>>n;
    vector<P>ans;
    if(n%2==1){
        for(int i=1; i<=n; ++i){
            for(int j=i+1; j<=n; ++j){
                if(i+j==n)continue;
                ans.push_back(P(i,j));
            }
        }
    }
    else{
        for(int i=1; i<=n; ++i){
            for(int j=i+1; j<=n; ++j){
                if(i+j==n+1)continue;
                ans.push_back(P(i,j));
            }
        }
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size())cout<<ans[i].first<<" "<<ans[i].second<<endl;
}

Measured memory_bytes: 3628
import heapq

n, m = map(int,input().split())
price = list(map(int, input().split()))
price = list(map(lambda x: x*(-1), price))
heapq.heapify(price)
while m != 0:
    maxv = heapq.heappop(price)
    heapq.heappush(price, (maxv+1) // 2)
    m -= 1
print(sum(price) * (-1))


Measured memory_bytes: 14180
n=int(input())
s=list(input())
ans=0
i=0
while i+1<n:
  j=0
  while s[i+j]==s[i+j+1]:
    if i+j+1<=n-2:
      j+=1
    else:
      j+=1
      break
  i+=j+1
  ans+=j
  
print(n-ans)

Measured memory_bytes: 9880
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N = int(input())
    h = list(map(int, input().split()))
    h += [0, 0]
    dp = np.full(N+2, int(1e15))

    dp[0] = 0
    for i in range(N):
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]))
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]))
    # print(dp)
    print(int(dp[N-1]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 24876
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N,M,C;

int main() {
  cin >> N >> M >> C;
  vector<int> B(M);
  rep(i,0,M - 1) cin >> B[i];
  int ans = 0;
  for(int i = 0;i < N;i++) {
    int res = 0;
    for(int j = 0;j < M;j++) {
      int a;
      cin >> a;
      res += a * B[j];
    }
    if(res + C > 0) ans++;
  }
  cout << ans << endl;
}


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

using namespace std;

int main()
{
    string S;
    int K;
    cin >> K >> S;

    if (S.length() > K)
    {
        for (int i = 0; i < K; i++)
        {
            cout << S[i];
        }

        cout << "...";
    }

    else
    {
        cout << S;
    }
}

Measured memory_bytes: 3624
#include <iostream>

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

  char a; std::cin >> a;
  if ('A' <= a and a <= 'Z')
    std::cout << "A\n";
  else
    std::cout << "a\n";

  return 0;
}


Measured memory_bytes: 3616