akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<map>

using namespace std;
typedef long long ll;
#define Inf 1 << 20
#define MInf -(1 << 20)


#define REP(n) for(int i = 0;i < (int)(n);i++)
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n - 1); i > -1;i--)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;


ll binary(ll bina)
{
    long long ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    string a;
    return ans;

}

int main()
{
    ll r,D,x;
    cin >> r >> D >> x;
    rep(i,10)
    {
        cout << r * x - D << endl;
        x = r * x - D;
    }
}


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

int main() {
  ll n, x;
  cin >> n >> x;
  vll a(n);
  rep(i,n) cin >> a.at(i);
  ll ans = 0;
  if(a[0]>x) {
    ans += (a[0]-x);
    a[0] = x;
  }
  rep(i,n-1) {
    if(a[i+1]+a[i]<=x) continue;
    else {
      ans += (a[i+1] - (x-a[i]));
      a[i+1] -= (a[i+1] - (x-a[i]));
    }
  }
  cout << ans << endl;
  return 0;
}

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

ll K, X, Y;
vector<pair<ll, ll>> ans;
int dirx[] = {1, 1, -1, -1};
int diry[] = {1, -1, 1, -1};

void calc(ll x, ll y) {
  ll d = abs(x - X) + abs(y - Y);
  if (d == 0) return;

  if (d > 2 * K || d % 2 || d % K == 0) {
    ll dx = min(abs(x - X), K);
    ll dy = K - dx;
    ll nx = (x < X)? (x + dx): (x - dx);
    ll ny = (y < Y)? (y + dy): (y - dy);
    ans.emplace_back(make_pair(nx, ny));
    calc(nx, ny);
  } else {
    ll t = (2 * K - d) / 2;
    for (int i = 0; i < 4; i++) {
      ll nx = x + t * dirx[i];
      ll ny = y + (K - t) * diry[i];
      ll nd = abs(nx - X) + abs(ny - Y);
      if (nd == K) {
        ans.emplace_back(make_pair(nx, ny));
        ans.emplace_back(make_pair(X, Y));
        return;
      }
    }
    for (int i = 0; i < 4; i++) {
      ll nx = x + (K - t) * dirx[i];
      ll ny = y + t * diry[i];
      ll nd = abs(nx - X) + abs(ny - Y);
      if (nd == K) {
        ans.emplace_back(make_pair(nx, ny));
        ans.emplace_back(make_pair(X, Y));
        return;
      }
    }
  }
}

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

  cin >> K >> X >> Y;

  if ((X + Y) % 2 != 0 && K % 2 == 0) {
    cout << -1 << '\n';
    return 0;
  }
  calc(0, 0);
  cout << ans.size() << '\n';
  for (auto g: ans) {
    cout << g.first << ' ' << g.second << '\n';
  }
  return 0;
}

