akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
int main(){
  int n,q;
  cin>>n>>q;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
    Query queries[q];
    for(int i=0;i<q;i++){
      int lft,rt;
      cin>>lft>>rt;
      lft--;
      rt--;
      queries[i].l=lft;
      queries[i].r=rt;
      queries[i].idx=i;
      
    }
  sort(queries, queries+q, cmp); 
    answeringQueries(arr, n, queries, q);
  return 0;
}

Measured memory_bytes: 19412
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	vector<double> a(n); rep(i, n)cin >> a[i];
	int ok = 1e9, ng = 0;
	while (ok - ng > 1)
	{
		int mid = (ok + ng) / 2;
		ll cnt = 0;
		rep(i, n)
		{
			if (mid == 1)cnt += a[i];
			else cnt += (a[i] - 1) / mid;
		}
		if (cnt <= k)ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 4740
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

#define N 1001

int lcs(string x,string y){
    int c[N + 1][N + 1] = {};
    int maxl = 0;
    x = ' ' + x; // X[0]に空白を挿入
    y = ' ' + y; // Y[0]に空白を挿入

    for(int i = 1;i <= x.size();++i){
        for(int j = 1;j <= y.size();++j){
            if(x[i] == y[j]){
                c[i][j] = c[i - 1][j - 1] + 1;
            }else{
                c[i][j] = max(c[i - 1][j],c[i][j - 1]);
            }
            maxl = max(maxl,c[i][j]);
        }
    }
    
    for(int i = 1;i <= x.size();++i){
        for(int j = 1;j <= y.size();++j){
            if(x[i] == y[j]){
                c[i][j] = c[i - 1][j - 1] + 1;
            }else{
                c[i][j] = max(c[i - 1][j],c[i][j - 1]);
            }
            maxl = max(maxl,c[i][j]);
        }
    }
    // 空白一致分
    return maxl - 1;
}

int main(){
    string s1,s2;
    int n;
    cin >> n;
    
    for(int i = 0;i < n;++i){
        cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }
}



Measured memory_bytes: 7128
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,x,cnt0=0,cnt1=0,sum,mi,mif,a[100005],b[100005],i;
const ll inf=1e18;
void solve1()
{
	ll i,k;
	printf("%lld\n",sum-2*mi);
	sort(a+1,a+cnt0+1);
	if(n==2)printf("%lld %lld\n",a[2],a[1]);
	else
	{
		k=a[1];
		for(i=2;i<n;i++)printf("%lld %lld\n",k,a[i]),k=k-a[i];
		printf("%lld %lld\n",a[n],k);
	}
}
void solve2()
{
	ll i,k;
	printf("%lld\n",sum-2*mi);
	sort(b+1,b+cnt1+1);
	k=-b[1];
	for(i=2;i<=n;i++)
	{
		printf("%lld %lld\n",k,-b[i]);
		k+=b[i];
	}
}
void solve3()
{
	ll i,k;
	printf("%lld\n",sum);
	k=-b[1];
	for(i=2;i<=cnt0;i++)
	{
		printf("%lld %lld\n",k,a[i]);
		k-=a[i];	
	}
	b[1]=-k;
	k=a[1];
	for(i=1;i<=cnt1;i++)
	{
		printf("%lld %lld\n",k,-b[i]);
		k+=b[i];
	}
}
int main()
{
	mi=inf;sum=0;mif=0;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		sum+=abs(x);
		if(abs(x)<mi)
		{
			mi=abs(x);
			mif=i;
		}
		if(x<0)b[++cnt1]=abs(x);
		else a[++cnt0]=abs(x);
	}
	if(cnt1==0)solve1();
	if(cnt0==0)solve2();
	if(cnt1&&cnt0)solve3();
	return 0;
}

Measured memory_bytes: 2560
import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val A = sc.nextInt()
    val B = sc.nextInt()
    val C = sc.nextInt()
    val L = mutableListOf<Pair<Int,Int>>()//<length,ABC or not used>
    for (i in 0 until N) {
        val l = sc.nextInt()
        L.add(l to 0)
    }

    fun calc() :Int{
        var a = 0
        var b = 0
        var c = 0
        var score = 0
        for ((l,x) in L) {
            score += 10
            when (x) {
                0-> score-=10
                1-> a+=l
                2-> b+=l
                3-> c+=l
            }
        }
        if (a==0||b==0||c==0) return 100000
        score += Math.abs(a-A)+Math.abs(b-B)+Math.abs(c-C) - 30//first abc
        return score
    }

    fun search(n:Int) :Int{
        if (n == 0) return calc()
        var res = 100000
        for (i in 0 until 4) {
            L[n-1] = L[n-1].copy(second = i)
            res = Math.min (search(n-1), res)
        }
        return res
    }

    println(search(N))
}


