akhauriyash/Code-Regression huggingface dataset:
H,W = map(int,input().split())
src = [input() for i in range(H)]

def solve():
    cums = [[0]*(H+W) for y in range(H+W-1)]
    coins = [[] for y in range(H+W-1)]
    for i in range(H):
        for j in range(W):
            if src[i][j] == '.': continue
            x,y = j-i+H, j+i
            cums[y][x] += 1
            coins[y].append(x)
    for i in range(H+W-1):
        for j in range(H+W-1):
            cums[i][j+1] += cums[i][j]
    cnt = 0
    for y1 in range(H+W-1):
        if len(coins[y1]) < 2: continue
        for i1 in range(len(coins[y1])-1):
            for i2 in range(i1+1,len(coins[y1])):
                x1,x2 = coins[y1][-1-i1], coins[y1][-1-i2]
                y2 = y1 - (x2 - x1)
                if y2 < 0: continue
                cnt += cums[y2][x2] - cums[y2][x1]
    return cnt

def rotate():
    global H,W,src
    H,W = W,H
    src2 = []
    for col in reversed(list(zip(*src))):
        src2.append(''.join(list(col)))
    src = src2

ans = 0
for i in range(4):
    rotate()
    ans += solve()
print(ans)

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {


            var input = Console.ReadLine();
            string prev = string.Empty;
            var output = "Good";
            foreach (var item in input)
            {
                if (prev == item.ToString())
                {
                    output = "Bad";
                }
                prev = item.ToString();
            }
            Console.WriteLine(output);


        }




       

    }
}


Measured memory_bytes: 11092
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


# MOD = int(1e09) + 7
MOD = 2019
INF = int(1e15)


def solve():
    S = Scanner.string()
    N = len(S)
    S = S[::-1]
    p = 1
    total = 0
    cnt = [0 for _ in range(MOD)]
    ans = 0
    for i in range(N):
        cnt[total] += 1
        total += int(S[i]) * p
        total %= MOD
        ans += cnt[total]
        p = p * 10 % MOD
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10804
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	int x[4], y[4];
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	int vx, vy;
	vx = x[1] - x[0];
	vy = y[1] - y[0];
	swap(vx,vy);
	vx *= -1;
	x[2] = x[1] + vx;
	y[2] = y[1] + vy;
	cout << x[2] << " " << y[2] << " ";
	swap(vx, vy);
	vx *= -1;
	x[3] = x[2] + vx;
	y[3] = y[2] + vy;
	cout << x[3] << " " << y[3] << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<b&&b<c){
cout<<a<<" "<<b<<" "<<c<<endl;
}
  if(a<c&&c<b){
cout<<a<<" "<<c<<" "<<b<<endl;
}
  if(b<a&&a<c){
cout<<b<<" "<<a<<" "<<c<<endl;
}
  if(b<c&&c<a){
cout<<b<<" "<<c<<" "<<a<<endl;
}
  if(c<a&&a<b){
cout<<c<<" "<<a<<" "<<b<<endl;
}
  if(c<b&&b<a){
cout<<c<<" "<<b<<" "<<a<<endl;
}
  if(a==c&&c<b){
cout<<a<<" "<<c<<" "<<b<<endl;
}
  if(b==c&&c<a){
cout<<b<<" "<<c<<" "<<a<<endl;
}
 return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <map>
#include <algorithm>
typedef long long ll;
using namespace std;
map<ll,int> m;
ll sum[200005];
ll ans;
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    sum[i+1] = sum[i] + a;
    m[sum[i+1]]++;
  }

  ans += m[0];
  
  for(int i = 1; i <= n; i++) {
    int tmp = m[sum[i]] - 1;
    // cout << sum[i] <<"   "<<tmp << endl;
    if(tmp > 0) {
      ans += tmp;
      m[sum[i]]--;
    }
  }
  
  cout << ans << endl;
}

  


Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

const int vx[4] = {0, 1, 0, -1}, vy[4] = {1, 0, -1, 0};

inline bool check(int x, int y, int H, int W) {
  return (0 <= x && x < H && 0 <= y && y < W);
}