Measured memory_bytes: 18028
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	h, _ := io.ScanInt2()
	graph := io.Scan2DGraph(h)
	skippedIndexMap := map[int]bool{}
	for x := 0; x < len(graph[0]); x++ {
		isAllWhite := true
		for y := 0; y < len(graph); y++ {
			if graph[y][x] == "#" {
				isAllWhite = false
			}
		}
		if isAllWhite {
			skippedIndexMap[x] = true
		}
	}
	for y := 0; y < len(graph); y++ {
		for x := 0; x < len(graph[0]); x++ {
			if skippedIndexMap[x] {
				continue
			}
			fmt.Print(graph[y][x])
		}
		fmt.Println()
	}
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, 0)
	for i := 0; i < y; i++ {
		str := io.ScanString()
		if strings.Contains(str, "#") {
			strs = append(strs, strings.Split(str, ""))
		}
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2556
use strict;
use warnings;

my $d = <STDIN>;
chomp($d);
if ( $d == 25 ){
        print "Christmas";
}
elsif( $d == 24 ){
        print "Christmas Eve";
}
elsif( $d == 23 ){
        print "Christmas Eve Eve";
}
else{
        print "Christmas Eve Eve Eve";
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

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

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

    int A, B;
    cin >> A >> B;

    if (A > 9 or B > 9) {
        cout << -1 << endl;
    } else {
        cout << A*B << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long LL;

#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define LEN(a) int((a).size())
#define SORT(a) sort((a).begin(), (a).end())
#define CLR(a) memset((a), 0, sizeof(a))

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m, vector<int>());
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int tmp;
            cin >> tmp;
            s[i].PB(tmp - 1);
        }
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        bool ok = true;
        for (int j = 0; j < m; j++) {
            int cnt = 0;
            for (int k = 0; k < LEN(s[j]); k++) {
                if (((1 << s[j][k]) & i) > 0) cnt++;
            }
            if (cnt % 2 != p[j]) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, K; cin >> N >> K;
  LL ans = 0;
  REP(i,N-1) ans = K * (ans / (K-1)) + ans % (K-1) + 1;

  cout << ans << endl;

  return 0;
}

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

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

    vector<long long> x(N);
    vector<long long> y(N);
    vector<long long> h(N);

    for (long long i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    for (long long X = 0; X <= 100; X++)
    {
        for (long long Y = 0; Y <= 100; Y++)
        {
            long long H = 0;
            long long Hmax = 10000000000;
            for (long long i = 0; i < N; i++)
            {
                if (h[i] != 0)
                {
                    if (H == 0)
                    {
                        H = abs(x[i] - X) + abs(y[i] - Y) + h[i];
                    }
                    else if (H != abs(x[i] - X) + abs(y[i] - Y) + h[i] || Hmax < abs(x[i] - X) + abs(y[i] - Y) + h[i])
                    {
                        break;
                    }
                }
                else
                {
                    if (Hmax > abs(x[i] - X) + abs(y[i] - Y) + h[i])
                    {
                        Hmax = abs(x[i] - X) + abs(y[i] - Y) + h[i];
                    }

                    if (H > Hmax && H != 0)
                    {
                        break;
                    }
                }
                if(i == N - 1)
                {
                    cout << X << " " << Y << " " << H << endl;
                    exit(0);
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (500 * i + 100 * j + 50 * k == X) count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

using namespace std;

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

    int n, m;

    cin >> n >> m;

    vector<int> num (n+1);

    for(int i=0; i<n+1; i++) num[i] = -1;

    bool ok = true;

    for(int i=1; i<=m; i++){
        int c, s;

        cin >> s >> c;

        if(num[s] == -1) num[s] = c;
        else{
            if(num[s] != c) ok = false;
        }
    }

    if(num[1] == 0 and n>1) ok = false;
    if(!ok) cout << -1 << endl;
    else{
        for(int i=1; i<=n; i++){
            if(num[i] == -1){
                if(i == 1 and n>1) num[i] = 1;
                else num[i] = 0;
            }
            cout << num[i];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = 500;
int range[MAX_N + 2][MAX_N + 2];

int main()
{
	memset(range, 0, sizeof(range));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, M, Q; cin >> N >> M >> Q;
	rep (i, M){
		int L, R; cin >> L >> R;
		++range[L][R];
	} // end rep

	for (int i = 1; i <= 501; ++i){
		for (int j = 1; j <= 501; ++j){
			range[i][j] += range[i][j-1];
		} // end for
	} // end for

	rep (i, Q){
		int p, q; cin >> p >> q;
		int res = 0;
		for (int l = p; l <= q; ++l){
			res += range[l][q] - range[l][p-1];
		} // end for
		cout << res << endl;
	} // end rep
	
	return 0;
}

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

using namespace std;

#define int long long 
#define double long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

int32_t main()
{
	string ch,bh;
	cin >> ch >> bh;
	int coun = 0;
	for(int i = 0; i < (int)ch.size();i++) 
	{
		if(ch[i] != bh[i]) coun++;
	}
	cout << coun << endl;
	return 0;
}


Measured memory_bytes: 3864
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
  string s;
  cin>>s;
  ll cnt[2020]={0},cnt1[2020]={0};
  cnt[0]=1;
  ll cur=0,ans=0;
  rep(i,0,sz(s))
  {
    rep(j,0,2020) cnt1[j]=0;
    cur=(cur*10+s[i]-'0')%2019;
    ans+=cnt[cur];
    rep(j,0,2020) cnt1[(j*10)%2019]+=cnt[j];
    cnt1[(cur*10)%2019]++;
    rep(j,0,2020) cnt[j]=cnt1[j];
  }
  cout<<ans;
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 4004
a, b = map(int, input().split())
ans = 0
for i in range(a, b+1):
  temp = []
  for j in range(5):
    d = 10**(4-j)
    p = i//d
    temp.append(p)
    i -= p*d
  if temp[0] == temp[4] and temp[1] == temp[3]:
    ans += 1
print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
from itertools import product, combinations
from operator import itemgetter
def inpl(): return tuple(map(int, input().split()))

N, K = inpl()
X = []
Y = []
Px = []
Py = []

for i in range(N):
    x, y = inpl()
    X.append(x)
    Y.append(y)
    Px.append((x, i))
    Py.append((y, i))

X = sorted(X)
Y = sorted(Y)

dX = {x:i for i, x in enumerate(X)}
dY = {y:i for i, y in enumerate(Y)}
Px = sorted(Px)
Py = sorted(Py)

get = itemgetter(1)
res = 5 * 10**18

for (l, r), (d, u) in product(combinations(X, 2), combinations(Y, 2)):
    if (dX[r] - dX[l] < K-1) or (dY[u] - dY[d] < K-1):
        continue
    if res < (r-l)*(u-d):
        continue

    sx = set(map(get, Px[dX[l]:dX[r]+1]))
    sy = set(map(get, Py[dY[d]:dY[u]+1]))
    if len(sx.intersection(sy)) >= K:
        res = min(res, (r-l)*(u-d))

print(res)

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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int main() {
  string s;
  cin >> s;
  deque<char> q;
  itr(s) q.push_back(v);
  bool rev = false;
  int n;
  cin >> n;
  repi(n) {
    int com;
    cin >> com;
    if (com == 1) {
      rev = !rev;
      continue;
    }
    int f;
    char c;
    cin >> f >> c;
    if ((f == 1 && !rev) || (f == 2 && rev)) {
      q.push_front(c);
    } else {
      q.push_back(c);
    }
  }
  if (rev) {
    for (auto i = q.rbegin(); i != q.rend(); ++i) cout << *i;
  } else {
    itr(q) cout << v;
  }
  cout << endl;
}


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

int main() {
    int N;
    scanf("%d", &N);
    int *B = malloc(N * sizeof(int));
    for (int i = 1; i < N; i++) {
        scanf("%d", &B[i]);
    }
    int ans = B[1];
    for (int i = 2; i < N; i++) {
        if (B[i-1] > B[i])
            ans += B[i];
        else
            ans += B[i-1];
    }
    ans += B[N-1];
    printf("%d\n", ans);

    return 0;
}


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

int main()
{
  int N; cin >> N;
  int a[3*N]; rep(i,3*N) cin >> a[i];
  sort(a, a+3*N);
  long long sum = 0;
  for(int i = N; i < 3*N; i+= 2)
  {
    sum += a[i];
  }
  cout << sum << endl;
}

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

namespace ConsoleApplication4
{
    class Program
    {

        static void Main(string[] args)
        {

           
            var s = Console.ReadLine().TrimEnd('L').TrimEnd('A').TrimEnd('V').TrimEnd('I').TrimEnd('T').TrimEnd('S').TrimEnd('E').TrimEnd('F');
            Console.WriteLine(s);

        }


    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define fill(c,v) memset(c,v,sizeof(c));
#define prarr(a,n) rep(n) cout<<a[i]<<" \n"[i==n-1]; 
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define ff first
#define ss second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n;
    int x=0,y=n;
    int p = 1;
    while(n)
    {
    	x+=n%10;
    	// n = n/
    	n = n/(int)pow(10,p);
    	// n = n/(int)pow(10,p);
    	// p++;	
    }
    if(y%x==0)
    	printf("%s\n","Yes" );
    else
    	printf("%s\n","No" );
    return 0;

}


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

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K = map(int,readline().split())
H = list(map(int,readline().split()))

ans = 0
for h in H:
    if h >= K:
        ans += 1

print(ans)

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

int main() {
    int n, x, c;
    while(1){
        c = 0;
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                for(int k = j + 1; k <= n; k++){
                    if(i + j + k == x) c++;
                }
            }
        }
        cout << c << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
	using namespace std;
	
	#define MAX 5002
	
	int n;
	
	vector<int> v[MAX];
	
	long long int dp[MAX][MAX][2];  //node, unpaired nodes, parity of cut edges
	int cnt[MAX];
	#define MOD 1000000007
	long long int tmp[MAX][2];
	long long int f[MAX];
	
	inline void dfs(int b,int pr=-1){
		cnt[b]=1;
		dp[b][1][0]=1;
		for(int go:v[b]){
			if(pr==go)continue;
			dfs(go,b);
			for(int i=0;i<=cnt[b]+cnt[go];i++)tmp[i][0]=tmp[i][1]=0;
			for(int i=0;i<=cnt[b];i++){
				for(int j=0;j<=cnt[go];j++){
					for(int k=0;k<2;k++){
						for(int kk=0;kk<2;kk++){
							tmp[i+j][k^kk]+=dp[b][i][k]*dp[go][j][kk];
							if(tmp[i+j][k^kk]>=MOD){
								tmp[i+j][k^kk]%=MOD;
							}
							if(j%2==0){
								long long int way=dp[go][j][kk]*f[j];
								if(way>=MOD)way%=MOD;
								tmp[i][k^kk^true]+=dp[b][i][k]*way;
								if(tmp[i][k^kk^true]>=MOD)tmp[i][k^kk^true]%=MOD;
							}
						}
					}
				}
			}
			cnt[b]+=cnt[go];
			for(int i=cnt[b];i>=0;i--){
				for(int k=0;k<2;k++){
					dp[b][i][k]=tmp[i][k];
				}
			}
		}
	}
	int main(){
		cin>>n;
		for(int i=1;i<n;i++){
			int a,b;
			scanf("%d%d",&a,&b);
			a--;
			b--;
			v[a].push_back(b);
			v[b].push_back(a);
		}
		f[0]=1;
		for(int i=2;i<MAX;i++){
			f[i]=f[i-2];
			f[i]*=(long long int)(i-1);
			if(f[i]>=MOD)f[i]%=MOD;
		}
		dfs(0);
		long long int ans=0;
		for(int i=0;i<=cnt[0];i++){
			for(int j=0;j<2;j++){
				if(i%2==0){
					long long int z=f[i]*dp[0][i][j];
					z%=MOD;
					if(j==0){
						ans+=z;
					}
					else{
						ans+=MOD-z;
					}
					if(ans>=MOD)ans-=MOD;
				}
			}
		}
		printf("%lld\n",ans);
		return 0;
	}
	


Measured memory_bytes: 390400
s = input()

if len(s) == 2 and s[0] == s[1]:
    print(1, 2)
    exit()

for start in range(len(s) - 2):
    a, b ,c = s[start:start + 3]
    if (a == b and b != c) or (a != b and b == c) or (a == c and a != b):
        print(start + 1, start + 3)
        break
else:
    print(-1, -1)

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



int main() {
    string s, t;
    int a, b;
    string u;
    
    cin >> s >> t >> a >> b >> u;
    
    if(s == u)
        a--;
    else if(t == u)
        b--;
    
    cout << a << " " << b << endl;
    
    
    return 0;
}


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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
#define fcout cout<<fixed<<setprecision(10)
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//template<typename T>void pp(T x){cout<<x<<endl;}

using namespace std;
template<typename T> void test(vector<T> v){for(int i=0;i<v.size();i++){if(i)cout<<" ";cout<<v[i];}cout<<endl;}

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int x,y;
    cin>>x>>y;

    int ans=0;
    rep(i,1,n){
        int px=x,py=y;
        cin>>x>>y;
        if(px==x&&py!=y)ans+=abs(py-y);
        else if(px!=x&&py==y)ans+=abs(px-x);
        else if((px>x&&py>y)||(px<x&&py<y)){
            int diffx=abs(px-x), diffy=abs(py-y);
            int mindiff=min(diffx,diffy);
            ans+=mindiff;
            diffx-=mindiff;
            diffy-=mindiff;
            ans+=diffx+diffy;
        }else {
            int diffx=abs(px-x), diffy=abs(py-y);
            ans+=diffx+diffy;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  if(n%7==0||n%4==0)
    cout << "Yes";
  else{
    for(int i=0;i<1;){
      n=n-4;
        if(n%7==0){
          cout << "Yes";
          break;
        }
      if(n<4){
        cout << "No";
        break;
      }
    }
  }
}

Measured memory_bytes: 256
def main():
    H, W = (int(i) for i in input().split())
    A = [[int(i) for i in input().split()] for j in range(H)]
    coin_sum = 0
    for a in A:
        coin_sum += sum(a)
    ope_xy = []
    if coin_sum % 2 == 0:
        for h in range(H):
            for w in range(W):
                if A[h][w] & 1:
                    A[h][w] -= 1
                    if w < W - 1:
                        A[h][w + 1] += 1
                        ope_xy.append((h, w, h, w+1))
                    elif h < H - 1:
                        A[h + 1][w] += 1
                        ope_xy.append((h, w, h+1, w))
                    elif w == W - 1 and h == H - 1:
                        if A[h][w-1] & 1:
                            A[h][w-1] += 1
                            ope_xy.append((h, w, h, w-1))
                        else:
                            A[h-1][w] += 1
                            ope_xy.append((h, w, h-1, w))
    else:
        for h in range(H):
            for w in range(W):
                if A[h][w] & 1:
                    A[h][w] -= 1
                    if w < W - 1:
                        A[h][w + 1] += 1
                        ope_xy.append((h, w, h, w+1))
                    elif h < H - 1:
                        A[h + 1][w] += 1
                        ope_xy.append((h, w, h+1, w))
    print(len(ope_xy))
    for xy in ope_xy:
        print(xy[0] + 1, xy[1] + 1, xy[2] + 1, xy[3] + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71260
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
 
int main(){
  string N;
  cin>>N;
  ll cnt=0;
  rep(i,N.length()){
    cnt+=N[i]-'0';
  }
  if(cnt%9==0){
    cout<<"Yes"<<endl;
  }
  if(cnt%9!=0){
    cout<<"No"<<endl;
  }
}

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

vector<pair<ll, ll>> primeFactorize(ll n) {
  vector<pair<ll, ll>> r;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) {
      continue;
    }
    ll ex = 0;
    while (n % i == 0) {
      ex++;
      n /= i;
    }
    r.push_back({i, ex});
  }
  if (n > 1) {
    r.push_back({n, 1});
  }
  return r;
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  auto res = primeFactorize(g);
  ll v = 1;
  for (auto r: res) {
		v++;
  }
	cout << v <<endl;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] s_char = s.toCharArray();

        char[] output = new char[10];
        int index = 0;
        for (char ch : s_char) {
            switch (ch) {
                case '0':
                case '1':
                    output[index++] = ch;
                    break;
                case 'B':
                    index = Math.max(0, index - 1);
            }
        }
        for (int i = 0; i < index; i++) {
            System.out.print(output[i]);
        }
        System.out.print("\n");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define INF 2000000000
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
//gcd,lcmセット
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);
}
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main(){
    int a[3][3];
    REP(i,3)REP(j,3) cin>>a[i][j];
    int n;
    cin>>n;
    int b;
    REP(i,n){
        cin>>b;
        REP(j,3)REP(k,3)if(a[j][k]==b)a[j][k]=0;
    }
    string ans="No";
    REP(i,3)if(a[i][0]+a[i][1]+a[i][2]==0||a[0][i]+a[1][i]+a[2][i]==0){
        ans="Yes";
      break;
    }
    if(a[0][0]+a[1][1]+a[2][2]==0||a[2][0]+a[1][1]+a[0][2]==0){
        ans="Yes";
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int mod = 1000'000'007;

long long c(int n, int a);
long long p(long long a, long long b);

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

	long long ans = p(2, n);
	ans--;

	ans = ans - c(n, a) - c(n, b) + mod + mod;
	ans %= mod;

	cout << ans << endl;

	return 0;
}

long long c(int n, int a)
{
	long long x = 1;
	long long y = 1;
	for (int i = 0; i < a; i++) {
		y *= n - i;
		x *= a - i;
		y %= mod;
		x %= mod;
	}
	return (y * p(x, mod - 2)) % mod;
}

long long p(long long a, long long b)
{
	long long t = a;
	int s = b;
	long long ans = 1;
	for (int i = 0; i < 31; i++) {
		if ((s & 1) == 1) {
			ans *= t;
			ans %= mod;
		}
		t *= t;
		t %= mod;
		s >>= 1;
	}

	return ans;
}

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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for(int i = s; i < (e); ++i)
#define FASTIO                                                                                     \
	ios_base::sync_with_stdio(false);                                                              \
	cin.tie(NULL);
#define FILEIO                                                                                     \
	freopen("./input.txt", "r", stdin);                                                            \
	freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                                                  \
	for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;  \
		debug("%s : %lld ms\n ",                                                                   \
			  d,                                                                                   \
			  chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() -   \
														  blockTime.first)                         \
				  .count()),                                                                       \
			 blockTime.second = false)
const int M = 200000 + 10;

template <class T>
T ABS(const T& x) {
	return x > 0 ? x : -x;
}
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }
ll ceil2(ll a, ll b) { return (a + b - 1) / b; }

char arr[M];

int main() {
	FASTIO
#ifdef LOCAL
	FILEIO
#endif
	int n;
	cin >> n;
	int cntw = 0, cntr = 0;
	forn(i, 0, n) {
		cin >> arr[i];
		if(arr[i] == 'W') ++cntw;
		else
			++cntr;
	}
	int cnt = 0;
	for(int i = n - 1; i >= n - cntw; --i)
		if(arr[i] == 'W') ++cnt;
	cout << cntw - cnt << endl;

	return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  long long N,ans;
  int ANS = 0;
  cin >> N;
  for (long long i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      ans = N / i;
    }
  }
  while (ans != 0) {
    ans /= 10;
    ANS++;
  }
  cout << ANS << endl;
  return 0;
}


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

using namespace std;

int main(){
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  while(true){
  	c -= b;
    if(c <= 0) {
      cout << "Yes";
      break;
    }
    a -= d;
    if(a <= 0){
      cout << "No";
      break;
    }
  } 
  cout << "\n";
 return 0; 
}

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

int main()
{
	int N, A, B;
	cin >> N;
	cin >> A;
	cin >> B;
	if (N*A < B)
	{
		cout << N * A << endl;
	}
	else {
		cout << B << endl;
	}
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_e

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
MOD = 10**9 + 7


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
A = read_ints()
# 重要な考察
# 1, i番目の人がかぶれる帽子は[0,i)における帽子の内訳の中で,A_iに数が等しいものである
# 2, i番目における各帽子の個数は(色はわからないけど)確定できる. ∵A_iに等しい個数の帽子がかぶれるということとは、次はその個数+1個の帽子があるはず

# よってAi、通りの数を取得ansに掛け算。さらに各種帽子の個数を更新してA{i+1}の処理に映れば良い

ans = 1
c = [0, 0, 0]
for a in A:
    ans *= c.count(a)  # 通りの数に加算
    for i in range(3):
        if a == c[i]:
            c[i] += 1
            break
    if ans > MOD:
        ans %= MOD
print(ans)


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

using namespace std;

const double PI = acos(-1.0); 
using cd = complex<double>;

void solve() {
    int n; double L;
    cin >> n >> L;
    vector<double> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cd res;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            res += polar(1.0, PI*(a[i]+a[j])/L) * (double)(n-j-1 + i);
            res += polar(1.0, PI*(a[i]+a[j])/L + PI) * (double)(j - i - 1);
        }
    }
    double tot = double(n)*(n-1)*(n-2)/6;
    res /= tot;
    cout << fixed << setprecision(10);
    cout << res.real() << ' ' << res.imag();
}
void fast() {
    int n; double L;
    cin >> n >> L;
    cd res;
    cd f, g;
    for (int i = 0; i < n; i++) {
        double x; cin >> x;
        cd a = polar(1.0, PI*x/L);
        res += f * a + g  * double(n-2*i) * a;
        f += a * double(2*i);
        g += a;
    }
    double tot = double(n)*(n-1)*(n-2)/6;
    res /= tot;
    cout << fixed << setprecision(10);
    cout << res.real() << ' ' << res.imag();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //solve();
    fast();
    cout << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll X, Y, Z, K; cin >> X >> Y >> Z >> K;
  vector<ll> a(X), b(Y), c(Z);
  rep(i, X) cin >> a[i];
  rep(i, Y) cin >> b[i];
  rep(i, Z) cin >> c[i];
  sort(a); sort(b); sort(c);

  vector<ll> v;
  for (int i = 1; i <= min(X, K); i++) {
    for (int j = 1; j <= Y; j++) {
      if (i * j > K) break;
      for (int k = 1; k <= Z; k++) {
        if (i * j * k > K) break;
        // debug3(a[X-i], b[Y-j], c[Z-k]);
        v.emplace_back(a[X-i] + b[Y-j] + c[Z-k]);
      }
    }
  }
  sort(v);
  ll vi = v.size() - 1;
  rep(i, K) outl(v[vi-i]);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 1404
#include <cstdio>
#include <set>
#include <tuple>

using namespace std;

const int N = 59;

int a[N][N];
long long b[N][N];
int c[N];
int dd[N];
long long d[N][N * N];

int main() {
  int n, m, ss;
  scanf("%d%d%d", &n, &m, &ss);
  const long long inf = 1'000'000'000'000'000'000;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      b[i][j] = inf;
      a[i][j] = 1'000'000'000;
    }
  }
  for (int i = 0; i < m; ++i) {
    int x, y, na, nb;
    scanf("%d%d%d%d", &x, &y, &na, &nb);
    --x;
    --y;
    a[x][y] = a[y][x] = na;
    b[x][y] = b[y][x] = nb;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", c + i, dd + i);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < N * N; ++j) {
      d[i][j] = inf;
    }
  }
  ss = min(ss, 50 * (n - 1));
  d[0][ss] = 0;
  set<tuple<long long, int, int>> s;
  s.emplace(0, 0, ss);
  while (!s.empty()) {
    int x = get<1>(*s.begin());
    int w = get<2>(*s.begin());
    s.erase(s.begin());
    {
      long long nd = d[x][w] + dd[x];
      int nw = min(w + c[x], 50 * (n - 1));
      if (nd < d[x][nw]) {
        if (d[x][nw] != inf) {
          s.erase(make_tuple(d[x][nw], x, nw));
        }
        d[x][nw] = nd;
        s.emplace(d[x][nw], x, nw);
      }
    }
    for (int y = 0; y < n; ++y) {
      if (a[x][y] > w) {
        continue;
      }
      int nw = w - a[x][y];
      long long nd = d[x][w] + b[x][y];
      if (nd < d[y][nw]) {
        if (d[y][nw] != inf) {
          s.erase(make_tuple(d[y][nw], y, nw));
        }
        d[y][nw] = nd;
        s.emplace(d[y][nw], y, nw);
      }
    }
  }
  for (int i = 1; i < n; ++i) {
    long long ans = inf;
    for (int j = 0; j < N * N; ++j) {
      ans = min(ans, d[i][j]);
    }
    printf("%lld\n", ans);
  }
}


Measured memory_bytes: 7868
from fractions import Fraction
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def judge(a,c,d):
  x = a//c
  y = a//d
  z = a//lcm(d,c)
  return a-x-y+z

a,b,c,d = map(int,input().split())
#print(judge(a-1,c,d))
#print(judge(b,c,d))
ans = judge(b,c,d) - judge(a-1,c,d)
print(ans)

Measured memory_bytes: 5048
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        s: chars,
        t: chars
    }
    let (s_len, t_len) = (s.len(), t.len());
    let mut dp = vec![vec![0; t_len + 1]; s_len + 1];
    for si in 0..s_len {
        for ti in 0..t_len {
            dp[si+1][ti+1] = cmp::max(dp[si][ti] + (s[si] == t[ti]) as i64, cmp::max(dp[si+1][ti], dp[si][ti+1]));
        }
    }
    let mut text = Vec::<char>::new();
    let (mut s_len, mut t_len) = (s_len, t_len);
    while s_len > 0 && t_len > 0 {
        if dp[s_len][t_len] == dp[s_len-1][t_len] {
            s_len -= 1;
        } else if dp[s_len][t_len] == dp[s_len][t_len-1] {
            t_len -= 1;
        } else {
            s_len -= 1;
            t_len -= 1;
            text.push(s[s_len]);
        }
    }
    println!("{}", text.into_iter().rev().collect::<String>());
}


