akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int x; cin >> x;
	for (int i = 1; i <= x; ++i) {
		int j = i * 108 / 100;
		if (j == x) {
			cout << i << endl;
			return 0;
		}
	}
	puts(":(");
	return 0;
}

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

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

  int num = 0;
  string s;
  for(int i=0; i<n; i++){
    cin >> s;
    if(s == "A"){
      num++;
    }else{
      num--;
    }
    if(num < 0){
      cout << "NO" << endl;
      return 0;
    }
  }

  if(num == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3144
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {

	public static void main(String[] args)throws Exception {
		BufferedReader br = new BufferedReader ( new InputStreamReader(System.in));
		String [] input = br.readLine().split(" ");
		long a = Long.parseLong(input[0]);
		long b = Long.parseLong(input[1]);
		long c = Long.parseLong(input[2]);
		long formerA = a;
		long formerB = b;
		long formerC = c;
		long result = 0;
		while(true) {
			if(unEven(a) || unEven(b) || unEven(c)) {
				break;
			}
			long a2 = a/2;
			long b2 = b/2;
			long c2 = c/2;
			a = b2 + c2;
			b = a2 + c2;
			c = a2 + b2;
			result++;
			if(formerA == a && formerB == b && formerC == c) {
				result = -1;
				break;
			}
		}
		System.out.println(result);
	}
	private static boolean unEven(long var) {
		return (var % 2!=0);
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include<cmath>
using namespace std;
int sushu(int n)
{
    for(int i=2; i<=sqrt(n); i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;
}
int main()
{
    int n;
    cin>>n;
    for(int i=11; n; i+=10)
    {
        int m=sushu(i);
        if(m&&n!=1)
        {
            cout<<i<<" ";
            n--;
        }
     else if(m&&n==1){cout<<i;n--;}
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int f[2000010],in[2000010];
int cc(int n,int m){
	int sum=1;
	for(;m;m>>=1,n=n*n%mod)
		if(m&1)
			sum=sum*n%mod;
	return sum;
}
int c(int n,int m){
	return f[n]*in[m]%mod*in[n-m]%mod;
}
signed main(){
	int k;
	int sum=0;
	string s;
	cin>>k>>s;
	f[0]=1;
	in[0]=1;
	for(int i=1;i<k+s.size()+5;i++){
		f[i]=f[i-1]*i%mod;
		in[i]=cc(f[i],mod-2);
	}
	for(int i=0;i<=k;i++){
		sum=(sum+cc(26,i)*cc(25,k-i)%mod*c(k-i+s.size()-1,s.size()-1))%mod;
	}
	cout<<sum<<endl;
	return 0;
}
/*
				A					CCCCCCCCCC                
			   AAA                  C
			  A   A                 C
			 A     A                C
			AAAAAAAAA               C
		   A         A              CCCCCCCCCC
*/

Measured memory_bytes: 35580
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = 0;
    for(int i=1; i<=n; ++i){
        if(to_string(i).size() % 2 != 0)
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, A[1 << 18], C[3];
long long sum = 1;
int main() {
        cin >> N;
        for (int i = 1; i <= N; i++) cin >> A[i];

        for (int i = 1; i <= N; i++) {
                long long cnt = 0, id = -1;
                if (A[i] == C[0]) { cnt++; id = 0; }
                if (A[i] == C[1]) { cnt++; id = 1; }
                if (A[i] == C[2]) { cnt++; id = 2; }
                if (id == -1) {
                        cout << "0" << endl;
                        return 0;
                }
                sum *= cnt; C[id]++;
                sum %= 1000000007;
        }
        cout << sum << endl;
        return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> w_sum(n, 0);
    for(int i=0; i<n; i++) {
        int tmp;
        cin >> tmp;
        if(i == 0) {
            w_sum.at(0) = tmp;
        } else {
            w_sum.at(i) = w_sum.at(i-1) + tmp;
        }
    }

    int ans = 100000;

    for(int i=0; i<n; i++) {
        int tmp = abs((w_sum.at(n-1)-w_sum.at(i))-w_sum.at(i));
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,T;
  cin>>n>>T;
  int c[n],t[n];
  int m=10000;
  for(int i=0;i<n;i++){
    cin>>c[i]>>t[i];
    if(t[i]<=T){
      m = min(m,c[i]);
    }
  }
  
  if(m==10000){
    cout<< "TLE" << endl;
    return 0;
  }else{
    cout<<m<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
//  ######    ##   ######    ##   ##    ##
//  ##  ##   ###   ##  ##   ###   ###   ##
//  ######  ####   ######  ####   ##### ##
//  ##     ## ##   ##     ## ##   ## #####
//  ##    ##  ##   ##    ##  ##   ##   ###
#include<bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(b);i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(d);j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for((a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for((a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRvl(c) for (vl::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvll(c) for (vll::iterator it = (c).begin(); it != (c).end(); it++)
#define mod 1000000007
#define gc getchar_unlocked
#define pc putchar_unlocked3
#define pb(a) push_back((a))
 
int arr[]={31,28,31,30,31,30,31,31,30,31,30,31};

void solve()
{
    int n;
    cin>>n;
    for(double i=0;i<=n;i++)
    {
        if(int(i*1.08)==n){cout<<i;return;}
    }
    cout<<":(";
}


int main()
{/*
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
   */ 
    
    lo t;
    //cin>>t;
    //while(t--)
        solve();




}


Measured memory_bytes: 256
n,k = map(int,input().split())
h_ = []
for _ in range(n):
    h = int(input())
    h_.append(h)
h_.sort()
ans = h_[k-1]-h_[0]
for i in range(k,n):
    ans = min(ans,h_[i]-h_[i+1-k])
print(ans)

Measured memory_bytes: 7384
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	int A, B;

	cin >> A >> B;

	if (A >= 10 || B >= 10) {
		cout << "-1" << endl;
	}
	else {
		cout << A * B << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if((a+b)%2)
		cout<<"IMPOSSIBLE"<<endl;
	else
		cout<<(a+b)/2;
	return 0;
}

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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

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

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int ans = INF;
	FOR(i,0,26){
		int longestSubstr = 0;
		int count = 0;
		FOR(j,0,n){
			if(s[j] != 'a' + i ){
				count++;
			}else{
				longestSubstr = max(longestSubstr, count);
				count = 0;
			}
		}
		longestSubstr = max(longestSubstr, count);
		//cout << (char)('a' + i) << " " << longestSubstr << endl;
		ans = min(ans, longestSubstr);
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
    //解説あり
    int Q;
    cin >> Q;
    rep(i, 0, Q) {
        ll A, B;
        cin >> A >> B;
        ll X = A*B;
        if (A>B) swap(A, B);

        ll l = 0, r = A+B-1;
        while (r-l>1) {
            ll m = (r+l)/2;
            ll k = (m+1)/2;
            ll mx = 0;
            if (m%2==1) {
              ll a = k, b = k;
              if (A<=k) a++;
              if (B<=k) b++;
              mx = a*b;
            } else {
              ll ax = k, ay = k+1;
              ll bx = k, by = k+1;
              if (A==k+1) ay = k+2;
              else if (A<=k) ax = k+1, ay = k+2;
              
              if (B==k+1) by = k+2;
              else if (B<=k) bx = k+1, by = k+2;
              
              mx = max(ax*by, ay*bx);
            
            }

            if (mx<A*B) l = m;
            else r = m;
            
        }

       
      
        cout << l << endl;
    }

    return 0;
}





Measured memory_bytes: 3636
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 998244353;

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

  LL n;
  cin>>n;
  vector<LL> a(n);
  REP(i,n){
    cin >> a[i];
  }

  SORT(a);

  cout << a[a.size() - 1] - a[0] << endl;
}


Measured memory_bytes: 256
# Aizu Problem ITP_1_9_B: Shuffle
#
import sys, math, os
 
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")
 
 
while True:
    string = input().strip()
    if string == '-':
        break
    n = int(input())
    for _ in range(n):
        h = int(input())
        string = string[h:] + string[:h]
    print(string)


Measured memory_bytes: 5648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(4);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N;
    cin >> N;
    char S[2][N];
    bool used[N]={};
    rep(i,2) cin >> S[i];
    lint ans=1;
    rep(i,N){
        if(S[0][i]==S[1][i]){
            if(i==0) ans=ans*3;
            else if(S[0][i-1]!=S[1][i-1]) ans*=1;
            else ans=(ans*2)%MOD;
        }
        if(S[0][i]!=S[1][i]){
            if(i>0) if(used[i-1]) continue;
            if(i==0) ans=ans*6;
            else if(S[0][i-1]!=S[1][i-1]) ans=(ans*3)%MOD;
            else ans=(ans*2)%MOD;
            used[i]=true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;



int main()
{
	string A,B;cin>>A>>B;
	
	vector<vector<int>>places(26);
	for (int i = 0; i < A.size(); ++i) {
		places[A[i]-'a'].push_back(i);
	}

	vector<int>v;
	{
		 int now=-1;
		for (int i = 0; i < B.size(); ++i) {
			int ch(B[i]-'a');

			auto it=upper_bound(places[ch].begin(),places[ch].end(),now);
			if (it == places[ch].end()) {
				v.clear();
				break;
			}
			else {
				v.push_back(*it);
				now=*it;
			}
		}
	}
	if (v.empty()) {
		cout<<"no"<<endl;
	}
	else {
		bool ok = true;
		int N=B.size();
		for (int i = 0; i < B.size(); ++i) {
			int pre=i==0?0:v[i-1]+1;
			int nex=i==N-1?A.size()-1:v[i+1]-1;

			{
				auto lt=lower_bound(places[B[i]-'a'].begin(),places[B[i]-'a'].end(),pre);
				auto rt=upper_bound(places[B[i]-'a'].begin(),places[B[i]-'a'].end(),v[i]-1);

				if(lt!=rt)ok=false;
			}
			{
				auto lt = lower_bound(places[B[i] - 'a'].begin(), places[B[i] - 'a'].end(), v[i]+1);
				auto rt = upper_bound(places[B[i] - 'a'].begin(), places[B[i] - 'a'].end(), nex);

				if (lt != rt)ok = false;
			}
		}
		if(ok)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 8908
t = int(input())
a = []
a = list(map(int, input().split()))
answer = []

pos = True
while len(a) > 0:
    for i in range(len(a)-1, -1 ,-1):
        if a[i] == i+1:
            temp = a.pop(i)
            answer.append(temp)
            break
    else:
        pos = False
        break

if pos == True:
    for i in answer[::-1]:
        print(i)
else:
    print(-1) 


Measured memory_bytes: 3064
#include <iostream>
#include<stdio.h>
#include <math.h>
using namespace std;


int main(){
	string S;
	cin >>S;
	S[0]='2';
	S[1]='0';
	S[2]='1';
	S[3]='8';

	cout<<S<<endl;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;

int main(){
    int N;
    cin >> N;
    int cnt=0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(i % 2 == 0 && a % 2 == 1){
            cnt ++;
        }
    }
    cout << cnt << endl;


    return 0;
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 2005;

int n;
char tmp[N];
std::bitset<N> a[N], f[N], g[N];

int main() {
	read(n);
	for (int i = 2; i <= n; ++i) {
		readStr(tmp + 1);
		for (int j = 1; j < i; ++j) {
			a[i][j] = tmp[j] ^ '0';
			a[j][i] = a[i][j] ^ 1;
		}
	}
	for (int i = 1; i <= n; ++i) {
		f[i][i] = g[i][i] = 1;
	}
	for (int len = 2; len <= n; ++len) {
		for (int l = 1; l <= n - len + 1; ++l) {
			int r = l + len - 1;
			if ((g[l + 1] & f[r] & a[l]).count()) {
				f[r][l] = 1;
			}
			if ((g[l] & f[r - 1] & a[r]).count()) {
				g[l][r] = 1;
			}
		}
	}
	int ans = (g[1] & f[n]).count();
	print(ans);
}


Measured memory_bytes: 7072
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>

/***** type *****/
using namespace std;
using ll = long long;
using ld = long double;
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
template <class T> using vvvt = vector<vector<vector<T>>>;
using ml = boost::multiprecision::cpp_int;

/***** define *****/
#define all(c) (c).begin(), (c).end()            // begin to end
#define rep(i, b, e) for (ll i = b; i < e; i++)  // repeat
#define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse
/***** const value *****/
#define llong_max 9223372036854775807            // 9 * 10^18
#define ldbl_max 1.79769e+308                    // 1.7 * 10^308
#define mod 1000000007                           // 1e9 + 7
#define pi 3.14159265                            // 3.14 ...
#define nya 10                                   // nya size
/***** for each macro *****/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = Size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

/***** lambda *****/
auto Adjust = [] // add vector or sub vector
(auto b, auto e, auto x)
{ for (auto it = b; it != e; ++it)* it += x; };
auto Bit = [] // long long bit shift
(auto n) { return (1LL << n); };
auto Count = [] // long long count value
(auto b, auto e, auto x) { return (ll)count(b, e, x); };
auto CtoLL = [] // char to long long
(auto c) { return (ll)(c - '0'); };
auto Divc = [] // long double div ceiling
(auto a, auto b) { return ceil((ld)a / (ld)b); };
auto Nya = [] // long long nya size
(auto n) { return (ll)pow(10, n); };
auto Size = []  // long long collection size
(auto& c) { return (ll)(c).size(); };
auto Sum = []   // long long accumulate
(auto b, auto e) { return accumulate(b, e, 0LL); };
auto VVT = []   // vector<vector<T>> resize 
(auto& vvt, auto ysize, auto xsize)
{ vvt.resize(ysize); each(i, vy, vvt) vy.resize(xsize); };
auto VVVT = []   // vector<vector<vector<T>>> resize 
(auto& vvvt, auto zsize, auto ysize, auto xsize)
{ vvvt.resize(zsize); each(z, vz, vvvt) VVT(vz, ysize, xsize); };
auto InVVT = []  // input vector<vector<T>> (T != struct)
(auto& vvt) { each(y, vy, vvt) each(x, e, vy) cin >> e; };
auto InVVVT = [] // input vector<vector<vector<T>>> (T != struct)
(auto& vvvt) { each(z, vz, vvvt) InVVT(vz); };

int main(void)
{
	ll N; cin >> N;
	vt<ll> a(N); each(i, e, a) cin >> e;

	if (Count(all(a), 1) == 0)
	{
		cout << -1;
		return 0;
	}

	ll ans = 0;
	each(i, e, a)
	{
		if (e == ans + 1)
			ans++;
	}

	cout << N - ans;
	return 0;
}


Measured memory_bytes: 1792
mod = 10 ** 9 + 7
S = input()
dp = [[0] * 4 for i in range(len(S) + 1)]

dp[0][0] = 1
for i in range(len(S)):
    for j in range(4):
        if S[i] == '?':
            dp[i + 1][j] = dp[i][j] * 3 % mod
        else:
            dp[i + 1][j] = dp[i][j]
            
    if S[i] == 'A' or S[i] == '?':
        dp[i + 1][1] += dp[i][0]
    if S[i] == 'B' or S[i] == '?':
        dp[i + 1][2] += dp[i][1]
    if S[i] == 'C' or S[i] == '?':
        dp[i + 1][3] += dp[i][2]
        
print(dp[len(S)][3] % mod)

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   ll N, K; cin >> N >> K;
   (K <= (N + 1) / 2) ? cout << "YES\n" : cout << "NO\n";
}



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

int main(){
   string c;
   int b,a;
   cin>>a>>b>>c;
   for(int i=0;i<a;i++){
     if(!isdigit(c[i] )){
        cout<<"No";
                    return 0;
     }
   }
    if(c[a] !='-'){
        cout<<"No";
            return 0;
     }
     for(int i=a+1;i<c.size();i++){
             if(!isdigit(c[i] )){
            cout<<"No";
            return 0;
     }
     }
     cout<<"Yes";
}


Measured memory_bytes: 256
import itertools

n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

pa = list(itertools.accumulate([0] + p))

m = 0
for i in range(n-k+1):
  s = pa[i+k] - pa[i]
  if s > m:
    m = s
print((m+k)/2)

Measured memory_bytes: 25152
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define FOR(i,a,n) for(register int i=a; i<=n; ++i)
#define FDR(i,a,n) for(register int i=a; i>=n; --i)
#define mem(a) memset(a, 0, sizeof(a))
#define pb push_back()
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 100005;
const int MOD = 1000000009;
int prime[1000005];
int Mark[1000005];
void Prime(){
    int index = 0;
    for(int i = 2; i <= 100000; i++)
    {
        if(Mark[i] == 0){
            prime[index++] = i;
        }
        for(int j = 0; j < index && prime[j] * i <= 100000; j++)
        {
            Mark[i * prime[j]] = 1;
            if(i % prime[j] == 0){
                break;
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    Prime();
    int n;
    cin >> n;
    int i = 1;
    int cnt = 0;
    while(1)
    {
        if(prime[i]%5 == 1)
        {
            cout << prime[i] << ' ';
            cnt++;
        }
        if(cnt == n)break;
        i++;
    }
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
const ll MOD=1e9+7;
char a[55][55];
bool vis[55][55];
ll dx[]={0,-1,0,1};
ll dy[]={-1,0,1,0};
ll n,m;
ll bfs(ll x,ll y){
    queue< pair<ll,ll> >q;
    q.push({x,y});
    ll cnt = 0;
    vis[x][y]=1;
    while(!q.empty()){
        cnt++;
        x=q.front().first,y=q.front().second;
        q.pop();
        for(ll i=0;i<4;i++){
            ll nx = x+dx[i] , ny = y+dy[i];
            if(nx>=0 && nx< n  && ny>=0 && ny<m && a[nx][ny]=='#' && !vis[nx][ny]){
                q.push({nx,ny});
                vis[nx][ny]=1;
            }
        }
    }
    return cnt;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
     cin>>n>>m;
     for(ll i=0;i<n;i++)cin>>a[i];
     for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(vis[i][j] || a[i][j]=='.')continue;
            ll cnt = bfs(i,j);
            //cout<<i<<" "<<j<<"  "<<cnt<<endl;
            if(cnt==1)return cout<<"No" , 0;
        }
     }
     cout<<"Yes";
}


Measured memory_bytes: 256
N,A,B = map(int,input().split())
*v, = sorted(map(int,input().split()))[::-1]
f = [1]*51
for i in range(1,51):
    f[i] = f[i-1]*i
def comb(n,r):
    return f[n]//f[r]//f[n-r]
print(sum(v[:A])/A)
a = v[:A].count(v[A-1])
b = v[A:].count(v[A-1])+a
ans = comb(b,a)
if a == A:
    for k in range(A+1,B+1):
        ans += comb(b,k)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int sum = 0;
            String st = sc.next();
            if(st.equals("0")) break;
            for(int i=0; i<st.length(); i++){
                //System.out.println();
                sum = sum + (st.charAt(i) - '0');
            }
            System.out.println(sum);
        }
        sc.close();
    }
    
}


Measured memory_bytes: 26164
// Help from https://www.geeksforgeeks.org/queries-number-distinct-elements-subarray/

#include <bits/stdc++.h> 

using namespace std; 

struct Query { 
    int l, r, index; 
};

const int MAXN = 5e5 + 1; 

vector<long long> input_vector(MAXN); 
vector<long long> bit(MAXN, 0);
vector<Query> queries(MAXN);

bool compare(const Query &x, const Query &y) { 
    return x.r < y.r; 
}

void update(int index, int value, int n) { 
    for (; index <= n; index += index & -index) 
        bit[index] += value;
} 

long long query(int index, int n) { 
    long long sum = 0; 
    for (; index > 0; index -= index & -index) {
        sum += bit[index];
    }
    return sum; 
}
  
void answer_queries(int n, int q) { 
    vector<int> last_visit(MAXN, -1);
    vector<long long> answer(q);

    int query_counter = 0;

    for (int i = 0; i < n; i++) { 
        if (last_visit[input_vector[i]] != -1) 
            update(last_visit[input_vector[i]] + 1, -1, n); 
  
        last_visit[input_vector[i]] = i;
        update(i + 1, 1, n);
  
        while (query_counter < q && queries[query_counter].r == i) { 
            answer[queries[query_counter].index] = 
                     query(queries[query_counter].r + 1, n)- 
                     query(queries[query_counter].l, n); 
            query_counter++; 
        } 
    }

    for (int i = 0; i < q; i++) {
        cout << answer[i] << "\n";
    }
}

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

    cin >> number_of_elements >> number_of_queries;

    input_vector.resize(number_of_elements);
    queries.resize(number_of_queries);
    
    for (int i = 0; i < number_of_elements; i++) {
        cin >> input_vector[i];
    }


    int l;
    int r;
    
    for (int i = 0; i < number_of_queries; i++) {
        cin >> l >> r;
        queries[i] = {l - 1, r - 1, i};
    }

    sort(queries.begin(), queries.end(), compare);
    answer_queries(number_of_elements, number_of_queries);

    return 0;
}

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

int main() {
  std::string s;
  
  std::cin >> s;
  
  int count = 0;
  for(int i=0; i<s.size(); i++) {
    if(s[i] == '1') {
      count++;
    }
  }
  std::cout << count;
}

Measured memory_bytes: 256
n,x=gets.chomp.split(" ").map { |e| e.to_i }
a = gets.chomp.split(" ").map { |e| e.to_i  }.push(x).sort



b=Array.new(n,0)

for i in 0..n-1 do
  b[i] = a[i+1]-a[i]
end

def gcd(a,b)
  if b>a
     gcd(b,a)
  end

  if a%b == 0
    return b
  end
r = a%b

 gcd(b,r)
end

gc = b[0]

for i in 1..n-1 do
  gc = gcd(gc,b[i])
end

puts gc

Measured memory_bytes: 11016
n,m = map(int,input().split())
ans = [-1,10**6]

for i in range(m):
    tmp = list(map(int,input().split()))
    ans[0] = max(ans[0],min(tmp))
    ans[1] = min(ans[1],max(tmp))

print(max(ans[1]-ans[0]+1,0))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>


using namespace std;

// 1色かどうか
int is1Color(string s) {
    char first = s[0];
    for(int i = 1; i < s.length(); i++) {

        if(first != s[i]) {
            return 0;
        }
    }
    return 1;
}

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

    int count = 0;

    //while(1) {
    //    if( is1Color(s) ) break;

        int cost = 0;
        char c = s[0];

        for(int i = 1; i < s.length(); i++) {

            if(c != s[i]) {
                cost++;
                c = s[i];
            }
        }
        count++;
        //printf("loop[%d]:%d\n", count,cost);

        //if(count == 10) break;
    //}
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


/*
void test() {
	int k = 4;
	vector<int> a = { 1,4,2,4,3 };
	vector<int> b;

	rep(i, a.size() * k) {
		int j = i % a.size();
		auto it = find(all(b), a[j]);
		if (it == b.end()) {
			b.push_back(a[j]);
		}
		else {
			b.erase(it, b.end());
		}

		for (int x : b)cout << x << ' ';
		cout << endl;
	}
}*/



int n;
long long k;
int a[200000];

set<int> pos[200001];
int nxt[200000];



pair<long long, int> nearest_clear() {
	map<int, long long> memo;
	long long ti = 0;
	int p = 0;

	while (1) {
		int np = nxt[p];
		int t;
		if (p < np) {
			t = np - p + 1;
		}
		else {
			t = n - p + np + 1;
		}
		if (ti + t > n * k)break;

		ti += t;
		p = (np + 1) % n;

		auto it = memo.find(p);
		if (it != memo.end()) {
			long long past = ti - it -> second;
			long long rem = n * k - ti;
			
			ti += rem - rem % past;
		}
		else {
			memo[p] = ti;
		}
	}
	return make_pair(ti, p);
}


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

	cin >> n >> k;
	rep(i, n)cin >> a[i];

	rep(i,n) {
		pos[a[i]].insert(i);
	}
	rep(i,n) {
		auto it = pos[a[i]].upper_bound(i);
		if (it != pos[a[i]].end()) {
			nxt[i] = *it;
		}
		else {
			nxt[i] = *pos[a[i]].begin();
		}
	}

	auto pa = nearest_clear();
	long long num = n * k - pa.first;
	int p = pa.second;

	set<int> s;
	vector<int> v;
	rep(i, num) {
		if (s.count(a[p])) {
			while (1) {
				int x = v.back();
				v.pop_back();
				s.erase(x);
				if (x == a[p])break;
			}
		}
		else {
			v.push_back(a[p]);
			s.insert(a[p]);
		}

		p = (p + 1) % n;
	}

	rep(i,v.size()) {
		if (i)cout << ' ';
		cout << v[i];
	}
	cout << endl;


	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<long long> vll;

#define pub push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define umap unordered_map
#define uset unordered_set

#define forn(i, n)     for(ll i = 0; i< (ll)n; i++)
#define forf(i, x, y)  for(ll i=(x); i<=(ll)y; i++)
#define forb(i, x, y)  for(ll i=(x); i>=(ll)y; i--)
#define lpt() 		   ll T; std::cin>>T; while(T--)

#define nl "\n"
#define newl std::cout<<"\n";
#define bug(x) std::cerr<<"debug "<<#x<<" : "<<x<<"\n";
#define all(x) x.begin(),x.end()
#define fastio() ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);

template<typename X> std::ostream& operator<< (std::ostream& out, std::vector<X> v)
{ for(auto &i : v) out<<i<<" "; return out; }
template<typename X, typename Y> std::ostream& operator<< (std::ostream& out, std::pair<X,Y> p)
{ out<<p.first<<" "<<p.second; return out; }

static const long long mod = 1000000007;

using namespace std;

ll h,w;
ll dp[1005][1005];
ll a[1005][1005];


ll grid(ll i, ll j)
{
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(a[i][j]==-1)
		return dp[i][j]=0;
	
	return dp[i][j] = (grid(i+1,j) + grid(i,j+1))%mod;
}

int main()
{fastio()
	
	memset(dp,-1,sizeof dp);
	memset(a,-1,sizeof a);

	cin>>h>>w;
	forn(i,h)
	{
		forn(j,w)
		{
			char temp;
			cin>>temp;
			if(temp == '.')
				a[i][j]=0;
		}
	}

	dp[h-1][w-1] = 1;

	cout<<grid(0,0)<<nl;

return 0;}


Measured memory_bytes: 16128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		String T = sc.next();
		
		int Sn = sc.nextInt();
		int Tn = sc.nextInt();
		
		String U = sc.next();
		
		if(U.contentEquals(S)) {
			Sn -= 1;
		    }
		if(T.contentEquals(U)) {
			Tn -= 1;	
			}
		System.out.println(Sn);
		System.out.println(Tn);
	
	}
	}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<int> two = {65536,32768,16384,8192,4096,2048,1024,512,256,128,64,32,16,8,4,2,1};
    int counter = 0;
    cout << 0 << "\n";
    cout.flush();
    string mae = in<string>();
    int now = 0;
    int plus = 1;
    while(1){
        if(mae == "Vacant")break;
        if(two[counter] >= N){
            counter++;
            continue;
        }
        if(plus)if(now + two[counter] >=N){
            counter++;
            continue;
        }
        if(plus){
            now += two[counter];
            cout << now << "\n";
            cout.flush();
        }else{
            now -= two[counter];
            cout << now << "\n";
            cout.flush();
        }
        string cat = in<string>();
        if(cat == "Vacant"){
            break;
        }else if(cat == mae){
            mae = cat;
            plus = 1;
        }else{
            plus = 0;
        }
        counter++;
    }
}

Measured memory_bytes: 852
#
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i,n) for (int i = 1; i <= (int)(n); i++)

int main()
{
  int n;
  cin >> n;
  
  string s;
  cin >> s;
  
  int east[n] = {0}, west[n] = {0};
  if(s[0] == 'E') east[0] = 1;
  else west[0] = 1;
  for(int i = 1; i < n; i++)
  {
    if(s[i] == 'E')
    {
      east[i] = east[i-1] + 1;
      west[i] = west[i-1];
    }else
    {
      west[i] = west[i-1] + 1;
      east[i] = east[i-1];
    }
  }
    
  int ans = 0;
  int minans = east[n-1] - east[0];
  for(int i = 1; i < n; i++)
  {
    ans = west[i-1] + east[n-1] - east[i];
    minans = min(ans,minans);
  }
  
  cout << minans << endl;
}


Measured memory_bytes: 6140
fun main(args: Array<String>) {
    val S = readLine()!!
    val N = S.length

    for (i in 1..N/2-1) {
        val j = N/2-i
        if (S.substring(0, j) == S.substring(j, 2*j)) {
            println(j*2)
            return
        }
    }
}

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

typedef long long ll;
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
const double pi = acos(-1.0);
int h,w,k;
char m[310][310];

int idx=1;
int ans[310][310];

int main(){
  cin>>h>>w>>k;
  rep(i,0,h){
    scanf("%s",m[i]);
  }
  rep(i,0,h){
    int lastj = 0;
    rep(j,0,w){
      if(m[i][j] == '#'){
        rep(jj,lastj,j+1){
          ans[i][jj]=idx;
        }
        lastj=j+1;
        idx++;
      }
    }
    // empty line exclude
    if(lastj != 0){
      rep(j,lastj,w){
        ans[i][j]=ans[i][j-1];
      }
    }
  }
  rep(i,0,h){
    if(ans[i][0] != 0)continue;
    if(i == 0 || ans[i-1][0] == 0)continue;
    rep(j,0,w){
      ans[i][j] = ans[i-1][j];
    }
  }
  per(i,0,h){
    if(ans[i][0] != 0)continue;
    if(i == h-1 || ans[i+1][0] == 0)continue;
    rep(j,0,w){
      ans[i][j] = ans[i+1][j];
    }
  }
  rep(i,0,h){
    rep(j,0,w){
      printf("%d ",ans[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 1280
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
use std::collections::BinaryHeap;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        M: usize,
        shohin: [(i64, i64, i64); N],
    }

    if M == 0 {
        println!("0");
        return
    }
    let mut sums = [0; 8];
    let mut stacks: BinaryHeap<i64> = BinaryHeap::with_capacity(M);
    for ind in 0..8 {
        let ind0 = -(ind&1 as i64) * 2 + 1; 
        let ind1 = -((ind>>1)&1 as i64) * 2 + 1;
        let ind2 = -((ind>>2)&1 as i64) * 2 + 1;
        for inds in 0..N {
            let s = shohin[inds];
            let ss = s.0*ind0 + s.1*ind1 + s.2*ind2;
            if inds < M {
                stacks.push(ss);
            } else {
                let max = stacks.pop().unwrap();
                stacks.push(cmp::min(ss, max));
            }
        }
        sums[ind as usize] = -stacks.iter().sum::<i64>();
        stacks.clear();
    }

    println!("{}", sums.iter().max().unwrap());
}


Measured memory_bytes: 4352
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    long left_one = a, right_one = a+W;
    long left_two = b, right_two = b+W;

    long ans;
    if(right_one < left_two or left_one > right_two)
    {
        ans = min(abs(right_one - left_two), abs(left_one - right_two));
    }
    else
    {
        ans = 0;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K; cin >> N >>K;
  vector<int> l(N);
  for(int i = 0; i < N; i++)
    cin >> l.at(i);
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans = 0;
  for(int i = 0; i < K; i++)
    ans += l.at(i);
  
  cout << ans << endl;
}

Measured memory_bytes: 3584
module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let rec factorize acc i n =
  if n <= 1 then acc
  else if n < i * i then n :: acc
  else if n mod i = 0 then factorize (i :: acc) i (n / i)
  else factorize acc (i + 1) n
let factorize n =
  match factorize [] 2 n with
  | [] -> []
  | p :: ps ->
      let (acc, p, n) = List.fold_left (fun (acc, p, n) q ->
        if p = q
        then (acc, p, n + 1)
        else ((p, n) :: acc, q, 1)) ([], p, 1) ps in
      (p, n) :: acc

let rec solve x = function
  | [] -> if x = 1 then 1 else 0
  | n :: rest ->
      Array.fold_left ( + ) 0 @@
      Array.init (n + 1) @@ fun i ->
        if x mod (i + 1) <> 0 then 0
        else solve (x / (i + 1)) rest
let solve = solve 75

let () = Scanf.scanf "%d" @@ fun n ->
  Printf.printf "%d\n" @@
  solve @@
  List.map snd @@
  IntMap.bindings @@
  Array.fold_left (List.fold_left (fun pf (p, n) ->
    IntMap.add p (n + try IntMap.find p pf with Not_found -> 0) pf)) IntMap.empty @@
  Array.init n @@ fun i -> factorize @@ i + 1



Measured memory_bytes: 1408
import sys
input = sys.stdin.readline

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

import functools
N,K = map(int,input().split())
A = [int(x) for x in input().split()]
max_A = max(A)
gcd_A = functools.reduce(gcd,A)

answer = 'POSSIBLE' if K <= max_A and K % gcd_A == 0 else 'IMPOSSIBLE'

print(answer)

Measured memory_bytes: 14664
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b

main = do
 inputs <- readLnInt
 print $ solve inputs

solve [a,p] = div (a*3 + p) 2


Measured memory_bytes: 380
package main

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

const mod = int(1e9) + 7

func invCount(a []int) int {
	ret := 0
	for i := 0; i < len(a); i++ {
		for j := i + 1; j < len(a); j++ {
			if a[i] > a[j] {
				ret++
			}
		}
	}
	return ret
}

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	A := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}
	p := invCount(A) // A単独での転倒数
	p2 := invCount(append(A, A...))
	q := p2 - p*2 // AとAの間で発生する転倒数
	P := (p * K) % mod
	Q := (q * ((K * (K - 1) / 2) % mod)) % mod // AをK個並べた時、2個のAを選ぶ選び方はkC2個(==K*(K-1)/2)となる
	fmt.Println((P + Q) % mod)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ii pair<int ,int >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1(x,n) for(int x = 1; x <= n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}


string ans="";
int dp[(int)(3001)][(int)3001];

void lcs(string& s1,string& s2, int i, int j)
{
	if(i==0||j==0)
		return;
	if(s1[i-1]==s2[j-1])
	{
		ans.pb(s1[i-1]);
		lcs(s1,s2,i-1,j-1);
	}
	else
	{
		dp[i-1][j]==dp[i][j]?lcs(s1,s2,i-1,j):lcs(s1,s2,i,j-1);
	}
}
int main(){
	IOS
 	
 	
	string s1,s2;
	cin>>s1>>s2;
	int n1 = s1.size();
	int n2 = s2.size();

	for(int i=0;i<=s1.size();i++)
	{
		for(int j=0;j<=s2.size();j++)
		{
			if(i==0||j==0)
				dp[i][j]=0;
			else if(s1[i-1]==s2[j-1])
				dp[i][j] = 1+dp[i-1][j-1];
			else
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
	//cout<<dp[n1][n2];

 	lcs(s1,s2,n1,n2);
 	reverse(ans.begin(),ans.end());
 	cout<<ans;
	return 0;	
}

Measured memory_bytes: 35456
N = int(input())
A = list(map(int, input().split()))
A.sort()

F = [0 for i in range(A[-1]+1)]
for i in A:
  F[i] = 1

c_set = set()
for i in A:
  if F[i] == 0:
    continue
  c_set.add(i)
  for j in range(i, A[-1]+1, i):
    F[j] = 0

ans = len(c_set)
d = 0
d_set = set()
for i in range(N):
  if i == 0 and N > 1:
    if A[i] == A[i+1]:
      d_set.add(A[i])
  elif i < N - 1 and A[i-1] != A[i] and A[i] == A[i+1]:
    d_set.add(A[i])

print( len(c_set - d_set) )

Measured memory_bytes: 164876
H, W = map(int, input().split(' '))
S = []
for i in range(H):
  S.append(input())
 
dj = [-1, 0, 0, 1]
dk = [0, -1, 1, 0]
flug = []
for j in range(H):
  for k in range(W):
    judge = 'No'
    if S[j][k] == '.':
      judge = 'Yes'
    if S[j][k] == '#':
      for d in range(4):
        if 0 <= j+dj[d] <= H-1:
          if 0 <= k+dk[d] <= W-1:
            if S[j+dj[d]][k+dk[d]] == '#':
              judge = 'Yes'
      if judge == 'No':
        flug.append(0)
if 0 in flug:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9236