akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Random;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EWhoSaysAPun solver = new EWhoSaysAPun();
        solver.solve(1, in, out);
        out.close();
    }

    static class EWhoSaysAPun {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            String s = in.next();
            int maxLen = 0;

            RollingHash rh = new RollingHash(s);

            for (int i = 0; i < s.length(); i++) {
                for (int j = i; j < s.length(); j++) {
                    while (maxLen < j - i && j + maxLen < n
                            && rh.slice(i, maxLen + 1) == rh.slice(j, maxLen + 1)) {
                        maxLen++;
                    }
                }
            }
            out.println(maxLen);

        }

    }

    static class RollingHash {
        private static final int MAX_LENGTH = 500000;
        private final static long MASK30 = (1L << 30) - 1;
        private final static long MASK31 = (1L << 31) - 1;
        private final static long MOD = (1L << 61) - 1;
        private final static long POSITIVER = MOD * 3;
        private static int Base;
        private static long[] pow = new long[MAX_LENGTH + 1];
        public long[] hash;

        static {
            Base = new Random().nextInt((int) 1e9) + 129;
            pow[0] = 1;
            for (int i = 1; i < pow.length; i++) {
                pow[i] = calc(mul(pow[i - 1], Base));
            }
        }

        public RollingHash(String s) {
            hash = new long[s.length() + 1];
            for (int i = 0; i < s.length(); i++) {
                hash[i + 1] = calc(mul(hash[i], Base) + s.charAt(i));
            }
        }

        public long slice(int begin, int length) {
            return calc(hash[begin + length] + POSITIVER - mul(hash[begin], pow[length]));
        }

        private static long mul(long l, long r) {
            long lu = l >> 31;
            long ld = l & MASK31;
            long rd = r & MASK31;
            long ru = r >> 31;
            long mid = ld * ru + lu * rd;
            return ((lu * ru) << 1) + ld * rd + ((mid & MASK30) << 31) + (mid >> 30);
        }

        private static long calc(long v) {
            v = (v & MOD) + (v >> 61);
            if (v >= MOD) v -= MOD;
            return v;
        }

    }
}



Measured memory_bytes: 28348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

const int MAX_V = 3*(1<<15);

struct segment_tree{
    //[1,2^16)がoff,[2^16,2^16+2^15)がonの状態
    bool used[MAX_V];
    int topo[MAX_V];
    vector<int> Es[MAX_V], Rs[MAX_V], Vs;
    segment_tree(){
        rep2(i, 1, (1<<15)-1){
            Es[i].pb(i*2), Es[i].pb(i*2+1);
            Rs[i*2].pb(i), Rs[i*2+1].pb(i);
        }
    }
    void add_edge(int u, int v){
        Es[u].pb(v), Rs[v].pb(u);
    }
    void dfs(int now){
        used[now] = true;
        for(auto &e: Es[now]) if(!used[e]) dfs(e);
        Vs.pb(now);
    }
    void rdfs(int now, int k){
        used[now] = true;
        topo[now] = k;
        for(auto &e: Rs[now]) if(!used[e]) rdfs(e, k);
    }
    void scc(){
        fill(used, used + MAX_V, false);
        rep(i, MAX_V) if(!used[i]) dfs(i);
        fill(used, used + MAX_V, false);
        int k = 0;
        rep3(i, Vs.size()-1, 0){
            if(!used[Vs[i]]) rdfs(Vs[i], k++);
        }
    }
    //stから[a,b)に辺を張る
    void query(int a, int b, int st, int k = 1, int l = 0, int r = 1<<15){
        if(a >= r || b <= l) return;
        elif(a <= l && b >= r) Es[st].pb(k), Rs[k].pb(st);
        else{
            query(a, b, st, 2*k, l, (l+r)/2);
            query(a, b, st, 2*k+1, (l+r)/2, r);
        }
    }
};

int main(){
    int N;
    cin >> N;
    pii p[2*N];
    rep(i, N){
        int x, y;
        cin >> x >> y;
        p[i] = pii(x, i), p[N+i] = pii(y, N+i);
    }
    sort(p, p+2*N);
    map<int, int> mp;
    rep(i, 2*N) mp[p[i].second] = i;
    int l = 0, r = 1e9;
    while(r-l > 1){
        int n = (l+r)/2;
        segment_tree seg;
        rep(i, N){
            seg.add_edge((1<<15)+mp[i], (1<<16)+mp[N+i]);
            seg.add_edge((1<<15)+mp[N+i], (1<<16)+mp[i]);
        }
        int now = 0;
        rep(i, 2*N){
            while(now < 2*N && p[now].first-p[i].first < n) now++;
            seg.query(i+1, now, (1<<16)+i); 
        }
        now = 2*N-1;
        rep3(i, 2*N-1, 0){
            while(now >= 0 && p[i].first-p[now].first < n) now--;
            seg.query(now+1, i, (1<<16)+i);
        }
        seg.scc();
        bool able = true;
        rep(i, N){
            if(seg.topo[(1<<16)+mp[i]] == seg.topo[(1<<16)+mp[N+i]]) able = false;
        }
        if(able) l = n;
        else r = n;
    }
    cout << l << endl;
}