int solve(int& H, int& W, std::vector<std::string>& v) {
  int ret = 1, sx, sy;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; ++j) {
      if (v[i][j] == '@') {
        sx = i, sy = j;
      }
    }
  }

  bool is_searched[21][21];

  std::memset(is_searched, false, sizeof is_searched);

  std::queue<std::pair<int, int> > que;
  que.push(std::make_pair(sx, sy));
  is_searched[sx][sy] = true;

  while (!que.empty()) {
    auto p = que.front();
    que.pop();

    for (int i = 0; i < 4; ++i) {
      int nx = p.first + vx[i], ny = p.second + vy[i];

      if (check(nx, ny, H, W) && !is_searched[nx][ny] && v[nx][ny] == '.') {
        ret++;
        is_searched[nx][ny] = true;
        que.push(std::make_pair(nx, ny));
      }
    }
  }

  return ret;
}

int main() {
  int H, W;

  while (cin >> W >> H, W | H) {
    std::vector<std::string> v(H);

    for (int i = 0; i < H; ++i) {
      cin >> v[i];
    }

    int ans = solve(H, W, v);

    cout << ans << endl;    
  }

  return 0;
}



Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a[] = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        long b[] = new long[n];
        b[0] = 0;
        for (int i = 1; i < n; i++) {
            if (a[i - 1] <= a[i]) {
                b[i] = 0;
            } else {
                b[i] = a[i - 1] - a[i];
            }
            a[i] += b[i];
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += b[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 61608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  if( (B-1)%(A-1) == 0){
    cout << (B-1)/(A-1) << endl;
  }
  else if( (B-1)%(A-1) != 0){
    cout << (B-1)/(A-1) +1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int r,c;
    std::cin>>r>>c;
    int m[100][100]={{}};
    int csum[100]={},rsum[100]={};
    int tsum = 0;

    for(int i = 0; i < r; i++)
    {
        for(int j = 0; j < c; j++)
        {
        std::cin>>m[i][j];
        tsum += m[i][j];
        rsum[i] += m[i][j];
        csum[j] += m[i][j];
        }
    }

    for(int i = 0; i < r + 1; i++)
    {
        for(int j = 0; j < c + 1; j++)
        {
            if(i==r&&j==c){std::cout<<tsum<<std::endl;}
            else if(i==r&&j!=c){std::cout<<csum[j]<<" ";}
            else if(j==c&&i!=r){std::cout<<rsum[i]<<std::endl;}
            else{std::cout<<m[i][j]<<" ";}
        }
    }
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<ll, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int maxn = 1e5+5;
const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"No\n"; exit(0);}


main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, k; cin>>n>>k;
    cout<<n-k+1<<endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC089_B();
        }
        
        static void ABC089_B()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().Split(' ');
            var set = new HashSet<string>();

            foreach (var s in S)
                set.Add(s);

            Console.WriteLine(set.Count == 4 ? "Four" : "Three");
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0)
                throw new Exception("0未満");

            if (start > stop || (start == 0 && stop == 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }
    }
}

Measured memory_bytes: 11232
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,-1,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fst first
#define sec second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}

int main()
{
	//fopen();
	fastio;
	ll n,m;
	cin>>n>>m;
	ll a[n];
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	ll i=0,j=10000000010;
	//cout<<j;
	while(j-i>1)
	{
		ll mid=(j+i)/2;
		ll cunt=0;
		rep(i,n){ 
			ll t=lower_bound(a,a+n,mid-a[i])-a;
			cunt+=n-t;
			//cout<<t;
		}
		//cout<<endl;
		if(cunt>=m)i=mid;
		else j=mid;
	}
	ll r[n];
	//cout<<i<<endl;
	rep(j,n) r[j]=a[j]+(j?r[j-1]:0);
	//cout<<r[1]<<endl;
	ll ans=0;
	ll cnt=0;
	rep(j,n){
		ll k=lower_bound(a,a+n,i-a[j])-a;
		ans+=r[n-1]-(k?r[k-1]:0);
		ans+=a[j]*(n-k);
		cnt+=(n-k);
	}
	//cout<<ans<<endl;
	ans-=(cnt-m)*i;
	cout<<ans;
	return 0;
}


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

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

    long long a = 0;
    vector<long long> v_a;
    for(int i=0; i<N; i++)
    {
        cin >> a;
        v_a.push_back(a);
    }

    long long x = 0;

    auto it_b = v_a.begin();
    auto it_e = v_a.end();

    it_e--;

    while(it_b != it_e)
    {
      // cout << "x : ";
      // cout << x << endl;
        if(x>0)
        {
            // 左側のほうが長い→後ろを進める
            x = x - *it_e;
            it_e--;
        }
        else
        {
            // 右側のほうが長い→前を進める
            x = x + *it_b;
            it_b++;
        }
    }

    // cout << "x : ";
    // cout << x << endl;

  // 真ん中をまだ精算してない
    if(x>0)
    {
        // 左側のほうが長い→後ろを進める
        x = x - *it_e;
    }
    else
    {
        // 右側のほうが長い→前を進める
        x = x + *it_b;
    }
    
    cout << abs(x) << endl;
    return 0;
}

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