Measured memory_bytes: 90364
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef vector<ll> row;
typedef vector<row> mat;

ll N, M, K, P[10000];

row mul(row &A, row &B) {
  row C(N);
  REP(i, 0, N)
    REP(j, 0, N)
      C[i] = (C[i] + A[j] * B[(i - j + N) % N]) % MOD;
  return C;
}

row pow(row A, ll n) {
  row B(N);
  B[0] = 1;
  while(n > 0) {
    if(n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}


int main(void) {
  cin >> N >> M >> K;
  REP(i, 0, M) cin >> P[i];

  row A(N);
  A[0]++;
  REP(i, 0, M) A[P[i] % N]++;
  A = pow(A, K);

  REP(i, 0, N) cout << A[i] << endl;
}

Measured memory_bytes: 3252
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]
up = 0
down = 0
ans = 0
for i in range(n):
  up += a[0][i]
  if down == 0: down += sum(a[1])
  else: down -= a[1][i-1]
  if up+down > ans: ans = up+down
print(ans)

Measured memory_bytes: 3064
import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))

ans_1 = min(H[np.where(H==H.max())[0].min():]) > max(H)-2

tmp = H[1:] - H[:-1]

ans_2 = all(tmp > -2)

print("Yes") if ans_1 & ans_2 else print("No")