Measured memory_bytes: 21316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using T = tuple<string,int,int>;

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  int ans = a[0] + a[1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,i;
    scanf("%d",&n);
    int a[n+1];
    for(i=1;i<n+1;i++)scanf("%d",&a[i]);

    for(i=1;i<n+1;i++){
        printf("node %d: key = %d, ",i,a[i]);
        if(i!=1)printf("parent key = %d, ",a[i/2]);
        if(2*i<=n)printf("left key = %d, ",a[2*i]);
        if(2*i+1<=n)printf("right key = %d, ",a[2*i+1]);
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2108
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];;

    vector<ll> rb = b;

    reverse(all(rb));

    vector<ll> same;

    rep(i, n){
        if(a[i] == rb[i]){
            same.push_back(i);
        }
    }

    //cout << same.size() << endl;

    vector<ll> ans = rb;
    ll bidx = n - 1;
    ll tmpidx = -1;
    rep(i, same.size()){
        if(ans[same[i]] == a[bidx] || ans[same[i]] == ans[bidx]){
            tmpidx = i - 1;
            break;
        }
        swap(ans[same[i]], ans[bidx]);
        bidx--;
        if(i == same.size() - 1){
            tmpidx = i;
        }
    }
    ll fidx = 0;
    for(ll i = (ll)same.size() - 1; i > tmpidx; i--){
        swap(ans[same[i]], ans[fidx]);
        fidx++;
    }
    bool ok = true;
    rep(i, n){
        if(ans[i] == a[i]) ok = false;
    }

    if(ok){
        cout << "Yes" << endl;
        rep(i, n) cout << ans[i] << " ";
        cout << endl;
    } else {
        cout << "No" << endl;
    }

}



Measured memory_bytes: 11016
#include <stdio.h>

int main()
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
		printf("Possible");
	else
		printf("Impossible");
	return 0;
}

Measured memory_bytes: 128
while 1:	
	n, m, p = map(int, raw_input().split(" "))
	if (n,m,p) == (0,0,0):
		break
	x = [0]
	x[1:] = [int(raw_input()) for i in range(n)]
	if x[m] == 0:
		print 0
	else :
		print sum(x) * (100 - p) / x[m]

Measured memory_bytes: 4212
#include <cstdio>

using namespace std;

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b) {
        printf("a < b\n");
    }
    if (a > b) {
        printf("a > b\n");
    }
    if (a == b) {
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2588
/*H - Grid 1*/

#include <bits/stdc++.h>

using namespace std;

using Long = long long;
const Long mod = Long(1e9) + 7;

Long memo[1001][1001];

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int h, w;
	cin >> h >> w;

	vector < vector <char> > mat(h, vector <char> (w));

	memset(memo, 0, sizeof memo);

	for (int i = 0; i < h ; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin >> mat[i][j];
		}
	}

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

	for (int j = w - 1; j >= 0; --j)
	{
		for (int i = h - 1; i >= 0; --i)
		{

			if(i + 1 < h and mat[i + 1][j] == '.'){
				memo[i][j] += memo[i + 1][j];
				memo[i][j] %= mod;
			}

			if(j + 1 < w and mat[i][j + 1] == '.'){
				memo[i][j] += memo[i][j + 1];
				memo[i][j] %= mod;
			}

		}
	}


	cout << memo[0][0];



	return 0;
}



Measured memory_bytes: 9088
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

namespace NetFlow
{
	const int N = 202;
	const int M = 40400;
	const int INF = 1e7;
	struct Edge
	{
		int v,w,nxt,rev;
	} e[(M<<1)+3];
	int fe[N+3];
	int te[N+3];
	int dep[N+3];
	int que[N+3];
	int n,en;
	void addedge(int u,int v,int w)
	{
//		printf("addedge%d %d %d\n",u,v,w);
		en++; e[en].v = v; e[en].w = w;
		e[en].nxt = fe[u]; fe[u] = en; e[en].rev = en+1;
		en++; e[en].v = u; e[en].w = 0;
		e[en].nxt = fe[v]; fe[v] = en; e[en].rev = en-1;
	}
	bool bfs()
	{
		for(int i=1; i<=n; i++) dep[i] = 0;
		int head = 1,tail = 1; que[tail] = 1; dep[1] = 1;
		while(head<=tail)
		{
			int u = que[head]; head++;
			for(int i=fe[u]; i; i=e[i].nxt)
			{
				if(dep[e[i].v]==0 && e[i].w>0)
				{
					dep[e[i].v] = dep[u]+1;
					tail++; que[tail] = e[i].v;
				}
			}
		}
		return dep[2]!=0;
	}
	int dfs(int u,int cur)
	{
		if(u==2) {return cur;}
		int rst = cur;
		for(int i=te[u]; i; i=e[i].nxt)
		{
			if(dep[e[i].v]==dep[u]+1 && e[i].w>0 && rst>0)
			{
				int flow = dfs(e[i].v,min(rst,e[i].w));
				if(flow>0)
				{
					e[i].w-=flow; e[e[i].rev].w += flow; rst-=flow;
					if(e[i].w>0) {te[u] = i;}
					if(rst==0) {return cur;}
				}
			}
		}
		if(cur==rst) {dep[u] = 0;}
		return cur-rst;
	}
	void dinic(int _n)
	{
		n = _n;
		int ret = 0;
		while(bfs())
		{
			for(int i=1; i<=n; i++) te[i] = fe[i];
			ret += dfs(1,INF);
		}
//		printf("ret=%d\n",ret);
	}
	void clear()
	{
		for(int i=1; i<=en; i++) e[i].v = e[i].w = e[i].nxt = e[i].rev = 0;
		for(int i=1; i<=n; i++) dep[i] = fe[i] = que[i] = te[i] = 0;
		n = en = 0;
	}
}
using NetFlow::e;
using NetFlow::fe;
using NetFlow::addedge;
using NetFlow::dinic;
using NetFlow::clear;

