akhauriyash/Code-Regression huggingface dataset:
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

const int mod = 1e9+7;
enum{N=2023};
il ll qpow(ll a,ll b){
	ll ans= 1;
	for(; b; b>>=1,a=a*a%mod) if( b&1 ){
		ans= ans*a%mod;
	} return ans;
}
il ll inv(ll x){ return qpow(x,mod-2); }
ll fac[N*N],Invf[N*N];
il void init_fac(int n){
	fac[0] = 1;
	rep(i,1,n) fac[i]=fac[i-1]*i%mod;
	Invf[n] = inv(fac[n]);
	rev_rep(i,n,1) Invf[i-1]=Invf[i]*i%mod;
}
il ll comp(ll n,ll m){
	if( n<m ) return 0;
	return fac[n]*Invf[m]%mod*Invf[n-m]%mod;
}

ll f[N][N];
int main(){
	int n = ci(), k = ci();
	if( k==1 ){
		puts("1");
		return 0;
	}
	init_fac(n*k);
	f[0][0] = 1;
	rep(i,1,n){
		f[i][0] = f[i-1][0];
		rep(j,1,i){
			f[i][j] = (f[i-1][j]+f[i][j-1]*(n-j+1)%mod*comp((n-i)+(n-j+1)*(k-1)-1,k-2))%mod;
		}
	}
	printf("%lld\n",(f[n][n]+mod)%mod);
	return 0;
}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, long long M) {
    cout << (N - 1) * N / 2 + M * (M - 1) / 2 << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
k=10**9
for i in range(n):
    t=0
    while True:
        if a[i]%2==0:
            a[i]=a[i]//2
            t=t+1
        else:
            if t<k:
                k=t
                break
            else:
                break
print(k)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define LL long long
#define N 200005
#define MOD 1000000007
#define bas 8741
#define pli pair<LL, int>
#define mp make_pair
#define fi first
#define se second
using namespace std;
int n, m, head[2][N], num[2], x, y, z, headb[N], cnt, low[N], dfn[N], cnt1;
const LL INF = (LL)1 << 50;
bool flag[N], flage[N << 1];
LL dis[3][N], ans, stand;
struct edge {
    int fr, to, nxt, w, id;
}a[2][N << 1], b[N << 1];
void add(int x, int y, int z, int _id) {
    a[0][++num[0]] = (edge){x, y, head[0][x], z, _id}, head[0][x] = num[0];
    a[1][++num[1]] = (edge){y, x, head[1][y], z, _id}, head[1][y] = num[1];
}
void add2(int x, int y, int z, int _id) {
    b[++cnt] = (edge){x, y, headb[x], z, _id}, headb[x] = cnt;
}
priority_queue<pli, vector<pli>, greater<pli> >q;
void sssp(int st, int type) {
    for(int i = 1; i <= n; ++i) {
        dis[st][i] = INF;
        flag[i] = 0;
    }
    dis[st][st] = 0;
    while(!q.empty()) q.pop();
    pli temp = mp(0, st);
    q.push(temp);
    while(!q.empty()) {
        temp = q.top();
        q.pop();
        x = temp.se;
        flag[x] = 1;
        for(int e = head[type][x]; e; e = a[type][e].nxt) {
            y = a[type][e].to, z = a[type][e].w;
            if(dis[st][y] > dis[st][x] + z) {
                dis[st][y] = dis[st][x] + z;
                temp = mp(dis[st][y], y);
                q.push(temp);
            }
        }
    }
}
void dfs(int x, int f) {
    low[x] = dfn[x] = ++cnt1;
    flag[x] = 1;
    for(int e = headb[x]; e; e = b[e].nxt) {
        int k = b[e].to;
        if(!flag[k]) {
            dfs(k, x);
            low[x] = min(low[x], low[k]);
        }
        else if(k != f) {
            low[x] = min(low[x], dfn[k]);
        }
    }
}
void print(LL x, LL y) {
    if(x > y) printf("SAD\n");
    else if(x == y) printf("SOSO\n");
    else printf("HAPPY\n");
}
int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; ++i) {
        scanf("%d%d%d", &x, &y, &z);
        add(x, y, z, i);
    }
    sssp(1, 0);
    sssp(2, 1);
    for(int i = 1; i <= m; ++i) {
        x = a[0][i].fr, y = a[0][i].to;
        if(dis[1][x] + a[0][i].w == dis[1][y] && dis[2][y] + a[0][i].w == dis[2][x]) {
            add2(x, y, z, i);
            add2(y, x, z, i);
            flage[i] = 1;
        }
    }
    for(int i = 1; i <= n; ++i) flag[i] = 0;
    dfs(1, 0);
    for(int i = 1; i <= m; ++i) {
        if(!flage[i]) continue;
        x = a[0][i].fr, y = a[0][i].to;
        if(low[y] <= dfn[x]) flage[i] = 0;
    }
    stand = dis[1][2];
    for(int i = 1; i <= m; ++i) {
        x = a[0][i].fr, y = a[0][i].to;
        if(flage[i]) {
            ans = dis[1][y] + a[0][i].w + dis[2][x];
            print(ans, stand);
        }
        else {
            ans = min(stand, dis[1][y] + a[0][i].w + dis[2][x]);
            print(ans, stand);
        }
    }
    return 0;
}



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

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n, m;
  cin >> n >> m;
  vector<vector<ll>> dp(n + 1, vector<ll>(60 * 60));
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    int mx = 50 * 50 - x;
    for (int j = i; j >= 0; --j)
      for (int v = mx; v >= 0; --v) dp[j + 1][v + x] += dp[j][v];
  }

  ll ans = 0;
  for (int i = 1; i <= n; ++i) ans += dp[i][m * i];
  cout << ans;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N,D;