Measured memory_bytes: 23108
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> p(n);
  rep(i, n)
    cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());
  map<pair<int, int>, int> mp;
  rep(i, n) rep(j, i) {
    int x = p[i].first-p[j].first;
    int y = p[i].second-p[j].second;
    mp[{x, y}]++;
  }
  int ans = 0;
  for (auto e : mp)
    chmax(ans, e.second);
  ans = n-ans;
  cout << ans << endl;
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	is >> p.first >> p.second;
	return (is);
}

const int INF = numeric_limits<int>::max();

template<typename T>
struct SegmentTree {

	T id;
	function <T(T, T)> op;
	vector<T> dat;
	int size;

	SegmentTree(int n, T id, function <T(T, T)> op) : id(id), op(op) {
		size = 1;
		while (size < n) size <<= 1;
		dat.assign(size * 2 + 10, id);
	}

	void update(int k, T x) {
		k += size, dat[k] = x;
		while (k > 1) k >>= 1, dat[k] = op(dat[k << 1], dat[(k << 1) | 1]);
	}

	void merge(int k, T x) { update(k, op(x, dat[k + size])); }
	//[a, b)
	T query(int a, int b) {
		T tl = id, tr = id;
		for (int l = a + size, r = b + size; l < r; l >>= 1, r >>= 1) {
			if (l & 1) tl = op(tl, dat[l++]);
			if (r & 1) tr = op(tr, dat[--r]);
		}
		return (op(tl, tr));
	}
};