const int N = 100;
int a[N+3][N+3];
int b[N+3][N+3];
vector<int> vec[N+3][N+3];
int tmp[N+3];
int n,m;

int getclr(int x) {return (x-1)/m+1;}
bool cmp(int x,int y) {return getclr(x)<getclr(y);}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) scanf("%d",&a[i][j]),vec[i][getclr(a[i][j])].push_back(a[i][j]);
	for(int k=1; k<=m; k++)
	{
		for(int i=1; i<=n; i++)
		{
			for(int j=1; j<=n; j++)
			{
				if(vec[i][j].size()>0) {addedge(i+2,j+n+2,1);}
			}
			addedge(1,i+2,1);
			addedge(i+n+2,2,1);
		}
		dinic(n+n+2);
		for(int i=1; i<=n; i++)
		{
			int u = i+2;
			for(int j=fe[u]; j; j=e[j].nxt)
			{
				int v = e[j].v-n-2;
				if(v>0 && v<=n && e[j].w==0)
				{
//					printf("(%d,%d)\n",i,v);
					b[i][k] = *vec[i][v].rbegin();
					vec[i][v].pop_back();
				}
			}
		}
		clear();
	}
	for(int i=1; i<=n; i++) {for(int j=1; j<=m; j++) printf("%d ",b[i][j]); puts("");}
	for(int j=1; j<=m; j++)
	{
		for(int i=1; i<=n; i++) tmp[i] = b[i][j];
		sort(tmp+1,tmp+n+1,cmp);
		for(int i=1; i<=n; i++) b[i][j] = tmp[i];
	}
	for(int i=1; i<=n; i++) {for(int j=1; j<=m; j++) printf("%d ",b[i][j]); puts("");}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n + 1));
	for (int i = 0; i < 2; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 2; j <= n; j++) {
			a[i][j] += a[i][j - 1];
		}
	}
	int m = 0;
	for (int i = 1; i <= n; i++) {
		m = max(m, a[0][i] + a[1][n] - a[1][i - 1]);
	}
	cout << m << endl;
	return 0;
}


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

const int maxn=505;
int a[maxn],s,r[maxn],sum[maxn],ans,n,k;

