akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

template<class Func>auto order_by(Func func)
{
	return [=](auto lhs, auto rhs)
	{
		return func(lhs) < func(rhs);
	};
}

bool check(std::vector<int>& data, int v, int K)
{
	int count = 0, dp = 0;
	boost::sort(data, order_by([&](int a) {return a % v; }));
	for (auto d : data)
	{
		auto x = d % v;
		auto y = v - x;
		if (count + x <= K)
		{
			count += x;
			dp -= x;
		}
		else if (dp + y <= 0)
		{
			dp += y;
		}
		else
		{
			return false;
		}
	}
	return true;
}

void Main()
{
	int N, K;
	std::cin >> N >> K;
	std::vector<int> data(N);
	int sum = 0;
	for (auto& v : data)
	{
		std::cin >> v;
		sum += v;
	}
	int max = 1;
	for (auto i : boost::irange(2, sum + 1))
	{
		if (sum % i != 0)
		{
			continue;
		}
		if (check(data, i, K))
		{
			max = i;
		}
	}
	std::cout << max << std::endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b, x;
cin >> x >> a >> b;
vector <int> c = {x,a,b};
cout << x + a + b - *max_element(c.begin(),c.end()) << "\n";
return 0;
}


Measured memory_bytes: 256
N = int(input())
A = sorted(map(int, input().split()), reverse=True)

i = 0   # Aを足した回数（最後にはi=N）
ans = A[0]
while 2 * i < N - 2:
    if N - 2 - 2 * i == 1:
        ans += A[i + 1]
    else:
        ans += 2 * A[i + 1]
    i += 1


print(ans)

Measured memory_bytes: 31460
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    aa=LI()
    cnt=Counter(aa)
    mx=-1
    for a,an in sorted(cnt.items(),reverse=True):
        if an>3 and mx==-1:
            print(a*a)
            break
        elif an>1:
            if mx==-1:mx=a
            else:
                print(mx*a)
                break
    else:
        print(0)



main()

Measured memory_bytes: 21532
var 
  i,j,n,ans:longint;
  a:array[1..3]of string;
begin
  readln(n);
  for i:=1 to 3 do
	readln(a[i]);
  ans:=0;
  {for i:=1 to 3 do 
  begin
    for j:=1 to n do 
	  write(a[i][j],' ');
	writeln;
  end;}
  for i:=1 to n do
  begin
    if (a[1][i]<>a[2][i]) and (a[2][i]<>a[3][i]) and (a[1][i]<>a[3][i]) then ans:=ans+2;
	if ((a[1][i]=a[2][i]) and (a[3][i]<>a[2][i])) or ((a[2][i]=a[3][i]) and (a[1][i]<>a[2][i])) or ((a[1][i]=a[3][i]) and (a[1][i]<>a[2][i])) then ans:=ans+1;
  end;
  writeln(ans);
  readln(i);
end.

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Globalization;

namespace cswork
{
    class Program
    {
        public Program() { }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        void Omame()
        {
            cin = new Scanner();
            int k = cin.nextInt();
            string s = cin.next();

            if (s.Length <= k)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine(s.Substring(0, k) + "...");
            }
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 27680
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;

int main() {

	int a,b,c,x; 
	cin >> a >> b >> c >> x;
	int cnt = 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) {
					cnt++;
				}
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 52
using namespace std;
int n,l,i,j,minx[N],cnt[N];
char c[N];
int main()
{
	memset(minx,0x3f,sizeof(minx));
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		memset(cnt,0,sizeof(cnt));
		scanf("%s",c+1);
		l=strlen(c+1);
		for(j=1;j<=l;j++) cnt[(int)(c[j]-'a')]++;
		for(j=0;j<26;j++) minx[j]=min(minx[j],cnt[j]);
	}
	for(i=0;i<26;i++){
		for(j=1;j<=minx[i];j++) putchar((char)(i+'a'));
	}
	puts("");
	return 0;
}


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

using namespace std;

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	
	deque<char> q;
	rep(i, s.length()){
		if(s[i] == 'B' && !q.empty()){
			q.pop_back();
		} else if(s[i] != 'B'){
			q.push_back(s[i]);
		}
	}
	
