akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){

	while(true) {

		int n,m,input;
		cin >> n;
		if ( n == 0 ) break;

		vector<int> time;
		vector<int> sat;
		for ( int i = 0; i < n; i++ ) {
			cin >> m >> input;
			sat.push_back(input);
			input = 0;
			int s,e;
			for ( int j = 0; j < m; j++ ) {
				cin >> s >> e;
				for ( int k = s - 6; k < e - 6; k++ ) {
					input += ( 1 << k );
				}
			}
			time.push_back(input);
		}

		int sch[ 1 << 16 ] = {0};
		int sat_max = 0;

		for ( int i = 0; i < n; i++ ) {
			for ( int j = ( 1<<16 ) - time[i] - 1; j >= 0; j-- ) {
				if ( ( j & time[i] ) == 0 ) {
					sch[ j + time[i] ] = max( sch[ j + time[i] ], sch[j] + sat[i] );
					sat_max = max( sat_max, sch[ j + time[i] ] );
				}
			}
		}

		cout << sat_max << endl;

	}
	return 0;
}

Measured memory_bytes: 1476
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define l long long
void frooty()
{
	l k;
	cin>>k;
	l sum=0;
	for(l i=1;i<=k;i++)
	{
		for(l j=1;j<=k;j++)
		{
			for(l a=1;a<=k;a++)
			{
				sum+=__gcd(i,__gcd(j,a));
			}
		}
	}
	cout<<sum<<endl;
}
int main()
{
	l t=1;
//	cin>>t;
	while(t--)
	{
		frooty();
	}
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 50000001
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans,cnt;


int main() {
	ll N;
	cin >> N;
	vector<int> P(N),Q(N);
	rep(i, N) {
		cin >> P[i];
	}
	rep(i, N) {
		cin >> Q[i];
	}
	vector<int> v(N);
	iota(v.begin(), v.end(), 1);

	int a, b;
	do {
		cnt++;
		if (equal(v.begin(), v.end(), P.begin())) {
			a = cnt;
		}
	} while (next_permutation(v.begin(), v.end()));
	
	cnt = 0;
	do {
		cnt++;
		if (equal(v.begin(), v.end(), Q.begin())) {
			b = cnt;
		}
	} while (next_permutation(v.begin(), v.end()));

	cout << abs(a - b) << endl;
	
	return 0;
}

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

int main()
{
  ll n;
  cin>>n;
  ll a[10000000],b[10000000];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  
  b[0]=0;
  b[1]=abs(a[1]-a[0]);
  
  for(ll j=2;j<n;j++)
    b[j]=min(b[j-1]+abs(a[j]-a[j-1]),b[j-2]+abs(a[j]-a[j-2]));
  
  cout<<b[n-1];
  return 0;
  
}

Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

typedef vector<int> vi;

void dfs(vi e[], int x, int p, int c[]) {
    for (int y : e[x]) {
        if (y != p) {
            c[y] += c[x];
            dfs(e, y, x, c);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    vi e[n];
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int c[n];
    memset(c, 0, sizeof(c));
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        c[p-1] += x;
    }

    dfs(e, 0, -1, c);

    for (int i = 0; i < n; i++) {
        cout << c[i] << " \n"[i==n-1];
    }

    return 0;
}


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

#define F first
#define S second
#define pii pair<int, int>
#define mod 1000000007

int N, A[2099], Z, W, ans = 0;
int main() {
    cin >> N >> Z >> W;
    for(int i = 0;i < N;i++) {
        cin >> A[i];
    }
    ans = abs(A[N-1]-W);
    for(int i = 0;i < N;i++) {
        int minm = abs(A[N-1]-A[i]);
        for(int j = i+1;j < N-1;j++) {
            minm = min(minm, abs(A[N-1]-A[j]));
        }
        ans = max(ans, minm);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

map<int,int>m;

lli func(int n)
{
    if(n==0)
        return 0;
    return (n*1LL*(n-1))/2;
}

int main()
{
    fastio;
    int n;
    cin >> n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        m[x]+=1;
        v[i]=x;
    }
    map<int,int>:: iterator itr;
    lli ans=0;
    for(itr=m.begin();itr!=m.end();itr++)
    {
        int t=itr->second;
        ans=ans+func(t);
    }
    //cout << ans << endl;
    for(int i=0;i<n;i++)
    {
        int t=m[v[i]];
        lli ans1=ans;
        ans1-=func(t);
        ans1+=func(t-1);
        cout << ans1 << endl;
    }
}

Measured memory_bytes: 8320
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
struct edge{long long to,cost;};
typedef pair<int,int>P;
#define inf 1000000007
string alph("abcdefghijklmnopqrstuvwxyz");
vector<int>es[214514];
signed main(){
    int n;cin>>n;
    int size[114514];rep(i,0,n)cin>>size[i];
    sort(size,size+n);
    int sum[114514]={};sum[0]=size[0];
    rep(i,1,n)sum[i]=sum[i-1]+size[i];
    reverse(sum,sum+n);
    rep(i,0,n){
        if(sum[i]>sum[i+1]*3){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 6912
#include<cstdio>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a==b)
	{
		printf("Draw");
		return 0;
	}
	if(a==1&&b!=1)
	{
		printf("Alice");
		return 0;
	}
	if(a!=1&&b==1)
	{
		printf("Bob");
		return 0;
	}
	if(a!=0&&b!=0)
	{
		if(a>b)
		printf("Alice");
		else
		printf("Bob");
	}
	return 0;
} 

Measured memory_bytes: 128
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
	#define setfile(__a) ('orzyrt')
	#define Compile(__a) system("g++ "__a".cpp -lm -o "__a)
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
	#define setfile(__a) freopen(__a".in","r",stdin);freopen(__a".out","w",stdout)
	#define Compile(__a) ('orzyrt')
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	const int maxn = 100010;
	int n,a,b;
	int x[maxn],d[maxn];
	LL ans;
	int main(){
		read(n);read(a);read(b);
		for(R int i=1;i<=n;++i)read(x[i]);
		for(R int i=1;i<n;++i)d[i]=x[i+1]-x[i];
		for(R int i=1;i<n;++i){
			ans+=Min(1ll*d[i]*a,1ll*b);
		}
		cout<<ans;
		return 0;
	}
}
int main(){
	return Night::main();
}


Measured memory_bytes: 1024
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef double real;
typedef int64_t i64;
typedef uint64_t u64;

int main() {
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	auto can = 0, scr = 0;
	for(auto c : s) {
		if(c == 'g') {
		} else if(c == 'p') {
			scr--;
		}
		if(can) {
			can--;
			scr++;
		} else {
			can++;
		}
	}
	cout << scr << endl;
	return 0;
}

Measured memory_bytes: 512
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    int n;
    cin>>n;
    int sum=0;
    int j;
    for(int i=1;i<=n;i++){
        sum+=i;
        if(sum>=n){
            j=i; 
            break;
        }
    }
    for(int i=1;i<=j;i++){
        if(i!=sum-n){
            cout<<i<<endl;
        }
    }
}


Measured memory_bytes: 256
def dic_counter(dic, num):
    if num in dic:
        dic[num] += 1
    else:
        dic[num] = 1

N = int(input())
dic = {}
for i in input().split():
    dic_counter(dic, int(i)-1)
    dic_counter(dic, int(i))
    dic_counter(dic, int(i)+1)
for _, value in sorted(dic.items(), key=lambda x: -x[1]):
    print(value)
    break

Measured memory_bytes: 71276
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

using BigNum = unsigned long long;

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

    int i = 0, j = 0, max = 0;
    for(i = 0; i < S.size(); i++) {
        for(j = i; j < S.size() && (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T'); j++) {
            
        }
        if(max < j - i) max = j - i;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"

int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	ll t,a;
	cin>>n>>t>>a;
	map<ll,ll>mp;
	db d=1000000,tmp;
	for(ll i=1;i<=n;i++){
		cin>>x;
		tmp=abs(t-x*0.006-a);
		if(d>tmp)d=tmp,ans=i;
	}
	cout<<ans;

}

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

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data1 = Console.ReadLine().Split(' ');
            string[] data = Console.ReadLine().Split(' ');
            long h = long.Parse(data1[0]);
            long n = long.Parse(data1[1]);
            long ans = 0;

            for(long i = 0; i < n; i++)
            {
                long d = long.Parse(data[i]);
                h -= d;
        
            }

            if (h <= 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
        }
    }
}


Measured memory_bytes: 18016
n, a = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)
dp = [[[0 for _ in range(n*x_max+1)] for _ in range(n+1)] for _ in range(n+1)]

for i in range(n+1):
    for j in range(n+1):
        for k in range(n*x_max+1):
            if i == 0 and j == 0 and k == 0:
                dp[i][j][k] = 1
            elif i >= 1 and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i >= 1 and j >= 1 and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k - x[i-1]]
            else:
                dp[i][j][k] = 0