int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",a+i);
		s+=a[i];
	}
	for(int i=1;i<=sqrt(s);++i) {
		if(s%i==0) {
			i=s/i;
			for(int j=1;j<=n;++j) {
				r[j]=a[j]%i;
			}
			sort(r+1,r+n+1);
			for(int j=1;j<=n;++j) sum[j]=sum[j-1]+r[j];
			int f=0;
			for(int j=1;j<=n;++j)
				if((n-j)*i-sum[n]==0&&sum[j]<=k) f=1;
			if(f) ans=max(ans,i);
			i=s/i;
			for(int j=1;j<=n;++j) {
				r[j]=a[j]%i;
			}
			sort(r+1,r+n+1);
			for(int j=1;j<=n;++j) sum[j]=sum[j-1]+r[j];
			f=0;
			for(int j=1;j<=n;++j)
				if((n-j)*i-sum[n]==0&&sum[j]<=k) f=1;
			if(f) ans=max(ans,i);
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>


using namespace std;

int arr[21], n;

int solve(int i, int m) {  //表示用第i个元素后面的元素可以得到m
	if (m == 0) //m为0 则不需要任何元素就可以得到，所以返回1
		return 1;
	if (i >= n) //超出数组界限则返回0
		return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - arr[i]);//两种情况当前元素参与相加或者不参与
	return res;
}

int main() {

	int q;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	cin >> q;
	int t;
	while (q--) {
		cin >> t;
		if (solve(0, t) == 1)
			cout << "yes\n";
		else
			cout << "no\n";
	}
	return 0;
}





Measured memory_bytes: 3072
n,m=list(map(int, input().split()))
lll = []
a = n
b = m
if (n * m) % 3 == 0:
    print(0)
else:
    for i in range(1, a):
        p = b * i

        if b % 2 == 1:
            q = (a - i) * (int(b / 2) + 1)
        elif b % 2 == 0:
            q = (a - i) * (int(b / 2))
        r = (a - i) * (int(b / 2))

        if (a - i) % 2 == 1:
            q2 = b * (int((a - i) / 2) + 1)
        elif (a - i) % 2 == 0:
            q2 = b * (int((a - i) / 2))

        r2 = b * (int((a - i) / 2))

        lll.append(min(max(p, q, r) - min(p, q, r), max(p, q2, r2) - min(p, q2, r2)))

    temp = b
    b = a
    a = temp
    for i in range(1, a):
        p = b * i

        if b % 2 == 1:
            q = (a - i) * (int(b / 2) + 1)
        elif b % 2 == 0:
            q = (a - i) * (int(b / 2))
        r = (a - i) * (int(b / 2))

        if (a - i) % 2 == 1:
            q2 = b * (int((a - i) / 2) + 1)
        elif (a - i) % 2 == 0:
            q2 = b * (int((a - i) / 2))

        r2 = b * (int((a - i) / 2))

        lll.append(min(max(p, q, r) - min(p, q, r), max(p, q2, r2) - min(p, q2, r2)))


    print(min(lll))

Measured memory_bytes: 11056
#include<cstdio>
#include<cstring>

const int MAXN = 2e5 + 10;
char s[MAXN], t[MAXN];

int main()
{
    fgets(s, MAXN, stdin);
    fgets(t, MAXN, stdin);
    int n,count=0;
    n = strlen(s);
    for (int i = 0; i < n;i++)
    {
        if(s[i]!=t[i])
            count++;
    }
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 1972
import sys
sys.setrecursionlimit(1000000)

def solve(K, A, B):
    for i in range(A, B+1):
        if i % K == 0:
            return "OK"
    return "NG"

if __name__ == "__main__":
    K = int(input())
    A, B = tuple(map(int, input().split(" ")))

    print(solve(K, A, B))


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  
  int ans;
  if (a == 1 && b == 2)
    ans = 3;
  if (a == 1 && b == 3)
    ans = 2;
  if (a == 2 && b == 1)
    ans = 3;
  if (a == 2 && b == 3)
    ans = 1;
  if (a == 3 && b == 1)
    ans = 2;
  if (a == 3 && b == 2)
    ans = 1;
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){
  int k,n;
  int o = 0;
  cin >> k >> n;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i]-a[i-1]>o){
      o = a[i]-a[i-1];
    }
  }

  if(k-a[n-1]+a[0]>o){
    o = k-a[n-1]+a[0];
  }
  cout << k-o << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

vector<int> Zalgo(const string &s){
    int N=s.size();
    vector<int> z(N,0);
    z[0]=N;
    int i=1,j=0;
    while(i<N){
        while(i+j<N && s[j]==s[i+j])j++;
        z[i]=j;
        if(j==0){i++;continue;}
        int k=1;
        while(i+k<N && z[k]+k < j){
            z[i+k]=z[k];
            k++;
        }
        i+=k;j-=k;
    }
    return z;
}

