akhauriyash/Code-Regression huggingface dataset:
in_num = int(input())
check_num = 1
ans_counter = 0



while check_num <= in_num:
	i = 1
	div_counter = 0
	while i <= check_num :
		if check_num % i == 0:
			div_counter += 1
		i += 2
	if div_counter == 8:
		ans_counter += 1
	check_num += 2

print(ans_counter)






Measured memory_bytes: 9176
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const llong MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int range_check(int val, int min, int max) {
	if (val < min) {
		return -1;
	}
	if (val > max) {
		return -1;
	}
	return val;
}
class wi{
public:
	int work;
	int f;
	string str;
};
int main() {
	string str;
	int num;
	cin >> str >> num;
	bool is_head = true;
	int work;
	int f;
	char ch;
	REP(i, num) {
		cin >> work;
		if (work == 1) {
			is_head = !is_head;
		}
		else {
			cin >> f >> ch;
			if (is_head) {
				if (f == 1) {
					str.insert(str.begin(), ch);
				}
				else {
					str.push_back(ch);
				}
			}
			else {
				if (f == 1) {
					str.push_back(ch);
				}
				else {
					str.insert(str.begin(),ch);
				}
			}
		}
	}

	if (!is_head) {
		reverse(str.begin(), str.end());
	}
	cout << str << endl;
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+10;
int A[maxn],B[maxn],v[maxn],vv[maxn];
vector<int> lsh,ans;
vector<pii> g[maxn];
bool vis[maxn];
int n,m;
int dfs(int x)
{
	vis[x]=1;
	int cur=vv[x];
	for(int i=0;i<g[x].size();i++)
	{
		int to=g[x][i].first;
		if(vis[to])continue;
		int tr=dfs(to);
		if(tr)ans.push_back(g[x][i].second);
		cur^=tr;
	}
	return cur;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&A[i],&B[i]);
		lsh.push_back(A[i]);
	}
	sort(lsh.begin(),lsh.end());
	lsh.erase(unique(lsh.begin(),lsh.end()),lsh.end());
	for(int i=0;i<n;i++)
	{
		A[i]=lower_bound(lsh.begin(),lsh.end(),A[i])-lsh.begin();
		v[A[i]]=B[i];
	}
	v[n]=0;
	int cur=0;
	for(int i=0;i<=n;i++)
	{
		if(cur^v[i])
		{
			vv[i]=1;
			cur^=1;
		}
	}
	for(int i=0;i<m;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		l=lower_bound(lsh.begin(),lsh.end(),l)-lsh.begin();
		int p=lower_bound(lsh.begin(),lsh.end(),r)-lsh.begin();
		if(!(p<lsh.size()&&lsh[p]==r))p--;
		r=p+1;
		g[l].push_back(make_pair(r,i+1));
		g[r].push_back(make_pair(l,i+1));
	}
	for(int i=0;i<=n;i++)
	{
		if(!vis[i])
		{
			if(dfs(i))
			{
				printf("-1\n");
				return 0;
			}
		}
	}
	
	printf("%d\n",ans.size());
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++)
		printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 16120
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<math.h>
#include <cassert>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAXN 1200
struct node
{
	int l, r;
}a[110000];
bool cmp(node a, node b)
{
	return a.l < b.l;
}
int main()
{
	int n, m,maxs,mins;
	cin >> n >> m;
	maxs = 0; mins = n;
	for (int i = 1; i <= m; i++)
	{
		scanf("%d %d", &a[i].l, &a[i].r);
		mins = min(mins, a[i].r);
		maxs = max(maxs, a[i].l);
	}
	printf("%d", max(0, mins - maxs + 1));
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	string res = "NO";
	for (int i = 1;i <= b;i++) {
		if (i*a%b == c) {
			res = "YES";
			break;
		}
	}
	cout << res <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <tuple>

using namespace std;

int N, Q;
string s;
vector<char> t;
vector<char> d;

int calc(int target) {
    int index = target;
    for (int i = 0; i < Q; i++) {
        char c = s[index];
        if (t[i] == c) {
            if (d[i] == 'L') index--;
            else index++;

            if (index == -1) return index;
            else if (index == N) return index;
        }
    }
    return target;
}

int findL(int l, int r) {
    while (l <= r) {
        int mid = (l+r)/2;
        if (calc(mid) == -1) {
            // if (calc(mid+1) == mid+1) return mid + 1;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    return l;
}

int findR(int l, int r) {
    while (l <= r) {
        int mid = (l+r)/2;
        if (calc(mid) == N) {
            // if (calc(mid-1) == mid-1) return mid - 1;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    return r;
}

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

    for (int i = 0; i < Q; i++) {
        char tt, dd;
        cin >> tt >> dd;
        t.push_back(tt);
        d.push_back(dd);
    }

    if (calc(N-1) == -1 || calc(0) == N) {
        cout << 0 << endl;
        return 0;
    }

    int l = findL(-1, N);
    int r = findR(-1, N);

    // if (l == -1) l = 0;
    // if (r == -1) r = N - 1;

    cout << r - l + 1 << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.IO.Pipes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        //var S = Console.ReadLine();
        //var A = long.Parse(Console.ReadLine());
        //var N = long.Parse(Console.ReadLine());
       var NXT = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N = NXT[0];
        var X = NXT[1];
        var T = NXT[2];
        

        Console.WriteLine((((N-1)/X)+1)*T);
        
    }



}


public class PriorityQueue<T> : IEnumerable<T>
{
    private readonly List<T> _data = new List<T>();
    private readonly IComparer<T> _comparer;
    private readonly bool _isDescending;

    public PriorityQueue(IComparer<T> comparer, bool isDescending = true)
    {
        _comparer = comparer;
        _isDescending = isDescending;
    }

    public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
        : this(Comparer<T>.Create(comparison), isDescending)
    {
    }

    public PriorityQueue(bool isDescending = true)
        : this(Comparer<T>.Default, isDescending)
    {
    }

    public void Enqueue(T item)
    {
        _data.Add(item);
        var childIndex = _data.Count - 1;
        while (childIndex > 0)
        {
            var parentIndex = (childIndex - 1) / 2;
            if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
                break;
            Swap(childIndex, parentIndex);
            childIndex = parentIndex;
        }
    }

    public T Dequeue()
    {
        var lastIndex = _data.Count - 1;
        var firstItem = _data[0];
        _data[0] = _data[lastIndex];
        _data.RemoveAt(lastIndex--);
        var parentIndex = 0;
        while (true)
        {
            var childIndex = parentIndex * 2 + 1;
            if (childIndex > lastIndex)
                break;
            var rightChild = childIndex + 1;
            if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0)
                childIndex = rightChild;
            if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
                break;
            Swap(parentIndex, childIndex);
            parentIndex = childIndex;
        }
        return firstItem;
    }

    public T Peek()
    {
        return _data[0];
    }

    private void Swap(int a, int b)
    {
        var tmp = _data[a];
        _data[a] = _data[b];
        _data[b] = tmp;
    }

    private int Compare(T a, T b)
    {
        return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
    }

    public int Count => _data.Count;

    public IEnumerator<T> GetEnumerator()
    {
        return _data.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}

Measured memory_bytes: 28228
#include <bits/stdc++.h>
using namespace std;
// define
#define endl "\n"
#ifdef LOCAL
#define lout cerr
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET cin.tie(0);ios::sync_with_stdio(false);
// https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) (__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) rep5(i, a, n, d, <)
#define rep5(i, a, n, d, o) for (auto i = decltype(n)(a), _n = (n); i o _n; i += (d))

#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, -1)
#define rrep4(i, a, n, d) rep5(i, (a) - 1, n, d, >=)

#define dump(x) lout << #x << " = " << x << endl;
// alias
typedef long long ll;
typedef long long lint;
typedef pair<int,int> pii;
typedef pair<lint,lint> pll;
// func
template <class C> inline void vcin(C &c);
template <class C,class D> inline void vcin(C &c,D &d);
template <class C> inline void vcout(const C &c,const string separate="\n");
template <class T=int> inline T in();

int n;
const int MAX_S = ((int)1e5)+1;
const lint MOD = (int)1e9 + 7;
char s[MAX_S];
lint dp[MAX_S][13];

void solve()
{
  scanf("%s", s);
  n = strlen(s);

  dp[0][0] = 1;
  rep(i, n)
  {
    int c;
    if (s[i] == '?')
      c = -1;
    else
      c = s[i] - '0';
    rep(j, 10)
    {
      if (c != -1 && c != j)
        continue;
      rep(k, 13)
        dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
    }
    rep(m, 13)
        dp[i + 1][m] %= MOD;
      
  }

  cout << dp[n][5] << endl;
}

signed main(){
  AMULET
  solve();
  return 0;
}

template <class C>inline void vcin(C &c){for(auto &a:c){cin>>a;}}
template <class C,class D> inline void vcin(C &c,D &d){for(auto it1=c.begin(),it2=d.begin();it1!=c.end()&&it2!=d.end();it1++,it2++){cin>>*it1>>*it2;}}
template <class C> inline void vcout(const C &c,const string separate){for(auto it=c.begin();it!=c.end();it++){if(it!=c.begin())cout<<separate;cout<<*it;}}
template <class T=int> inline T in(){T x;cin>>x;return (x);}


Measured memory_bytes: 10496
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a = number.nextInt();
		int b = number.nextInt();
		int c = number.nextInt();
		if(a < b && b < c) System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 26188
n,k=map(int,input().split())
a=list(map(int,input().split()))
if n==k:
    print(1)
else:
    ans=0
    cnt=k
    for i in range(2,n):
        cnt+=(k-1)
        if cnt>=n:
            ans=i
            break
    print(ans)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF=1e16;
const int Ah=1e15;

signed main() {
  int N,M,S,T;cin>>N>>M>>S>>T;S--;T--;
  typedef pair<int,int> P;
  std::vector<P> en[N],su[N];
  for(int i=0;i<M;i++){
    int a,b,c,d;cin>>a>>b>>c>>d;a--;b--;
    en[a].push_back(P(b,c));
    en[b].push_back(P(a,c));
    su[a].push_back(P(b,d));
    su[b].push_back(P(a,d));
  }
  std::vector<int> de(N,INF),ds(N,INF);
  de[S]=0;ds[T]=0;
  priority_queue<P,vector<P>,greater<P>> que;
  que.push(P(0,S));
  while(que.size()){
    P p=que.top();que.pop();
    if(de[p.second]<p.first)continue;
    for(int i=0;i<en[p.second].size();i++){
      if(de[p.second]+en[p.second][i].second<de[en[p.second][i].first]){
        de[en[p.second][i].first]=de[p.second]+en[p.second][i].second;
        que.push(P(de[en[p.second][i].first],en[p.second][i].first));
      }
    }
  }
  que.push(P(0,T));
  while(que.size()){
    P p=que.top();que.pop();
    if(ds[p.second]<p.first)continue;
    for(int i=0;i<su[p.second].size();i++){
      if(ds[p.second]+su[p.second][i].second<ds[su[p.second][i].first]){
        ds[su[p.second][i].first]=ds[p.second]+su[p.second][i].second;
        que.push(P(ds[su[p.second][i].first],su[p.second][i].first));
      }
    }
  }
  std::vector<int> v(N);
  for(int i=0;i<N;i++)v[i]=de[i]+ds[i];
  std::vector<int> ans(N);
  ans[N-1]=v[N-1];
  for(int i=N-2;i>=0;i--)ans[i]=min(ans[i+1],v[i]);
  for(int i=0;i<N;i++)cout<<Ah-ans[i]<<endl;
}


Measured memory_bytes: 20344
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200000+10;
int n,a[N],sum,f[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		f[i]=a[i];
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		if(f[i]==a[n])printf("%d\n",a[n-1]);
		else printf("%d\n",a[n]);
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);	
	int n;
	string s;
	cin>>n>>s;
	if(s.length() > n){
		cout<<s.substr(0,n)<<"...";
	}else{
		cout<<s;
	}
	
	
	
	
	return 0;
}



Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    int day,a,b,c,d;
    cin >>day>>a>>b>>c>>d;
    if(a%c!=0){
        a=1+(a/c);
    }
    else a/=c;
    if(b%d!=0){
        b=1+(b/d);
    }
    else b/=d;
    if(a>b)day-=a;
    else day-=b;
    cout <<day<<endl;

    return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = a-b;
        
        if (d > c) {
            System.out.println("0");
        } else {
            System.out.println(c-d);
        }
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
int dp[100005];
bool visited[100005];
vector<int> edge[100005]; 

void visit(int vertex)
{
	if(!visited[vertex])
	{
		visited[vertex] = 1;
		dp[vertex] = 0;
		for(int child : edge[vertex] )
		{
			if(!visited[child] ) visit(child);
			dp[vertex] = max(dp[vertex], 1+dp[child]);
		}
	}	
	return;
}

int main()
{
	int m,n,x,y,mx = -1;
	cin>>n>>m;
	
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		edge[x].push_back(y);
	}
	
	for(int i=1;i<=n;i++)
	{
		if(!visited[i]) 
		{
			visit(i);
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		mx = max(mx,dp[i]);
	}
	cout<<mx<<endl;
	
	return 0;
}


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

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

char a[51][51];
char b[51][51];
int main(void)
{
	int N, M;
	cin >> N >> M;
	Rep(n, N) cin >> a[n];
	Rep(m, M) cin >> b[m];

	Rep(h, N - M + 1){
		Rep(w, N - M + 1){
			bool f = true;
			Rep(y, M){
				Rep(x, M){
					if(a[y + h][x + w] != b[y][x]){
						f = false;
						break;
					}
				}
			}
			if(f){
				PrintLn("Yes");
				return 0;
			}
		}
	}
	PrintLn("No");

	return 0;
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 555;

int main () {
    int n;
    cin >> n;
    set < int > me;
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d" , &x);
        me.insert(x);
    }
    printf("%d\n" , (int)me.size());
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, W; cin >> N >> W;
    int value[N];
    int weight[N];
    REP(n, N) {
        cin >> value[n];
        cin >> weight[n];
    } 

    int dp[101][10002] = {{}};

    REP(n, N) {
        REP(w, W + 1) {
            weight[n] > w ? dp[n + 1][w] = dp[n][w] : dp[n+1][w] = max(dp[n][w], dp[n][w - weight[n]] + value[n]); 
        } 
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 7120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		double[] c = new double[8];
		StringTokenizer st;

		while ((line = br.readLine()) != null) {
			if (line.contains(" ")) {
				st = new StringTokenizer(line);
				for (int i = 0; i < 8; i++) {
					c[i] = Double.parseDouble(st.nextToken());
				}
				if (c[0] == c[2] && c[5] == c[7]) {
					// 直交
					System.out.println("NO");
				} else if (c[1] == c[3] && c[4] == c[6]) {
					// 直交
					System.out.println("NO");
				} else if ((c[0] - c[2]) * (c[1] - c[3]) == (c[4] - c[6])
						* (c[5] - c[7])) {
					System.out.println("YES");
				} else {
					System.out.println("NO");
				}

			}
		}
	}
}

Measured memory_bytes: 16916
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2*acos(0))
#define cross(a, b) ((conj(a)*b).Y)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> point;
typedef pair<point, point> segment;
typedef tuple<ll, ll, ll> line;
const int N = 1e5 + 105, M = 100 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 9;

int n, arr[N], memo[N], k;
int solve(int i = 0)
{
	if(i == n - 1)
		return 0;
	if(i >= n)
		return OO;
	int &ret  = memo[i];
	if(~ret)
		return ret;
	ret = OO;
	for(int j = 1 ; j <= k ; j++)
		ret = min(ret, solve(i + j) + abs(arr[i + j] - arr[i]));
	return ret;
}
int main()
{
	MuhammedAly
	mem(memo, -1);
	cin >> n >> k;
	for(int i = 0 ; i < n ; i++)
		cin >> arr[i];
	cout << solve();
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define f first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
 
 
using namespace std;
 
const int N = 1e6 + 123;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const int M = 210;


ll L, pw[40], mx[N], edg = 0;
vector <pll> g[M];


void rec(ll beg, ll x) {
//	cout << x << " " << mx[x] + 2 << " " << beg << "\n";
	if (x == 0) {
		g[1].pb({20, beg});
//		cout << 1 << " " << 20 << " " << beg << "\n";
		edg++;
		return;
	}
	g[mx[x] + 2].pb({20, beg});
	if (mx[x] + 2 != 20)
		edg++; 
//	cout << mx[x] + 2 << " " << 20 << " " << beg << "\n";
//	cout << pw[mx[x] + 1] - 1 << "\n";
	if (pw[mx[x] + 1] - 1 == x)
		return;
	rec(beg + pw[mx[x] + 1], x - pw[mx[x] + 1]);
}


int main() {
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
//	freopen("input.txt", "r", stdin);
//	if (L == 0) {
//		cout << "2 1\n" << "1 2 0";
//		return 0; 
//	}
	ll t = 1;
	for (ll i = 0; i <= 33; i++) {
		pw[i] = t;
		t *= 2;
	}
//	cout << pw[19] - 1 << "\n";
	cin >> L;
	L--;
	mx[0] = 0;
	mx[1] = 0;
	for (ll i = 2; i <= 1000000; i++) {
		if (pw[mx[i - 1] + 2] <= i + 1)
			mx[i] = mx[i - 1] + 1;
		else
			mx[i] = mx[i - 1];
	}
	ll brd = pw[19] - 1;
	for (int i = 1; i <= 18; i++) {
		g[i].pb({i + 1, pw[i - 1]});
		g[i].pb({i + 1, 0});
		edg+=2;
	}
	if (L >= brd) {
		g[19].pb({20, pw[18]});
		g[19].pb({20, 0});
		edg+=2;
	}
	rec(0, L);
	cout << 20 << " " << edg << "\n";
	for (int i = 1; i <= 20; i++)
		for (pll to : g[i])
			if (to.f != i)
				cout << i << " " << to.f << " " << to.se << "\n";
	return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    //const i64 mod = 1'000'000'007;
    string s,t;
    cin >> s >> t;

    vector<vector<tuple<i64,i64,i64>>> memo(s.size()+1,vector<tuple<i64,i64,i64>>(vector<tuple<i64,i64,i64>>(t.size()+1,make_tuple(0,-1,-1))));
    vector<vector<bool>> done(s.size()+1,vector<bool>(t.size()+1));
    function<tuple<i64,i64,i64>(i64,i64)> rec=[&](i64 i,i64 j){
        if(done[i][j]) return memo[i][j];
        done[i][j]=true;
        if(i==s.size() or j==t.size()){
            return memo[i][j]=make_tuple<i64,i64,i64>(0,-1,-1);
        }
        i64 l=0;
        if(s[i]==t[j]){
            memo[i][j]=make_tuple(1,-1,-1);
            i64 nl,ni,nj;
            tie(nl,ni,nj)=rec(i+1,j+1);
            if(chmax(get<0>(memo[i][j]),nl+1)){
                get<1>(memo[i][j])=i+1;
                get<2>(memo[i][j])=j+1;
            }
        }else{
            if(chmax(get<0>(memo[i][j]),get<0>(rec(i+1,j)))){
                get<1>(memo[i][j])=i+1;
                get<2>(memo[i][j])=j;
            }
            if(chmax(get<0>(memo[i][j]),get<0>(rec(i,j+1)))){
                get<1>(memo[i][j])=i;
                get<2>(memo[i][j])=j+1;
            }
        }
        return memo[i][j];
    };

    string ans;
    if(s[0]==t[0]) ans+=s[0];
    i64 l,i,j;
    tie(l,i,j)=rec(0,0);
    while(l>0 and i>=0 and j>=0){
        if(s[i]==t[j]) ans+=s[i];
        tie(l,i,j)=rec(i,j);
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 213632
//
// Created by Hideaki Imamura on 2020-03-13.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
vector<int> L;

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int l;
        cin >> l;
        L.push_back(l);
    }

    sort(L.begin(), L.end());

    ll ans = 0;
    for (int i = N - 1; i >= 2; --i) {
        for (int j = i - 1; j >= 1; --j) {
            int x = lower_bound(L.begin(), L.end(), L[i] - L[j] + 1) - L.begin();
            //cout << j << ": " << j - x << endl;
            ans += max(j - x, 0);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;

#define rep(i,n) for(ll (i)=0;(i)<(n);++i)

#define rep1(i,n) for(ll (i)=1;(i)<=(n);++i)

#define rrep(i,n) for(ll (i)=(n)-1;(i)>=(0);--i)

#define rrep1(i,n) for(ll (i)=(n);(i)>=(1);--i)

#define pb push_back

#define fr first

#define sc second

ll N;
bool ps[100001];
vector<ll> p;
vector<P> fs;

ll ans;

ll res;

ll calc(ll a){
	ll cnt1=0;
	while(a){
		cnt1++;
		a/=10;
	}
	return cnt1;
}

ll rec(ll x,ll id){
	if(id==fs.size()){
		return max(calc(x),calc(N/x));
	}
	ll res=rec(x,id+1);
	rep(i,fs[id].sc){
		x*=fs[id].fr;
		res=min(res,rec(x,id+1));
	}
	return res;
}



int main()

{
	rep1(i,100000) ps[i]=1;
	ps[0]=ps[1]=0;
	rep1(i,100000){
		if(ps[i]){
			p.pb(i);
			for(ll j=2*i;j<=100000;j+=i) ps[j]=0;
		}
	}

	cin>>N;
	ll n=N;
	rep(i,p.size()){
		if(n==1) break;
		ll cnt=0;
		while(n%p[i]==0){
			cnt++;
			n/=p[i];
		}
		if(cnt){
			fs.pb(P(p[i],cnt));
		}
	}
	if(n!=1){
		fs.pb(P(n,1));
	}
	ll ans=0xfffffff;
	cout<<rec(1,0)<<endl;
}

Measured memory_bytes: 512
n=gets.to_i
t=gets.split.map(&:to_i)
m=gets.to_i
p=Array.new(m)
x=Array.new(m)
m.times do |i|
    p[i],x[i]=gets.split.map(&:to_i)
end

sum=t.sum
m.times do |i|
    puts sum-t[p[i]-1]+x[i]
end


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input_0 = GetLongNumArray();
            var sunuke = new List<long>();

            for (int i = 0; i < input_0[0]; i++)
            {
                sunuke.Add(i + 1);
            }

            for (int i = 0; i < input_0[1]; i++)
            {
                var input_1 = GetLongNum();
                var input_2 = GetLongNumArray();

                foreach (var item in input_2)
                {
                    sunuke.Remove(item);
                }
            }

            Console.WriteLine(sunuke.Count);
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 28652
fun main(args:Array<String>):Unit {
    val n = readLine()!!.trim().toInt()
    var current = readLine()!!.trim().toInt()
    var max = current
    repeat(n){
        val (i, o) = readLine()!!.trim().split(' ').map(String::toInt)
        current += i - o
        if (current < 0) max = -1
        else if (max in 0 until current) max = current
    }
    println(if (max >= 0) max else 0)
}


Measured memory_bytes: 39684
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nq = Input.ar;
        var str = ReadLine();
        var dp = new long[nq[0] + 1];
        for(var i = 2; i <= str.Length; i++)
        {
            if (str.Substring(i - 2, 2)=="AC")
                dp[i] = dp[i - 2] + 1;
            else dp[i] = dp[i - 1];
        }
        var res = new long[nq[1]];
        for(var i = 0; i < nq[1]; i++)
        {
            var lr = Input.ar;
            res[i] = dp[lr[1]] - dp[lr[0]];
        }
        WriteLine(string.Join("\n", res));
        /*var str = ReadLine();
        var acgt = "ACGT";
        var res = 0;
        for (var i = 0; i < str.Length; i++)
        {
            var ct = 0;
            for (var j = i; j < str.Length; j++)
                if (acgt.Contains(str[j])) ct++;
                else
                {
                    res = Max(ct, res);
                    ct = 0;
                }
        }
        WriteLine(res);*/
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public static Tuple<int, int, long> MakeEdge(int num1, int num2, long weight)
        => new Tuple<int, int, long>(num1, num2, weight);
    public const long Inf = (long)1e18;
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 21184
<?php
$n = trim(fgets(STDIN));
list($a,$b) = explode(" ",trim(fgets(STDIN)));
$p = explode(" ",trim(fgets(STDIN)));
$A = 0;
$B = 0;
$C = 0;

foreach($p as $value){
	if($value<=$a){
      ++$A;
    }elseif($value<=$b){
      ++$B;
    }else{
      ++$C;
    }
}
$ans = 0;
$i = 1;

while(true){
if($A>=$i and $B>=$i and $C>=$i){
++$ans;
++$i;
}else{

echo $ans;
exit;
}
}

      

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


int main() {
  int N, K, num = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++){
	if (num * 2 >= num + K) num += K;
    else num *= 2;
  }
 
  cout << num << endl;
}

Measured memory_bytes: 3620
n, k, q = map(int, input().split())
a = list(map(int, input().split()))

ans = 10 ** 10
for y in a:
    li = []
    l = 0
    cnd = []
    l_cnd = 0
    for x in a + [-1]:
        if x < y:
            if l - k + 1 >= 0:
                li.sort()
                cnd += li[:l-k+1]
                l_cnd += l - k + 1
            li = []
            l = 0
        else:
            li.append(x)
            l += 1

    if l_cnd >= q:
        cnd.sort()
        sub = cnd[q-1] - y
        ans = min(ans, sub)

print(ans)


Measured memory_bytes: 3316
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int C=stdIn.nextInt();
		if(A<=C&&C<=B)
			System.out.println("Yes");
		else
			if(B<=C&&C<=A)
				System.out.println("Yes");
			else
				System.out.println("No");
	}
}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T1, typename T2>
inline auto mini(T1 a, T2 b) { return (a < b ? a : b); }
template<typename T, typename... Args>
inline auto mini(T a, Args... args) { return mini(a, mini(args...)); }
template <typename T1, typename T2>
inline auto maxi(T1 a, T2 b) { return (a > b ? a : b); }
template<typename T, typename... Args>
inline auto maxi(T a, Args... args) { return maxi(a, maxi(args...)); }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // use mt19937_64 for 64 bit

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    char ch;
    cin >> ch;
    if(ch - 'a' >=0 and ch - 'a' < 26) {
        cout << 'a';
    }
    else {
        cout << 'A';
    }
    return 0;
}



Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) {
  return a < b ? a : b;
}