int main(){
    cin>>N>>D;
    out((N+2*D)/(2*D+1));

    
}


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

def solve():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    
    longest = L[-1]
    sum = 0
    for i in range(len(L)-1):
        sum += L[i]
    
    if longest < sum:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
int n;
struct block{
int w,s;
LL v;
bool operator <(block o){
	return s+w>o.s+o.w;
}
};
block b[1005];
LL dp[1005][10005];
LL solve(int i,int S){
	LL &ret=dp[i][S];
	if(i==n||S==0) return 0;
	if(ret!=-1) return ret;
	ret=solve(i+1,S);
	if(b[i].w>S) return ret;
	ret=max(ret,b[i].v+solve(i+1,min(S-b[i].w,b[i].s)));
	return ret;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++) scanf("%d%d%lld",&b[i].w,&b[i].s,&b[i].v);
	sort(b,b+n);
	/*
	 *for(auto t:b)
	 *    cout<<t.w<<"\n";
	 */
	memset(dp,-1,10000005*sizeof(dp[0][0]));
	cout<<solve(0,50003);
	return 0;
}

Measured memory_bytes: 78464
N, K = map(int, input().split())
h = [0] + list(map(int, input().split()))

dp = [int(1e18)]*(N+1)
dp[1] = 0
for i in range(1, N):
    for k in range(1, min(N-i+1, K+1)):
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i] - h[i+k]))
print(dp[N])


Measured memory_bytes: 52832
const log = console.log;

const parseLines = (s: string) => s.trim().split("\n");
const parseSpaceSeparated = (line: string) => line.trim().split(" ");
const parseDecimalInt = (s: string) => parseInt(s);
const parseSpaceSeparatedDecimalInt = (line: string) =>
  parseSpaceSeparated(line).map(parseDecimalInt);

const sumReducer = (accumulator: number, currentValue: number) =>
  accumulator + currentValue;
const sum = (numbers: number[]) => numbers.reduce(sumReducer, 0);

// ----

function Main(input: string): void {
  const [head, ...body] = parseLines(input);
  const [n, x] = parseSpaceSeparatedDecimalInt(head);
  const m = body.map(parseDecimalInt);

  let donutsCount = m.length;
  const usedPowderWeight = sum(m);
  const minM = Math.min(...m);

  donutsCount += ((x - usedPowderWeight) / minM) | 0;

  log(donutsCount);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.math.BigDecimal;
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        BigDecimal x = sc.nextBigDecimal();
        BigDecimal y = sc.nextBigDecimal();
        System.out.println(x.multiply(y).toBigInteger());
    }
}

