akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("02")
#define ll long long
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
struct ios{
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline ios & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
string s;
string a;
int main(){
	cin>>s;
	a=s;
	reverse(a.begin(),a.end());
	for(int i=0;i<s.size();i++){
		if(s[i]=='b') s[i]='d';
		else if(s[i]=='d') s[i]='b';
		else if(s[i]=='q') s[i]='p';
		else s[i]='q';
	}
	puts(a==s?"Yes":"No");
	return 0;
}

Measured memory_bytes: 512
NUM = (None, 2, 5, 5, 4, 5, 6, 3, 7, 6)

nSticks, n = map(int, input().split())
a = list(map(int, input().split()))

# maximum value to make using exactly sticks
dp = [0] * (nSticks + 1)
for digit in a:
    if NUM[digit] <= nSticks:
        dp[NUM[digit]] = max(dp[NUM[digit]], digit)
for sticks in range(2, nSticks + 1):
    for digit in a:
        if sticks - NUM[digit] >= 0 and dp[sticks - NUM[digit]] > 0:
            dp[sticks] = max(dp[sticks], dp[sticks - NUM[digit]] * 10 + digit)
print(dp[-1])



Measured memory_bytes: 14516
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	s := make([]string, n)
	t := make([]int, n)
	for i := 0; i < n; i++ {
		s[i] = Scan()
		t[i] = iScan()
	}
	x := Scan()
	f := false
	ans := 0
	for i := 0; i < n; i++ {
		if s[i] == x {
			f = true
		} else if f {
			ans += t[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,m;
    cin >> n >> m;
    cout << (n-1) * (m-1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a;
int r[100],l[100];
int main()
{
    cin>>a;
    r[1]=9,l[1]=1;
    for(int i=2;i<=7;i++){
        r[i]=r[i-1]*10+9;
        l[i]=l[i-1]*10;
    }
    int t=1;
    while(r[t]<=a)t+=2;
    int ans=0;
    for(int i=1;i<t;i++)if(i%2==1)ans+=r[i]-l[i]+1;
    ans+=max(0,a-l[t]+1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
# import math
# import statistics
# import itertools
# a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
W,a,b= map(int,input().split())
# f = list(map(int,input().split()))
# g = [int(input()) for _ in range(N)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

ans1=b-(a+W)
ans2=a-(b+W)

if a+W<b or b+W<a:
    print(min(abs(ans1),abs(ans2)))
else:
    print(0)
    

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

class Program
{
    static void Main(string[] args)
    {
        var x = long.Parse(Console.ReadLine());

        for(int i = 1; i < 10; i++)
        {
            if(200 * i + 200 <= x && 200 * i + 400 > x)
            {
                Console.WriteLine(9 - i);
                return;
            }
        }
    }
}

Measured memory_bytes: 27536
n = int(input())
h = list(map(int,input().split()))
if n == 1:
    print('Yes')
    exit()
height = h[0]- 1
for i in range(1,n):
    if h[i] < height:
        print('No')
        exit()
    else:
        if h[i]-1 > height:
            height = h[i]-1
print('Yes')
            


Measured memory_bytes: 14252
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl


int N,T,ans=10000;

int main(){
    cin>>N>>T;
int c[N],t[N];
rep(i,N){
cin>>c[i]>>t[i];
if(t[i]<=T){
ans=min(ans,c[i]);
}
}
if(ans==10000){
out("TLE");
}
else{
out(ans);
}
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,s,x,x1,X,X1;
	while((scanf("%d %d",&a,&b))!=EOF){
		s=0;
		x=a; x1=b;
		if(x<x1){
			s=x;
			x=x1;
			x1=s;
		}
		while(1){
		if(x1==0) break;
			x%=x1;
			s=x;
			x=x1;
			x1=s;
		}
		X=a; X1=b;
		while(1){
			if(X==X1) break;
			else if(X<X1){
				X+=a;
			}
			else if(X>X1){
				X1+=b;
			}
		}
		printf("%d %d\n",x,X);
	}
	return 0;
}

Measured memory_bytes: 596
package main

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

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

type combi struct {
	fac  []int
	finv []int
	inv  []int
	mod  int
}

func (c *combi) init(n int, m int) {
	c.fac = make([]int, n)
	c.finv = make([]int, n)
	c.inv = make([]int, n)
	c.mod = m

	c.fac[0] = 1
	c.fac[1] = 1
	c.finv[0] = 1
	c.finv[1] = 1
	c.inv[1] = 1
	for i := 2; i < n; i++ {
		c.fac[i] = c.fac[i-1] * i % c.mod
		c.inv[i] = c.mod - c.inv[c.mod%i]*(c.mod/i)%c.mod
		c.finv[i] = c.finv[i-1] * c.inv[i] % c.mod
	}
}

func (c *combi) combi(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return c.fac[n] * (c.finv[k] * c.finv[n-k] % c.mod) % c.mod
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()

	var c combi
	mod := int(1e9) + 7
	c.init(n+1, mod)
	ans := 0
	if n < k {
		k = n - 1
	}
	for i := 0; i <= k; i++ {
		ans += c.combi(n, i) * c.combi(n-1, n-i-1)
		ans %= mod
		//debugf("i: %d, ans: %d, diff:%d\n", i, ans, c.combi(n, i)*c.combi(n-1, n-i-1))
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 5504
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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



int main(){
    
    int n,a,ans=0,M,m,cnt=0,flag[8]={};
    
    cin>>n;
    rep(i,0,n){
        cin>>a;
        if(a>=1&&a<400){
            if(!flag[0]){
                flag[0]=1;
                ans++;
            }
        }
        else if(a<800){
            if(!flag[1]){
                flag[1]=1;
                ans++;
            }
        }
        else if(a<1200){
            if(!flag[2]){
                flag[2]=1;
                ans++;
            }
        }
        else if(a<1600){
            if(!flag[3]){
                flag[3]=1;
                ans++;
            }
        }
        else if(a<2000){
            if(!flag[4]){
                flag[4]=1;
                ans++;
            }
        }
        else if(a<2400){
            if(!flag[5]){
                flag[5]=1;
                ans++;
            }
        }
        else if(a<2800){
            if(!flag[6]){
                flag[6]=1;
                ans++;
            }
        }
        else if(a<3200){
            if(!flag[7]){
                flag[7]=1;
                ans++;
            }
        }
        else cnt++;
    }
    M=ans+cnt;
    m=max(1,ans);
    cout<<m<<" "<<M<<endl;
        
    return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n;
ll a[maxn];
ll x,y;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  cin>>n;
  cin>>x>>y;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a,a+n);
  ll ans = 0;
  for (int i=0; i+1<n; i++) {
    ans += min(x*(a[i+1]-a[i]),y);
  }
  cout<<ans<<endl;
  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 1024
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int n;
	cin >> n;
	vector<int>a(n + 1), b(n);
	for (int i = 0; i <= n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];
	LL ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] >= b[i]) {
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}
		else
		{
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
			if (a[i + 1] <= b[i]) {
				ans += a[i + 1];
				b[i] -= a[i + 1];
				a[i + 1] = 0;
			}
			else
			{
				a[i + 1] -= b[i];
				ans += b[i];
				b[i] = 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e3 + 5;
int d[MAXN];
int nbdig;
ll dp[101][5][3];

ll solve(int i,int cnt,int exact,int zeros,bool ok)
{
    
    if(cnt < 0)
        return 0;
    if(i == nbdig)
         return (cnt == 0);
   ll &ret = dp[i][cnt][exact];
    if(ret != -1)
        return ret;
    int st = 0;
     if(zeros != 0)
         ok = 1;
  
     ret = 0;
       // cout << i << ' ' << cnt << ' ' << exact << ' ' << zeros << ' ' << ok << ' ' << st << '\n';
    if(exact)
    {
       ret+=solve(i + 1 , cnt - (d[i] != 0) , 1, d[i], ok);
        for(int j = 0 ; j < d[i] ; j++)
            ret+=solve(i + 1 , cnt - (j != 0) , 0 , j , (ok || j));

    }
    else
    {
         for(int j = 0 ; j <= 9 ; j++)
          ret+=solve(i + 1 , cnt - (j != 0) , 0 , j , (ok or j));
    }
    
    return ret;
}



ll get(string s,int k)
{
    nbdig = (int)s.size();
    for(int i = 0  ; i < nbdig ; i++)
    {
        d[i] = s[i] - '0';
    }
    
    return solve(0,k,1,0,0);
}

int main()
{

string s;
cin >> s;
int k;
cin >> k;
memset(dp,-1,sizeof(dp));
cout << get(s,k);
    
}

Measured memory_bytes: 256
N,K,Q = map(int,input().split())
A = [int(input())-1 for i in range(Q)]
p = [K-Q]*N
for i in range(Q):
    p[A[i]] += 1
for i in range(N):
    if p[i]>0:
        print('Yes')
    else:
        print('No')

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

int x[100000], y[100000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		int a, b; scanf("%d%d", &a, &b);
		x[i] = a - b; y[i] = a + b;
	}
	int X[2]{ -INF,INF }, Y[2]{ -INF,INF };
	rep(i, n) {
		X[0] = max(X[0], x[i]); X[1] = min(X[1], x[i]);
		Y[0] = max(Y[0], y[i]); Y[1] = min(Y[1], y[i]);
	}
	int l = 0, r = INF;
	while (l != r) {
		int t = (l + r) / 2;
		bool flag = false;
		rep(i, 2)rep(j, 2) {
			bool ok = true;
			rep(k, n) {
				if (abs(x[k] - X[i]) <= t&&abs(y[k] - Y[j]) <= t)continue;
				if (abs(x[k] - X[!i]) > t || abs(y[k] - Y[!j]) > t) { ok = false; break; }
			}
			if (ok) { flag = true; break; }
		}
		if (flag)r = t;
		else l = t + 1;
	}
	printf("%d\n", l);
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if (n >= 30) cout << "Yes\n";
	else cout << "No\n";
}

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

int main()
{
	int n,r;
	while(cin >> n >> r){
		if(!n && !r)
			break;
		int p,c;
		int card[50];
		for(int i=0;i<n;i++){
			card[i] =  i+1;
		}
		for(int i=0;i<r;i++){
			cin >> p >> c;
			int tmp[50];
			for(int j=0;j<n;j++){
				tmp[j] = card[j];
			}
			int a = n-1;
			for(int j=0;j<c;j++){
				tmp[a--] = card[n-p-j];
			}
			for(int j=0;j<p-1;j++){
				tmp[a--] = card[n-1-j];
			}
			for(int j=0;j<n;j++){
				card[j] = tmp[j];
			}
		}
		cout << card[n-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

static const int64_t kRem = 1000000007;

int64_t gcd(int64_t a, int64_t b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}


int64_t pow_rem(int64_t x, int64_t m, int64_t rem)
{
	if (m == 0) {
		return 1;
	}
	if (m == 1) {
		return x;
	}

	if (m & 1) {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		val *= x;
		val %= rem;
		return val;
	}
	else {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		return val;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t h, w, t; cin >> h >> w >> t;

	int64_t hgcd = gcd(h, t);
	int64_t wgcd = gcd(w, t);
	int64_t hn = h / hgcd;
	int64_t wn = w / wgcd;

	int64_t ans = pow_rem(2, hn, kRem);
	ans += pow_rem(2, wn, kRem);
	ans -= 1;
	ans %= kRem;
	int64_t ngcd = gcd(hn, wn);
	if (ngcd != 1) {
		ans += pow_rem(2, ngcd, kRem);
		ans -= 2;
		ans %= kRem;
	}

	int64_t ans2 = 0;
	ans2 = pow_rem(ans, hgcd * wgcd, kRem);
	ans2 %= kRem;
	
	cout << ans2 << endl;

	return 0;
}

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

int main()
{
    int N,M,C;
    int A;
    int B[202];
    int total=0;
    int count=0;

    scanf("%d%d%d",&N,&M,&C);
    int i,j;
    for(j=0;j<M;j++){
        scanf("%d",&B[j]);
    }


    for(i=0;i<N;i++){

        for(j=0;j<M;j++){
            scanf("%d",&A);
            total += A*B[j];
        }

        if(total + C > 0){
            count++;
        }

        total = 0;
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define N 100000
 
int Partition(int, int);
void Quicksort(int, int);

typedef struct{
  int n;
  char c;
  int count;
}Card;

Card a[N];

int main(void){
  int n,i,q,flag=0;
  char y;

  scanf("%d%c",&n,&y);
  for(i = 1; i < n+1; i++){
    scanf("%c%d%c",&a[i].c, &a[i].n, &y);
    a[i].count = i;
  }

  Quicksort(1,n);

  for(i = 0; i < n; i++){
    if(a[i].n == a[i+1].n && a[i].count > a[i+1].count){
      flag = 1;
      break;
    }
  }

  if(flag == 0){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }

  for(i = 1; i < n+1; i++){
    printf("%c %d\n",a[i].c,a[i].n);
  }
  return 0;
}
 
int Partition(int p, int r){
  int i,j;
  Card x,tmp;

  x = a[r];
  i = p - 1;

  for(j = p; j <= r-1; j++){
    if(a[j].n <=  x.n){
      i =  i + 1;
      tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  tmp = a[i+1];
  a[i+1] = a[r];
  a[r] = tmp;

  return i+1; 
}

void Quicksort(int p, int r){
  int q;
  if(p < r){
    q = Partition(p,r);
    Quicksort(p,q-1);
    Quicksort(q+1,r);
  }
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(std::string S, std::string T) {
    int a = 0;
    rep (i, S.size() - T.size() + 1) {
        int cnt = 0;
        rep (j, T.size()) {
            cnt += S[i+j] == T[j];
        }
        a = max(a, cnt);
    }
    cout << T.size() - a << endl;
}

int main() {
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3592
N = int(input())


def sum_digit(num):
    tmp = str(num)
    res = 0
    for i in tmp:
        res += int(i)
    return res


res = sum_digit(2) + sum_digit(N - 2)
for i in range(3, N):
    tmp = sum_digit(i) + sum_digit(N - i)
    if res > tmp:
        res = tmp

print(res)

Measured memory_bytes: 3060
X = int(input())

pn = []
pn_flg = [0] * 10**6
for i in range(2, 10**6):
    if pn_flg[i] == 1:
        continue
    pn.append(i)
    pn_flg[i] = 1
    for j in range(i, 10**6, i):
        pn_flg[j] = 1

for i in pn:
    if i >= X:
        print(i)
        exit()

Measured memory_bytes: 20020
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	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;
}

// ===============================================================

int main() {
	ll h, a; cin >> h >> a;
	if (h % a == 0) cout << h / a << endl;
	else cout << h / a + 1 << endl;
}

Measured memory_bytes: 3552
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(; sc.hasNext();){
			String[] s=sc.nextLine().split(",");
			double x1=Double.parseDouble(s[0]);
			double y1=Double.parseDouble(s[1]);
			double x2=Double.parseDouble(s[2]);
			double y2=Double.parseDouble(s[3]);
			double xq=Double.parseDouble(s[4]);
			double yq=Double.parseDouble(s[5]);
			P p1=new P(x1, y1);
			P p2=new P(x2, y2);
			P q=new P(xq, yq);
			P proj=p1.add(p2.sub(p1).mul(
					p2.sub(p1).dot(q.sub(p1))/p2.sub(p1).abs2()));
			P r=proj.sub(q).add(proj);
			println(r.x+" "+r.y);
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}

	class P{
		double x, y;

		P(){}

		P(double x, double y){
			this.x=x;
			this.y=y;
		}

		P add(P p){
			return new P(x+p.x, y+p.y);
		}

		P sub(P p){
			return new P(x-p.x, y-p.y);
		}

		P mul(double m){
			return new P(m*x, m*y);
		}

		double dot(P p){
			return x*p.x+y*p.y;
		}

		double abs2(){
			return x*x+y*y;
		}
	}
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

struct SegmentTree{
    int numNode;
    std::vector<ll> data;

    SegmentTree(int n){
        numNode = 1;
        while(numNode < n){
            numNode *= 2;
        }

        data.assign(numNode * 2, 0);
    }

    void set(int k, ll v){
        k += numNode;
        data[k] = v;

        while(k > 1){
            k /= 2;
            data[k] = std::max(data[k*2], data[k*2+1]);
        }
    }

    ll max(int l, int r){
        l += numNode;
        r += numNode;

        ll res = 0;
        for(;l<r;l/=2,r/=2){
            if(l & 1){
                res = std::max(res, data[l]);
                l += 1;
            }

            if(r & 1){
                r -= 1;
                res = std::max(res, data[r]);
            }
        }

        return res;
    }

    ll at(int k){
        return data[k + numNode];
    }
};

int N;
int hs[200100], as[200100];

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> hs[i];
    }

    for(int i=0;i<N;++i){
        std::cin >> as[i];
    }

    SegmentTree seg(N + 1);

    for(int i=0;i<N;++i){
        seg.set(hs[i], seg.max(1, hs[i]) + as[i]);
    }

    ll res = seg.max(1, N + 1);
    std::cout << res << std::endl;
}


Measured memory_bytes: 5888
a[100000],x,r;main(n,m){
for(scanf("%d%d",&n,&m);++x<n;a[x]+=a[x-1])scanf("%d",a+x);
for(n=0;m;m--)scanf("%d",&x),r=(r+abs(a[n+x]-a[n]))%100000,n+=x;
x=!printf("%d\n",r%100000);}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  string s;
  cin >> s;
  int n = s.size();

  vi ans(n, 1);
  for(int i = 0; i < n-1; i++){
    if(s[i] == 'R' and s[i+1] == 'R'){
      ans[i+2] += ans[i];
      ans[i] = 0;
    }
  }

  for(int i = n-1; i > 0; i--){
    if(s[i-1] == 'L' and s[i] == 'L'){
      ans[i-2] += ans[i];
      ans[i] = 0;
    }
  }
  
  rep(i, 0, n) cout << ans[i] << " \n"[i==n-1];

  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main()
{

int a[10000], min, max, n, i;
long long sum = 0;
scanf("%d", &n);//1以上が入力されるものとします
for(i = 0; i < n; i++){
scanf("%d", &a[i]);
sum += a[i];
}
max = min = a[0];//とりあえず最初の要素をセットしておく
for(i = 1; i < n; i++){//2番目以降の要素と比較
if(a[i] > max)max = a[i];
if(a[i] < min)min = a[i];
}
printf("%d %d %lld\n", min, max, sum);

return 0;
}


Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a;
    std::deque<int> deq;
    for (int i=0;i<3;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    sort(deq.begin(),deq.end(),greater<int>());
    int k;
    cin>>k;
    for (int j=0;j<k;j++) {
        deq[0]*=2;
    }
    int sum=0;
    for (int l=0;l<3;l++) {
        sum+=deq[l];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        Queue<Integer> queue = new PriorityQueue<>();
        
        for(int i = 0; i < N; i++){
            int c = sc.nextInt();
            int t = sc.nextInt();
            if( t <= T ) queue.add(c);
        }
        
        if( queue.isEmpty() ){
            System.out.println("TLE");
        } else {
            System.out.println(queue.poll() );
        }
        
    }
}


Measured memory_bytes: 23124
begin
	writeln('1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1');
end.


Measured memory_bytes: 1384
#include<stdio.h>
#include<string.h>
#define MAX 1200

int main(void)
{
	char str[MAX], *p;
	int i, c;
	int count[26]; // 26个英文单词


	// 初始化数组
	for (i = 0; i < 26; i++)
		count[i] = 0;

	while(fgets(str, MAX, stdin) != NULL)
	{
		p = str;
		while(*(char *)p != '\0')
		{
			c = *(char *)(p++);
			if ( c >= 'a' && c <= 'z')
				count[c - 'a']++;
			else if (c >= 'A' && c <= 'Z')
				count[c - 'A']++;
		}
	}
	// 输出统计结果
	for (i = 0; i < 26; i++)
		printf("%c : %d\n", (char) (i + 'a'), count[i]);
	return 0;
}



Measured memory_bytes: 2080
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;

int main ()
{
    map<int,int> m;
    set<int> s;
    int a, b;
    while (scanf("%d,%d", &a, &b), (a | b)) {
        m[a] = b;
        s.insert(b);
    }
    vector<int> v;
    while (cin >> a) {
        v.push_back(a);
    }
    for (int i = 0; i < v.size(); i++) {
        int j = 0;
        for (auto it = s.begin(); it != s.end(); it++) {
            j++;
            if (*it == m[v[i]]) {
                cout << (s.size()-j+1) << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1260
a,b =[],[]
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
b = [int(input()) for _ in range(m)]

for i in range(n):
    x=0
    for j in range(m):
        x = x + a[i][j]*b[j]
    print(x)


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

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

double calc_dist(vector<int>a, vector<int>b){
    double ans = 0;
    rep(i, a.size()){
        ans += pow(a[i]-b[i], 2);
    }
    return sqrt(ans);
}

int main() {
    int n, d; cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    rep(i, n) rep(j, d) cin >> x[i][j];
    int cnt = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            double dist = calc_dist(x[i], x[j]);
            if(ceil(dist) == floor(dist)) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

def Eratosthenes(N): #N以下の素数のリストを返す
    N+=1
    is_prime_list = [True]*N
    m = int(N**0.5)+1
    for i in range(3,m,2):
        if is_prime_list[i]:
            is_prime_list[i*i::2*i]=[False]*((N-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,N,2) if is_prime_list[i]]

#p,n,k,b,*a = [int(i) for i in read().split()]

# k以下、長さn
n,k = map(int,input().split())

MOD = 10**9+7
res = [0]+[pow(k//i,n,MOD) for i in range(1,k+1)]

p = Eratosthenes(k)

#print(res)
for i in p:
    for j in range(i,k+1,i):
        res[j//i] -= res[j]

#print(res)
print(sum(ri*i for i,ri in enumerate(res))%MOD)

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n, -1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
};

int deg[100005];
vector<int> to[100005];

int main() {
  int n,m,k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  REP(i,m) {
    int a,b; cin >> a >> b;
    a--; b--;
    deg[a]++; deg[b]++;
    uf.unite(a,b);
  }
  REP(i,k) {
    int a,b; cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  REP(i,n) {
    // 友達関係をたどってたどり着ける人の数
    // 友達及び友達関係から辿れる人の合計 - 親の分の1 - 直接つながっている友達
    int ans = uf.size(i) - 1 - deg[i];
    // ブロック関係を引く
    for (int u: to[i]) if (uf.same(i,u)) ans--;
    if (i > 0) cout << " ";
    cout << ans;
  }
  cout << endl;
}

Measured memory_bytes: 6784
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define int long long

using namespace std;

string s;

int mp[1500], n, res;

main ()
{
    cin >> s;
    s = ' ' + s;
    n = sz(s) - 1;
    for (int i = 1; i <= n; i++)
        mp[ s[i] ]++;

    res = n * (n + 1) / 2;

    for (int i = 'a'; i <= 'z'; i++)
        res -= mp[i] * (mp[i] + 1) / 2;

    cout << res + 1 << endl;
}


Measured memory_bytes: 772
#include<bits/stdc++.h>
#define endl '\n'
#define mp make_pair
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef long long int ll;
ll mod =1000000007;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,d;
    cin>>n>>d;
    ll a;
    vector<ll> v[20];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>a;
            v[i].push_back(a);
        }
    }
    ll cnt=0;
    for(int i=0;i<n-1;i++){
        
        for(int j=i+1;j<n;j++){
            ll sum=0;
            for(int k=0;k<d;k++){
               ll x= v[i][k] ; ll y= v[j][k];
                ll val=(x-y)*(x-y);
                sum+=val;
            }
            double value =sqrt(sum);
        // cout<<fixed<<setprecision(6)<<value<<endl;
        if(value-floor(value)==0.0) cnt++;
        }
//         

        
    }
    cout<<cnt<<endl;
    
    
}

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

int main(void) {
    char str[3];
    scanf("%s", str);

    char *s1 = "abc";
    char *s2 = "acb";
    char *s3 = "bac";
    char *s4 = "bca";
    char *s5 = "cba";
    char *s6 = "cab";

    if(strcmp(str,s1)==0){
        printf("Yes\n");
    }else if(strcmp(str,s2) == 0){
        printf("Yes\n");
    }else if(strcmp(str,s3) == 0){
        printf("Yes\n");
    }else if(strcmp(str,s4) == 0){
        printf("Yes\n");
    }else if(strcmp(str,s5) == 0){
        printf("Yes\n");
    }else if(strcmp(str,s6) == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;

}

Measured memory_bytes: 128
#include <cstdio>
int a, b;
int main() {
	scanf("%d%d", &a, &b);
	if (a <= 0 && b >= 0) puts("Zero");
	else 
		if (a > 0) puts("Positive");
		else puts((b - a) & 1 ? "Positive" : "Negative");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
#define rep(i,n) for(int i = 0; i < (n); i++)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
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; }

class UnionFind {
public:
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll k) :par(k), siz(k, 1LL) {
        rep(i, k) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        if (siz[x] < siz[y]) swap(x, y);
        par[y] = x;
        siz[x] += siz[y];
        return;
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

	int n, m;
    cin >> n >> m;
	vector<int> a(n);
	vector<P> v(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
    
    UnionFind uf(n);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (uf.same(i, a[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3072
n = int(input())
count = [[[0 for x in range(10)] for x in range(3)] for x in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    count[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print(" " + " ".join(map(str, count[i][j])))

    if i != 3:
        print("#"*20)



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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  ll N, T;
  scanf("%lld %lld", &N, &T);

  vector<pair<ll, ll>> list;
  for (ll i = 0; i < N; i++) {
    ll a, b;
    scanf("%lld %lld", &a, &b);
    list.emplace_back(make_pair(a, b));
  }

  sort(list.begin(), list.end());

  for (ll i = 0; i < list.size(); i++) {
    auto v = list[i];
    if (v.second <= T) {
      cout << (v.first) << endl;
      return 0;
    }
  }

  cout << ("TLE") << endl;
}


Measured memory_bytes: 3692
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
from itertools import accumulate
ar=[0]+list(accumulate(a))
bru=[0]+list(accumulate(b))
from bisect import bisect_left as bl,bisect_right as br
ans=0

for i in range(n+1):
    g=ar[i]
    if g>k:break
    if k-g>=bru[-1]:ans=max(ans,i+m);continue
    j=br(bru,k-g)
    ans=max(ans,i+j-1)
    #print(i,j-1)
print(ans)


Measured memory_bytes: 50940
s=input()
n=int(len(s))
count=0
ans=0
for i in range(n):
  if s[i]=='A' or s[i]=='T' or s[i]=='G' or s[i]=='C':
    count+=1
    if ans<count:
      ans=count      
  else:
    count=0

else:
  print(ans)


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

// GCD, LCM
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;}

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

    if(S=="ABC"){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }

    return 0;
}

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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int n1,n2;
	if (a%d == 0){
		n1 = a/d;
	}
	else{
		n1 = a/d + 1;
	}
	if (c%b == 0){
		n2 = c/b;
	}
	else{
		n2 = c/b + 1;
	}
	if (n1 >= n2){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,c,k;
    cin>>n>>c>>k;
    vector<int>t(n);
    rep(i,n)cin>>t[i];
    sort(t.begin(),t.end());
    int ans=n,cnt=c-1,x=t[0];
    for(int i=1; i<n; ++i){
        if(t[i]<=x+k&&cnt>0){ans--; cnt--;}
        else{cnt=c-1; x=t[i];}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int static long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int n, m, x[100005], y[100005];
signed main() {
	cin >> n >> m;
	rep(i, n)
		cin >> x[i];
	rep(i, m)
		cin >> y[i];
	int xx = 0, yy = 0;
	rep(i, n) {
		if (i)xx += (x[i] - x[i - 1])*(n - i)*i % moder;
		xx %= moder;
	}
	rep(i, m) {
		if (i)yy += (y[i] - y[i - 1])*(m - i)*i % moder;
		yy %= moder;
	}
	cout << xx * yy%moder << endl;
	endre;
}

Measured memory_bytes: 1920
// Problem : C - Skill Up
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
//#define int long long
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
int n, m, x;
const int N = 20, M = 200020;
int c[N], s[N][M], sum[M];
int main() {
	n = qread(); m = qread(); x = qread(); 
	rep(i, n) {
		c[i] = qread();
		rep(j, m) s[i][j] = qread();
	}
	int ans = INF;
	rep(i, lsh(n)) {
		//check
		memset(sum, 0, sizeof(sum));
		int res = 0;
		rep(j, n) {
			if (lsh(j) & i) {
				rep(k, m) sum[k] += s[j][k];
				res += c[j];
			}
			
		}
		bool bad = false;
		rep(j, m) if (sum[j] < x) {
			bad = true;
			break;
		}
		if (not bad) {
			ans = min(ans, res);
		}
		
	}
	cout << ((ans == INF) ? -1 : ans) << endl;
	return 0;
}


Measured memory_bytes: 4464
def bubble_sort(n, key=0):
    c = 0
    r = [x if isinstance(x, list) else [x] for x in n[:]]
    l = len(r) - 1
    for i in range(0, l):
        for j in range(l, i, -1):
            if r[j][key] < r[j-1][key]:
                r[j], r[j-1] = r[j-1], r[j]
                c += 1
    r = [x[0] if len(x) == 1 else x for x in r]
    return {'list': r, 'count': c}

def selection_sort(n, key=0):
    c = 0
    r = [x if isinstance(x, list) else [x] for x in n[:]]
    l = len(r)
    for i in range(0, l):
        mini = i
        for j in range(i, l):
            if (r[j][key] < r[mini][key]):
                mini = j
        if mini != i:
            r[i], r[mini] = r[mini], r[i]
            c += 1
    r = [x[0] if len(x) == 1 else x for x in r]
    return {'list': r, 'count': c}

def card_format(cards):
    return ' '.join([x[0] + str(x[1]) for x in cards])

if __name__ == '__main__':
    n = int(input())
    c = list(map(list, input().split(' ')))
    c = [[x[0], int(x[1])] for x in c]
    bsc = card_format(bubble_sort(c, 1)['list'])
    ssc = card_format(selection_sort(c, 1)['list'])
    print(bsc)
    print('Stable')
    print(ssc)
    print('Stable' if bsc == ssc else 'Not stable')



Measured memory_bytes: 5616
#include <stdio.h>
 
int main(void){
    long n,i,x,j;
    long R[200000],max=-1000000000,min;
 
    scanf("%ld", &n);
 
    for(i=0; i<n; i++) scanf("%ld", &R[i]);
 
    min=R[0];
 
    for(i=1; i<n; i++){
        x=R[i]-min;
        if(max<x) max=x;
        if(min>R[i]) min=R[i];
    }
 
    printf("%ld\n",max);
    return 0;
}

Measured memory_bytes: 3344
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    cin >> S;

    int score = 0, depth = 0;
    for (char c : S) {
        if (depth > 0) {
            depth--;
            if (c == 'g')
                score++;
        } else {
            depth++;
            if (c == 'p')
                score--;
        }
    }

    cout << score << endl;
    return 0;
};

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

int main()
{
    string str;
    cin >> str;
    int n;
    cin >> n;
    
    for(int i=0; i<n; ++i)
    {
        string query, p;
        int a, b;
        cin >> query >> a >> b;
        
        if(query == "replace")
        {
            cin >> p;
            int k=0;
            for(int j=a; j<=b; ++j)
            {
                str[j] = p[k];
                k++;
            }
        }
        
        else if(query == "reverse")
        {
            int k = b;
            for(int j=a; j<k; ++j)
            {
                swap(str[k], str[j]);
                k--;
            }
        }
        
        else if(query == "print")
        {
            for(int k=a; k<=b; ++k)
            {
                cout << str[k];
            }
            cout << endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3212
package main
import "fmt"
func main(){
	var N int
	fmt.Scan(&N)
	ans := 0
	for i:=1; i<=N; i++{
		if i % 15 != 0 && i % 3 != 0 && i % 5 != 0{
			ans += i
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1752
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
signed main()
{
	int a=read(),b=read(),c=read();
	if (a==b&&b==c) cout<<"Yes";
	else cout<<"No";
	return 0;
	//NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100005

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

//FILE* outFile;

inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
inline int gcd(int a, int b){if(b == 0)return a; return gcd(b, a%b);}
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int b[N], l[N], r[N], vis[N], now;
vector<pair<ll, int>> e;
int main(){
    int j,k,i,T,ca=0, n, m, K = 0;
    scanf("%d%d", &n, &m);
    ll s = 0, L = 0, R = 0, w;
    rep(i, 0, n){
        scanf("%d%d%d", &b[i], &l[i], &r[i]);
        w = 1LL * b[i] * l[i];
        s += w;
        R += b[i];
        e.pb({1LL * (m - b[i]) * r[i] + w, i});
    }
    sort(all(e));
    reverse(all(e));
    while(L <= R){
        ll x = (L + R) >> 1;
        ll y = x / m;
        if(y > n || (y == n && x % m)){
            R = x - 1;
            continue;
        }
        w = 0;
        now++;
        rep(i, 0, y){
            w += e[i].x;
            vis[e[i].y] = now;
        }
        int ok = 0;
        if(x % m){
            K = x % m;
            rep(i, 0, n){
                ll v = w;
                if(vis[i] == now){
                    v = v - 1LL * (m - b[i]) * r[i] - 1LL * b[i] * l[i];
                    v = v + e[y].x;
                }
                if(K <= b[i])v += 1LL * K * l[i];
                else v += 1LL * b[i] * l[i] + 1LL * (K - b[i]) * r[i];
                if(v >= s){
                    ok = 1;
                    break;
                }
            }
        }
        else{
            if(w >= s)ok = 1;
        }
        if(ok)R = x - 1;
        else L = x + 1;
    }
    printf("%lld\n", R + 1);
}



Measured memory_bytes: 3440