akhauriyash/Code-Regression huggingface dataset:
n = int(input())
B_list = list(map(int, input().split()))
A_list = []

for i in range(n-1):
    if i == 0:
        A_list.append(B_list[i])
    elif i >= 1:
        if B_list[i-1] <= B_list[i]:
            A_list.append(B_list[i-1])
        else:
            A_list.append(B_list[i])
A_list.append(B_list[-1])
print(sum(A_list))

Measured memory_bytes: 3060
extension String:CollectionType{}
func readInts()->[Int]{
  return readLine()!.split(" ").map{Int($0)!}
}
var a:[Int]=readInts()
var n=a[0]
var k=a[1]
var h:[Int]=readInts()
var sh=h.sort{$0<$1}
var sum:Int64=0
if(n<=k){print(0)}
else{
  for i in 0..<n-k{
  sum=sum+sh[i]
}
print(sum)
}



Measured memory_bytes: 14948
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <stack>
using namespace std;
int main() {
    int n;
    cin >> n;
    int ar[n];
    int dp[n];
    for (int i = 0; i < n; i ++) {
        cin >> ar[i];
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    for (int i = 0; i < n; i ++) {
        if (i + 1 < n) {
            dp[i+1] = min(dp[i+1], dp[i] + abs(ar[i+1]-ar[i]));
        }
        if (i + 2 < n) {
            dp[i+2] = min(dp[i+2], dp[i] + abs(ar[i+2]-ar[i]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4392
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, c, d = sc.nextInt

  val res = (0 to 100).foldLeft(0) { (acc, n) =>
    if (a <= n && n < b && c <= n && n < d) acc+1 else acc
  }
  println(res)
}

Measured memory_bytes: 25520
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    ll D, N;
    cin >> D >> N;
    if (N != 100)
    {
        cout << (ll)pow(100, D) * N << endl;
    }
    else
    {
        cout << (ll)pow(100, D) * (N + 1) << endl;
    }
}


Measured memory_bytes: 3688
#include <iostream>
#include <set>

using namespace std;
typedef long long LL;

int main() {
    LL N;
    cin >> N;
    set<LL> s;
    for (LL i = 2; i * i <= N; i++) {
        if (!(N % i)) {
            LL tmp = N;
            while (!(tmp % i)) {
                tmp /= i;
            }
            if (tmp % i == 1) {
                s.insert(i);
            }
        }
    }
    for (LL i = 1; i * i <= N - 1; ++i) {
        if (!((N - 1) % i)) {
            s.insert(i);
            s.insert((N - 1) / i);
        }
    }
    s.erase(1);
    s.insert(N);
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
day = input()

if day == 'SUN' :
    print (7)

if day == 'MON' :
    print (6)

if day == 'TUE' :
    print (5)

if day == 'WED' :
    print (4)

if day == 'THU' :
    print (3)

if day == 'FRI' :
    print (2)

if day == 'SAT' :
    print (1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
#define pr(x) cout << x << endl;
using namespace std;

//const int mod = 998244353;
const int mod=1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// 出力は.xで！！！！

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

mint dp[202020];
int last[202020];

int main(){
  int n; cin >> n;
  vector<int> c(n);
  rep(i,n) cin >> c[i];
  rep(i,202020) last[i]=-1;
  dp[0]=1;
  last[c[0]]=0;
  for(int i=1; i<n; i++){
    dp[i]=dp[i-1];
    if(c[i]!=c[i-1] && last[c[i]]!=-1){
      dp[i]+=dp[last[c[i]]];
    }
    last[c[i]]=i;
  }
  pr(dp[n-1].x)
return 0;
}


Measured memory_bytes: 6416
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  ll n; cin >> n;
  map<ll,bool> num;
  rep(i,n){
    ll x; cin >> x;
    if(num[x]) num[x] = false;
    else num[x] = true;
  }
  ll ans = 0;
  for(auto c:num){
    if(c.second) ans++;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 6528
import java.util.*;
import java.math.*;
public class Main {
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		List<Integer> a = new ArrayList<>();
		
		for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
		}
		for (int i = 0; i < N; i++) {
			int r = a.get(i);
			if ((i+1) == a.get(r-1)) ans++;
		}
		
		ans = ans/2;
		
	 
		System.out.println(ans);
	
	}
}
			

Measured memory_bytes: 61256
import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

fun solve(sc: Scanner): String {
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()

    return when {
        c - a - b < 0 -> "No"
        4 * a * b < (c - a - b) * (c - a - b) -> "Yes"
        else -> "No"
    }
}


Measured memory_bytes: 31520
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
priority_queue<string> qq;
queue<string> tmpppp;
int cal(string k,int len ,int dd){
    int si = k.size();
    for(int i=0;i+len-1<si;i++){
        string tmp = k.substr(i,len);
        int fl =0;
        while(!qq.empty()){
            if(qq.top()==tmp){
                fl =1;
            }
            tmpppp.push(qq.top());
            qq.pop();
        }
        if(fl==1){
            while(!tmpppp.empty()){
                qq.push(tmpppp.front());
                tmpppp.pop();
            }
            continue;
        }
        while(!tmpppp.empty()){
                qq.push(tmpppp.front());
                tmpppp.pop();
            }
        qq.push(tmp);
        //cout<<qq.size()<<endl;
        if((int)qq.size()>dd){
            string cc = qq.top();
            qq.pop();
        }
    }
}
int main()
{
   // string nn = "1234366";
   // cout<<nn.substr(1,2);
    string str;
    while(cin>>str){
        while(!qq.empty()) qq.pop();
        int k;
        cin>>k;
        int len = str.size();
        int bb = min(5,len);
        for(int i=1;i<=bb;i++){
            cal(str,i,k);
        }
        string tmp = qq.top();
        cout<<tmp<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
char a[10],b[10];
int main()
{
    scanf("%s\n%s",a,b);
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int h,n,dp[20005],a[10005],b[10005];
int main()
{
    scanf("%d%d",&h,&n);
    rep(i,1,n) scanf("%d%d",a+i,b+i);
    rep(i,1,20000) dp[i]=inf;
    rep(i,1,n) rep(j,0,20000) {
        if(j>=a[i]) dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
    }
    int ans=inf;rep(i,h,20000) ans=min(ans,dp[i]);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let x: i32 = sc.read();
    let y: i32 = sc.read();

    let res = x * y - (x + y) + 1;
    println!("{}", res);
}



Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>

int main(){
char str[1001];
while(1){
scanf("%s",str);
if(str[0]=='0') break;
int sum=0;
for(int i=0;i<strlen(str);i++){
sum+=(str[i]-'0');
}
printf("%d\n",sum);
}
return 0;
}

Measured memory_bytes: 2704
console.log(function(args){
  const [[N],A,[Q],...tmp] = args.trim().split('\n').map( r=>r.split(' ').map( v=>v|0 ) );
  const sum = Array(Q+1).fill(0);
  sum[0] = 0;
  const a = new Map();
  for ( let i = 0; i < N; i++ ) {
    a.set(A[i], (a.get(A[i])|0) + 1 );
    sum[0] += A[i];
  }
  for ( let i = 0; i < Q; i++ ) {
    const [B,C] = tmp[i];
    if ( a.has(B) ) {
      const b = a.get(B);
      const c = a.has(C) ? a.get(C) : 0;
      sum[i+1] = sum[i] + b*C - b*B;
      a.set( C, c + b );
      a.delete( B );
    } else sum[i+1] = sum[i];
  }
  return sum.slice(1).join('\n');
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 83952
import numpy as np
def read_input():
  D = int(input())
  c = list(map(int, input().split()))
  s = [list(map(int, input().split())) for _ in range(D)]
  return D, c, s
D, c, s = read_input()

for t in np.array(s).argmax(axis=1)+1:
  print(t)

Measured memory_bytes: 27720
z[4000],*a=z,*b=z+2000,m,i,j,t;main(n){for(;scanf("%d",&n)*n++;m=!printf("%d\n",m))for(i=n;i--;j=a,a=b,b=j)for(j=n;j--;t>m?m=t:0)t=b[j]=n+~i&&getchar()>45?1+fmin(a[j],fmin(b[j+1],a[j+1])):0;}

Measured memory_bytes: 0
class Dice():
    def __init__(self, labels):
        self.top = labels[0]
        self.front = labels[1]
        self.right = labels[2]
        self.left = labels[3]
        self.back = labels[4]
        self.bottom = labels[5]

    def roll(self, axis, count=1):
        while count < 0:
            count += 4
        if axis == "X":
            for _ in range(count):
                self.top, self.back, self.bottom, self.front = self.front, self.top, self.back, self.bottom
        elif axis == "Y":
            for _ in range(count):
                self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom
        elif axis == "Z":
            for _ in range(count):
                self.front, self.left, self.back, self.right = self.right, self.front, self.left, self.back
        elif axis == "N":
            self.roll("X", 1)
        elif axis == "W":
            self.roll("Y", -1)
        elif axis == "S":
            self.roll("X", -1)
        elif axis == "E":
            self.roll("Y", 1)


labels = [int(c) for c in input().split()]
operations = input()
d = Dice(labels)
for o in operations:
    d.roll(o)
print(d.top)



Measured memory_bytes: 5612
N=int(input())
S=[1]
for i in range(1,N):
  S.append(S[i-1]+i+1)
p=0
j=0
if N==1:
  print(1)
else:
  while N>=S[j]:
    j += 1
  p=S[j]-N
  for i in range(1,j+2):
    if i!=p:
      print(i)

Measured memory_bytes: 193204
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		String t;
		double[] p = new double[12];
		double s,r;
		while((t=bf.readLine())!=null){
			String[] d=t.split(",");
			for(int i=0;i<8;i++)p[i]=Double.parseDouble(d[i]);
			for(int i=0;i<4;i++)p[i+8]=p[i];
			s=((p[3]-p[1])*(p[2]-p[4])-(p[2]-p[0])*(p[3]-p[5]));
			for(int i=4;i<=8;i+=2){
				r=((p[i+1]-p[i-1])*(p[i]-p[i+2])-(p[i]-p[i-2])*(p[i+1]-p[i+3]));
				if(s*r<0){System.out.println("NO");break;}
				if(i==8)System.out.println("YES");
			}
		}
	}
}

Measured memory_bytes: 9780
#include<bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  priority_queue<int,vector<int>,greater<int> > q;
  int a,b,c[1000000]={};
  int d,e;
  int f;
  vector<pair<int,int> > p;
  cin>>a>>b;
  for(int i=0;i<a;i++){
    cin>>c[i];
    q.push(c[i]);
  }
  sort(c,c+a);
  for(int i=0;i<b;i++){
    cin>>d>>e;
    p.push_back(make_pair(e,d));
  }
  sort(p.begin(),p.end(),greater<pair<int,int> >());
  for(int i=0;i<b;i++){
    f=q.top();
    if(f<p[i].fi){
      for(int j=0;j<p[i].se;j++){
        f=q.top();
        if(f<p[i].fi){
          q.pop();
          q.push(p[i].fi);
        }
        else break;
      }      
    }
    else break;
  }
  f=0;
  for(int i=0;i<a;i++){
    f+=q.top();
    q.pop();
  }
  cout<<f<<"\n";
} 

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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int ss = Integer.parseInt(br.readLine());
		System.out.print(ss/3600 + ":");
		int s =ss%3600;
		System.out.print(s/60 +":");
		int m = s%60;
		System.out.println(m%60);
	}
}

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

int main() {
  int n;
  int bob = 0;
  int alice = 0;
  int data[105];

  cin >> n;
  for ( int i = 0; i < n; i++) {
    cin >> data[i];
    data[i] *= -1;
  }

  sort(data, data + n);

  for ( int i = 0; i < n; i++) {
    if ( i % 2 == 1 ) {
      bob -= data[i];
    } else {
      alice -= data[i];
    }
  }

  cout << alice - bob << endl;

  return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;



int main() {
	int n, m;
	cin >> n >> m;
	vector<int> L(m);
	vector<int> R(m);
	for (int i = 0; i < m; i++) {
		cin >> L[i] >> R[i];
	}
	cout << max(0,(*min_element(R.begin(), R.end()) - *max_element(L.begin(), L.end())+1)) << endl;
	return 0;
}

Measured memory_bytes: 1024
import numpy as np
S=list(input())
S=[True if i=="0" else False for i in S]
stripeA=[True]*len(S)
stripeB=[True]*len(S)
for i in range(len(S)):
    if i%2==0:
        stripeA[i]=False
    else:
        stripeB[i]=False
stripeA=list(np.logical_xor(S,stripeA))
stripeB=list(np.logical_xor(S,stripeB))
stripeA=stripeA.count(True)
stripeB=stripeB.count(True)
if stripeA>stripeB:
    print(stripeB)
else:
    print(stripeA)

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

int main(){
	long long S;
	cin >> S;
	
	const int v = 1000000000;
	
	int x = (v - S % v) % v;
	int y = (S + x) / v;
	
	cout << "0 0 1000000000 1 " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import collections


def solve(ds, ts):
    ctr_d = collections.Counter(ds)
    ctr_t = collections.Counter(ts)
    delta_ctr = collections.Counter({k: ctr_d[k] - v for
                                     k, v in ctr_t.items()})
    return all(v >= 0 for v in delta_ctr.values())


def main():
    _ = input()
    ds = [int(d) for d in input().split()]
    _ = input()
    ts = [int(t) for t in input().split()]
    print("YES" if solve(ds, ts) else "NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 81496
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let solve xs =
    let rec loop acc c = function
        | [] -> c :: acc
        | (a, b) :: xs ->
            if a >= b then
                loop acc (c + 1) xs
            else
                loop (c :: acc) 0 xs
    loop [] 0 xs

[<EntryPoint>]
let main _ =
    let n = read int
    let hs = reads int
    let xs = Seq.zip hs (List.tail hs) |> Seq.toList
    solve xs
    |> List.max
    |> printfn "%i"
    0

Measured memory_bytes: 37656
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N;
    io.read(N);
    cout << N / 3;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,w;
    scanf("%lld%lld",&n,&w);
    ll we[n],v[n];
    rep(i,0,n){
        scanf("%lld%lld",&we[i],&v[i]);
    }
    ll dp[n][w+1];
    rep(i,0,we[0]){
        dp[0][i]=0;
    }
    rep(i,we[0],w+1){
        dp[0][i]=v[0];
    }
    rep(i,1,n){
        rep(j,0,w+1){
            dp[i][j] = j>=we[i] ? max2( dp[i-1][j-we[i]]+v[i] , dp[i-1][j] ) : dp[i-1][j];
        }
    }
    
    printf("%lld\n",dp[n-1][w]);
    return 0;
}


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

int main()
{
    int n,i;
    cin>>n;
    vector<int>v(n),c(n);
    for(i=0; i<n; i++){
        cin>>v[i];
    }
    for(i=0; i<n; i++){
        cin>>c[i];
    }
    int res=0;
    for(i=0; i<n; i++){
        if(v[i]-c[i]>0){ res+=v[i]-c[i];}
    }
    cout<<res<<endl;
    return 0;
}


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

MOD=10**9+7

sm=0
tmp=0
b=1
for i in range(1,N+2):
    if i!=0:
        b=(b-2*(i-1))%MOD
    else:
        b=1
    #print(b)
    val=(i*N+b)%MOD
    sm=(sm+val)%MOD
    if i<K:
        tmp=(tmp+val)%MOD
#print(sm)
#print(tmp)
ans=(sm-tmp)%MOD
print(ans%MOD)

Measured memory_bytes: 64312
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s.substr(i, 3) == "ABC")
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

using ll = long long;
using namespace std;

int n, w, weight[101], value[101];
ll dp[101][100001];

ll solve(int index, int weight_took)
{
	if (index == n || weight_took >= w)
		return weight_took > w ? -1e17 : 0;

	ll &dp = ::dp[index][weight_took];
	
	if (dp != -1)
		return dp;
	dp = -1e17;
	
	dp = max(solve(index + 1, weight_took), solve(index + 1, weight_took + weight[index]) + value[index]);

	return dp;
}

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

#ifdef LOCAL_DEFINE
	freopen("in.txt", "r", stdin);
#endif

	cin >> n >> w;
	for (int i = 0; i < n; ++i)
	{
		cin >> weight[i] >> value[i];
	}

	memset(dp, -1, sizeof(dp));

	ll ans = solve(0, 0);

	if (ans <= -1e17)
		ans = 0;

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int N;
    cin >> N;
    int T[100000];
    int total = 0;
    for(int i = 0; i < N; ++i){
        cin >> T[i];
        total += T[i];
    }
    int M;
    cin >> M;
    vector<P> px(M);
    for(int i = 0; i < M; ++i) cin >> get<0>(px[i]) >> get<1>(px[i]);

    for(int i = 0; i < M; ++i){
        cout << total - T[get<0>(px[i]) - 1] + get<1>(px[i]) << endl;;
    }

    return 0;
}


Measured memory_bytes: 256
n,k,q=(int(x) for x in input().split())
a=[]
p=[0]*n
for i in range(0,q):
    temp=int(input())
    p[temp-1]+=1
border=-k+q


for j in range(0,n):
    if p[j]> border:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 4680
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops,rename-registers")
//#pragma GCC target("sse4,avx,avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <chrono>
#include <random>
#include <string>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <sstream>
#include <numeric>
#include <complex>
#include <immintrin.h>
#include <unordered_set>

using namespace std;

using ll = long long;
using ld = long double;
using VectorType = ld;
using ull = unsigned long long;

const ll INF = 1e15;
const ld eps = 1e-7;
const ld pi = atan2(0, -1);
const ll mod = 1e9 + 7;
const ll P = 179, Q = 239;
const ll A = 26;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

ll sign(ll a) {
	if (a < 0) return -1;
	if (a == 0) return 0;
	return 1;
}

bool equal(ld a, ld b) {
	return abs(a - b) < eps;
}

struct query {
	ll l, r, i;

	query(ll l = 0, ll r = 0, ll i = 0) : l(l), r(r), i(i) {};
};

bool mini(ll &a, ll b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

bool maxi(ll &a, ll b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool mini(ld &a, ld b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

ll mmax(ll a, ll b) {
	if (a > b) return a;
	return b;
}

ll mmin(ll a, ll b) {
	if (a < b) return a;
	return b;
}

ld mmax(ld a, ld b) {
	if (a > b) return a;
	return b;
}

ld mmin(ld a, ld b) {
	if (a < b) return a;
	return b;
}

bool maxi(ld &a, ld b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

ll sub(ll a, ll b) {
	a -= b;
	if (a < 0) {
		a += mod;
	}
	return a;
}

ll add(ll a, ll b) {
	a += b;
	if (a > mod) {
		a -= mod;
	}
	return a;
}

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

ll n, m;
ll k;
vector <vector <ll>> vec;
vector <bool> used;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll a, b;
	cin >> k >> a >> b;
	ll l = (a + k - 1) / k * k, r = b / k * k;
	if (l <= r) {
		cout << "OK\n";
	}
	else {
		cout << "NG\n";
	}
	return 0;
}

Measured memory_bytes: 3660
import math
a,v = [int(x) for x in input().split(' ')]
b,w = [int(x) for x in input().split(' ')]
t = int(input())

sp = v-w
if sp <= 0:
    print('NO')
else:
    t_ = abs(a - b) / sp
    if t_ > t:
        print('NO')
    else:
        print('YES')

Measured memory_bytes: 9188
#include <iostream>
using namespace std;
typedef long long ll;

ll fac[1000005];
ll ans = 0;

const ll mod = 1e9 + 7;
ll f(ll a, ll x) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}



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

  fac[0] = 1;
  for(int i = 1; i <= max(x,y); i++) fac[i] = fac[i-1] * i % mod;

  for(int i = 0; i <= x; i++) {
    int yy = y - 2 * i;
    if(yy < 0) continue;
    if((i + 2 * yy) == x) {
      ans = (ans + fac[i+yy] * f(fac[i] * fac[yy] % mod,mod-2)) % mod;
    }
  }

  cout << ans << endl;
}


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

int main()
{
	string st;
	cin>>st;
//	int len=st.length();
	
	for(int i=1;i<st.size();i++)
	{
		if(i>=1&&st[i-1]=='S'&&st[i]=='T')
		{
			st.erase(i-1,2);
			i=i-2;	
		}	
	}
	cout<<st.length()<<endl;	
	
} 

Measured memory_bytes: 640
from bisect import bisect

n = int(input())
ma = [-int(input()) for _ in range(n)]

ans = [ma[0]]
for ai in ma[1:]:
    tmp = bisect(ans, ai)
    if tmp == len(ans):
        ans.append(ai)
    elif tmp < len(ans):
        ans[tmp] = ai
print(len(ans))


Measured memory_bytes: 84956
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> edge(n);
    vector<int> dgr(n, 0);
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(make_pair(b, i));
        edge[b].push_back(make_pair(a, i));
        dgr[a]++;
        dgr[b]++;
    }
    vector<int> col(n - 1, -1);
    vector<bool> visited(n, false);
    int k = *max_element(all(dgr));
    queue<pair<int, int>> que;
    que.push(make_pair(0, -1));
    visited[0] = true;
    while(!que.empty()) {
        auto now = que.front();
        que.pop();
        int c = now.second + 1;
        c %= k;
        for(auto next : edge[now.first]) {
            if(visited[next.first]) {
                continue;
            } else {
                que.push(make_pair(next.first, c));
                col[next.second] = c;
                c++;
                c %= k;
                visited[next.first] = true;
            }
        }
    }
    cout << k << endl;
    for(int i = 0; i < n - 1; i++) {
        cout << col[i] + 1 << endl;
    }
}

Measured memory_bytes: 7424
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  char s[51];
  scanf ("%s", s);
  k--;
  if (s[k] == 'A') {
    s[k] = 'a';
  } else if (s[k] == 'B') {
    s[k] = 'b';
  } else {
    s[k] = 'c';
  }
  puts (s);
}

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


Measured memory_bytes: 128
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const int N=2000;
int n,m,s;
char a[N+5],b[N+5],c[N+5];
bool eq(char x,char y){return x=='?'||y=='?'||x==y;}
bool pre_a[N+1],rg_a[N+1],suf_a[N+1],pre_b[N+1],rg_b[N+1],suf_b[N+1];
void pre_rg_suf_init(int lenx,char x[],bool pre[],bool rg[],bool suf[]){
	memset(pre,1,N+1);memset(rg,1,N+1);memset(suf,1,N+1);
	for(int i=1;i<=s;i++)for(int j=1;j<=i;j++)pre[i]&=eq(x[j],c[j-i+s]);
	for(int i=2;i+s-1<lenx;i++)for(int j=i;j<=i+s-1;j++)rg[i]&=eq(x[j],c[j-i+1]);
	for(int i=lenx-s+1;i<=lenx;i++)for(int j=i;j<=lenx;j++)suf[i]&=eq(x[j],c[j-i+1]);
}
bool ok(int dif){
	for(int i=1;i<=n;i++)if(1<=i-dif&&i-dif<=m&&!eq(a[i],b[i-dif]))return false;
	return true;
}
int sol(int dif){
	int l=min(1,1+dif),r=max(n,m+dif);
	int ans=inf;
	for(int i=l-s;i<=r+1;i++)
		if((i+s-1<1?true:i<=1?pre_a[i+s-1]:i+s-1<n?rg_a[i]:i<=n?suf_a[i]:true)&&
		   (i+s-1<1+dif?true:i<=1+dif?pre_b[i+s-1-dif]:i+s-1<m+dif?rg_b[i-dif]:i<=m+dif?suf_b[i-dif]:true))
			ans=min(ans,max(r,i+s-1)-min(l,i)+1);
//	cout<<dif<<" "<<ans<<"\n";
	return ans;
}
int main(){
	cin>>a+1>>b+1>>c+1;
	n=strlen(a+1);m=strlen(b+1);s=strlen(c+1);
	if(s>n){
		for(int i=1;i<=s;i++)swap(a[i],c[i]);
		swap(n,s);
	}
	if(s>m){
		for(int i=1;i<=s;i++)swap(b[i],c[i]);
		swap(m,s);
	}
	pre_rg_suf_init(n,a,pre_a,rg_a,suf_a);pre_rg_suf_init(m,b,pre_b,rg_b,suf_b);
	int ans=inf;
	for(int i=-(m+s);i<=n+s;i++)if(ok(i))ans=min(ans,sol(i));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;
class c
{
    static void Main()
    {
        var s = Console.ReadLine();
        var acgt = new char[4] { 'A', 'C', 'G', 'T' };
        var ans = 0;
        var temp = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (acgt.Contains(s[i]))
            {
                temp++;
                ans = Math.Max(ans, temp);
            }
            else temp = 0;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

VI memo;

int solve( int n )
{
	if ( n == 0 )
	{
		return 1;
	}
	else if ( n < 0 )
	{
		return 0;
	}

	if ( memo[n] != -1 )
	{
		return memo[n];
	}

	return solve( n - 1 ) + solve( n - 2 ) + solve( n - 3 );
}

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

		if ( n == 0 )
		{
			break;
		}

		memo.resize( n + 1 );
		fill( ALL( memo ), -1 );

		cout << solve( n ) / 3650 + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <iostream>
#include <fstream>

using std::cin;
using std::cout;
using std::endl;
using std::terminate;

void solve() {
    int A, B; cin >> A >> B;

    for (int i = 1; i <= 1250; ++i) {
        if (i * 8 / 100 == A && i * 10 / 100 == B) {
            cout << i << endl;
            return ;
        }
    }

    cout << -1 << endl;
}

int main() {

#ifdef DEV
    std::ifstream in("input");
    cin.rdbuf(in.rdbuf());

    int t; cin >> t;
    for (int x = 1; x <= t; ++x) {
        solve();
    }
#else
    solve();
#endif

    return 0;
}


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

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

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

    int d[n];
    rep(i, n)
        cin >> d[i];

    sort(d, d + n);

    int count = 0;
    for(int i = d[n / 2 - 1] + 1; i <= d[n / 2]; i++)
        count++;

    cout << count << endl;
    return 0;

}


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

#define ll long long int
ll const mod = 1e9 + 7;

ll power(ll x, ll y, ll p){ //x^y % p
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {
        if (y & 1) // If y is odd, multiply x with result 
        res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    
    int dp[n] {0};
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
	// your code goes here
	return 0;
}


Measured memory_bytes: 1024
import sys
N = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
print(str.lower(num2alpha(N)))

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
using namespace std;
#define maxn 100005 
struct Seg
{
	int l,r,i;
}ls[maxn],rs[maxn];
inline bool cmp1(Seg &a,Seg &b)
{
	return a.l>b.l;
}
inline bool cmp2(Seg &a,Seg &b)
{
	return a.r<b.r;
}
inline int dst(int l,int r,int p)
{
	if(p<=l)
	{
		return l;
	}
	if(p>=r)
	{
		return r;
	}
	return p;
}
int b[maxn];
int main()
{
	int n,j,p=0,t1;
	ll ans1=0,ans2=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&ls[i].l,&ls[i].r);
		ls[i].i=i;
	}
	sort(ls,ls+n,cmp1);
	for(int i=0;i<n;i++)
	{
		rs[i].l=ls[i].l;
		rs[i].r=ls[i].r;
		rs[i].i=ls[i].i;
	}
	sort(ls,ls+n,cmp2);
	j=0;p=0;
	for(int i=0;i<n;i++)
	{
		if(b[ls[i].i])
		{
			continue;
		}
		b[ls[i].i]=1;
		t1=dst(ls[i].l,ls[i].r,p);
		ans1+=abs(p-t1);
		p=t1;
		while(b[rs[j].i] and j<n)
		{
			j++;
		}
		if(j>=n)
		{
			continue;
		}
		b[rs[j].i]=1;
		t1=dst(rs[j].l,rs[j].r,p);
		ans1+=abs(p-t1);
		p=t1;
	}
	ans1+=abs(p);
	memset(b,0,sizeof(b));
	j=0;p=0;
	for(int i=0;i<n;i++)
	{
		if(b[rs[i].i])
		{
			continue;
		}
		b[rs[i].i]=1;
		t1=dst(rs[i].l,rs[i].r,p);
		ans2+=abs(p-t1);
		p=t1;
		while(b[ls[j].i] and j<n)
		{
			j++;
		}
		if(j>=n)
		{
			continue;
		}
		b[ls[j].i]=1;
		t1=dst(ls[j].l,ls[j].r,p);
		ans2+=abs(p-t1);
		p=t1;
	}
	ans2+=abs(p);
	printf("%lld\n",max(ans1,ans2));
	return 0;
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: u32 = read();
    let p_vec: Vec<u32> = read_vec();

    let mut count = 0;
    let mut min = p_vec[0];
    for p in p_vec {
        if p <= min {
            count += 1;
            min = p;
        }
    }

    println!("{}", count);
}


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

int N, Q;
string s;
vector<pair<char, char>> com;

bool isOK_l(int v) {
  if(v == -1) return true;
  rep(i, 0, Q) {
    char t = com[i].first;
    char d = com[i].second;
    if(t != s[v]) continue;
    if(d == 'R') v++;
    else v--;
    if(v == -1) return true;
    if(v == N) return false;
  }
  return false;
}

int bs_l() {
  int ng = N;
  int ok = -1;
  while(abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if(isOK_l(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isOK_r(int v) {
  if(v == N) return true;
  rep(i, 0, Q) {
    char t = com[i].first;
    char d = com[i].second;
    if(t != s[v]) continue;
    if(d == 'R') v++;
    else v--;
    if(v == N) return true;
    if(v == -1) return false;
  }
  return false;
}

int bs_r() {
  int ng = -1;
  int ok = N;
  while(abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if(isOK_r(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin >> N >> Q >> s;
  rep(i, 0, Q) {
    char a, b;
    cin >> a >> b;
    com.emplace_back(a, b);
  }
  cout << bs_r() - bs_l() - 1 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    ll N;
    cin >> N;
    ll A[N];
    ll count = 0;
    ll NUmax = 0;
    ll NUmin = INF;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i]<0)count++;
        NUmax = abs(A[i]) + NUmax;
        NUmin = min(abs(A[i]),NUmin);
    }
    if(count%2==0){
        cout << NUmax << endl;
    }else{
        cout << NUmax -  2*NUmin  << endl;
    }
}
    


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
    using namespace std;
 
    typedef long long ll;
    typedef long double ld;
 
    typedef pair<int, int> pi;
    typedef pair<ll,ll> pl;

    typedef vector<int> vi;
    typedef vector<ll> vl;
    typedef vector<pi> vpi;
    typedef vector<pl> vpl;
    typedef vector<vi> vvi;

    #define FOR(i, a, b) for (int i=a; i<(b); i++)
    
    #define sz(x) (int)(x).size()
    #define mp make_pair
    #define pb push_back
    #define f first
    #define s second
    #define lb lower_bound
    #define ub upper_bound
    #define all(x) x.begin(), x.end()
 
    template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
    template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
    
    #define trav(container, it) for(typeof(container.begin()) it=container.begin(); it!=container.end(); it++)
 
    const int MOD = 1000000007;
    const char nl = '\n';
 
    int main() 
    {
        ios_base::sync_with_stdio(0); cin.tie(0);

        int n,m,x;cin>>n>>m>>x;
        
        vvi v;
        if(n>m) v.resize(n);
        else v.resize(m);

        vi c(n);
        
        int temp;

        FOR(i,0,n)
        {
            cin>>c[i];

            FOR(j,0,m)
            {
                cin>>temp;
                v[j].pb(temp);
            }
        }

        ll count,sum,res=INT_MAX;
        bool flag;

            FOR(mask,1,pow(2,n))
            {
                count=0;
                sum=0;
                flag=true;

                FOR(j,0,n)
                {
                    if(mask & (1<<j))
                        count+=v[0][j],sum+=c[j];
                }
                if(count>=x)
                {
                    FOR(l,1,m)
                    {
                        count=0;
                        FOR(j,0,n)
                        {
                            if(mask & (1<<j))
                            {
                                count+=v[l][j];
                            }
                        }
                        if(count < x) {flag=false;break;}
                    }
                    if(flag) res=min(res,sum);
                }
            }

            if(res==INT_MAX) cout<<-1;
            else cout<<res;
        
    }


Measured memory_bytes: 4036
def main():
    import bisect
    import sys
    input=sys.stdin.readline
    n,m,k=map(int,input().split())
    A=[0]+list(map(int,input().split()))
    B=list(map(int,input().split()))
    for i in range(n):
        A[i+1]+=A[i]
    for i in range(m-1):
        B[i+1]+=B[i]
    ans=0
    for i in range(n+1):
        if k<A[i]:
            break
        r=k-A[i]
        j=bisect.bisect_right(B,r)
        ans_=i+j
        ans=max(ans,ans_)
    print(ans)
if __name__ == '__main__':
    main()

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

int main(){
  char c;cin>>c;
  cout<<char(c+1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int clue,black,i;cin>>clue>>black;
    if(clue==0)cout<<black;
    for(i=clue-1;i>=0;i--){
            cout<<black-i<<" ";
    }
    for(i=1;i<clue;i++){
        cout<<black+i<<" ";
    }


   return 0;
}


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

string ToString(int number){
  if(number==9){
    return "9";
  }
  if(number==8){
    return "8";
  }
  if(number==7){
    return "7";
  }
  if(number==6){
    return "6";
  }
  if(number==5){
    return "5";
  }
  if(number==4){
    return "4";
  }
  if(number==3){
    return "3";
  }
  if(number==2){
    return "2";
  }
  if(number==1){
    return "1";
  }else{
    return "0";
  }
}

string IntToString(int number){
  int a[10],b=0,c;
  string s="";
  while(1){
    if(number==0)break;
    a[b]=number%10;
    b++;
    number/=10;
  }
  for(int i=b-1;i>=0;i--){
    s=s+ToString(a[i]);
  }
  return s;
}


int main(){
  int n,cc,cnt;
  string tmp;
  string moji;
  string ans,aa;
  while(1){
    cin>>n;
    if(n==0)break;
    cin>>moji;
    for(int k=0;k<n;k++){
      ans="";
      cnt=0;
      tmp=moji.substr(0,1);
      for(int i=0;i<moji.size();i++){
	if(tmp==moji.substr(i,1)){
	  cnt++;
	  //cout<<tmp<<"=="<<moji.substr(i,1)<<endl;
	}else{
	  //  cout<<tmp<<"!="<<moji.substr(i,1)<<endl;
	  aa=IntToString(cnt);
	  ans=ans+aa;
	  ans=ans+tmp;
	  cnt=1;
	  tmp=moji.substr(i,1);
	}
      }
      aa=IntToString(cnt);
      ans=ans+aa;
      ans=ans+tmp;
      moji=ans;
      // cout<<ans<<endl;
    }
    cout<<moji<<endl;
  }
  return 0;
}

Measured memory_bytes: 1396
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define int ll

signed main(){
    int n;
    VL a,b,c;
    cin >> n;
    REP(i,n){
        int tmp;
        scanf("%lld",&tmp);
        a.PB(tmp);
    }
    REP(i,n){
        int tmp;
        scanf("%lld",&tmp);
        b.PB(tmp);
    }
    REP(i,n){
        int tmp;
        scanf("%lld",&tmp);
        c.PB(tmp);
    }
    SORT(a);SORT(b);SORT(c);
    int ans = 0;
    REP(i,n){
        int tmp = b[i];
        ans += (LB(ALL(a),tmp)-a.begin()) * (c.end()-UB(ALL(c),tmp));
    }
    printf("%lld\n",ans);
}

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

int top, S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a, b;
    top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            b = pop();
            a = pop();
            push(a + b);
        }else if (s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }else if(s[0] == '*'){
            b = pop();
            a = pop();
            push(a * b);
        }else{
            push(atoi(s));
        }
    }

    printf("%d\n", pop());
    return 0;    
    
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long unsigned int llu;
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define YUGEN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lp(i,start,end) for(int i=start;i<end;i++)
#define MAX 105
#define BPC(x)  __builtin_popcountll(x)
#define test() ll t; cin>>t; while(t--)
#define gcd(a,b)  __gcd(a,b)
#define SIZE 26
ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

int main()
 {
    YUGEN;
      // test()
      // {
        // ll a,b;
       // cin>>a>>b;
       // ll ans=0;
        //if(a<b)
        //{
         //  int x=(b-a);
         //  if(x&1)
        //   ans++;
        //   else
        //   ans+=2;
       // }
      //   else if(a==b)
      //   ans=0;
      //   else if(a>b)
      //   {
      //     int x=(a-b);
      //     if(x&1)
      //     ans+=2;
      //     else
      //     ans++;
          
      //   }
      //   cout<<ans<<endl;
      // }
      string s;
      cin>>s;
      string t;
      cin>>t;
      int ans=t.size();
      for(int i=0;i<=s.size()-t.size();i++)
      {
        int count=0;
        for(int j=0;j<t.size();j++)
        {
          if(t[j]!=s[i+j])
          count++;
        }
        ans=min(ans,count);
      }
      cout<<ans;
 }




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

int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    ll y=n/b;
    if(n<b){
        cout << (a*n/b)-a*(n/b) << "\n";
        return 0;
    }
    n=b*y-1;
    cout << (a*n/b)-a*(n/b) << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    ll d, t, s; cin >> d >> t >> s;
    if(s*t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3576