akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <valarray>
#include <string>
#include <algorithm>
#include <set>
#include <climits>
typedef unsigned long long ull;
typedef long long ll;
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define rep(i,n) for(ull i = 0;i<(n);i++)
#define rep1(i,n) for(ull i = 1;i<=(n);i++)
#define revrep(i,n) for(ull i = (n-1);i>=0;i--)
#define all(n) (n).begin(),(n).end()
#define show(x) cout << "debug " << #x << ":" << x << endl;
#define showvec(x) cout << endl << "debug " << #x << ";" << endl; \
    for(ull __i = 0;__i < x.size();__i++){ \
        for(ull __j = 0;__j<x[0].size();__j++){ \
            cout << x[__i][__j] << " "; \
        } \
        cout << endl; \
    } \
    cout << endl;
using namespace std;

vector<pair<int,int> > G[1002];
int V,E,r;
ll d[1002];
int main(){
	bool negative = false;
	rep(i,1002){
		d[i] = LLONG_MAX / 3;
	}
	cin >> V >> E >> r;
	rep(_e,E){
		int _s,_t,_d;
		cin >> _s >> _t >> _d;
		G[_s].push_back(make_pair(_t,_d));
	}
	d[r] = 0;
	rep(_v,V){
		rep(v1,V){
			rep(_e,G[v1].size()){
				pair<int,int> e = G[v1][_e];
				int v2 = e.first;
				if(d[v1] != LLONG_MAX / 3 && d[v2] > d[v1] + e.second){
					if(_v >= V - 1){
						negative = true;
						break;
					}
					d[v2] = d[v1] + e.second;
				}
			}
			if(negative) break;
		}
		if(negative) break;
	}

	if(negative){
		cout << "NEGATIVE CYCLE" << endl;
		return 0;
	}
	rep(i,V){
		if(d[i] == LLONG_MAX / 3){
			cout << "INF" << endl;
		}else{
			cout << d[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1260
from heapq import heappush, heappop
x,y,z,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

Q=[]
I=[]
heappush(Q,(-(A[0]+B[0]+C[0]),0,0,0))
for i in range(k):
    qmin,j,k,l=heappop(Q)    
    print(-qmin)

    xi=(j+1,k,l)
    yi=(j,k+1,l)
    zi=(j,k,l+1)

    if j+1<x and xi not in I:
        heappush(Q,(-(A[j+1]+B[k]+C[l]),)+xi)
        I.append(xi)
    if k+1<y and yi not in I:
        heappush(Q,(-(A[j]+B[k+1]+C[l]),)+yi)
        I.append(yi)
    if l+1<z and zi not in I:
        heappush(Q,(-(A[j]+B[k]+C[l+1]),)+zi)
        I.append(zi)


Measured memory_bytes: 4468
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  ll ans = 0;
  rep(i, N) {
    ans += a[i]/2;
    a[i] %= 2;
    if(i < N-1) {
      int tmp = min(a[i],a[i+1]);
      a[i] -= tmp;
      a[i+1] -= tmp;
      ans += tmp;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

struct Data {
	int data;
	int user;
};

bool checkLock(int data, Data lock[], Data wait[], int lockNum, int waitNum, bool check[]);

bool checkWait(int user, Data lock[], Data wait[], int lockNum, int waitNum, bool check[]) {
	if (check[user]) {
		return false;
	}
	bool checkCopy[101];
	for (int i = 0; i < 101; i++) {
		checkCopy[i] = check[i];
	}
	checkCopy[user] = true;

	for (int i = 0; i < waitNum; i++) {
		if (user == wait[i].user) {
			if (!checkLock(wait[i].data, lock, wait, lockNum, waitNum, checkCopy)) {
				return false;
			}
		}
	}
	return true;
}
bool checkLock(int data, Data lock[], Data wait[], int lockNum, int waitNum, bool check[]) {
	for (int i = 0; i < lockNum; i++) {
		if (data == lock[i].data) {
			if (!checkWait(lock[i].user, lock, wait, lockNum, waitNum, check)) {
				return false;
			}
		}
	}
	return true;
}


int main() {
	int N;
	int lockNum = 0;
	int waitNum = 0;
	bool check[101];
	Data lock[1000];
	Data wait[1000];

	int user;
	int data;
	string str;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> user >> str >> data;
		if (str == "lock") {
			lock[lockNum].data = data;
			lock[lockNum].user = user;
			lockNum++;
		}
		else {
			wait[waitNum].data = data;
			wait[waitNum].user = user;
			waitNum++;
		}
	}

	for (int i = 0; i < waitNum; i++) {
		for (int j = 0; j < 101; j++) {
			check[j] = false;
		}
		if (!checkWait(wait[i].user,lock,wait,lockNum,waitNum,check)) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int a, b;
  std::cin >> a >> b;
  string str = readString();
  REP(i, str.size()) {
    if (i != a && str[i] == '-') {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  if (str[a] == '-')
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
}


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

int main() {
    int n, a;
    cin >> n;
    vector<int> V;
    for (int i = 0; i < n; i++) {
        cin >> a;
        V.push_back(a);
    }

    ll sol = 0;
    int mmax = V[0];
    for (int i = 1; i < n; i++) {
        sol += max(0, mmax - V[i]);
        mmax = max(mmax, V[i]);
    }

    cout << sol;

}


Measured memory_bytes: 4316
#include<bits/stdc++.h>
#include<string>
#define rep(i,a,b) for(long long int i=(a);i<(b);i++)
#define se(a) a.begin(),a.end()
#define ll long long int
#define mll map<ll,ll>
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e16
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
//	ll tc;
//	cin>>tc;
//	while(tc--)
	{
		ll n;
		cin>>n;
		ll a[n];
		rep(i,0,n)
		cin>>a[i];
		ll sum=0;
		rep(i,0,n)
		sum+=a[i];
		bitset<4000005> dp;
		dp.set(0);
		
		for(int i=0;i<n;i++)
		dp=dp|dp<<a[i];
		ll x=(sum+1)/2;
		while(dp[x]==0)
		x++;
		cout<<x<<endl;
	}
}

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

int main(){
  int n , m;
  cin >> n >> m;
  int sum = 0;
  vector <int> vec (m);
  for(int i = 0 ; i < m;i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  if(n - sum >= 0){
    cout << n - sum << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}

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

using namespace std;

#define ll long long

void solve() {
	int n;
	cin >> n;
	int x = sqrt(n);
	cout << x * x << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3652
import collections
N = int(input())
lsA = list(map(int,input().split()))
counterA = collections.Counter(lsA)
lsline = []
for i in counterA.keys():
    if counterA[i] >= 2:
        lsline.append(i)
lsline.sort(reverse=True)
if bool(lsline):
    if counterA[lsline[0]] >= 4:
        ans = lsline[0]*lsline[0]
    elif len(lsline) < 2:
        ans = 0
    else:
        ans = lsline[0]*lsline[1]
else:
    ans = 0
print(ans)

Measured memory_bytes: 22148
n,y = map(int, input().split())

list = [-1, -1, -1]
for i in range(n+1):
    for j in range(n+1-i):
        k = n - i - j
        if y == i*10000 + j*5000 + k*1000:
            list = [i, j, k]
            break
print(list[0], list[1], list[2])


Measured memory_bytes: 3060
// ABC120_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B, K;
    cin >> A >> B >> K;
    
    // calculation
    vector<ll> vec;
    ll mx = max(A, B);
    for (ll i = 1; i <= mx; ++i) {
        if (A%i == 0 && B%i == 0) {
            vec.push_back(i);
        }
    }
    cout << vec[vec.size()-1-K+1] << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
    int num;
    std::cin >> num;
    std::vector<int> vec;

    for(int i = 0; i < num; ++i){
        int v;
        std::cin >> v;
        vec.push_back(v);
    }

    int maxDiff = vec[1] - vec[0];
    int min = std::min(vec[0], vec[1]);
    bool incremental = true;
    for(int i = 2; i < num; ++i){
        maxDiff = std::max(maxDiff, vec[i] - min);
        min = std::min(min, vec[i]);
    }

    std::cout << maxDiff << std::endl;
    return 0;
}



Measured memory_bytes: 3868
i,j = map(int,input().split())
a = [[] for x in range(i)]
for x in range(i):
    a[x] = list(map(int,input().split()))
b = [[0]*1 for x in range(j)]
for x in range(j):
    b[x] = int(input())

for x in range(i):
    ans = 0
    for y in range(j):
        ans += a[x][y]*b[y]
    print(ans)
    


Measured memory_bytes: 6016
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n;
    cin >> n;
    multiset<LL> a;
    for(LL i = 0; i < n; ++i){
        LL v;
        cin >> v;
        auto it = a.lower_bound(v);
        if(it != a.begin() && *(--it) < v){
            a.erase(it);
        }
        a.insert(v);
        //cerr << v << ", " << a.size() << endl;
    }
    cout << a.size() << endl;
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
#define ll long long
const ll mod = 1e9 + 7;
ll n, a[maxn], fac[maxn], inv[maxn];
ll qpow(ll x, ll n)
{
    ll ans = 1;
    while (n)
    {
        if (n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ans % mod;
}
void slove()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i)
        cin >> a[i];
    fac[1] = 1; fac[0] = 1, inv[1] = 1;
    for (ll i = 2; i <= n; ++ i)
    {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = (inv[i - 1] + qpow(i, mod - 2)) % mod;
    }
    ll ans = 0;
    for (int i = 1; i <= n; ++ i)
    {
        ll pre = i, sub = n - i + 1;
        ans += a[i] * (inv[pre] + inv[sub]) % mod;
        ans = (ans + mod - a[i]) % mod;
    }
    cout << ans * fac[n] % mod << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    slove();
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int n; cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    int ans = 0,tans=0;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i] >= arr[i+1]){
            tans++;
        }
        else{
            ans = max(tans,ans);
            tans = 0;
        }
    }
    ans = max(tans,ans);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stdio.h>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main() {
	int a, b;	cin >> a >> b;
	if (a - b * 2 < 0) { cout << 0 << endl; }
	else cout << a - b * 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];

  int res = 1e+9;
  rep1(i,100){
    int sum=0;
    rep(j,n){
      sum += (x[j]-i)*(x[j]-i);
    }
    sum = max(0,sum);
    res = min(res,sum);
  }
  cout << res << "\n";
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int i, n;
  n = s.size();
  for (i = 0; i < n; i++) {
    if (i % 2 == 0) {
      cout << s[i];
    }
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static int nowMin = Integer.MAX_VALUE;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        search(n,0,n);
        System.out.println(nowMin);
    }

    public static void search(int n,int c,int last){
        if(n == 0){
            if(nowMin > c)nowMin = c;
            return;
        }
        else if(n < 0||nowMin < c)return;
        int n9 = 0;
        int n6 = 0;
        for (int i = 1;Math.pow(9,i) <= last;++i){
            n9 = i;
        }
        for (int i = 1;Math.pow(6,i) <= last;++i){
            n6 = i;
        }
        for (int i = n9;i >= 1;--i){
            search(n - (int)Math.pow(9,i),c + 1,(int)Math.pow(9,i));
        }
        for (int i = n6;i >= 1;--i){
            search(n - (int)Math.pow(6,i),c + 1,(int)Math.pow(6,i));
        }
        int mm = c + n;
        if(nowMin > mm)nowMin = mm;
    }
}


Measured memory_bytes: 22840
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;

int main() {
	LL N, A, B;
	cin >> N >> A >> B;
	LL tmp = N / (A + B);
	LL sisa = N % (A + B);
	cout << tmp * A + min(sisa, A) << "\n";
}

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


using namespace std;

#include <vector>

vector<int> labels,deg,sizes;
vector<vector<int>> flist,blist;

//DFSでラベル付けを行う再起関数
void makeLabel(int node,int set) {
	if (labels[node] != -1) return;
	labels[node] = set;
	for (int n : flist[node]) {
		makeLabel(n, set);
	}
}

int main() {
	int N, M, K;

	cin >> N >> M >> K;
	labels.resize(N + 1,-1);
	deg.resize(N + 1, 0);
	flist.resize(N + 1,vector<int>());
	blist.resize(N + 1, vector<int>());


	//友達情報取得＆設定
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		deg[a]++;
		deg[b]++;
		flist[a].push_back(b);
		flist[b].push_back(a);
	}
	//ブロッキングペア取得&設定
	for (int i = 0; i < K; i++)
	{
		int c, d;
		cin >> c >> d;
		blist[c].push_back(d);
		blist[d].push_back(c);
	}

	//連結成分計算
	int nowLabel = 0;
	for (int i = 1; i <= N; i++) {
		if (labels[i] == -1) {
			makeLabel(i,nowLabel);
			nowLabel++;
		}
	}

	sizes.resize(nowLabel + 1,0);
	//各連結成分の大きさを計算
	for (int i = 1; i <= N; i++) {
		sizes[labels[i]]++;
	}

	//答え出力
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		ans = sizes[labels[i]]-1 - deg[i];
		//ブロッキングペアを除く
		for (int p:blist[i])
		{
			if (labels[p] == labels[i]) ans--;
		}

		cout << ans << " ";
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 12672
//Author:: Pham Ngoc Minh- Chuyen Thai Binh
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define fl float
#define db double
#define ii pair<ll,ll>
#define pii pair<ii,ii>
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define oo 10000000000001
#define ooo -1000000000001
#define bost  ios_base::sync_with_stdio(false); cin.tie(0);
string s;
int main()
{
    bost
    cin>>s;
    for(int i=0;i<s.length()-1;i++){
        if(s[i]==s[i+1]){
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
    return 0;
}
// I love Chuyen Thai Binh Verry much ! Now, you alaways in my code of me <3
// Chuyen Thai Binh La Nha :>>


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pa;
const int maxn=1;

inline ll rd(){
    ll x=0;char c=getchar();int neg=1;
    while(c<'0'||c>'9'){if(c=='-') neg=-1;c=getchar();}
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*neg;
}

ll N,M;

int main(){
    //freopen("","r",stdin);
	M=rd(),N=rd();
	ll ans=min(M,N/2)+max(0ll,(N-2*M)/4);
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
    var fp *os.File
    fp = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)
    var queue [][]int
    line, _, _ := reader.ReadLine()
    arr := strings.Split(string(line), " ")
    H, _ := strconv.Atoi(arr[0])
    W, _ := strconv.Atoi(arr[1])
    visited := make([][]int, H)

    for i := 0; i < H; i++ {
        line, _, _ = reader.ReadLine()

        for j, v := range line {
            visited[i] = append(visited[i], -1)

            if string(v) == "#" {
                var val []int
                val = append(val, i)
                val = append(val, j)
                queue = append(queue, val)
                visited[i][j] = 0
            }
        }
    }

    // BFS
    var dx [4]int
    var dy [4]int
    dx[0] = 0
    dx[1] = 0
    dx[2] = 1
    dx[3] = -1
    dy[0] = 1
    dy[1] = -1
    dy[2] = 0
    dy[3] = 0
    var now_x, now_y, next_x, next_y int
    var cnt int = 0

    for len(queue) > 0 {
        now_y = queue[0][0]
        now_x = queue[0][1]

        for i := 0; i < 4; i++ {
            next_y = queue[0][0] + dy[i]
            next_x = queue[0][1] + dx[i]

            if next_x >= 0 && next_x <= W - 1 &&
               next_y >= 0 && next_y <= H - 1 &&
               visited[next_y][next_x] == -1 {
               var val []int
               val = append(val, next_y)
               val = append(val, next_x)
               queue = append(queue, val)
               visited[next_y][next_x] = visited[now_y][now_x] + 1
               cnt = visited[next_y][next_x]
            }
        }

        queue = queue[1:]
    }

    fmt.Println(cnt)
}

Measured memory_bytes: 114944
#include<bits/stdc++.h>
using namespace std;
main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j)cout<<((i<b)^(j<a));
    cout<<"\n";
  }
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	string L = "";
	for_(i,0,26) L += char('a' + i);
	for_(i,0,26) L += char('A' + i);
	
	int n;
	while (cin >> n, n) {
		vector< int > k(n);
		for_(i,0,n) cin >> k[i];
		
		string s;
		cin >> s;
		
		int m = s.size();
		for_(i,0,m) {
			int pos = L.find(s[i]);
			s[i] = L[(pos - k[i%n] + 52) % 52];
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
	string s;
	cin>>n>>p;
	cin>>s;
	
	if(p==2){
		rep(i,n){
			if((s[i]-'0')%2==0)ans+=i+1;
		}
	}
	else if(p==5){
		rep(i,n){
			if((s[i]-'0')%5==0)ans+=i+1;
		}
	}
	else{
		vl S[p];
		a=0;
		k=1;
		S[0].push_back(1);
		rep(i,n){
			a=(a+(s[n-i-1]-'0')*k)%p;
			ans+=S[a%p].size();
			S[a%p].push_back(i);
			k=(k*10)%p;
		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 3332
s = gets.split("").map(&:to_i)

n = s.length

result = 0
(n-2).times do |i|
  if s[i] == s[i+1]
    result = result + 1

    if s[i+1].zero?
       s[i+1] = 1
    else
       s[i+1] = 0
    end
  end
end

puts result


Measured memory_bytes: 7676
#include<stdio.h>
#include<string.h>

int main(){
  char W[10],T[1000];
  int i,count=0;

  scanf("%s",W);
  while(1){
    scanf("%s",T);
    if(strcmp(T,"END_OF_TEXT")==0)break;

    for(i=0;i<strlen(T);i++)
      if(T[i] >= 'A' && T[i] <= 'Z')T[i] += 32;

    if(strcmp(T,W)==0)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 548
package main

import "fmt"

func main() {
	var n,a,b int
	fmt.Scan(&n,&a,&b)
	if a>b || (n==1 && a!=b){
		fmt.Println(0)
		return
	}
	mn:=(n-1)*a+b
	mx:=(n-1)*b+a
	fmt.Println(mx-mn+1)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------

int main(void) {
  ll n, w;
  cin >> n >> w;
  ll weight[n+1], value[n+1];
  rep(i,n){
    cin >> weight[i+1] >> value[i+1];
  }

  vec2ll dp;
  dp.resize(n+1, vector<ll>(100010));
  rep(i,100010){
    dp[0][i]=1e10;
  }
  rep(i,n+1){
    dp[i][0]=0;
  }

  // dp[i][j]
  // value >= j tonaru omosa no minimum
  // i: choose goods from 1, 2, ..., i
  // j: value

  ll ans=0;
  REP(i,1,n+1){
    //prt2("phase: ", i);
    rep(j,100010){
      if(j-value[i]>-1){
        dp[i][j]=min(dp[i-1][j], dp[i-1][j-value[i]]+weight[i]);
        //prt("1");
      } else {
        dp[i][j]=dp[i-1][j];
        //prt("2");
      }
      if(dp[i][j]<=w && ans<j){
        ans=j;
      }
    }
  }
/*
  rep(i,n+1){
    rep(j,7){
      cout << dp[i][j] << " ";
    }
    cout << "\n";
  }
*/

  prt(ans);
}


Measured memory_bytes: 80384
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  for (int c = 1; c <= 3; ++c) {
    if (a * b * c % 2 == 1) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
import itertools
L,R = map(int, input().split())
if (R - L) + 1 >= 2019:
        print(0)
        exit()
elif (R - L) + 1 >= 673:
        print(0)
        exit()

if (R - 1) * R < 2019:
        print(L * R)
        exit()


if L % 2019 == 0:
        print(0)
        exit()
elif L % 673 < R % 673:
        li = range(L, R + 1)
        cmb = list(itertools.combinations(li,2))
        ans = (R-1) * R
        for i,j in cmb:
                ans = min(ans, (i*j) % 2019)
        print(ans)

else:
        print(0)
        exit()


Measured memory_bytes: 10660
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 //	ios::sync_with_stdio(0);
 //   cin.tie(0);
    lli n,m,c;
    cin>>n>>m>>c;
    lli b[m];
    loop(i,0,m)cin>>b[i];
    lli ct=0;
    lli a[n][m];
    loop(i,0,n)loop(j,0,m)cin>>a[i][j];
    for(lli i=0;i<n;i++){
    	lli ans=0;
    	for(lli j=0;j<m;j++){
    		ans+=a[i][j]*b[j];
		}
		if(ans+c>0)ct++;
	}
    cout<<ct;
    
    
    return 0;
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int32_t main() {
	FIO;



	int n , k ;
	cin >> n >> k ;
	vi a(n);
	for (int i = 0 ; i < n ; i++) {
		cin >> a[i];
	}

	int count = 1;
	int i = k ;
	while (i < n) {
		i += (k - 1);
		count++;
	}
	cout << count;












	return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>
int main()
{
int i,n;
long long oddc=0,evenc=0;
long long odds=0,evens=0,a[100001];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lld",&a[i]);
odds+=a[i];
evens+=a[i];
  if(i%2==0){
    if(odds<=0){
    oddc=oddc+1-odds;
    odds=1;
    }
    if(evens>=0){
    evenc=evenc+1+evens;
    evens=-1;
    }
  }else{
    if(odds>=0){
    oddc=oddc+1+odds;
    odds=-1;
    }
    if(evens<=0){
    evenc=evenc+1-evens;
    evens=1;
    }
  }
}
if(oddc<evenc){
printf("%lld",oddc);
}else{
printf("%lld",evenc);
}
return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  uli x,s=0;
  cin>>x;
  for(uli i=1;s<x;i++){
    s+=i;
    if(s>=x){
      printf("%lld\n",i);
      return 0;
    }
  }
  return 0;
}


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

#define int long long 

#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define pb push_back
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MP make_pair
#define sqr(x) ((x) * (x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 100;
const int MOD = 1e9 + 7;
int fact[N], inv_fact[N], inv[N];

void add(int &x, int y) {
	x += y;
	if (x >= MOD) x -= MOD;
}

int mul(int a, int b) {
	return 1ll * a * b % MOD;
}

int C(int n, int k) {
	return mul(fact[n], mul(inv_fact[k], inv_fact[n - k]));
}

int get(int x1, int y1, int x2, int y2) {
	int x = x2 - x1;
	int y = y2 - y1;
	assert(x >= 0 && y >= 0);
	if (x == 0 || y == 0) return 1;
	return C(x + y, y);
}

signed main() {
	fastio;
	#ifdef FlameDragon
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	
	int n, m, a, b;
	cin >> n >> m >> a >> b;
	inv_fact[0] = inv_fact[1] = fact[0] = fact[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < N; i++) {
		inv[i] = (MOD - mul(MOD / i, inv[MOD % i])) % MOD;
		fact[i] = mul(fact[i - 1], i);
		inv_fact[i] = mul(inv_fact[i - 1], inv[i]);
		assert(mul(inv[i], i) == 1); 
		assert(mul(fact[i], inv_fact[i]) == 1);
	}	
	int ans = 0;
	for (int i = 1; i <= n - a; i++) {
		int j = b + 1;
		int val = mul(get(1, 1, i, j - 1), get(i, j, n, m));
		add(ans, val);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 8352
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int color(int pt) {
  if (pt <= 399) {
    return 1;
  } else if (pt <= 799) {
    return 2;
  } else if (pt <= 1199) {
    return 3;
  } else if (pt <= 1599) {
    return 4;
  } else if (pt <= 1999) {
    return 5;
  } else if (pt <= 2399) {
    return 6;
  } else if (pt <= 2799) {
    return 7;
  } else if (pt <= 3199) {
    return 8;
  } else {
    return 0;
  }
}

int main() {
  //
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, n) {
    int a;
    cin >> a;
    int col = color(a);
    if (mp.find(col) == mp.end()) {
      mp[col] = 1;
    } else {
      mp[col]++;
    }
  }
  int m = 0, M = 0;
  for (auto& x : mp) {
    if (x.first == 0) continue;
    m++;
    M++;
  }
  if (mp.find(0) != mp.end()) {
    if (m == 0) {
      m = 1;
      M = mp[0];
    } else {
      M += mp[0];
    }
  }
  cout << m << " " << M << endl;
  return 0;
}


Measured memory_bytes: 256
def binarySearch(r, n, key):
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if r[mid] == key:
            return True
        elif key < r[mid]:
            right = mid
        else:
            left = mid + 1
    return False

n = int(input())
L = list(map(int, input().split()))
q = int(input())
Key = list(map(int, input().split()))
cnt = 0

for i in range(q):
    if binarySearch(L, n, Key[i]):
        cnt += 1
print(cnt)

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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize
    }
    let mut k = 1;
    while k * (k - 1) / 2 < n {
        k += 1;
    }
    if k * (k - 1) / 2 > n {
        println!("No");
        return;
    }
    println!("Yes");
    println!("{}", k);
    for i in 0..k {
        print!("{}", k - 1);
        for j in 0..k {
            if i == j {
                continue;
            }
            let x = std::cmp::min(i,j);
            let y = std::cmp::max(i,j);
            print!(" {}", x * k + y + 1 - (x + 1) * (x + 2) / 2);
        }
        println!("");
    }
}


Measured memory_bytes: 5500
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;   
    return 0;
}

Measured memory_bytes: 3232
import sys
from math import sqrt
from itertools import permutations

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    XY = [LIST() for _ in range(N)]

    pmt = list(permutations(range(N)))

    dist = 0
    for p in pmt:
        for cur, nxt in zip(p[:N-1], p[1:]):
            dist += sqrt((XY[nxt][0] - XY[cur][0])**2 + (XY[nxt][1] - XY[cur][1])**2)

    print(dist/len(pmt))


if __name__ == '__main__':
    main()

Measured memory_bytes: 46956
#include <iostream>


using namespace std;


using ll = long long;


const ll MAX = 100;

bool adj[MAX + 1][MAX + 1] = {};
bool visited[MAX + 1] = {};
ll d[MAX + 1], f[MAX + 1];
ll n;
ll t = 1;


void dfs(ll now)
{
    visited[now] = true;
    d[now] = t++;
    for (ll i = 1; i <= n; i++) {
        if (!adj[now][i])
            continue;
        if (visited[i])
            continue;

        dfs(i);
    }
    f[now] = t++;
}


int main()
{
    cin >> n;
    for (ll i = 0; i < n; i++) {
        ll u, k;
        cin >> u >> k;
        for (ll j = 0; j < k; j++) {
            ll v;
            cin >> v;
            adj[u][v] = true;
        }
    }

    for (ll i = 1; i <= n; i++) {
        if (!visited[i])
            dfs(i);
    }

    for (ll i = 1; i <= n; i++) {
        cout << i << " " << d[i] << " " << f[i] << endl;
    }
}



Measured memory_bytes: 3104
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <set>
#include <map>
#define SIZE 100005

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

char str[SIZE];
int rnk[SIZE];
int sa[SIZE];
int lcp[SIZE];
PP tmp[SIZE];
int imos[SIZE];

int main()
{
	scanf("%s",&str);
	int n=strlen(str);
	for(int i=0;i<n;i++) rnk[i]=str[i]-'a';
	for(int k=1;k<=n;k<<=1)
	{
		for(int i=0;i<n;i++)
		{
			tmp[i]=PP(P(rnk[i],i+k<n?rnk[i+k]:-1),i);
		}
		sort(tmp,tmp+n);
		for(int i=0;i<n;)
		{
			int f=i;
			for(;i<n&&tmp[i].first==tmp[f].first;i++)
			{
				rnk[tmp[i].second]=f;
			}
		}
	}
	for(int i=0;i<n;i++) sa[rnk[i]]=i;
	int H=0;
	for(int i=0;i<n;i++)
	{
		if(H>0) H--;
		if(rnk[i]==n-1) continue;
		int to=sa[rnk[i]+1];
		while(i+H<n&&to+H<n&&str[i+H]==str[to+H]) H++;
		imos[H]++;
	}
	for(int i=n-1;i>=1;i--) imos[i]+=imos[i+1];
	int ret=0;
	for(int i=1;i<=n;i++)
	{
		ret=max(ret,(n-i+1)-imos[i]);
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 2688
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL;
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

void printv(vector<int> v){
    rep(i,0,v.size())cout<<v[i]<<" ";
    cout<<endl;
}

int main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    vector<int> v(n),vv(m);
    rep(i,0,n)cin>>v[i];
    rep(i,0,m)cin>>vv[i];
    Sort(v); Sort(vv);
    int z=v[v.size()-1]+1;

    rep(i,v[v.size()-1]+1,vv[0]+1){
        if(x<i&&i<=y){
            cout<<"No War"<<endl;
            return 0;
        }
    }
    cout<<"War"<<endl;
    
    
    




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N, M; cin >> N >> M;
  vi L(M); vi R(M);
  rep(i,M) cin >> L[i] >> R[i];
  int a=1; int b=N;
  rep(i,M){
    a = max(a,L[i]);
    b = min(b,R[i]);
  }
  cout << max(b - a + 1, 0) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N,0);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i == a[a[i]-1]-1) {
			ans++;
		}
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 640
a, b, m = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))

t = []
for i in range(m):
    x, y, c = map(int, input().split())
    t.append(al[x-1]+bl[y-1]-c)
a_min = min(al)
b_min = min(bl)
t.append(a_min+b_min)

print(min(t))


Measured memory_bytes: 73112
n=int(input())
def factorize(n):
    fct=[]
    b,e=2,0
    while b*b<=n:
        while n%b==0:
            n=n//b
            e=e+1
        if e>0:
            fct.append((b,e))
        b,e=b+1,0
    if n>1:
        fct.append((n,1))
    return fct
l=factorize(n)
ans=0
for i,j in l:
    ans+=int((-1+pow(1+8*j,0.5))/2)
print(ans)










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

int main(){
  ll n,k; cin >> n >> k;
  if(k>=n){
    cout << 0; return 0;
  }
  ll ret=0;
  priority_queue<ll> q;
  rep(i,n){
    ll a; cin >> a;
    q.push(a); 
  }
  while(k>0 && q.size()>0){
    ll t = q.top();
    q.pop();
    k--;
  }
  while(q.size()>0){
    ll t = q.top();
    q.pop();
    ret+=t;
  }
  cout << ret;

}

Measured memory_bytes: 2420
/* ABC099_B
    Stuartyg */

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
int snowfall(int a, int b);

int main(void){
        int west_height,east_height; /*a,bのこと*/
        scanf("%d %d",&west_height,&east_height); /*標準入力から受け取る*/

        printf("%d\n",snowfall(west_height,east_height));
        /*関数snow_fallにwest_heightの値とeast_heightの値を代入*/
        return 0;
}

int snowfall(int a, int b){
        int snow_amount; /*求める積雪量*/
        
        /*与えられた西側の塔が西からi番目にあるとすると、東側の塔との高さの差b-a = i+1
        だから、本来の西側の塔の高さは
        1/2* i * (i+1) = (b-a-1) * (b-a) / 2
        よって雪が積もった高さは　（本来の高さ）- a*/

        snow_amount = (b-a-1) * (b-a) / 2 - a;
        return snow_amount;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++)
		if (s[i] == 'C')
			for (int j = i + 1; j < s.length(); j++)
				if (s[j] == 'F')
				{
					cout << "Yes" << endl;
					return 0;
				}
	cout << "No" << endl;
				
}
	

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

using namespace std;

#define DIM 100007
#define INF 1e11+9
#define MODULO 1000000007
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<int,int>
#define fi first
#define se second

int i,j,k,l,n,m,mini,maxi,res;

int a[109],dp2[DIM],dp1[DIM];

int get(int k){
    if(k==0)return 1;
    if(k<0)return 0;
    return dp1[k];
}

int main()
{
    cin>>n>>maxi;
    mini=maxi;
    for(i=1;i<=n;i++)cin>>a[i];

    memset(dp1,0,sizeof(dp1));
    res=0;

    dp1[0]=1;

    for(i=1;i<=maxi;i++)dp1[i]=1;

    for(i=1;i<=n;i++){
        for(j=0;j<=maxi;j++){
            k=(dp1[j]-get(j-min(j,a[i])-1))%MODULO;
            if(k<0)k+=MODULO;
            dp2[j]=(k+dp2[j-1])%MODULO;
        }
        for(j=0;j<=maxi;j++)dp1[j]=dp2[j];
    }

    k=dp1[maxi]-get(mini-1);
    if(k<0)k+=MODULO;

    cout<<k<<endl;

    return 0;
}


Measured memory_bytes: 1024