	rep(i, q.size()){
		cout << q[i];
	}
	
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

long long int INF = 1000000000000000000LL; // 10^18
using namespace std;

long long int A[210000] = {};

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

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 1; i <= N; i++){
		cin >> A[i];
	}
	
	A[0] = (1 << 28) - 1;
	A[N + 1] = (1 << 28) - 1;
	
	long long int ans = 0;
	
	long long int num = 0;
	int index_s = 1;
	
	for(int i = 1; i <= N + 1; i++){
		if((num & A[i]) != 0){
			while(true){
				num -= A[index_s];
				ans += i - index_s;
				//cout << index_s << " " << i << " ";
				//cout << num << " " << A[i] << endl;
				index_s++;
				if((num & A[i]) == 0){
					num += A[i];
					break;
				}
			}
		}else{
			num += A[i];
		}
	}
	
	for(int i = index_s; i <= N; i++){
		ans += N - i + 1;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
    int M, T, P, R;
    while(1){
        cin >> M >> T >> P >> R;
        if(M == 0){
            break;
        }

        int ap[55] = {};
        int at[55] = {};
        int pen[55][11] = {};
        for(int i=0;i<55;i++){
            ap[i] = 0;
            at[i] = 0;
            for(int j=0;j<11;j++){
                pen[i][j] = 0;
            }
        }

        for(int i=0;i<R;i++){
            int m, t, p, j;
            cin >> m >> t >> p >> j;
            if(j==0){
                ap[t]++;
                at[t]+=m+20*pen[t][p];
            }else{
                pen[t][p]++;
            }
        }

        bool c_flag = false;
        for(int i=10;i>=0;i--){
            for(int j=0;j<50000;j++){
                bool e_flag = false;
                for(int k=T;k>=1;k--){
                    if(ap[k]==i && at[k]==j){
                        if(e_flag){
                            cout << '=';
                        }else if(c_flag){
                            cout << ',';
                        }
                        c_flag = true;
                        e_flag = true;
                        cout << k;
                    }
                }
            }
        }
        cout << endl;
    }
}

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