Measured memory_bytes: 39552
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

LL modpow(LL base, LL exp, LL modulus) {
  base %= modulus;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

int main(){
    DRI(n);
    int mod = 998244353;
    VL D(n);
    VL a(n);
    LL res=1;
    bool isok=true;
    bool stillon=true;
    REP(i,n){
        RI(D[i]);
        a[D[i]]++;
        if (!i and D[i]) res=0;
        if (i and !D[i]) res=0;
    }
    REPP(i,1,n){
        if (!a[i]) stillon=false;
        else{
            if (!stillon) res=0;
            if (i>1) {
                res*=modpow(a[i-1],a[i],mod);
                res%=mod;
            }
        }
    }
    printf("%d",int(res));

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define foi for(int i=0; i<n; i++)
#define foj for(int j=0; j<n; j++)
#define ll long long int
#define vi vector<int>
#define maxn 200005
#define mod 1000000007
using namespace std;

int cnt[30];
char c;
int main() {
    int n;
    cin >> n;
    foi {
        cin >> c;
        cnt[c-'a']++;
    }
    ll ans=1;
    for (int i=0; i<30; i++) {
        ans=ans*(cnt[i]+1)%mod;
    }
    ans--;
    if (ans<0) ans+=mod;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

vector<ll> dp(214514,-1);
ll f(ll n){
    if(n<=0){
        return 0;
    }
    if(dp[n]!=-1){
        return dp[n];
    }
    
    ll k=0;
    ll m=n;
    while(m>0){
        if(m%2==1)k++;
        m/=2;
    }
    
    ll r = n%k;
    
    dp[n]=1+f(r);
    return dp[n];
    
}


int main(void){
    
    ll N;
    string X;
    cin >> N;
    cin >> X;
    
    ll P=0;
    REP(i,N){
        if(X[i]=='1'){
            P++;
        }
    }
    
    
    ll M=0,m=0;
    REP(i,N){
        M*=2;
        if(X[i]=='1'){
            M++;
        }
        M%=(P+1);
    }
    
    if(P==0 || P==1){
        m=-1;
    }else{
        REP(i,N){
            m*=2;
            if(X[i]=='1'){
                m++;
            }
            m%=(P-1);
        }
    }
    
    vector<ll> Q(N),Ans(N,0);
    
    ll k=1,l=1;
    RREP(i,N){
        
        if(P==1 && X[i]=='1'){
            Q[i]=-1;
        }else{
            if(X[i]=='1'){
                Q[i]=(m+P-1-l)%(P-1);
            }else{
                Q[i]=(M+k)%(P+1);
            }
        }
        
        
        k = (k*2)%(P+1);
        if(P!=1){
            l = (l*2)%(P-1);
        }
    }
    
    
    /*
    REP(i,N){
        cout << Q[i] << endl;
    }*/
    
    REP(i,N){
        if(Q[i]==-1){
            Ans[i]=0;
        }else{
            Ans[i]=1+f(Q[i]);
        }
    }
    
    REP(i,N){
        cout << Ans[i] << endl;
    }
    
    /*
    ll A=0;
    REP(i,X.size()){
        A*=2;
        if(X[i]=='1'){
            A++;
        }
    }
    cout << A << endl;
    
    REP(i,N){
        ll B = A^(1LL<<(N-i-1));
        cout << B << endl;
    }*/
    
    return 0;
}



Measured memory_bytes: 8500
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int K; cin >> K;
    string s; cin >> s;
    if (s.length() <= K) cout << s << endl;
    else {
        rep(i, K) cout << s[i];
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

const int N = 505;
int a[N][N], n, m, q;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> q;
  FOR(i, 0, m){
    int l, r;
    cin >> l >> r;
    a[l][r]++;
  }
  FOR(i, 1, N)FOR(j, 0, N-i) a[j][i+j] += a[j][i+j-1] + a[j+1][i+j] - a[j+1][i+j-1];
  FOR(i, 0, q){
    int l, r;
    cin >> l >> r;
    printf("%d\n", a[l][r]);
  }
  return 0;
}

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

bool is_maze(vector<vector<int> > grid, const pair<int,int>& start, const pair<int,int>& goal)
{
  const int W = grid.size();
  const int H = grid[0].size();
  const int color = grid[start.first][start.second];
  queue<pair<int,int> > q;
  q.push(start);
  grid[start.first][start.second] = -1;
  while (!q.empty()) {
    const pair<int,int> p = q.front();
    q.pop();
    if (p == goal) {
      return true;
    }

    for (int d = 0; d < 4; d++) {
      static const int dir_w[] = {-1, 1, 0, 0};
      static const int dir_h[] = {0, 0, -1, 1};
      const int next_w = p.first + dir_w[d];
      const int next_h = p.second + dir_h[d];
      if (next_w >= 0 && next_w < W && next_h >= 0 && next_h < H
          && grid[next_w][next_h] == color) {
        q.push(make_pair(next_w, next_h));
        grid[next_w][next_h] = -1;
      }
    }
  }
  return false;
}

int main()
{
  int W, H;
  while (cin >> W >> H && W != 0) {
    vector<vector<int> > grid(W, vector<int>(H, 0));
    pair<int,int> start, goal;
    cin >> start.first >> start.second;
    --start.first;  --start.second;
    cin >> goal.first >> goal.second;
    --goal.first; --goal.second;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
      int c, d, x, y;
      cin >> c >> d >> x >> y;
      --x;  --y;
      if (d == 1) {
        // vert
        for (int i = 0; i < 4; i++) {
          grid[x][y+i] = grid[x+1][y+i] = c;
        }
      } else {
        // horiz
        for (int i = 0; i < 4; i++) {
          grid[x+i][y] = grid[x+i][y+1] = c;
        }
      }
    }
    cout << (is_maze(grid, start, goal) ? "OK" : "NG") << endl;
  }
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t h, w;
    cin >> h >> w;

    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    int64_t ans = min(h, w);
    for (auto i : irange(1L, h)) {
        auto smax = max({(w + 1) / 2 * i, (h - i) * w});
        auto smin = min({w / 2 * i, (h - i) * w});
        ans = min(ans, smax - smin);
    }
    for (auto i : irange(1L, w)) {
        auto smax = max({(h + 1) / 2 * i, (w - i) * h});
        auto smin = min({h / 2 * i, (w - i) * h});
        ans = min(ans, smax - smin);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int ans[200010],query[200010];
vector<int> G[200010];

void dfs(int v,int counter){
	counter += query[v];
	ans[v] = counter;
	for(int to : G[v]){
		dfs(to,counter);
	}
}

signed main(){
	int n,q;
	cin >> n >> q;
	for(int i = 0;i < n - 1;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		G[a].pb(b);
	}
	for(int i = 0;i < q;i++){
		int p,x;
		cin >> p >> x;
		query[p - 1] += x;
	}
	dfs(0,0);
	for(int i = 0;i < n;i++) cout << (i ? " " : "") << ans[i];
	cout << endl;
}

Measured memory_bytes: 22656
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
    const ll N = 1e5 + 7;
    const ll mod = 1e9 + 7;

int main(){
    TIME
    int n , m , cnt =0;
    cin >> n >> m;
    while(n > 0){
        n -= m;
        cnt ++;
    }
    cout << cnt;
}
///...


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

int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	string p;
	string copy;
	int n;
	cin >> n;
	cin >> p;
	for (a = 0; a < n; a++)
	{
		d = 0;
		for (c = 0; c <= a; c++)
		{
			for (b = a + 1; b < n; b++)
			{
				f = 0;
				for ( e = 0; e < c; e++)
				{
					if (p[e]==p[c])
					{
						f = 1;
						break;
					}
				}
				if (f==1)
				{
					break;
				}
				if (p[c] == p[b]&&f==0)
				{
					d++;
					break;
				}
			}
		}
		ans = max(ans, d);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
        (source = $s:expr, $($r:tt)*) => {
            let mut iter = $s.split_whitespace();
            let mut next = || { iter.next().unwrap() };
            input_inner!{next, $($r)*}
        };
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! input_inner {
        ($next:expr) => {};
        ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };

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

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

        ($next:expr, bytes) => {
            read_value!($next, String).into_bytes()
        };

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

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

fn main() {
    input! {
            n: usize,
            mod_numbers: [i32; n],
        }

    let mut balls_in_box = vec![0; n];

    for inverted_i in 0..n {
        let i = n as i32 - inverted_i as i32 - 1;

        let count = count_multiple_box(&balls_in_box, i + 1);

        if mod_numbers[i as usize] != count % 2 {
            balls_in_box[i as usize] = 1;
        }
    }

    let ans = balls_in_box.clone().into_iter().enumerate().filter(|&(_, x)| x == 1).collect::<Vec<(usize, i32)>>();

    // I think this problem always has answer

    println!("{}", ans.len());

    if ans.len() as i32 != 0 {
        let ans_str = ans.into_iter().map(|(index, _)| (index as i32 + 1).to_string()).collect::<Vec<String>>().join(" ");

        println!("{}", ans_str);
    }
}

// usize1
fn count_multiple_box(balls_in_box: &Vec<i32>, number: i32) -> i32 {
    let mut answer = 0;

    for i in 0..(balls_in_box.len() as i32 / number) {
        let current_index = ((i + 1) * number - 1) as usize;
        answer += balls_in_box[current_index];
    }

    return answer;
}

Measured memory_bytes: 14068
#include <bits/stdc++.h>
 
using namespace std;
 
 
const int N=1e6+5,MOD=1e9;
 
const int dx[]={0,1,-1,0},
          dy[]={1,0,0,-1};
 
typedef long long ll;
 
int n,m,k,a[N],b[N],q,u,x,y,tc,c,ans;
 
char s[N],s2[N];
 
vector<int> v;

int main() {
    ll ans=0;
    priority_queue<int> pq;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]),pq.push(a[i]);
    while(!pq.empty() && m>0){
        int x=pq.top();
        pq.pop();
        x/=2;
        m--;
        if (x!=0)
            pq.push(x);
    }
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 4856
using System;

namespace abc145
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            
            if(N != 1 && N % 2 == 0 && S.Substring(0,N/2) == S.Substring(N/2,N/2)){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


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

using namespace std;

const int N=707;

int adj[N][N];
int mem[N][N],col[N];
int n,m;
vector<pair<int,int> > got;
int co[2];

int go(int node,int c)
{
	if(col[node]!=-1) return col[node]==c;
	col[node]=c;
	co[c]++;
	int ans=1;
	for(int i=1;i<=n;i++)
	{
		if(adj[node][i]||node==i) continue;
		ans&=go(i,c^1);
	}
	return ans;
}

int can(int x,int y)
{
	if(y<0) return 0;
	if(x==got.size()) return (y==0?1:0);
	if(mem[x][y]!=-1) return mem[x][y];
	return mem[x][y]=can(x+1,y-got[x].first)|can(x+1,y-got[x].second);
}

int main()
{
	scanf("%d %d",&n,&m);
	while(m--)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		adj[x][y]=adj[y][x]=1;
	}
	memset(col,-1,sizeof col);
	for(int i=1;i<=n;i++)
	{
		if(col[i]==-1)
		{
			co[0]=co[1]=0;
			if(!go(i,0))
			{
				printf("-1\n");
				return 0;
			}
			got.push_back({co[0],co[1]});
		}
	}
	int ans=(1<<30);
	for(int i=0;i<=n;i++)
	{
		int y=n-i;
		memset(mem,-1,sizeof mem);
		if(can(0,i)) ans=min(ans,i*(i-1)/2+y*(y-1)/2);
	}
	assert(ans!=(1<<30));
	printf("%d\n",ans);
}

Measured memory_bytes: 7728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



signed main(){
  int a,b;
  while(cin>>a>>b){
    int sum=a+b;
    int c=0;
    while(sum){
      sum=sum/10;
      c++;
    }
    cout<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 3064
from itertools import product
n, m, x = map(int,input().split())
A = []
C = []
for i in range(n):
    a = list(map(int,input().split()))
    C.append(a[0])
    A.append(a[1:])

total = float('inf')
ok = False
for pr in product([0, 1], repeat=n):
    tf = []
    for i in range(m):
        cnt = 0
        for j in range(n):
            if pr[j] == 1:
                cnt += A[j][i]
        if cnt >= x:
            tf.append(True)

    if len(tf) == m:
        ok = True
        ttl = 0
        for i,p in enumerate(pr):
            if p == 1:
                ttl += C[i]
        total = min(total, ttl)

if ok:
    print(total)
else:
    print(-1)

Measured memory_bytes: 9248
n, m = map(int, input().split())
p = [[] for _ in range(n)]
for i in range(m):
    j, y = map(int, input().split())
    p[j-1].append((y, i))
for i in range(n):
    p[i].sort()
r = [None]*m
for j in range(n):
    for x, (_, i) in enumerate(p[j]):
        r[i] = str(j+1).zfill(6) + str(x+1).zfill(6)
for s in r:
    print(s)

Measured memory_bytes: 35944
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);

  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n-1) cin>>c[i];
  
  ll ans=0;
  ll prev=-1;
  rep(i,n){
    //cout << a[i] <<"," << prev << endl;
    ans+=b[ a[i]-1 ];
    if( prev == a[i]-1 ) ans+=c[ prev-1 ];

    prev=a[i];
  }
  cout << ans << endl;


  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void program(); int main() {cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); program();}
#define endl "\n"
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>

#define N 22
#define BIG 5000000
#define MOD 1000000007

int g[N][N], dp[BIG];
int n,t;

int f(int i, int w) {
    if (i==n) return 1;
    if(dp[w] != -1) return dp[w];

    int res = 0;
    for(int j=0;j<n;j++) if(w&(1<<j) && g[i][j])
        res = (res + f(i+1, w&(~(1<<j))))%MOD;
    return dp[w] = res;
}

void program(){
    for(int j=0;j<BIG;j++) dp[j] = -1;

    cin>>n;
    for(int i=0;i<n;i++) for(int j=0;j<n;j++){
        cin>>t;
        g[i][j] = t;
    }
    int v=0;
    for(int i=0;i<n;i++) v = (v<<1)|1;
    cout <<f(0,v)<<endl;
}

/*
WA:
-bounds on loops
-truncating
-intialization
-0 vs 1 indexing

TLE:
-might need unordered_set/map
-infinite while loop

Stuck:
-different perspective?
-bruteforce?
-greedy?
-reduce dimensionality with problem contraints?
*/


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

using namespace std;

typedef long long ll;

const int N = 2e3 + 10;
const ll INF_of_ll = 1e17;

int n, x, a[N], b[N][N];

int getid(int x, int len) {
  if (x > len) return x - len;
  else return x - len + n;
}

int main() {
  scanf("%d %d", &n, &x);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    b[i][0] = a[i];
    for (int j = 1; j <= n; j++) {
      b[i][j] = min(b[i][j - 1], a[getid(i, j)]);
    }
  }
  ll ans = INF_of_ll;
  for (int k = 0; k <= n; k++) {
    ll res = 1ll * k * x;
    for (int i = 1; i <= n; i++) {
      res += b[i][k];
    }
    ans = min(ans, res);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x


using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

struct UnionFind {
    // UnionFind u(n) 宣言
    // u.unionSet(x,y) 併合
    // u.findSet(x,y) -> {true, false}
    // u.root(x) xのroot. data[x]を参照。併合前はxそのもの、併合後は同一union
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main() {
    int n,m;cin>>n>>m;
    vector<vector<int>> L(n+1);
    
    UnionFind langs(m+1);

    for(auto i = 1;i<=n;i++){
        int k;cin>>k;
        L[i].resize(k);cin>>L[i];
        for(auto l:L[i]){
            langs.unionSet(L[i][0],l);
        }
    }
    
    set<int> ulang;
    
    for(auto i=1;i<=m;i++){
        ulang.insert(langs.root(i));
    }
    
    vector<set<int>> langlist(m+1);

    for(auto i = 1;i<=n;i++){
        for(auto l:L[i]){
            langlist[langs.root(l)].insert(i);
        }
    }
    
    UnionFind u(n+1);
    
    for(auto i = 1;i<=m;i++){
        if(langlist[i].size()==0)continue;
        for(auto l:langlist[i]){
            u.unionSet(*langlist[i].begin(), l);
        }
    }
    
    for(auto i = 1; i<=n;i++){
        
        if(!u.findSet(1,i)) {
            cout<<"NO"<<endl;
            return 0;
        }
        
    }
    
    cout<<"YES"<<endl;
    
    
    return 0;
}




Measured memory_bytes: 20608
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;
int dx[8000] = {}, dy[8000] = {};

int main() {
	string S;
	cin >> S;
	int x, y;
	cin >> x >> y;
	int N = S.size();
	
	int d = 0, nx = 1, ny = 0;
	REP(i, N) {
		if (S[i] == 'T') {
			d++;
			if (d % 2 == 0) nx++;
			if (d % 2 == 1) ny++;
		}
		if (S[i] == 'F') {
			if (d % 2 == 0) dx[nx - 1]++;
			if (d % 2 == 1) dy[ny - 1]++;
		}
	}

	if (ny == 0) ny = 1;

	VVB dpx(nx, VB(16000 + 1, false)), dpy(ny, VB(16000 + 1, false));
	dpx[0][dx[0] + 8000] = true;
	
	FOR(i, 1, nx) {
		REP(j, 16000 + 1) {
			if (j + dx[i] <= 16000) dpx[i][j] = dpx[i - 1][j + dx[i]];
			if (j - dx[i] >= 0) if (!dpx[i][j]) dpx[i][j] = dpx[i - 1][j - dx[i]];
		}
	}

	dpy[0][dy[0] + 8000] = dpy[0][-dy[0] + 8000] = true;
	FOR(i, 1, ny) {
		REP(j, 16000 + 1) {
			if (j + dy[i] <= 16000) dpy[i][j] = dpy[i - 1][j + dy[i]];
			if (j - dy[i] >= 0) if(!dpy[i][j]) dpy[i][j] = dpy[i - 1][j - dy[i]];
		}
	}
	

	/*REP(i, 16000 + 1) if (dpx[nx - 1][i]) cout << i << " ";
	cout << endl;

	REP(i, 16000 + 1) if (dpx[ny - 1][i]) cout << i << " ";
	cout << endl;*/

	S = ((dpx[nx - 1][x + 8000])&&(dpy[ny - 1][y + 8000])) ? "Yes" : "No";
	cout << S << endl;;
	//cin >> S;

	return 0;
}


Measured memory_bytes: 16128
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<cstdio>
#include<ctime>

#define endl '\n'
#define ll long long
#define ull unsigned ll
#define x first
#define y second

using namespace std;

int main(){
    long long c=1;
    long long a,b;
    cin>>a>>b;
    while(a*2<=b){
        a*=2;
        c++;
    }
    cout<<c<<endl;
    return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n),b(n);
    set<int> x;
    set<int> y;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        if(a==0) x.insert(b);
        if(b==0) x.insert(a);
        if(a==n-1) y.insert(b);
        if(b==n-1) y.insert(a);
    }
    bool res=false;
    for(auto v:x){
        if(y.count(v)){
            res=true;
        }
    }
    cout<<(res? "POSSIBLE" : "IMPOSSIBLE")<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	string s;
	cin >> s;
	
	s[3] = '8';
	
	cout << s << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().strip().split()))
money=1000
stock=0
for n in range(N):
    if n<N-1:
        if A[n]<A[n+1]:
            if money>=A[n]:
                stock+=money//A[n]
                money%=A[n]
        else:
            money+=A[n]*stock
            stock=0
    else:
        money+=A[n]*stock
print(money)

Measured memory_bytes: 9016
#include<cstdio>
const int N=1005,INF=~0u>>2;
int b[N],n,vis[N],lk[N],even[N],odd[N],even_num,odd_num,ans,k,tot,tim,v[N][N];
int abs(int x){return x>0?x:-x;}
bool find(int x){
	vis[x]=tim;
	for(int i=1;i<=even_num;++i){
		if(v[x][i]&&vis[lk[i]]!=tim){
			if(!lk[i]||find(lk[i])) return lk[i]=x,1;
		}
	}
	return 0;
}
bool check(int x){
	if(x==1) return 0;
	for(int i=2;i*i<=x;++i){
		if(x%i==0) return 0;
	}
	return 1;
}
void solve(int x){
	if(x&1) odd[++odd_num]=x;
	else even[++even_num]=x;
}
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&b[i]);b[0]=-1;
	for(int i=1;i<=n;++i){
		if(b[i]!=b[i-1]+1) solve(b[i]);
		if(b[i]+1!=b[i+1]) solve(b[i]+1);
	}
	for(int i=1;i<=odd_num;++i)
		for(int j=1;j<=even_num;++j)
			if(check(abs(even[j]-odd[i]))) v[i][j]=1;
	for(int i=1;i<=odd_num;++i){
		tim++;
		if(find(i)) k++;
	}
	ans=k+((even_num-k)/2+(odd_num-k)/2)*2+((odd_num-k)%2)*3;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x; cin >> x;
    for(int i = x; ; i++){
        int count = 0;
        for(int j = 2; j <= i; j++){
            if(i % j ==  0) count++;
        }
        if(count ==1){
            cout << i;
            return 0;
        }
    }
}