int main(){
    int N;cin>>N;
    string s;cin>>s;
    int res=0;
    REP(i,N){
        vector<int> A=Zalgo(s.substr(i));
        REP(j,A.size()){
            res=max(res,min(j,A[j]));
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
n,k,*x=map(int,open(0).read().split())
if x[0]>=0:
  ans=x[k-1]
elif x[-1]<=0:
  ans=abs(x[~(k-1)])
else:
  ans=10**10
  for i in range(n-k+1):
    l=x[i]
    r=x[i+k-1]
    if l<=0<=r:
      ll=abs(l)
      rr=abs(r)
      tmp=min(ll+2*rr,2*ll+rr)
      ans=min(ans,tmp)
      
print(ans)
  


Measured memory_bytes: 69672
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-5,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  // ll N;
  // cin >> N ;
  ll a,b,c;
  vl x(3);
  cin >> x[0] >> x[1] >> x[2] ;
  bool ans = (x[0]==x[1])&&(x[1]==x[2]);
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    priority_queue<ll> que;
    ll ans = 100000000000001;
    ll x = 0, y = 0, sum = 0;

    rep(i, 0, n) {
        cin >> a[i];
        sum += a[i];
    }

    rep(i, 0, n) {
        x += a[i];
        if(i+1 < n) ans = min(abs(sum-x*2), ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int d,n;
    cin >> d >> n;
    int count;
    if(d == 0){
        if(n == 100){
            cout << 101 << endl;
        }else{
            cout << n << endl;
        }
    }else if(d == 1){
        if(n == 100){
            cout << 10100 << endl;
        }else{
            cout << n*100 << endl;
        }
    }else if(d == 2){
        if(n == 100){
            cout << 1010000 << endl;
        }else{
            cout << n*100*100 << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        int ans = 0;
        int count = 0;
        for (int i = 0; i < S.length(); i++) {
            String s = S.charAt(i) + "";
            if (s.equals("A")
                || s.equals("C") 
                || s.equals("G") 
                || s.equals("T") ) {
                    count++;
                    if (ans < count) {
                        ans = count;
                    }
                } else {
                if (ans < count) {
                    ans = count;
                }
                count = 0;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 22868
#include <algorithm>
#include <cmath>
#include <cstdio>
typedef long long LL;
const int N = 205;
double l[N], r[N], t[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lf", &r[i]);
    r[i] += (l[i] = r[i - 1]); 
  }
  for (int i = 1; i <= n; ++i) scanf("%lf", &t[i]);
  l[n + 1] = r[n + 1] = r[n];
  double ans = .0;
  for (int i = 1; i <= n; ++i) {
    double ll = t[i] - l[i], rr = t[i] + r[i];
    for (int j = 0; j < i; ++j)
      ll = std::min(ll, (double)t[j] - r[j]);
    for (int j = i + 1; j <= n + 1; ++j)
      rr = std::min(rr, (double)t[j] + l[j]);
    // y <= x + ll, <= rr - x, <= t
    // x + ll = rr - x = (rr + ll) / 2, x = (rr - ll) / 2
#define q(x) std::min(t[i], std::min(ll + (x), rr - (x)))
#define add(x1, y1, x2, y2) ans += ((double)(y1) + (y2)) * ((double)(x2) - (x1))
    double xx0 = l[i], yy0 = q(xx0);
    double xx1 = std::max(l[i], std::min(t[i] - ll, (rr - ll) / 2)), yy1 = q(xx1);
    double xx2 = std::min(r[i], std::max(rr - t[i], (rr - ll) / 2)), yy2 = q(xx2);
    double xx3 = r[i], yy3 = q(xx3);
    add(xx0, yy0, xx1, yy1);
    add(xx1, yy1, xx2, yy2);
    add(xx2, yy2, xx3, yy3);
  }
  printf("%.20lf", ans / 2);
  return 0;
}

Measured memory_bytes: 128
import scala.collection.immutable.HashSet

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M = sc.nextInt()
  val pairs = HashSet.fill(M)(sc.nextInt() - 1 -> sc.next().toCharArray.head)
  val isMatched = (i: String) => pairs.forall { case (s, c) => i(s) == c }
  val start = if (N == 1) 0 else math.pow(10, N - 1)
  println {
    start.toInt.to(("9" * N).toInt).collectFirst {
      case i if isMatched(i.toString) => i
    }.getOrElse(-1)
  }
}


Measured memory_bytes: 55748
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }


    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var s = Console.ReadLine();
        var y = long.Parse(s.Substring(0, 4));
        var m = long.Parse(s.Substring(5, 2));
        var d = long.Parse(s.Substring(8,2));
        if (y < 2019)
            Console.WriteLine("Heisei");
        else if (y == 2019 && m < 5)
            Console.WriteLine("Heisei");
        else
            Console.WriteLine("TBD");

        Console.Out.Flush();
    }
}

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


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

    ll n;
    cin>>n;
    vector<ll> a[3],b,c;
    ll now = 2;
    if(n==3){
        cout << "2 5 63\n";
        return 0;
    }
    if(n==4){
        cout << "2 5 20 63\n";
        return 0;
    }
    for(int i=2;i<=30000;i++){
        if(i%2 && (i%3)==0) b.push_back(i);
        else if(i%3 && (i%2)==0) a[i%3].push_back(i);
        else if(i%3==0 && i%2==0) c.push_back(i);
    }
    cerr << a[1].size() << " " << a[2].size() <<  " " << b.size() << " "<< c.size() << endl;
    int cnt = 0;
    while(cnt < 5000 && n>=4){
        cout << b[cnt] << " " << b[cnt+1] << " ";
        cnt+=2;
        n-=2;
    }
    cnt = 0;
    while(cnt < 5000 && n>=2){
        cout <<a[1][cnt] << " " << a[2][cnt] << " ";
        cnt++;
        n-=2;
    }
    cnt =0 ;
    while(n){
        n--;
        cout << c[cnt] << " ";
        cnt++;
    }

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll N;
    cin>>N;
    if(N<1200)
    {
        cout<<"ABC"<<endl;
    }
    else
    {
        cout<<"ARC"<<endl;
    }
  return 0;
}



Measured memory_bytes: 256
n,k = map(int,input().split())
s = input()

x = []
idx = 0
b = 1
while idx<n:
    st = idx
    while idx<n and int(s[idx])==b:
        idx += 1
    x.append(idx-st)
    st = idx
    b ^= 1

if b == 1:
    x.append(0)

ans = n
if len(x) > 2*k+1:
    ans = 0

    t = 0
    for i in range(2*k+1):
        t += x[i]
    ans = max(ans, t)

    for i in range(2*k+1, len(x), 2):
        t -= x[i - (2*k+1)]
        t -= x[i+1 - (2*k+1)]
        t += x[i]
        t += x[i+1]
        ans = max(ans, t)

print(ans)


Measured memory_bytes: 4212
N, x = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

initial = as.inject(:+)

for i in 0..(N-2) do
  m = as[i]
  n = as[i + 1]
  if m + n > x
    as[i + 1] = [x - m, 0].max
    as[i] = [x, m].min
  end
end

puts initial - as.inject(:+)

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

int main(){
  string s;cin>>s;
  int n;n=s.size();
  bool ans=true;
  for(int i=1;i<=n/2;i++){
    if(s.at(i-1)!=s.at(n-i)){
      cout <<"No"<<endl;
      return 0;
    }
  }
  int n2=n/2;
  for(int i=1;i<=n2/2;i++){
    if(s.at(i-1)!=s.at(n2-i)){
      cout <<"No"<<endl;
      return 0;
    }
  }
  int n3=(n+3)/2;
  int tmp=n-n3+1;
  for(int i=1;i<=tmp/2;i++){
    if(s.at(n3-1+i-1)!=s.at(n-i)){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout <<"Yes"<<endl;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  int n;
  string s;
  cin>>n>>s;
  string t = "ABC";
  int ans = 0;
  rep(i,n-2)if(s.substr(i,3)==t)ans++;
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
k=int(input())

from queue import Queue
q=Queue()

for i in range(1,10):
  q.put(i)

cnt=0

while 1:
  cnt+=1
  x=q.get()
  if cnt==k:
    print(x)
    exit()
  if x%10!=0:
    q.put(10*x+x%10-1)
  q.put(10*x+x%10)
  if x%10!=9:
    q.put(10*x+x%10+1)

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

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 1;
  
  for(int i=0;i<n;i++){
    if(ans+k<ans*2)
      ans = ans + k;
    else
      ans = ans * 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int a;
	int d[50];
	int ans = 0;
	scanf("%d", &a);

	for (int i = 0; i < a; i++) {
		scanf("%d", &d[i]);
	}

	for (int i = 0; i < a - 1; i++) {
		for (int j = i + 1; j < a; j++) {
			if (i != j) {
				ans += d[i] * d[j];
			}
		}
	}

	printf("%d\n", ans);

	return 0;
}

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

using namespace std;

string s;
int ans;
int N;

int main()
{
  cin >> s;
  N = s.length();
  vector<int> cnt(2, 0);
  for(string::size_type i = 0; i < s.size(); i++)
  {
    cnt[s[i] - '0']++;
  }
  int ans = 2 * (N - max(cnt[0], cnt[1]));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
from collections import deque

h,w = map(int,input().split())
matrix = [["a" for _ in range(w+2)]] + [list("a" + input() + "a") for _ in range(h)] + [["a" for _ in range(w+2)]]

matrix_list1 = deque()
cnt = 0

#黒いタイルの位置情報を確認
for i in range(1,h+1):
    for j in range(1,w+1):
        if matrix[i][j] == "#":
            matrix_list1.append([i,j])

#白いタイルが無くなるまで、黒いタイルを増やす
while len(matrix_list1) != 0:     
    for _ in range(len(matrix_list1)):
        x,y = matrix_list1.popleft()
        if matrix[x+1][y] == ".":
            matrix[x+1][y] = "#"
            matrix_list1.append([x+1,y])
        if matrix[x-1][y] == ".":
            matrix[x-1][y] = "#"
            matrix_list1.append([x-1,y])
        if matrix[x][y+1] == ".":
            matrix[x][y+1] = "#"
            matrix_list1.append([x,y+1])
        if matrix[x][y-1] == ".":
            matrix[x][y-1] = "#"
            matrix_list1.append([x,y-1])
    else:
        if len(matrix_list1) > 0:
            cnt += 1
    
print(cnt)

Measured memory_bytes: 168796
// Author :mdragneell
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define pi  pair< int,int >
#define pl  pair< ll,ll >
#define f first
#define s second


ll const mod=1e9+7;
ll const N=1e4+5;
ll min(ll x,ll y) { if(x < y) return x; else return y; }
ll max(ll x,ll y) { if(x > y) return x; else return y; }
ll gcd(ll x,ll y) { if(x == 0) return y; else return gcd(y%x,x);}
ll powmod(ll x,ll y){ll res=1;while(y>0){if(y%2==1)res=(res*x)%mod;y>>=1;if(y<=0)break;x=(x*x)%mod;}return res;}



struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);}
};
struct compare {
    bool operator()(const pair<ll, ll>& value,  const ll& key){ return (value.first < key); }
    bool operator()(const ll& key, const pair<ll, ll>& value) { return (key < value.first); }
};

bool compare1(const pair<ll,ll> &a,const pair<ll,ll> &b)
{   if(a.first<b.first) return true ;
    else if(a.first==b.first) return (a.second > b.second);
    else return false;
}

ll dp[N];
ll x[N],y[N];
ll h,n;

ll sol(ll h)
{
    
    if(h<=0)
        return 0;
    ll &ans=dp[h];
    
    if(ans!=1e9)
        return ans;
    
    for(int i=0;i<n;i++)
        ans=min(ans,y[i]+sol(h-x[i]));
    return ans;
    
}



int main()
{

        ios_base::sync_with_stdio(false); cin.tie(NULL);
       
        int tt=1;
        //cin>>tt;

        while(tt--)
        {
           
               cin>>h>>n;
               
               for(int i=0;i<n;i++){
                    cin>>x[i]>>y[i];
               }
                
               for(int i=0;i<=h+5;i++)
                    dp[i]=1e9;
                
               
               cout<<sol(h)<<endl;
               
               
                
        }



}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 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 mul(ll a, ll b) { if (a == 0) return 0; if (infl / a < b) return infl; return min(infl, a * b); }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
ll MA = 1;
//---------------------------------------------------------------------------------------------------
void _main() {
	rep(i, 0, 18) MA *= 10;

	cin >> N;
	ll tot = 1;
	rep(i, 0, N) {
		ll a; cin >> a;
		tot = mul(tot, a);
	}
	if (MA < tot) cout << "-1" << endl;
	else cout << tot << endl;
}







Measured memory_bytes: 3668
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
   
   ll n;
   cin>>n;
   vector<ll>v(n);
   for(ll i=0;i<n;i++)
    cin>>v[i];
    ll ans=0;
   for(ll i=0;i<n;i++)
   {
       for(ll j=i+1;j<n;j++)
       {
           for(ll k=j+1;k<n;k++)
           {
               if(v[i]<v[j]+v[k] && v[j]<v[i]+v[k]&&v[k]<v[i]+v[j] && v[i]!=v[j] && v[i]!=v[k] && v[j]!=v[k])
               // cout<<i<<j<<k<<endl;
                ans++;
           }
       }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int n,m,k;
char hyadainnzugeeto[500];
char sekaisen[5][500];

char hg_tenkai[1000000];
char* now_tenkaisaki;

void moziretu_tenkai(const char* moziretu,int length,int repeat) {
	int i,j;
	char* initial_tenkaisaki=now_tenkaisaki;
	int tenkaiLength,repeatNumModify;
	for(i=0;i<length;i++) {
		if(isalpha(moziretu[i])) {
			*(now_tenkaisaki++)=moziretu[i];
		} else if(isdigit(moziretu[i])) {
			int startPos;
			int kakkoNum;
			int repeatNum;
			for(j=i;isdigit(moziretu[j]);j++);
			startPos=j+1;
			kakkoNum=1;
			for(j=startPos;kakkoNum>0;j++) {
				if(moziretu[j]=='(')kakkoNum++;
				else if(moziretu[j]==')')kakkoNum--;
			}
			while(moziretu[i]=='0')i++;
			if(startPos-i-1>9) {
				repeatNum=10000;
			} else {
				sscanf(&moziretu[i],"%d",&repeatNum);
			}
			moziretu_tenkai(&moziretu[startPos],j-1-startPos,repeatNum);
			i=j-1;
		}
	}

	tenkaiLength=(int)(now_tenkaisaki-initial_tenkaisaki);
	repeatNumModify=(m+tenkaiLength-1)/tenkaiLength;
	if(repeatNumModify<=1)repeatNumModify=2;
	if(repeatNumModify>repeat)repeatNumModify=repeat;
	if(repeatNumModify>1 && tenkaiLength>(m-1)*2+1) {
		char* tenkaisaki_last=now_tenkaisaki;
		strncpy(now_tenkaisaki,initial_tenkaisaki,m-1);
		now_tenkaisaki+=m-1;
		*(now_tenkaisaki++)='*';
		strncpy(now_tenkaisaki,tenkaisaki_last-(m-1),m-1);
		now_tenkaisaki+=m-1;
	} else {
		for(i=1;i<repeatNumModify;i++) {
			strncpy(now_tenkaisaki,initial_tenkaisaki,tenkaiLength);
			now_tenkaisaki+=tenkaiLength;
		}
	}
}

int main(void) {
	int i,j;
	int sekaisencount;
	int max,maxsekaisen;

	scanf("%d%d%d",&n,&m,&k);
	scanf("%s",hyadainnzugeeto);
	for(i=0;i<k;i++)scanf("%s",sekaisen[i]);

	now_tenkaisaki=&hg_tenkai[0];
	moziretu_tenkai(hyadainnzugeeto,n,1);
	*now_tenkaisaki=0;

	max=maxsekaisen=0;
	for(sekaisencount=0;sekaisencount<k;sekaisencount++) {
		char buffer[500]={0};
		int count=0;
		char* nowpointer;
		int complete=0;
		buffer[0]=sekaisen[sekaisencount][0];
		for(i=0,j=1;i<m && !complete;i++) {
			nowpointer=hg_tenkai;
			while(1) {
				nowpointer=strstr(nowpointer,&buffer[i]);
				if(nowpointer==NULL)break;
				while(j<m && nowpointer[j-i]==sekaisen[sekaisencount][j]) {
					buffer[j]=sekaisen[sekaisencount][j];
					j++;
				}
				if(j<m) {
					buffer[j]=sekaisen[sekaisencount][j];
					j++;
				} else {
					complete=1;
					break;
				}
			}
			count+=j-i-1;
			if(complete)count++;
		}
		count+=(j-i)*(j-i+1)/2;
		if(count>max) {
			max=count;
			maxsekaisen=sekaisencount;
		}
	}
	printf("%d %d\n",maxsekaisen+1,max);
	return 0;
}

Measured memory_bytes: 704
#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)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

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

    ll min = 0, max = 0;
    int l = 0, r = N;
    rep(i, K) {
        min += l;
        max += r;
        l++,
        r--;
    }

    mint ans = 0;
    for (int k = K; k <= N+1; ++k) {
        ans += max - min + 1;
        min += l;
        max += r;
        l++;
        r--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct edge{
	int to;
	ll cost;
};
vector<edge> G[100010];
ll d[100010];
void dfs(int v, int parent) {
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i].to == parent) continue;
		d[G[v][i].to] = d[v] + G[v][i].cost;
		dfs(G[v][i].to, v);
	}
}
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--; b--;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
	}
	int Q, K;
	cin >> Q >> K;
	dfs(K - 1, -1);
	for (int i = 0; i < Q; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		cout << d[x] + d[y] << endl;
	}
}

Measured memory_bytes: 15872
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int res = 0;
      	int n = x / 100;
      	int m = x % 100;
      	
      	if(x >= 2000){
      	    res = 1;
      	}else if(m <= 5 * n){
      	    res = 1;
      	}
        
      	System.out.println(res);
    }
}