int main()
{
	int N;
	vint pos(200005);

	SegmentTree<int> seg1(200005, INF, [](int a, int b) { return (min(a, b)); } );
	SegmentTree<int> seg2(200005, INF, [](int a, int b) { return (min(a, b)); } );

	auto inspect = [&](int l, int r) {
		int val1 = (l&1?seg2:seg1).query(l, r);
		int val2 = (l&1?seg1:seg2).query(pos[val1], r);
		return (Pi(val1, val2));
	};

	cin >> N;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		(i%2 == 0 ? seg1 : seg2).update(i, A);
		pos[A] = i;
	}

	priority_queue<pair<Pi, Pi>, vector<pair<Pi, Pi>>, greater<pair<Pi, Pi>>> que;
	que.emplace(inspect(0, N), Pi(0, N));

	vint ans;

	while (!que.empty()) {
		Pi value, range;
		int l, r;
		tie(value, range) = que.top(); que.pop();	
		tie(l, r) = range;
		ans.push_back(value.first); ans.push_back(value.second);
		int posl = pos[value.first], posr = pos[value.second];

		if (l + 1 < posl) que.emplace(inspect(l, posl), Pi(l, posl));
		if (posl + 2 < posr) que.emplace(inspect(posl + 1, posr), Pi(posl + 1, posr));
		if (posr + 2 < r) que.emplace(inspect(posr + 1, r), Pi(posr + 1, r));
	}
	cout << ans[0];
	for (int i = 1; i < N; i++) cout << " " << ans[i];
	cout << endl;

	return (0);
}

Measured memory_bytes: 7924
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int N,K;cin>>N>>K;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int ans = 0;
    for(int i=0;i<K;i++){
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592