int main() {
  int elaps = 0;
  int c, q;
  P u;
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    // printf("ENQ %s %d\n", Q[i].name, Q[i].t);
  }
  head = 0;
  tail = n;

  while (head != tail) {
    u = dequeue();
    // printf("DEQ %s %d\n", u.name, u.t);
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0)
      enqueue(u);
    else
      printf("%s %d\n", u.name, elaps);
  }
}

Measured memory_bytes: 12748
#include <stdio.h>

int horie_yui(int isikawa_kaito) {
	if (isikawa_kaito % 3 == 0) return 1;
	do {
		if (isikawa_kaito % 10 == 3) return 1;
	} while ((isikawa_kaito /= 10));
	return 0;
}

int main(void) {
	int n, i = 1;
	if (scanf("%d", &n) != 1) return 1;
	do {
		if (horie_yui(i)) printf(" %d", i);
	} while (++i <= n);
	putchar('\n');
	return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 10e9
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll int, ll int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

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

int N;
int a[210000];

int main () {
  cin >> N;
  Rep(i, N) cin >> a[i];

  int max1 = 0;
  int max1_index = 0;
  int max2 = 0;
  int max2_index = 0;

  Rep(i, N) {
    int tmp = a[i];

    if (tmp > max1) {
      max2 = max1;
      max2_index = max1_index;
      max1 = tmp;
      max1_index = i;
    } else if (tmp > max2) {
      max2 = tmp;
      max2_index = i;
    }
  }

  Rep(i, N) {
    if (i == max1_index) {
      cout << a[max2_index] << "\n";
    } else {
      cout << a[max1_index] << "\n";
    }
  }
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    ll n;
    cin >> n;

    ll ans = 1;
    ll tmp = 1;
    while(n > 1){
        tmp *= 2;
        ans += tmp;
        n /= 2;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin>>n;
  
  int x;
  int min=1000000010;
  int cnt=0;
  rep(i,n){
    cin>>x;
    if(x<min){
      min=x;
      cnt++;
    }
  }
  
  cout<<cnt<<endl;
  
  return 0;
}

Measured memory_bytes: 256
N = str(input().strip())

def sss(index, is3, is5, is7, TOP, zz=False):
    counter = 0
    if index == len(N):
        if is3 and is5 and is7:
            return 1
        return 0
    if zz:
        counter += sss(index+1, False, False, False, False, True)
    if TOP:
        if int(N[index]) >= 3:
            counter += sss(index+1, True, is5, is7, int(N[index]) == 3)
        if int(N[index]) >= 5:
            counter += sss(index+1, is3, True, is7, int(N[index]) == 5)
        if int(N[index]) >= 7:
            counter += sss(index+1, is3, is5, True, int(N[index]) == 7)
    else:
        counter += sss(index+1, True, is5, is7, False)
        counter += sss(index+1, is3, True, is7, False)
        counter += sss(index+1, is3, is5, True, False)
    return counter

print(sss(0, False, False, False, True, True))


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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity() ? std::numeric_limits<T>::infinty() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int q, m; cin >> q >> m;
	int n = 1;
	vector<vll> g(n + 2, vll(m + 2));
	while (q--) {
		int lx = 0, ly, rx = 1, ry; cin >> ly >> ry;
		lx++, ly++;
		g[lx][ly]++;
		g[lx][ry + 1]--;
		g[rx + 1][ly]--;
		g[rx + 1][ry + 1]++;
	}
	ll ans = -BINF;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			g[i][j] += g[i][j - 1];
			g[i][j] += g[i - 1][j];
			g[i][j] -= g[i - 1][j - 1];
			ans = max(ans, g[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

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

// vim: fdm=marker



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

int main(){
    
    int N,K;
    cin>>N>>K;
    vector<int> S(N),T(N+1,0);
    vector<pair<int,int>> M(N);
    for(int i=0;i<N;i++){
        M[i].first=0;
        M[i].second=i;
    }
    for(int i=0;i<N;i++){
        cin>>S[i];
        if(i==0) T[1]=S[0];
        else T[i+1]=T[i]+S[i];
        if(S[i]<0) M[i].first=S[i];
    }
    int ans=0;
    for(int i=0;i<=min(N,K);i++){
        for(int j=0;j<=min(N-i,K-i);j++){
            int sum=0;
            sum+=T[i];
            sum+=(T[N]-T[N-j]);
            int r=K-i-j;
            if(r>0){
                vector<int> A;
                for(int x=0;x<i;x++){
                    if(S[x]<0) A.push_back(S[x]);
                }
                for(int y=N-1;y>N-1-j;y--){
                    if(S[y]<0) A.push_back(S[y]);
                }
                sort(A.begin(),A.end());
                int e=A.size();
                for(int z=0;z<min(e,r);z++){
                    sum-=A[z];
                }
            }
            ans=max(sum,ans);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 1000000100;

ll N;
ll a[300010], cnt[70];
ll bit[70];

ll ans;

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

ll sum_bit(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add_bit(ll i, ll x)
{
	while (i <= 2 * N + 10)
	{
		bit[i] += x;
		i += i & -i;
	}
}

void init()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	bit[0] = 1;
	for (int i = 1; i < 60; i++)
	{
		bit[i] = bit[i - 1] * 2;
	}
}

void output()
{
	cout << ans << endl;
}



void solve()
{
	for (ll i = 0; i < 60; i++)
	{
		for (ll j = 0; j < N; j++)
		{
			if ((a[j] & bit[i]) > 0)
			{
				cnt[i]++;
			}
		}
	}
	
	for (ll i = 0; i < 60; i++)
	{
		(ans += pow_mod(2, i) * cnt[i] % mod * (N - cnt[i]) % mod) %= mod;
	}
}

int main()
{
	init();

	solve();

	

	output();

	cin >> N;
}

Measured memory_bytes: 2560
package main

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

func main() {
	N := nextInt64()

	if N%2 == 1 {
		fmt.Println(0)
		return
	}
	a5 := int64(0)
	n5 := int64(10)

	// 5の指数と対応
	// 10の倍数 + 50の倍数 + 250の倍数 + 1250の倍数 + ...
	for n5 <= N && n5 > 0 {
		a5 += N / n5
		n5 *= 5
	}

	a2 := int64(0)
	n2 := int64(2)

	for n2 <= N && n2 > 0 {
		a2 += N / n2
		n2 *= 2
	}

	fmt.Println(min(a5, a2))
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;

using namespace std;

int main()
{
    char a[3];
    int ans = 0;
    cin >> a;
    REP(i, 3) {
        if (a[i] == '1')ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        mut n: i64,
    }
    let mut v = vec![];

    for i in 2.. {
        if i * i > n {
            break;
        }
        if n % i != 0 {
            continue;
        }
        let mut ex = 0u64;
        while n % i == 0 {
            ex += 1;
            n /= i;
        }

        //iも
        v.push((i, ex));
    }
    if n != 1 {
        v.push((n, 1));
    }

    //println!("{:?}", v);
    let mut ans = 0u64;

    for i in 0..v.len() {
        for j in 1.. {
            if v[i].1 < j {
                break;
            }
            v[i].1 -= j;
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2140
#include<stdio.h>
int main(){
        int H,W,i,j;
        
        scanf("%d %d",&H,&W);
        
        while(1){
        	if(H==0 && W==0){
        	   break;
        	}
        	for(i=1;i<=H;i++){
        		if(i%2==1){
        			for(j=1;j<=W;j++){
        				if(j%2==1){
        					printf("#");
        		        }
        			else  {
        				printf(".");
        			}
        		}
        				printf("\n");
        	}
        	else {
        		for(j=1;j<=W;j++){
        			if(j%2==1){
        			 printf(".");
        		    }
        			else  {
        			 printf("#");
        			}
        		}
        		printf("\n");
        	}
        }
          printf("\n");
          scanf("%d %d",&H,&W);
        }
        return 0;
}


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

div_1,div_2,div_4=0,0,0
for a in A:
    if a%4==0:
        div_4+=1
    elif a%2==0:
        div_2+=1
    elif a%2!=0:
        div_1+=1
if div_2==0 and div_1<=div_4+1:
    print('Yes')
elif div_2>0 and div_1<=div_4:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
s = input()
x, y = map(int, input().split())
dpx = set()
dpy = set()
xli = []
yli = []
tmp = 0
d = 0
tcnt = 0
xc = 0
yc = 0

for i in range(len(s)):
    if s[i] == "F":
        if tcnt % 2 == 0:
            xc += 1
        else:
            yc += 1
    else:
        if tcnt % 2 == 0:
            if xc != 0:
                xli.append(xc)
                xc = 0
        else:
            if yc != 0:
                yli.append(yc)
                yc = 0
        tcnt += 1
if tcnt % 2 == 0:
    xli.append(xc)
    xc = 0
else:
    yli.append(yc)
    yc = 0
    
    

if s[0] == 'F':
    dpx.add(xli[0])
    xli = xli[1:]
else:
    dpx.add(0)
dpy.add(0)
for a in xli:
    tmp = set()
    for dx in dpx:
        tmp.add(dx + a)
        tmp.add(dx - a)
    dpx = tmp
for a in yli:
    tmp = set()
    for dy in dpy:
        tmp.add(dy + a)
        tmp.add(dy - a)
    dpy = tmp

# print(dpx,dpy)
if x in dpx and y in dpy:
    print("Yes")
else:
    print("No")

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;cin >> n;
    string s, t;
    cin >> s >> t;
    string ans= "";
    rep(i,n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
using P = pair<ll,ll>;

P f( ll x ){
  ll head,tail;
  tail = x%10;
  while( x ){
    head = x;
    x /= 10;
  }
  return make_pair(head,tail);
}

int main(){
  ll n;cin >> n;
  map<P,ll> m;
  for(ll i=1;i<=n;++i){
    if( i%10 == 0 ) continue;
    P p = f(i);
    m[p]++;
  }
  ll ans = 0;
  for(auto mp : m ){
    if( mp.second == 0 ) continue;
    P p = mp.first;
    P rp = make_pair(p.second,p.first);
    ans += m[rp]*m[p];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652