ans = 0
for k in range(1, n+1):
    if k * a <= n*x_max:
        ans += dp[n][k][k*a]
print(ans)

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

int main(void){
    using namespace std;
    int N,a=1;
    cin>>N;
    int H[N];
    for(int i=0;i<N;i++) cin>>H[i];
    for(int i=N-1;i>0;i--){
        if(H[i]+1<H[i-1]){
            a=0;
            break;
        }
        else if(H[i]+1==H[i-1]) H[i-1]--;
    }
    if(a==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main()
{
    int N,K;
    cin >> N >> K;
    double p[200100];
    for(int i = 0; i < N; i++) cin >> p[i];

    double Max = 0;
    double sum = 0;
    for(int i=0; i<K; i++){
        Max += p[i];
        sum = Max;
    }
    for(int k=K; k<N; k++){
        sum = sum - p[k-K] + p[k];
        if(sum>Max) Max = sum;
    } 
    cout << fixed << setprecision(10) << (Max+K)/2 << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
    long n,x,D,sum,bounce;

    scanf("%ld%ld",&n,&x);

    int i,arr[100];

    for(i=1; i<=n; i++)
    {
        scanf("%d",&arr[i]);
    }

    D=0;
    bounce=1;
    long newD;
    long index=1;

    while(1){
        newD = D + arr[index];

        D=newD;

        if(D>x){
            break;
        }

        index++;
    }

    printf("%ld\n",index);
    return 0;
}



Measured memory_bytes: 128
N,K = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
DP=[100000000000]*(N+1)
DP[0] = 0
DP[1] = 0
DP[2] = DP[1] + abs(h[0]-h[1])
for i in range(1,N):
    for j in range(i+1,min(i+K+1,N+1)):
        DP[j] = min(DP[j],DP[i]+abs(h[j-1]-h[i-1]))
print(DP[N])

Measured memory_bytes: 52320
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
ll T[100100], A[100100];
ll ans[100100];
int main() {
	ll N; cin >> N;
	bool ok = true;
	REP(i, N)cin >> T[i];
	REP(i, N)cin >> A[i];
	for (int i = 0; i < N; ++i) {
		ans[i] = min(T[i], A[i]);
	}
	ans[0] = 1;
	ans[N - 1] = 1;
	for (int i = 0; i < N - 1; ++i) {
		if (T[i] != T[i + 1]) {
			ans[i + 1] = 1;
		}
	}
	for (int i = N - 1; i >= 1; --i) {
		if (A[i] != A[i - 1]) {
			ans[i-1] = 1;
		}
	}
	ll res = 1;
	for (int i = 0; i < N; ++i) {
		res *= ans[i];
		res %= INF;
	}
	if (A[0] != T[N-1]) {
		ok = false;
	}
	for (int i = 0; i < N - 1; ++i) {
		if (T[i] != T[i + 1] ) {
			if (T[i+1] > A[i+1]) {
				ok = false;
			}
		}
	}
	for (int i = N - 1; i >= 1; --i) {
		if (A[i] != A[i - 1]) {
			if (A[i - 1] > T[i - 1]) {
				ok = false;
			}
		}
	}
	if (ok) {
		cout << res << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        String s = sc.next();
        if (s.charAt(s.length() - 1) == 's') s += "es"; else s += "s";
        out.println(s);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 36680
#include <iostream>
using namespace std;
int main(void){
  int mountain[10];
  for(int i = 0; i < 10; i++) {
    cin >> mountain[i];
  }
  
  for(int i = 0; i < 9; i++) {
    for(int j = i; j < 10; j++) {
      if(mountain[i] < mountain[j]) {
        int temp = mountain[i];
        mountain[i] = mountain[j];
        mountain[j] = temp;
      }
    }
  }
    
  for(int i = 0; i < 3; i++) {
    cout << mountain[i] << endl;
  }
}

Measured memory_bytes: 3096
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

struct E {
  int a, b;
  ll c;
};
typedef vector<vector<E> > G;

const ll INF = 1000000000000000000LL;

ll go(G& g, int start) {
  int n = g.size();
  vector<ll> costs(n, INF);
  costs[start] = 0;

  REP(k, n) REP(a, n) if (costs[a] != INF) for(auto e : g[a]) {
      int b = e.b;
      ll w = costs[a] + e.c;
      if (w < costs[b]) {
        costs[b] = w;
      }
    }
  ll c1 = costs[n-1];
  REP(k, n) REP(a, n) if (costs[a] != INF) for(auto e : g[a]) {
      int b = e.b;
      ll w = costs[a] + e.c;
      if (w < costs[b]) {
        costs[b] = w;
      }
    }
  ll c2 = costs[n-1];
  if(c1 != c2) return -1;
  return max(0LL, -c1);
}

G g;

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

  int n, nEdge, P;
  cin >> n >> nEdge >> P;
  g.assign(n, vector<E>(0));

  REP(i, nEdge) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    g[a].push_back((E){a, b, -(c-P)});
  }
  ll res = go(g, 0);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vl = vector<ll>;
using vi = vector<int>;
const ll INF = 1e18;
const ll mod = 1e9+7;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

// int dp[100100][100100];

ll power(int m, int n) { // m^n（繰り返し自乗法）
    if (n == 0) return 1;
    if (n % 2 == 1) return power(m, n-1) * m % mod;
    ll r = power(m, n/2);
    return r * r % mod;
}

// ll fact(int n) { // 階乗
//     return f[n];
// }

ll inv(ll a, ll b) { // 逆元を利用してa/bのmodを返す
    return a * power(b, mod-2) % mod;
}

ll f[101000];

ll comb(int n, int r) { // nCr
    if (n < r) return 0;
    // if (n == r || r == 0) return dp[n][r] = 1;
    // if (r == 1) return dp[n][r] = n;
    // if (dp[n][r] != 0) return dp[n][r];
    // return dp[n][r] = (comb(n-1, r-1) + comb(n-1, r)) % mod;
    if (n == r || r == 0) return 1;
    ll s = f[n-r] * f[r] % mod;
    return inv(f[n], s);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll p = 1;
    rep(i, 101000) {
        if (i == 0) f[i] = 1;
        else {
            p *= i;
            p %= mod;
            f[i] = p;
        }
    }
    int n, m;
    cin >> n >> m;
    int M = m;
    ll r = 1;
    for (int i = 2; i <= M; i++) {
        int cnt = 0;
        if (M % i == 0) {
            while (M % i == 0) {
                M /= i;
                cnt++;
            }
            // cout << cnt << "\n";
            r *= comb(cnt+n-1, cnt);
            r %= mod;
        }
    }
    cout << r << "\n";
}

Measured memory_bytes: 4440
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 $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")
    };
}

fn main() {
    input!{
        n: u32,
        a: [i32; n],
    }

    let mut ans = true;
    let mut tmp_max = -1;
    for &i in a.iter() {
        tmp_max = if i > tmp_max { i } else { tmp_max };

        if i < tmp_max - 1 {
            ans = false;
            break;
        }
    }

    if ans {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int n;
double x[24], y[24], r[24];
int c[24], p[24];

char dp[1 << 24];

int f(int s) {
	if(dp[s] != -1) return -1;
	if(s == 0) return 0;

	int ret = 0;
	for(int i = 0; i < n; i++) if((s & (1 << i)) && ((s & p[i]) == 0)) {
		for(int j = i + 1; j < n; j++) if((s & (1 << j)) && ((s & p[j]) == 0)) {
			if(c[i] != c[j]) continue;
			int ns = s ^ (1 << i) ^ (1 << j);
			ret = max(ret, 2 + f(ns));
		}
	}
	return dp[s] = ret;
}

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

	while(cin >> n, n) {
		for(int i = 0; i < n; i++) {
			cin >> x[i] >> y[i] >> r[i] >> c[i];
		}

		memset(p, 0, sizeof p);
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < i; j++) {
				double d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
				if(d < (r[i] + r[j]) * (r[i] + r[j])) {
					p[i] |= 1 << j;
				}
			}
		}

		memset(dp, -1, sizeof dp);
		cout << f((1 << n) - 1) << endl;
	}
}