Measured memory_bytes: 21716
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int mxN = 2e5 + 5;

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

int dp[mxN][2];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r = 0, w = 0;
	rep(i, n){
		if(s[i] == 'R') r++;
		else w++;
	}
	int ans = 0;
	vi vis(n, 0);
	rep(i, r) vis[i] = 1;
	repn(i, r, n) vis[i] = 2;
	int numW = 0, numR = 0;
	rep(i, n){
		if(s[i] == 'R'){
			if(vis[i] == 2) numR++;
		}
		else{
			if(vis[i] == 1) numW++;
		}
	}
	ans = min(numR, numW) + numR + numW - (2 * min(numW, numR));
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll a[5];
  rep(i,5) cin>>a[i];
  ll b[5];
  ll ans=INF;
  ll sum=0;
  rep(i,5){
    if(a[i]%10==0){
      b[i]=a[i];
    }
    else{
      b[i]=a[i]+(10-a[i]%10);
    }
    sum+=b[i];
  }
  rep(i,5){
    ll mi=sum;
    mi-=b[i];
    mi+=a[i];
    ans=min(ans,mi);
  }
  cout<<ans<<endl;
}

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

def lcm(a,b):
    return a * b // (gcd(a,b))
n = int(input())
a = [1]
for _ in range(n):
    a.append(int(input()))