Measured memory_bytes: 37472
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = ReadInts();
            WriteLine(Max((ab[0] - ab[1] * 2),0));
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }


        public static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        //最大公約数
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
        public static void debuglist(List<int> x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debuglist(List<string> x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debugarray(int[] x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debugarray(string[] x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<math.h>
 
int main(){
    double a;
    double b;
    double now=90;
    double x=0,y=0;
    double PI=3.14159265358;
    while(1){
        scanf("%lf,%lf",&a,&b);
        if(a==b&&b==0)break;
        x+=cos(now*PI/180)*a;
        y+=sin(now*PI/180)*a;
        now-=b;
    }
    printf("%d\n%d\n",(int)x,(int)y);
}

Measured memory_bytes: 1060
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    input!{
        n: i64,
        k: i64,
    }
    let t = n / k;
    let mut ans = t * t * t;
    if k % 2 == 0 {
        let t = (n + k / 2) / k;
        ans += t * t * t;
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<stdio.h>

int main(){
   int N,M ;   
   int total = 0;
   int count = 0;
   scanf("%d %d",&N,&M);
   int A[N];

   for(int i = 0;i<N;i++){
      scanf("%d",&A[i]);
      total = total+A[i];
   }
   for(int i = 0;i<N;i++){
      if(A[i]*4*M>=total){
         count++;
      }
   }
   if(count>=M){
      printf("Yes");
   }else{
      printf("No");
   }
   
   return 0;
}
      

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

int main() {
  int N;
  cin>>N;
  int Z=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a%2==1){
      continue;
    }
    else if(a%3==0||a%5==0){
      continue;
    }
    else{
      Z++;
      break;
    }
  }
  if(Z==0){
    cout<<"APPROVED"<<endl;
  }
  else{
    cout<<"DENIED"<<endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

			int n = int.Parse(Console.ReadLine());
			long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
			long ans = 0;
			long min = long.MaxValue;
			for (int i = 0; i < n - 1; i++) {
				if (a[i] < 0) {
					a[i] = -a[i];
					a[i + 1] = -a[i + 1];
				}
				ans += a[i];
				min = Math.Min(min, a[i]);
			}
			System.Diagnostics.Debug.WriteLine(string.Join(" ", a));
			System.Diagnostics.Debug.WriteLine(min);
			if (a[n - 1] < 0 && min < -a[n - 1]) {
				ans -= min * 2;
				ans += -a[n - 1];
			} else {
				ans += a[n - 1];
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 31324
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Checkpoints
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;
const int MAX_M = 50;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int as[MAX_N], bs[MAX_N], cs[MAX_M], ds[MAX_M];

/* subroutines */

inline int mh_dist(int a, int b, int c, int d) {
  return abs(a - c) + abs(b - d);
}

/* main */

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> as[i] >> bs[i];
  for (int i = 0; i < m; i++) cin >> cs[i] >> ds[i];

  for (int i = 0; i < n; i++) {
    int mind = INF, minj = -1;
    for (int j = 0; j < m; j++) {
      int md = mh_dist(as[i], bs[i], cs[j], ds[j]);
      if (mind > md) mind = md, minj = j;
    }

    printf("%d\n", minj + 1);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	string s;
 	cin >> s;
 	cout << string(sz(s), 'x');
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <climits>
#include <set>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::string;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

int num_divisors(int n) {

	int divs = 0;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			divs += 2;
		}
	}

	return divs;

}

int main() {

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

	int n;
	cin >> n;

	if (n < 105) {
		cout << 0 << "\n";
	} else {
		int count = 0;
		for (int i = 105; i <= n; i += 2) {
			if (num_divisors(i) == 8) {
				++count;
			}
		}

		cout << count << "\n";
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll ans;
int main(void){
    string s; cin>>s;
    ll n=s.size();
    for(int i=0;i<n;i++){
        ans=ans*10+s[i]-'0';
    }
    for(ll bit=1;bit<(1<<(n-1));bit++){
        ll sum=0;
        ll l=0;
        ll k=0;
        for(ll i=0;i<n;i++){
            l=0;
            if(bit&(1<<i)){
                for(ll j=k;j<=i;j++){
                    l=l*10+s[j]-'0';
                }
                sum+=l;
                k=i+1;
            }
        }
        l=0;
        for(ll j=k;j<n;j++){
            l=l*10+s[j]-'0';
        }
        sum+=l;
        ans+=sum;
        //cout<<sum<<endl;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
void Sort(int &a, int &b, int &c){
    if (a > b)
        std::swap(a, b);
    if (a > c)
        std::swap(a, c);
    if (b > c)
        std::swap(b, c);
}
int main(int argc, const char * argv[]) {
    int a, b, c;
    cin >> a >> b >> c;
    Sort(a,b,c);
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 3216
N = int(input())
S = input()

char = []
num = 1
while(len(S) > 0):
    num = num * (S.count(S[0]) + 1)
#    print(S[0] + " : count = {}, num = {}".format(S.count(S[0]), num))
    S = S.replace(S[0], "")

num = num - 1
print(num % 1000000007)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,b;
     cin>>t>>b;
     b--;
     t--;
     cout<<ceil(b/(t*1.0))<<endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll t=1;
ll n,x,k;
string s;

// <------------- Implement Functions Here ----------> //

  
long long exponentiation(long long base, 
                        long long exp) 
{ 
    if (exp == 0) 
        return 1; 
  
    if (exp == 1) 
        return base % N; 
  
    long long t = exponentiation(base, exp / 2); 
    t = (t * t) % N; 
  
    // if exponent is even value 
    if (exp % 2 == 0) 
        return t; 
  
    // if exponent is odd value 
    else
        return ((base % N) * t) % N; 
} 

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>k;
	n++;
	ll val  = exponentiation(2,MOD-2);
	//ll sum_f = (k%MOD * (k-1)%MOD * val%MOD)%MOD; 
	//ll sum_l = ((n%MOD*(n-1)%MOD * val%MOD)%MOD - sum_f + MOD)%MOD;
	ll sum_f=0,sum_l=0;

	for(ll i=0,j=n-1;i<k;i++,j--) {
		sum_f = (sum_f + i)%MOD;
		sum_l = (sum_l + j)%MOD;
	}

	ll diff = 0,ans = 0;

	for(ll i = k;i<=n;i++) {
		//deb2(sum_l,sum_f);
		diff = (sum_l - sum_f +1+MOD)%MOD;
		ans = (ans + diff)%MOD;
		sum_f = (sum_f + i)%MOD;
		sum_l = (sum_l + n - i -1 + MOD)%MOD;
	}
	cout<<ans;newl;
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 238000
import sys
buf = sys.stdin.buffer
input = buf.readline
class BIT:
    def __init__(self, n):
        self.n = n
        self.tree = [0] * (n + 1)
    def add(self, i, x):
        n, tree = self.n, self.tree
        while i <= n:
            tree[i] += x
            i += i & -i
    def sum(self, i):
        tree = self.tree
        s = 0
        while i:
            s += tree[i]
            i -= i & -i
        return s
def main():
    n, q = map(int, input().split())
    res = [0] * q
    *c, = map(int, input().split())
    q = [(i, l, r) for i, (l, r) in enumerate(zip(*[map(int, buf.read().split())] * 2))]
    q.sort(key=lambda x:x[2])
    bit = BIT(n + 2)
    add, sum = bit.add, bit.sum
    b = [1] * (n + 1)
    j = 1
    for i, l, r in q:
        while j <= r:
            d = c[j - 1]
            j += 1
            k = b[d]
            b[d] = j
            add(k + 1, 1)
            add(j + 1, -1)
        res[i] = sum(l + 1)
    print(' '.join(map(str, res)))
main()

Measured memory_bytes: 269640
#include <iostream>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;

int solve(int x,int p){
	return floor(p*(1+x*0.01));
}

int main() {
	int n;
	int a[6][10];
	memset(a,0,sizeof(a));
	while(cin >> n && n){
		for(int i=0;i<n;i++) for(int j=0;j<5;j++) cin >> a[j][i];
		int sum=0;
		int csum;
		do{
			csum=sum;
			for(int i=0;i<n;i++){
				int current=0;
				int count=0;
				int start;
				for(int j=0;j<6;j++){
					if(current != a[j][i]){
						if(count>=3){
							sum+=count*current;
							for(int k=1;k<=count;k++){
								a[j-k][i]=0;
							}
//							cout << "count:" << count << endl;
//							cout << "current:" << current << endl;
						}
						current = a[j][i];
						count=1;
					} else {
						count++;
					}
				}
			}
/*			for(int i=0;i<n;i++){
				for(int j=0;j<5;j++){
					cout << a[j][i] << " ";
				}
				cout << endl;
			}*/
			for(int j=0;j<5;j++){
				for(int i=n-1;i>0;i--){
					if(a[j][i]==0){
						for(int k=i-1;k>=0;k--){
							if(a[j][k]!=0){
//								cout << j << " swap " << i << " " << k << endl;
								swap(a[j][k],a[j][i]);
								break;
							}
						}
					}
				}
			}
		}while(csum!=sum);
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());

    int n = b - a;

    System.out.println(n * (n + 1) / 2 - b);
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <fstream>
#include <memory.h>
#include <iomanip>
#include <omp.h>
#include <bitset>
#include <string>
#include <list>

using namespace std;

#define right asfdsg
#define left asfdsvs
#define MAXN 1000000000
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define x1 asicvlid
#define y1 ascnsdkn

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int st[20][200500];
int a[200500];
int n;
int lg[200500];
ll ans = 0;

void bld () {
    for (int i = 2; i <= n; i ++)
        lg[i] = lg[i >> 1] + 1;
    for (int k = 1; k <= lg[n]; k ++) {
        for (int i = 1; i <= n - (1 << k) + 1; i ++)
            st[k][i] = min (st[k - 1][i], st[k - 1][i + (1 << (k - 1))]);
    }
}

int get(int l, int r) {
    int k = lg[r - l + 1];
    return min (st[k][l], st[k][r - (1 << k) + 1]);
}

int main() {
    scanf ("%d", &n);
    for (int i = 1; i <= n; i ++)
        scanf ("%d", &a[i]),
        st[0][i] = a[i];
    bld ();
    for (int i = 1; i <= n; i ++) {
        int l = 1;
        int r = i;
        while ( l != r ) {
            int m = (l + r) >> 1;
            if (get(m, i) < a[i])
                l = m + 1;
            else r = m;
        }
        int mxL = l;
        l = i;
        r = n;
        while ( l != r ) {
            int m = (l + r + 1) >> 1;
            if (get(i, m) < a[i])
                r = m - 1;
            else l = m;
        }
        int mxR = l;
        ll cnt = 1ll * (mxR - i) * (i - mxL) + (mxR - mxL) + 1ll;
        ans += cnt * a[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 14848
def main():
    N, T = map(int, input().split())
    ans = float("Inf")
    for _ in range(N):
        c, t = map(int, input().split())
        if t <= T:
            ans = min(ans, c)
    if ans == float("Inf"):
        print("TLE")
    else:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int s[100];
int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    bool inc=true;
    rep(i,n-1)if(a[i]>=a[i+1])inc=false;
    if(inc){
        cout<<1<<endl;
        return 0;
    } 
    int ng=1,ok=n;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        rep(i,min(a[0],100))s[i]=1;
      	REP(i,a[0],100)s[i]=0;
        bool tempura=true;
        rep(i,n-1){
            if(a[i+1]>a[i])REP(j,a[i],min(100,a[i+1]))s[j]=1;
            else {
              	if(a[i+1]>100)continue;
                REP(j,a[i+1],min(100,a[i]))s[j]=0;
                bool can=false;
                for(int j=a[i+1]-1;j>=0;--j){
                    if(s[j]<mid){
                        ++s[j];
                        REP(k,j+1,a[i+1])s[k]=1;
                        can=true;
                        break;
                    }
                }
                if(!can){
                    tempura=false;
                    break;
                }
            }
        }
        if(tempura)ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
    return 0;
}


Measured memory_bytes: 1024
// E - Colorful Blocks

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
const ll MOD = 998244353;

class Comb {
private:
	int MOD;
	long long* fac;
	long long* finv;
	long long* inv;
public:
	// 事前にテーブルを作成
	Comb(int MAX, int MOD) {
		this->MOD = MOD;

		fac = new long long[MAX + 1];
		finv = new long long[MAX + 1];
		inv = new long long[MAX + 1];

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

	~Comb() {
		delete[] fac, finv, inv;
	}

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

// aのn乗をmodで割った余りを計算
ll mod_pow(ll a, ll n, ll mod) {
	ll result = 1;
	while (n > 0) {
		if (n & 1) result = result * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return result;
}

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

	Comb comb = Comb(N, MOD);

	ll ans = 0;
	for (int k=0; k<=K; k++) {
		//ans += M * mod_pow(M-1, N-1-k, MOD) * comb.calc(N-1, k);
		ans = (ans + (((M * mod_pow(M-1, N-1-k, MOD)) % MOD) * comb.calc(N-1, k)) % MOD) % MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8008
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split(' ').Select(ss => int.Parse(ss)).ToArray();
            int A = n[0];
            int B = n[1];
            
            string s = Console.ReadLine();
            bool ok = true;
            for(int i = 0 ; i < A ;i++)
            {
                if(s[i]=='-') ok = false;
            }
            if(s[A] != '-') ok = false;
            for(int i = A+1 ; i < A+B ;i++)
            {
                if(s[i] == '-') ok = false;
            }
            
            if(ok) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13268
//============================================================================
// Name        : KochCurve.cpp
// Author      : Ken
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
using namespace std;

const double PI = 3.141592653589793238463;
const double cos_pi_3 = cos(PI/3.0);
const double sin_pi_3 = sin(PI/3.0);

struct Point{
	double x;
	double y;
};

void drawNewSegment(Point& P1, Point& P2, Point& P3, Point& P4, Point& P5){
	P3.x = (P1.x * 2 + P2.x * 1) / 3.0;
	P3.y = (P1.y * 2 + P2.y * 1) / 3.0;

	P5.x = (P1.x * 1 + P2.x * 2) / 3.0;
	P5.y = (P1.y * 1 + P2.y * 2) / 3.0;

	double P1_P3_x = P3.x - P1.x;
	double P1_P3_y = P3.y - P1.y;

	P4.x = P3.x + (P1_P3_x * cos_pi_3 - P1_P3_y * sin_pi_3);
	P4.y = P3.y + (P1_P3_x * sin_pi_3 + P1_P3_y * cos_pi_3);
}

vector<Point> drawNewCurve(vector<Point>& v){
	vector<Point> new_v;

	for(int i=0; i<v.size()-1; i++){
		Point P3, P4, P5;
		drawNewSegment(v.at(i), v.at(i+1), P3, P4, P5);

		new_v.push_back(v.at(i));
		new_v.push_back(P3);
		new_v.push_back(P4);
		new_v.push_back(P5);
		//new_v.push_back(v.at(i+1));
	}

	new_v.push_back(v.at(v.size()-1));

	return new_v;
}

void writePointVector(vector<Point>& v){
	for(int i=0; i<v.size(); i++){
		cout << setprecision(9) << v.at(i).x;
		cout << " ";
		cout << setprecision(9) << v.at(i).y << "\n";
	}
}

int main() {
	vector<Point> v;
	vector<Point> next_v;
	Point P1, P2;
	P1.x = 0;
	P1.y = 0;

	P2.x = 100;
	P2.y = 0;

	v.push_back(P1);
	v.push_back(P2);

	int n;
	cin >> n;

	for(int i=0; i<n; i++){
		next_v = drawNewCurve(v);
		v = next_v;
	}

	writePointVector(v);

	return 0;
}



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

int main(){
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    
    int ans = 0;
    for (int i = 0;i <= N/R;i++){
        for (int j = 0;j <= (N - R*i)/G;j++){
            int M = R*i + G*j;
            if((N-M)%B == 0) ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const int Maxn = 100000;
const int Mod = 1000000000 + 7;
int n;
string S;
int main()
{
    cin>>S;
    n = 0;
    for (int i = 0; i < S.size(); i++)
        if(S[i] == '1')
            n++;
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		long ans = 0;
		for(int mask = 0 ; mask < 1<<(n - 1) ; mask++) {
			String temp = s.charAt(0)  + "";
			for(int i = 0 ; i < n - 1 ; i++) {
				if((mask&(1<<i)) >= 1) {
					temp += "+" + s.charAt(i + 1);
				} else {
					temp += s.charAt(i + 1);
				}
			}
			String[] split = temp.split("\\+");
			for(int i = 0 ; i < split.length ; i++) {
				ans += Long.valueOf(split[i]);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26068
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;


 int main()
 {
   int n;
   long long int arr[202];
   while(cin>>n)
   {
     int min=100;
     for(int i=0;i<n;i++) cin>>arr[i];
     for(int i=0;i<n;i++)
     {
       int cnt=0;
       while(arr[i]%2==0)
       {
         arr[i]/=2;
         cnt++;                  
       }       
       if(cnt<min) min=cnt; 
     } 
     cout<<min<<endl;
   }
   return 0;
 }
 


Measured memory_bytes: 256
import numpy as np

n=int(input())
d=np.zeros((n))
for i in range(n):
    d[i]=int(input())

#print(n)                                                                                                     
#print(d[:])                                                                                                  

ans=n
for i in range(n):
    flag=0
    for j in range(n-i-1):
        if(d[i]==d[i+j+1]):
            flag=flag+1
    if(flag!=0):
        ans=ans-1
#    print('j=',j)                                                                                            
#    print(flag)                                                                                              
#    print(ans)                                                                                               

print(ans)


Measured memory_bytes: 20356
#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, char *argv[])
{
  int n, k, i;
  int *w;
  int max = 0, sum = 0;
  int P_st, P_ed, P_center, k_st, k_ed, k_center, p[3];
 
  scanf("%d", &n);
  scanf("%d", &k);
  w = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) {
    scanf("%d", &w[i]);
    sum += w[i];
    if (max < w[i]) max = w[i];
  }
 
  P_st = max - 1;
  P_ed = sum;
  p[0] = 0;
  p[1] = 0;
  k_st = 1;
  k_ed = 1;
  for (i = 0; i < n; i++) {
    if (p[1] + w[i] > P_ed) {
      k_ed++;
      p[1] = 0;
    }
    p[1] += w[i];
  }
  k_st = 100001;
 
  while (1) {
    P_center = (P_st + P_ed) / 2;
    p[2] = 0;
    k_center = 1;
    for (i = 0; i < n; i++) {
      if (p[2] + w[i] > P_center) {
    if (p[2] == 0) {
      k_center = 100001;
      break;
    }
    k_center++;
    p[2] = 0;
      }
      p[2] += w[i];
    }
    if (k_center > k) {
      P_st = P_center;
      k_st = k_center;
    } else {
      P_ed = P_center;
      k_ed = k_center;
    }
    if (P_ed - P_st <= 1) break;
  }
 
  printf("%d\n", P_ed);
 
  free(w);
 
  return 0;
}
 
  

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

int mx = 0;
int n;
string s;


int nextfree = 1;
class trie {
	uint32_t d[20] = {0};
public:
	int first;
	int depth;

	int nxt(int i) {
		int s = i * 24, t = s + 24;
		int sa = s / 32, sb = s % 32;
		int ta = t / 32, tb = t % 32;
		if (sa == ta) {
			return d[sa] & ((1 << 24) - 1);
		}
		return (d[sa] >> sb) | ((d[ta] & ((1 << tb) - 1)) << (24 - tb));
	}
	void setnxt(int i, uint32_t v) {
		int s = i * 24, t = s + 24;
		int sa = s / 32, sb = s % 32;
		int ta = t / 32, tb = t % 32;
		if (sa == ta) {
			d[sa] = v | ((d[sa] >> 24) << 24);
			return;
		}
		d[sa] = d[sa] & ((1 << sb) - 1) | (v << sb);
		d[ta] = ((d[ta] >> tb) << tb) | (v >> (24 - tb));
	}
	//trie(int f, int d): first(f), depth(d) {}
} t[5000 * 5001 / 2 * 5 / 6];

void f(int i_nxt, int first, trie& pre) {
	if (i_nxt >= n || i_nxt - first > n / 2) return;
	int tc = s[i_nxt] - 'a';
	if (pre.nxt(tc) == 0) {
		pre.setnxt(tc, nextfree++);
		t[pre.nxt(tc)].first = first;
		t[pre.nxt(tc)].depth = pre.depth + 1;
	}
	trie& now = t[pre.nxt(tc)];
	int d = now.depth;
	if (now.first + d <= first) {
		chmax(mx, d);
	}
	return f(i_nxt + 1, first, now);
}

int main() {
	cin >> n;
	cin >> s;
	rep(i, n) {
		f(i, i, t[0]);
	}
	cout << mx << endl;
}



Measured memory_bytes: 895744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    string s;cin>>s;
    ll x[2];cin>>x[0]>>x[1];
    ll n=(ll)s.size();
    set<ll> st[2][n];
    st[0][0].insert(0);
    st[1][0].insert(0);
    vector<ll> v[2];
    ll now=0;
    ll sum=0;
    rep(i,0,n-1){
        if(s[i]=='T'){
            v[now].pb(sum);
            now=1-now;
            sum=0;
        }else{
            sum++;
        }
    }
    if(sum>0){
        v[now].pb(sum);
    }
    rep(j,0,1){
        rep(i,0,(ll)v[j].size()-1){
            for(auto it=st[j][i].begin();it!=st[j][i].end();++it){
                ll k=*it;
                st[j][i+1].insert(k+v[j][i]);
                if(j==0 && i==0){
                    
                }else{
                    st[j][i+1].insert(k-v[j][i]);
                }
            }
        }
    }
    string ans="Yes";
    rep(j,0,1){
        auto it=st[j][(ll)v[j].size()].find(x[j]);
        if(it==st[j][(ll)v[j].size()].end()){
            ans="No";
        }
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}





Measured memory_bytes: 236124
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp(a,b) make_pair(a,b)
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };
int p[100005], q[100005];
signed main() {
	int w, h; cin >> w >> h;
	rep(i, w)cin >> p[i];
	rep(i, h)cin >> q[i];

	priority_queue<P, vector<P>, greater<P>>Q;
	rep(i, w)Q.push(P(p[i], 0));
	rep(i, h)Q.push(P(q[i], 1));
	int ans = 0;
	int uw = 0, uh = 0;
	while (Q.size()) {
		P x = Q.top();
		Q.pop();
		if (x.second) {
			ans += x.first*(w +1-uw);
			uh++;
		}
		else {
			ans += x.first*(h +1- uh);
			uw++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8048
# -*- coding: utf-8 -*-
a = str(input())

pre = a[0]
chenge = 0
for i in range(1,len(a)):
    if pre == "0" and a[i] == "0":
        a = a[:i] + "1" + a[i+1:]
        chenge += 1
    elif pre == "1" and a[i] == "1":
        a = a[:i] + "0" + a[i+1:]
        chenge += 1
    else:
        pass
    pre = a[i]

print(chenge)

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

const int MAX_N = 1000;
const ll INF = 1LL<<60;

int n, m;
vector<vector<ll>> dist(MAX_N, vector<ll>(MAX_N, INF));

void init()
{
  cin >> n >> m;
  rep(i,n) dist[i][i] = 0;
  rep(i,m)
  {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    dist[a][b] = c;
  }
  return;
}

void wf()
{
  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < n; j++)
    {
      for(int k = 0; k < n; k++)
      {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
}

void put()
{
  rep(i,n)
  {
    if(dist[i][i] < 0)
    {
      cout << "NEGATIVE CYCLE" << endl;
      return;
    }
  }
    
  rep(i,n)
  {
    rep(j,n)
    {
      if(dist[i][j] >= INF/2) cout << "INF";
      else cout << dist[i][j];
      cout << ((j == n-1)? "\n" : " ");
    }
  }
  return;
}

int main()
{
  init();
  wf();
  put();
  return 0;
}


Measured memory_bytes: 10640
function main(input){
	input = input.split("\n");
	input=stn(input);
	var fee=input[2];
	var sum=0;
	for(var i=1;i<=input[0];i++){
		if(i>input[1]){
			fee=input[3];
		}
		sum+=fee;
	}
	op(sum);
}
function stn(a){
	return a.map(function(x){return parseInt(x,10);});
}
function op(a){
	console.log(a);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    ll n,a,b;
    cin >> n >> a >> b;

    if((a&1) == (b&1)){
	P((b-a)/2);
    }else{
	P(min(a-1, n-b ) + 1 + (b-a-1)/2);
    }
    return  0;
}


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

int main(){
  int N,i,j;
  int count=0;
  cin >> N;
  vector<int> mochi(N);
  for(i=0;i<N;++i){
    cin >> mochi.at(i);
  }
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;++j){
      if(mochi.at(i) == mochi.at(j)){
        mochi.at(j) = -1; 
      }
    }
  }
  for(i=0;i<N;i++){
    if(mochi.at(i) != -1)
    count += 1;
  }
  
     cout << count << endl;

}

Measured memory_bytes: 256
s = input()
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        break
    try:
        if s[i] == s[i+2] or s[i+1] == s[i+2]:
            print(i+1, i+3)
            break
    except :
        pass
else:
    print(-1, -1)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

void err() {
	puts(-1);
	exit(0);
}

int main() {
	string s, t;
	cin >> s >> t;
	vector<int>scnt[26];
	for (int i = 0; i < s.size(); i++) {
		scnt[s[i] - 'a'].pb(i);
	}

	ll shuuki = 0;
	int cur = -1;
	ll ans = 0;
	for (int i = 0; i < t.size(); i++) {
		if (scnt[t[i] - 'a'].size() == 0)err();
		if (scnt[t[i] - 'a'].back() <= cur) {
			cur = -1;
			shuuki++;
		}
		cur = *upper_bound(all(scnt[t[i] - 'a']),cur);
	}
	puts((int)s.size()*shuuki + cur + 1);

	return 0;
}

Measured memory_bytes: 1216