Measured memory_bytes: 256
///
// File:  0528.go
// Author: ymiyamoto
//
// Created on Thu Mar 22 01:52:09 2018
//
package main

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

var S, T string
var dp [4001][4001]int

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for {
		scanner.Scan()
		S = scanner.Text()
		if len(S) == 0 {
			return
		}

		scanner.Scan()
		T = scanner.Text()

		for i := range dp {
			for j := range dp[i] {
				dp[i][j] = 0
			}
		}

		dp[0][0] = 0
		for i := range S {
			for j := range T {
				if S[i] == T[j] {
					dp[i+1][j+1] = dp[i][j] + 1
				} else {
					dp[i+1][j+1] = 0
				}
			}
		}

		var m int
		for i := range dp {
			for j := range dp[i] {
				m = max(m, dp[i][j])
			}
		}
		fmt.Println(m)
	}
}



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

using namespace std;

const int MAX_N = 7368792;

bool used[MAX_N];

int main()
{
    while(1){
        int m,n;
        cin >> m >> n;
        if(m == 0 && n == 0){
            break;
        }
        rep(i,MAX_N){
            used[i] = false;
        }
        int id = 0;
        for(int i = m; i < MAX_N; i++){
            if(!used[i]){
                id++;
                for(int j = i; j < MAX_N; j += i){
                    used[j] = true;
                }
                if(id == n){
                    break;
                }
            }
        }
        for(int i = m; i < MAX_N; i++){
            if(!used[i]){
                cout << i << "\n";
                break;
            }
        }
    }
}