for i in range(1, n+1):
    a[i] = lcm(a[i-1], a[i])
print(a[-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
bool is_left(char c) {
    string left="qwertasdfgzxcvb";
    for(int i=0;i<left.size();i++) if(left[i]==c) return 1;
    return 0;
}
int main() {
    string s;
    while(cin>>s,s!="#") {
        bool L=is_left(s[0]);
        int ans=0;
        for(int i=1;i<s.size();i++) {
            if(L!=is_left(s[i])) {ans++;L^=1;}
        } 
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 3224
import java.util.*;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int l = sc.nextInt();
			int sum = 0;
			int[] array = new int[n];
			for(int i = 0;i<n;i++) {
				array[i] = l+i;
				sum+=array[i];
			}
			int min = array[0];
			for(int num : array) {
				if(num>0) {
				if(num<=min) 
					min = num;
				if(num == 0) {
					min = 0;
					break;
				}
				}
				else if(num<0) {
					if(num>=min) 
						min = num;
				}
				if(num == 0) {
					min = 0;
					break;
				}
			}
			System.out.println(sum-min);
			
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

}


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

int main() {
    int n, k;
    char c;

    cin >> n >> k;
    for (int i = 0 ; i < n ; ++i) {
        cin >> c;
        if (i == k-1) cout << (char)(c + ('a'-'A'));
        else cout << c;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
int main(){
	int n;
	string str;
	cin>>str;
	int ans=0,now=0;
	for(int i=0;i<str.size();i++){
		if(str[i]=='S')now++;
		else now--;
		ans=min(ans,now);
	}
	ans=-ans;
	cout<<2*ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const long long  mod = 1000000007;



// 3 5 -> 3 2 -> 1 2 -> 1 1 .= 1 0
// 3 5 6 -> 3 2 0 ->
//10 6 -> 4 6 -> 4 2 -> 2 2 .> 2 0
//gcd

int gcd(int n, int m){
  if(n < m) swap(n,m);

  if(m==0) return n; // 0's deviser is all numbers.
  while(m > 0){
    int res = n%m;
    n = m;
    m = res;
  }
  return n;
}
//

int lcm(int n, int m){
  return m*n/gcd(n,m);
}




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

  int ans = a[0];
  rep(i,n) ans = min(ans, gcd(ans,a[i]));
  cout << ans << endl;
}


Measured memory_bytes: 3768