Measured memory_bytes: 17624
#include<bits/stdc++.h>
#define int long long 
#define MOD 1000000007
using namespace std;

vector<int> G[100005];
bool vis[100005];
int levelu[100005];
int levelv[100005];

int32_t main()
{
  int n,u,v;
  cin>>n>>u>>v;

  for (int i=0;i<n-1;i++){
    int a,b;cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  queue<pair<int,int>>q;
  q.push({v,0});
  vis[v]=1;

  while(!q.empty()) 
  {
    auto it=q.front();
    q.pop();

    levelv[it.first]=it.second;

    for (auto k:G[it.first]){
      if (!vis[k])
          q.push({k,it.second+1}),vis[k]=1;
    }
  }

  memset(vis,0,sizeof(vis));
  q.push({u,0});
  vis[u]=1;

  while (!q.empty()){
    auto it=q.front();
    q.pop();

    levelu[it.first]=it.second;

    for (auto k:G[it.first]){
      if (!vis[k])
          q.push({k,it.second+1}),vis[k]=1;
    }

  }

  int ans=0;
  for (int i=1;i<=n;i++){
    if (levelu[i]<levelv[i])
        ans=max(ans,levelv[i]-1);
  }

  cout<<ans<<'\n';



}


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

int main(void)
{
  int N;
  cin >> N;
  long long sum = 0;
  for (int i = 1; i <= N; i++)
  {
    if (i % 3 != 0 && i % 5 != 0)
    {
      sum += i;
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int h,w;
    cin>>h>>w;
    vector<string> before(h);
    rep(i,h){
        cin>>before[i];
    }

    rep(i,h){
        cout<<before[i]<<endl;
        cout<<before[i]<<endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define all(x) (x).begin(),(x).end()

#include <bits/stdc++.h>

using namespace std;

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

    vector<int> list(N);
    rep(i, N)cin >> list.at(i);
    sort(all(list));
    double ans = list.at(0);
    for ( int i =1; i< N;i++){
        ans = (ans + list.at(i))/2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)

int main() {
	ll n,ans=0;
	in(n);
	rep(i, 1, n) {
		ans += i;
	}
	outn(ans);
	return 0;

}

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

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

    int ans = 0;
    int a;
    for (int i = 1; i <= N; ++i) {
        std::cin >> a;
        if ((i % 2 != 0) && (a % 2 != 0)) {
            ++ans;
        }
    }   

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3568
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int w,h,T,p,x[55]={},y[55]={},t[55]={},ans=0,a[55][55]={};
  cin >> w >> h >> T >> p;
  for(int i=0; i<p; i++) {
    cin >> x[i] >> y[i] >> t[i];
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> a[i][j];
    }
  }
  int hi[55][55]={};
  for(int i=0; i<p; i++) {
    if(a[y[i]][x[i]]) {
      hi[y[i]][x[i]]++;
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      ans+=hi[i][j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3236
def bs_left(lists, item):
    low, high = 0, len(lists)
    
    while (high >low ) :
        mid = (low + high)//2
        if lists[mid]  < item:
            low = mid +1
            
        else:
            high = mid
            
    return low

def bs_right(lists, item):
    low, high = 0, len(lists)
    
    while (high >low ):
        mid = (low + high)//2
        if lists[mid] > item:
            high = mid 
            
        else:
            low = mid+1
            
    return len(lists) - low
  
n = int(input())
A = [int(x) for x in input().split()]
B =[int(x) for x in input().split()]
C =[int(x) for x in input().split()]

count = 0
A.sort(), B.sort(), C.sort()
for b in B:
    count += (bs_left(A, b) * bs_right(C, b))
    
print(count)


Measured memory_bytes: 29436
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>p(N);
    rep(i,N)cin>>p[i];
    ll ans=0;
    ll flag=0;
    rep(i,N){
        if(p[i]==i+1&& flag==0){
            ans++;
            flag=1;
        }else{
            flag=0;
        }
    }
    cout << ans << endl;


    return 0;
    

}

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

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

    vector<int> H(N+1);
    for (int i = 1; i < N+1; i++) cin >> H[i];

    vector<vector<int>> connect(N+1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        connect[a].push_back(b);
        connect[b].push_back(a);
    }

    int good_hils = 0;
    for (int i = 1; i < N + 1; i++) {
        if (connect[i].size() == 0) {
            good_hils++;
        }
        else {
            bool bad = false;
            for (int j = 0; j < connect[i].size(); j++)
            {
                if (H[i] <= H[connect[i][j]]) bad = true;
            }
            if (!bad) good_hils++;
        }
    }

    cout << good_hils;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int a=0;
  int b=0;
  
  for(int i=0; i<n; i++){
    if(i % 2 == 0){
      a += vec.at(i);
    }else{
      b += vec.at(i);
    }
  }
  cout << a-b << endl;
}

Measured memory_bytes: 3616
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
const ll MOD = 1e9+7;
long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }
  
  ll inv_mul(ll x, ll y){
     return (x % MOD* modpow(y,MOD-2))%MOD;
 }
int main() {
    ll n,k;
    std::cin >> n>>k;
    ll ans = 0;
    ll mod =1e9+7;
    for (ll i = k; i <= n+1 ; i++) {
        ans += inv_mul((n-i+1+n)*i,2)-inv_mul((0+i-1)*i,2)+mod+1;
        ans %= mod;
    }
    std::cout << ans << std::endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n,m,t[1000005],a[1005],b[1005];

ll x,y,ans=1,mod=1e9+7;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
#ifdef LOCAL_DEFINE
	ifstream cin("input.in");
#endif
	
	cin >> n >> m;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		for(int j=1;j<i;j++){
			if(a[i]==a[j]){
				cout << 0;
				return 0;
			}
		}
		t[a[i]]=1;
	}
	for(int i=1;i<=m;i++){
		cin >> b[i];
		for(int j=1;j<i;j++){
			if(b[i]==b[j]){
				cout << 0;
				return 0;
			}
		}
		if(t[b[i]]) t[b[i]]=3;
		else t[b[i]]=2;
	}
	for(int i=n*m;i>=1;i--){
		if(t[i]==3) x++,y++;
		else if(t[i]==2) ans*=x,y++;
		else if(t[i]==1) ans*=y,x++;
		else ans*=(x*y-n*m+i);
		ans%=mod;
		if(ans<0) ans+=mod;
	}
	cout << ans;
#ifdef LOCAL_DEFINE
	cerr << "\nTime elapsed: " << 1.0*clock()/CLOCKS_PER_SEC << " \n";
#endif
}


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

int main(){
int N,D,X;
   cin>>N;
   cin>>D>>X;
  vector<int>A(N);
  for(int i=0; i<N; i++){
   cin>>A[i]; }
  
  vector<int>choco(N);
  int eatchoco=0;
  for(int i=0; i<N; i++){
   for(int j=0; j<D; j++){
    if(A[i]*j+1<=D){choco[i]++;}
   }
   eatchoco+=choco[i];
  }
  
  cout<<eatchoco+X;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string S;
	int K;
	cin >> S >> K;
	int N =S.length();
	vector< vector< vector<int> > > ans(N+1, vector< vector<int> >(N+1, vector<int>(K+1, -OVER9000)));
	ans[0][N][0] =0;
	for(int l =N; l > 0; l--) for(int i =0; i <= N-l; i++) {
		if(l == 1) {
			for(int k =0; k <= K; k++) ans[i][i][k] =max(ans[i][i][k], ans[i][i+1][k]+1);
			for(int k =0; k <= K; k++) ans[i][i+l-1][k] =max(ans[i][i+l-1][k], ans[i][i+l][k]);
			for(int k =0; k <= K; k++) ans[i+1][i+l][k] =max(ans[i+1][i+l][k], ans[i][i+l][k]);
			continue;
		}
		if(S[i] == S[i+l-1]) {
			for(int k =0; k <= K; k++) ans[i+1][i+l-1][k] =max(ans[i+1][i+l-1][k], ans[i][i+l][k]+2);
			continue;
		}
		for(int k =0; k <= K; k++) ans[i][i+l-1][k] =max(ans[i][i+l-1][k], ans[i][i+l][k]);
		for(int k =0; k <= K; k++) ans[i+1][i+l][k] =max(ans[i+1][i+l][k], ans[i][i+l][k]);
		for(int k =0; k < K; k++) ans[i+1][i+l-1][k+1] =max(ans[i+1][i+l-1][k+1], ans[i][i+l][k]+2);
	}
	int ansF =0;
	for(int i =0; i <= K; i++) for(int j =0; j <= N; j++) ansF =max(ansF, ans[j][j][i]);
	cout << ansF << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 110336
A = int(input())
B = int(input())
C = int(input())
X = int(input())
res = 0
for x in range(A+1):
    for y in range(B+1):
        for z in range(C+1):
            if 500 * x + 100 * y + 50 * z == X:
                res += 1
                
print(res)

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

int solve(std::vector<int>& times)
{
  std::sort(times.begin(), times.end(), [](int lhs, int rhs) {
      return (lhs - 1) % 10 > (rhs - 1) % 10;
  });

  int result = 0;
  int n = static_cast<int>(times.size());
  for (int i = 0; i < n; ++i) {
    int t = times[i];
    result += t;
    if ((t % 10) && i < n - 1) result += 10 - t % 10;
  }
  return result;
}

int main()
{
  std::vector<int> times(5);
  for (auto& t : times) {
    std::cin >> t;
  }

  std::cout << solve(times) << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) throws Exception{
		Scanner s = new Scanner( System.in );
		while(s.hasNext()){
		int a = s.nextInt();
		int b = s.nextInt();
		int i,c=a+b;
		for(i = 1; (c/10) != 0; i++)
			c = c / 10;
		System.out.println(i);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int A, B, C;
long long K;
int main() {

	cin >> A >> B >> C;

	cin >> K;

	if (K % 2 == 0) {
		cout << A - B;
	}
	else {
		cout << B - A;
	}
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

N = INT()
a = np.array(LIST())
a = np.bincount(a)
b = a.copy()
b[1:] += a[:-1]
b[:-1] += a[1:]
print(b.max())



Measured memory_bytes: 24328
import bisect
def enum_devisors(n):
    divisors = set([])
    for i in range(1, int(n**.5) + 1):
        if n%i == 0:
            divisors.add(i)
            divisors.add(n//i)
    return divisors

n,m = list(map(int, input().split()))
devisors = sorted(enum_devisors(m))
d = devisors[bisect.bisect_left(devisors, n)]
print(m//d)

Measured memory_bytes: 9376
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<int> ok(N), ng(N);
    for (int i = 0; i < N; i++) {
      int M;
      cin >> M;
      for (int t = 0; t < M; t++) {
        int x, y;
        cin >> x >> y;
        --x;
        if (y) {
          ok[i] |= 1 << x;
        } else {
          ng[i] |= 1 << x;
        }
      }
    }
    int res = 0;
    for (int m = 0; m < (1 << N); m++) {
      bool chk = true;
      int c = 0;
      for (int i = 0; i < N; i++) {
        if (((m >> i) & 1) == 0) continue;
        if ((ok[i] & m) != ok[i]) {
          chk = false;
        }
        if ((ng[i] & m) != 0) {
          chk = false;
        }
        ++c;
      }
      if (chk) chmax(res, c);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int A[2001];
int main() {
	int N,K,Q;
	cin >> N >> K >> Q;
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	int ret=1e9;
	vector<int> vs;
	vector<int> ws;
	for(int i=0;i<N;i++){
		vs.clear();
		ws.clear();
		for(int j=0;j<=N;j++){
			if(A[j]>=A[i]){
				ws.push_back(A[j]);
			}
			else{
				if(ws.size()>=K){
					sort(ws.begin(),ws.end());
					for(int k=0;k<ws.size()-K+1;k++){
						vs.push_back(ws[k]);
					}
				}
				ws.clear();
			}
		}
		if(vs.size()>=Q){
			sort(vs.begin(),vs.end());
			ret=min(ret,vs[Q-1]-vs[0]);
		}
	}
	cout << ret << endl;


	return 0;
}



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

int pos[3];
int main(){
    string x, cad[3];
    cin>>cad[0]>>cad[1]>>cad[2];
    int current=0, aux;
    while(true){
        if(pos[current]==cad[current].length()){
            if(current==0)
                printf("A");
            else if(current==1)
                printf("B");
            else
                printf("C");
            break;
        }
        aux=current;
        current=cad[current][pos[current]]-'a';
        pos[aux]++;
    }
return 0;
}


Measured memory_bytes: 256
open System

let K = int <| Console.ReadLine()

let runrun = 
    let rec f (n: int) (xs: int list) =
        seq {
            match n, xs with
            | 0, xss -> xss 
            | n, [] -> for i in 1..9 do yield! f (n - 1) [i]
            | n, x::xs->
                if x > 0 then  yield! f (n - 1) ((x - 1)::x::xs)
                yield! f (n - 1) (x::x::xs)
                if x < 9 then yield! f (n - 1) ((x + 1)::x::xs)
        }
    let ls2num = List.rev >> List.fold (fun acc x -> acc * 10L + int64 x) 0L
    seq {
        for digits in Seq.initInfinite((+) 1) do 
            yield! f digits [] |> Seq.map ls2num
    }

runrun
|> Seq.item (K-1)
|> printfn "%i"

Measured memory_bytes: 48720
#include "bits/stdc++.h"
using namespace std;

// f(x) = floor(Ax/B) - A floor(x/B)
// = Ax/B - (Ax % B) / B - A (x/B - (x%B)/B) ※ floor(X/Y) = (X-X%Y)/Y = X/Y - (X%Y)/Y を使いました。
// = -(Ax%B)/B + A(x％B)/B ※ ここで、y＝x%B とおくと、y<=min(N,B-1)
// = -((Ay)％B)/B + (Ay)/B ※ Ax%B = A(x%B)%B を使いました。
// = floor(Ay/B) ※ floorの式変形を逆に使いました。

int main(void) {
    long long A, B, N;
    cin >> A >> B >> N;
    cout << static_cast<long long>(A * min(N, B - 1) / B) << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
 
typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "

#define SZ  60
ll mod = 1e9 + 7;
ll no = 2;
 
 
struct matrix{
    ll arr[SZ][SZ];
    void reset(){
        memset(arr , 0 , sizeof(arr));
    }
    void makeiden(){
        reset();
        for(ll i = 0 ; i < no ; ++i){
            arr[i][i] = 1;
        }
    }
    inline matrix operator =(const matrix& o) {
       for(ll i= 0;i < no;i++){
        for(ll j = 0; j < no;j++){ 
          arr[i][j] = o.arr[i][j];
        }
      }
      return *this;
    }
    inline matrix operator * (const matrix &o) const {
        matrix res;
        for(ll i = 0 ; i < no ; ++i){
            for(ll j = 0 ; j < no ; ++j){
                unsigned long long sum = 0;
                for(ll k = 0 ; k < no ; ++k){
                    sum = (sum + 1LL * arr[i][k] * o.arr[k][j]) % (mod);
                }
                res.arr[i][j] = sum;
            }
        }
        return res;
    }
    inline matrix operator ^(ll n) const {
     
      matrix res; res.makeiden();
      matrix cur = *this;
      while (n) {
        if (n & 1) {
          res = res * cur;
        }
        n >>= 1;
        cur = cur * cur;
      }
      return res;
    }
};

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


  ll n, k,i,j;

  cin>>n>>k;
  no = n;
  matrix a;

  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
    {
      cin>>a.arr[i][j];
    
    }
  }

  a=a^k;

  ll ans = 0;

  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
    {
      ans+=a.arr[i][j];
      ans%=mod;
    }
  }

  cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
#define NONE -1
 
int main()
{
 int W,Q,id,w;
 char c;
 int i,cnt;
 vector<int> wall;
 while(cin>>W>>Q,W|Q){
  wall.resize(W);
  fill(wall.begin(),wall.end(),NONE);
  while(Q-->0){
   cin>>c;
   if(c=='w'){
    cin>>id;
    for(i=0;i<W;i++)if(wall[i]==id)wall[i]=NONE;
    continue;
   }
   cin>>id>>w;
   cnt=0;
   for(i=0;i<W;i++){
    if(wall[i]==NONE)cnt++;
    else cnt=0;
    if(cnt==w){
     for(i-=(cnt-1);cnt-->0;)wall[i+cnt]=id;
     cnt=-1;
     break;
    }
   }
   if(cnt==-1)cout<<i<<endl;
   else cout<<"impossible"<<endl;
  }
  cout<<"END"<<endl;
 }
}

Measured memory_bytes: 0
//
// Created by watemus on 08.09.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FF first
#define SS second

using ll = long long;
using ld = long double;

#define int ll

template<typename T>
using vec = std::vector<T>;

template<typename T>
using uset = std::unordered_set<T>;

template<typename T1, typename T2>
using umap = std::unordered_map<T1, T2>;

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
const ld PI = acos(-1);

#ifdef LOCAL
std::mt19937 rnd(228);
#else
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
#endif

vec<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
/*
template<class... Args>
auto Vec(size_t n, Args&&... args) {
  if constexpr(sizeof...(args) == 1)
    return vector(n, args...);
  else
    return vector(n, Vec(args...));
}*/

#ifdef LOCAL
#else
#endif

void run() {
    int n, m, k;
    cin >> n >> m >> k;
    vec<vec<char>> f(n, vec<char>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> f[i][j];
        }
    }
    int ans = 0;
    for (int maski = 0; maski < (1 << n); maski++) {
        for (int maskj = 0; maskj < (1 << m); maskj++) {
            int cr = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (((1 << i) & maski) || ((1 << j) & maskj))
                        continue;
                    cr += f[i][j] == '#';
                }
            }
            if (cr == k)
                ans++;
        }
    }
    cout << ans << '\n';
}

signed main() {
#ifdef LOCAL
  std::freopen("input.txt", "r", stdin);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
#endif
  int t = 1;
  //cin >> t;
  while (t--) {
    run();
  }
  return 0;
}




Measured memory_bytes: 3652