Measured memory_bytes: 10292
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int MAX_M=10000;

int main(){
    ios::sync_with_stdio(false);
    int n,m;
    int a[MAX_M];
    cin >> n >> m;
    ll sum=0;
    rep(i,m){
        cin >> a[i];
        sum+=a[i];
    }
    if(n<sum) cout << -1<< endl;
    else cout << n-sum << endl;
    return 0;
}

Measured memory_bytes: 3680
N=int(input())
a=list(map(int, input().split()))
n=N//2
b=[None]*N
for i in range(n,N):
        b[i]=a[i]
for i in range(n-1,-1,-1):
        c=0
        t=2*i+1
        while t<N:
                if b[t]==1:
                        c+=1
                t+=(i+1)
        b[i]=(c+a[i])%2
print(b.count(1))
for i in range(N):
        if b[i]==1:
                print(i+1,end=" ")

Measured memory_bytes: 7148
/*
 *    author:  gantheory
 *    created: 2018-07-26 20:05:16
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using point = pair<int, int>;

const int N = 100 + 10;
const double EPS = 1e-6;

int n;
point p[N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  while (cin >> n) {
    if (n == 0) break;

    int ly = INT_MAX, ry = INT_MIN;
    for (int i = 0; i < n; ++i) {
      cin >> p[i].first >> p[i].second;
      p[i].first += 2000, p[i].second += 2000;
      ly = min(ly, p[i].second);
      ry = max(ry, p[i].second);
    }
    p[n] = p[0];

    int ans = 0;
    for (int y = ly; y < ry; ++y) {
      vector<bool> used(5000, false);
      auto cross = [&](double now_y) {
        vector<double> cp;
        for (int i = 0; i < n; ++i) {
          point lp = p[i];
          point rp = p[i + 1];
          if (lp.second > rp.second) swap(lp, rp);

          double low_x = lp.first, low_y = lp.second;
          double high_x = rp.first, high_y = rp.second;
          if (low_y <= now_y and now_y <= high_y) {
            double delta_x = (high_x - low_x);
            double cross_x =
                low_x + delta_x * (now_y - low_y) / (high_y - low_y);
            cp.push_back(cross_x);
          }
        }
        sort(cp.begin(), cp.end());
        return cp;
      };
      vector<double> p1 = cross(double(y) + EPS);
      vector<double> p2 = cross(double(y + 1) - EPS);
      for (int i = 0; i < (int)p1.size(); i += 2) {
        int lx = floor(min(p1[i], p2[i]));
        int rx = ceil(max(p1[i + 1], p2[i + 1]));
        for (int j = lx; j < rx; ++j)
          if (used[j] == false) ++ans, used[j] = true;
      }
    }
    cout << ans << '\n';
  }
}



Measured memory_bytes: 3116
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] l = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int ans = 0;
        for (int i = 0; i < n - 2; i++)
        {
            for (int j = i + 1; j < n - 1; j++)
            {

                if (l[i] == l[j])
                {
                    continue;
                }

                for (int k = j + 1; k < n; k++)
                {
                    if (l[i] == l[k] || l[j] == l[k])
                    {
                        continue;
                    }

                    if (Math.Abs(l[j] - l[k]) < l[i] && l[i] < l[j] + l[k])
                    {
                        ans++;
                    }
                }
            }
        }
        Console.WriteLine(ans);
    }
}

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

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

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

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

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

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

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

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

#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
       A: u32,
       B: u32,
       C: u32,
    }

    println!("{}", std::cmp::min(C, B/A));
}


Measured memory_bytes: 4352
class Point
  attr_reader :x, :y

  def initialize(x, y)
    @x=x
    @y=y
  end
end

# 1次関数(2点標準形)
def linear(p1, p2)
  lambda { |p| (p2.y-p1.y)*(p.x-p1.x)-(p2.x-p1.x)*(p.y-p1.y) }
end

# 包含判定
def inner?(p, poly)

  temp=poly+[poly[0]]

  a=linear(temp[0], temp[1]).call(p)
  1.upto(temp.size-2) do |i|
    b=a
    a=linear(temp[i], temp[i+1]).call(p)
    if ((a<0&&b<0)|| (a>0&&b>0))
      next
    else
      return false
    end
  end
  true
end

gets.to_i.times do

  ps = gets.split.map(&:to_f)

  p1=Point.new(ps[0], ps[1])
  p2=Point.new(ps[2], ps[3])
  p3=Point.new(ps[4], ps[5])
  poly=[p1, p2, p3]

  pa=Point.new(ps[6], ps[7]) # altair
  pv=Point.new(ps[8], ps[9]) # vega

  if inner?(pv, poly)
    unless inner?(pa, poly)
      puts :OK
      next
    end
  else
    if inner?(pa, poly)
      puts :OK
      next
    end
  end

  puts :NG

end

Measured memory_bytes: 6176
#include <stdio.h>
int main(void){
    int H, W, i, j;
    for (;;){
        scanf("%d",&H);
        scanf("%d",&W);
        if (H==0 && W==0)break;

        else{
            for ( i = 0; i < H; i++ ){
                for ( j = 0; j < W; j++ ){
                    if ( i%2 == 0){
                        if(j%2 != 0){
                        printf(".");
                        }else{
                            printf("#");
                        }
                    } else {
                        if (j%2 == 0){
                        printf(".");
                        }else{
                        printf("#");
                        }
                    }
                }
            printf("\n");
            }
        }
        printf("\n");
    }
    return 0;
    
}



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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, x;

bool read() {
    if (!(cin >> n >> x))
        return false;

    return true;
}

void solve() {
    int ans = 1;

    for (int i = 0, j = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans += (j += a) <= x;
    }

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int a[99999];
int main(void){
    int i,b;
    i=b=1;
    while(1){
        scanf("%d",&a[i]);
        if(a[i]==0) break;
        i++;
    }
    while(b<i){
        printf("Case %d: %d\n",b,a[b]);
        b++;
    }
	return 0;
}

Measured memory_bytes: 636