using namespace std;

int a[100000] , b, n, ans, line[100001];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		line[a[i]]++;
	}
	ans = 1;
	if(n % 2 == 1){
		if(line[0] == 1){
			for(int i = 2; i < n; i += 2){
				if(line[i] != 2){
					cout << 0;
					return 0;
				}
				b++;
			}
		}
		else{
			cout << 0;
			return 0;
		}
	}
	else{
        for(int i = 1; i < n; i += 2){
            if(line[i] != 2){
                cout << 0;
                return 0;
            }
            b++;
			}
	}
	for(int i = 0; i < b; i++){
		ans = 2 * ans;
		ans = ans % 1000000007;
	}
	cout << ans % 1000000007;
}


Measured memory_bytes: 1024
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

int main()
{
	int n;
	
	while (cin>>n) {
		int ans=0;
		rep(i, 10) {
			rep(j, 10) {
				rep(k, 10) {
					if (n-i-j-k>=0 && n-i-j-k<10)
						ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x = (c+b-1)/b,y=(a+d-1)/d;
    if(y<x)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <cmath>
#include <iostream>
#include <map>
#include <vector>

int main() {
	int N = 0;
	std::string S1, S2;

	std::cin >> N >> S1 >> S2;

	/*
	 *    xoo  x.o  xxo
	 *    x..  x.o  ..o
	 */

	std::uint64_t count = 1;
	std::uint64_t mod   = std::pow(10, 9) + 7;

	for (int i = 0; i < N; ++i) {
		if (S1[i] == S2[i]) {
			if (i == 0) {
				count *= 3;
				count %= mod;
			} else if (S1[i - 1] == S2[i - 1]) {
				count *= 2;
				count %= mod;
			}
		} else {
			if (i == 0) {
				count *= 6;
				count %= mod;
			} else if (S1[i - 1] == S2[i - 1]) {
				count *= 2;
				count %= mod;
			} else {
				count *= 3;
				count %= mod;
			}
			++i;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 256
import sys

N, M = map(int, input().split())

if M == 0:
    alist = set()
else:
    # Input below rows
    alist = set(map(int, sys.stdin))

dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 1 if 1 not in alist else 0

MOD = 10**9 + 7
for i in range(2, N + 1):
    if i in alist:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % MOD

print(dp[N])

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

int main(void){
	ll a,b;
	cin>>a>>b;
	ll diva=a/2019;
	ll divb=b/2019;
	a=a%2019;
	b=b%2019;
	if(b<a){
		ll temp=a;
		a=b;
		b=temp;
	}
  	if(diva==divb){
  		ll ans=INT_MAX;
	for(ll i=a;i<=b;i++){
      	for(ll j=i+1;j<=b;j++){
          	ans=min(ans,(i*j)%2019);
        }
    }
  	cout<<ans<<endl;
  	}
  	else cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List

main=putStrLn =<< chk.reverse<$>getLine

chk s
    | isPrefixOf "resare"  s = chk $ drop 6 s
    | isPrefixOf "esare"   s = chk $ drop 5 s
    | isPrefixOf "remaerd" s = chk $ drop 7 s
    | isPrefixOf "maerd"   s = chk $ drop 5 s
    | s == "" = "YES"
    | otherwise = "NO"


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll f(ll x) {
    ll m = x % 4;
    if (m == 0) {
        return x;
    } else if (m == 1) {
        return 1;
    } else if (m == 2) {
        return x + 1;
    } else {
        return 0;
    }
}

void Main() {
    ll A, B;
    cin >> A >> B;
    cout << (f(A - 1) ^ f(B)) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int a[100010],f[100010];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    f[1]=0;
    for(int i=2;i<=n;i++)
    {
        f[i]=0x7fffffff;
        for(int j=1;j<=k;j++)
        {
            if(i-j<=0)break;
            f[i]=min(f[i],f[i-j]+abs(a[i-j]-a[i]));
        }
    }
    cout<<f[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
work = [list(map(int,input().split())) for _ in range(n)]
work = sorted(work,key = lambda x:x[1])
a = [0] * n
a[0] = work[0][0]
for i in range(1,n):
    a[i] = a[i-1] + work[i][0]
ans = 'Yes'
for j in range(n):
    if a[j] > work[j][1]:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 118624
#include <stdio.h>

int main(int argc, char *args[])
{
	int i;
	int x;
	int n;

	scanf("%d", &n);

	for( i=1; i<=n; i++ ) {
		x=i;
		if( x%3 == 0 ) {
			printf(" %d", i );
		}
		else {
			do {
				if( x%10 == 3 ) {
					printf(" %d", i );
					break;
				}
				x /= 10;
			} while(x);
		}
	}
	printf("\n");

	return 0;

}

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

int main(){
	int n,m;cin >> n >> m;
	vector<vector<int>> v;
	vector<int> p;
	int ans = 0;
	for(int i = 0;i < m;i++){
		int k;cin >> k;
		vector<int> vt;
		for(int j = 0;j < k;j++){
			int t;cin >> t;
			vt.push_back(t);
		}
		v.push_back(vt);
	}
	for(int i = 0;i < m;i++){
		int t;cin >> t;
		p.push_back(t);
	}
	for(int i = 0;i < (1 << n);i++){
		bool flag = true;
		int ind = 0;
		for(vector<int> vv : v){
			int cnt = 0;
			for(int j : vv){
				if((1 << (j - 1)) & i)cnt++;
			}
			if((cnt & 1) != (p[ind] & 1)){
				flag = false;
				break;
			}
			ind++;
		}
		if(flag)ans++;
	}
	cout << ans;
}
// make pair, tuple
// make pair, tuple
// 
// __gcd(int, int);
// lcm = a * b / __gcd(a, b);
// 
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }
// 
// #Count leading & trailing zero of an integer bits
// __builtin_clz(n);
// __builtin_clzll(n);
//
// #Count 1s bits of an integer
// __builtin_popcount(n);
// __builtin_popcountll(n);
//
// #Error checking
// assert(n == 3);
// 
// #Error Printing
// cerr << "Some thing";

// #binary exponentiation
// long long binpow(long long a, long long b) {
//     long long res = 1;
//     while (b > 0) {
//         if (b & 1)
//             res = res * a;
//         a = a * a;
//         b >>= 1;
//     }
//     return res;
// }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

unsigned int count = 0;
std::vector<std::vector<unsigned int> > graph;
std::vector<bool> visited;

void solve(unsigned int index){

bool flg = true;

for (auto it = graph[index].begin(); it != graph[index].end(); ++it){
if (visited[*it]){
continue;
}

flg = false;

visited[*it] = true;
solve(*it);
visited[*it] = false;

}

if (flg){

for (unsigned int i = 0; i < visited.size(); ++i){
if (!visited[i]){
return;
}
}

++count;

}

}

int main(){
unsigned int N, M;
std::string line;

std::cin >> N >> M;
std::getline(std::cin, line);

for (unsigned int i = 0; i < N; ++i){
graph.push_back(std::vector<unsigned int>());
visited.push_back(false);
}

for (unsigned int i = 0, a, b; i < M; ++i){
std::cin >> a >> b;
std::getline(std::cin, line);
graph[a-1].push_back(b-1);
graph[b-1].push_back(a-1);
}

visited[0] = true;
solve(0);

std::cout << count << std::endl;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e5)
#define INFL LLONG_MAX
#define NINFL LLONG_MIN
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a) a.begin(),a.end()
using namespace std;

int main() {
	FIO;
	int t = 1;
	//cin >> t;
	while (t--) {
		ll n,m;
		cin >> n >> m;
		vl v(n,0);
		for(int i=0;i<m;i++){
			ll l,r;
			cin >> l >> r;
			l--;
			v[l]++;
			if(r < n) v[r]--;
		}
		ll ans = 0;
		if(v[0] == m) ans++;
		for(int i=1;i<n;i++){
			v[i] += v[i-1];
			if(v[i] == m) ans++;
		}
		cout << ans << "\n";
	}


	return 0;
}


Measured memory_bytes: 3996
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ll long long
using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    ll sum = 0;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum > n) {
        cout << -1 << endl;
    } else {
        cout << n - sum << endl;
    }
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    while(t--)
        solve();
    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int N = 1e6 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool isp[N];
int p[N];
int len;
vector<int> t;

bool check(int x) {
    if(!isp[(x+1)/2]) return true;
    return false;
}

void init() {
    isp[0] = isp[1] = true;
    for(int i = 2;i <= 100000;i++) {
        if(!isp[i]) {
            p[len++] = i;
            for(int j = i+i;j <= 1000000;j+=i) {
                isp[j] = true;
            }
        }
    }
    for(int i = 0;i < len;i++) {
        if(check(p[i])) t.push_back(p[i]);
    }
  //  for(int i = 0;i < 100;i++) cout<<t[i]<<' ';cout<<endl;
}

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    init();
    int q;cin>>q;
    while (q--) {
        int l,r;cin>>l>>r;
        int T = upper_bound(t.begin(),t.end(),r) - lower_bound(t.begin(),t.end(),l-1);
        cout<<T<<endl;

    }
    return 0;
}


Measured memory_bytes: 3584
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int m=scan.nextInt();
        int f=scan.nextInt();
        int r=scan.nextInt();
        
        while(!(m==-1&&f==-1&&r==-1)){
            
            if(m==-1||f==-1)
                System.out.println("F");
            else if(80<=m+f)
                System.out.println("A");
            else if(65<=m+f)
                System.out.println("B");
            else if(50<=m+f)
                System.out.println("C");
            else if(30<=m+f&&50<=r)
                System.out.println("C");
            else if(30<=m+f)
                System.out.println("D");
            else
                System.out.println("F");
            
            m=scan.nextInt();
            f=scan.nextInt();
            r=scan.nextInt();
        }
    }
}


Measured memory_bytes: 26356
import java.io.BufferedReader;
import java.io.*;

public class Main{
    public static void solution(int[] array,int n,int m){
        int i,j,max,temp;
        max = 0;
        for (i=0;i<n;i++){
            for (j=i+1;j<n;j++){
                temp = array[i] + array[j];
                //System.out.print(temp+" ");
            if (temp > max && temp <= m) max = temp;
            }
        }
        if (max == 0){
            System.out.println("NONE");
        }else{
            System.out.println(max);
        }
    }
    public static void main(String[] args){
        //final String FILENAME = "atest.txt";
        BufferedReader br = null;

        try{
            br = new BufferedReader(new InputStreamReader(System.in));
            String curr;
            while(!(curr = br.readLine()).equals("0 0")){
                String[] nm = curr.split(" ");
                int n = Integer.parseInt(nm[0]);
                int m = Integer.parseInt(nm[1]);
                curr = br.readLine();
                String[] a = curr.split(" ");
                int[] array = new int[1024];
                //System.out.println("ARRAY");
                for (int i = 0; i < n ; i++){
                    array[i] = Integer.parseInt(a[i]);
                    //System.out.print(array[i]+" ");
                }
                //System.out.println();
                solution(array,n,m);
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 31272
def d_cake_123_sort_modified():
    """editorial の解法 1."""
    import sys
    import numpy as np
    input = sys.stdin.readline
    X, Y, Z, K = [int(i) for i in input().split()]
    A = np.array([int(i) for i in input().split()])
    B = np.array([int(i) for i in input().split()])
    C = np.array([int(i) for i in input().split()])

    _a, _b = np.meshgrid(A, B)
    ab = np.sort((_a + _b).flatten())[::-1][:K]
    _ab, _c = np.meshgrid(ab, C)
    ans = np.sort((_ab + _c).flatten())[::-1][:K]
    return '\n'.join(map(str, ans))

print(d_cake_123_sort_modified())

Measured memory_bytes: 129708
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
int n, m, x, y;ll z = 0, w, h, sum = 0, ans = 0,a,b,t,v;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main(void) {
    cin >> n >> m; vector<int> a(n),b(n,0);
    rep(i, n) cin >> a[i];
    rep(l, min(41,m)) {
        rep(i, n) {
            if (i - a[i] < 0) b[0]++;
            else b[i - a[i]]++;
            if (i + a[i] < n - 1) b[i + a[i] + 1]--;
        }
        rep(i, n - 1) {
            b[i + 1] += b[i];
        }
        rep(i, n) {
            a[i] = b[i];
            b[i] = 0;
        }
    }
    for (int k : a) cout << k << " ";
    cout << endl;
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll N,x,mn[2000][2000]; cin >> N >> x;
	vector<ll> a(N); F0R(i,N) cin >> a[i];
	F0R(i,N) {
		mn[i][0] = a[i];
		FOR(j,1,N) mn[i][j] = min(mn[i][j-1],a[(i-j+N)% N]);
	}
	ll a1 = 1000000000000000000;
	F0R(i,N) {
		ll ans = i*x;
		F0R(j,N) ans += mn[j][i];
		a1 = min(ans,a1);
	}
	cout << a1;
}

Measured memory_bytes: 31488
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int n; cin >> n;
	double t, a; cin >> t >> a;
	vector<double>h(n);
	rep(i, n) {
		int c; cin >> c;
		h[i] = t - c * (double)6/(double)1000;
		h[i] = abs(a - h[i]);
	}
	int ans = 0;
	double cnt = INF;
	rep(i, n) {
		if (chmin(cnt, h[i]))ans = i + 1;
	}
	cout<<ans<<"\n";


	return 0;
}

Measured memory_bytes: 256
def main():
    H =int(input())
    bit_list = list(bin(H))
    del bit_list[:2]
    bit_in = [s.replace('0', '1') for s in bit_list]
    mojiretu = ' '
    for x in bit_in:
        mojiretu += x
    print(int(mojiretu, 2))
if __name__ == '__main__':
    main()

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N;
  cin >> N;
  map<ll,int> m;
  for(int i = 0; i < N; i++){
    ll tmp;
    cin >> tmp;
    if(m.count(tmp) == 0){
      m[tmp] = 1;
    } else { 
      m[tmp]++;
    }
  }
  vector<ll> x;
  vector<ll> y;
  for(auto z: m){
    if(z.second >= 4) x.push_back(z.first);
    if(z.second >= 2) y.push_back(z.first);
  }
  ll ans = 0;
  if(x.size() > 0) ans = x.at(x.size()-1) * x.at(x.size()-1);
  if(y.size() > 1) ans = max(y.at(y.size()-1) * y.at(y.size()-2), ans);
  cout << ans << endl;
}


Measured memory_bytes: 6528
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,d;
main() {
    file("balance");
    ios;
    cin>>n>>d;
    d<<=1;
    ++d;
    cout<<n/d+(n%d!=0);
    return 0;
}
/**

*/


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  vll l(n+1), r(n+1);
  rep(i,n){
    l[i+1]=gcd(l[i],a[i]);
  }
  rrep(i,n){
    r[i]=gcd(r[i+1],a[i]);
  }
  ll ans=1;
  rep(i,n){
    chmax(ans,gcd(l[i],r[i+1]));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
a,b = input().split()
a = int(a)
b = int(b)

s = 0
if a > b:
  s += a
  a -= 1
  if a > b:
    s += a
  else:
    s += b
else:
  s += b
  b -= 1
  if a > b:
    s += a
  else:
    s += b

print(s)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> s(n), t(m);
  rep(i,n) cin >> s[i];
  rep(i,m) cin >> t[i];

  vector<vector<mint>> dp(n+1,vector<mint>(m+1));
  dp[0][0] = 1;
  rep(i,n) dp[i+1][0] = 1;
  rep(j,m) dp[0][j+1] = 1;
  rep(i,n)rep(j,m){
    dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j];
    if(s[i]!=t[j]){
      dp[i+1][j+1] -= dp[i][j];
    }
  }
  cout << dp[n][m] << endl;
}


Measured memory_bytes: 31616
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n := Scanner()
	f := false
	for i := 0; i < len(n); i++ {
		if string(n[i]) == "7" {
			f = true
		}
	}
	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1756
S = input('')

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

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

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

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

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

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

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

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

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> s(h);
  for (int i = 0; i < h; i++) cin >> s[i];

  vector<vector<int>> a(h, vector<int>(w, 0));

  vector<int> dh, dw;
  dh = {-1, 0, 0, 1};
  dw = {0, -1, 1, 0};

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      for (int k = 0; k < 3; k++) {
        int ni = i + dh[k], nj = j + dw[k];
        if (0 <= ni && ni < h && 0 <= nj && nj < w && s[i][j] == '#' &&
            s[ni][nj] == '#')
          a[i][j] = a[ni][nj] = 1;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#' && a[i][j] == 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
D = [0]*N
for i in range(N-1):
    D[i] = A[i + 1] - A[i]
D[N-1] = K+A[0]-A[N-1]
print(sum(D)-max(D))

Measured memory_bytes: 26436
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N,K;
  cin >> N >> K;
  ll t[N], d[N]; 
  pair<ll,ll> sushi[N];
  rep(i,N){
    cin >> t[i] >> d[i];
    sushi[i].second=t[i];
    sushi[i].first=d[i];
  }
  sort(sushi, sushi+N);
  ll ans = 0;
  set<ll> neta_l;
  ll neta_n=0;
  vector<ll> same;
  for(int i=N-1; i>N-1-K; i--){
    ans += sushi[i].first;
    if(neta_l.count(sushi[i].second) == 0){
      //      cout << sushi[i].second << endl;
      ans += (neta_n+1)*(neta_n+1) - neta_n * neta_n;
      neta_n++;
      neta_l.insert(sushi[i].second);
    }
    else{
      same.push_back(i);
    }
  }
  //  cout << same.size() << endl;
  if(!same.empty()){
  ll tmp = ans;
  ll tmp_in=same.size()-1;
  for(int i=N-1-K; i>=0; i--){
    //    cout << " "<< endl;
    if(neta_l.count(sushi[i].second) != 0) continue;
    else{
   
      //      cout << tmp_in << endl;
      //      cout << sushi[i].second << endl;
      tmp = tmp - sushi[same[tmp_in]].first + sushi[i].first + (neta_n+1)*(neta_n+1) - (neta_n)*(neta_n);
      neta_n++;
      neta_l.insert(sushi[i].second);
      tmp_in--;
      ans = max(ans, tmp);
      if(tmp_in == -1) break;
    }
  }
  }
  cout << ans << endl;
  
  return 0;
  

}


Measured memory_bytes: 6780
using System;

namespace C2
{
    class Program
    {
        static int[] ToIntAry(string[] str)
        {
            int len = str.Length;
            int[] intary = new int[len];
            for(int i = 0; i < len;i++)
            {
                intary[i] = int.Parse(str[i]);
            }
            return intary;
        }
        static int[] AddZero(int[] intary)
        {
            int len = intary.Length + 1;
            int[] addIntary = new int[len];
            addIntary[0] = 0;
            intary.CopyTo(addIntary,1);
            return addIntary;
        }
        static void Main(string[] args)
        {
            int[] H,MA;
            int[] NM = ToIntAry(Console.ReadLine().Split(' '));
            int N  = NM[0], M = NM[1];
            H = AddZero(ToIntAry(Console.ReadLine().Split(' ')));
            MA = new int[N+1];
            for(int i = 0; i < MA.Length;i++)
            {
                MA[i] = 0;
            }
            for(int i = 0; i < M;i++)
            {
                int[] AB = ToIntAry(Console.ReadLine().Split(' '));
                int A = AB[0],B = AB[1];
                MA[A] = Math.Max(MA[A],H[B]);
                MA[B] = Math.Max(MA[B],H[A]);
            }
            int Answer = 0;
            for(int i = 1; i <= N ;i++)
            {
                Answer += Convert.ToInt32(H[i] > MA[i]);
            }
            Console.WriteLine(Answer);
        }
    }
}


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

long long int N, A, B, v[55], i, fi, a, b, k = 1, ans;

static inline long long int binom(long long up, long long dow){
    if(up <= 0 || up >= dow)return 1;
    long long int ret = 1;
    for(fi = 1; fi <= up; ++fi){
        ret = ret * dow / fi;
        --dow;
    }
    return ret;
}

int main(){
    //cout << binom(25, 50) << endl;
    scanf("%lld%lld%lld", &N, &A, &B);
    for(i = 0; i < N; ++i){
        scanf("%lld", v + i);
    }
    sort(v, v + N, greater<long long int>());
    if(*v == v[A - 1]){
        cout << *v << endl;
        a = upper_bound(v, v + N, v[A - 1], greater<long long int>()) - v;
        //cout << a << " " << B << " " << A << endl;
        for(i = min(B, a); i >= A; --i){
            //cout << i << endl;
            ans += binom(i, a);
        }
        cout << ans << endl;
        return 0;
    }
    //for(i = 0; i < N; ++i){
    //    cout << v[i] << " ";
    //}
    //cout << endl;
    //cout << v[A - 1] << endl;
    a = upper_bound(v, v + N, v[A - 1], greater<long long int>()) - lower_bound(v, v + N, v[A - 1], greater<long long int>());
    b = A - (lower_bound(v, v + N, v[A - 1], greater<long long int>()) - v);
    //cout << a << " " << b << endl;
    printf("%f\n", accumulate(v, v + A, 0.0) / double(A));
    cout << binom(b, a) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	static final int uncal = -1;
	static final int mod = (int) (1e9)+7;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in); 
		out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[] s = sc.inArr(n);
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				if(s[i] == s[j]) continue;

				for (int j2 = j+1; j2 < n; j2++) {
						if(s[i] == s[j2] || s[j] == s[j2]) continue;
						if(checkTri(s[i], s[j], s[j2])) cnt++;
				}
			}
		}
		out.println(cnt);
		out.close();
	}
	static boolean checkTri(int a, int b,int c) {
		return a+b>c && a+c>b && b+c>a;
	}
	static void shuffle(int[] array) {
		Random rand = new Random();
		for (int i = 0; i < array.length; i++) {
			int randomIndexToSwap = rand.nextInt(array.length);
			int temp = array[randomIndexToSwap];
			array[randomIndexToSwap] = array[i];
			array[i] = temp;
		}
	}
	static boolean isPalindrome(String s) {
		int l = s.length();
		char[] sa = s.toCharArray();
		for(int i=0;i<l/2;i++) {
			if(sa[i] != sa[l-i-1])
				return false;
		}
		return true;
	}
	static class Point extends java.awt.Point implements Comparable<Point>{
		public Point(int x,int y) {
			// TODO Auto-generated constructor stub
			super(x,y);
		}
		public String toString() {
			return x+" "+y;
		}
		@Override
		public int compareTo(Point p) {
			// TODO Auto-generated method stub
			if(x == p.x)
				return y - p.y;
			return x - p.x;
		}
		
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public Scanner(String filename) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(filename));
		}
		public String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(next());
			}
			return a;
		}
	}

}

Measured memory_bytes: 33524
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
void f(){
 int n;
 cin >> n;
 LL ans = 0;
 LL b = 0, temp = 0;
 double c = 0;


 vector<int> seq(n);
 vector<int> x(n);
 forn(i,n){
     cin >> seq.at(i);
     x.at(i) = seq.at(i) - i;
 }

 sort(x.begin(), x.end());
if(n == 1)
    {
        cout << 0 << endl;
        return;
    }
 if(n % 2){
     forn(i,n){
         ans += abs(x.at(i) - x.at(n/2-1));
     }
     forn(i,n){
         temp += abs(x.at(i) - x.at(n/2));
     }
     ans = min(ans, temp);
 }
 else{
     forn(i,n){
         ans += abs(x.at(i) - x.at(n/2));
     }
 }
 cout << ans << endl;
}
   
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    
  f();
 return 0;
}


Measured memory_bytes: 4768
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int K; cin >> K;
    string s; cin >> s;

    int N = s.size();
    if(N <= K) cout << s << endl;
    else cout << s.substr(0, K) << "..." << endl;
    return 0;
}


Measured memory_bytes: 3632