int main(){
  int a,b;
  char op;

  while(1){
    cin >> a >> op >> b;

    if (op == '+')      cout << a + b << endl;
    else if (op == '-') cout << a - b << endl;
    else if (op == '*') cout << a * b << endl;
    else if (op == '/') cout << a / b << endl;
    else                break;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define pii pair<int, int>
#define fi first
#define se second
#define mk(x, y) make_pair( x, y )
#define pk push_back
using namespace std;
const int M = 2*1e5 + 5;
const int N = 2*1e5 + 5;
const double PI = acos(-1.0);
const ll Mod = 1e9+7;
ll n, k;

int main( ){
    while( scanf( "%lld %lld", &n, &k ) != EOF ){
        ll lsum = 0, rsum = 0;
        for( int i = 0; i < k; i++ )
            lsum += i;
        for( int i = n; i > n-k; i-- )
            rsum += i;
        ll ans = rsum - lsum + 1;
        int lp = k, rp = n-k;
        while( lp <= n && rp >= 0 ){
            lsum += lp++;
            rsum += rp--;
            ans = ( ans + rsum-lsum+1 ) % Mod;
        }
        printf( "%lld\n", ans );
    }
    return 0;
}


Measured memory_bytes: 3824
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using pii = pair<int, int>;
pii operator+(pii a, pii b) { return {a.first + b.first, a.second + b.second}; }
pii operator-(pii a, pii b) { return {a.first - b.first, a.second - b.second}; }
int abs(const pii &p) { return abs(p.first) + abs(p.second); }

int main() {
    int h, w; cin >> h >> w;
    int d; cin >> d;
    vector<pii> pos(h * w);
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        int a; cin >> a; a--;
        pos[a] = {i, j};
    }
    vector<int> dist(h * w);
    for (int i = d; i < h * w; i++) {
        dist[i] = dist[i - d] + abs(pos[i] - pos[i - d]);
    }
    int q; cin >> q;
    while (q--) {
        int l, r; cin >> l >> r; l--, r--;
        cout << dist[r] - dist[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
// B. 

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL N, K, A[100000], sum[100001] = {}, msum[100001] = {}, dp[100000][3] = {};
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum[i + 1] = sum[i] + A[i];
		msum[i + 1] = msum[i] + max(0LL, A[i]);
	}
	dp[K-1][0] = 0;
	dp[K-1][1] = 0;
	dp[K-1][2] = sum[K];
	for (int i = K; i < N; ++i) {
		dp[i][0] = max({ dp[i - 1][0], dp[i - 1][1], dp[i - 1][2] });
		dp[i][1] = max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][2]) + A[i];
		dp[i][1] = max(dp[i][1], msum[1 + i - K]);
		dp[i][2] = max(dp[i][2], msum[1 + i - K] + sum[i + 1] - sum[i + 1 - K]);
	}
	LL ans = max({ dp[N - 1][0], dp[N - 1][1], dp[N - 1][2] });
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#import numpy as np
import math
#from fractions import gcd

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    N = first_input[0]
    M = first_input[1]
    H_list = second_input

    H_link_list = []
    for i in range(N):
        H_link_list.append([])
    for i in range(M):
        current_input = list(map(lambda x:int(x), input().split(" ")))
        H_link_list[current_input[0]-1].append(H_list[current_input[1]-1])
        H_link_list[current_input[1]-1].append(H_list[current_input[0]-1])

    count = 0
    for i in range(N):
        if len(H_link_list[i])==0:
            count = count+1
        else:
            if max(H_link_list[i])<H_list[i]:
                count = count+1

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 91852
#include<stdlib.h>
#include<iostream>
#include<cstdio>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<map>
#include<string.h>
#include<queue>
#define int long long
using namespace std;

signed main() {
	int a, b, c; cin >> a >> b >> c;
	int MAX = a*c - c + b, MIN = a*b - b + c;
	cout << max(0ll,MAX-MIN+1) << endl;
}

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

int main ()
{
	long int n;
	cin>>n;
	
	if(n>=1800) cout<<"1"<<endl;
	else if(n>=1600) cout<<"2"<<endl;
	else if(n>=1400) cout<<"3"<<endl;
	else if(n>=1200) cout<<"4"<<endl;
	else if(n>=1000) cout<<"5"<<endl;
	else if(n>=800) cout<<"6"<<endl;
	else if(n>=600) cout<<"7"<<endl;
	else 
	cout<<"8"<<endl;

}


Measured memory_bytes: 3540
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath> 
using namespace std;
int ws(int x){
	int ans = 0;
	while(x!=0){
		ans++;
		x/=10;
	}
	return ans;
}
int main(){
	int n;
	cin>>n;
	long long ans = 0;
	for(int i = 1; i < ws(n);i+=2){
		int t = 9;
		for(int j = 1; j < i; j++){
			t*=10;
		}
		ans+=t;
	}
	if(ws(n)&1)
		ans+=(n-pow(10,ws(n)-1)+1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	ll S=in<ll>();
	ll x0=0,y0=0;
	ll x1=1e9,y1=1;
	ll a=S/x1;
	ll b=S%x1;
	ll x2,y2;
	if(b){
		x2=x1-b,y2=a+1;
	}
	else{
		x2=0,y2=a;
	}

	out(x0,y0,x1,y1,x2,y2);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string S;
    std::cin >> S;
    if((S[0]==S[1] && S[2]==S[3] && S[0]!=S[2]) || (S[0]==S[2] && S[1] == S[3] && S[0]!=S[1]) || (S[0]==S[3] && S[1]==S[2] && S[0]!=S[1]))
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
    return 0;
        
}

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

using namespace std;


unsigned long long d[2000];

int main()
{
	int n;
	cin >> n;
	int result = 0;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		result += b - a + 1;
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int dp[n][22];
  memset(dp,0,sizeof(dp));
  dp[1][a[0]]=1;
  for(int i=1;i<n-1;i++){
    for(int j=0;j<=20;j++){
      if(j+a[i]<=20) dp[i+1][j+a[i]]+=dp[i][j];
      if(j-a[i]>= 0) dp[i+1][j-a[i]]+=dp[i][j];
    }
  }
  cout<<dp[n-1][a[n-1]]<<endl;
  return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>
int main(void) {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    b=b/a;
    if (b>c) {
        printf("%d",c);
        return 0;
    }
    else {
        printf("%d",b);
        return 0;
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s;std::cin>>s;
    std::cout<<(s.at(2)==s.at(3)&&s.at(4)==s.at(5)?"Yes":"No")<<'\n';
}


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

int main() {
    //bool hon[2] = {};
    char c;
    cin >> c;
    if(c == 'H'){
        cin >> c;
        cout << c << endl;
    }else{
        cin >> c;
        if(c == 'H') cout << "D" << endl;
        else cout << "H" << endl;
    }
    return 0;
}

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

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

typedef long long ll;

int n;
double rs[525];
double xs[525];

typedef complex<double> P;

int main(){
  cin>>n;
  REP(i,n)cin>>rs[i];
  xs[0] = rs[0];
  FOR(i,1,n){
    double low = max(xs[i-1], rs[i]);
    double high = 1e9;
    REP(_,100){
      double x = (low+high)/2.0;
      P rc = P(x, rs[i]);
      bool col = false;
      FORR(j,0,i){
        P lc = P(xs[j], rs[j]);
        if(abs(lc - rc) <= rs[i] + rs[j]){
          col = true;
          break;
        }
      }
      if(col){
        low = x;
      }else{
        high = x;
      }
    }
    xs[i] = high;
  }
  double ans = 0.0;
  REP(i,n)ans = max(ans, xs[i]+rs[i]);
  printf("%.9f\n",ans);
  return 0;
}

Measured memory_bytes: 3360
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ priority_queue<ll, vector<ll>, greater<ll>>

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll A[22][22] = {};
ll B[22] = {};

int main() {
  ll N, M, C;
  ll ans = 0;
  cin >> N >> M >> C;
  REP(i, M) { cin >> B[i]; }
  REP(i, N) REP(j, M) { cin >> A[i][j]; }
  REP(i, N) {
    ll n = C;
    REP(j, M) { n += A[i][j] * B[j]; }
    if (n > 0)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n, N) for(int i=(n); i < N; i++)
#define p(s) cout << (s) << endl
#define p2(a, b) cout << (a) << ' ' << (b) << endl
using namespace std;
typedef long long ll;

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

int main() {
    int n;
    while(cin >> n && n){
        vector<vector<int>> field(401,vector<int>(401,0));
        vector<pair<int,int>> points(n);
        points[0].first=200; // x
        points[0].second=200; // y
        field[200][200] = 1;
        int n1,d;
        REP(i,1,n){
            cin >> n1 >> d;
            field[points[n1].second+dy[d]][points[n1].first+dx[d]] = 1;
            points[i].first=points[n1].first+dx[d];
            points[i].second=points[n1].second+dy[d];
        }

        int x_min=500,x_max=-1,y_min=500,y_max=-1;
        REP(y,0,401){ // y
            REP(x,0,401){ // x
                if(field[y][x] == 1){
                    x_min = min(x_min,x);
                    x_max = max(x_max,x);
                    y_min = min(y_min,y);
                    y_max = max(y_max,y);
                }
            }
        }
        p2((x_max-x_min+1),(y_max-y_min+1));

    }

    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int n; cin >> n;
	vector<int> a(n);
	ll ans = 0;
	rep(i, n) {
		int a; cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
}



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

int main(){
    
    int n;
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    cin>>n;
    cout<<a[n-1]<<"\n";
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,s=0;
  cin>>a>>b>>c>>x;
  for(int p=0;p<=a;p++){
    for(int q=0;q<=b;q++){
      for(int r=0;r<=c;r++){
        if(p*500+q*100+r*50==x){
          s++;
        }
      }
    }
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int M,D;

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

  cin >> M >> D;
  if (D<22 || M<4) {
    cout << 0 << "\n";
    return 0;
  };
  int d1=D%10;
  int d2=D/10;

  int ans=0;
  for(int i=4; i<=M; i++){
    for (int j=2; j<=d2-1; j++){
      for (int k=2; k<=9;k++){
        if (i==j*k) ans++;
      }
    }
    for (int k=2; k<=d1;k++){
      if (i==d2*k) ans++;
    }
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool solve(int idx, int n) {
	int sum = 0;
	REP (i, idx, n) {
		sum += i;
		if (sum == n) return true;
	}
	return false;
}

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

	int n;
	while (1) {
		cin >> n;
		if (n == 0) break;
		int ans = 0;
		REP (i, 1, n) {
			ans += solve(i, n);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int w,h,n; cin>>w>>h>>n;
	int d[h][w]; CLR(d);
	rep(i,n){
		int x,y,a; cin>>x>>y>>a;
		if(a==1){
			for(int i=0;i<x;i++)rep(j,h) d[j][i]=1;
		}else if(a==2){
			for(int i=x;i<w;i++)rep(j,h) d[j][i]=1;
		}else if(a==3){
			for(int i=0;i<y;i++)rep(j,w) d[i][j]=1;
		}else{
			for(int i=y;i<h;i++)rep(j,w) d[i][j]=1;
		}
	}
	int ans=0;
	rep(i,h)rep(j,w)if(d[i][j]==0) ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
lxrs = []
for _ in range(n):
    x, l = map(int, input().split())
    lxrs.append((x-l, x, x+l))

lxrs = sorted(lxrs)
cur_l = lxrs[0][0]
cur_r = lxrs[0][2]
cnt = 0
for l, x, r in lxrs[1:]:
    if cur_r <= l:
        cur_l, cur_r = l, r
        cnt += 1
    elif r <= cur_r:
        cur_l, cur_r = l, r

print(cnt+1 )



Measured memory_bytes: 21760
import numpy as np
h,n=map(int,input().split())    
ab=np.array([tuple(map(int,input().split())) for _ in range(n)])
dp=np.zeros(h+1,dtype="int")
for i in range(1,h+1):
    dp[i]=np.min(dp[np.maximum(i-ab[:, 0],0)]+ab[:,1])
print(dp[-1])

Measured memory_bytes: 12516
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

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; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    rep(i, ty - sy) {
        cout << "U";
    }
    rep(i, tx - sx) {
        cout << "R";
    }
    rep(i, ty-sy) cout << "D";
    rep(i, tx - sx) cout << "L";
    cout << "L";
    rep(i, ty-sy+1) cout << "U";
    rep(i, tx - sx+1) cout << "R";
    cout << "D";
    cout << "R";
    rep(i, ty-sy+1) cout << "D";
    rep(i, tx - sx + 1) cout << "L";
    cout << "U" << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

const ll INF = 1ll<<61;

class WarchallFloyd {
private:
    int N;
    vvii E;

    void init(int n) {
        N = n;
        E = vvii(n);
    }

public:
    WarchallFloyd() {}
    WarchallFloyd(int n) { init(n); }

    void add(int from, int to, ll dist) {
        E[from].push_back(make_pair(to, dist));
    }

    vvi solve() {
        vvi ret(N, vi(N, INF));
        REP (i, N) FORE (e, E[i]) {
            ret[i][e.first] = e.second;
        }
        REP (i, N) ret[i][i] = 0;

        REP (k, N) REP (j, N) REP (i, N) {
            ret[j][i] = min(ret[j][i], ret[j][k] + ret[k][i]);
        }
        return ret;
    }
};

const int MAX = 210;

int H, W;
int C[10][10];
int A[MAX][MAX];

int solve() {
    WarchallFloyd wf(10);
    REP (i, 10) REP (j, 10) wf.add(i, j, C[i][j]);
    vvi c = wf.solve();

    int ret = 0;
    REP (h, H) REP (w, W) if (A[h][w] != -1) {
        ret += c[A[h][w]][1];
    }
    return ret;
}

int main() {
    cout << fixed << setprecision(15);
    cin >> H >> W;
    REP (i, 10) REP (j, 10) cin >> C[i][j];
    REP (i, H) REP (j, W) cin >> A[i][j];
    cout << solve() << endl;
}

Measured memory_bytes: 384
from itertools import combinations_with_replacement

n,m,q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(q)]

result = 0

for x in combinations_with_replacement(range(1, m+1), n):
    t = 0
    for a,b,c,d in abcd:
        if x[b-1] - x[a-1] == c:
            t += d
    result = max(result,t)
print(result)

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
    FIO
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2;

    return 0;
}

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

const int maxn=100000;

struct M
{
    bool operator <(const M &t)const
    {
        if(s==t.s)
            return score>t.score;
        else return s<t.s;
    }
    M(string &s,int &score,int x):s(s),score(score),x(x){}
    string s;
    int x;
    int score;
};

vector<M> vec;

int main()
{
    int n;
    string s;
    int id;
    cin>>n;
    for(int i=0;i<n;++i)
    {
        cin>>s>>id;
        vec.push_back(M(s,id,i+1));
    }
    sort(vec.begin(),vec.end());
    for(auto &t:vec)
    {
        cout<<t.x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < n; i++) 

using namespace std;

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

    for (double i = 1; i < 10000; i++) {
        if (int(i * 0.08) == a && int(i * 0.1) == b) {
            cout << int(i) << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0; 
}

Measured memory_bytes: 256
class Dice
  attr_accessor :face

  def rotate(dir)
    case dir
    when "N"
      @face[0],@face[1],@face[5],@face[4] = @face[1],@face[5],@face[4],@face[0]
    when "E"
      @face[0],@face[2],@face[5],@face[3] = @face[3],@face[0],@face[2],@face[5]
    when "S"
      @face[0],@face[1],@face[5],@face[4] = @face[4],@face[0],@face[1],@face[5]
    when "W"
      @face[0],@face[2],@face[5],@face[3] = @face[2],@face[5],@face[3],@face[0]
    when "cw" #ClockWise rotation
      self.rotate("E").rotate("N").rotate("W")
      #@face[1],@face[2],@face[4],@face[3] = @face[2],@face[4],@face[3],@face[1]
    when "acw" #Anti ClockWise rotation
      self.rotate("W").rotate("N").rotate("E")
      #@face[1],@face[2],@face[4],@face[3] = @face[3],@face[1],@face[2],@face[4]
    end
    return self
  end

  def aline_dir(top, front)
    alined_dice = []
    self.face.each_with_index do |item, index|
      dice_clone = Marshal.load(Marshal.dump(self))
      if item == top
        case index
        when 1
          dice_clone.rotate("N")
        when 2
          dice_clone.rotate("W")
        when 3
          dice_clone.rotate("E")
        when 4
          dice_clone.rotate("S")
        when 5
          dice_clone.rotate("N").rotate("N")
        end
        (1..4).each do |i|
          dice_clone2 = Marshal.load(Marshal.dump(dice_clone))
          if dice_clone.face[i] == front
            case i
            when 2
              dice_clone2.rotate("cw")
            when 3
              dice_clone2.rotate("acw")
            when 4
              dice_clone2.rotate("cw").rotate("cw")
            end
            alined_dice.push(dice_clone2.face)
          end
        end
      end
    end
    return alined_dice
  end
  
  def same?(dice_alined)
    bool = false
    dice_alined.each do |item|
      bool = true if self.face.eql?(item)
    end
    return bool
  end
end

dice1 = Dice.new
dice2 = Dice.new
dice1.face = gets.chomp.split.map(&:to_i)
dice2.face = gets.chomp.split.map(&:to_i)

dice2_alined = dice2.aline_dir(dice1.face[0], dice1.face[1])
puts dice1.same?(dice2_alined) ? "Yes" : "No"

Measured memory_bytes: 6152
""" AtCoder """
import collections

S = input()
T = input()

s = {}
t = {}

for i in range(len(S)):
    if S[i] in s and s[S[i]] != T[i] or T[i] in t and t[T[i]] != S[i]:
        print("No")
        exit()
    s[S[i]] = T[i]
    t[T[i]] = S[i]

print("Yes")


Measured memory_bytes: 4144
n = int(input())
a = [int(input()) for i in range(n)]
max = 0
max2 = 0
tmp = 0
for i in range(n):
    if max<a[i]:
        max = a[i]
        tmp=i
for i in range(n):
    if tmp!=i and max2<a[i]:
        max2 = a[i]

for i in range(n):
    if i != tmp:
        print(max)
    else:
        print(max2)

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

int N;
bool in_vector(int x, vector<int> vec) {
    for (int i : vec) {
        if (i == x) return false;
    }
    return true;
}

int main() {
    int X; cin >> X >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) cin >> vec[i];

    int up = 0, down = 1;
    for (int i = 0; i < N + 1; i++) {
        if (i%2 == 0) {
            if (in_vector(X + up, vec)) {
                cout << X + up << endl;
                return 0;
            }
            up++;
        }
        else {
            if (in_vector(X - down, vec)) {
                cout << X - down << endl;
                return 0;
            }
            down++;
        }
    }
}

Measured memory_bytes: 3604
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	static long  baseTime;
	static long  nowTime;

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[][] LR = new int[N][2];
		for(int i=0;i<N; i++) {
			LR[i][0] = in.nextInt();
			LR[i][1] = in.nextInt();
		}
		
		LinkedList<Range> list = new LinkedList<>();
		LinkedList<Range> list2 = new LinkedList<>();
		for(int i=0;i<N; i++) {
			Range range = new Range(LR[i][0],LR[i][1]);
			list.add(range);
			list2.add(range);
		}
		
		long sum1 = game(list,list2,true);
		
		list = new LinkedList<>();
		list2 = new LinkedList<>();
		for(int i=0;i<N; i++) {
			Range range = new Range(LR[i][0],LR[i][1]);
			list.add(range);
			list2.add(range);
		}
		long sum2 = game(list,list2,false);
		
		System.out.println(Math.max(sum1,sum2));
		
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	public long game(LinkedList<Range> list,LinkedList<Range>list2, boolean toRight) {
			list.sort((a,b)->b.left-a.left);
			list2.sort((a,b) -> a.right-b.right);
			
			int base = 0;
			long sum = 0;
			loop : while(!list.isEmpty()) {
				int distance;
				int nextBase;
				if(toRight) {
					while(list.get(0).used) {
						list.remove(0);
						if(list.isEmpty()) break loop;
					}
					nextBase = list.get(0).left;
					distance = nextBase-base;
					list.get(0).used = true;
					list.remove(0);
				}else{
					while(list2.get(0).used) {
						list2.remove(0);
						if(list2.isEmpty()) break loop;
					}
					nextBase = list2.get(0).right;
					distance = base-nextBase;
					list2.remove(0);
				}
				if(distance<0) break;
				sum += distance;
				base = nextBase;
				toRight = !toRight;
			}
			return sum + Math.abs(base);	
	}
	
	class Range{
		boolean used;
		int left;
		int right;
		
		public Range(int left, int right) {
			this.used = false;
			this.left = left;
			this.right = right;
		}
	}
}


Measured memory_bytes: 103232
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;
class Tree{
	int Id;
	int parent;
	int depth;
	string type;
	int left, right;
public:
	Tree(){ Id = 0, parent = -1, depth = 0, type = "", left = -1, right = -1; }
	void setId(int a){ this->Id = a; }
	void setParent(int a){ this->parent = a; }
	int takeId(){ return this->Id; }
	int takeParent(){ return this->parent; }
	int takeDepth(){ return this->depth; }
	int takeLeft(){ return this->left; }
	int takeRight(){ return this->right; }
	string takeType(){ return this->type; }
	void setDepth(int a){ this->depth = a; }
	void setLeft(int a){ this->left = a; }
	void setRight(int a){ this->right = a; }
	void setType(){
		if (this->parent == -1) this->type = "root";
		else if (this->left == -1) this->type = "leaf";
		else this->type = "internal node";
	}
};
Tree nodes[100001];
void printChildren(int parentId){
	int i = nodes[parentId].takeLeft();
	if (i == -1) return;
	cout << i;
	i = nodes[i].takeRight();
	while (i != -1){
		cout << ", " << i;
		i = nodes[i].takeRight();
	}
}
void print(int Id){
	nodes[Id].setType();
	cout << "node " << Id << ": parent = " << nodes[Id].takeParent()
		<< ", depth = " << nodes[Id].takeDepth() << ", " << nodes[Id].takeType()
		<< ", [";
	printChildren(Id);
	cout << "]\n";
}
void makeDepth(int NODE, int depth){
	nodes[NODE].setDepth(depth);
	int LEFT = nodes[NODE].takeLeft();
	if (LEFT != -1) makeDepth(LEFT,depth+1);
	int RIGHT = nodes[NODE].takeRight();
	if (RIGHT != -1) makeDepth(RIGHT, depth);
	return;
}
int main(){
	int n; scanf("%d",&n);
	for (int i = 0; i < n;++i){
		int id, k, childId; scanf("%d %d", &id, &k);
		nodes[id].setId(id);
		int NODE = id;
		for (int j = 0; j < k; ++j){
			scanf("%d", &childId);
			if (j == 0){
				nodes[NODE].setLeft(childId);
			}
			else{
				nodes[NODE].setRight(childId);
			}
			nodes[childId].setParent(id);
			NODE = childId;
		}
	}
	int p = -1;
	for (int i = 0; i < n; ++i) if (nodes[i].takeParent() == -1) { p = i; break; }
	makeDepth(p,0);
	for (int i = 0; i < n; ++i) print(i);
}

Measured memory_bytes: 9028
import 'dart:io';

main(List<String> args) {
  int N = int.parse(stdin.readLineSync());
  List<int> a =
      stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();

  a.sort((x, y) => y - x);
  int Alice = 0;
  int Bob = 0;
  for (var i = 0; i < N; i++) {
    if (i % 2 == 0) {
      Alice += a[i];
    } else {
      Bob += a[i];
    }
  }
  print(Alice - Bob);
}

Measured memory_bytes: 13152
use std::collections::VecDeque;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let n = parse!(it);
    let mut s = vec![];
    for _ in 0..n {
        let a: isize = parse!(it);
        let a = -a;
        match s.binary_search(&(a + 1)) {
            Ok(i) => s[i] = a,
            Err(i) if i < s.len() => s[i] = a,
            _ => s.push(a),
        };
    }
    println!("{}", s.len());
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    vector<int> v(S.size()+1);
    int num = 1;
    for(int i=1;i<=S.size();i++){
        if(i!=1){
            num *= 10;
            num %= 2019;
        }
        v[i]=v[i-1]+num*(S[S.size()-i]-'0');
        v[i]%=2019;
    }
    map<int,int> mp;
    for(int i=0;i<=S.size();i++){
        mp[v[i]]++;
    }
    ll ans = 0;
    for(int i=0;i<=S.size();i++){
        ans += mp[v[i]]*(mp[v[i]]-1)/2;
        mp[v[i]]=0;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S ;
  int a;
  if(S=="SUN"){
    a=7;
  }
  else if(S=="MON"){
    a=6;
  }
    else if(S=="TUE"){
    a=5;
  }
    else if(S=="WED"){
    a=4;
  }
    else if(S=="THU"){
    a=3;
  }
    else if(S=="FRI"){
    a=2;
  }
    else if(S=="SAT"){
    a=1;
  }
  
  cout << a <<endl;
  return 0;
}

  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int ans=1000;
  for (int i=0;i<S.size()-2;i++){
    int x=abs((S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0')-753);
    ans=min(ans,x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int unsigned long long
const int base=20040409;
const int N=1e6+5;
int n,ans,m,h[N],p[N],gs[N];
char a[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int find(int l,int r)
{
	return h[r]-h[l-1]*p[r-l+1];
}
signed main()
{
	n=read();
	scanf("%s",a+1);
	p[0]=1;
	for(int i=1;i<=n;i++)p[i]=p[i-1]*base;
	for(int i=1;i<=n;i++)h[i]=h[i-1]*base+a[i];
	for(int i=1;i<=n;i++)
		gs[a[i]-'a']++;
	bool p=0;
	for(int i=1;i<=n;i++)
		if(gs[a[i]-'a']>=2)p=1;
	if(!p){puts("0");return 0;}
	int l=1,r=n/2;
	while(l<r)
	{
		int mid=(l+r+1)/2;
		for(int i=1;i<=n;i++)
			for(int j=i+mid;j<=n-mid+1;j++)
				if(find(i,i+mid-1)==find(j,j+mid-1))goto xjh;
		r=mid-1;
		continue;
		xjh:l=mid;
	}
	cout<<r;
}

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

using namespace std;

#define endl "\n"

const int INF = 1e9 + 5;

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

    int t;
    cin >> t;
    vector<vector<int>> A(t, vector<int>(3));
    for (int i = 0; i < t; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }

    int dp[t][3];

    memset(dp, 0, sizeof dp);
    int mx = INT_MIN;
    for (int i = 0; i < 3; i++) {
        dp[0][i] = A[0][i];
        mx = max(dp[0][i], mx);
    }

    for (int i = 1; i < t; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (k != j) {
                    dp[i][k] = max(A[i][k] + dp[i - 1][j], dp[i][k]);
                } else {
                    dp[i][k] = max(dp[i][k], A[i][k]);
                }
                mx = max(dp[i][k], mx);
            }
        }
    }

    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 9768
function move(y,x,str){
   if(yx[tank[0]+y][tank[1]+x]=="."){
      yx[tank[0]+y][tank[1]+x]=str;
      yx[tank[0]][tank[1]]=".";
      tank[0]+=y;
      tank[1]+=x;
   }else{
     yx[tank[0]][tank[1]]=str;
   }
}
function shot(y,x){
   var i=0;
   while(true){
      i++;
      if(yx[tank[0]+(y*i)][tank[1]+(x*i)]=="#")break;
      else if(yx[tank[0]+(y*i)][tank[1]+(x*i)]=="*"){yx[tank[0]+(y*i)][tank[1]+(x*i)]=".";break;}
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var t=arr.shift()-0;
for(var i=0;i<t;i++){
   if(i!=0)console.log("");
   var hw=arr.shift().split(" ").map(Number);
   var yx=[];
   yx.push("######################".split(""));
   var tank=[0,0];
   for(var j=0;j<hw[0];j++){
      var ary=arr.shift().split("");
      var w=-1;
      ary.forEach(function(v,i){
         if(v=="^" || v=="v" || v=="<" || v==">")w=i;
      });
      if(w!=-1)tank=[j+1,w+1];
      ary.unshift("#");
      ary.push("#");
      yx.push(ary);
   }
   yx.push("######################".split(""));
   arr.shift();
   var n=arr.shift().split("");
   n.forEach(function(v){
      if(v=="U")move(-1,0,"^");
      else if(v=="D")move(1,0,"v");
      else if(v=="L")move(0,-1,"<");
      else if(v=="R")move(0,1,">");
      else if(v=="S"){
         var str=yx[tank[0]][tank[1]];
         if(str=="^")shot(-1,0);
         else if(str=="v")shot(1,0);
         else if(str=="<")shot(0,-1);
         else if(str==">")shot(0,1);
      }
   });
   yx.shift();
   yx.pop();
   var ans=yx.join("\n").replace(/\,/g,"").replace(/^#|#$/mg,"");
   console.log(ans);
}

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

//vector <long long> v;

//stack <long long> s[1000000], wym;

//queue <long long> s;

long long int  x[1000000], y, z;
char s1[1000000], s2[1000000];

int main()
{
    long long int a, b, c, d, k, l, i, j, q, t, p, n, m=131072, w, r;
    
    t=1;
    //scanf("%lld", &t);
    for(q=0; q<t; q++)
    {
        scanf("%lld", &n);

        n-=400;
        n/=200;
        n=8-n;
        printf("%lld\n", n);
    }
    return(0);
}


Measured memory_bytes: 3824
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// MACRO

#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "YES" : "NO")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}
#define NSUM(N) (((N)*((N)+1))/2)

// Global Tables


// Class Definitions

// Functions

void TC(int t)
{
    long long  N, K, i;
    cin >> N >> K;
    long long out = 0, mod = 1e9+7;
    for(i = K; i <= N+1; i++)
    {
        out = (out + NSUM(N+1) - NSUM(N - i + 1) - NSUM(i) + 1)%mod;
    }
    //cout.setf(ios::fixed, ios::floatfield);
    //cout.precision(4);
    cout << out << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3652